#include <err.h>
#include <limits.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void fill_date(entry)
DIRECTORY *entry;
{
- register long cur_time = time((long *) 0) - DOS_TIME;
+ register long cur_time = time(NULL) - DOS_TIME;
unsigned short year = 0, month = 1, day, hour, minutes, seconds;
int i;
long tmp;
#endif
/* everybody but Amiga wants lseek declared here */
-#if !AMIGA
+/* LSC: MINIX Does not want it either! */
+#if !AMIGA && !defined(__minix)
extern long lseek();
#endif
if (rflag) {
if (aflag) usage();
if ((argc - i) != 1) usage();
- fprintf(stderr, "%s: -r is not yet implemented\n");
+ fprintf(stderr, "%s: -r is not yet implemented\n", __func__);
exit(1);
} else {
if ((argc - i) < 1) usage();
- if (aflag) fprintf(stderr, "%s: -a is not yet implemented\n");
+ if (aflag) fprintf(stderr, "%s: -a is not yet implemented\n", __func__);
device= argv[i++];
geometry();
int main ( int argc, char *argv[] )
{
int i, r, audio, file;
- char *buffer, *file_name;
+ char *buffer, *file_name = NULL;
unsigned int sign;
unsigned int fragment_size;
unsigned int channels;
{
char *name;
int r, f, err;
- struct partition geometry;
name= finddev(device);
if ((f= open(name, O_RDONLY)) < 0) return -1;
struct stat hdst;
struct partition whole, entry;
struct part_entry table[4], *pe;
- int drive, par, device, incr;
+ int drive, par = 0, device, incr;
int partf;
char *table_file;
int hd_major, hd_minor;
COMMON_DIR:=${.PARSEDIR}
.if defined(__MINIX)
COMMON_CODEDIRS=atomic gen inet md net quad stdlib string
-COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160
.else
COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string sys
-COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 hash/murmurhash
.endif
+COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 hash/murmurhash
.if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \
exists(${COMMON_DIR}/arch/${COMMON_MACHINE_ARCH})
-/* $NetBSD: atomic_add_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_add_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
strex ip, r2, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return old value */
END(_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
strex r2, r0, [r3] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
--- /dev/null
+/* $NetBSD: atomic_add_64.S,v 1.3 2012/09/13 00:36:12 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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_add_64)
+ str r4, [sp, #-4]! /* save temporary */
+ mov r4, r0 /* need r0 for return value */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+1: ldrexd r0, [r4] /* load old value (to be returned) */
+ adds NLO, LO, NLO /* calculate new value */
+ adc NHI, HI, NHI /* calculate new value */
+ strexd ip, r2, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return old value */
+ END(_atomic_add_64)
+ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
+
+ENTRY_NP(_atomic_add_64_nv)
+ str r4, [sp, #-4]! /* save temporary */
+ mov r4, r0 /* need r0 for return value */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+1: ldrexd r0, [r4] /* load old value */
+ adds LO, LO, NLO /* calculate new value lo */
+ adc HI, HI, NHI /* calculate new value hi */
+ strexd ip, r0, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return new value */
+ END(_atomic_add_64_nv)
+ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
+
+#endif /* _ARM_ARCH_6 */
-/* $NetBSD: atomic_and_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_and_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
strex ip, r2, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return old value */
END(_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
strex r2, r0, [r3] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
--- /dev/null
+/* $NetBSD: atomic_and_64.S,v 1.2 2012/09/13 00:36:12 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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_and_64)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value (to be returned) */
+ and r2, r0, r2 /* calculate new value */
+ and r3, r1, r3 /* calculate new value */
+ strexd ip, r2, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return old value */
+ END(_atomic_and_64)
+ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
+
+ENTRY_NP(_atomic_and_64_nv)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value */
+ and r0, r0, r2 /* calculate new value */
+ and r1, r1, r3 /* calculate new value */
+ strexd ip, r0, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return new value */
+ END(_atomic_and_64_nv)
+ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
+
+#endif /* _ARM_ARCH_6 */
-/* $NetBSD: atomic_cas_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_cas_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
strex ip, r2, [r3] /* store new value */
cmp ip, #0 /* succeed? */
bne 1b /* nope, try again. */
- RET /* yes, return. */
+#ifdef _ARM_ARCH_7
+ dsb
+#else
+ mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
+#endif
+ RET /* return. */
END(_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
+ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
+ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
+ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
+ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
+STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
+STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
+STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
+STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
#endif /* _ARCH_ARM_6 */
--- /dev/null
+/* $NetBSD: atomic_cas_64.S,v 1.1 2012/09/11 20:51: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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#if defined(_ARM_ARCH_6)
+/*
+ * ARMv6 has load-exclusive/store-exclusive which works for both user
+ * and kernel.
+ */
+ENTRY_NP(_atomic_cas_64)
+ stmfd sp!, {r4, r5, r6} /* save temporaries */
+ mov r6, r0 /* we need r0 for return value */
+#ifdef __ARM_EABI__
+ ldrd r4, [sp] /* fetch new value */
+#else
+ ldr r5, [sp, #4] /* fetch new value */
+ ldr r4, [sp, #0] /* fetch new value */
+ mov r3, r2 /* r2 will be overwritten by r1 which ... */
+ mov r2, r1 /* r1 will be overwritten by ldrexd */
+#endif
+1:
+ ldrexd r0, [r6] /* load current value */
+ teq r0, r2 /* compare to old? 1st half */
+ teqeq r1, r3 /* compare to old? 2nd half */
+ bne 2f /* jump to return if different */
+ strexd ip, r4, [r6] /* store new value */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* nope, try again. */
+#ifdef _ARM_ARCH_7
+ dsb
+#else
+ mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
+#endif
+2:
+ ldmfd sp!, {r4, r5, r6} /* restore temporaries */
+ RET /* return. */
+ END(_atomic_cas_64)
+
+ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
+
+#endif /* _ARCH_ARM_6 */
-/* $NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $ */
+/* $NetBSD: atomic_cas_8.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
-RCSID("$NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $")
+#include "atomic_op_asm.h"
-ENTRY(atomic_cas_8)
- XPUSH {r4,r5} /* we need some more registers */
- and r3, r0, #3 /* which byte do we replace? */
-#if __ARMEB__
- eor r3, r3, #3 /* bytes are reversed on BE */
+#if defined(_ARM_ARCH_6)
+/*
+ * ARMv6 has load-exclusive/store-exclusive which works for both user
+ * and kernel.
+ */
+ENTRY_NP(_atomic_cas_8)
+ mov r3, r0 /* we need r0 for return value */
+1:
+ ldrexb r0, [r3] /* load old value */
+ teq r0, r1 /* compare? */
+ RETc(ne) /* return if different */
+ strexb ip, r2, [r3] /* store new value */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* nope, try again. */
+#ifdef _ARM_ARCH_7
+ dsb /* data synchronization barrier */
+#else
+ mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
#endif
- mov r3, r3, lsl #3 /* multiply by 8 */
- mov r1, r1, lsl r3 /* mov old value to correct byte */
- eor r2, r1, r2, lsl r3 /* move new value to correct byte */
-/* eor r2, r2, r1 */ /* new value is now (old ^ new) */
- mov r5, #0xff /* load mask */
- mov r5, r5, lsl r3 /* and move to correct byte */
- mov r3, r0 /* move pointer */
+ RET /* return. */
+ END(_atomic_cas_8)
-1: ldrex r4, [r3] /* load 32bit value */
- and r0, r4, r5 /* clear other bytes */
- teq r0, r1 /* equal old value? */
- bne 2f /* nope, bail. */
- eor r4, r4, r2 /* new == old ^ (old ^ new) */
- strex ip, r4, [r3] /* attempt to store it */
- cmp ip, #0 /* succeed? */
- bne 1b /* nope, try again. */
+ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8)
+STRONG_ALIAS(_atomic_cas_char,_atomic_cas_8)
+STRONG_ALIAS(_atomic_cas_uchar,_atomic_cas_8)
-2: XPOP {r4,r5} /* don't need these anymore */
- and r1, r3, #3
-#if __ARMEB__
- eor r1, r1, #3
-#endif
- mov r0, r0, lsr r1 /* shift it back to lsb byte */
- RET
+#endif /* _ARCH_ARM_6 */
-/* $NetBSD: atomic_dec_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_dec_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
strex r3, r1, [r2] /* try to store */
cmp r3, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
strex r1, r0, [r2] /* try to store */
cmp r1, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
--- /dev/null
+/* $NetBSD: atomic_dec_64.S,v 1.2 2012/09/13 00:36:12 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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_dec_64)
+ mvn r2, #0
+ mov r3, r0 /* need r0 for return value */
+1: ldrexd r0, [r3] /* load old value (return value) */
+ adds LO, LO, r2 /* calculate new value */
+ adc HI, HI, r2 /* calculate new value */
+ strexd ip, r0, [r3] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ adds LO, LO, #1
+ adc HI, HI, #0
+ RET /* return old value */
+ END(_atomic_dec_64)
+ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
+
+ENTRY_NP(_atomic_dec_64_nv)
+ mvn r2, #0
+ mov r3, r0 /* need r0 for return value */
+1: ldrexd r0, [r3] /* load old value */
+ adds LO, LO, r2 /* calculate new value */
+ adc HI, HI, r2 /* calculate new value */
+ strexd ip, r0, [r3] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ RET /* return new value */
+ END(_atomic_dec_64_nv)
+ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
+
+#endif /* _ARM_ARCH_6 */
-/* $NetBSD: atomic_inc_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_inc_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
strex r3, r1, [r2] /* try to store */
cmp r3, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
strex r1, r0, [r2] /* try to store */
cmp r1, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
--- /dev/null
+/* $NetBSD: atomic_inc_64.S,v 1.2 2012/09/13 00:36:12 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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_inc_64)
+ mov r3, r0 /* need r0 for return value */
+1: ldrexd r0, [r3] /* load old value (return value) */
+ adds LO, LO, #1 /* calculate new value */
+ adc HI, HI, #0 /* zero means we carried */
+ strexd ip, r0, [r3] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ mvn r2, #0 /* r2 = -1 */
+ adds LO, LO, r2 /* add it */
+ adc HI, HI, r2 /* add with carry */
+ RET /* return orig value */
+ END(_atomic_inc_64)
+ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
+
+ENTRY_NP(_atomic_inc_64_nv)
+ mov r3, r0 /* need r0 for return value */
+1: ldrexd r0, [r3] /* load old value */
+ add LO, LO, #1 /* calculate new value (return value) */
+ adc HI, HI, #0 /* fold carry into high */
+ strexd ip, r0, [r3] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ RET /* return new value */
+ END(_atomic_inc_64_nv)
+ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
+
+#endif /* _ARCH_ARM_6 */
-/* $NetBSD: atomic_op_asm.h,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_op_asm.h,v 1.3 2012/09/11 20:51:25 matt Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
#endif /* _KERNEL */
+#ifdef __ARMEB__
+#define HI r0
+#define LO r1
+#define NHI r2
+#define NLO r3
+#else
+#define LO r0
+#define HI r1
+#define NLO r2
+#define NHI r3
+#endif
+
#endif /* _ATOMIC_OP_ASM_H_ */
-/* $NetBSD: atomic_or_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
+/* $NetBSD: atomic_or_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
strex ip, r2, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return old value */
END(_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
strex r2, r0, [r3] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET /* return new value */
END(_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
--- /dev/null
+/* $NetBSD: atomic_or_64.S,v 1.2 2012/09/13 00:36:12 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 <matt@3am-software.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+#ifdef _ARM_ARCH_6
+
+ENTRY_NP(_atomic_or_64)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value (to be returned) */
+ orr r2, r0, r2 /* calculate new value */
+ orr r3, r1, r3 /* calculate new value */
+ strexd ip, r2, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return old value */
+ END(_atomic_or_64)
+ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
+
+ENTRY_NP(_atomic_or_64_nv)
+ str r4, [sp, #-4]! /* save temporary */
+#ifndef __ARM_EABI__
+ mov r3, r2
+ mov r2, r1
+#endif
+ mov r4, r0 /* need r0 for return value */
+1: ldrexd r0, [r4] /* load old value */
+ orr r0, r0, r2 /* calculate new value (return value) */
+ orr r1, r1, r3 /* calculate new value (return value) */
+ strexd ip, r0, [r4] /* try to store */
+ cmp ip, #0 /* succeed? */
+ bne 1b /* no, try again? */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET /* return new value */
+ END(_atomic_or_64_nv)
+ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
+
+#endif /* _ARM_ARCH_6 */
-/* $NetBSD: atomic_swap.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
+/* $NetBSD: atomic_swap.S,v 1.4 2012/08/31 23:41:52 matt Exp $ */
/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007,2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* 2. Redistributions in binary form must reproduce 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
#include "atomic_op_asm.h"
+/*
+ * While SWP{B} is sufficient on its own for pre-ARMv7 CPUs, on MP ARMv7 cores
+ * SWP{B} is disabled since it's no longer atomic among multiple CPUs. They
+ * will actually raise an UNDEFINED exception.
+ *
+ * So if we use the LDREX/STREX template, but use a SWP instruction followed
+ * by a MOV instruction (using a temporary register), that gives a handler
+ * for the SWP UNDEFINED exception enough information to "patch" this instance
+ * SWP with correct forms of LDREX/STREX. (note that this would happen even
+ * "read-only" pages. If the page gets tossed, we will get another exception
+ * and fix yet again).
+ */
+
ENTRY_NP(_atomic_swap_32)
- swp r0, r1, [r0]
+ mov r2, r0
+1:
+#ifdef _ARM_ARCH_6
+ ldrex r0, [r2]
+ cmp r0, r1
+ strexne ip, r1, [r2]
+#else
+ swp r0, r1, [r2]
+ cmp r0, r1
+ movsne ip, #0
+#endif
+ cmpne ip, #0
+ bne 1b
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET
END(_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
ENTRY_NP(_atomic_swap_8)
- swpb r0, r1, [r0]
+ mov r2, r0
+1:
+#ifdef _ARM_ARCH_6
+ ldrexb r0, [r2]
+ strexb r3, r1, [r2]
+#else
+ swpb r0, r1, [r2]
+ mov r3, #0
+#endif
+ cmp r3, #0
+ bne 1b
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
RET
END(_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
-STRONG_ALIAS(_atomic_swap_char,_atomic_swap_32)
-STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_32)
+STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8)
+STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8)
--- /dev/null
+/* $NetBSD: atomic_swap_64.S,v 1.2 2012/09/13 00:36:12 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.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_64)
+ str r4, [sp, #-4]! /* save temporary */
+ mov r4, r0 /* return value will be in r0 */
+#ifndef __ARM_EABI__
+ mov r3, r2 /* r2 will be overwriten by r1 */
+ mov r2, r1 /* and r1 will be overwritten by ldrexd */
+#endif
+1:
+ ldrexd r0, [r4] /* load old value */
+ strexd ip, r2, [r4] /* store new value */
+ cmpne ip, #0 /* succeed? */
+ bne 1b /* no, try again */
+#ifdef _ARM_ARCH_7
+ dmb
+#else
+ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
+#endif
+ ldr r4, [sp], #4 /* restore temporary */
+ RET
+ END(_atomic_swap_64)
+ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
-/* $NetBSD: membar_ops.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
+/* $NetBSD: membar_ops.S,v 1.3 2012/08/16 16:49:10 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
#ifdef _ARM_ARCH_6
ENTRY_NP(_membar_producer)
+#ifdef _ARM_ARCH_7
+ dsb
+#else
mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */
+#endif
RET
END(_membar_producer)
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
STRONG_ALIAS(_membar_write,_membar_producer)
ENTRY_NP(_membar_sync)
+#ifdef _ARM_ARCH_7
+ dmb
+#else
mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */
+#endif
RET
END(_membar_sync)
ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
-/* $NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+/* $NetBSD: divsi3.S,v 1.3 2012/10/10 02:16:54 christos Exp $ */
/*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* which makes a C call
*/
-ENTRY(__umodsi3)
- stmfd sp!, {lr}
- sub sp, sp, #4 /* align stack */
- bl .L_udivide
- add sp, sp, #4 /* unalign stack */
- mov r0, r1
- ldmfd sp!, {pc}
-
-ENTRY(__modsi3)
- stmfd sp!, {lr}
- sub sp, sp, #4 /* align stack */
- bl .L_divide
- add sp, sp, #4 /* unalign stack */
- mov r0, r1
- ldmfd sp!, {pc}
-
.L_overflow:
#if !defined(_KERNEL) && !defined(_STANDALONE)
mov r0, #8 /* SIGFPE */
#endif
RET
+ENTRY_NP(__aeabi_uidivmod)
+ENTRY_NP(__aeabi_uidiv)
ENTRY(__udivsi3)
.L_udivide: /* r0 = r0 / r1; r1 = r0 % r1 */
eor r0, r1, r0
mov r1, #0
RET
+ENTRY_NP(__aeabi_idivmod)
+ENTRY_NP(__aeabi_idiv)
ENTRY(__divsi3)
.L_divide: /* r0 = r0 / r1; r1 = r0 % r1 */
eor r0, r1, r0
--- /dev/null
+/* $NetBSD: modsi3.S,v 1.1 2012/10/10 02:16:54 christos Exp $ */
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * stack is aligned as there's a possibility of branching to .L_overflow
+ * which makes a C call
+ */
+
+ENTRY(__modsi3)
+ stmfd sp!, {lr}
+ sub sp, sp, #4 /* align stack */
+ bl PIC_SYM(__divsi3, PLT)
+ add sp, sp, #4 /* unalign stack */
+ mov r0, r1
+ ldmfd sp!, {pc}
+
--- /dev/null
+/* $NetBSD: umodsi3.S,v 1.1 2012/10/10 02:16:54 christos Exp $ */
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * stack is aligned as there's a possibility of branching to .L_overflow
+ * which makes a C call
+ */
+
+ENTRY(__umodsi3)
+ stmfd sp!, {lr}
+ sub sp, sp, #4 /* align stack */
+ bl PIC_SYM(__udivsi3, PLT)
+ add sp, sp, #4 /* unalign stack */
+ mov r0, r1
+ ldmfd sp!, {pc}
--- /dev/null
+/*-
+ * 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 <sys/cdefs.h>
+
+__RCSID("$NetBSD: __aeabi_lcmp.c,v 1.2 2012/08/06 02:15:51 matt Exp $");
+
+#include "quad.h"
+#include <arm/aeabi.h>
+
+/*
+ * Return -1, 0, 1 (like strcmp) if a [<, =, >] b
+ */
+int
+__aeabi_lcmp(long long a, long long b)
+{
+ const union uu aa = { .q = a }, bb = { .q = b };
+
+ if (aa.sl[H] < bb.sl[H])
+ return -1;
+ if (aa.sl[H] > bb.sl[H])
+ return 1;
+
+ if (aa.sl[L] < bb.sl[L])
+ return -1;
+ if (aa.sl[L] > bb.sl[L])
+ return 1;
+
+ return 0;
+}
--- /dev/null
+/*-
+ * 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 <machine/asm.h>
+
+RCSID("$NetBSD: __aeabi_ldivmod.S,v 1.1 2012/08/05 06:33:51 matt Exp $")
+
+ENTRY(__aeabi_ldivmod)
+ push {r4-r5, sl, lr}
+#define NEG r5
+ mov NEG, #0
+
+#ifdef __ARMEB__
+#define ALO r1 /* incoming numerator, outgoing quotient */
+#define AHI r0 /* incoming numerator, outgoing quotient */
+#define BLO r3 /* incoming denominator, outgoing remainder */
+#define BHI r2 /* incoming denominator, outgoing remainder */
+#else
+#define ALO r0 /* incoming numerator, outgoing quotient */
+#define AHI r1 /* incoming numerator, outgoing quotient */
+#define BLO r2 /* incoming denominator, outgoing remainder */
+#define BHI r3 /* incoming denominator, outgoing remainder */
+#endif
+
+ cmp BHI, #0
+ bge 2f
+ eor NEG, NEG, #1 /* flip quotient sign */
+ bl .Lnegate_b
+ bcs .Lmaxdenom
+
+2:
+ cmp AHI, #0
+ /* bge 3f */
+ eorlt NEG, NEG, #3 /* flip quotient sign, flip remainder sign */
+ bllt .Lnegate_a
+3:
+ /*
+ * Arguments are setup, allocate some stack for the remainder
+ * and call __qdivrem for the heavy lifting.
+ */
+ sub sp, sp, #8
+ mov r4, sp /* pointer to remainder */
+ bl PLT_SYM(__qdivrem)
+
+ teq NEG, #0 /* any signs to flip? */
+ /*
+ * The quotient is already in the right place and neither value
+ * needs its sign flipped.
+ */
+ popeq {r2-r5, sl, lr}
+ RETc(eq)
+
+ pop {r2, r3}
+ tst NEG, #2 /* does remainder need to be negative? */
+ bleq .Lnegate_b
+ tst NEG, #1 /* does quotient need to be negative? */
+ bleq .Lnegate_a
+ pop {r4-r5, sl, lr}
+ RET
+
+.Lnegate_a:
+ rsbs ALO, ALO, #0
+ rsc AHI, AHI, #0
+ RET
+
+.Lnegate_b:
+ rsbs BLO, BLO, #0
+ rsc BHI, BHI, #0
+ RET
+
+.Lmaxdenom:
+ /*
+ * We had a carry so the denominator must have INT64_MIN
+ * Also BLO and BHI never changed values so we can use
+ * them to see if the numerator has the same value. We
+ * don't have to worry about sign.
+ */
+ teq BHI, AHI
+ teqeq BLO, ALO
+ bne 1f
+
+ /*
+ * They were equal, so we return a quotient of 1 and remainder of 0.
+ */
+ mov ALO, #1
+ mov AHI, #0
+ mov BLO, #0
+ mov BHI, #0
+ pop {r4-r5, sl, lr}
+ RET
+
+ /*
+ * Our remainder must be the numerator and our quotient is 0.
+ */
+1: mov BLO, ALO
+ mov BHI, AHI
+ mov ALO, #0
+ mov AHI, #0
+ pop {r4-r5, sl, lr}
+ RET
+
+END(__aeabi_ldivmod)
--- /dev/null
+/*-
+ * 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 <sys/cdefs.h>
+
+__RCSID("$NetBSD: __aeabi_ulcmp.c,v 1.2 2012/08/06 02:15:51 matt Exp $");
+
+#include "quad.h"
+#include <arm/aeabi.h>
+
+/*
+ * Return -1, 0, 1 (like strcmp) if a [<, =, >] b
+ */
+int
+__aeabi_ulcmp(unsigned long long a, unsigned long long b)
+{
+ const union uu aa = { .uq = a }, bb = { .uq = b };
+
+ if (aa.ul[H] < bb.ul[H])
+ return -1;
+ if (aa.ul[H] > bb.ul[H])
+ return 1;
+
+ if (aa.ul[L] < bb.ul[L])
+ return -1;
+ if (aa.ul[L] > bb.ul[L])
+ return 1;
+
+ return 0;
+}
--- /dev/null
+/*-
+ * 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 <machine/asm.h>
+
+RCSID("$NetBSD: __aeabi_uldivmod.S,v 1.2 2012/08/05 06:34:09 matt Exp $")
+
+/*
+ * typedef struct { unsigned long long quo, rem } ulldiv_t;
+ * __value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n,
+ * unsigned long long d);
+ */
+
+ENTRY(__aeabi_uldivmod)
+ push {r4,lr}
+ sub sp, sp, #8
+ mov r4, sp
+ bl PLT_SYM(__qdivrem)
+ /*
+ * The remainder is already on the stack just waiting to be popped
+ * into r2/r3.
+ */
+ pop {r2-r4,lr}
+ RET
+END(__aeabi_uldivmod)
-/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+/* $NetBSD: ffs.S,v 1.2 2011/07/03 07:13:31 matt Exp $ */
/*
* Copyright (c) 2001 Christopher Gilbert
* All rights reserved.
#include <machine/asm.h>
-RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+RCSID("$NetBSD: ffs.S,v 1.2 2011/07/03 07:13:31 matt Exp $")
/*
* ffs - find first set bit, this algorithm isolates the first set
* This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
* 16 Feb 1994.
*/
-
+WEAK_ALIAS(__ffssi2,ffs)
ENTRY(ffs)
#ifdef _ARM_ARCH_5
/* (X & -X) gives LSB or zero. */
--- /dev/null
+/* $NetBSD: memcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: memcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+ENTRY(memcmp)
+ pushl %esi
+ pushl %edi
+ movl 12(%esp), %edi
+ movl 16(%esp), %esi
+ movl 20(%esp), %ecx
+ xorl %eax, %eax
+ rep
+ cmpsb
+ popl %edi
+ popl %esi
+ ja 1f
+ setnz %al
+ ret
+1:
+ decl %eax
+ ret
--- /dev/null
+/* $NetBSD: memcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: memcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+# ifdef BCOPY
+ENTRY(bcopy)
+ pushl %esi
+ pushl %edi
+ movl 12(%esp), %esi
+ movl 16(%esp), %edi
+ jmp __memmove_start
+# endif
+# if defined(MEMMOVE)
+ENTRY(memcpy)
+ENTRY(memmove)
+ pushl %esi
+ pushl %edi
+ movl 12(%esp), %edi
+ movl 16(%esp), %esi
+ .globl __memmove_start
+__memmove_start:
+ movl 20(%esp), %ecx
+ pushl %edi
+ testl %ecx, %ecx
+ jz 2f
+ cmpl %esi, %edi
+ jb 1f
+ addl %ecx, %esi
+ decl %esi
+ addl %ecx, %edi
+ decl %edi
+ std
+1:
+ rep
+ movsb
+2:
+ cld
+ popl %eax
+ popl %edi
+ popl %esi
+ ret
+# endif /* MEMMOVE */
--- /dev/null
+/* $NetBSD: memmove.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+
+#define MEMMOVE
+#include "memcpy.S"
--- /dev/null
+/* $NetBSD: memset.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: memset.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+ENTRY(memset)
+ pushl %edi
+ movl 8(%esp), %edi
+ movl 12(%esp), %eax
+ movl 16(%esp), %ecx
+ pushl %edi
+ rep
+ stosb
+ popl %eax
+ popl %edi
+ ret
--- /dev/null
+/* $NetBSD: strchr.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: strchr.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+ENTRY(strchr)
+ popl %edx /* Return address */
+ popl %eax /* String pointer */
+ popl %ecx /* Character to find */
+ pushl %ecx
+ pushl %eax
+ pushl %edx
+1:
+ cmpb $0, 0(%eax)
+ je 2f
+ cmpb %cl, 0(%eax)
+ je 3f
+ incl %eax
+ jmp 1b
+2:
+ xorl %eax, %eax
+3:
+ ret
--- /dev/null
+/* $NetBSD: strcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: strcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+ENTRY(strcmp)
+ pushl %esi
+ movl 12(%esp), %ecx
+ movl 8(%esp), %esi
+ decl %ecx
+1:
+ incl %ecx
+ lodsb
+ cmpb 0(%ecx), %al
+ jne 2f
+ testb %al, %al
+ jne 1b
+2:
+ subb 0(%ecx), %al
+ movsbl %al, %eax
+ popl %esi
+ ret
--- /dev/null
+/* $NetBSD: strcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <machine/asm.h>
+ RCSID("$NetBSD: strcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+
+ENTRY(strcpy)
+ pushl %esi
+ pushl %edi
+ movl 12(%esp), %edi
+ movl 16(%esp), %esi
+ pushl %edi
+1:
+ lodsb
+ stosb
+ testb %al, %al
+ jne 1b
+ popl %eax
+ popl %edi
+ popl %esi
+ ret
--- /dev/null
+/* $NetBSD: strlen.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+ RCSID("$NetBSD: strlen.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
+ENTRY(strlen)
+ movl 8(%esp), %ecx
+ xorl %eax, %eax
+ dec %eax
+1:
+ incl %eax
+ cmpb $0, 0(%ecx,%eax,1)
+ jnz 1b
+ ret
-/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+/* $NetBSD: ffs.S,v 1.2 2011/07/09 14:57:29 mrg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#if 0
RCSID("from: @(#)ffs.s 5.1 (Berkeley) 5/12/90")
#else
- RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+ RCSID("$NetBSD: ffs.S,v 1.2 2011/07/09 14:57:29 mrg Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* bit = ffs(value) */
+WEAK_ALIAS(__ffssi2,ffs)
+
#ifndef __mc68010__
ENTRY(ffs)
-/* $NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
+/* $NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $")
+RCSID("$NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
+
LEAF(_atomic_add_32)
1: INT_LL t0, 0(a0)
-/* $NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
+/* $NetBSD: atomic_and.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $")
+RCSID("$NetBSD: atomic_and.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
+
LEAF(_atomic_and_32)
1: INT_LL t0, 0(a0)
-/* $NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
+RCSID("$NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $")
.text
.set noat
-/* $NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
+RCSID("$NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
LEAF(_atomic_dec_32)
1: INT_LL t0, 0(a0)
-/* $NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
+RCSID("$NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
+
LEAF(_atomic_inc_32)
1: INT_LL t0, 0(a0)
-/* $NetBSD: atomic_or.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_or.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
LEAF(_atomic_or_32)
1: INT_LL t0, 0(a0)
-/* $NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
-RCSID("$NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
+RCSID("$NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
.text
- .set noat
.set noreorder
+#ifdef _KERNEL_OPT
+#include "opt_cputype.h"
+#ifndef MIPS3_LOONGSON2F
+ .set noat
+ .set nomacro
+#endif
+#else /* _KERNEL_OPT */
+ .set noat
.set nomacro
+#endif /* _KERNEL_OPT */
+
LEAF(_atomic_swap_32)
1: INT_LL v0, 0(a0)
-/* $NetBSD: membar_ops.S,v 1.4 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: membar_ops.S,v 1.5 2012/08/03 06:06:44 matt Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
#endif
.text
+ .set noreorder
LEAF(_membar_sync)
j ra
#ifdef SYNC
- SYNC
+ SYNC
#else
- nop
+ nop
#endif
END(_membar_sync)
-/* $NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: bcopy.S,v 1.4 2011/08/27 13:23:52 bouyer Exp $ */
/*
* Mach Operating System
#if 0
RCSID("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93")
#else
- RCSID("$NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $")
+ RCSID("$NetBSD: bcopy.S,v 1.4 2011/08/27 13:23:52 bouyer Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
PTR_ADDU DSTREG,1
4: # copydone
+ .set at #-mfix-loongson2f-btb
j ra
nop
+ .set noat
/*
* Copy from unaligned source to aligned dest.
PTR_SUBU DSTREG,1
4: # copydone
+ .set at #-mfix-loongson2f-btb
j ra
nop
+ .set noat
/*
* Copy from unaligned source to aligned dest.
-/* $NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: ffs.S,v 1.4 2011/07/04 11:35:26 mrg Exp $ */
/*-
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
*
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
+ * 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
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <mips/asm.h>
-#if defined(LIBC_SCCS) && !defined(lint)
- /* RCSID("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") */
- RCSID("$NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
-#endif /* LIBC_SCCS and not lint */
+RCSID("$NetBSD: ffs.S,v 1.4 2011/07/04 11:35:26 mrg Exp $")
/* bit = ffs(value) */
+ .text
+ .set noreorder
+
+WEAK_ALIAS(__ffssi2,ffs)
+#if __mips == 64 || __mips == 32
+LEAF(ffs)
+#ifndef _LP64
+XLEAF(ffsl)
+#endif
+ .set push
+ .set mips32
+ li v1, 32
+#if __mips == 64
+ sll a0, a0, 0
+#endif
+ negu a1, a0
+ and a0, a1
+ clz v0, a0
+ j ra
+ subu v0, v1, v0
+ .set pop
+END(ffs)
+#if defined(_LP64) && __mips == 64
+LEAF(ffsl)
+ li v1, 64
+ negu a1, a0
+ and a0, a1
+ dclz v0, a0
+ j ra
+ subu v0, v1, v0
+END(ffsl)
+#endif
+#else /* __mips != 64 && __mips != 32 */
+
+#ifdef _LP64
+XLEAF(ffsl)
+ beqz a0, 6f # fast escape if 0
+ li v0, 0
+
+ li v0, 1
+ li a3, 0xffffffff # initial mask
+ b 1f
+ li a2, 32 # bit count of mask
+#endif /* _LP64 */
LEAF(ffs)
- move v0, zero
- beq a0, zero, done
+#ifndef _LP64
+XLEAF(ffsl)
+#endif /* !_LP64 */
+ beqz a0, 6f
+ li v0, 0
+
+ li v0, 1
+ li a3, 0xffff # initial mask
+ li a2, 16 # bit count of mask
1:
- and v1, a0, 1 # bit set?
- addu v0, v0, 1
- srl a0, a0, 1
- beq v1, zero, 1b # no, continue
-done:
+ and v1, a0, a3 # focus no lower half of bits left
+ bnez v1, 2f # any of the lower half set?
+ nop
+ addu v0, a2 # nope, then bit is in the upper half
+#ifdef _LP64
+ dsrlv a0, a0, a2 # discard low bits
+#else
+ srlv a0, a0, a2 # discard low bits
+#endif
+2:
+ srl a2, 1 # divide bit count by 2
+ bnez a2, 1b # still bits left to text?
+ srlv a3, a3, a2 # shrink mask in half
+6:
j ra
+ nop
END(ffs)
+#endif /* __mips == 64 || __mips == 32 */
-/* $NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
+/* $NetBSD: ffs.S,v 1.3 2011/07/04 12:18:05 mrg Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
+ RCSID("$NetBSD: ffs.S,v 1.3 2011/07/04 12:18:05 mrg Exp $")
#endif
/*
* The remaining 8bit is tested in every 2bit.
*/
+WEAK_ALIAS(__ffssi2,ffs)
ENTRY(ffs)
mov r4,r0 ! using r0 specific instructions
tst #0xff,r0
-/* $NetBSD: atomic_cas.S,v 1.10 2009/03/13 16:40:22 nakayama Exp $ */
+/* $NetBSD: atomic_cas.S,v 1.11 2011/02/22 18:45:10 pooka Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
#if defined(MULTIPROCESSOR)
.section .bss
.align 1024
+#ifdef PIC
+ .globl _C_LABEL(_atomic_cas_locktab)
+#endif
OTYPE(_C_LABEL(_atomic_cas_locktab))
_C_LABEL(_atomic_cas_locktab):
.space 1024
+#ifdef PIC
+/* o4 is not used for PSR in PIC cases, so we can use it here */
+#define GETLOCKTAB \
+ PIC_PROLOGUE(%o3,%o4) ;\
+ set _C_LABEL(_atomic_cas_locktab), %o4 ;\
+ ld [%o3 + %o4], %o3
+#else
+#define GETLOCKTAB \
+ sethi %hi(_C_LABEL(_atomic_cas_locktab)), %o3
+#endif
+
#define ACQUIRE_INTERLOCK \
DISABLE_INTERRUPTS ;\
srl %o0, 3, %o5 /* get lock address */ ;\
and %o5, 1023, %o5 ;\
- sethi %hi(_C_LABEL(_atomic_cas_locktab)), %o3 ;\
+ GETLOCKTAB ;\
add %o5, %o3, %o5 ;\
;\
/* %o5 has interlock address */ ;\
-/* $NetBSD: ffs.S,v 1.2 2009/12/19 19:09:48 pooka Exp $ */
+/* $NetBSD: ffs.S,v 1.3 2011/07/04 11:18:23 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
.asciz "@(#)ffs.s 8.1 (Berkeley) 6/4/93"
#else
- RCSID("$NetBSD: ffs.S,v 1.2 2009/12/19 19:09:48 pooka Exp $")
+ RCSID("$NetBSD: ffs.S,v 1.3 2011/07/04 11:18:23 mrg Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
* one, we just return the table value plus 24. This means
* that ffstab[0] must be -24 so that ffs(0) will return 0.
*/
+WEAK_ALIAS(__ffssi2,ffs)
ENTRY(ffs)
#ifdef PIC
PICCY_SET(ffstab, %o2, %o3)
-/* $NetBSD: bswap16.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
+/* $NetBSD: bswap16.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
#include <machine/asm.h>
+RCSID("$NetBSD: bswap16.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
+
#if defined(_KERNEL) || defined(_STANDALONE)
-ENTRY(_C_LABEL(bswap16), 0)
+ALTENTRY(_C_LABEL(bswap16))
#else
ALTENTRY(_C_LABEL(ntohs))
ALTENTRY(_C_LABEL(htons))
-ENTRY(_C_LABEL(__bswap16), 0)
#endif
+ENTRY(_C_LABEL(__bswap16), 0)
movl 4(%ap), %r1
extzv $8, $8, %r1, %r0
insv %r1, $8, $8, %r0
ret
+END(_C_LABEL(__bswap16))
-/* $NetBSD: bswap32.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
+/* $NetBSD: bswap32.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
#include <machine/asm.h>
+RCSID("$NetBSD: bswap32.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
+
#if defined(_KERNEL) || defined(_STANDALONE)
-ENTRY(_C_LABEL(bswap32), 0)
+ALTENTRY(_C_LABEL(bswap32))
#else
-#if BYTE_ORDER == LITTLE_ENDIAN
ALTENTRY(_C_LABEL(ntohl))
ALTENTRY(_C_LABEL(htonl))
#endif
ENTRY(_C_LABEL(__bswap32), 0)
-#endif
rotl $-8, 4(%ap), %r0
insv %r0, $16, $8, %r0
rotl $8, 4(%ap), %r1
movb %r1, %r0
ret
-
+END(_C_LABEL(__bswap32))
/* Written by Anders Magnusson. Public Domain */
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "$NetBSD: bswap64.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
-#endif /* LIBC_SCCS and not lint */
-
#include <machine/asm.h>
+RCSID("$NetBSD: bswap64.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
+
ENTRY(bswap64, 0)
movq 4(%ap),%r3
rotl $-8,%r3,%r1
rotl $8,%r4,%r2
movb %r2,%r0
ret
+END(bswap64)
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
+#include <machine/asm.h>
+
/* .asciz "@(#)udiv.s 8.1 (Berkeley) 6/4/93" */
- .asciz "$NetBSD: udiv.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
-#endif /* LIBC_SCCS and not lint */
+RCSID("$NetBSD: udiv.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
/*
* Unsigned division, PCC flavor.
* audiv() takes a pointer to a dividend and an ordinary divisor.
*/
-#include <machine/asm.h>
-
#define DIVIDEND 4(%ap)
#define DIVISOR 8(%ap)
-#ifdef __ELF__
ASENTRY(__udiv,0)
-#else
-ASENTRY(udiv,0)
-#endif
movl DIVISOR,%r2
jlss Leasy # big divisor: settle by comparison
movl DIVIDEND,%r0
Lone:
movl $1,%r0
ret
+END(__udiv)
-#ifdef __ELF__
ASENTRY(__audiv,0)
-#else
-ASENTRY(audiv,0)
-#endif
movl DIVIDEND,%r3
movl DIVISOR,%r2
jlss La_easy # big divisor: settle by comparison
movl $1,%r0
movl %r0,(%r3)
ret
+END(__audiv)
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- /* .asciz "@(#)urem.s 8.1 (Berkeley) 6/4/93" */
- .asciz "$NetBSD: urem.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
-#endif /* LIBC_SCCS and not lint */
-
#include <machine/asm.h>
+ /* .asciz "@(#)urem.s 8.1 (Berkeley) 6/4/93" */
+RCSID("$NetBSD: urem.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
+
/*
* Unsigned modulus, PCC flavor.
* urem() takes an ordinary dividend/divisor pair;
#define DIVIDEND 4(%ap)
#define DIVISOR 8(%ap)
-#ifdef __ELF__
ASENTRY(__urem,0)
-#else
-ASENTRY(urem,0)
-#endif
movl DIVISOR,%r2
jlss Leasy # big divisor: settle by comparison
movl DIVIDEND,%r0
movl DIVIDEND,%r0 # if divisor is bigger, return dividend
Ldifference:
ret
+END(__urem)
-#ifdef __ELF__
ASENTRY(__aurem,0)
-#else
-ASENTRY(aurem,0)
-#endif
movl DIVIDEND,%r3
movl DIVISOR,%r2
jlss La_easy # big divisor: settle by comparison
La_dividend:
movl (%r3),%r0
ret
+END(__aurem)
-/* $NetBSD: memcpy.S,v 1.2 2005/12/24 08:33:32 matt Exp $ */
+/* $NetBSD: memcpy.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)memcpy.s 8.1 (Berkeley) 6/4/93"
-#endif /* LIBC_SCCS and not lint */
+#include <machine/asm.h>
+
+/* .asciz "@(#)memcpy.s 8.1 (Berkeley) 6/4/93" */
+RCSID("$NetBSD: memcpy.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
/*
* void *memcpy(dst, src, size)
* of some extra memory references and branches when count >= 65536.
*/
-#include <machine/asm.h>
-
ENTRY(memcpy, 0)
movzwl $65535,%r0 /* %r0 = 64K (needed below) */
movq 8(%ap),%r1 /* %r1 = src, %r2 = length */
subl2 %r0,%r1
subl2 %r0,%r3
brb 5b
+END(memcpy)
-/* $NetBSD: memmove.S,v 1.2 2005/12/24 08:33:32 matt Exp $ */
+/* $NetBSD: memmove.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)memmove.s 8.1 (Berkeley) 6/4/93"
-#endif /* LIBC_SCCS and not lint */
+#include <machine/asm.h>
+
+/* .asciz "@(#)memmove.s 8.1 (Berkeley) 6/4/93" */
+RCSID("$NetBSD: memmove.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
/*
* void *memmove(dst, src, size)
* of some extra memory references and branches when count >= 65536.
*/
-#include <machine/asm.h>
-
ENTRY(memmove, 0)
movzwl $65535,%r0 /* %r0 = 64K (needed below) */
movq 8(%ap),%r1 /* %r1 = src, %r2 = length */
subl2 %r0,%r1
subl2 %r0,%r3
brb 5b
+END(memmove)
-/* $NetBSD: memset.S,v 1.1 2010/03/12 09:12:34 uwe Exp $ */
+/* $NetBSD: memset.S,v 1.2 2011/01/25 04:45:28 matt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)memset.s 8.1 (Berkeley) 6/4/93"
-#endif /* LIBC_SCCS and not lint */
+#include <machine/asm.h>
-/* void *memset(base, c, length) */
+/* .asciz "@(#)memset.s 8.1 (Berkeley) 6/4/93" */
+RCSID("$NetBSD: memset.S,v 1.2 2011/01/25 04:45:28 matt Exp $")
-#include <machine/asm.h>
+/* void *memset(base, c, length) */
ENTRY(memset, 0)
movl 4(%ap),%r3
subl2 %r0,12(%ap)
movc5 $0,(%r3),%r1,%r0,(%r3)
jbr 1b
+END(memset)
-/* $NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $ */
+/* $NetBSD: atomic_init_testset.c,v 1.8 2012/02/28 20:41:19 joerg Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $");
+__RCSID("$NetBSD: atomic_init_testset.c,v 1.8 2012/02/28 20:41:19 joerg Exp $");
#include "atomic_op_namespace.h"
#undef atomic_cas_uint
#undef atomic_cas_ulong
#undef atomic_cas_ptr
+#undef atomic_cas_32_ni
+#undef atomic_cas_uint_ni
+#undef atomic_cas_ulong_ni
+#undef atomic_cas_ptr_ni
atomic_op_alias(atomic_cas_32,_atomic_cas_32)
atomic_op_alias(atomic_cas_uint,_atomic_cas_32)
-/* $NetBSD: bswap16.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
+/* $NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $ */
/*
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: bswap16.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
+__RCSID("$NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#undef bswap16
uint16_t
-bswap16(x)
- uint16_t x;
+bswap16(uint16_t x)
{
+ /*LINTED*/
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
}
-/* $NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
+/* $NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $ */
/*
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
+__RCSID("$NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#undef bswap32
uint32_t
-bswap32(x)
- uint32_t x;
+bswap32(uint32_t x)
{
return ((x << 24) & 0xff000000 ) |
((x << 8) & 0x00ff0000 ) |
-/* $NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $ */
+/* $NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
#include <sys/types.h>
#include <sys/systm.h>
#include <lib/libkern/libkern.h>
-__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
#else
#include <stddef.h>
#include <stdint.h>
#else
#define KASSERT(e) do { } while (/*CONSTCOND*/ 0)
#endif
-__RCSID("$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
+__RCSID("$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
#endif /* _KERNEL || _STANDALONE */
#ifdef _LIBC
#endif
/*
- * This is an implementation of a radix / PATRICIA tree. As in a traditional
+ * This is an implementation of a radix / PATRICIA tree. As in a traditional
* patricia tree, all the data is at the leaves of the tree. An N-value
* tree would have N leaves, N-1 branching nodes, and a root pointer. Each
* branching node would have left(0) and right(1) pointers that either point
* have no need for pointers.
*
* However, allocation for these branching nodes is problematic since the
- * allocation could fail. This would cause insertions to fail for reasons
- * beyond the users control. So to prevent this, in this implementation
+ * allocation could fail. This would cause insertions to fail for reasons
+ * beyond the user's control. So to prevent this, in this implementation
* each node has two identities: its leaf identity and its branch identity.
* Each is separate from the other. Every branch is tagged as to whether
* it points to a leaf or a branch. This is not an attribute of the object
* but of the pointer to the object. The low bit of the pointer is used as
* the tag to determine whether it points to a leaf or branch identity, with
* branch identities having the low bit set.
- *
+ *
* A node's branch identity has one rule: when traversing the tree from the
* root to the node's leaf identity, one of the branches traversed will be via
* the node's branch identity. Of course, that has an exception: since to
*
* Branching nodes also has a bit offset and a bit length which determines
* which branch slot is used. The bit length can be zero resulting in a
- * one-way branch. This is happens in two special cases: the root and
+ * one-way branch. This happens in two special cases: the root and
* interior mask nodes.
*
* To support longest match first lookups, when a mask node (one that only
pt_bitoff_t *bitoff_p, pt_slot_t *slots_p)
{
return (*pt->pt_ops->ptto_matchnode)(NODETOKEY(pt, target),
- (ptn != NULL ? NODETOKEY(pt, ptn) : NULL), max_bitoff,
- bitoff_p, slots_p);
+ (ptn != NULL ? NODETOKEY(pt, ptn) : NULL),
+ max_bitoff, bitoff_p, slots_p, pt->pt_context);
}
static inline pt_slot_t
{
const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
if (bitlen == 0)
- return PT_SLOT_ROOT;
+ return PT_SLOT_ROOT; /* mask or root, doesn't matter */
return (*pt->pt_ops->ptto_testnode)(NODETOKEY(pt, target),
- PTN_BRANCH_BITOFF(ptn),
- bitlen);
+ PTN_BRANCH_BITOFF(ptn), bitlen, pt->pt_context);
}
static inline bool
const pt_node_t *ptn, pt_bitoff_t bitoff, pt_bitlen_t bitlen)
{
return (*pt->pt_ops->ptto_matchkey)(key, NODETOKEY(pt, ptn),
- bitoff, bitlen);
+ bitoff, bitlen, pt->pt_context);
}
static inline pt_slot_t
ptree_testkey(const pt_tree_t *pt, const void *key, const pt_node_t *ptn)
{
- return (*pt->pt_ops->ptto_testkey)(key,
- PTN_BRANCH_BITOFF(ptn),
- PTN_BRANCH_BITLEN(ptn));
+ const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
+ if (bitlen == 0)
+ return PT_SLOT_ROOT; /* mask or root, doesn't matter */
+ return (*pt->pt_ops->ptto_testkey)(key, PTN_BRANCH_BITOFF(ptn),
+ PTN_BRANCH_BITLEN(ptn), pt->pt_context);
}
static inline void
}
void
-ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, size_t node_offset,
- size_t key_offset)
+ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, void *context,
+ size_t node_offset, size_t key_offset)
{
memset(pt, 0, sizeof(*pt));
pt->pt_node_offset = node_offset;
pt->pt_key_offset = key_offset;
+ pt->pt_context = context;
pt->pt_ops = ops;
}
pt_insertfunc_t insertfunc;
pt_insertdata_t id;
+ /*
+ * If this node already exists in the tree, return failure.
+ */
+ if (target == PT_NODE(pt->pt_root))
+ return false;
+
/*
* We need a leaf so we can match against. Until we get a leaf
* we having nothing to test against.
pt_node_t * const ptn = PT_NODE(*id.id_insertp);
id.id_node = *id.id_insertp;
+ /*
+ * If this node already exists in the tree, return failure.
+ */
+ if (target == ptn)
+ return false;
+
/*
* If we hit a leaf, try to insert target at leaf. We could
* have inlined ptree_insert_leaf here but that would have
#endif /* !PTNOMASH */
void *
-ptree_find_filtered_node(pt_tree_t *pt, void *key, pt_filter_t filter,
+ptree_find_filtered_node(pt_tree_t *pt, const void *key, pt_filter_t filter,
void *filter_arg)
{
#ifndef PTNOMASK
#endif
return ok;
}
+
+bool
+ptree_mask_node_p(pt_tree_t *pt, const void *item, pt_bitlen_t *lenp)
+{
+ const pt_node_t * const mask = ITEMTONODE(pt, item);
+
+ if (!PTN_ISMASK_P(mask))
+ return false;
+
+ if (lenp != NULL)
+ *lenp = PTN_MASK_BITLEN(mask);
+
+ return true;
+}
--- /dev/null
+/* $NetBSD: radixtree.c,v 1.17 2011/11/02 13:49:43 yamt Exp $ */
+
+/*-
+ * Copyright (c)2011 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.
+ */
+
+/*
+ * radixtree.c
+ *
+ * this is an implementation of radix tree, whose keys are uint64_t and leafs
+ * are user provided pointers.
+ *
+ * leaf nodes are just void * and this implementation doesn't care about
+ * what they actually point to. however, this implementation has an assumption
+ * about their alignment. specifically, this implementation assumes that their
+ * 2 LSBs are zero and uses them internally.
+ *
+ * intermediate nodes are automatically allocated and freed internally and
+ * basically users don't need to care about them. only radix_tree_insert_node
+ * function can allocate memory for intermediate nodes and thus can fail for
+ * ENOMEM.
+ *
+ * efficiency:
+ * it's designed to work efficiently with dense index distribution.
+ * the memory consumption (number of necessary intermediate nodes)
+ * heavily depends on index distribution. basically, more dense index
+ * distribution consumes less nodes per item.
+ * approximately,
+ * the best case: about RADIX_TREE_PTR_PER_NODE items per intermediate node.
+ * the worst case: RADIX_TREE_MAX_HEIGHT intermediate nodes per item.
+ *
+ * gang lookup:
+ * this implementation provides a way to lookup many nodes quickly via
+ * radix_tree_gang_lookup_node function and its varients.
+ *
+ * tags:
+ * this implementation provides tagging functionality to allow quick
+ * scanning of a subset of leaf nodes. leaf nodes are untagged when
+ * inserted into the tree and can be tagged by radix_tree_set_tag function.
+ * radix_tree_gang_lookup_tagged_node function and its variants returns
+ * only leaf nodes with the given tag. to reduce amount of nodes to visit for
+ * these functions, this implementation keeps tagging information in internal
+ * intermediate nodes and quickly skips uninterested parts of a tree.
+ */
+
+#include <sys/cdefs.h>
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.17 2011/11/02 13:49:43 yamt Exp $");
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/pool.h>
+#include <sys/radixtree.h>
+#include <lib/libkern/libkern.h>
+#if defined(_STANDALONE)
+#include <lib/libsa/stand.h>
+#endif /* defined(_STANDALONE) */
+#else /* defined(_KERNEL) || defined(_STANDALONE) */
+__RCSID("$NetBSD: radixtree.c,v 1.17 2011/11/02 13:49:43 yamt Exp $");
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#if 1
+#define KASSERT assert
+#else
+#define KASSERT(a) /* nothing */
+#endif
+#endif /* defined(_KERNEL) || defined(_STANDALONE) */
+
+#include <sys/radixtree.h>
+
+#define RADIX_TREE_BITS_PER_HEIGHT 4 /* XXX tune */
+#define RADIX_TREE_PTR_PER_NODE (1 << RADIX_TREE_BITS_PER_HEIGHT)
+#define RADIX_TREE_MAX_HEIGHT (64 / RADIX_TREE_BITS_PER_HEIGHT)
+#define RADIX_TREE_INVALID_HEIGHT (RADIX_TREE_MAX_HEIGHT + 1)
+__CTASSERT((64 % RADIX_TREE_BITS_PER_HEIGHT) == 0);
+
+__CTASSERT(((1 << RADIX_TREE_TAG_ID_MAX) & (sizeof(int) - 1)) == 0);
+#define RADIX_TREE_TAG_MASK ((1 << RADIX_TREE_TAG_ID_MAX) - 1)
+
+static inline void *
+entry_ptr(void *p)
+{
+
+ return (void *)((uintptr_t)p & ~RADIX_TREE_TAG_MASK);
+}
+
+static inline unsigned int
+entry_tagmask(void *p)
+{
+
+ return (uintptr_t)p & RADIX_TREE_TAG_MASK;
+}
+
+static inline void *
+entry_compose(void *p, unsigned int tagmask)
+{
+
+ return (void *)((uintptr_t)p | tagmask);
+}
+
+static inline bool
+entry_match_p(void *p, unsigned int tagmask)
+{
+
+ KASSERT(entry_ptr(p) != NULL || entry_tagmask(p) == 0);
+ if (p == NULL) {
+ return false;
+ }
+ if (tagmask == 0) {
+ return true;
+ }
+ return (entry_tagmask(p) & tagmask) != 0;
+}
+
+static inline unsigned int
+tagid_to_mask(radix_tree_tagid_t id)
+{
+
+ KASSERT(id >= 0);
+ KASSERT(id < RADIX_TREE_TAG_ID_MAX);
+ return 1U << id;
+}
+
+/*
+ * radix_tree_node: an intermediate node
+ *
+ * we don't care the type of leaf nodes. they are just void *.
+ */
+
+struct radix_tree_node {
+ void *n_ptrs[RADIX_TREE_PTR_PER_NODE];
+ unsigned int n_nptrs; /* # of non-NULL pointers in n_ptrs */
+};
+
+/*
+ * any_children_tagmask:
+ *
+ * return OR'ed tagmask of the given node's children.
+ */
+
+static unsigned int
+any_children_tagmask(const struct radix_tree_node *n)
+{
+ unsigned int mask;
+ int i;
+
+ mask = 0;
+ for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
+ mask |= (unsigned int)(uintptr_t)n->n_ptrs[i];
+ }
+ return mask & RADIX_TREE_TAG_MASK;
+}
+
+/*
+ * p_refs[0].pptr == &t->t_root
+ * :
+ * p_refs[n].pptr == &(*p_refs[n-1])->n_ptrs[x]
+ * :
+ * :
+ * p_refs[t->t_height].pptr == &leaf_pointer
+ */
+
+struct radix_tree_path {
+ struct radix_tree_node_ref {
+ void **pptr;
+ } p_refs[RADIX_TREE_MAX_HEIGHT + 1]; /* +1 for the root ptr */
+ /*
+ * p_lastidx is either the index of the last valid element of p_refs[]
+ * or RADIX_TREE_INVALID_HEIGHT.
+ * RADIX_TREE_INVALID_HEIGHT means that radix_tree_lookup_ptr found
+ * that the height of the tree is not enough to cover the given index.
+ */
+ unsigned int p_lastidx;
+};
+
+static inline void **
+path_pptr(const struct radix_tree *t, const struct radix_tree_path *p,
+ unsigned int height)
+{
+
+ KASSERT(height <= t->t_height);
+ return p->p_refs[height].pptr;
+}
+
+static inline struct radix_tree_node *
+path_node(const struct radix_tree * t, const struct radix_tree_path *p,
+ unsigned int height)
+{
+
+ KASSERT(height <= t->t_height);
+ return entry_ptr(*path_pptr(t, p, height));
+}
+
+/*
+ * radix_tree_init_tree:
+ *
+ * initialize a tree.
+ */
+
+void
+radix_tree_init_tree(struct radix_tree *t)
+{
+
+ t->t_height = 0;
+ t->t_root = NULL;
+}
+
+/*
+ * radix_tree_init_tree:
+ *
+ * clean up a tree.
+ */
+
+void
+radix_tree_fini_tree(struct radix_tree *t)
+{
+
+ KASSERT(t->t_root == NULL);
+ KASSERT(t->t_height == 0);
+}
+
+bool
+radix_tree_empty_tree_p(struct radix_tree *t)
+{
+
+ return t->t_root == NULL;
+}
+
+bool
+radix_tree_empty_tagged_tree_p(struct radix_tree *t, radix_tree_tagid_t tagid)
+{
+ const unsigned int tagmask = tagid_to_mask(tagid);
+
+ return (entry_tagmask(t->t_root) & tagmask) == 0;
+}
+
+static void
+radix_tree_node_init(struct radix_tree_node *n)
+{
+
+ memset(n, 0, sizeof(*n));
+}
+
+#if defined(_KERNEL)
+pool_cache_t radix_tree_node_cache __read_mostly;
+
+static int
+radix_tree_node_ctor(void *dummy, void *item, int flags)
+{
+ struct radix_tree_node *n = item;
+
+ KASSERT(dummy == NULL);
+ radix_tree_node_init(n);
+ return 0;
+}
+
+/*
+ * radix_tree_init:
+ *
+ * initialize the subsystem.
+ */
+
+void
+radix_tree_init(void)
+{
+
+ radix_tree_node_cache = pool_cache_init(sizeof(struct radix_tree_node),
+ 0, 0, 0, "radix_tree_node", NULL, IPL_NONE, radix_tree_node_ctor,
+ NULL, NULL);
+ KASSERT(radix_tree_node_cache != NULL);
+}
+#endif /* defined(_KERNEL) */
+
+static bool __unused
+radix_tree_node_clean_p(const struct radix_tree_node *n)
+{
+ unsigned int i;
+
+ if (n->n_nptrs != 0) {
+ return false;
+ }
+ for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
+ if (n->n_ptrs[i] != NULL) {
+ return false;
+ }
+ }
+ return true;
+}
+
+static struct radix_tree_node *
+radix_tree_alloc_node(void)
+{
+ struct radix_tree_node *n;
+
+#if defined(_KERNEL)
+ n = pool_cache_get(radix_tree_node_cache, PR_NOWAIT);
+#else /* defined(_KERNEL) */
+#if defined(_STANDALONE)
+ n = alloc(sizeof(*n));
+#else /* defined(_STANDALONE) */
+ n = malloc(sizeof(*n));
+#endif /* defined(_STANDALONE) */
+ if (n != NULL) {
+ radix_tree_node_init(n);
+ }
+#endif /* defined(_KERNEL) */
+ KASSERT(n == NULL || radix_tree_node_clean_p(n));
+ return n;
+}
+
+static void
+radix_tree_free_node(struct radix_tree_node *n)
+{
+
+ KASSERT(radix_tree_node_clean_p(n));
+#if defined(_KERNEL)
+ pool_cache_put(radix_tree_node_cache, n);
+#elif defined(_STANDALONE)
+ dealloc(n, sizeof(*n));
+#else
+ free(n);
+#endif
+}
+
+static int
+radix_tree_grow(struct radix_tree *t, unsigned int newheight)
+{
+ const unsigned int tagmask = entry_tagmask(t->t_root);
+
+ KASSERT(newheight <= 64 / RADIX_TREE_BITS_PER_HEIGHT);
+ if (t->t_root == NULL) {
+ t->t_height = newheight;
+ return 0;
+ }
+ while (t->t_height < newheight) {
+ struct radix_tree_node *n;
+
+ n = radix_tree_alloc_node();
+ if (n == NULL) {
+ /*
+ * don't bother to revert our changes.
+ * the caller will likely retry.
+ */
+ return ENOMEM;
+ }
+ n->n_nptrs = 1;
+ n->n_ptrs[0] = t->t_root;
+ t->t_root = entry_compose(n, tagmask);
+ t->t_height++;
+ }
+ return 0;
+}
+
+/*
+ * radix_tree_lookup_ptr:
+ *
+ * an internal helper function used for various exported functions.
+ *
+ * return the pointer to store the node for the given index.
+ *
+ * if alloc is true, try to allocate the storage. (note for _KERNEL:
+ * in that case, this function can block.) if the allocation failed or
+ * alloc is false, return NULL.
+ *
+ * if path is not NULL, fill it for the caller's investigation.
+ *
+ * if tagmask is not zero, search only for nodes with the tag set.
+ * note that, however, this function doesn't check the tagmask for the leaf
+ * pointer. it's a caller's responsibility to investigate the value which
+ * is pointed by the returned pointer if necessary.
+ *
+ * while this function is a bit large, as it's called with some constant
+ * arguments, inlining might have benefits. anyway, a compiler will decide.
+ */
+
+static inline void **
+radix_tree_lookup_ptr(struct radix_tree *t, uint64_t idx,
+ struct radix_tree_path *path, bool alloc, const unsigned int tagmask)
+{
+ struct radix_tree_node *n;
+ int hshift = RADIX_TREE_BITS_PER_HEIGHT * t->t_height;
+ int shift;
+ void **vpp;
+ const uint64_t mask = (UINT64_C(1) << RADIX_TREE_BITS_PER_HEIGHT) - 1;
+ struct radix_tree_node_ref *refs = NULL;
+
+ /*
+ * check unsupported combinations
+ */
+ KASSERT(tagmask == 0 || !alloc);
+ KASSERT(path == NULL || !alloc);
+ vpp = &t->t_root;
+ if (path != NULL) {
+ refs = path->p_refs;
+ refs->pptr = vpp;
+ }
+ n = NULL;
+ for (shift = 64 - RADIX_TREE_BITS_PER_HEIGHT; shift >= 0;) {
+ struct radix_tree_node *c;
+ void *entry;
+ const uint64_t i = (idx >> shift) & mask;
+
+ if (shift >= hshift) {
+ unsigned int newheight;
+
+ KASSERT(vpp == &t->t_root);
+ if (i == 0) {
+ shift -= RADIX_TREE_BITS_PER_HEIGHT;
+ continue;
+ }
+ if (!alloc) {
+ if (path != NULL) {
+ KASSERT((refs - path->p_refs) == 0);
+ path->p_lastidx =
+ RADIX_TREE_INVALID_HEIGHT;
+ }
+ return NULL;
+ }
+ newheight = shift / RADIX_TREE_BITS_PER_HEIGHT + 1;
+ if (radix_tree_grow(t, newheight)) {
+ return NULL;
+ }
+ hshift = RADIX_TREE_BITS_PER_HEIGHT * t->t_height;
+ }
+ entry = *vpp;
+ c = entry_ptr(entry);
+ if (c == NULL ||
+ (tagmask != 0 &&
+ (entry_tagmask(entry) & tagmask) == 0)) {
+ if (!alloc) {
+ if (path != NULL) {
+ path->p_lastidx = refs - path->p_refs;
+ }
+ return NULL;
+ }
+ c = radix_tree_alloc_node();
+ if (c == NULL) {
+ return NULL;
+ }
+ *vpp = c;
+ if (n != NULL) {
+ KASSERT(n->n_nptrs < RADIX_TREE_PTR_PER_NODE);
+ n->n_nptrs++;
+ }
+ }
+ n = c;
+ vpp = &n->n_ptrs[i];
+ if (path != NULL) {
+ refs++;
+ refs->pptr = vpp;
+ }
+ shift -= RADIX_TREE_BITS_PER_HEIGHT;
+ }
+ if (alloc) {
+ KASSERT(*vpp == NULL);
+ if (n != NULL) {
+ KASSERT(n->n_nptrs < RADIX_TREE_PTR_PER_NODE);
+ n->n_nptrs++;
+ }
+ }
+ if (path != NULL) {
+ path->p_lastidx = refs - path->p_refs;
+ }
+ return vpp;
+}
+
+/*
+ * radix_tree_insert_node:
+ *
+ * insert the node at idx.
+ * it's illegal to insert NULL.
+ * it's illegal to insert a non-aligned pointer.
+ *
+ * this function returns ENOMEM if necessary memory allocation failed.
+ * otherwise, this function returns 0.
+ *
+ * note that inserting a node can involves memory allocation for intermediate
+ * nodes. if _KERNEL, it's done with no-sleep IPL_NONE memory allocation.
+ *
+ * for the newly inserted node, all tags are cleared.
+ */
+
+int
+radix_tree_insert_node(struct radix_tree *t, uint64_t idx, void *p)
+{
+ void **vpp;
+
+ KASSERT(p != NULL);
+ KASSERT(entry_compose(p, 0) == p);
+ vpp = radix_tree_lookup_ptr(t, idx, NULL, true, 0);
+ if (vpp == NULL) {
+ return ENOMEM;
+ }
+ KASSERT(*vpp == NULL);
+ *vpp = p;
+ return 0;
+}
+
+/*
+ * radix_tree_replace_node:
+ *
+ * replace a node at the given index with the given node.
+ * return the old node.
+ * it's illegal to try to replace a node which has not been inserted.
+ *
+ * this function doesn't change tags.
+ */
+
+void *
+radix_tree_replace_node(struct radix_tree *t, uint64_t idx, void *p)
+{
+ void **vpp;
+ void *oldp;
+
+ KASSERT(p != NULL);
+ KASSERT(entry_compose(p, 0) == p);
+ vpp = radix_tree_lookup_ptr(t, idx, NULL, false, 0);
+ KASSERT(vpp != NULL);
+ oldp = *vpp;
+ KASSERT(oldp != NULL);
+ *vpp = entry_compose(p, entry_tagmask(*vpp));
+ return entry_ptr(oldp);
+}
+
+/*
+ * radix_tree_remove_node:
+ *
+ * remove the node at idx.
+ * it's illegal to try to remove a node which has not been inserted.
+ */
+
+void *
+radix_tree_remove_node(struct radix_tree *t, uint64_t idx)
+{
+ struct radix_tree_path path;
+ void **vpp;
+ void *oldp;
+ int i;
+
+ vpp = radix_tree_lookup_ptr(t, idx, &path, false, 0);
+ KASSERT(vpp != NULL);
+ oldp = *vpp;
+ KASSERT(oldp != NULL);
+ KASSERT(path.p_lastidx == t->t_height);
+ KASSERT(vpp == path_pptr(t, &path, path.p_lastidx));
+ *vpp = NULL;
+ for (i = t->t_height - 1; i >= 0; i--) {
+ void *entry;
+ struct radix_tree_node ** const pptr =
+ (struct radix_tree_node **)path_pptr(t, &path, i);
+ struct radix_tree_node *n;
+
+ KASSERT(pptr != NULL);
+ entry = *pptr;
+ n = entry_ptr(entry);
+ KASSERT(n != NULL);
+ KASSERT(n->n_nptrs > 0);
+ n->n_nptrs--;
+ if (n->n_nptrs > 0) {
+ break;
+ }
+ radix_tree_free_node(n);
+ *pptr = NULL;
+ }
+ /*
+ * fix up height
+ */
+ if (i < 0) {
+ KASSERT(t->t_root == NULL);
+ t->t_height = 0;
+ }
+ /*
+ * update tags
+ */
+ for (; i >= 0; i--) {
+ void *entry;
+ struct radix_tree_node ** const pptr =
+ (struct radix_tree_node **)path_pptr(t, &path, i);
+ struct radix_tree_node *n;
+ unsigned int newmask;
+
+ KASSERT(pptr != NULL);
+ entry = *pptr;
+ n = entry_ptr(entry);
+ KASSERT(n != NULL);
+ KASSERT(n->n_nptrs > 0);
+ newmask = any_children_tagmask(n);
+ if (newmask == entry_tagmask(entry)) {
+ break;
+ }
+ *pptr = entry_compose(n, newmask);
+ }
+ /*
+ * XXX is it worth to try to reduce height?
+ * if we do that, make radix_tree_grow rollback its change as well.
+ */
+ return entry_ptr(oldp);
+}
+
+/*
+ * radix_tree_lookup_node:
+ *
+ * returns the node at idx.
+ * returns NULL if nothing is found at idx.
+ */
+
+void *
+radix_tree_lookup_node(struct radix_tree *t, uint64_t idx)
+{
+ void **vpp;
+
+ vpp = radix_tree_lookup_ptr(t, idx, NULL, false, 0);
+ if (vpp == NULL) {
+ return NULL;
+ }
+ return entry_ptr(*vpp);
+}
+
+static inline void
+gang_lookup_init(struct radix_tree *t, uint64_t idx,
+ struct radix_tree_path *path, const unsigned int tagmask)
+{
+ void **vpp;
+
+ vpp = radix_tree_lookup_ptr(t, idx, path, false, tagmask);
+ KASSERT(vpp == NULL ||
+ vpp == path_pptr(t, path, path->p_lastidx));
+ KASSERT(&t->t_root == path_pptr(t, path, 0));
+ KASSERT(path->p_lastidx == RADIX_TREE_INVALID_HEIGHT ||
+ path->p_lastidx == t->t_height ||
+ !entry_match_p(*path_pptr(t, path, path->p_lastidx), tagmask));
+}
+
+/*
+ * gang_lookup_scan:
+ *
+ * a helper routine for radix_tree_gang_lookup_node and its variants.
+ */
+
+static inline unsigned int
+__attribute__((__always_inline__))
+gang_lookup_scan(struct radix_tree *t, struct radix_tree_path *path,
+ void **results, unsigned int maxresults, const unsigned int tagmask,
+ bool reverse)
+{
+
+ /*
+ * we keep the path updated only for lastidx-1.
+ * vpp is what path_pptr(t, path, lastidx) would be.
+ */
+ void **vpp;
+ unsigned int nfound;
+ unsigned int lastidx;
+ /*
+ * set up scan direction dependant constants so that we can iterate
+ * n_ptrs as the following.
+ *
+ * for (i = first; i != guard; i += step)
+ * visit n->n_ptrs[i];
+ */
+ const int step = reverse ? -1 : 1;
+ const unsigned int first = reverse ? RADIX_TREE_PTR_PER_NODE - 1 : 0;
+ const unsigned int last = reverse ? 0 : RADIX_TREE_PTR_PER_NODE - 1;
+ const unsigned int guard = last + step;
+
+ KASSERT(maxresults > 0);
+ KASSERT(&t->t_root == path_pptr(t, path, 0));
+ lastidx = path->p_lastidx;
+ KASSERT(lastidx == RADIX_TREE_INVALID_HEIGHT ||
+ lastidx == t->t_height ||
+ !entry_match_p(*path_pptr(t, path, lastidx), tagmask));
+ nfound = 0;
+ if (lastidx == RADIX_TREE_INVALID_HEIGHT) {
+ if (reverse) {
+ lastidx = 0;
+ vpp = path_pptr(t, path, lastidx);
+ goto descend;
+ }
+ return 0;
+ }
+ vpp = path_pptr(t, path, lastidx);
+ while (/*CONSTCOND*/true) {
+ struct radix_tree_node *n;
+ unsigned int i;
+
+ if (entry_match_p(*vpp, tagmask)) {
+ KASSERT(lastidx == t->t_height);
+ /*
+ * record the matching non-NULL leaf.
+ */
+ results[nfound] = entry_ptr(*vpp);
+ nfound++;
+ if (nfound == maxresults) {
+ return nfound;
+ }
+ }
+scan_siblings:
+ /*
+ * try to find the next matching non-NULL sibling.
+ */
+ if (lastidx == 0) {
+ /*
+ * the root has no siblings.
+ * we've done.
+ */
+ KASSERT(vpp == &t->t_root);
+ break;
+ }
+ n = path_node(t, path, lastidx - 1);
+ if (*vpp != NULL && n->n_nptrs == 1) {
+ /*
+ * optimization; if the node has only a single pointer
+ * and we've already visited it, there's no point to
+ * keep scanning in this node.
+ */
+ goto no_siblings;
+ }
+ for (i = vpp - n->n_ptrs + step; i != guard; i += step) {
+ KASSERT(i < RADIX_TREE_PTR_PER_NODE);
+ if (entry_match_p(n->n_ptrs[i], tagmask)) {
+ vpp = &n->n_ptrs[i];
+ break;
+ }
+ }
+ if (i == guard) {
+no_siblings:
+ /*
+ * not found. go to parent.
+ */
+ lastidx--;
+ vpp = path_pptr(t, path, lastidx);
+ goto scan_siblings;
+ }
+descend:
+ /*
+ * following the left-most (or right-most in the case of
+ * reverse scan) child node, decend until reaching the leaf or
+ * an non-matching entry.
+ */
+ while (entry_match_p(*vpp, tagmask) && lastidx < t->t_height) {
+ /*
+ * save vpp in the path so that we can come back to this
+ * node after finishing visiting children.
+ */
+ path->p_refs[lastidx].pptr = vpp;
+ n = entry_ptr(*vpp);
+ vpp = &n->n_ptrs[first];
+ lastidx++;
+ }
+ }
+ return nfound;
+}
+
+/*
+ * radix_tree_gang_lookup_node:
+ *
+ * search nodes starting from idx in the ascending order.
+ * results should be an array large enough to hold maxresults pointers.
+ * returns the number of nodes found, up to maxresults.
+ * returning less than maxresults means there are no more nodes.
+ *
+ * the result of this function is semantically equivalent to what could be
+ * obtained by repeated calls of radix_tree_lookup_node with increasing index.
+ * but this function is much faster when node indexes are distributed sparsely.
+ *
+ * note that this function doesn't return exact values of node indexes of
+ * found nodes. if they are important for a caller, it's the caller's
+ * responsibility to check them, typically by examinining the returned nodes
+ * using some caller-specific knowledge about them.
+ */
+
+unsigned int
+radix_tree_gang_lookup_node(struct radix_tree *t, uint64_t idx,
+ void **results, unsigned int maxresults)
+{
+ struct radix_tree_path path;
+
+ gang_lookup_init(t, idx, &path, 0);
+ return gang_lookup_scan(t, &path, results, maxresults, 0, false);
+}
+
+/*
+ * radix_tree_gang_lookup_node_reverse:
+ *
+ * same as radix_tree_gang_lookup_node except that this one scans the
+ * tree in the reverse order. ie. descending index values.
+ */
+
+unsigned int
+radix_tree_gang_lookup_node_reverse(struct radix_tree *t, uint64_t idx,
+ void **results, unsigned int maxresults)
+{
+ struct radix_tree_path path;
+
+ gang_lookup_init(t, idx, &path, 0);
+ return gang_lookup_scan(t, &path, results, maxresults, 0, true);
+}
+
+/*
+ * radix_tree_gang_lookup_tagged_node:
+ *
+ * same as radix_tree_gang_lookup_node except that this one only returns
+ * nodes tagged with tagid.
+ */
+
+unsigned int
+radix_tree_gang_lookup_tagged_node(struct radix_tree *t, uint64_t idx,
+ void **results, unsigned int maxresults, radix_tree_tagid_t tagid)
+{
+ struct radix_tree_path path;
+ const unsigned int tagmask = tagid_to_mask(tagid);
+
+ gang_lookup_init(t, idx, &path, tagmask);
+ return gang_lookup_scan(t, &path, results, maxresults, tagmask, false);
+}
+
+/*
+ * radix_tree_gang_lookup_tagged_node_reverse:
+ *
+ * same as radix_tree_gang_lookup_tagged_node except that this one scans the
+ * tree in the reverse order. ie. descending index values.
+ */
+
+unsigned int
+radix_tree_gang_lookup_tagged_node_reverse(struct radix_tree *t, uint64_t idx,
+ void **results, unsigned int maxresults, radix_tree_tagid_t tagid)
+{
+ struct radix_tree_path path;
+ const unsigned int tagmask = tagid_to_mask(tagid);
+
+ gang_lookup_init(t, idx, &path, tagmask);
+ return gang_lookup_scan(t, &path, results, maxresults, tagmask, true);
+}
+
+/*
+ * radix_tree_get_tag:
+ *
+ * return if the tag is set for the node at the given index. (true if set)
+ * it's illegal to call this function for a node which has not been inserted.
+ */
+
+bool
+radix_tree_get_tag(struct radix_tree *t, uint64_t idx,
+ radix_tree_tagid_t tagid)
+{
+#if 1
+ const unsigned int tagmask = tagid_to_mask(tagid);
+ void **vpp;
+
+ vpp = radix_tree_lookup_ptr(t, idx, NULL, false, tagmask);
+ if (vpp == NULL) {
+ return false;
+ }
+ KASSERT(*vpp != NULL);
+ return (entry_tagmask(*vpp) & tagmask) != 0;
+#else
+ const unsigned int tagmask = tagid_to_mask(tagid);
+ void **vpp;
+
+ vpp = radix_tree_lookup_ptr(t, idx, NULL, false, 0);
+ KASSERT(vpp != NULL);
+ return (entry_tagmask(*vpp) & tagmask) != 0;
+#endif
+}
+
+/*
+ * radix_tree_set_tag:
+ *
+ * set the tag for the node at the given index.
+ * it's illegal to call this function for a node which has not been inserted.
+ */
+
+void
+radix_tree_set_tag(struct radix_tree *t, uint64_t idx,
+ radix_tree_tagid_t tagid)
+{
+ struct radix_tree_path path;
+ const unsigned int tagmask = tagid_to_mask(tagid);
+ void **vpp;
+ int i;
+
+ vpp = radix_tree_lookup_ptr(t, idx, &path, false, 0);
+ KASSERT(vpp != NULL);
+ KASSERT(*vpp != NULL);
+ KASSERT(path.p_lastidx == t->t_height);
+ KASSERT(vpp == path_pptr(t, &path, path.p_lastidx));
+ for (i = t->t_height; i >= 0; i--) {
+ void ** const pptr = (void **)path_pptr(t, &path, i);
+ void *entry;
+
+ KASSERT(pptr != NULL);
+ entry = *pptr;
+ if ((entry_tagmask(entry) & tagmask) != 0) {
+ break;
+ }
+ *pptr = (void *)((uintptr_t)entry | tagmask);
+ }
+}
+
+/*
+ * radix_tree_clear_tag:
+ *
+ * clear the tag for the node at the given index.
+ * it's illegal to call this function for a node which has not been inserted.
+ */
+
+void
+radix_tree_clear_tag(struct radix_tree *t, uint64_t idx,
+ radix_tree_tagid_t tagid)
+{
+ struct radix_tree_path path;
+ const unsigned int tagmask = tagid_to_mask(tagid);
+ void **vpp;
+ int i;
+
+ vpp = radix_tree_lookup_ptr(t, idx, &path, false, 0);
+ KASSERT(vpp != NULL);
+ KASSERT(*vpp != NULL);
+ KASSERT(path.p_lastidx == t->t_height);
+ KASSERT(vpp == path_pptr(t, &path, path.p_lastidx));
+ /*
+ * if already cleared, nothing to do
+ */
+ if ((entry_tagmask(*vpp) & tagmask) == 0) {
+ return;
+ }
+ /*
+ * clear the tag only if no children have the tag.
+ */
+ for (i = t->t_height; i >= 0; i--) {
+ void ** const pptr = (void **)path_pptr(t, &path, i);
+ void *entry;
+
+ KASSERT(pptr != NULL);
+ entry = *pptr;
+ KASSERT((entry_tagmask(entry) & tagmask) != 0);
+ *pptr = entry_compose(entry_ptr(entry),
+ entry_tagmask(entry) & ~tagmask);
+ /*
+ * check if we should proceed to process the next level.
+ */
+ if (0 < i) {
+ struct radix_tree_node *n = path_node(t, &path, i - 1);
+
+ if ((any_children_tagmask(n) & tagmask) != 0) {
+ break;
+ }
+ }
+ }
+}
+
+#if defined(UNITTEST)
+
+#include <inttypes.h>
+#include <stdio.h>
+
+static void
+radix_tree_dump_node(const struct radix_tree *t, void *vp,
+ uint64_t offset, unsigned int height)
+{
+ struct radix_tree_node *n;
+ unsigned int i;
+
+ for (i = 0; i < t->t_height - height; i++) {
+ printf(" ");
+ }
+ if (entry_tagmask(vp) == 0) {
+ printf("[%" PRIu64 "] %p", offset, entry_ptr(vp));
+ } else {
+ printf("[%" PRIu64 "] %p (tagmask=0x%x)", offset, entry_ptr(vp),
+ entry_tagmask(vp));
+ }
+ if (height == 0) {
+ printf(" (leaf)\n");
+ return;
+ }
+ n = entry_ptr(vp);
+ assert(any_children_tagmask(n) == entry_tagmask(vp));
+ printf(" (%u children)\n", n->n_nptrs);
+ for (i = 0; i < __arraycount(n->n_ptrs); i++) {
+ void *c;
+
+ c = n->n_ptrs[i];
+ if (c == NULL) {
+ continue;
+ }
+ radix_tree_dump_node(t, c,
+ offset + i * (UINT64_C(1) <<
+ (RADIX_TREE_BITS_PER_HEIGHT * (height - 1))), height - 1);
+ }
+}
+
+void radix_tree_dump(const struct radix_tree *);
+
+void
+radix_tree_dump(const struct radix_tree *t)
+{
+
+ printf("tree %p height=%u\n", t, t->t_height);
+ radix_tree_dump_node(t, t->t_root, 0, t->t_height);
+}
+
+static void
+test1(void)
+{
+ struct radix_tree s;
+ struct radix_tree *t = &s;
+ void *results[3];
+
+ radix_tree_init_tree(t);
+ radix_tree_dump(t);
+ assert(radix_tree_lookup_node(t, 0) == NULL);
+ assert(radix_tree_lookup_node(t, 1000) == NULL);
+ assert(radix_tree_gang_lookup_node(t, 0, results, 3) == 0);
+ assert(radix_tree_gang_lookup_node(t, 1000, results, 3) == 0);
+ assert(radix_tree_gang_lookup_node_reverse(t, 0, results, 3) == 0);
+ assert(radix_tree_gang_lookup_node_reverse(t, 1000, results, 3) == 0);
+ assert(radix_tree_gang_lookup_tagged_node(t, 0, results, 3, 0) == 0);
+ assert(radix_tree_gang_lookup_tagged_node(t, 1000, results, 3, 0) == 0);
+ assert(radix_tree_gang_lookup_tagged_node_reverse(t, 0, results, 3, 0)
+ == 0);
+ assert(radix_tree_gang_lookup_tagged_node_reverse(t, 1000, results, 3,
+ 0) == 0);
+ assert(radix_tree_empty_tree_p(t));
+ assert(radix_tree_empty_tagged_tree_p(t, 0));
+ assert(radix_tree_empty_tagged_tree_p(t, 1));
+ assert(radix_tree_insert_node(t, 0, (void *)0xdeadbea0) == 0);
+ assert(!radix_tree_empty_tree_p(t));
+ assert(radix_tree_empty_tagged_tree_p(t, 0));
+ assert(radix_tree_empty_tagged_tree_p(t, 1));
+ assert(radix_tree_lookup_node(t, 0) == (void *)0xdeadbea0);
+ assert(radix_tree_lookup_node(t, 1000) == NULL);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node(t, 0, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ assert(radix_tree_gang_lookup_node(t, 1000, results, 3) == 0);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node_reverse(t, 0, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node_reverse(t, 1000, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ assert(radix_tree_gang_lookup_tagged_node(t, 0, results, 3, 0)
+ == 0);
+ assert(radix_tree_gang_lookup_tagged_node_reverse(t, 0, results, 3, 0)
+ == 0);
+ assert(radix_tree_insert_node(t, 1000, (void *)0xdeadbea0) == 0);
+ assert(radix_tree_remove_node(t, 0) == (void *)0xdeadbea0);
+ assert(!radix_tree_empty_tree_p(t));
+ radix_tree_dump(t);
+ assert(radix_tree_lookup_node(t, 0) == NULL);
+ assert(radix_tree_lookup_node(t, 1000) == (void *)0xdeadbea0);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node(t, 0, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node(t, 1000, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ assert(radix_tree_gang_lookup_node_reverse(t, 0, results, 3) == 0);
+ memset(results, 0, sizeof(results));
+ assert(radix_tree_gang_lookup_node_reverse(t, 1000, results, 3) == 1);
+ assert(results[0] == (void *)0xdeadbea0);
+ assert(radix_tree_gang_lookup_tagged_node(t, 0, results, 3, 0)
+ == 0);
+ assert(radix_tree_gang_lookup_tagged_node_reverse(t, 0, results, 3, 0)
+ == 0);
+ assert(!radix_tree_get_tag(t, 1000, 0));
+ assert(!radix_tree_get_tag(t, 1000, 1));
+ assert(radix_tree_empty_tagged_tree_p(t, 0));
+ assert(radix_tree_empty_tagged_tree_p(t, 1));
+ radix_tree_set_tag(t, 1000, 1);
+ assert(!radix_tree_get_tag(t, 1000, 0));
+ assert(radix_tree_get_tag(t, 1000, 1));
+ assert(radix_tree_empty_tagged_tree_p(t, 0));
+ assert(!radix_tree_empty_tagged_tree_p(t, 1));
+ radix_tree_dump(t);
+ assert(radix_tree_lookup_node(t, 1000) == (void *)0xdeadbea0);
+ assert(radix_tree_insert_node(t, 0, (void *)0xbea0) == 0);
+ radix_tree_dump(t);
+ assert(radix_tree_lookup_node(t, 0) == (void *)0xbea0);
+ assert(radix_tree_lookup_node(t, 1000) == (void *)0xdeadbea0);
+ assert(radix_tree_insert_node(t, UINT64_C(10000000000), (void *)0xdea0)
+ == 0);
+ radix_tree_dump(t);
+ assert(radix_tree_lookup_node(t, 0) == (void *)0xbea0);
+ assert(radix_tree_lookup_node(t, 1000) == (void *)0xdeadbea0);
+ assert(radix_tree_lookup_node(t, UINT64_C(10000000000)) ==
+ (void *)0xdea0);
+ radix_tree_dump(t);
+ assert(!radix_tree_get_tag(t, 0, 1));
+ assert(radix_tree_get_tag(t, 1000, 1));
+ assert(!radix_tree_get_tag(t, UINT64_C(10000000000), 1));
+ radix_tree_set_tag(t, 0, 1);;
+ radix_tree_set_tag(t, UINT64_C(10000000000), 1);
+ radix_tree_dump(t);
+ assert(radix_tree_get_tag(t, 0, 1));
+ assert(radix_tree_get_tag(t, 1000, 1));
+ assert(radix_tree_get_tag(t, UINT64_C(10000000000), 1));
+ radix_tree_clear_tag(t, 0, 1);;
+ radix_tree_clear_tag(t, UINT64_C(10000000000), 1);
+ radix_tree_dump(t);
+ assert(!radix_tree_get_tag(t, 0, 1));
+ assert(radix_tree_get_tag(t, 1000, 1));
+ assert(!radix_tree_get_tag(t, UINT64_C(10000000000), 1));
+ radix_tree_dump(t);
+ assert(radix_tree_replace_node(t, 1000, (void *)0x12345678) ==
+ (void *)0xdeadbea0);
+ assert(!radix_tree_get_tag(t, 1000, 0));
+ assert(radix_tree_get_tag(t, 1000, 1));
+ assert(radix_tree_gang_lookup_node(t, 0, results, 3) == 3);
+ assert(results[0] == (void *)0xbea0);
+ assert(results[1] == (void *)0x12345678);
+ assert(results[2] == (void *)0xdea0);
+ assert(radix_tree_gang_lookup_node(t, 1, results, 3) == 2);
+ assert(results[0] == (void *)0x12345678);
+ assert(results[1] == (void *)0xdea0);
+ assert(radix_tree_gang_lookup_node(t, 1001, results, 3) == 1);
+ assert(results[0] == (void *)0xdea0);
+ assert(radix_tree_gang_lookup_node(t, UINT64_C(10000000001), results, 3)
+ == 0);
+ assert(radix_tree_gang_lookup_node(t, UINT64_C(1000000000000), results,
+ 3) == 0);
+ assert(radix_tree_gang_lookup_tagged_node(t, 0, results, 100, 1) == 1);
+ assert(results[0] == (void *)0x12345678);
+ assert(entry_tagmask(t->t_root) != 0);
+ assert(radix_tree_remove_node(t, 1000) == (void *)0x12345678);
+ assert(entry_tagmask(t->t_root) == 0);
+ radix_tree_dump(t);
+ assert(radix_tree_remove_node(t, UINT64_C(10000000000)) ==
+ (void *)0xdea0);
+ radix_tree_dump(t);
+ assert(radix_tree_remove_node(t, 0) == (void *)0xbea0);
+ radix_tree_dump(t);
+ radix_tree_fini_tree(t);
+}
+
+#include <sys/time.h>
+
+struct testnode {
+ uint64_t idx;
+ bool tagged[RADIX_TREE_TAG_ID_MAX];
+};
+
+static void
+printops(const char *title, const char *name, int tag, unsigned int n,
+ const struct timeval *stv, const struct timeval *etv)
+{
+ uint64_t s = stv->tv_sec * 1000000 + stv->tv_usec;
+ uint64_t e = etv->tv_sec * 1000000 + etv->tv_usec;
+
+ printf("RESULT %s %s %d %lf op/s\n", title, name, tag,
+ (double)n / (e - s) * 1000000);
+}
+
+#define TEST2_GANG_LOOKUP_NODES 16
+
+static bool
+test2_should_tag(unsigned int i, radix_tree_tagid_t tagid)
+{
+
+ if (tagid == 0) {
+ return (i & 0x3) == 0; /* 25% */
+ } else {
+ return (i % 7) == 0; /* 14% */
+ }
+}
+
+static void
+test2(const char *title, bool dense)
+{
+ struct radix_tree s;
+ struct radix_tree *t = &s;
+ struct testnode *n;
+ unsigned int i;
+ unsigned int nnodes = 100000;
+ unsigned int removed;
+ radix_tree_tagid_t tag;
+ unsigned int ntagged[RADIX_TREE_TAG_ID_MAX];
+ struct testnode *nodes;
+ struct timeval stv;
+ struct timeval etv;
+
+ nodes = malloc(nnodes * sizeof(*nodes));
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ ntagged[tag] = 0;
+ }
+ radix_tree_init_tree(t);
+ for (i = 0; i < nnodes; i++) {
+ n = &nodes[i];
+ n->idx = random();
+ if (sizeof(long) == 4) {
+ n->idx <<= 32;
+ n->idx |= (uint32_t)random();
+ }
+ if (dense) {
+ n->idx %= nnodes * 2;
+ }
+ while (radix_tree_lookup_node(t, n->idx) != NULL) {
+ n->idx++;
+ }
+ radix_tree_insert_node(t, n->idx, n);
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ n->tagged[tag] = test2_should_tag(i, tag);
+ if (n->tagged[tag]) {
+ radix_tree_set_tag(t, n->idx, tag);
+ ntagged[tag]++;
+ }
+ assert(n->tagged[tag] ==
+ radix_tree_get_tag(t, n->idx, tag));
+ }
+ }
+
+ gettimeofday(&stv, NULL);
+ for (i = 0; i < nnodes; i++) {
+ n = &nodes[i];
+ assert(radix_tree_lookup_node(t, n->idx) == n);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "lookup", 0, nnodes, &stv, &etv);
+
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ unsigned int count = 0;
+
+ gettimeofday(&stv, NULL);
+ for (i = 0; i < nnodes; i++) {
+ bool tagged;
+
+ n = &nodes[i];
+ tagged = radix_tree_get_tag(t, n->idx, tag);
+ assert(n->tagged[tag] == tagged);
+ if (tagged) {
+ count++;
+ }
+ }
+ gettimeofday(&etv, NULL);
+ assert(ntagged[tag] == count);
+ printops(title, "get_tag", tag, nnodes, &stv, &etv);
+ }
+
+ gettimeofday(&stv, NULL);
+ for (i = 0; i < nnodes; i++) {
+ n = &nodes[i];
+ radix_tree_remove_node(t, n->idx);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "remove", 0, nnodes, &stv, &etv);
+
+ gettimeofday(&stv, NULL);
+ for (i = 0; i < nnodes; i++) {
+ n = &nodes[i];
+ radix_tree_insert_node(t, n->idx, n);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "insert", 0, nnodes, &stv, &etv);
+
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ ntagged[tag] = 0;
+ gettimeofday(&stv, NULL);
+ for (i = 0; i < nnodes; i++) {
+ n = &nodes[i];
+ if (n->tagged[tag]) {
+ radix_tree_set_tag(t, n->idx, tag);
+ ntagged[tag]++;
+ }
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "set_tag", tag, ntagged[tag], &stv, &etv);
+ }
+
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+ unsigned int total;
+
+ nextidx = 0;
+ total = 0;
+ while ((nfound = radix_tree_gang_lookup_node(t, nextidx,
+ (void *)results, __arraycount(results))) > 0) {
+ nextidx = results[nfound - 1]->idx + 1;
+ total += nfound;
+ if (nextidx == 0) {
+ break;
+ }
+ }
+ assert(total == nnodes);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup", 0, nnodes, &stv, &etv);
+
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+ unsigned int total;
+
+ nextidx = UINT64_MAX;
+ total = 0;
+ while ((nfound = radix_tree_gang_lookup_node_reverse(t, nextidx,
+ (void *)results, __arraycount(results))) > 0) {
+ nextidx = results[nfound - 1]->idx - 1;
+ total += nfound;
+ if (nextidx == UINT64_MAX) {
+ break;
+ }
+ }
+ assert(total == nnodes);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup_reverse", 0, nnodes, &stv, &etv);
+
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+ unsigned int total;
+
+ nextidx = 0;
+ total = 0;
+ while ((nfound = radix_tree_gang_lookup_tagged_node(t,
+ nextidx, (void *)results, __arraycount(results),
+ tag)) > 0) {
+ nextidx = results[nfound - 1]->idx + 1;
+ total += nfound;
+ }
+ assert(total == ntagged[tag]);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup_tag", tag, ntagged[tag], &stv,
+ &etv);
+ }
+
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+ unsigned int total;
+
+ nextidx = UINT64_MAX;
+ total = 0;
+ while ((nfound =
+ radix_tree_gang_lookup_tagged_node_reverse(t,
+ nextidx, (void *)results, __arraycount(results),
+ tag)) > 0) {
+ nextidx = results[nfound - 1]->idx - 1;
+ total += nfound;
+ if (nextidx == UINT64_MAX) {
+ break;
+ }
+ }
+ assert(total == ntagged[tag]);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup_tag_reverse", tag, ntagged[tag],
+ &stv, &etv);
+ }
+
+ removed = 0;
+ for (tag = 0; tag < RADIX_TREE_TAG_ID_MAX; tag++) {
+ unsigned int total;
+
+ total = 0;
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+
+ nextidx = 0;
+ while ((nfound = radix_tree_gang_lookup_tagged_node(t,
+ nextidx, (void *)results, __arraycount(results),
+ tag)) > 0) {
+ for (i = 0; i < nfound; i++) {
+ radix_tree_remove_node(t,
+ results[i]->idx);
+ }
+ nextidx = results[nfound - 1]->idx + 1;
+ total += nfound;
+ if (nextidx == 0) {
+ break;
+ }
+ }
+ assert(tag != 0 || total == ntagged[tag]);
+ assert(total <= ntagged[tag]);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup_tag+remove", tag, total, &stv,
+ &etv);
+ removed += total;
+ }
+
+ gettimeofday(&stv, NULL);
+ {
+ struct testnode *results[TEST2_GANG_LOOKUP_NODES];
+ uint64_t nextidx;
+ unsigned int nfound;
+ unsigned int total;
+
+ nextidx = 0;
+ total = 0;
+ while ((nfound = radix_tree_gang_lookup_node(t, nextidx,
+ (void *)results, __arraycount(results))) > 0) {
+ for (i = 0; i < nfound; i++) {
+ assert(results[i] == radix_tree_remove_node(t,
+ results[i]->idx));
+ }
+ nextidx = results[nfound - 1]->idx + 1;
+ total += nfound;
+ if (nextidx == 0) {
+ break;
+ }
+ }
+ assert(total == nnodes - removed);
+ }
+ gettimeofday(&etv, NULL);
+ printops(title, "ganglookup+remove", 0, nnodes - removed, &stv, &etv);
+
+ assert(radix_tree_empty_tree_p(t));
+ assert(radix_tree_empty_tagged_tree_p(t, 0));
+ assert(radix_tree_empty_tagged_tree_p(t, 1));
+ radix_tree_fini_tree(t);
+ free(nodes);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ test1();
+ test2("dense", true);
+ test2("sparse", false);
+ return 0;
+}
+
+#endif /* defined(UNITTEST) */
-/* $NetBSD: rb.c,v 1.9 2010/11/17 13:19:32 tron Exp $ */
+/* $NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#else
#define KASSERT(s) do { } while (/*CONSTCOND*/ 0)
#endif
+__RCSID("$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
#else
#include <lib/libkern/libkern.h>
+__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
#endif
#ifdef _LIBC
{
rbt->rbt_ops = ops;
- *((const struct rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE;
+ rbt->rbt_root = RB_SENTINEL_NODE;
RB_TAILQ_INIT(&rbt->rbt_nodes);
#ifndef RBSMALL
rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */
-/* $NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $ */
+/* $NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $ */
/*-
* Copyright (c)2009 YAMAMOTO Takashi,
#include <sys/cdefs.h>
-#if defined(_KERNEL)
-__KERNEL_RCSID(0, "$NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $");
+#if defined(_KERNEL) || defined(_STANDALONE)
+__KERNEL_RCSID(0, "$NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $");
#include <sys/param.h>
-#else /* defined(_KERNEL) */
-__RCSID("$NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $");
+#include <lib/libkern/libkern.h>
+#if defined(_STANDALONE)
+#include <lib/libsa/stand.h>
+#endif /* defined(_STANDALONE) */
+#else /* defined(_KERNEL) || defined(_STANDALONE) */
+__RCSID("$NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $");
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#else
#define KASSERT(a)
#endif
-#endif /* defined(_KERNEL) */
+#endif /* defined(_KERNEL) || defined(_STANDALONE) */
#include <sys/rpst.h>
-/* $NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $ */
+/* $NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $ */
/*
* Copyright (c) 2003, 2004 Wasabi Systems, Inc.
#if 0
static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $");
+__RCSID("$NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $");
#endif
#endif
struct gmonparam *_m_gmon_alloc(void);
#endif
-_MCOUNT_DECL __P((u_long, u_long))
+#ifndef __LINT__
+_MCOUNT_DECL(u_long, u_long)
#ifdef _KERNEL
__attribute__((__no_instrument_function__))
#endif
__used;
+#endif
/* XXX: make these interfaces */
#ifdef _RUMPKERNEL
* both frompcindex and frompc. Any reasonable, modern compiler will
* perform this optimization.
*/
-_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
- u_long frompc, selfpc;
+#ifndef __LINT__
+/* _mcount; may be static, inline, etc */
+_MCOUNT_DECL(u_long frompc, u_long selfpc)
{
u_short *frompcindex;
struct tostruct *top, *prevtop;
#endif
return;
}
+#endif
#ifdef MCOUNT
/*
--- /dev/null
+/* $NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $ */
+
+/*
+ * MurmurHash2 -- from the original code:
+ *
+ * "MurmurHash2 was written by Austin Appleby, and is placed in the public
+ * domain. The author hereby disclaims copyright to this source code."
+ *
+ * References:
+ * http://code.google.com/p/smhasher/
+ * https://sites.google.com/site/murmurhash/
+ */
+
+#include <sys/cdefs.h>
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+__KERNEL_RCSID(0, "$NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $");
+
+#else
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/hash.h>
+
+#ifdef __weak_alias
+__weak_alias(murmurhash2,_murmurhash2)
+#endif
+
+uint32_t
+murmurhash2(const void *key, size_t len, uint32_t seed)
+{
+ /*
+ * Note: 'm' and 'r' are mixing constants generated offline.
+ * They're not really 'magic', they just happen to work well.
+ * Initialize the hash to a 'random' value.
+ */
+ const uint32_t m = 0x5bd1e995;
+ const int r = 24;
+
+ const uint8_t *data = key;
+ uint32_t h = seed ^ (uint32_t)len;
+
+ while (len >= sizeof(uint32_t)) {
+ uint32_t k;
+
+ k = data[0];
+ k |= data[1] << 8;
+ k |= data[2] << 16;
+ k |= data[3] << 24;
+
+ k *= m;
+ k ^= k >> r;
+ k *= m;
+
+ h *= m;
+ h ^= k;
+
+ data += sizeof(uint32_t);
+ len -= sizeof(uint32_t);
+ }
+
+ /* Handle the last few bytes of the input array. */
+ switch (len) {
+ case 3:
+ h ^= data[2] << 16;
+ /* FALLTHROUGH */
+ case 2:
+ h ^= data[1] << 8;
+ /* FALLTHROUGH */
+ case 1:
+ h ^= data[0];
+ h *= m;
+ }
+
+ /*
+ * Do a few final mixes of the hash to ensure the last few
+ * bytes are well-incorporated.
+ */
+ h ^= h >> 13;
+ h *= m;
+ h ^= h >> 15;
+
+ return h;
+}
-/* $NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
+/* $NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $ */
/*
* Copyright (c) 1983, 1990, 1993
static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp";
#else
-__RCSID("$NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
+__RCSID("$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
int
inet_aton(const char *cp, struct in_addr *addr) {
uint32_t val;
- int base, n;
+ int base;
+ size_t n;
char c;
uint8_t parts[4];
uint8_t *pp = parts;
-/* $NetBSD: md4c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $ */
+/* $NetBSD: md4c.c,v 1.5 2012/03/20 16:21:41 matt Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD4 Message-Digest
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md4c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $");
+__RCSID("$NetBSD: md4c.c,v 1.5 2012/03/20 16:21:41 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#define S33 11
#define S34 15
-static void MD4Transform __P((UINT4 [4], const unsigned char [64]));
+static void MD4Transform(UINT4 [4], const unsigned char [64]);
-static void Encode __P((unsigned char *, UINT4 *, unsigned int));
-static void Decode __P((UINT4 *, const unsigned char *, unsigned int));
+static void Encode(unsigned char *, UINT4 *, unsigned int);
+static void Decode(UINT4 *, const unsigned char *, unsigned int);
static const unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* $NetBSD: md5c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $ */
+/* $NetBSD: md5c.c,v 1.5 2012/03/20 16:21:41 matt Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
#else
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md5c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $");
+__RCSID("$NetBSD: md5c.c,v 1.5 2012/03/20 16:21:41 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
__weak_alias(MD5Transform,_MD5Transform)
#endif
-static void MD5Transform __P((UINT4 [4], const unsigned char [64]));
+static void MD5Transform(UINT4 [4], const unsigned char [64]);
-static void Encode __P((unsigned char *, UINT4 *, unsigned int));
-static void Decode __P((UINT4 *, const unsigned char *, unsigned int));
+static void Encode(unsigned char *, UINT4 *, unsigned int);
+static void Decode(UINT4 *, const unsigned char *, unsigned int);
/*
* Encodes input (UINT4) into output (unsigned char). Assumes len is
-/* $NetBSD: htonl.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
+/* $NetBSD: htonl.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: htonl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
+__RCSID("$NetBSD: htonl.c,v 1.3 2012/03/21 20:02:56 he Exp $");
#endif
#include <sys/types.h>
#undef htonl
uint32_t
-htonl(x)
- uint32_t x;
+htonl(uint32_t x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *)&x;
+ u_char *s = (void *)&x;
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
#else
return x;
-/* $NetBSD: htons.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
+/* $NetBSD: htons.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: htons.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
+__RCSID("$NetBSD: htons.c,v 1.3 2012/03/21 20:02:56 he Exp $");
#endif
#include <sys/types.h>
#undef htons
uint16_t
-htons(x)
- uint16_t x;
+htons(uint16_t x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *) &x;
+ u_char *s = (void *) &x;
return (uint16_t)(s[0] << 8 | s[1]);
#else
return x;
-/* $NetBSD: ntohl.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
+/* $NetBSD: ntohl.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ntohl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
+__RCSID("$NetBSD: ntohl.c,v 1.3 2012/03/21 20:02:56 he Exp $");
#endif
#include <sys/types.h>
#undef ntohl
uint32_t
-ntohl(x)
- uint32_t x;
+ntohl(uint32_t x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *)&x;
+ u_char *s = (void *)&x;
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
#else
return x;
-/* $NetBSD: ntohs.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
+/* $NetBSD: ntohs.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ntohs.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
+__RCSID("$NetBSD: ntohs.c,v 1.3 2012/03/21 20:02:56 he Exp $");
#endif
#include <sys/types.h>
#undef ntohs
uint16_t
-ntohs(x)
- uint16_t x;
+ntohs(uint16_t x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *) &x;
+ u_char *s = (void *) &x;
return (uint16_t)(s[0] << 8 | s[1]);
#else
return x;
-/* $NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)ashldi3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
return(a);
aa.q = a;
if (shift >= INT_BITS) {
- aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
+ aa.ul[H] = aa.ul[L] << (unsigned int)(shift - INT_BITS);
aa.ul[L] = 0;
} else {
aa.ul[H] = (aa.ul[H] << shift) |
-/* $NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: ashrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)ashrdi3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: ashrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
+ARM_EABI_ALIAS(__aeabi_lasr, __ashrdi3) /* no semicolon */
+
/*
* Shift a (signed) quad value right (arithmetic shift right).
*/
aa.ul[H] = s;
} else {
aa.ul[L] = (aa.ul[L] >> shift) |
- (aa.ul[H] << (INT_BITS - shift));
+ (aa.ul[H] << (unsigned int)(INT_BITS - shift));
/* LINTED inherits machine dependency */
aa.sl[H] >>= shift;
}
-/* $NetBSD: lshldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: lshldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)lshldi3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: lshldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: lshldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
+ARM_EABI_ALIAS(__aeabi_llsl, __lshldi3) /* no semicolon */
+
/*
* Shift an (unsigned) quad value left (logical shift left).
* This is the same as arithmetic shift left!
-/* $NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: lshrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)lshrdi3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: lshrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
+ARM_EABI_ALIAS(__aeabi_llsr, __lshrdi3) /* no semicolon */
+
/*
* Shift an (unsigned) quad value right (logical shift right).
*/
aa.ul[H] = 0;
} else {
aa.ul[L] = (aa.ul[L] >> shift) |
- (aa.ul[H] << (INT_BITS - shift));
+ (aa.ul[H] << (unsigned int)(INT_BITS - shift));
aa.ul[H] >>= shift;
}
return (aa.q);
-/* $NetBSD: muldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: muldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)muldi3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: muldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: muldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
+ARM_EABI_ALIAS(__aeabi_lmul, __muldi3) /* no semicolon */
+
/*
* Multiply two quads.
*
-/* $NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
+/* $NetBSD: qdivrem.c,v 1.4 2012/03/20 16:21:41 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)qdivrem.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: qdivrem.c,v 1.4 2012/03/20 16:21:41 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
-#define B ((int)1 << HALF_BITS) /* digit base */
+#define B ((int)1 << (unsigned int)HALF_BITS) /* digit base */
/* Combine two `digits' to make a single two-digit number. */
-#define COMBINE(a, b) (((u_int)(a) << HALF_BITS) | (b))
+#define COMBINE(a, b) (((u_int)(a) << (unsigned int)HALF_BITS) | (b))
/* select a type for digits in base B: use unsigned short if they fit */
#if UINT_MAX == 0xffffffffU && USHRT_MAX >= 0xffff
typedef u_int digit;
#endif
-static void shl __P((digit *p, int len, int sh));
+static void shl(digit *p, int len, int sh);
/*
* __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
* D1: choose multiplier 1 << d to ensure v[1] >= B/2.
*/
d = 0;
- for (t = v[1]; t < B / 2; t <<= 1)
+ for (t = v[1]; t < B / 2; t <<= (unsigned int)1)
d++;
if (d > 0) {
shl(&u[0], m + n, d); /* u <<= d */
if (d) {
for (i = m + n; i > m; --i)
u[i] = (digit)(((u_int)u[i] >> d) |
- LHALF((u_int)u[i - 1] << (HALF_BITS - d)));
+ LHALF((u_int)u[i - 1] << (unsigned int)(HALF_BITS - d)));
u[i] = 0;
}
tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
-/* $NetBSD: quad.h,v 1.1 2005/12/20 20:29:40 christos Exp $ */
+/* $NetBSD: quad.h,v 1.7 2012/08/06 02:31:54 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#include <machine/limits.h>
#endif
+#if defined(__ARM_EABI__) && !defined(lint)
+#define ARM_EABI_ALIAS(alias,sym) __strong_alias(alias,sym);
+#else
+#define ARM_EABI_ALIAS(alias,sym) /* nothing */
+#endif
+
/*
* Depending on the desired operation, we view a `long long' (aka quad_t) in
* one or more of the following formats.
* (sizeof(int)*CHAR_BIT/2).
*/
#define HHALF(x) ((u_int)(x) >> HALF_BITS)
-#define LHALF(x) ((u_int)(x) & (((int)1 << HALF_BITS) - 1))
-#define LHUP(x) ((u_int)(x) << HALF_BITS)
+#define LHALF(x) ((u_int)(x) & (((int)1 << (u_int)HALF_BITS) - 1))
+#define LHUP(x) ((u_int)(x) << (u_int)HALF_BITS)
/*
* XXX
#endif
__BEGIN_DECLS
-quad_t __adddi3 __P((quad_t, quad_t));
-quad_t __anddi3 __P((quad_t, quad_t));
-quad_t __ashldi3 __P((quad_t, qshift_t));
-quad_t __ashrdi3 __P((quad_t, qshift_t));
-int __cmpdi2 __P((quad_t, quad_t));
-quad_t __divdi3 __P((quad_t, quad_t));
-quad_t __fixdfdi __P((double));
-quad_t __fixsfdi __P((float));
-u_quad_t __fixunsdfdi __P((double));
-u_quad_t __fixunssfdi __P((float));
-double __floatdidf __P((quad_t));
-float __floatdisf __P((quad_t));
-double __floatunsdidf __P((u_quad_t));
-quad_t __iordi3 __P((quad_t, quad_t));
-quad_t __lshldi3 __P((quad_t, qshift_t));
-quad_t __lshrdi3 __P((quad_t, qshift_t));
-quad_t __moddi3 __P((quad_t, quad_t));
-quad_t __muldi3 __P((quad_t, quad_t));
-quad_t __negdi2 __P((quad_t));
-quad_t __one_cmpldi2 __P((quad_t));
-u_quad_t __qdivrem __P((u_quad_t, u_quad_t, u_quad_t *));
-quad_t __subdi3 __P((quad_t, quad_t));
-int __ucmpdi2 __P((u_quad_t, u_quad_t));
-u_quad_t __udivdi3 __P((u_quad_t, u_quad_t ));
-u_quad_t __umoddi3 __P((u_quad_t, u_quad_t ));
-quad_t __xordi3 __P((quad_t, quad_t));
+quad_t __adddi3(quad_t, quad_t);
+quad_t __anddi3(quad_t, quad_t);
+quad_t __ashldi3(quad_t, qshift_t);
+quad_t __ashrdi3(quad_t, qshift_t);
+int __cmpdi2(quad_t, quad_t);
+quad_t __divdi3(quad_t, quad_t);
+quad_t __fixtfdi(long double);
+quad_t __fixdfdi(double);
+quad_t __fixsfdi(float);
+u_quad_t __fixunstfdi(long double);
+u_quad_t __fixunsdfdi(double);
+u_quad_t __fixunssfdi(float);
+long double __floatditf(quad_t);
+double __floatdidf(quad_t);
+float __floatdisf(quad_t);
+long double __floatunditf(u_quad_t);
+double __floatundidf(u_quad_t);
+float __floatundisf(u_quad_t);
+quad_t __iordi3(quad_t, quad_t);
+quad_t __lshldi3(quad_t, qshift_t);
+quad_t __lshrdi3(quad_t, qshift_t);
+quad_t __moddi3(quad_t, quad_t);
+quad_t __muldi3(quad_t, quad_t);
+quad_t __negdi2(quad_t);
+quad_t __one_cmpldi2(quad_t);
+u_quad_t __qdivrem(u_quad_t, u_quad_t, u_quad_t *);
+quad_t __subdi3(quad_t, quad_t);
+int __ucmpdi2(u_quad_t, u_quad_t);
+u_quad_t __udivdi3(u_quad_t, u_quad_t );
+u_quad_t __umoddi3(u_quad_t, u_quad_t );
+quad_t __xordi3(quad_t, quad_t);
__END_DECLS
-/* $NetBSD: _strtol.h,v 1.2 2009/05/20 22:03:29 christos Exp $ */
+/* $NetBSD: _strtol.h,v 1.3 2012/03/09 15:41:16 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = (neg ? __INT_MIN : __INT_MAX);
+ cutoff = (__INT)(neg ? __INT_MIN : __INT_MAX);
cutlim = (int)(cutoff % base);
cutoff /= base;
if (neg) {
-/* $NetBSD: _strtoul.h,v 1.1 2008/08/20 12:42:26 joerg Exp $ */
+/* $NetBSD: _strtoul.h,v 1.3 2012/03/22 15:57:29 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
/*
* See strtol for comments as to the logic used.
*/
- cutoff = __UINT_MAX / (__UINT)base;
- cutlim = (int)(__UINT_MAX % (__UINT)base);
+ cutoff = ((__UINT)__UINT_MAX / (__UINT)base);
+ cutlim = (int)((__UINT)__UINT_MAX % (__UINT)base);
for (acc = 0, any = 0;; c = *s++) {
if (isdigit(c))
i = c - '0';
-/* $NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $ */
+/* $NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $");
+__RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if (*p1++ != *p2++)
break;
while (--length);
- return(length);
+ return length != 0;
}
--- /dev/null
+/* $NetBSD: consttime_bcmp.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <string.h>
+#define consttime_bcmp __consttime_bcmp
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
+int
+consttime_bcmp(const void *b1, const void *b2, size_t len)
+{
+ const char *c1 = b1, *c2 = b2;
+ int res = 0;
+
+ while (len --)
+ res |= *c1++ ^ *c2++;
+ return res;
+}
--- /dev/null
+/* $NetBSD: explicit_bzero.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <string.h>
+#define explicit_bzero __explicit_bzero
+#define explicit_memset_impl __explicit_memset_impl
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
+/*
+ * The use of a volatile pointer guarantees that the compiler
+ * will not optimise the call away.
+ */
+void *(* volatile explicit_memset_impl)(void *, int, size_t) = memset;
+
+void
+explicit_bzero(void *b, size_t len)
+{
+
+ (*explicit_memset_impl)(b, 0, len);
+}
-/* $NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $ */
+/* $NetBSD: ffs.c,v 1.4 2011/08/07 01:52:47 mrg Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.4 2011/08/07 01:52:47 mrg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/*
* ffs -- vax ffs instruction
*/
+__weak_alias(__ffssi2,ffs)
int
ffs(int mask)
{
-/* $NetBSD: memcmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */
+/* $NetBSD: memcmp.c,v 1.3 2011/11/08 16:52:11 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: memcmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
+__RCSID("$NetBSD: memcmp.c,v 1.3 2011/11/08 16:52:11 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <lib/libkern/libkern.h>
#endif
+#undef memcmp
/*
* Compare memory regions.
*/
-/* $NetBSD: memset.c,v 1.8 2009/03/18 12:25:06 tsutsui Exp $ */
+/* $NetBSD: memset.c,v 1.9 2011/11/08 16:52:11 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: memset.c,v 1.8 2009/03/18 12:25:06 tsutsui Exp $");
+__RCSID("$NetBSD: memset.c,v 1.9 2011/11/08 16:52:11 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#ifdef _FORTIFY_SOURCE
#undef bzero
-#undef memset
#endif
+#undef memset
#ifndef __OPTIMIZE_SIZE__
#ifdef BZERO
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: memset2.c,v 1.5 2012/03/02 16:22:27 apb Exp $");
+#endif /* LIBC_SCCS and not lint */
+
#include <sys/types.h>
#if !defined(_KERNEL) && !defined(_STANDALONE)
#ifdef _FORTIFY_SOURCE
#undef bzero
-#undef memset
#endif
-
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: memset2.c,v 1.2 2009/12/14 00:39:01 matt Exp $");
-#endif /* LIBC_SCCS and not lint */
+#undef memset
/*
* Assume uregister_t is the widest non-synthetic unsigned type.
*/
typedef uregister_t memword_t;
+__CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U);
+
#ifdef BZERO
static inline
#define memset memset0
#define memset test_memset
#endif
-#ifdef CTASSERT
-CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U);
-#endif
-
void *
memset(void *addr, int c, size_t len)
{
-/* $NetBSD: popcount32.c,v 1.3 2009/07/21 19:56:55 drochner Exp $ */
+/* $NetBSD: popcount32.c,v 1.4 2011/08/21 21:25:04 dholland Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: popcount32.c,v 1.3 2009/07/21 19:56:55 drochner Exp $");
+__RCSID("$NetBSD: popcount32.c,v 1.4 2011/08/21 21:25:04 dholland Exp $");
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <limits.h>
+#include <stdint.h>
#include <strings.h>
#else
#include <lib/libkern/libkern.h>
-/* $NetBSD: popcount64.c,v 1.5 2009/08/05 15:04:15 joerg Exp $ */
+/* $NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: popcount64.c,v 1.5 2009/08/05 15:04:15 joerg Exp $");
+__RCSID("$NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <limits.h>
+#include <stdint.h>
#include <strings.h>
#else
#include <lib/libkern/libkern.h>
{
unsigned int c;
- v = v - ((v >> 1) & 0x5555555555555555ULL);
- v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
- v = ((v + (v >> 4)) & 0x0f0f0f0f0f0f0f0fULL) * 0x0101010101010101ULL;
- c = v >> 56;
+ v = v - ((v >> 1) & (uint64_t)0x5555555555555555ULL);
+ v = (v & (uint64_t)0x3333333333333333ULL) +
+ ((v >> 2) & (uint64_t)0x3333333333333333ULL);
+ v = ((v + (v >> 4)) & (uint64_t)0x0f0f0f0f0f0f0f0fULL) *
+ (uint64_t)0x0101010101010101ULL;
+ c = (unsigned int)(v >> 56);
return c;
}
-/* $NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $ */
+/* $NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $");
+__RCSID("$NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
return(__UNCONST(p));
}
if (!*p)
- return((char *)NULL);
+ return(NULL);
}
/* NOTREACHED */
}
-/* $NetBSD: strcpy.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */
+/* $NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strcpy.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
+__RCSID("$NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <lib/libkern/libkern.h>
#endif
-#ifdef _FORTIFY_SOURCE
#undef strcpy
-#endif
char *
strcpy(char *to, const char *from)
-/* $NetBSD: strnlen.c,v 1.1 2009/05/01 17:27:01 perry Exp $ */
+/* $NetBSD: strnlen.c,v 1.1 2011/09/01 22:35:18 jym Exp $ */
/*-
* Copyright (c) 2009 David Schultz <das@FreeBSD.org>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strnlen.c,v 1.1 2009/05/01 17:27:01 perry Exp $");
+__RCSID("$NetBSD: strnlen.c,v 1.1 2011/09/01 22:35:18 jym Exp $");
#endif /* LIBC_SCCS and not lint */
/* FreeBSD: src/lib/libc/string/strnlen.c,v 1.1 2009/02/28 06:00:58 das Exp */
+#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <string.h>
+#else
+#include <lib/libkern/libkern.h>
+#endif
size_t
strnlen(const char *s, size_t maxlen)
-/* $NetBSD: cpuset.c,v 1.16 2010/09/21 02:03:29 rmind Exp $ */
+/* $NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
#ifndef _STANDALONE
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: cpuset.c,v 1.16 2010/09/21 02:03:29 rmind Exp $");
+__RCSID("$NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
uint32_t bits[0];
};
-#ifdef _KERNEL
-struct _kcpuset {
- unsigned int nused;
- struct _kcpuset *next;
- uint32_t bits[0];
-};
-#define KCPUSET_SIZE(n) (sizeof( \
- struct { \
- unsigned int nused; \
- struct _kcpuset *next; \
- uint32_t bits[0]; \
- }) + sizeof(uint32_t) * (n))
-#endif
+#ifndef _KERNEL
static size_t cpuset_size = 0;
static size_t cpuset_nentries = 0;
-#ifndef _KERNEL
size_t
/*ARGSUSED*/
_cpuset_size(const cpuset_t *c)
errno = EINVAL;
return -1;
}
- return ((1 << (i & CPUSET_MASK)) & c->bits[j]) != 0;
+ return ((1 << (unsigned int)(i & CPUSET_MASK)) & c->bits[j]) != 0;
}
int
errno = EINVAL;
return -1;
}
- c->bits[j] |= 1 << (i & CPUSET_MASK);
+ c->bits[j] |= 1 << (unsigned int)(i & CPUSET_MASK);
return 0;
}
errno = EINVAL;
return -1;
}
- c->bits[j] &= ~(1 << (i & CPUSET_MASK));
+ c->bits[j] &= ~(1 << (unsigned int)(i & CPUSET_MASK));
return 0;
}
u_int nc;
len = sizeof(nc);
- if (sysctl(mib, __arraycount(mib), &nc, &len, NULL, 0) == -1)
+ if (sysctl(mib, (unsigned int)__arraycount(mib), &nc, &len,
+ NULL, 0) == -1)
return NULL;
cpuset_nentries = CPUSET_NENTRIES(nc);
free(c);
}
-#else
-
-kcpuset_t *
-kcpuset_create(void)
-{
- kcpuset_t *c;
-
- if (cpuset_size == 0) {
- cpuset_nentries = CPUSET_NENTRIES(MAXCPUS);
- cpuset_size = KCPUSET_SIZE(cpuset_nentries);
- }
- c = kmem_zalloc(cpuset_size, KM_SLEEP);
- c->next = NULL;
- c->nused = 1;
- return c;
-}
-
-void
-kcpuset_destroy(kcpuset_t *c)
-{
- kcpuset_t *nc;
-
- while (c) {
- KASSERT(c->nused == 0);
- nc = c->next;
- kmem_free(c, cpuset_size);
- c = nc;
- }
-}
-
-void
-kcpuset_copy(kcpuset_t *d, const kcpuset_t *s)
-{
-
- KASSERT(d->nused == 1);
- memcpy(d->bits, s->bits, cpuset_nentries * sizeof(s->bits[0]));
-}
-
-void
-kcpuset_use(kcpuset_t *c)
-{
-
- atomic_inc_uint(&c->nused);
-}
-
-void
-kcpuset_unuse(kcpuset_t *c, kcpuset_t **lst)
-{
-
- if (atomic_dec_uint_nv(&c->nused) != 0)
- return;
- KASSERT(c->nused == 0);
- KASSERT(c->next == NULL);
- if (lst == NULL) {
- kcpuset_destroy(c);
- return;
- }
- c->next = *lst;
- *lst = c;
-}
-
-int
-kcpuset_copyin(const cpuset_t *u, kcpuset_t *k, size_t len)
-{
-
- KASSERT(k->nused > 0);
- KASSERT(k->next == NULL);
- if (len != CPUSET_SIZE(cpuset_nentries))
- return EINVAL;
- return copyin(u->bits, k->bits, cpuset_nentries * sizeof(k->bits[0]));
-}
-
-int
-kcpuset_copyout(const kcpuset_t *k, cpuset_t *u, size_t len)
-{
-
- KASSERT(k->nused > 0);
- KASSERT(k->next == NULL);
- if (len != CPUSET_SIZE(cpuset_nentries))
- return EINVAL;
- return copyout(k->bits, u->bits, cpuset_nentries * sizeof(u->bits[0]));
-}
-
-void
-kcpuset_zero(kcpuset_t *c)
-{
-
- KASSERT(c->nused > 0);
- KASSERT(c->next == NULL);
- memset(c->bits, 0, cpuset_nentries * sizeof(c->bits[0]));
-}
-
-void
-kcpuset_fill(kcpuset_t *c)
-{
-
- KASSERT(c->nused > 0);
- KASSERT(c->next == NULL);
- memset(c->bits, ~0, cpuset_nentries * sizeof(c->bits[0]));
-}
-
-void
-kcpuset_set(cpuid_t i, kcpuset_t *c)
-{
- const unsigned long j = i >> CPUSET_SHIFT;
-
- KASSERT(c->next == NULL);
- KASSERT(j < cpuset_nentries);
- c->bits[j] |= 1 << (i & CPUSET_MASK);
-}
-
-int
-kcpuset_isset(cpuid_t i, const kcpuset_t *c)
-{
- const unsigned long j = i >> CPUSET_SHIFT;
-
- KASSERT(c != NULL);
- KASSERT(c->nused > 0);
- KASSERT(c->next == NULL);
- KASSERT(j < cpuset_nentries);
- return ((1 << (i & CPUSET_MASK)) & c->bits[j]) != 0;
-}
-
-bool
-kcpuset_iszero(const kcpuset_t *c)
-{
- unsigned long j;
-
- for (j = 0; j < cpuset_nentries; j++)
- if (c->bits[j] != 0)
- return false;
- return true;
-}
-
-bool
-kcpuset_match(const kcpuset_t *c1, const kcpuset_t *c2)
-{
- unsigned long j;
-
- for (j = 0; j < cpuset_nentries; j++)
- if ((c1->bits[j] & c2->bits[j]) != c2->bits[j])
- return false;
- return true;
-}
-
#endif
#endif
-/* $NetBSD: prop_array.c,v 1.20 2008/08/11 05:54:21 christos Exp $ */
+/* $NetBSD: prop_array.c,v 1.21 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <prop/prop_array.h>
#include "prop_object_impl.h"
+#include <prop/prop_array.h>
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <errno.h>
_prop_array_iterator_next_object(void *v)
{
struct _prop_array_iterator *pai = v;
- prop_array_t pa __unused = pai->pai_base.pi_obj;
+ prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj;
prop_object_t po;
_PROP_ASSERT(prop_object_is_array(pa));
_prop_array_iterator_reset(void *v)
{
struct _prop_array_iterator *pai = v;
- prop_array_t pa __unused = pai->pai_base.pi_obj;
+ prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj;
_PROP_ASSERT(prop_object_is_array(pa));
-/* $NetBSD: prop_array_util.c,v 1.3 2011/03/24 17:05:39 bouyer Exp $ */
+/* $NetBSD: prop_array_util.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* exactly what we're doing here.
*/
-#include <prop/proplib.h>
#include "prop_object_impl.h" /* hide kernel vs. not-kernel vs. standalone */
+#include <prop/proplib.h>
bool
prop_array_get_bool(prop_array_t array,
-/* $NetBSD: prop_dictionary.c,v 1.37 2011/04/20 19:40:00 martin Exp $ */
+/* $NetBSD: prop_dictionary.c,v 1.38 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "prop_object_impl.h"
#include <prop/prop_array.h>
#include <prop/prop_dictionary.h>
#include <prop/prop_string.h>
-#include "prop_object_impl.h"
#include "prop_rb_impl.h"
#if !defined(_KERNEL) && !defined(_STANDALONE)
static int
/*ARGSUSED*/
-_prop_dict_keysym_rb_compare_nodes(void *ctx __unused,
+_prop_dict_keysym_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED,
const void *n1, const void *n2)
{
const struct _prop_dictionary_keysym *pdk1 = n1;
static int
/*ARGSUSED*/
-_prop_dict_keysym_rb_compare_key(void *ctx __unused,
+_prop_dict_keysym_rb_compare_key(void *ctx _PROP_ARG_UNUSED,
const void *n, const void *v)
{
const struct _prop_dictionary_keysym *pdk = n;
_prop_dictionary_iterator_next_object(void *v)
{
struct _prop_dictionary_iterator *pdi = v;
- prop_dictionary_t pd __unused = pdi->pdi_base.pi_obj;
+ prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
prop_dictionary_keysym_t pdk;
_PROP_ASSERT(prop_object_is_dictionary(pd));
_prop_dictionary_iterator_reset(void *v)
{
struct _prop_dictionary_iterator *pdi = v;
- prop_dictionary_t pd __unused = pdi->pdi_base.pi_obj;
+#ifdef _REENTRANT
+ prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
+#endif
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
_prop_dictionary_iterator_reset_locked(pdi);
if (! prop_object_is_dictionary(pd))
return (NULL);
+#ifdef _REENTRANT
if (!locked)
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+#endif
pde = _prop_dict_lookup(pd, key, NULL);
if (pde != NULL) {
_PROP_ASSERT(pde->pde_objref != NULL);
po = pde->pde_objref;
}
+#ifdef _REENTRANT
if (!locked)
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+#endif
return (po);
}
/*
-/* $NetBSD: prop_dictionary_util.c,v 1.4 2011/03/24 17:05:39 bouyer Exp $ */
+/* $NetBSD: prop_dictionary_util.c,v 1.5 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* exactly what we're doing here.
*/
-#include <prop/proplib.h>
#include "prop_object_impl.h" /* only to hide kernel vs. not-kernel */
+#include <prop/proplib.h>
bool
prop_dictionary_get_dict(prop_dictionary_t dict, const char *key, prop_dictionary_t *dp)
-/* $NetBSD: prop_ingest.c,v 1.3 2008/04/28 20:22:53 martin Exp $ */
+/* $NetBSD: prop_ingest.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <prop/proplib.h>
#include "prop_object_impl.h"
+#include <prop/proplib.h>
struct _prop_ingest_context {
prop_ingest_error_t pic_error;
-/* $NetBSD: prop_number.c,v 1.23 2010/09/24 22:51:52 rmind Exp $ */
+/* $NetBSD: prop_number.c,v 1.24 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
static int
/*ARGSUSED*/
-_prop_number_rb_compare_nodes(void *ctx __unused,
+_prop_number_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED,
const void *n1, const void *n2)
{
const struct _prop_number *pn1 = n1;
static int
/*ARGSUSED*/
-_prop_number_rb_compare_key(void *ctx __unused, const void *n, const void *v)
+_prop_number_rb_compare_key(void *ctx _PROP_ARG_UNUSED,
+ const void *n, const void *v)
{
const struct _prop_number *pn = n;
const struct _prop_number_value *pnv = v;
-/* $NetBSD: prop_object.c,v 1.27 2011/04/20 20:00:07 martin Exp $ */
+/* $NetBSD: prop_object.c,v 1.28 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <prop/prop_object.h>
#include "prop_object_impl.h"
+#include <prop/prop_object.h>
+
+#ifdef _PROP_NEED_REFCNT_MTX
+static pthread_mutex_t _prop_refcnt_mtx = PTHREAD_MUTEX_INITIALIZER;
+#endif /* _PROP_NEED_REFCNT_MTX */
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <sys/mman.h>
#include <assert.h>
#endif /* defined(__minix) */
#endif
-#include <sys/atomic.h>
#ifdef _STANDALONE
void *
* and create the temporary file.
*/
_prop_object_externalize_file_dirname(fname, tname);
- if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) {
+#define PLISTTMP "/.plistXXXXXX"
+ if (strlen(tname) + strlen(PLISTTMP) >= sizeof(tname)) {
errno = ENAMETOOLONG;
return (false);
}
+ strcat(tname, PLISTTMP);
+#undef PLISTTMP
+
if ((fd = mkstemp(tname)) == -1)
return (false);
struct _prop_object *po = obj;
uint32_t ncnt;
- ncnt = atomic_inc_32_nv(&po->po_refcnt);
+ _PROP_ATOMIC_INC32_NV(&po->po_refcnt, ncnt);
_PROP_ASSERT(ncnt != 0);
}
unlock = po->po_type->pot_unlock;
/* Dance a bit to make sure we always get the non-racy ocnt */
- ocnt = atomic_dec_32_nv(&po->po_refcnt);
+ _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt);
ocnt++;
_PROP_ASSERT(ocnt != 0);
unlock();
parent = po;
- atomic_inc_32(&po->po_refcnt);
+ _PROP_ATOMIC_INC32(&po->po_refcnt);
}
_PROP_ASSERT(parent);
/* One object was just freed. */
/* Save pointer to object unlock function */
unlock = po->po_type->pot_unlock;
- ocnt = atomic_dec_32_nv(&po->po_refcnt);
+ _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt);
ocnt++;
_PROP_ASSERT(ocnt != 0);
if (ret == _PROP_OBJECT_FREE_DONE)
break;
- atomic_inc_32(&po->po_refcnt);
+ _PROP_ATOMIC_INC32(&po->po_refcnt);
} while (ret == _PROP_OBJECT_FREE_RECURSE);
if (ret == _PROP_OBJECT_FREE_FAILED)
prop_object_release_emergency(obj);
-/* $NetBSD: prop_object_impl.h,v 1.30 2009/09/13 18:45:10 pooka Exp $ */
+/* $NetBSD: prop_object_impl.h,v 1.31 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
#define _PROP_ONCE_DECL(x) static ONCE_DECL(x);
#define _PROP_ONCE_RUN(x,f) RUN_ONCE(&(x), f)
+#include <sys/atomic.h>
+
+#define _PROP_ATOMIC_INC32(x) atomic_inc_32(x)
+#define _PROP_ATOMIC_DEC32(x) atomic_dec_32(x)
+#define _PROP_ATOMIC_INC32_NV(x, v) v = atomic_inc_32_nv(x)
+#define _PROP_ATOMIC_DEC32_NV(x, v) v = atomic_dec_32_nv(x)
+
#elif defined(_STANDALONE)
/*
#define _PROP_ONCE_DECL(x) _PROP_NOTHREAD_ONCE_DECL(x)
#define _PROP_ONCE_RUN(x,f) _PROP_NOTHREAD_ONCE_RUN(x,f)
+#define _PROP_ATOMIC_INC32(x) ++*(x)
+#define _PROP_ATOMIC_DEC32(x) --*(x)
+#define _PROP_ATOMIC_INC32_NV(x, v) v = ++*(x)
+#define _PROP_ATOMIC_DEC32_NV(x, v) v = --*(x)
+
#else
/*
#define _PROP_MALLOC_DEFINE(t, s, l) /* nothing */
-#if (defined(__NetBSD__) && defined(_LIBPROP))
+#if defined(__NetBSD__) && defined(_LIBPROP)
/*
* Use the same mechanism as libc; we get pthread mutexes for threaded
* programs and do-nothing stubs for non-threaded programs.
*/
+#include <sys/atomic.h>
#include "reentrant.h"
#define _PROP_MUTEX_DECL_STATIC(x) static mutex_t x;
#define _PROP_MUTEX_INIT(x) mutex_init(&(x), NULL)
static pthread_once_t x = PTHREAD_ONCE_INIT;
#define _PROP_ONCE_RUN(x,f) thr_once(&(x), (void(*)(void))f);
+#define _PROP_ATOMIC_INC32(x) atomic_inc_32(x)
+#define _PROP_ATOMIC_DEC32(x) atomic_dec_32(x)
+#define _PROP_ATOMIC_INC32_NV(x, v) v = atomic_inc_32_nv(x)
+#define _PROP_ATOMIC_DEC32_NV(x, v) v = atomic_dec_32_nv(x)
+
#elif defined(HAVE_NBTOOL_CONFIG_H) || defined(__minix)
/*
* None of NetBSD's build tools are multi-threaded.
#define _PROP_ONCE_DECL(x) _PROP_NOTHREAD_ONCE_DECL(x)
#define _PROP_ONCE_RUN(x,f) _PROP_NOTHREAD_ONCE_RUN(x,f)
+
+#define _PROP_ATOMIC_INC32(x) ++*(x)
+#define _PROP_ATOMIC_DEC32(x) --*(x)
+#define _PROP_ATOMIC_INC32_NV(x, v) v = ++*(x)
+#define _PROP_ATOMIC_DEC32_NV(x, v) v = --*(x)
+
#else
/*
* Use pthread mutexes everywhere else.
#define _PROP_ONCE_DECL(x) \
static pthread_once_t x = PTHREAD_ONCE_INIT;
#define _PROP_ONCE_RUN(x,f) pthread_once(&(x),(void(*)(void))f)
-#endif
+#define _PROP_NEED_REFCNT_MTX
+
+#define _PROP_ATOMIC_INC32(x) \
+do { \
+ pthread_mutex_lock(&_prop_refcnt_mtx); \
+ (*(x))++; \
+ pthread_mutex_unlock(&_prop_refcnt_mtx); \
+} while (/*CONSTCOND*/0)
+
+#define _PROP_ATOMIC_DEC32(x) \
+do { \
+ pthread_mutex_lock(&_prop_refcnt_mtx); \
+ (*(x))--; \
+ pthread_mutex_unlock(&_prop_refcnt_mtx); \
+} while (/*CONSTCOND*/0)
+
+#define _PROP_ATOMIC_INC32_NV(x, v) \
+do { \
+ pthread_mutex_lock(&_prop_refcnt_mtx); \
+ v = ++(*(x)); \
+ pthread_mutex_unlock(&_prop_refcnt_mtx); \
+} while (/*CONSTCOND*/0)
+
+#define _PROP_ATOMIC_DEC32_NV(x, v) \
+do { \
+ pthread_mutex_lock(&_prop_refcnt_mtx); \
+ v = --(*(x)); \
+ pthread_mutex_unlock(&_prop_refcnt_mtx); \
+} while (/*CONSTCOND*/0)
+
+#endif
#endif /* _KERNEL */
/*
-/* $NetBSD: prop_rb.c,v 1.9 2008/06/17 21:29:47 thorpej Exp $ */
+/* $NetBSD: prop_rb.c,v 1.10 2012/07/27 09:10:59 pooka Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* CONTRACT, STRICT LIABILITY, OR TORT (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: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp
*/
+#include "prop_object_impl.h"
#include <prop/proplib.h>
-#include "prop_object_impl.h"
#include "prop_rb_impl.h"
-#undef KASSERT
#ifdef RBDEBUG
-#define KASSERT(x) _PROP_ASSERT(x)
+#define KASSERT(s) _PROP_ASSERT(s)
#else
-#define KASSERT(x) /* nothing */
+#define KASSERT(s) do { } while (/*CONSTCOND*/ 0)
#endif
#ifndef __predict_false
-#define __predict_false(x) (x)
+#define __predict_false(x) (x)
#endif
-static void rb_tree_reparent_nodes(struct rb_tree *, struct rb_node *,
- unsigned int);
static void rb_tree_insert_rebalance(struct rb_tree *, struct rb_node *);
static void rb_tree_removal_rebalance(struct rb_tree *, struct rb_node *,
unsigned int);
#ifdef RBDEBUG
static const struct rb_node *rb_tree_iterate_const(const struct rb_tree *,
- const struct rb_node *, unsigned int);
+ const struct rb_node *, const unsigned int);
static bool rb_tree_check_node(const struct rb_tree *, const struct rb_node *,
const struct rb_node *, bool);
-#endif
-
-#ifdef RBDEBUG
-#define RBT_COUNT_INCR(rbt) (rbt)->rbt_count++
-#define RBT_COUNT_DECR(rbt) (rbt)->rbt_count--
#else
-#define RBT_COUNT_INCR(rbt) /* nothing */
-#define RBT_COUNT_DECR(rbt) /* nothing */
+#define rb_tree_check_node(a, b, c, d) true
#endif
-#define RBUNCONST(a) ((void *)(unsigned long)(const void *)(a))
+#define RB_NODETOITEM(rbto, rbn) \
+ ((void *)((uintptr_t)(rbn) - (rbto)->rbto_node_offset))
+#define RB_ITEMTONODE(rbto, rbn) \
+ ((rb_node_t *)((uintptr_t)(rbn) + (rbto)->rbto_node_offset))
-/*
- * Rather than testing for the NULL everywhere, all terminal leaves are
- * pointed to this node (and that includes itself). Note that by setting
- * it to be const, that on some architectures trying to write to it will
- * cause a fault.
- */
-static const struct rb_node sentinel_node = {
- .rb_nodes = { RBUNCONST(&sentinel_node),
- RBUNCONST(&sentinel_node),
- NULL },
- .rb_u = { .u_s = { .s_sentinel = 1 } },
-};
+#define RB_SENTINEL_NODE NULL
void
-_prop_rb_tree_init(struct rb_tree *rbt, const struct rb_tree_ops *ops)
+_prop_rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops)
{
+
+ rbt->rbt_ops = ops;
+ rbt->rbt_root = RB_SENTINEL_NODE;
RB_TAILQ_INIT(&rbt->rbt_nodes);
-#ifdef RBDEBUG
+#ifndef RBSMALL
+ rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */
+ rbt->rbt_minmax[RB_DIR_RIGHT] = rbt->rbt_root; /* maximum node */
+#endif
+#ifdef RBSTATS
rbt->rbt_count = 0;
+ rbt->rbt_insertions = 0;
+ rbt->rbt_removals = 0;
+ rbt->rbt_insertion_rebalance_calls = 0;
+ rbt->rbt_insertion_rebalance_passes = 0;
+ rbt->rbt_removal_rebalance_calls = 0;
+ rbt->rbt_removal_rebalance_passes = 0;
#endif
- rbt->rbt_ops = ops;
- *((const struct rb_node **)&rbt->rbt_root) = &sentinel_node;
}
-/*
- * Swap the location and colors of 'self' and its child @ which. The child
- * can not be a sentinel node.
- */
-/*ARGSUSED*/
-static void
-rb_tree_reparent_nodes(struct rb_tree *rbt _PROP_ARG_UNUSED,
- struct rb_node *old_father, unsigned int which)
+void *
+_prop_rb_tree_find(struct rb_tree *rbt, const void *key)
{
- const unsigned int other = which ^ RB_NODE_OTHER;
- struct rb_node * const grandpa = old_father->rb_parent;
- struct rb_node * const old_child = old_father->rb_nodes[which];
- struct rb_node * const new_father = old_child;
- struct rb_node * const new_child = old_father;
- unsigned int properties;
-
- KASSERT(which == RB_NODE_LEFT || which == RB_NODE_RIGHT);
-
- KASSERT(!RB_SENTINEL_P(old_child));
- KASSERT(old_child->rb_parent == old_father);
-
- KASSERT(rb_tree_check_node(rbt, old_father, NULL, false));
- KASSERT(rb_tree_check_node(rbt, old_child, NULL, false));
- KASSERT(RB_ROOT_P(old_father) || rb_tree_check_node(rbt, grandpa, NULL, false));
-
- /*
- * Exchange descendant linkages.
- */
- grandpa->rb_nodes[old_father->rb_position] = new_father;
- new_child->rb_nodes[which] = old_child->rb_nodes[other];
- new_father->rb_nodes[other] = new_child;
-
- /*
- * Update ancestor linkages
- */
- new_father->rb_parent = grandpa;
- new_child->rb_parent = new_father;
-
- /*
- * Exchange properties between new_father and new_child. The only
- * change is that new_child's position is now on the other side.
- */
- properties = old_child->rb_properties;
- new_father->rb_properties = old_father->rb_properties;
- new_child->rb_properties = properties;
- new_child->rb_position = other;
+ const rb_tree_ops_t *rbto = rbt->rbt_ops;
+ rbto_compare_key_fn compare_key = rbto->rbto_compare_key;
+ struct rb_node *parent = rbt->rbt_root;
- /*
- * Make sure to reparent the new child to ourself.
- */
- if (!RB_SENTINEL_P(new_child->rb_nodes[which])) {
- new_child->rb_nodes[which]->rb_parent = new_child;
- new_child->rb_nodes[which]->rb_position = which;
+ while (!RB_SENTINEL_P(parent)) {
+ void *pobj = RB_NODETOITEM(rbto, parent);
+ const signed int diff = (*compare_key)(rbto->rbto_context,
+ pobj, key);
+ if (diff == 0)
+ return pobj;
+ parent = parent->rb_nodes[diff < 0];
}
- KASSERT(rb_tree_check_node(rbt, new_father, NULL, false));
- KASSERT(rb_tree_check_node(rbt, new_child, NULL, false));
- KASSERT(RB_ROOT_P(new_father) || rb_tree_check_node(rbt, grandpa, NULL, false));
+ return NULL;
}
-bool
-_prop_rb_tree_insert_node(struct rb_tree *rbt, struct rb_node *self)
+void *
+_prop_rb_tree_insert_node(struct rb_tree *rbt, void *object)
{
- struct rb_node *parent, *tmp;
- rb_compare_nodes_fn compare_nodes = rbt->rbt_ops->rbto_compare_nodes;
+ const rb_tree_ops_t *rbto = rbt->rbt_ops;
+ rbto_compare_nodes_fn compare_nodes = rbto->rbto_compare_nodes;
+ struct rb_node *parent, *tmp, *self = RB_ITEMTONODE(rbto, object);
unsigned int position;
+ bool rebalance;
+
+ RBSTAT_INC(rbt->rbt_insertions);
- self->rb_properties = 0;
tmp = rbt->rbt_root;
/*
* This is a hack. Because rbt->rbt_root is just a struct rb_node *,
- * just like rb_node->rb_nodes[RB_NODE_LEFT], we can use this fact to
+ * just like rb_node->rb_nodes[RB_DIR_LEFT], we can use this fact to
* avoid a lot of tests for root and know that even at root,
- * updating rb_node->rb_parent->rb_nodes[rb_node->rb_position] will
- * rbt->rbt_root.
+ * updating RB_FATHER(rb_node)->rb_nodes[RB_POSITION(rb_node)] will
+ * update rbt->rbt_root.
*/
- /* LINTED: see above */
- parent = (struct rb_node *)&rbt->rbt_root;
- position = RB_NODE_LEFT;
+ parent = (struct rb_node *)(void *)&rbt->rbt_root;
+ position = RB_DIR_LEFT;
/*
* Find out where to place this new leaf.
*/
while (!RB_SENTINEL_P(tmp)) {
- const int diff = (*compare_nodes)(tmp, self);
+ void *tobj = RB_NODETOITEM(rbto, tmp);
+ const signed int diff = (*compare_nodes)(rbto->rbto_context,
+ tobj, object);
if (__predict_false(diff == 0)) {
/*
- * Node already exists; don't insert.
+ * Node already exists; return it.
*/
- return false;
+ return tobj;
}
parent = tmp;
- KASSERT(diff != 0);
- if (diff < 0) {
- position = RB_NODE_LEFT;
- } else {
- position = RB_NODE_RIGHT;
- }
+ position = (diff < 0);
tmp = parent->rb_nodes[position];
}
{
struct rb_node *prev = NULL, *next = NULL;
- if (position == RB_NODE_RIGHT)
+ if (position == RB_DIR_RIGHT)
prev = parent;
else if (tmp != rbt->rbt_root)
next = parent;
prev = TAILQ_PREV(next, rb_node_qh, rb_link);
KASSERT(prev == NULL || !RB_SENTINEL_P(prev));
KASSERT(next == NULL || !RB_SENTINEL_P(next));
- KASSERT(prev == NULL
- || (*compare_nodes)(prev, self) > 0);
- KASSERT(next == NULL
- || (*compare_nodes)(self, next) > 0);
+ KASSERT(prev == NULL || (*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, prev), RB_NODETOITEM(rbto, self)) < 0);
+ KASSERT(next == NULL || (*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, self), RB_NODETOITEM(rbto, next)) < 0);
}
#endif
/*
* Initialize the node and insert as a leaf into the tree.
*/
- self->rb_parent = parent;
- self->rb_position = position;
- /* LINTED: rbt_root hack */
- if (__predict_false(parent == (struct rb_node *) &rbt->rbt_root)) {
- RB_MARK_ROOT(self);
+ RB_SET_FATHER(self, parent);
+ RB_SET_POSITION(self, position);
+ if (__predict_false(parent == (struct rb_node *)(void *)&rbt->rbt_root)) {
+ RB_MARK_BLACK(self); /* root is always black */
+#ifndef RBSMALL
+ rbt->rbt_minmax[RB_DIR_LEFT] = self;
+ rbt->rbt_minmax[RB_DIR_RIGHT] = self;
+#endif
+ rebalance = false;
} else {
- KASSERT(position == RB_NODE_LEFT || position == RB_NODE_RIGHT);
- KASSERT(!RB_ROOT_P(self)); /* Already done */
+ KASSERT(position == RB_DIR_LEFT || position == RB_DIR_RIGHT);
+#ifndef RBSMALL
+ /*
+ * Keep track of the minimum and maximum nodes. If our
+ * parent is a minmax node and we on their min/max side,
+ * we must be the new min/max node.
+ */
+ if (parent == rbt->rbt_minmax[position])
+ rbt->rbt_minmax[position] = self;
+#endif /* !RBSMALL */
+ /*
+ * All new nodes are colored red. We only need to rebalance
+ * if our parent is also red.
+ */
+ RB_MARK_RED(self);
+ rebalance = RB_RED_P(parent);
}
KASSERT(RB_SENTINEL_P(parent->rb_nodes[position]));
self->rb_left = parent->rb_nodes[position];
self->rb_right = parent->rb_nodes[position];
parent->rb_nodes[position] = self;
- KASSERT(self->rb_left == &sentinel_node &&
- self->rb_right == &sentinel_node);
+ KASSERT(RB_CHILDLESS_P(self));
/*
* Insert the new node into a sorted list for easy sequential access
*/
- RBT_COUNT_INCR(rbt);
+ RBSTAT_INC(rbt->rbt_count);
#ifdef RBDEBUG
- if (RB_ROOT_P(self)) {
+ if (RB_ROOT_P(rbt, self)) {
RB_TAILQ_INSERT_HEAD(&rbt->rbt_nodes, self, rb_link);
- } else if (position == RB_NODE_LEFT) {
- KASSERT((*compare_nodes)(self, self->rb_parent) > 0);
- RB_TAILQ_INSERT_BEFORE(self->rb_parent, self, rb_link);
+ } else if (position == RB_DIR_LEFT) {
+ KASSERT((*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, self),
+ RB_NODETOITEM(rbto, RB_FATHER(self))) < 0);
+ RB_TAILQ_INSERT_BEFORE(RB_FATHER(self), self, rb_link);
} else {
- KASSERT((*compare_nodes)(self->rb_parent, self) > 0);
- RB_TAILQ_INSERT_AFTER(&rbt->rbt_nodes, self->rb_parent,
+ KASSERT((*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, RB_FATHER(self)),
+ RB_NODETOITEM(rbto, self)) < 0);
+ RB_TAILQ_INSERT_AFTER(&rbt->rbt_nodes, RB_FATHER(self),
self, rb_link);
}
#endif
+ KASSERT(rb_tree_check_node(rbt, self, NULL, !rebalance));
-#if 0
/*
- * Validate the tree before we rebalance
+ * Rebalance tree after insertion
*/
- _prop_rb_tree_check(rbt, false);
-#endif
+ if (rebalance) {
+ rb_tree_insert_rebalance(rbt, self);
+ KASSERT(rb_tree_check_node(rbt, self, NULL, true));
+ }
+
+ /* Succesfully inserted, return our node pointer. */
+ return object;
+}
+
+/*
+ * Swap the location and colors of 'self' and its child @ which. The child
+ * can not be a sentinel node. This is our rotation function. However,
+ * since it preserves coloring, it great simplifies both insertion and
+ * removal since rotation almost always involves the exchanging of colors
+ * as a separate step.
+ */
+/*ARGSUSED*/
+static void
+rb_tree_reparent_nodes(struct rb_tree *rbt, struct rb_node *old_father,
+ const unsigned int which)
+{
+ const unsigned int other = which ^ RB_DIR_OTHER;
+ struct rb_node * const grandpa = RB_FATHER(old_father);
+ struct rb_node * const old_child = old_father->rb_nodes[which];
+ struct rb_node * const new_father = old_child;
+ struct rb_node * const new_child = old_father;
+
+ KASSERT(which == RB_DIR_LEFT || which == RB_DIR_RIGHT);
+
+ KASSERT(!RB_SENTINEL_P(old_child));
+ KASSERT(RB_FATHER(old_child) == old_father);
+
+ KASSERT(rb_tree_check_node(rbt, old_father, NULL, false));
+ KASSERT(rb_tree_check_node(rbt, old_child, NULL, false));
+ KASSERT(RB_ROOT_P(rbt, old_father) ||
+ rb_tree_check_node(rbt, grandpa, NULL, false));
/*
- * Rebalance tree after insertion
+ * Exchange descendant linkages.
*/
- rb_tree_insert_rebalance(rbt, self);
+ grandpa->rb_nodes[RB_POSITION(old_father)] = new_father;
+ new_child->rb_nodes[which] = old_child->rb_nodes[other];
+ new_father->rb_nodes[other] = new_child;
-#if 0
/*
- * Validate the tree after we rebalanced
+ * Update ancestor linkages
*/
- _prop_rb_tree_check(rbt, true);
+ RB_SET_FATHER(new_father, grandpa);
+ RB_SET_FATHER(new_child, new_father);
+
+ /*
+ * Exchange properties between new_father and new_child. The only
+ * change is that new_child's position is now on the other side.
+ */
+#if 0
+ {
+ struct rb_node tmp;
+ tmp.rb_info = 0;
+ RB_COPY_PROPERTIES(&tmp, old_child);
+ RB_COPY_PROPERTIES(new_father, old_father);
+ RB_COPY_PROPERTIES(new_child, &tmp);
+ }
+#else
+ RB_SWAP_PROPERTIES(new_father, new_child);
#endif
+ RB_SET_POSITION(new_child, other);
- return true;
+ /*
+ * Make sure to reparent the new child to ourself.
+ */
+ if (!RB_SENTINEL_P(new_child->rb_nodes[which])) {
+ RB_SET_FATHER(new_child->rb_nodes[which], new_child);
+ RB_SET_POSITION(new_child->rb_nodes[which], which);
+ }
+
+ KASSERT(rb_tree_check_node(rbt, new_father, NULL, false));
+ KASSERT(rb_tree_check_node(rbt, new_child, NULL, false));
+ KASSERT(RB_ROOT_P(rbt, new_father) ||
+ rb_tree_check_node(rbt, grandpa, NULL, false));
}
-\f
+
static void
rb_tree_insert_rebalance(struct rb_tree *rbt, struct rb_node *self)
{
- RB_MARK_RED(self);
-
- while (!RB_ROOT_P(self) && RB_RED_P(self->rb_parent)) {
- const unsigned int which =
- (self->rb_parent == self->rb_parent->rb_parent->rb_left
- ? RB_NODE_LEFT
- : RB_NODE_RIGHT);
- const unsigned int other = which ^ RB_NODE_OTHER;
- struct rb_node * father = self->rb_parent;
- struct rb_node * grandpa = father->rb_parent;
- struct rb_node * const uncle = grandpa->rb_nodes[other];
+ struct rb_node * father = RB_FATHER(self);
+ struct rb_node * grandpa = RB_FATHER(father);
+ struct rb_node * uncle;
+ unsigned int which;
+ unsigned int other;
+ KASSERT(!RB_ROOT_P(rbt, self));
+ KASSERT(RB_RED_P(self));
+ KASSERT(RB_RED_P(father));
+ RBSTAT_INC(rbt->rbt_insertion_rebalance_calls);
+
+ for (;;) {
KASSERT(!RB_SENTINEL_P(self));
+
+ KASSERT(RB_RED_P(self));
+ KASSERT(RB_RED_P(father));
/*
* We are red and our parent is red, therefore we must have a
* grandfather and he must be black.
*/
- KASSERT(RB_RED_P(self)
- && RB_RED_P(father)
- && RB_BLACK_P(grandpa));
+ grandpa = RB_FATHER(father);
+ KASSERT(RB_BLACK_P(grandpa));
+ KASSERT(RB_DIR_RIGHT == 1 && RB_DIR_LEFT == 0);
+ which = (father == grandpa->rb_right);
+ other = which ^ RB_DIR_OTHER;
+ uncle = grandpa->rb_nodes[other];
+
+ if (RB_BLACK_P(uncle))
+ break;
- if (RB_RED_P(uncle)) {
+ RBSTAT_INC(rbt->rbt_insertion_rebalance_passes);
+ /*
+ * Case 1: our uncle is red
+ * Simply invert the colors of our parent and
+ * uncle and make our grandparent red. And
+ * then solve the problem up at his level.
+ */
+ RB_MARK_BLACK(uncle);
+ RB_MARK_BLACK(father);
+ if (__predict_false(RB_ROOT_P(rbt, grandpa))) {
/*
- * Case 1: our uncle is red
- * Simply invert the colors of our parent and
- * uncle and make our grandparent red. And
- * then solve the problem up at his level.
+ * If our grandpa is root, don't bother
+ * setting him to red, just return.
*/
- RB_MARK_BLACK(uncle);
- RB_MARK_BLACK(father);
- RB_MARK_RED(grandpa);
- self = grandpa;
- continue;
+ KASSERT(RB_BLACK_P(grandpa));
+ return;
}
- /*
- * Case 2&3: our uncle is black.
- */
- if (self == father->rb_nodes[other]) {
+ RB_MARK_RED(grandpa);
+ self = grandpa;
+ father = RB_FATHER(self);
+ KASSERT(RB_RED_P(self));
+ if (RB_BLACK_P(father)) {
/*
- * Case 2: we are on the same side as our uncle
- * Swap ourselves with our parent so this case
- * becomes case 3. Basically our parent becomes our
- * child.
+ * If our greatgrandpa is black, we're done.
*/
- rb_tree_reparent_nodes(rbt, father, other);
- KASSERT(father->rb_parent == self);
- KASSERT(self->rb_nodes[which] == father);
- KASSERT(self->rb_parent == grandpa);
- self = father;
- father = self->rb_parent;
+ KASSERT(RB_BLACK_P(rbt->rbt_root));
+ return;
}
- KASSERT(RB_RED_P(self) && RB_RED_P(father));
- KASSERT(grandpa->rb_nodes[which] == father);
+ }
+
+ KASSERT(!RB_ROOT_P(rbt, self));
+ KASSERT(RB_RED_P(self));
+ KASSERT(RB_RED_P(father));
+ KASSERT(RB_BLACK_P(uncle));
+ KASSERT(RB_BLACK_P(grandpa));
+ /*
+ * Case 2&3: our uncle is black.
+ */
+ if (self == father->rb_nodes[other]) {
/*
- * Case 3: we are opposite a child of a black uncle.
- * Swap our parent and grandparent. Since our grandfather
- * is black, our father will become black and our new sibling
- * (former grandparent) will become red.
+ * Case 2: we are on the same side as our uncle
+ * Swap ourselves with our parent so this case
+ * becomes case 3. Basically our parent becomes our
+ * child.
*/
- rb_tree_reparent_nodes(rbt, grandpa, which);
- KASSERT(self->rb_parent == father);
- KASSERT(self->rb_parent->rb_nodes[self->rb_position ^ RB_NODE_OTHER] == grandpa);
- KASSERT(RB_RED_P(self));
- KASSERT(RB_BLACK_P(father));
- KASSERT(RB_RED_P(grandpa));
- break;
+ rb_tree_reparent_nodes(rbt, father, other);
+ KASSERT(RB_FATHER(father) == self);
+ KASSERT(self->rb_nodes[which] == father);
+ KASSERT(RB_FATHER(self) == grandpa);
+ self = father;
+ father = RB_FATHER(self);
}
+ KASSERT(RB_RED_P(self) && RB_RED_P(father));
+ KASSERT(grandpa->rb_nodes[which] == father);
+ /*
+ * Case 3: we are opposite a child of a black uncle.
+ * Swap our parent and grandparent. Since our grandfather
+ * is black, our father will become black and our new sibling
+ * (former grandparent) will become red.
+ */
+ rb_tree_reparent_nodes(rbt, grandpa, which);
+ KASSERT(RB_FATHER(self) == father);
+ KASSERT(RB_FATHER(self)->rb_nodes[RB_POSITION(self) ^ RB_DIR_OTHER] == grandpa);
+ KASSERT(RB_RED_P(self));
+ KASSERT(RB_BLACK_P(father));
+ KASSERT(RB_RED_P(grandpa));
/*
* Final step: Set the root to black.
*/
RB_MARK_BLACK(rbt->rbt_root);
}
-\f
-struct rb_node *
-_prop_rb_tree_find(struct rb_tree *rbt, const void *key)
-{
- struct rb_node *parent = rbt->rbt_root;
- rb_compare_key_fn compare_key = rbt->rbt_ops->rbto_compare_key;
- while (!RB_SENTINEL_P(parent)) {
- const int diff = (*compare_key)(parent, key);
- if (diff == 0)
- return parent;
- parent = parent->rb_nodes[diff > 0];
- }
-
- return NULL;
-}
-\f
static void
-rb_tree_prune_node(struct rb_tree *rbt, struct rb_node *self, int rebalance)
+rb_tree_prune_node(struct rb_tree *rbt, struct rb_node *self, bool rebalance)
{
- const unsigned int which = self->rb_position;
- struct rb_node *father = self->rb_parent;
+ const unsigned int which = RB_POSITION(self);
+ struct rb_node *father = RB_FATHER(self);
+#ifndef RBSMALL
+ const bool was_root = RB_ROOT_P(rbt, self);
+#endif
- KASSERT(rebalance || (RB_ROOT_P(self) || RB_RED_P(self)));
+ KASSERT(rebalance || (RB_ROOT_P(rbt, self) || RB_RED_P(self)));
KASSERT(!rebalance || RB_BLACK_P(self));
KASSERT(RB_CHILDLESS_P(self));
KASSERT(rb_tree_check_node(rbt, self, NULL, false));
+ /*
+ * Since we are childless, we know that self->rb_left is pointing
+ * to the sentinel node.
+ */
father->rb_nodes[which] = self->rb_left;
/*
- * Remove ourselves from the node list and decrement the count.
+ * Remove ourselves from the node list, decrement the count,
+ * and update min/max.
*/
RB_TAILQ_REMOVE(&rbt->rbt_nodes, self, rb_link);
- RBT_COUNT_DECR(rbt);
+ RBSTAT_DEC(rbt->rbt_count);
+#ifndef RBSMALL
+ if (__predict_false(rbt->rbt_minmax[RB_POSITION(self)] == self)) {
+ rbt->rbt_minmax[RB_POSITION(self)] = father;
+ /*
+ * When removing the root, rbt->rbt_minmax[RB_DIR_LEFT] is
+ * updated automatically, but we also need to update
+ * rbt->rbt_minmax[RB_DIR_RIGHT];
+ */
+ if (__predict_false(was_root)) {
+ rbt->rbt_minmax[RB_DIR_RIGHT] = father;
+ }
+ }
+ RB_SET_FATHER(self, NULL);
+#endif
+ /*
+ * Rebalance if requested.
+ */
if (rebalance)
rb_tree_removal_rebalance(rbt, father, which);
- KASSERT(RB_ROOT_P(self) || rb_tree_check_node(rbt, father, NULL, true));
+ KASSERT(was_root || rb_tree_check_node(rbt, father, NULL, true));
}
+/*
+ * When deleting an interior node
+ */
static void
rb_tree_swap_prune_and_rebalance(struct rb_tree *rbt, struct rb_node *self,
struct rb_node *standin)
{
- unsigned int standin_which = standin->rb_position;
- unsigned int standin_other = standin_which ^ RB_NODE_OTHER;
- struct rb_node *standin_child;
- struct rb_node *standin_father;
+ const unsigned int standin_which = RB_POSITION(standin);
+ unsigned int standin_other = standin_which ^ RB_DIR_OTHER;
+ struct rb_node *standin_son;
+ struct rb_node *standin_father = RB_FATHER(standin);
bool rebalance = RB_BLACK_P(standin);
- if (standin->rb_parent == self) {
+ if (standin_father == self) {
/*
* As a child of self, any childen would be opposite of
- * our parent (self).
+ * our parent.
*/
KASSERT(RB_SENTINEL_P(standin->rb_nodes[standin_other]));
- standin_child = standin->rb_nodes[standin_which];
+ standin_son = standin->rb_nodes[standin_which];
} else {
/*
* Since we aren't a child of self, any childen would be
- * on the same side as our parent (self).
+ * on the same side as our parent.
*/
KASSERT(RB_SENTINEL_P(standin->rb_nodes[standin_which]));
- standin_child = standin->rb_nodes[standin_other];
+ standin_son = standin->rb_nodes[standin_other];
}
/*
/*
* If standin has a child, it must be red.
*/
- KASSERT(RB_SENTINEL_P(standin_child) || RB_RED_P(standin_child));
+ KASSERT(RB_SENTINEL_P(standin_son) || RB_RED_P(standin_son));
/*
* Verify things are sane.
KASSERT(rb_tree_check_node(rbt, self, NULL, false));
KASSERT(rb_tree_check_node(rbt, standin, NULL, false));
- if (!RB_SENTINEL_P(standin_child)) {
- /*
- * We know we have a red child so if we swap them we can
- * void flipping standin's child to black afterwards.
- */
- KASSERT(rb_tree_check_node(rbt, standin_child, NULL, true));
- rb_tree_reparent_nodes(rbt, standin,
- standin_child->rb_position);
- KASSERT(rb_tree_check_node(rbt, standin, NULL, true));
- KASSERT(rb_tree_check_node(rbt, standin_child, NULL, true));
+ if (__predict_false(RB_RED_P(standin_son))) {
/*
- * Since we are removing a red leaf, no need to rebalance.
+ * We know we have a red child so if we flip it to black
+ * we don't have to rebalance.
*/
+ KASSERT(rb_tree_check_node(rbt, standin_son, NULL, true));
+ RB_MARK_BLACK(standin_son);
rebalance = false;
- /*
- * We know that standin can not be a child of self, so
- * update before of that.
- */
- KASSERT(standin->rb_parent != self);
- standin_which = standin->rb_position;
- standin_other = standin_which ^ RB_NODE_OTHER;
+
+ if (standin_father == self) {
+ KASSERT(RB_POSITION(standin_son) == standin_which);
+ } else {
+ KASSERT(RB_POSITION(standin_son) == standin_other);
+ /*
+ * Change the son's parentage to point to his grandpa.
+ */
+ RB_SET_FATHER(standin_son, standin_father);
+ RB_SET_POSITION(standin_son, standin_which);
+ }
}
- KASSERT(RB_CHILDLESS_P(standin));
- /*
- * If we are about to delete the standin's father, then when we call
- * rebalance, we need to use ourselves as our father. Otherwise
- * remember our original father. Also, if we are our standin's father
- * we only need to reparent the standin's brother.
- */
- if (standin->rb_parent == self) {
+ if (standin_father == self) {
/*
- * | R --> S |
- * | Q S --> Q * |
- * | --> |
+ * If we are about to delete the standin's father, then when
+ * we call rebalance, we need to use ourselves as our father.
+ * Otherwise remember our original father. Also, sincef we are
+ * our standin's father we only need to reparent the standin's
+ * brother.
+ *
+ * | R --> S |
+ * | Q S --> Q T |
+ * | t --> |
*/
- standin_father = standin;
KASSERT(RB_SENTINEL_P(standin->rb_nodes[standin_other]));
KASSERT(!RB_SENTINEL_P(self->rb_nodes[standin_other]));
KASSERT(self->rb_nodes[standin_which] == standin);
/*
- * Make our brother our son.
+ * Have our son/standin adopt his brother as his new son.
*/
- standin->rb_nodes[standin_other] = self->rb_nodes[standin_other];
- standin->rb_nodes[standin_other]->rb_parent = standin;
- KASSERT(standin->rb_nodes[standin_other]->rb_position == standin_other);
+ standin_father = standin;
} else {
/*
- * | P --> P |
- * | S --> Q |
- * | Q --> |
+ * | R --> S . |
+ * | / \ | T --> / \ | / |
+ * | ..... | S --> ..... | T |
+ *
+ * Sever standin's connection to his father.
+ */
+ standin_father->rb_nodes[standin_which] = standin_son;
+ /*
+ * Adopt the far son.
+ */
+ standin->rb_nodes[standin_other] = self->rb_nodes[standin_other];
+ RB_SET_FATHER(standin->rb_nodes[standin_other], standin);
+ KASSERT(RB_POSITION(self->rb_nodes[standin_other]) == standin_other);
+ /*
+ * Use standin_other because we need to preserve standin_which
+ * for the removal_rebalance.
*/
- standin_father = standin->rb_parent;
- standin_father->rb_nodes[standin_which] =
- standin->rb_nodes[standin_which];
- standin->rb_left = self->rb_left;
- standin->rb_right = self->rb_right;
- standin->rb_left->rb_parent = standin;
- standin->rb_right->rb_parent = standin;
+ standin_other = standin_which;
}
+ /*
+ * Move the only remaining son to our standin. If our standin is our
+ * son, this will be the only son needed to be moved.
+ */
+ KASSERT(standin->rb_nodes[standin_other] != self->rb_nodes[standin_other]);
+ standin->rb_nodes[standin_other] = self->rb_nodes[standin_other];
+ RB_SET_FATHER(standin->rb_nodes[standin_other], standin);
+
/*
* Now copy the result of self to standin and then replace
* self with standin in the tree.
*/
- standin->rb_parent = self->rb_parent;
- standin->rb_properties = self->rb_properties;
- standin->rb_parent->rb_nodes[standin->rb_position] = standin;
+ RB_COPY_PROPERTIES(standin, self);
+ RB_SET_FATHER(standin, RB_FATHER(self));
+ RB_FATHER(standin)->rb_nodes[RB_POSITION(standin)] = standin;
/*
- * Remove ourselves from the node list and decrement the count.
+ * Remove ourselves from the node list, decrement the count,
+ * and update min/max.
*/
RB_TAILQ_REMOVE(&rbt->rbt_nodes, self, rb_link);
- RBT_COUNT_DECR(rbt);
+ RBSTAT_DEC(rbt->rbt_count);
+#ifndef RBSMALL
+ if (__predict_false(rbt->rbt_minmax[RB_POSITION(self)] == self))
+ rbt->rbt_minmax[RB_POSITION(self)] = RB_FATHER(self);
+ RB_SET_FATHER(self, NULL);
+#endif
KASSERT(rb_tree_check_node(rbt, standin, NULL, false));
- KASSERT(rb_tree_check_node(rbt, standin_father, NULL, false));
+ KASSERT(RB_FATHER_SENTINEL_P(standin)
+ || rb_tree_check_node(rbt, standin_father, NULL, false));
+ KASSERT(RB_LEFT_SENTINEL_P(standin)
+ || rb_tree_check_node(rbt, standin->rb_left, NULL, false));
+ KASSERT(RB_RIGHT_SENTINEL_P(standin)
+ || rb_tree_check_node(rbt, standin->rb_right, NULL, false));
if (!rebalance)
return;
*
* But it's more efficient to just evalate and recolor the child.
*/
-/*ARGSUSED*/
static void
-rb_tree_prune_blackred_branch(struct rb_tree *rbt _PROP_ARG_UNUSED,
- struct rb_node *self, unsigned int which)
+rb_tree_prune_blackred_branch(struct rb_tree *rbt, struct rb_node *self,
+ unsigned int which)
{
- struct rb_node *parent = self->rb_parent;
- struct rb_node *child = self->rb_nodes[which];
+ struct rb_node *father = RB_FATHER(self);
+ struct rb_node *son = self->rb_nodes[which];
+#ifndef RBSMALL
+ const bool was_root = RB_ROOT_P(rbt, self);
+#endif
- KASSERT(which == RB_NODE_LEFT || which == RB_NODE_RIGHT);
- KASSERT(RB_BLACK_P(self) && RB_RED_P(child));
- KASSERT(!RB_TWOCHILDREN_P(child));
- KASSERT(RB_CHILDLESS_P(child));
+ KASSERT(which == RB_DIR_LEFT || which == RB_DIR_RIGHT);
+ KASSERT(RB_BLACK_P(self) && RB_RED_P(son));
+ KASSERT(!RB_TWOCHILDREN_P(son));
+ KASSERT(RB_CHILDLESS_P(son));
KASSERT(rb_tree_check_node(rbt, self, NULL, false));
- KASSERT(rb_tree_check_node(rbt, child, NULL, false));
+ KASSERT(rb_tree_check_node(rbt, son, NULL, false));
/*
* Remove ourselves from the tree and give our former child our
* properties (position, color, root).
*/
- parent->rb_nodes[self->rb_position] = child;
- child->rb_parent = parent;
- child->rb_properties = self->rb_properties;
+ RB_COPY_PROPERTIES(son, self);
+ father->rb_nodes[RB_POSITION(son)] = son;
+ RB_SET_FATHER(son, father);
/*
- * Remove ourselves from the node list and decrement the count.
+ * Remove ourselves from the node list, decrement the count,
+ * and update minmax.
*/
RB_TAILQ_REMOVE(&rbt->rbt_nodes, self, rb_link);
- RBT_COUNT_DECR(rbt);
+ RBSTAT_DEC(rbt->rbt_count);
+#ifndef RBSMALL
+ if (__predict_false(was_root)) {
+ KASSERT(rbt->rbt_minmax[which] == son);
+ rbt->rbt_minmax[which ^ RB_DIR_OTHER] = son;
+ } else if (rbt->rbt_minmax[RB_POSITION(self)] == self) {
+ rbt->rbt_minmax[RB_POSITION(self)] = son;
+ }
+ RB_SET_FATHER(self, NULL);
+#endif
- KASSERT(RB_ROOT_P(self) || rb_tree_check_node(rbt, parent, NULL, true));
- KASSERT(rb_tree_check_node(rbt, child, NULL, true));
+ KASSERT(was_root || rb_tree_check_node(rbt, father, NULL, true));
+ KASSERT(rb_tree_check_node(rbt, son, NULL, true));
}
-/*
- *
- */
+
void
-_prop_rb_tree_remove_node(struct rb_tree *rbt, struct rb_node *self)
+_prop_rb_tree_remove_node(struct rb_tree *rbt, void *object)
{
- struct rb_node *standin;
+ const rb_tree_ops_t *rbto = rbt->rbt_ops;
+ struct rb_node *standin, *self = RB_ITEMTONODE(rbto, object);
unsigned int which;
+
+ KASSERT(!RB_SENTINEL_P(self));
+ RBSTAT_INC(rbt->rbt_removals);
+
/*
* In the following diagrams, we (the node to be removed) are S. Red
* nodes are lowercase. T could be either red or black.
* | s --> * |
*/
if (RB_CHILDLESS_P(self)) {
- if (RB_RED_P(self) || RB_ROOT_P(self)) {
- rb_tree_prune_node(rbt, self, false);
- return;
- }
- rb_tree_prune_node(rbt, self, true);
+ const bool rebalance = RB_BLACK_P(self) && !RB_ROOT_P(rbt, self);
+ rb_tree_prune_node(rbt, self, rebalance);
return;
}
KASSERT(!RB_CHILDLESS_P(self));
* | S --> R --> R |
* | r --> s --> * |
*/
- which = RB_LEFT_SENTINEL_P(self) ? RB_NODE_RIGHT : RB_NODE_LEFT;
+ which = RB_LEFT_SENTINEL_P(self) ? RB_DIR_RIGHT : RB_DIR_LEFT;
KASSERT(RB_BLACK_P(self));
KASSERT(RB_RED_P(self->rb_nodes[which]));
KASSERT(RB_CHILDLESS_P(self->rb_nodes[which]));
* We invert these because we prefer to remove from the inside of
* the tree.
*/
- which = self->rb_position ^ RB_NODE_OTHER;
+ which = RB_POSITION(self) ^ RB_DIR_OTHER;
/*
* Let's find the node closes to us opposite of our parent
* Now swap it with ourself, "prune" it, and rebalance, if needed.
*/
- standin = _prop_rb_tree_iterate(rbt, self, which);
+ standin = RB_ITEMTONODE(rbto,_prop_rb_tree_iterate(rbt, object, which));
rb_tree_swap_prune_and_rebalance(rbt, self, standin);
}
{
KASSERT(!RB_SENTINEL_P(parent));
KASSERT(RB_SENTINEL_P(parent->rb_nodes[which]));
- KASSERT(which == RB_NODE_LEFT || which == RB_NODE_RIGHT);
+ KASSERT(which == RB_DIR_LEFT || which == RB_DIR_RIGHT);
+ RBSTAT_INC(rbt->rbt_removal_rebalance_calls);
while (RB_BLACK_P(parent->rb_nodes[which])) {
- unsigned int other = which ^ RB_NODE_OTHER;
+ unsigned int other = which ^ RB_DIR_OTHER;
struct rb_node *brother = parent->rb_nodes[other];
+ RBSTAT_INC(rbt->rbt_removal_rebalance_passes);
+
KASSERT(!RB_SENTINEL_P(brother));
/*
* For cases 1, 2a, and 2b, our brother's children must
if (RB_BLACK_P(parent)
&& RB_BLACK_P(brother->rb_left)
&& RB_BLACK_P(brother->rb_right)) {
- /*
- * Case 1: Our brother is red, swap its position
- * (and colors) with our parent. This is now case 2b.
- *
- * B -> D
- * x d -> b E
- * C E -> x C
- */
if (RB_RED_P(brother)) {
+ /*
+ * Case 1: Our brother is red, swap its
+ * position (and colors) with our parent.
+ * This should now be case 2b (unless C or E
+ * has a red child which is case 3; thus no
+ * explicit branch to case 2b).
+ *
+ * B -> D
+ * A d -> b E
+ * C E -> A C
+ */
KASSERT(RB_BLACK_P(parent));
rb_tree_reparent_nodes(rbt, parent, other);
brother = parent->rb_nodes[other];
KASSERT(!RB_SENTINEL_P(brother));
- KASSERT(RB_BLACK_P(brother));
KASSERT(RB_RED_P(parent));
+ KASSERT(RB_BLACK_P(brother));
KASSERT(rb_tree_check_node(rbt, brother, NULL, false));
KASSERT(rb_tree_check_node(rbt, parent, NULL, false));
} else {
* Change our brother to red, advance up rank
* and go through the loop again.
*
- * B -> B
- * A D -> A d
+ * B -> *B
+ * *A D -> A d
* C E -> C E
*/
RB_MARK_RED(brother);
KASSERT(RB_BLACK_P(brother->rb_left));
KASSERT(RB_BLACK_P(brother->rb_right));
- if (RB_ROOT_P(parent))
- return;
+ if (RB_ROOT_P(rbt, parent))
+ return; /* root == parent == black */
KASSERT(rb_tree_check_node(rbt, brother, NULL, false));
KASSERT(rb_tree_check_node(rbt, parent, NULL, false));
- which = parent->rb_position;
- parent = parent->rb_parent;
+ which = RB_POSITION(parent);
+ parent = RB_FATHER(parent);
+ continue;
}
- } else if (RB_RED_P(parent)
+ }
+ /*
+ * Avoid an else here so that case 2a above can hit either
+ * case 2b, 3, or 4.
+ */
+ if (RB_RED_P(parent)
&& RB_BLACK_P(brother)
&& RB_BLACK_P(brother->rb_left)
&& RB_BLACK_P(brother->rb_right)) {
+ KASSERT(RB_RED_P(parent));
KASSERT(RB_BLACK_P(brother));
KASSERT(RB_BLACK_P(brother->rb_left));
KASSERT(RB_BLACK_P(brother->rb_right));
+ /*
+ * We are black, our father is red, our brother and
+ * both nephews are black. Simply invert/exchange the
+ * colors of our father and brother (to black and red
+ * respectively).
+ *
+ * | f --> F |
+ * | * B --> * b |
+ * | N N --> N N |
+ */
RB_MARK_BLACK(parent);
RB_MARK_RED(brother);
KASSERT(rb_tree_check_node(rbt, brother, NULL, true));
break; /* We're done! */
} else {
- KASSERT(RB_BLACK_P(brother));
- KASSERT(!RB_CHILDLESS_P(brother));
/*
- * Case 3: our brother is black, our left nephew is
- * red, and our right nephew is black. Swap our
- * brother with our left nephew. This result in a
- * tree that matches case 4.
- *
- * B -> D
- * A D -> B E
- * c e -> A C
+ * Our brother must be black and have at least one
+ * red child (it may have two).
*/
+ KASSERT(RB_BLACK_P(brother));
+ KASSERT(RB_RED_P(brother->rb_nodes[which]) ||
+ RB_RED_P(brother->rb_nodes[other]));
if (RB_BLACK_P(brother->rb_nodes[other])) {
+ /*
+ * Case 3: our brother is black, our near
+ * nephew is red, and our far nephew is black.
+ * Swap our brother with our near nephew.
+ * This result in a tree that matches case 4.
+ * (Our father could be red or black).
+ *
+ * | F --> F |
+ * | x B --> x B |
+ * | n --> n |
+ */
KASSERT(RB_RED_P(brother->rb_nodes[which]));
rb_tree_reparent_nodes(rbt, brother, which);
- KASSERT(brother->rb_parent == parent->rb_nodes[other]);
+ KASSERT(RB_FATHER(brother) == parent->rb_nodes[other]);
brother = parent->rb_nodes[other];
KASSERT(RB_RED_P(brother->rb_nodes[other]));
}
/*
- * Case 4: our brother is black and our right nephew
- * is red. Swap our parent and brother locations and
- * change our right nephew to black. (these can be
+ * Case 4: our brother is black and our far nephew
+ * is red. Swap our father and brother locations and
+ * change our far nephew to black. (these can be
* done in either order so we change the color first).
* The result is a valid red-black tree and is a
- * terminal case.
+ * terminal case. (again we don't care about the
+ * father's color)
*
- * B -> D
- * A D -> B E
- * c e -> A C
+ * If the father is red, we will get a red-black-black
+ * tree:
+ * | f -> f --> b |
+ * | B -> B --> F N |
+ * | n -> N --> |
+ *
+ * If the father is black, we will get an all black
+ * tree:
+ * | F -> F --> B |
+ * | B -> B --> F N |
+ * | n -> N --> |
+ *
+ * If we had two red nephews, then after the swap,
+ * our former father would have a red grandson.
*/
+ KASSERT(RB_BLACK_P(brother));
+ KASSERT(RB_RED_P(brother->rb_nodes[other]));
RB_MARK_BLACK(brother->rb_nodes[other]);
rb_tree_reparent_nodes(rbt, parent, other);
break; /* We're done! */
KASSERT(rb_tree_check_node(rbt, parent, NULL, true));
}
-struct rb_node *
-_prop_rb_tree_iterate(struct rb_tree *rbt, struct rb_node *self,
- unsigned int direction)
+void *
+_prop_rb_tree_iterate(struct rb_tree *rbt, void *object,
+ const unsigned int direction)
{
- const unsigned int other = direction ^ RB_NODE_OTHER;
- KASSERT(direction == RB_NODE_LEFT || direction == RB_NODE_RIGHT);
+ const rb_tree_ops_t *rbto = rbt->rbt_ops;
+ const unsigned int other = direction ^ RB_DIR_OTHER;
+ struct rb_node *self;
- if (self == NULL) {
+ KASSERT(direction == RB_DIR_LEFT || direction == RB_DIR_RIGHT);
+
+ if (object == NULL) {
+#ifndef RBSMALL
+ if (RB_SENTINEL_P(rbt->rbt_root))
+ return NULL;
+ return RB_NODETOITEM(rbto, rbt->rbt_minmax[direction]);
+#else
self = rbt->rbt_root;
if (RB_SENTINEL_P(self))
return NULL;
- while (!RB_SENTINEL_P(self->rb_nodes[other]))
- self = self->rb_nodes[other];
- return self;
+ while (!RB_SENTINEL_P(self->rb_nodes[direction]))
+ self = self->rb_nodes[direction];
+ return RB_NODETOITEM(rbto, self);
+#endif /* !RBSMALL */
}
+ self = RB_ITEMTONODE(rbto, object);
KASSERT(!RB_SENTINEL_P(self));
/*
* We can't go any further in this direction. We proceed up in the
* opposite direction until our parent is in direction we want to go.
*/
if (RB_SENTINEL_P(self->rb_nodes[direction])) {
- while (!RB_ROOT_P(self)) {
- if (other == self->rb_position)
- return self->rb_parent;
- self = self->rb_parent;
+ while (!RB_ROOT_P(rbt, self)) {
+ if (other == RB_POSITION(self))
+ return RB_NODETOITEM(rbto, RB_FATHER(self));
+ self = RB_FATHER(self);
}
return NULL;
}
KASSERT(!RB_SENTINEL_P(self));
while (!RB_SENTINEL_P(self->rb_nodes[other]))
self = self->rb_nodes[other];
- return self;
+ return RB_NODETOITEM(rbto, self);
}
#ifdef RBDEBUG
static const struct rb_node *
rb_tree_iterate_const(const struct rb_tree *rbt, const struct rb_node *self,
- unsigned int direction)
+ const unsigned int direction)
{
- const unsigned int other = direction ^ RB_NODE_OTHER;
- KASSERT(direction == RB_NODE_LEFT || direction == RB_NODE_RIGHT);
+ const unsigned int other = direction ^ RB_DIR_OTHER;
+ KASSERT(direction == RB_DIR_LEFT || direction == RB_DIR_RIGHT);
if (self == NULL) {
+#ifndef RBSMALL
+ if (RB_SENTINEL_P(rbt->rbt_root))
+ return NULL;
+ return rbt->rbt_minmax[direction];
+#else
self = rbt->rbt_root;
if (RB_SENTINEL_P(self))
return NULL;
- while (!RB_SENTINEL_P(self->rb_nodes[other]))
- self = self->rb_nodes[other];
+ while (!RB_SENTINEL_P(self->rb_nodes[direction]))
+ self = self->rb_nodes[direction];
return self;
+#endif /* !RBSMALL */
}
KASSERT(!RB_SENTINEL_P(self));
/*
* opposite direction until our parent is in direction we want to go.
*/
if (RB_SENTINEL_P(self->rb_nodes[direction])) {
- while (!RB_ROOT_P(self)) {
- if (other == self->rb_position)
- return self->rb_parent;
- self = self->rb_parent;
+ while (!RB_ROOT_P(rbt, self)) {
+ if (other == RB_POSITION(self))
+ return RB_FATHER(self);
+ self = RB_FATHER(self);
}
return NULL;
}
return self;
}
+static unsigned int
+rb_tree_count_black(const struct rb_node *self)
+{
+ unsigned int left, right;
+
+ if (RB_SENTINEL_P(self))
+ return 0;
+
+ left = rb_tree_count_black(self->rb_left);
+ right = rb_tree_count_black(self->rb_right);
+
+ KASSERT(left == right);
+
+ return left + RB_BLACK_P(self);
+}
+
static bool
rb_tree_check_node(const struct rb_tree *rbt, const struct rb_node *self,
const struct rb_node *prev, bool red_check)
{
- KASSERT(!self->rb_sentinel);
- KASSERT(self->rb_left);
- KASSERT(self->rb_right);
- KASSERT(prev == NULL ||
- (*rbt->rbt_ops->rbto_compare_nodes)(prev, self) > 0);
+ const rb_tree_ops_t *rbto = rbt->rbt_ops;
+ rbto_compare_nodes_fn compare_nodes = rbto->rbto_compare_nodes;
+
+ KASSERT(!RB_SENTINEL_P(self));
+ KASSERT(prev == NULL || (*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, prev), RB_NODETOITEM(rbto, self)) < 0);
/*
* Verify our relationship to our parent.
*/
- if (RB_ROOT_P(self)) {
+ if (RB_ROOT_P(rbt, self)) {
KASSERT(self == rbt->rbt_root);
- KASSERT(self->rb_position == RB_NODE_LEFT);
- KASSERT(self->rb_parent->rb_nodes[RB_NODE_LEFT] == self);
- KASSERT(self->rb_parent == (const struct rb_node *) &rbt->rbt_root);
+ KASSERT(RB_POSITION(self) == RB_DIR_LEFT);
+ KASSERT(RB_FATHER(self)->rb_nodes[RB_DIR_LEFT] == self);
+ KASSERT(RB_FATHER(self) == (const struct rb_node *) &rbt->rbt_root);
} else {
+ int diff = (*compare_nodes)(rbto->rbto_context,
+ RB_NODETOITEM(rbto, self),
+ RB_NODETOITEM(rbto, RB_FATHER(self)));
+
KASSERT(self != rbt->rbt_root);
- KASSERT(!RB_PARENT_SENTINEL_P(self));
- if (self->rb_position == RB_NODE_LEFT) {
- KASSERT((*rbt->rbt_ops->rbto_compare_nodes)(self, self->rb_parent) > 0);
- KASSERT(self->rb_parent->rb_nodes[RB_NODE_LEFT] == self);
+ KASSERT(!RB_FATHER_SENTINEL_P(self));
+ if (RB_POSITION(self) == RB_DIR_LEFT) {
+ KASSERT(diff < 0);
+ KASSERT(RB_FATHER(self)->rb_nodes[RB_DIR_LEFT] == self);
} else {
- KASSERT((*rbt->rbt_ops->rbto_compare_nodes)(self, self->rb_parent) < 0);
- KASSERT(self->rb_parent->rb_nodes[RB_NODE_RIGHT] == self);
+ KASSERT(diff > 0);
+ KASSERT(RB_FATHER(self)->rb_nodes[RB_DIR_RIGHT] == self);
}
}
* Verify our position in the linked list against the tree itself.
*/
{
- const struct rb_node *prev0 = rb_tree_iterate_const(rbt, self, RB_NODE_LEFT);
- const struct rb_node *next0 = rb_tree_iterate_const(rbt, self, RB_NODE_RIGHT);
+ const struct rb_node *prev0 = rb_tree_iterate_const(rbt, self, RB_DIR_LEFT);
+ const struct rb_node *next0 = rb_tree_iterate_const(rbt, self, RB_DIR_RIGHT);
KASSERT(prev0 == TAILQ_PREV(self, rb_node_qh, rb_link));
- if (next0 != TAILQ_NEXT(self, rb_link))
- next0 = rb_tree_iterate_const(rbt, self, RB_NODE_RIGHT);
KASSERT(next0 == TAILQ_NEXT(self, rb_link));
+#ifndef RBSMALL
+ KASSERT(prev0 != NULL || self == rbt->rbt_minmax[RB_DIR_LEFT]);
+ KASSERT(next0 != NULL || self == rbt->rbt_minmax[RB_DIR_RIGHT]);
+#endif
}
/*
* There can never be two adjacent red nodes.
*/
if (red_check) {
- KASSERT(!RB_ROOT_P(self) || RB_BLACK_P(self));
+ KASSERT(!RB_ROOT_P(rbt, self) || RB_BLACK_P(self));
+ (void) rb_tree_count_black(self);
if (RB_RED_P(self)) {
const struct rb_node *brother;
- KASSERT(!RB_ROOT_P(self));
- brother = self->rb_parent->rb_nodes[self->rb_position ^ RB_NODE_OTHER];
- KASSERT(RB_BLACK_P(self->rb_parent));
+ KASSERT(!RB_ROOT_P(rbt, self));
+ brother = RB_FATHER(self)->rb_nodes[RB_POSITION(self) ^ RB_DIR_OTHER];
+ KASSERT(RB_BLACK_P(RB_FATHER(self)));
/*
* I'm red and have no children, then I must either
* have no brother or my brother also be red and
* black, my 2nd closet relative away from my parent
* is either red or has a red parent or red children.
*/
- if (!RB_ROOT_P(self)
+ if (!RB_ROOT_P(rbt, self)
&& RB_CHILDLESS_P(self)
- && RB_BLACK_P(self->rb_parent)) {
- const unsigned int which = self->rb_position;
- const unsigned int other = which ^ RB_NODE_OTHER;
+ && RB_BLACK_P(RB_FATHER(self))) {
+ const unsigned int which = RB_POSITION(self);
+ const unsigned int other = which ^ RB_DIR_OTHER;
const struct rb_node *relative0, *relative;
relative0 = rb_tree_iterate_const(rbt,
KASSERT(RB_RED_P(relative)
|| RB_RED_P(relative->rb_left)
|| RB_RED_P(relative->rb_right)
- || RB_RED_P(relative->rb_parent));
+ || RB_RED_P(RB_FATHER(relative)));
#endif
}
}
* A grandparent's children must be real nodes and not
* sentinels. First check out grandparent.
*/
- KASSERT(RB_ROOT_P(self)
- || RB_ROOT_P(self->rb_parent)
- || RB_TWOCHILDREN_P(self->rb_parent->rb_parent));
+ KASSERT(RB_ROOT_P(rbt, self)
+ || RB_ROOT_P(rbt, RB_FATHER(self))
+ || RB_TWOCHILDREN_P(RB_FATHER(RB_FATHER(self))));
/*
* If we are have grandchildren on our left, then
* we must have a child on our right.
const struct rb_node *prev0;
const struct rb_node *next0;
- prev0 = rb_tree_iterate_const(rbt, self, RB_NODE_LEFT);
+ prev0 = rb_tree_iterate_const(rbt, self, RB_DIR_LEFT);
KASSERT(prev0 != NULL);
KASSERT(RB_RIGHT_SENTINEL_P(prev0));
- next0 = rb_tree_iterate_const(rbt, self, RB_NODE_RIGHT);
+ next0 = rb_tree_iterate_const(rbt, self, RB_DIR_RIGHT);
KASSERT(next0 != NULL);
KASSERT(RB_LEFT_SENTINEL_P(next0));
}
return true;
}
-static unsigned int
-rb_tree_count_black(const struct rb_node *self)
-{
- unsigned int left, right;
-
- if (RB_SENTINEL_P(self))
- return 0;
-
- left = rb_tree_count_black(self->rb_left);
- right = rb_tree_count_black(self->rb_right);
-
- KASSERT(left == right);
-
- return left + RB_BLACK_P(self);
-}
-
void
_prop_rb_tree_check(const struct rb_tree *rbt, bool red_check)
{
const struct rb_node *self;
const struct rb_node *prev;
- unsigned int count;
+#ifdef RBSTATS
+ unsigned int count = 0;
+#endif
+
+ KASSERT(rbt->rbt_root != NULL);
+ KASSERT(RB_LEFT_P(rbt->rbt_root));
- KASSERT(rbt->rbt_root == NULL || rbt->rbt_root->rb_position == RB_NODE_LEFT);
+#if defined(RBSTATS) && !defined(RBSMALL)
+ KASSERT(rbt->rbt_count > 1
+ || rbt->rbt_minmax[RB_DIR_LEFT] == rbt->rbt_minmax[RB_DIR_RIGHT]);
+#endif
prev = NULL;
- count = 0;
TAILQ_FOREACH(self, &rbt->rbt_nodes, rb_link) {
rb_tree_check_node(rbt, self, prev, false);
+#ifdef RBSTATS
count++;
+#endif
}
+#ifdef RBSTATS
KASSERT(rbt->rbt_count == count);
- KASSERT(RB_SENTINEL_P(rbt->rbt_root)
- || rb_tree_count_black(rbt->rbt_root));
-
- /*
- * The root must be black.
- * There can never be two adjacent red nodes.
- */
+#endif
if (red_check) {
- KASSERT(rbt->rbt_root == NULL || RB_BLACK_P(rbt->rbt_root));
+ KASSERT(RB_BLACK_P(rbt->rbt_root));
+ KASSERT(RB_SENTINEL_P(rbt->rbt_root)
+ || rb_tree_count_black(rbt->rbt_root));
+
+ /*
+ * The root must be black.
+ * There can never be two adjacent red nodes.
+ */
TAILQ_FOREACH(self, &rbt->rbt_nodes, rb_link) {
rb_tree_check_node(rbt, self, NULL, true);
}
}
}
#endif /* RBDEBUG */
+
+#ifdef RBSTATS
+static void
+rb_tree_mark_depth(const struct rb_tree *rbt, const struct rb_node *self,
+ size_t *depths, size_t depth)
+{
+ if (RB_SENTINEL_P(self))
+ return;
+
+ if (RB_TWOCHILDREN_P(self)) {
+ rb_tree_mark_depth(rbt, self->rb_left, depths, depth + 1);
+ rb_tree_mark_depth(rbt, self->rb_right, depths, depth + 1);
+ return;
+ }
+ depths[depth]++;
+ if (!RB_LEFT_SENTINEL_P(self)) {
+ rb_tree_mark_depth(rbt, self->rb_left, depths, depth + 1);
+ }
+ if (!RB_RIGHT_SENTINEL_P(self)) {
+ rb_tree_mark_depth(rbt, self->rb_right, depths, depth + 1);
+ }
+}
+
+void
+rb_tree_depths(const struct rb_tree *rbt, size_t *depths)
+{
+ rb_tree_mark_depth(rbt, rbt->rbt_root, depths, 1);
+}
+#endif /* RBSTATS */
-/* $NetBSD: prop_rb_impl.h,v 1.8 2010/09/25 01:42:38 matt Exp $ */
+/* $NetBSD: prop_rb_impl.h,v 1.9 2012/07/27 09:11:00 pooka Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#else /* __NetBSD__ */
#include <sys/types.h>
+#ifdef RBDEBUG
#include <sys/queue.h>
-#include <machine/endian.h>
-
-struct rb_node {
- struct rb_node *rb_nodes[3];
-#define RB_NODE_LEFT 0
-#define RB_NODE_RIGHT 1
-#define RB_NODE_OTHER 1
-#define RB_NODE_PARENT 2
-#define rb_left rb_nodes[RB_NODE_LEFT]
-#define rb_right rb_nodes[RB_NODE_RIGHT]
-#define rb_parent rb_nodes[RB_NODE_PARENT]
- union {
- struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned int : 28;
- unsigned int s_root : 1;
- unsigned int s_position : 1;
- unsigned int s_color : 1;
- unsigned int s_sentinel : 1;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- unsigned int s_sentinel : 1;
- unsigned int s_color : 1;
- unsigned int s_position : 1;
- unsigned int s_root : 1;
- unsigned int : 28;
#endif
- } u_s;
- unsigned int u_i;
- } rb_u;
-#define rb_root rb_u.u_s.s_root
-#define rb_position rb_u.u_s.s_position
-#define rb_color rb_u.u_s.s_color
-#define rb_sentinel rb_u.u_s.s_sentinel
-#define rb_properties rb_u.u_i
-#define RB_SENTINEL_P(rb) ((rb)->rb_sentinel + 0)
-#define RB_LEFT_SENTINEL_P(rb) ((rb)->rb_left->rb_sentinel + 0)
-#define RB_RIGHT_SENTINEL_P(rb) ((rb)->rb_right->rb_sentinel + 0)
-#define RB_PARENT_SENTINEL_P(rb) ((rb)->rb_parent->rb_sentinel + 0)
-#define RB_CHILDLESS_P(rb) (RB_LEFT_SENTINEL_P(rb) \
- && RB_RIGHT_SENTINEL_P(rb))
-#define RB_TWOCHILDREN_P(rb) (!RB_LEFT_SENTINEL_P(rb) \
- && !RB_RIGHT_SENTINEL_P(rb))
-#define RB_ROOT_P(rb) ((rb)->rb_root != false)
-#define RB_RED_P(rb) ((rb)->rb_color + 0)
-#define RB_BLACK_P(rb) (!(rb)->rb_color)
-#define RB_MARK_RED(rb) ((void)((rb)->rb_color = 1))
-#define RB_MARK_BLACK(rb) ((void)((rb)->rb_color = 0))
-#define RB_MARK_ROOT(rb) ((void)((rb)->rb_root = 1))
+
+typedef struct rb_node {
+ struct rb_node *rb_nodes[2];
+#define RB_DIR_LEFT 0
+#define RB_DIR_RIGHT 1
+#define RB_DIR_OTHER 1
+#define rb_left rb_nodes[RB_DIR_LEFT]
+#define rb_right rb_nodes[RB_DIR_RIGHT]
+
+ /*
+ * rb_info contains the two flags and the parent back pointer.
+ * We put the two flags in the low two bits since we know that
+ * rb_node will have an alignment of 4 or 8 bytes.
+ */
+ uintptr_t rb_info;
+#define RB_FLAG_POSITION 0x2
+#define RB_FLAG_RED 0x1
+#define RB_FLAG_MASK (RB_FLAG_POSITION|RB_FLAG_RED)
+#define RB_FATHER(rb) \
+ ((struct rb_node *)((rb)->rb_info & ~RB_FLAG_MASK))
+#define RB_SET_FATHER(rb, father) \
+ ((void)((rb)->rb_info = (uintptr_t)(father)|((rb)->rb_info & RB_FLAG_MASK)))
+
+#define RB_SENTINEL_P(rb) ((rb) == NULL)
+#define RB_LEFT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_left)
+#define RB_RIGHT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_right)
+#define RB_FATHER_SENTINEL_P(rb) RB_SENTINEL_P(RB_FATHER((rb)))
+#define RB_CHILDLESS_P(rb) \
+ (RB_SENTINEL_P(rb) || (RB_LEFT_SENTINEL_P(rb) && RB_RIGHT_SENTINEL_P(rb)))
+#define RB_TWOCHILDREN_P(rb) \
+ (!RB_SENTINEL_P(rb) && !RB_LEFT_SENTINEL_P(rb) && !RB_RIGHT_SENTINEL_P(rb))
+
+#define RB_POSITION(rb) \
+ (((rb)->rb_info & RB_FLAG_POSITION) ? RB_DIR_RIGHT : RB_DIR_LEFT)
+#define RB_RIGHT_P(rb) (RB_POSITION(rb) == RB_DIR_RIGHT)
+#define RB_LEFT_P(rb) (RB_POSITION(rb) == RB_DIR_LEFT)
+#define RB_RED_P(rb) (!RB_SENTINEL_P(rb) && ((rb)->rb_info & RB_FLAG_RED) != 0)
+#define RB_BLACK_P(rb) (RB_SENTINEL_P(rb) || ((rb)->rb_info & RB_FLAG_RED) == 0)
+#define RB_MARK_RED(rb) ((void)((rb)->rb_info |= RB_FLAG_RED))
+#define RB_MARK_BLACK(rb) ((void)((rb)->rb_info &= ~RB_FLAG_RED))
+#define RB_INVERT_COLOR(rb) ((void)((rb)->rb_info ^= RB_FLAG_RED))
+#define RB_ROOT_P(rbt, rb) ((rbt)->rbt_root == (rb))
+#define RB_SET_POSITION(rb, position) \
+ ((void)((position) ? ((rb)->rb_info |= RB_FLAG_POSITION) : \
+ ((rb)->rb_info &= ~RB_FLAG_POSITION)))
+#define RB_ZERO_PROPERTIES(rb) ((void)((rb)->rb_info &= ~RB_FLAG_MASK))
+#define RB_COPY_PROPERTIES(dst, src) \
+ ((void)((dst)->rb_info ^= ((dst)->rb_info ^ (src)->rb_info) & RB_FLAG_MASK))
+#define RB_SWAP_PROPERTIES(a, b) do { \
+ uintptr_t xorinfo = ((a)->rb_info ^ (b)->rb_info) & RB_FLAG_MASK; \
+ (a)->rb_info ^= xorinfo; \
+ (b)->rb_info ^= xorinfo; \
+ } while (/*CONSTCOND*/ 0)
#ifdef RBDEBUG
TAILQ_ENTRY(rb_node) rb_link;
#endif
-};
+} rb_node_t;
+
+#define RB_TREE_MIN(T) rb_tree_iterate((T), NULL, RB_DIR_LEFT)
+#define RB_TREE_MAX(T) rb_tree_iterate((T), NULL, RB_DIR_RIGHT)
+#define RB_TREE_FOREACH(N, T) \
+ for ((N) = RB_TREE_MIN(T); (N); \
+ (N) = rb_tree_iterate((T), (N), RB_DIR_RIGHT))
+#define RB_TREE_FOREACH_REVERSE(N, T) \
+ for ((N) = RB_TREE_MAX(T); (N); \
+ (N) = rb_tree_iterate((T), (N), RB_DIR_LEFT))
#ifdef RBDEBUG
TAILQ_HEAD(rb_node_qh, rb_node);
-#define RB_TAILQ_REMOVE TAILQ_REMOVE
-#define RB_TAILQ_INIT TAILQ_INIT
-#define RB_TAILQ_INSERT_HEAD(a, b, c) TAILQ_INSERT_HEAD
-#define RB_TAILQ_INSERT_BEFORE(a, b, c) TAILQ_INSERT_BEFORE
-#define RB_TAILQ_INSERT_AFTER(a, b, c, d) TAILQ_INSERT_AFTER
+#define RB_TAILQ_REMOVE(a, b, c) TAILQ_REMOVE(a, b, c)
+#define RB_TAILQ_INIT(a) TAILQ_INIT(a)
+#define RB_TAILQ_INSERT_HEAD(a, b, c) TAILQ_INSERT_HEAD(a, b, c)
+#define RB_TAILQ_INSERT_BEFORE(a, b, c) TAILQ_INSERT_BEFORE(a, b, c)
+#define RB_TAILQ_INSERT_AFTER(a, b, c, d) TAILQ_INSERT_AFTER(a, b, c, d)
#else
#define RB_TAILQ_REMOVE(a, b, c) do { } while (/*CONSTCOND*/0)
#define RB_TAILQ_INIT(a) do { } while (/*CONSTCOND*/0)
#define RB_TAILQ_INSERT_HEAD(a, b, c) do { } while (/*CONSTCOND*/0)
#define RB_TAILQ_INSERT_BEFORE(a, b, c) do { } while (/*CONSTCOND*/0)
#define RB_TAILQ_INSERT_AFTER(a, b, c, d) do { } while (/*CONSTCOND*/0)
-#endif
+#endif /* RBDEBUG */
-typedef int (*rb_compare_nodes_fn)(const struct rb_node *,
- const struct rb_node *);
-typedef int (*rb_compare_key_fn)(const struct rb_node *, const void *);
+/*
+ * rbto_compare_nodes_fn:
+ * return a positive value if the first node > the second node.
+ * return a negative value if the first node < the second node.
+ * return 0 if they are considered same.
+ *
+ * rbto_compare_key_fn:
+ * return a positive value if the node > the key.
+ * return a negative value if the node < the key.
+ * return 0 if they are considered same.
+ */
+
+typedef signed int (*rbto_compare_nodes_fn)(void *, const void *, const void *);
+typedef signed int (*rbto_compare_key_fn)(void *, const void *, const void *);
-struct rb_tree_ops {
- rb_compare_nodes_fn rbto_compare_nodes;
- rb_compare_key_fn rbto_compare_key;
-};
+typedef struct {
+ rbto_compare_nodes_fn rbto_compare_nodes;
+ rbto_compare_key_fn rbto_compare_key;
+ size_t rbto_node_offset;
+ void *rbto_context;
+} rb_tree_ops_t;
-struct rb_tree {
+typedef struct rb_tree {
struct rb_node *rbt_root;
+ const rb_tree_ops_t *rbt_ops;
+ struct rb_node *rbt_minmax[2];
#ifdef RBDEBUG
struct rb_node_qh rbt_nodes;
#endif
- const struct rb_tree_ops *rbt_ops;
-#ifdef RBDEBUG
+#ifdef RBSTATS
unsigned int rbt_count;
+ unsigned int rbt_insertions;
+ unsigned int rbt_removals;
+ unsigned int rbt_insertion_rebalance_calls;
+ unsigned int rbt_insertion_rebalance_passes;
+ unsigned int rbt_removal_rebalance_calls;
+ unsigned int rbt_removal_rebalance_passes;
+#endif
+} rb_tree_t;
+
+#ifdef RBSTATS
+#define RBSTAT_INC(v) ((void)((v)++))
+#define RBSTAT_DEC(v) ((void)((v)--))
+#else
+#define RBSTAT_INC(v) do { } while (/*CONSTCOND*/0)
+#define RBSTAT_DEC(v) do { } while (/*CONSTCOND*/0)
#endif
-};
-void _prop_rb_tree_init(struct rb_tree *, const struct rb_tree_ops *);
-bool _prop_rb_tree_insert_node(struct rb_tree *, struct rb_node *);
-struct rb_node *
- _prop_rb_tree_find(struct rb_tree *, const void *);
-void _prop_rb_tree_remove_node(struct rb_tree *, struct rb_node *);
+void _prop_rb_tree_init(rb_tree_t *, const rb_tree_ops_t *);
+void * _prop_rb_tree_insert_node(rb_tree_t *, void *);
+void * _prop_rb_tree_find(rb_tree_t *, const void *);
+void * _prop_rb_tree_find_node(rb_tree_t *, const void *);
+void _prop_rb_tree_remove_node(rb_tree_t *, void *);
+void * _prop_rb_tree_iterate(rb_tree_t *, void *, const unsigned int);
#ifdef RBDEBUG
void _prop_rb_tree_check(const struct rb_tree *, bool);
#endif
-struct rb_node *
- _prop_rb_tree_iterate(struct rb_tree *, struct rb_node *, unsigned int);
#endif /* __NetBSD__ */
-.\" $NetBSD: proplib.3,v 1.7 2011/01/19 20:34:23 bouyer Exp $
+.\" $NetBSD: proplib.3,v 1.8 2012/03/15 22:35:02 njoly Exp $
.\"
.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
This external representation is an XML document whose format is described
by the following DTD:
.Bd -literal -offset indent
-http://www.apple.com/DTDs/PropertyList-1.0.dtd
+.Lk http://www.apple.com/DTDs/PropertyList-1.0.dtd
.Ed
.Pp
Property container objects are reference counted.
--- /dev/null
+/* $NetBSD: getfstypename.c,v 1.8 2012/04/07 16:28:59 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 _STANDALONE
+# include <sys/cdefs.h>
+# ifndef _KERNEL
+# if !defined(lint)
+__RCSID("$NetBSD: getfstypename.c,v 1.8 2012/04/07 16:28:59 christos Exp $");
+# endif
+# else
+__KERNEL_RCSID(0, "$NetBSD: getfstypename.c,v 1.8 2012/04/07 16:28:59 christos Exp $");
+# endif /* _KERNEL */
+
+# define FSTYPE_ENUMNAME fstype_enum
+# include <sys/types.h>
+# include <sys/disk.h>
+# include <sys/disklabel.h>
+# ifndef _KERNEL
+# include <util.h>
+# endif
+
+const char *
+getfstypename(int fstype)
+{
+ /*
+ * The cast is so that the compiler can check that we
+ * cover all the enum values
+ */
+ switch ((enum fstype_enum)fstype) {
+ case FS_UNUSED:
+ return DKW_PTYPE_UNUSED;
+ case FS_SWAP:
+ return DKW_PTYPE_SWAP;
+ case FS_V6:
+ return DKW_PTYPE_V6;
+ case FS_V7:
+ return DKW_PTYPE_V7;
+ case FS_SYSV:
+ return DKW_PTYPE_SYSV;
+ case FS_V71K:
+ return DKW_PTYPE_V71K;
+ case FS_V8:
+ return DKW_PTYPE_V8;
+ case FS_BSDFFS:
+ return DKW_PTYPE_FFS;
+ case FS_MSDOS:
+ return DKW_PTYPE_FAT;
+ case FS_BSDLFS:
+ return DKW_PTYPE_LFS;
+ case FS_OTHER:
+ return DKW_PTYPE_OTHER;
+ case FS_HPFS:
+ return DKW_PTYPE_HPFS;
+ case FS_ISO9660:
+ return DKW_PTYPE_ISO9660;
+ case FS_BOOT:
+ return DKW_PTYPE_BOOT;
+ case FS_ADOS:
+ return DKW_PTYPE_AMIGADOS;
+ case FS_HFS:
+ return DKW_PTYPE_APPLEHFS;
+ case FS_FILECORE:
+ return DKW_PTYPE_FILECORE;
+ case FS_EX2FS:
+ return DKW_PTYPE_EXT2FS;
+ case FS_NTFS:
+ return DKW_PTYPE_NTFS;
+ case FS_RAID:
+ return DKW_PTYPE_RAIDFRAME;
+ case FS_CCD:
+ return DKW_PTYPE_CCD;
+ case FS_JFS2:
+ return DKW_PTYPE_JFS2;
+ case FS_APPLEUFS:
+ return DKW_PTYPE_APPLEUFS;
+ case FS_VINUM:
+ return DKW_PTYPE_VINUM;
+ case FS_UDF:
+ return DKW_PTYPE_UDF;
+ case FS_SYSVBFS:
+ return DKW_PTYPE_SYSVBFS;
+ case FS_EFS:
+ return DKW_PTYPE_EFS;
+ case FS_NILFS:
+ return DKW_PTYPE_NILFS;
+ case FS_CGD:
+ return DKW_PTYPE_CGD;
+ case FSMAXTYPES:
+ return DKW_PTYPE_UNKNOWN;
+ case FS_MINIXFS3:
+ return DKW_PTYPE_MINIXFS3;
+ }
+ /* Stupid gcc, should know it is impossible to get here */
+ /*NOTREACHED*/
+ return DKW_PTYPE_UNKNOWN;
+}
+#endif /* !_STANDALONE */
--- /dev/null
+/* $NetBSD: proc_compare.c,v 1.1 2011/10/21 02:09:00 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.
+ */
+#ifndef _STANDALONE
+# ifndef _KERNEL
+
+# if HAVE_NBTOOL_CONFIG_H
+# include "nbtool_config.h"
+# endif
+
+# include <sys/cdefs.h>
+# if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: proc_compare.c,v 1.1 2011/10/21 02:09:00 christos Exp $");
+# endif
+
+# include <sys/types.h>
+# include <sys/inttypes.h>
+# include <sys/sysctl.h>
+# include <stdio.h>
+# include <util.h>
+# include <errno.h>
+# define PROC struct kinfo_proc2
+# define LWP struct kinfo_lwp
+# define P_RTIME_SEC p_rtime_sec
+# define P_RTIME_USEC p_rtime_usec
+# else
+# include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: proc_compare.c,v 1.1 2011/10/21 02:09:00 christos Exp $");
+# include <sys/param.h>
+# include <sys/inttypes.h>
+# include <sys/systm.h>
+# include <sys/proc.h>
+# include <sys/lwp.h>
+# include <lib/libkern/libkern.h>
+# define PROC struct proc
+# define LWP struct lwp
+# define P_RTIME_SEC p_rtime.sec
+# define P_RTIME_USEC p_rtime.frac
+# endif
+/*
+ * Returns 1 if p2 is "better" than p1
+ *
+ * The algorithm for picking the "interesting" process is thus:
+ *
+ * 1) Only foreground processes are eligible - implied.
+ * 2) Runnable processes are favored over anything else. The runner
+ * with the highest CPU utilization is picked (l_pctcpu). Ties are
+ * broken by picking the highest pid.
+ * 3) The sleeper with the shortest sleep time is next. With ties,
+ * we pick out just "short-term" sleepers (P_SINTR == 0).
+ * 4) Further ties are broken by picking the one started last.
+ * 5) Finally the one with the biggest pid wins, but that is nonsense
+ * because of pid randomization.
+ */
+#define ISRUN(p) ((p)->p_nrlwps > 0)
+#define TESTAB(a, b) (((a) << 1) | (b))
+#define ONLYA 2
+#define ONLYB 1
+#define BOTH 3
+
+int
+proc_compare(const PROC *p1, const LWP *l1, const PROC *p2, const LWP *l2)
+{
+ /*
+ * see if at least one of them is runnable
+ */
+ switch (TESTAB(ISRUN(p1), ISRUN(p2))) {
+ case ONLYA:
+ return 0;
+ case ONLYB:
+ return 1;
+ case BOTH:
+ /*
+ * tie - favor one with highest recent CPU utilization
+ */
+ if (l2->l_pctcpu > l1->l_pctcpu)
+ return 1;
+ goto out;
+ }
+ /*
+ * weed out zombies
+ */
+ switch (TESTAB(P_ZOMBIE(p1), P_ZOMBIE(p2))) {
+ case ONLYA:
+ return 1;
+ case ONLYB:
+ return 0;
+ case BOTH:
+ goto out;
+ }
+ /*
+ * pick the one with the smallest sleep time
+ */
+ if (l1->l_slptime < l2->l_slptime)
+ return 0;
+ if (l2->l_slptime < l1->l_slptime)
+ return 1;
+
+ /*
+ * favor one sleeping in a non-interruptible sleep
+ */
+ if ((l1->l_flag & LW_SINTR) && (l2->l_flag & LW_SINTR) == 0)
+ return 0;
+ if ((l2->l_flag & LW_SINTR) && (l1->l_flag & LW_SINTR) == 0)
+ return 1;
+out:
+ /* tie, return the one with the smallest realtime */
+ if (p1->P_RTIME_SEC < p2->P_RTIME_SEC)
+ return 0;
+ if (p2->P_RTIME_SEC < p1->P_RTIME_SEC)
+ return 1;
+ if (p1->P_RTIME_USEC < p2->P_RTIME_USEC)
+ return 0;
+ if (p2->P_RTIME_USEC < p1->P_RTIME_USEC)
+ return 1;
+
+ return p2->p_pid > p1->p_pid; /* Nonsense */
+}
+#endif /* STANDALONE */
-/* $NetBSD: snprintb.c,v 1.5 2009/05/13 02:50:31 pgoyette Exp $ */
+/* $NetBSD: snprintb.c,v 1.7 2012/01/23 03:22:41 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
# include <sys/cdefs.h>
# if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: snprintb.c,v 1.5 2009/05/13 02:50:31 pgoyette Exp $");
+__RCSID("$NetBSD: snprintb.c,v 1.7 2012/01/23 03:22:41 christos Exp $");
# endif
# include <sys/types.h>
# include <errno.h>
# else
# include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.5 2009/05/13 02:50:31 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.7 2012/01/23 03:22:41 christos Exp $");
# include <sys/param.h>
# include <sys/inttypes.h>
# include <sys/systm.h>
STORE('<'); \
} else { \
/* Remember separator location */ \
- if ( l_max > 0 && sep != '<') { \
+ if (l_max > 0 && sep != '<') { \
s_len = l_len; \
s_bp = bp; \
s_fmt = cur_fmt; \
f_len = *bitfmt++; /* field length */
field = (val >> bit) &
(((uint64_t)1 << f_len) - 1);
+ PUTSEP;
+ if (restart == 0)
+ sep = ',';
if (ch == 'F') /* just extract */
break;
- PUTSEP;
if (restart == 0) {
- sep = ',';
PUTS(bitfmt);
- }
- if (restart == 0) {
PUTCHR('=');
}
if (restart == 0) {
static int get_volume(u8_t *left, u8_t *right, int cmd) {
- u16_t value;
+ u16_t value = 0;
AC97_read_unsynced(dev, (u16_t)cmd, &value);
*/
int count;
- int result;
+ int result = OK;
register char *tbuf;
char buf[64];
console_t *cons = tp->tty_priv;
#define MINIX_TARGET_CPU_CPP_BUILTINS() \
do \
{ \
+ builtin_define ("__i386"); \
builtin_define_with_int_value ("_EM_WSIZE", 4); \
builtin_define_with_int_value ("_EM_PSIZE", 4); \
builtin_define_with_int_value ("_EM_SSIZE", 2); \
#undef SUBTARGET_EXTRA_SPECS /* i386.h bogusly defines it. */
#define SUBTARGET_EXTRA_SPECS \
{ "minix_dynamic_linker", MINIX_DYNAMIC_LINKER }
-
-/* Provide a STARTFILE_SPEC appropriate for MINIX. Here we add
- the magical crtbegin.o file (see crtstuff.c) which provides part
- of the support for getting C++ file-scope static object constructed
- before entering `main'. */
-
+
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
- %{!p:%{profile:gcrt1.o%s} \
- %{!profile:crt1.o%s}}}} \
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-
-/* Provide a ENDFILE_SPEC appropriate for MINIX. Here we tack on
- the magical crtend.o file (see crtstuff.c) which provides part of
- the support for getting C++ file-scope static object constructed
- before entering `main', followed by a normal "finalizer" file,
- `crtn.o'. */
+#define STARTFILE_SPEC MINIX_STARTFILE_SPEC
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+#define ENDFILE_SPEC MINIX_ENDFILE_SPEC
/* Provide a LINK_SPEC appropriate for MINIX. Here we provide support
for the special GCC options -static and -shared, which allow us to
#define MINIX_TARGET_OS_CPP_BUILTINS() \
do \
{ \
- builtin_define ("__minix"); \
- builtin_define ("__i386"); \
- MINIX_TARGET_CPU_CPP_BUILTINS(); \
+ builtin_define ("__minix"); \
+ MINIX_TARGET_CPU_CPP_BUILTINS(); \
} \
while (0)
#define MINIX_STARTFILE_SPEC \
"%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
- %{!p:%{profile:gcrt1.o%s} \
- %{!profile:crt1.o%s}}}} \
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+ %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \
+ %{!p:%{profile:gcrt0%O%s} \
+ %{!profile:crt0%O%s}}}} \
+ crti%O%s %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
/* Provide a ENDFILE_SPEC appropriate for MINIX. Here we tack on
the magical crtend.o file (see crtstuff.c) which provides part of
fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \
inttypes.h iso646.h langinfo.h libgen.h \
limits.h link.h link_aout.h link_elf.h locale.h \
- login_cap.h malloc.h math.h md2.h \
+ login_cap.h lwp.h malloc.h math.h md2.h \
memory.h mntopts.h monetary.h mpool.h mqueue.h \
ndbm.h netconfig.h netdb.h netgroup.h nlist.h nl_types.h nsswitch.h \
paths.h pwd.h randomid.h ranlib.h re_comp.h regex.h regexp.h \
-# $NetBSD: Makefile,v 1.40 2009/12/13 05:01:33 nakayama Exp $
-
-# For now, we install the machine and arch includes, and symlink 'machine'
-# to the location of the machine includes (usually).
-#
-# Eventually, we should install everything.
-
.include <bsd.own.mk>
SUBDIR= ${MACHINE}
-ARCHSUBDIR= ${MACHINE_CPU}
-
-.if ${ARCHSUBDIR} == "mips64"
-ARCHSUBDIR= mips
-.endif
-.if ${ARCHSUBDIR} == "powerpc64"
-ARCHSUBDIR= powerpc
-.endif
-
-.if ${MACHINE} != ${ARCHSUBDIR}
-.if exists(${ARCHSUBDIR})
-SUBDIR+= ${ARCHSUBDIR}
-.endif
-.endif
-.if ${MACHINE} == sparc
-SUBDIR+= sparc64
-.endif
-.if (${MACHINE} == hpcmips || ${MACHINE} == hpcsh)
-SUBDIR+= hpc
-.endif
-.if (${MACHINE} == sun2 || ${MACHINE} == sun3)
-SUBDIR+= sun68k
-.endif
-.if defined(XEN_BUILD)
-SUBDIR+= xen
-.endif
-
-
-INCSYMLINKS= ${MACHINE_ARCH} /usr/include/machine
-
-INCSYMLINKS+= machine/float.h /usr/include/float.h \
- machine/stdarg.h /usr/include/stdarg.h
-
-.include <bsd.inc.mk>
.include <bsd.subdir.mk>
+++ /dev/null
-/* $NetBSD: stdarg.h,v 1.10 2008/06/21 00:56:39 gmcgarry 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: @(#)stdarg.h 8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _ARM32_STDARG_H_
-#define _ARM32_STDARG_H_
-
-#include <machine/ansi.h>
-#include <sys/featuretest.h>
-
-typedef _BSD_VA_LIST_ va_list;
-#ifdef __lint__
-#define __builtin_next_arg(t) ((t) ? 0 : 0)
-#define __builtin_stdarg_start(a, l) ((a) = ((l) ? 0 : 0))
-#define __builtin_va_arg(a, t) ((t)((a) ? 0 : 0))
-#define __builtin_va_end /* nothing */
-#define __builtin_va_copy(d, s) ((d) = (s))
-#endif
-
-#if __GNUC_PREREQ__(4, 1)
-#define va_start(ap, last) __builtin_va_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#elif __GNUC_PREREQ__(2, 96)
-#define va_start(ap, last) __builtin_stdarg_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#elif defined(__PCC__)
-#define va_start(ap, last) __builtin_stdarg_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#else
-#define __va_size(type) \
- (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-
-#define va_start(ap, last) \
- ((ap) = (va_list)__builtin_next_arg(last))
-
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-
-#define va_end(ap)
-
-#define __va_copy(dest, src) ((dest) = (src))
-
-#endif /* __GNUC_PREREQ__(2, 96) */
-
-#if !defined(_ANSI_SOURCE) && \
- (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
- defined(_NETBSD_SOURCE))
-#define va_copy(dest, src) __va_copy((dest), (src))
-#endif
-
-#endif /* !_ARM32_STDARG_H_ */
-# $NetBSD: Makefile,v 1.38 2009/08/30 02:00:56 dyoung Exp $
-
SUBDIR= include
INCS= archconst.h archtypes.h diskparm.h elf.h interrupt.h \
ipcconst.h memory.h multiboot.h partition.h \
- stackframe.h stdarg.h vm.h
+ stackframe.h vm.h
.include <bsd.kinc.mk>
+/* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka 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.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (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 __MULTIBOOT_H__
#define __MULTIBOOT_H__
+#if !defined(_KERNEL) && defined(_STANDALONE)
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Multiboot header structure.
+ */
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
+#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
+#define MULTIBOOT_HEADER_HAS_VBE 0x00000004
+#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000
+
+#if !defined(_LOCORE)
+struct multiboot_header {
+ uint32_t mh_magic;
+ uint32_t mh_flags;
+ uint32_t mh_checksum;
+
+ /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
+ paddr_t mh_header_addr;
+ paddr_t mh_load_addr;
+ paddr_t mh_load_end_addr;
+ paddr_t mh_bss_end_addr;
+ paddr_t mh_entry_addr;
+
+ /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */
+ uint32_t mh_mode_type;
+ uint32_t mh_width;
+ uint32_t mh_height;
+ uint32_t mh_depth;
+};
+#endif /* !defined(_LOCORE) */
+
+/*
+ * Symbols defined in locore.S.
+ */
+#if !defined(_LOCORE) && defined(_KERNEL)
+extern struct multiboot_header *Multiboot_Header;
+#endif /* !defined(_LOCORE) && defined(_KERNEL) */
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Multiboot information structure.
+ */
+#define MULTIBOOT_INFO_MAGIC 0x2BADB002
+#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001
+#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
+#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
+#define MULTIBOOT_INFO_HAS_MODS 0x00000008
+#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010
+#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020
+#define MULTIBOOT_INFO_HAS_MMAP 0x00000040
+#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080
+#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100
+#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
+#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400
+#define MULTIBOOT_INFO_HAS_VBE 0x00000800
+
+#if !defined(_LOCORE)
+struct multiboot_info {
+ uint32_t mi_flags;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
+ uint32_t mi_mem_lower;
+ uint32_t mi_mem_upper;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */
+ uint8_t mi_boot_device_part3;
+ uint8_t mi_boot_device_part2;
+ uint8_t mi_boot_device_part1;
+ uint8_t mi_boot_device_drive;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
+ char * mi_cmdline;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
+ uint32_t mi_mods_count;
+ vaddr_t mi_mods_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */
+ uint32_t mi_elfshdr_num;
+ uint32_t mi_elfshdr_size;
+ vaddr_t mi_elfshdr_addr;
+ uint32_t mi_elfshdr_shndx;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
+ uint32_t mi_mmap_length;
+ vaddr_t mi_mmap_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
+ uint32_t mi_drives_length;
+ vaddr_t mi_drives_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
+ void * unused_mi_config_table;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
+ char * mi_loader_name;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
+ void * unused_mi_apm_table;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
+ void * unused_mi_vbe_control_info;
+ void * unused_mi_vbe_mode_info;
+ paddr_t unused_mi_vbe_interface_seg;
+ paddr_t unused_mi_vbe_interface_off;
+ uint32_t unused_mi_vbe_interface_len;
+};
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Drive information. This describes an entry in the drives table as
+ * pointed to by mi_drives_addr.
+ */
+struct multiboot_drive {
+ uint32_t md_length;
+ uint8_t md_number;
+ uint8_t md_mode;
+ uint16_t md_cylinders;
+ uint8_t md_heads;
+ uint8_t md_sectors;
+
+ /* The variable-sized 'ports' field comes here, so this structure
+ * can be longer. */
+};
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Memory mapping. This describes an entry in the memory mappings table
+ * as pointed to by mi_mmap_addr.
+ *
+ * Be aware that mm_size specifies the size of all other fields *except*
+ * for mm_size. In order to jump between two different entries, you
+ * have to count mm_size + 4 bytes.
+ */
+struct multiboot_mmap {
+ uint32_t mm_size;
+ uint64_t mm_base_addr;
+ uint64_t mm_length;
+ uint32_t mm_type;
+};
+
+/*
+ * Modules. This describes an entry in the modules table as pointed
+ * to by mi_mods_addr.
+ */
+
+struct multiboot_module {
+ uint32_t mmo_start;
+ uint32_t mmo_end;
+ char * mmo_string;
+ uint32_t mmo_reserved;
+};
+
+#endif /* !defined(_LOCORE) */
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Prototypes for public functions defined in multiboot.c.
+ */
+#if !defined(_LOCORE) && defined(_KERNEL)
+void multiboot_pre_reloc(struct multiboot_info *);
+void multiboot_post_reloc(void);
+void multiboot_print_info(void);
+bool multiboot_ksyms_addsyms_elf(void);
+#endif /* !defined(_LOCORE) */
+
+/* --------------------------------------------------------------------- */
+#else /* !defined(_KERNEL) && defined(_STANDALONE) */
+/* LSC FIXME: OLD MINIX DEFINITION: should be removed and replace with
+ definition above... */
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
#endif /* __ASSEMBLY__ */
+#endif /* !defined(_KERNEL) && defined(_STANDALONE) */
#endif /* __MULTIBOOT_H__ */
-# $NetBSD: Makefile,v 1.38 2009/08/30 02:00:56 dyoung Exp $
-
SUBDIR= include
+
INCSDIR= /usr/include/i386
-INCS= archconst.h archtypes.h bios.h cmos.h cpu.h \
+INCS= archconst.h archtypes.h bios.h cmos.h \
diskparm.h elf.h fpu.h int86.h interrupt.h \
ipcconst.h memory.h partition.h \
pci_amd.h pci.h pci_intel.h pci_sis.h \
- pci_via.h ports.h stackframe.h stdarg.h vm.h
+ pci_via.h ports.h stackframe.h vm.h
.include <bsd.kinc.mk>
+++ /dev/null
-/* $NetBSD: stdarg.h,v 1.23 2009/08/18 17:40:39 drochner 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.
- *
- * @(#)stdarg.h 8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _I386_STDARG_H_
-#define _I386_STDARG_H_
-
-#include <machine/ansi.h>
-#include <sys/featuretest.h>
-
-typedef _BSD_VA_LIST_ va_list;
-
-#ifdef __lint__
-#define __builtin_next_arg(t) ((t) ? 0 : 0)
-#define __builtin_stdarg_start(a, l) ((a) = ((l) ? 0 : 0))
-#define __builtin_va_arg(a, t) ((a) ? 0 : 0)
-#define __builtin_va_end /* nothing */
-#define __builtin_va_copy(d, s) ((d) = (s))
-#endif
-
-#if __GNUC_PREREQ__(4, 1)
-#define va_start(ap, last) __builtin_va_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#elif __GNUC_PREREQ__(2, 96)
-#define va_start(ap, last) __builtin_stdarg_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#elif defined(__PCC__)
-#define va_start(ap, last) __builtin_stdarg_start((ap), (last))
-#define va_arg __builtin_va_arg
-#define va_end __builtin_va_end
-#define __va_copy(dest, src) __builtin_va_copy((dest), (src))
-#else
-#define __va_size(type) \
- (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-
-#define va_start(ap, last) \
- ((ap) = (va_list)__builtin_next_arg(last))
-
-#define va_arg(ap, type) \
- (*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
-
-#define va_end(ap)
-
-#define __va_copy(dest, src) ((dest) = (src))
-#endif
-
-#if !defined(_ANSI_SOURCE) && \
- (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
- defined(_NETBSD_SOURCE))
-#define va_copy(dest, src) __va_copy((dest), (src))
-#endif
-
-#endif /* !_I386_STDARG_H_ */
-/* $NetBSD: assert.h,v 1.20 2008/11/02 14:27:44 christos Exp $ */
+/* $NetBSD: assert.h,v 1.21 2011/08/26 01:10:49 joerg Exp $ */
/*-
* Copyright (c) 1992, 1993
#ifndef __ASSERT_DECLARED
#define __ASSERT_DECLARED
__BEGIN_DECLS
-void __assert(const char *, int, const char *);
-void __assert13(const char *, int, const char *, const char *);
+__dead void __assert(const char *, int, const char *);
+__dead void __assert13(const char *, int, const char *, const char *);
void __diagassert(const char *, int, const char *);
void __diagassert13(const char *, int, const char *, const char *);
__END_DECLS
-/* $NetBSD: cdbw.h,v 1.1 2010/04/25 00:54:45 joerg Exp $ */
+/* $NetBSD: cdbw.h,v 1.2 2012/06/03 21:21:45 joerg Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
uint32_t *);
int cdbw_put_key(struct cdbw *, const void *, size_t,
uint32_t);
+uint32_t cdbw_stable_seeder(void);
int cdbw_output(struct cdbw *, int, const char[16],
uint32_t (*)(void));
void cdbw_close(struct cdbw *);
-/* $NetBSD: db.h,v 1.24 2008/08/26 21:18:38 joerg Exp $ */
+/* $NetBSD: db.h,v 1.25 2012/03/13 21:14:55 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#ifdef __DBINTERFACE_PRIVATE
-#define _DBMASK(a) (~((1ULL << (sizeof(a) * NBBY)) - 1))
-#define _DBFIT(a, t) _DIAGASSERT(((a) & _DBMASK(t)) == 0)
+#define _DBFIT(a, t) _DIAGASSERT(__type_fit(t, a))
DB *__bt_open(const char *, int, mode_t, const BTREEINFO *, int);
DB *__hash_open(const char *, int, mode_t, const HASHINFO *, int);
-/* $NetBSD: dirent.h,v 1.34 2010/09/26 02:26:59 yamt Exp $ */
+/* $NetBSD: dirent.h,v 1.35 2012/07/30 23:11:13 yamt Exp $ */
/*-
* Copyright (c) 1989, 1993
/* structure describing an open directory. */
struct _dirdesc {
+ /*
+ * dd_fd should be kept intact to preserve ABI compat. see dirfd().
+ */
int dd_fd; /* file descriptor associated with directory */
+ /*
+ * the rest is hidden from user.
+ */
long dd_loc; /* offset in current buffer */
long dd_size; /* amount of data returned by getdents */
char *dd_buf; /* data buffer */
-/* $NetBSD: dlfcn.h,v 1.22 2010/12/24 12:41:42 skrll Exp $ */
+/* $NetBSD: dlfcn.h,v 1.24 2012/02/16 23:00:39 joerg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* User interface to the run-time linker.
*/
__BEGIN_DECLS
+void *_dlauxinfo(void) __pure;
+
void *dlopen(const char *, int);
int dlclose(void *);
void *dlsym(void * __restrict, const char * __restrict);
int dladdr(const void * __restrict, Dl_info * __restrict);
int dlctl(void *, int, void *);
int dlinfo(void *, int, void *);
+void *dlvsym(void * __restrict, const char * __restrict,
+ const char * __restrict);
#endif
__aconst char *dlerror(void);
__END_DECLS
-/* $NetBSD: err.h,v 1.15 2010/02/25 18:37:12 joerg Exp $ */
+/* $NetBSD: err.h,v 1.16 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1993
#ifndef _ERR_H_
#define _ERR_H_
-/*
- * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two
- * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
- * of them here we may collide with the utility's includes. It's unreasonable
- * for utilities to have to include one of them to include err.h, so we get
- * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
- */
-#include <machine/ansi.h>
#include <sys/cdefs.h>
+#include <stdarg.h>
__BEGIN_DECLS
__dead void err(int, const char *, ...)
__printflike(2, 3) __dead;
-__dead void verr(int, const char *, _BSD_VA_LIST_)
+__dead void verr(int, const char *, va_list)
__printflike(2, 0) __dead;
__dead void errx(int, const char *, ...)
__printflike(2, 3) __dead;
-__dead void verrx(int, const char *, _BSD_VA_LIST_)
+__dead void verrx(int, const char *, va_list)
__printflike(2, 0) __dead;
void warn(const char *, ...)
__printflike(1, 2);
-void vwarn(const char *, _BSD_VA_LIST_)
+void vwarn(const char *, va_list)
__printflike(1, 0);
void warnx(const char *, ...)
__printflike(1, 2);
-void vwarnx(const char *, _BSD_VA_LIST_)
+void vwarnx(const char *, va_list)
__printflike(1, 0);
__END_DECLS
-/* $NetBSD: fenv.h,v 1.2 2010/08/02 17:49:04 joerg Exp $ */
+/* $NetBSD: fenv.h,v 1.7 2012/03/22 03:06:06 dholland Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if !defined(__i386__) && !defined(__amd64__)
+#if !defined(__i386__) && !defined(__amd64__) && !defined(__sparc__)
#error "fenv.h is currently not supported for this architecture"
#endif
int fedisableexcept(int mask);
int fegetexcept(void);
-#endif /* _NETBDS_SOURCE || _GNU_SOURCE */
+#endif /* _NETBSD_SOURCE || _GNU_SOURCE */
__END_DECLS
-/* $NetBSD: fnmatch.h,v 1.12 2005/02/03 04:39:32 perry Exp $ */
+/* $NetBSD: fnmatch.h,v 1.13 2011/01/31 04:49:46 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
#define FNM_NOMATCH 1 /* Match failed. */
#define FNM_NOSYS 2 /* Function not implemented. */
+#define FNM_NORES 3 /* Out of resources */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
-/* $NetBSD: ieeefp.h,v 1.7 2005/11/18 20:02:59 christos Exp $ */
+/* $NetBSD: ieeefp.h,v 1.9 2011/03/27 05:13:15 mrg Exp $ */
/*
* Written by J.T. Conklin, Apr 6, 1995
#include <machine/ieeefp.h>
__BEGIN_DECLS
-fp_rnd fpgetround(void);
-fp_rnd fpsetround(fp_rnd);
-fp_except fpgetmask(void);
-fp_except fpsetmask(fp_except);
-fp_except fpgetsticky(void);
-fp_except fpsetsticky(fp_except);
+typedef fp_rnd fp_rnd_t;
+#ifdef _X86_IEEEFP_H_ /* XXX */
+typedef fp_prec fp_prec_t;
+#endif
+typedef fp_except fp_except_t;
+
+fp_rnd_t fpgetround(void);
+fp_rnd_t fpsetround(fp_rnd_t);
+#ifdef _X86_IEEEFP_H_ /* XXX */
+fp_prec_t fpgetprec(void);
+fp_prec_t fpsetprec(fp_prec_t);
+#endif
+fp_except_t fpgetmask(void);
+fp_except_t fpsetmask(fp_except_t);
+fp_except_t fpgetsticky(void);
+fp_except_t fpsetsticky(fp_except_t);
+fp_except_t fpresetsticky(fp_except_t);
__END_DECLS
#endif /* _IEEEFP_H_ */
-/* $NetBSD: kvm.h,v 1.15 2007/11/08 20:48:04 joerg Exp $ */
+/* $NetBSD: kvm.h,v 1.16 2011/09/12 21:14:29 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
kvm_t *kvm_openfiles(const char *, const char *, const char *, int, char *);
ssize_t kvm_read(kvm_t *, u_long, void *, size_t);
ssize_t kvm_write(kvm_t *, u_long, const void *, size_t);
+const char *kvm_getkernelname(kvm_t *);
__END_DECLS
-/* $NetBSD: limits.h,v 1.29 2010/06/07 13:52:29 tnozaki Exp $ */
+/* $NetBSD: limits.h,v 1.32 2012/03/28 17:04:41 christos Exp $ */
/*
* Copyright (c) 1988, 1993
#define _POSIX_STREAM_MAX 8
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
+
+/*
+ * We have not implemented these yet
+ *
+ * _POSIX_THREAD_ATTR_STACKADDR
+ * _POSIX_THREAD_ATTR_STACKSIZE
+ * _POSIX_THREAD_CPUTIME
+ * _POSIX_THREAD_PRIORITY_SCHEDULING
+ * _POSIX_THREAD_PRIO_INHERIT
+ * _POSIX_THREAD_PRIO_PROTECT
+ * _POSIX_THREAD_PROCESS_SHARED
+ * _POSIX_THREAD_SAFE_FUNCTIONS
+ * _POSIX_THREAD_SPORADIC_SERVER
+ */
+
+/*
+ * The following 3 are not part of the standard
+ * but left here for compatibility
+ */
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-#define _POSIX_THREAD_KEYS_MAX 128
+#define _POSIX_THREAD_KEYS_MAX 256
#define _POSIX_THREAD_THREADS_MAX 64
+
+/*
+ * These are the correct names, defined in terms of the above
+ */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
+/* Not yet: PTHREAD_STACK_MIN */
+#define PTHREAD_THREADS_MAX _POSIX_THREAD_THREADS_MAX
+
#define _POSIX_TIMER_MAX 32
#define _POSIX_TTY_NAME_MAX 9
#define _POSIX_TZNAME_MAX 6
#define MB_LEN_MAX 32 /* Allow ISO/IEC 2022 */
+/*
+ * X/Open Extended API set 2 (a.k.a. C063)
+ * This hides unimplemented functions from GNU configure until
+ * we are done implementing them.
+ */
+#if !defined(_INCOMPLETE_XOPEN_C063)
+#define __stub_linkat
+#define __stub_renameat
+#define __stub_mkfifoat
+#define __stub_mknodat
+#define __stub_mkdirat
+#define __stub_faccessat
+#define __stub_fchmodat
+#define __stub_fchownat
+#define __stub_fexecve
+#define __stub_fstatat
+#define __stub_utimensat
+#define __stub_openat
+#define __stub_readlinkat
+#define __stub_symlinkat
+#define __stub_unlinkat
+#endif
+
#include <machine/limits.h>
-#include <sys/syslimits.h>
+
+#ifdef __CHAR_UNSIGNED__
+# define CHAR_MIN 0
+# define CHAR_MAX UCHAR_MAX
+#else
+# define CHAR_MIN SCHAR_MIN
+# define CHAR_MAX SCHAR_MAX
+#endif
#ifdef __minix
#define SYMLOOP_MAX 16
#define SYMLINK_MAX 1024
-#endif
+#endif /* __minix */
+
+#include <sys/syslimits.h>
#endif /* !_LIMITS_H_ */
-/* $NetBSD: math.h,v 1.53 2010/09/15 16:11:30 christos Exp $ */
+/* $NetBSD: math.h,v 1.58 2012/05/05 22:07:57 christos Exp $ */
/*
* ====================================================
#endif
/* 7.12#4 INFINITY */
-#if __GNUC_PREREQ__(3, 3)
-#define INFINITY __builtin_inff()
-#elif defined(__INFINITY)
+#if defined(__INFINITY)
#define INFINITY __INFINITY /* float constant which overflows */
+#elif __GNUC_PREREQ__(3, 3)
+#define INFINITY __builtin_inff()
#else
#define INFINITY HUGE_VALF /* positive infinity */
#endif /* __INFINITY */
float erff(float);
float erfcf(float);
float lgammaf(float);
+float tgammaf(float);
+double tgamma(double);
/* 7.12.9 nearest integer */
float fmodf(float, float);
float remainderf(float, float);
+/* 7.12.10.3 The remquo functions */
+double remquo(double, double, int *);
+float remquof(float, float, int *);
+
/* 7.12.11 manipulation */
float copysignf(float, float);
int __isnanl(long double);
int __signbitl(long double);
#endif
+
+int ilogbl(long double);
+long double logbl(long double);
+long double scalbnl(long double, int);
+
__END_DECLS
#endif /* _MATH_H_ */
-NOOBJ= # defined
-
.include <bsd.own.mk>
-INCSDIR= /usr/include/minix
+INCSDIR= /usr/include/minix
INCS+= dirent.h paths.h param.h
INCS+= acpi.h audio_fw.h bitmap.h \
-/* $NetBSD: mntopts.h,v 1.13 2009/01/12 18:14:20 pooka Exp $ */
+/* $NetBSD: mntopts.h,v 1.14 2011/06/17 14:23:50 manu Exp $ */
/*-
* Copyright (c) 1994
#define MOPT_SOFTDEP { "softdep", 0, MNT_SOFTDEP, 0 }
#define MOPT_LOG { "log", 0, MNT_LOG, 0 }
#define MOPT_IGNORE { "hidden", 0, MNT_IGNORE, 0 }
+#define MOPT_EXTATTR { "extattr", 0, MNT_EXTATTR, 0 }
/* Control flags. */
#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
-/* $NetBSD: netdb.h,v 1.64 2010/05/05 17:12:29 christos Exp $ */
+/* $NetBSD: netdb.h,v 1.65 2012/03/17 21:57:48 christos Exp $ */
/*
* ++Copyright++ 1980, 1983, 1988, 1993
#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */
/* valid flags for addrinfo (not a standard def, apps should not use it) */
#define AI_MASK \
- (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
+ (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
+ AI_ADDRCONFIG)
+#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
#endif
#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
-/* $NetBSD: nsswitch.h,v 1.20 2008/04/28 20:22:54 martin Exp $ */
+/* $NetBSD: nsswitch.h,v 1.21 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
#ifndef _NSSWITCH_H
#define _NSSWITCH_H 1
-/*
- * Don't use va_list in prototypes. va_list is typedef'd in two places
- * (<machine/varargs.h> and <machine/stdarg.h>), so if we include one of
- * them here we may collide with the utility's includes. It's unreasonable
- * for utilities to have to include one of them to include nsswitch.h, so
- * we get _BSD_VA_LIST_ from <machine/ansi.h> and use it.
- */
-#include <machine/ansi.h>
#include <sys/types.h>
+#include <stdarg.h>
#define NSS_MODULE_INTERFACE_VERSION 0
/*
* ns_dtab `callback' function signature.
*/
-typedef int (*nss_method)(void *, void *, _BSD_VA_LIST_);
+typedef int (*nss_method)(void *, void *, va_list);
/*
* ns_dtab - `nsswitch dispatch table'
-/* $NetBSD: paths.h,v 1.39 2010/12/29 15:53:57 pooka Exp $ */
+/* $NetBSD: paths.h,v 1.41 2012/06/03 21:42:46 joerg Exp $ */
/*
* Copyright (c) 1989, 1993
#define _PATH_CLOCKCTL "/dev/clockctl"
#define _PATH_CONSOLE "/dev/console"
#define _PATH_CONSTTY "/dev/constty"
+#define _PATH_CPUCTL "/dev/cpuctl"
#define _PATH_CSMAPPER "/usr/share/i18n/csmapper"
#define _PATH_DEFTAPE "/dev/nrst0"
+#define _PATH_DEVCDB "/var/run/dev.cdb"
#define _PATH_DEVDB "/var/run/dev.db"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DRUM "/dev/drum"
--- /dev/null
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David A. Holland.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (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 _QUOTA_H_
+#define _QUOTA_H_
+
+#include <sys/types.h>
+#include <sys/quota.h>
+
+struct quotahandle; /* Opaque. */
+struct quotacursor; /* Opaque. */
+
+
+void quotaval_clear(struct quotaval *);
+
+struct quotahandle *quota_open(const char *);
+void quota_close(struct quotahandle *);
+
+const char *quota_getmountpoint(struct quotahandle *);
+const char *quota_getmountdevice(struct quotahandle *);
+
+const char *quota_getimplname(struct quotahandle *);
+unsigned quota_getrestrictions(struct quotahandle *);
+
+int quota_getnumidtypes(struct quotahandle *);
+const char *quota_idtype_getname(struct quotahandle *, int /*idtype*/);
+
+int quota_getnumobjtypes(struct quotahandle *);
+const char *quota_objtype_getname(struct quotahandle *, int /*objtype*/);
+int quota_objtype_isbytes(struct quotahandle *, int /*objtype*/);
+
+int quota_quotaon(struct quotahandle *, int /*idtype*/);
+int quota_quotaoff(struct quotahandle *, int /*idtype*/);
+
+int quota_get(struct quotahandle *, const struct quotakey *,
+ struct quotaval *);
+
+int quota_put(struct quotahandle *, const struct quotakey *,
+ const struct quotaval *);
+
+int quota_delete(struct quotahandle *, const struct quotakey *);
+
+struct quotacursor *quota_opencursor(struct quotahandle *);
+void quotacursor_close(struct quotacursor *);
+
+int quotacursor_skipidtype(struct quotacursor *, int /*idtype*/);
+
+int quotacursor_get(struct quotacursor *, struct quotakey *,
+ struct quotaval *);
+
+int quotacursor_getn(struct quotacursor *, struct quotakey *,
+ struct quotaval *, unsigned /*maxnum*/);
+
+int quotacursor_atend(struct quotacursor *);
+int quotacursor_rewind(struct quotacursor *);
+
+#endif /* _QUOTA_H_ */
-/* $NetBSD: resolv.h,v 1.38 2009/10/24 17:23:34 christos Exp $ */
+/* $NetBSD: resolv.h,v 1.39 2012/09/09 18:03:17 christos Exp $ */
/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
#define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \
- RES_DNSRCH | RES_NO_NIBBLE2)
+ RES_DNSRCH | RES_NO_NIBBLE2 | RES_NOCHECKNAME)
/*%
* Resolver "pfcode" values. Used by dig.
-/* $NetBSD: rmt.h,v 1.6 2010/08/31 05:12:35 enami Exp $ */
+/* $NetBSD: rmt.h,v 1.7 2011/02/16 19:29:35 christos Exp $ */
/*
* rmt.h
#include <sys/cdefs.h>
+#if _FORTIFY_SOURCE > 0
+#define __ssp_weak_name(x) rmt ## x
+#include <ssp/unistd.h>
+#endif
+
__BEGIN_DECLS
int isrmt(int);
int rmtaccess(const char *, int);
#define lseek rmtlseek
#define lstat rmtlstat
#define open rmtopen
+#if __SSP_FORTIFY_LEVEL == 0
#define read rmtread
+#endif
#define stat rmtstat
#define write rmtwrite
#endif /* __RMTLIB_PRIVATE */
-/* $NetBSD: clnt.h,v 1.20 2005/12/03 15:16:19 yamt Exp $ */
+/* $NetBSD: clnt.h,v 1.21 2011/08/30 17:06:20 plunky Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* struct timeval timeout;
*/
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
- ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
- (const char *)(const void *)(argsp), xres, (caddr_t)(void *)resp, secs))
+ ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, \
+ (const char *)(const void *)(argsp), (xdrproc_t)xres, \
+ (caddr_t)(void *)resp, secs))
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
- ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
- (const char *)(const void *)(argsp), xres, (caddr_t)(void *)resp, secs))
+ ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, \
+ (const char *)(const void *)(argsp), (xdrproc_t)xres, \
+ (caddr_t)(void *)resp, secs))
/*
* void
-/* $NetBSD: svc.h,v 1.23 2005/12/26 19:01:47 perry Exp $ */
+/* $NetBSD: svc.h,v 1.24 2011/08/30 17:06:20 plunky Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
(*(xprt)->xp_ops->xp_stat)(xprt)
#define SVC_GETARGS(xprt, xargs, argsp) \
- (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
+ (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
#define svc_getargs(xprt, xargs, argsp) \
- (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
+ (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
#define SVC_REPLY(xprt, msg) \
(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
#define SVC_FREEARGS(xprt, xargs, argsp) \
- (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
+ (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
#define svc_freeargs(xprt, xargs, argsp) \
- (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
+ (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
#define SVC_DESTROY(xprt) \
(*(xprt)->xp_ops->xp_destroy)(xprt)
-/* $NetBSD: xdr.h,v 1.25 2005/12/28 15:26:06 yamt Exp $ */
+/* $NetBSD: xdr.h,v 1.27 2011/08/30 17:09:51 plunky Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* The opaque pointer generally points to a structure of the data type
* to be decoded. If this pointer is 0, then the type routines should
* allocate dynamic storage of the appropriate size and return it.
- *
- * XXX can't actually prototype it, because some take three args!!!
*/
-typedef bool_t (*xdrproc_t)(/* XDR *, void *, u_int */);
+typedef bool_t (*xdrproc_t)(XDR *, const void *);
/*
* Operations defined on a XDR handle
extern bool_t xdr_u_hyper(XDR *, u_longlong_t *);
extern bool_t xdr_longlong_t(XDR *, longlong_t *);
extern bool_t xdr_u_longlong_t(XDR *, u_longlong_t *);
+extern unsigned long xdr_sizeof(xdrproc_t, void *);
__END_DECLS
/*
-/* $NetBSD: ypclnt.h,v 1.13 2005/02/03 04:39:33 perry Exp $ */
+/* $NetBSD: ypclnt.h,v 1.14 2012/03/02 17:27:48 christos Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
int yp_all (const char *, const char *, struct ypall_callback *);
char * yperr_string (int);
int ypprot_err (unsigned int);
+int yp_setbindtries (int);
__END_DECLS
#endif /* _RPCSVC_YPCLNT_H_ */
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef __minix
-#define _SCHED_H_
-#endif /* !__minix */
+/* LSC: It seems we actually do not want this header to be visible. */
+#ifndef __minix
#ifndef _SCHED_H_
#define _SCHED_H_
#endif /* _NETBSD_SOURCE */
#endif /* _SCHED_H_ */
+
+#endif /* !__minix */
-/* $NetBSD: search.h,v 1.18 2005/07/06 15:47:15 drochner Exp $ */
+/* $NetBSD: search.h,v 1.19 2011/09/14 23:34:26 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>
void *data;
} ENTRY;
+#ifdef _NETBSD_SOURCE
+struct _ENTRY;
+struct hsearch_data {
+ struct _ENTRY *table;
+ size_t size;
+ size_t filled;
+};
+#endif
+
typedef enum {
FIND, ENTER
} ACTION;
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
#endif /* __BSEARCH_DECLARED */
+
int hcreate(size_t);
void hdestroy(void);
ENTRY *hsearch(ENTRY, ACTION);
+#ifdef _NETBSD_SOURCE
+int hcreate_r(size_t, struct hsearch_data *);
+void hdestroy_r(struct hsearch_data *);
+int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
+#endif /* _NETBSD_SOURCE */
+
void *lfind(const void *, const void *, size_t *, size_t,
int (*)(const void *, const void *));
void *lsearch(const void *, void *, size_t *, size_t,
-/* $NetBSD: semaphore.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */
+/* $NetBSD: semaphore.h,v 1.4 2012/03/08 21:59:28 joerg Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
#define SEM_FAILED ((sem_t *)0)
#define SEM_VALUE_MAX (~0U)
-#include <sys/cdefs.h>
+#include <sys/time.h>
__BEGIN_DECLS
int sem_close(sem_t *);
int sem_getvalue(sem_t * __restrict, int * __restrict);
int sem_init(sem_t *, int, unsigned int);
int sem_post(sem_t *);
+int sem_timedwait(sem_t *, const struct timespec * __restrict);
int sem_trywait(sem_t *);
int sem_unlink(const char *);
int sem_wait(sem_t *);
-/* $NetBSD: setjmp.h,v 1.25 2009/08/12 04:57:36 matt Exp $ */
+/* $NetBSD: setjmp.h,v 1.26 2011/11/05 09:27:06 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
__BEGIN_DECLS
#ifndef __LIBC12_SOURCE__
-int setjmp(jmp_buf) __RENAME(__setjmp14);
+int setjmp(jmp_buf) __RENAME(__setjmp14) __returns_twice;
void longjmp(jmp_buf, int) __RENAME(__longjmp14) __dead;
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
defined(_NETBSD_SOURCE)
-int sigsetjmp(sigjmp_buf, int) __RENAME(__sigsetjmp14);
+int sigsetjmp(sigjmp_buf, int) __RENAME(__sigsetjmp14) __returns_twice;
void siglongjmp(sigjmp_buf, int) __RENAME(__siglongjmp14) __dead;
#endif /* not ANSI */
#endif /* __LIBC12_SOURCE__ */
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-int _setjmp(jmp_buf);
+int _setjmp(jmp_buf) __returns_twice;
void _longjmp(jmp_buf, int) __dead;
#endif
-/* $NetBSD: ssp.h,v 1.6 2011/01/20 02:58:17 christos Exp $ */
+/* $NetBSD: ssp.h,v 1.10 2012/08/08 20:23:32 joerg Exp $ */
/*-
- * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
#include <sys/cdefs.h>
#if !defined(__cplusplus)
-# if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __GNUC_PREREQ__(4, 1)
+# if _FORTIFY_SOURCE > 0 && !defined(__lint__) && \
+ (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1)
# if _FORTIFY_SOURCE > 1
# define __SSP_FORTIFY_LEVEL 2
# else
# define __SSP_FORTIFY_LEVEL 1
# endif
+# else
+# define __SSP_FORTIFY_LEVEL 0
# endif
+#else
+# define __SSP_FORTIFY_LEVEL 0
#endif
-#ifdef _NAMESPACE_H_
-#define __ssp_weak_name(fun) _sys ## fun
+/* __ssp_real is used by the implementation in libc */
+#if __SSP_FORTIFY_LEVEL == 0
+#define __ssp_real_(fun) fun
#else
-#define __ssp_weak_name(fun) _sys_ ## fun
+#define __ssp_real_(fun) __ssp_real_ ## fun
#endif
+#define __ssp_real(fun) __ssp_real_(fun)
#define __ssp_inline static __inline __attribute__((__always_inline__))
#define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1)
#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
-#define __ssp_redirect_raw(rtype, fun, args, call, bos) \
-rtype __ssp_weak_name(fun) args; \
-__ssp_inline rtype fun args; \
+#define __ssp_check(buf, len, bos) \
+ if (bos(buf) != (size_t)-1 && len > bos(buf)) \
+ __chk_fail()
+#define __ssp_redirect_raw(rtype, fun, symbol, args, call, bos) \
+rtype __ssp_real_(fun) args __RENAME(symbol); \
+__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \
__ssp_inline rtype fun args { \
- if (bos(__buf) != (size_t)-1 && __len > bos(__buf)) \
- __chk_fail(); \
- return __ssp_weak_name(fun) call; \
+ __ssp_check(__buf, __len, bos); \
+ return __ssp_real_(fun) call; \
}
#define __ssp_redirect(rtype, fun, args, call) \
- __ssp_redirect_raw(rtype, fun, args, call, __ssp_bos)
+ __ssp_redirect_raw(rtype, fun, fun, args, call, __ssp_bos)
#define __ssp_redirect0(rtype, fun, args, call) \
- __ssp_redirect_raw(rtype, fun, args, call, __ssp_bos0)
+ __ssp_redirect_raw(rtype, fun, fun, args, call, __ssp_bos0)
__BEGIN_DECLS
void __stack_chk_fail(void) __dead;
-/* $NetBSD: stdio.h,v 1.4 2010/02/25 18:37:13 joerg Exp $ */
+/* $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...)
__printflike(4, 5);
int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict,
- _BSD_VA_LIST_)
+ __va_list)
__printflike(4, 0);
int __snprintf_chk(char *__restrict, size_t, int, size_t,
const char *__restrict, ...)
__printflike(5, 6);
int __vsnprintf_chk(char *__restrict, size_t, int, size_t,
- const char *__restrict, _BSD_VA_LIST_)
+ const char *__restrict, __va_list)
__printflike(5, 0);
char *__gets_chk(char *, size_t);
char *__fgets_chk(char *, int, size_t, FILE *);
-/* $NetBSD: string.h,v 1.4 2009/11/17 20:47:59 drochner Exp $ */
+/* $NetBSD: string.h,v 1.5 2012/07/22 21:05:26 joerg Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
#include <ssp/ssp.h>
+__BEGIN_DECLS
+void *__memcpy_chk(void *, const void *, size_t, size_t);
+void *__memmove_chk(void *, void *, size_t, size_t);
+void *__memset_chk(void *, int, size_t, size_t);
+char *__strcat_chk(char *, const char *, size_t);
+char *__strcpy_chk(char *, const char *, size_t);
+char *__strncat_chk(char *, const char *, size_t, size_t);
+char *__strncpy_chk(char *, const char *, size_t, size_t);
+__END_DECLS
+
#if __SSP_FORTIFY_LEVEL > 0
#define __ssp_bos_check3(fun, dst, src, len) \
__ssp_bos_icheck2_restrict(strcat, char *, const char *)
__ssp_bos_icheck3_restrict(strncpy, char *, const char *)
__ssp_bos_icheck3_restrict(strncat, char *, const char *)
-void *__memcpy_chk(void *, const void *, size_t, size_t);
-void *__memmove_chk(void *, void *, size_t, size_t);
-void *__memset_chk(void *, int, size_t, size_t);
-char *__strcat_chk(char *, const char *, size_t);
-char *__strcpy_chk(char *, const char *, size_t);
-char *__strncat_chk(char *, const char *, size_t, size_t);
-char *__strncpy_chk(char *, const char *, size_t, size_t);
__END_DECLS
#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
-/* $NetBSD: unistd.h,v 1.5 2011/01/19 19:21:29 christos Exp $ */
+/* $NetBSD: unistd.h,v 1.6 2011/01/26 18:07:44 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \
(__fd, __buf, __len));
-__ssp_redirect(int, readlink, (const char *__restrict __path, \
+__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \
char *__restrict __buf, size_t __len), (__path, __buf, __len));
__ssp_redirect(char *, getcwd, (char *__buf, size_t __len), (__buf, __len));
-/* $NetBSD: stdio.h,v 1.78 2010/09/24 09:21:53 tnozaki Exp $ */
+/* $NetBSD: stdio.h,v 1.82 2012/04/18 19:30:15 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#include <sys/featuretest.h>
#include <sys/ansi.h>
-#include <machine/ansi.h>
#ifdef _BSD_SIZE_T_
typedef _BSD_SIZE_T_ size_t;
#undef _BSD_SIZE_T_
#undef _BSD_SSIZE_T_
#endif
+#if defined(_POSIX_C_SOURCE)
+#ifndef __VA_LIST_DECLARED
+typedef __va_list va_list;
+#define __VA_LIST_DECLARED
+#endif
+#endif
+
#include <sys/null.h>
/*
* innards of an fpos_t anyway. The library internally uses off_t,
* which we assume is exactly as big as eight chars.
*/
-#if (!defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__)) || defined(_LIBC)
-typedef __off_t fpos_t;
-#else
typedef struct __sfpos {
__off_t _pos;
+ __mbstate_t _mbstate_in, _mbstate_out;
} fpos_t;
-#endif
#define _FSTDIO /* Define for new stdio with functions. */
/* operations */
void *_cookie; /* cookie passed to io functions */
int (*_close)(void *);
- int (*_read) (void *, char *, int);
- fpos_t (*_seek) (void *, fpos_t, int);
- int (*_write)(void *, const char *, int);
+ ssize_t (*_read) (void *, void *, size_t);
+ __off_t (*_seek) (void *, __off_t, int);
+ ssize_t (*_write)(void *, const void *, size_t);
/* file extension */
struct __sbuf _ext;
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
unsigned char _nbuf[1]; /* guarantee a getc() buffer */
+ int (*_flush)(void *);
/* Formerly used by fgetln/fgetwln; kept for binary compatibility */
- struct __sbuf _lb__unused;
+ char _lb_unused[sizeof(struct __sbuf) - sizeof(int (*)(void *))];
/* Unix stdio files get aligned to block boundaries on fseek() */
int _blksize; /* stat.st_blksize (may be != _bf._size) */
- fpos_t _offset; /* current lseek offset */
+ __off_t _offset; /* current lseek offset */
} FILE;
__BEGIN_DECLS
-extern FILE __sF[];
+extern FILE __sF[3];
__END_DECLS
#define __SLBF 0x0001 /* line buffered */
int ferror(FILE *);
int fflush(FILE *);
int fgetc(FILE *);
-int fgetpos(FILE * __restrict, fpos_t * __restrict);
char *fgets(char * __restrict, int, FILE * __restrict);
FILE *fopen(const char * __restrict , const char * __restrict);
int fprintf(FILE * __restrict , const char * __restrict, ...)
int fscanf(FILE * __restrict, const char * __restrict, ...)
__scanflike(2, 3);
int fseek(FILE *, long, int);
-int fsetpos(FILE *, const fpos_t *);
long ftell(FILE *);
size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
int getc(FILE *);
__scanflike(2, 3);
FILE *tmpfile(void);
int ungetc(int, FILE *);
-int vfprintf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_)
+int vfprintf(FILE * __restrict, const char * __restrict, __va_list)
__printflike(2, 0);
-int vprintf(const char * __restrict, _BSD_VA_LIST_)
+int vprintf(const char * __restrict, __va_list)
__printflike(1, 0);
#ifndef __AUDIT__
__printflike(2, 3);
char *tmpnam(char *);
int vsprintf(char * __restrict, const char * __restrict,
- _BSD_VA_LIST_)
+ __va_list)
__printflike(2, 0);
#endif
#endif
__END_DECLS
+#ifndef __LIBC12_SOURCE__
+int fgetpos(FILE * __restrict, fpos_t * __restrict) __RENAME(__fgetpos50);
+int fsetpos(FILE *, const fpos_t *) __RENAME(__fsetpos50);
+#endif
/*
* IEEE Std 1003.1-90
*/
int snprintf(char * __restrict, size_t, const char * __restrict, ...)
__printflike(3, 4);
int vsnprintf(char * __restrict, size_t, const char * __restrict,
- _BSD_VA_LIST_)
+ __va_list)
__printflike(3, 0);
__END_DECLS
#endif
*/
#if defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
__BEGIN_DECLS
-int vscanf(const char * __restrict, _BSD_VA_LIST_)
+int vscanf(const char * __restrict, __va_list)
__scanflike(1, 0);
-int vfscanf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_)
+int vfscanf(FILE * __restrict, const char * __restrict, __va_list)
__scanflike(2, 0);
int vsscanf(const char * __restrict, const char * __restrict,
- _BSD_VA_LIST_)
+ __va_list)
__scanflike(2, 0);
__END_DECLS
#endif /* _ISOC99_SOURCE || _NETBSD_SOURCE */
void setbuffer(FILE *, char *, int);
int setlinebuf(FILE *);
int vasprintf(char ** __restrict, const char * __restrict,
- _BSD_VA_LIST_)
+ __va_list)
__printflike(2, 0);
const char *fmtcheck(const char *, const char *)
__format_arg(2);
*/
__BEGIN_DECLS
FILE *funopen(const void *,
- int (*)(void *, char *, int),
- int (*)(void *, const char *, int),
- fpos_t (*)(void *, fpos_t, int),
- int (*)(void *));
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ off_t (*)(void *, off_t, int),
+ int (*)(void *));
+FILE *funopen2(const void *,
+ ssize_t (*)(void *, void *, size_t),
+ ssize_t (*)(void *, const void *, size_t),
+ off_t (*)(void *, off_t, int),
+ int (*)(void *),
+ int (*)(void *));
__END_DECLS
#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
+#define fropen2(cookie, fn) funopen2(cookie, fn, 0, 0, 0, 0)
+#define fwopen2(cookie, fn) funopen2(cookie, 0, fn, 0, 0, 0)
#endif /* _NETBSD_SOURCE */
/*
#endif /* !_ANSI_SOURCE */
#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
-int vdprintf(int, const char * __restrict, _BSD_VA_LIST_)
+int vdprintf(int, const char * __restrict, __va_list)
__printflike(2, 0);
int dprintf(int, const char * __restrict, ...)
__printflike(2, 3);
-/* $NetBSD: stdlib.h,v 1.94 2010/12/22 19:47:56 jruoho Exp $ */
+/* $NetBSD: stdlib.h,v 1.100 2012/06/21 21:13:29 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
int rand_r(unsigned int *);
#endif
-
/*
* X/Open Portability Guide >= Issue 4
*/
seed48(unsigned short[3]);
void srand48(long);
-int putenv(char *);
+#ifndef __LIBC12_SOURCE__
+int putenv(char *) __RENAME(__putenv50);
+#endif
#endif
int setkey(const char *);
-char *realpath(const char *, char *);
+char *realpath(const char * __restrict, char * __restrict);
int ttyslot(void);
#elif defined(__PCC__) && !defined(__GNUC__)
#define alloca(size) __builtin_alloca(size)
#elif (__GNUC__ >= 2)
+/* LSC: MINIX Patch needed (2 following lines) */
#define alloca(size) __builtin_alloca(size)
#else
void *alloca(size_t);
uint32_t arc4random(void);
void arc4random_stir(void);
+void arc4random_buf(void *, size_t);
+uint32_t arc4random_uniform(uint32_t);
void arc4random_addrandom(u_char *, int);
char *getbsize(int *, long *);
char *cgetcap(char *, const char *, int);
int daemon(int, int);
#ifndef __minix
+int devname_r(dev_t, mode_t, char *, size_t);
#ifndef __LIBC12_SOURCE__
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
#endif
-/* $NetBSD: string.h,v 1.39 2009/07/22 19:48:27 kleink Exp $ */
+/* $NetBSD: string.h,v 1.41 2012/08/30 12:16:48 drochner Exp $ */
/*-
* Copyright (c) 1990, 1993
* strxfrm_l
*/
#endif
+__END_DECLS
#if defined(_NETBSD_SOURCE)
#include <strings.h> /* for backwards-compatibilty */
+__BEGIN_DECLS
void *memmem(const void *, size_t, const void *, size_t);
char *strcasestr(const char *, const char *);
size_t strlcat(char *, const char *, size_t);
char *stresep(char **, const char *, int);
char *strndup(const char *, size_t);
void *memrchr(const void *, int, size_t);
-#endif
+void __explicit_bzero(void *, size_t);
+int __consttime_bcmp(const void *, const void *, size_t);
__END_DECLS
+#endif
#if _FORTIFY_SOURCE > 0
#include <ssp/string.h>
-/* $NetBSD: strings.h,v 1.17 2009/08/19 04:22:53 yamt Exp $ */
+/* $NetBSD: strings.h,v 1.18 2011/08/22 01:24:15 dholland Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
-#include <stdint.h>
+#include <machine/int_types.h>
__BEGIN_DECLS
int bcmp(const void *, const void *, size_t);
unsigned int popcount(unsigned int) __constfunc;
unsigned int popcountl(unsigned long) __constfunc;
unsigned int popcountll(unsigned long long) __constfunc;
-unsigned int popcount32(uint32_t) __constfunc;
-unsigned int popcount64(uint64_t) __constfunc;
+unsigned int popcount32(__uint32_t) __constfunc;
+unsigned int popcount64(__uint64_t) __constfunc;
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
-/* $NetBSD: time.h,v 1.40 2010/12/16 18:36:47 christos Exp $ */
+/* $NetBSD: time.h,v 1.41 2012/10/02 01:42:06 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#include <sys/time.h> /* XXX for struct timespec */
struct sigevent;
struct itimerspec;
+int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
#ifndef __LIBC12_SOURCE__
#ifndef __minix
int clock_getres(clockid_t, struct timespec *)
#endif /* _NETBSD_SOURCE */
-#ifdef _MINIX
+#ifdef __minix
int stime(time_t *_top);
-#endif /* _MINIX */
+#endif /* __minix */
__END_DECLS
-/* $NetBSD: ucontext.h,v 1.6 2009/03/19 08:04:38 uebayasi Exp $ */
+/* $NetBSD: ucontext.h,v 1.7 2011/11/05 09:27:06 joerg Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
#include <sys/ucontext.h>
__BEGIN_DECLS
-int getcontext(ucontext_t *);
+int getcontext(ucontext_t *) __returns_twice;
int setcontext(const ucontext_t *);
void makecontext(ucontext_t *, void (*)(), int, ...);
int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict);
-/* $NetBSD: unistd.h,v 1.125 2011/01/19 19:21:29 christos Exp $ */
+/* $NetBSD: unistd.h,v 1.135 2012/07/14 15:06:26 darrenr Exp $ */
/*-
* Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
getpagesize(void); /* legacy */
#ifndef __minix
pid_t getpgid(pid_t);
-#endif /* !__minix */
-#ifndef __minix
#if defined(_XOPEN_SOURCE)
int lchown(const char *, uid_t, gid_t) __RENAME(__posix_lchown);
#else
useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
#ifndef __LIBC12_SOURCE__
-pid_t vfork(void) __RENAME(__vfork14);
+pid_t vfork(void) __RENAME(__vfork14) __returns_twice;
#endif
#ifndef __AUDIT__
ssize_t pwrite(int, const void *, size_t, off_t);
#endif
+/*
+ * X/Open Extended API set 2 (a.k.a. C063)
+ */
+#if defined(_INCOMPLETE_XOPEN_C063)
+int linkat(int, const char *, int, const char *, int);
+int renameat(int, const char *, int, const char *);
+int mkfifoat(int, const char *, mode_t);
+int mknodat(int, const char *, mode_t, uint32_t);
+int mkdirat(int, const char *, mode_t);
+int faccessat(int, const char *, int, int);
+int fchmodat(int, const char *, mode_t, int);
+int fchownat(int, const char *, uid_t, gid_t, int);
+int fexecve(int, char * const *, char * const *);
+int readlinkat(int, const char *, char *, size_t);
+int symlinkat(const char *, int, const char *);
+int unlinkat(int, const char *, int);
+#endif
+
/*
* Implementation-defined extensions
int closefrom(int);
int des_cipher(const char *, char *, long, int);
int des_setkey(const char *);
+int dup3(int, int, int);
void endusershell(void);
int exect(const char *, char * const *, char * const *);
int fchroot(int);
int getgrouplist(const char *, gid_t, gid_t *, int *);
int getgroupmembership(const char *, gid_t, gid_t *, int, int *);
mode_t getmode(const void *, mode_t);
+char *getpassfd(const char *, char *, size_t, int *, int, int);
+#define GETPASS_NEED_TTY 0x001 /* Fail if we cannot set tty */
+#define GETPASS_FAIL_EOF 0x002 /* Fail on EOF */
+#define GETPASS_BUF_LIMIT 0x004 /* beep on buffer limit */
+#define GETPASS_NO_SIGNAL 0x008 /* don't make ttychars send signals */
+#define GETPASS_NO_BEEP 0x010 /* don't beep */
+#define GETPASS_ECHO 0x020 /* echo characters as they are typed */
+#define GETPASS_ECHO_STAR 0x040 /* echo '*' for each character */
+#define GETPASS_7BIT 0x080 /* mask the high bit each char */
+#define GETPASS_FORCE_LOWER 0x100 /* lowercase each char */
+#define GETPASS_FORCE_UPPER 0x200 /* uppercase each char */
+#define GETPASS_ECHO_NL 0x400 /* echo a newline if successful */
+
+char *getpass_r(const char *, char *, size_t);
int getpeereid(int, uid_t *, gid_t *);
int getsubopt(char **, char * const *, char **);
__aconst char *getusershell(void);
int issetugid(void);
int nfssvc(int, void *);
#ifndef __minix
+int pipe2(int *, int);
int profil(char *, size_t, u_long, u_int);
#endif /* !__minix */
#ifndef __PSIGNAL_DECLARED
#define __PSIGNAL_DECLARED
/* also in signal.h */
-void psignal(int, const char *);
+void psignal(int, const char *);
#endif /* __PSIGNAL_DECLARED */
int rcmd(char **, int, const char *, const char *, const char *, int *);
#ifdef __minix
int rcmd_af(char **, int, const char *,
const char *, const char *, int *, int);
int rresvport_af(int *, int);
+int rresvport_af_addr(int *, int, void *);
int iruserok_sa(const void *, int, int, const char *, const char *);
#endif
-/* $NetBSD: vis.h,v 1.18 2010/11/27 19:44:54 christos Exp $ */
+/* $NetBSD: vis.h,v 1.19 2011/03/12 19:52:45 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#define VIS_MIMESTYLE 0x100 /* mime-style escape = HEX HEX */
#define VIS_HTTP1866 0x200 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x400 /* don't decode `\' */
+#define _VIS_END 0x800 /* for unvis */
/*
* unvis return codes
/*
* unvis flags
*/
-#define UNVIS_END 1 /* no more characters */
+#define UNVIS_END _VIS_END /* no more characters */
#include <sys/cdefs.h>
__BEGIN_DECLS
char *vis(char *, int, int, int);
+char *nvis(char *, size_t, int, int, int);
+
char *svis(char *, int, int, int, const char *);
+char *snvis(char *, size_t, int, int, int, const char *);
+
int strvis(char *, const char *, int);
+int strnvis(char *, size_t, const char *, int);
+
int strsvis(char *, const char *, int, const char *);
+int strsnvis(char *, size_t, const char *, int, const char *);
+
int strvisx(char *, const char *, size_t, int);
+int strnvisx(char *, size_t, const char *, size_t, int);
+
int strsvisx(char *, const char *, size_t, int, const char *);
+int strsnvisx(char *, size_t, const char *, size_t, int, const char *);
+
int strunvis(char *, const char *);
+int strnunvis(char *, size_t, const char *);
+
int strunvisx(char *, const char *, int);
+int strnunvisx(char *, size_t, const char *, int);
+
#ifndef __LIBC12_SOURCE__
-int unvis(char *, int, int *, int) __RENAME(__unvis13);
+int unvis(char *, int, int *, int) __RENAME(__unvis50);
#endif
__END_DECLS
-/* $NetBSD: wchar.h,v 1.29 2010/03/27 22:14:09 tnozaki Exp $ */
+/* $NetBSD: wchar.h,v 1.30 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#undef _BSD_SIZE_T_
#endif
+#if defined(_POSIX_C_SOURCE)
+#ifndef __VA_LIST_DECLARED
+typedef __va_list va_list;
+#define __VA_LIST_DECLARED
+#endif
+#endif
+
struct tm;
__BEGIN_DECLS
int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, ...);
int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
-int vfwprintf(FILE * __restrict, const wchar_t * __restrict, _BSD_VA_LIST_);
+int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list);
int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict,
- _BSD_VA_LIST_);
-int vwprintf(const wchar_t * __restrict, _BSD_VA_LIST_);
+ __va_list);
+int vwprintf(const wchar_t * __restrict, __va_list);
int wprintf(const wchar_t * __restrict, ...);
int wscanf(const wchar_t * __restrict, ...);
#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) > 199901L || \
defined(_NETBSD_SOURCE)
-int vfwscanf(FILE * __restrict, const wchar_t * __restrict, _BSD_VA_LIST_);
+int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list);
int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
- _BSD_VA_LIST_);
-int vwscanf(const wchar_t * __restrict, _BSD_VA_LIST_);
+ __va_list);
+int vwscanf(const wchar_t * __restrict, __va_list);
#endif
#if defined(_NETBSD_SOURCE)
struct tinfo;
# Makefile for kernel
.include <bsd.own.mk>
+BINDIR= /usr/sbin
+MAN=
PROG= kernel
.include "arch/${MACHINE_ARCH}/Makefile.inc"
SRCS+= clock.c cpulocals.c interrupt.c main.c proc.c system.c \
table.c utility.c usermapped_data.c
-LINKERSCRIPT=${.CURDIR}/arch/${MACHINE_ARCH}/kernel.lds
+DPADD+= ${LIBTIMERS} ${LIBSYS} ${LIBEXEC} ${LIBMINLIB}
+LDADD+= -ltimers -lsys -lexec -lminlib -L/usr/lib
-DPADD+= ${LIBTIMERS} ${LIBSYS} ${LIBEXEC} ${LINKERSCRIPT}
-LDADD+= -ltimers -lsys -lexec
+LINKERSCRIPT= ${.CURDIR}/arch/${MACHINE_ARCH}/kernel.lds
-CFLAGS += -D__kernel__
-
-CPPFLAGS+= -fno-stack-protector -D_NETBSD_SOURCE -D_MINIX
LDFLAGS+= -T ${LINKERSCRIPT}
-LDFLAGS+= -nostdlib -L${DESTDIR}/${LIBDIR}
-LDADD+= -lminlib
-DPADD+= ${LIBMINLIB}
-.if !empty(CC:M*gcc)
-LDADD+= -lgcc -lsys -lgcc -lminc
-.elif !empty(CC:M*clang)
-LDADD+= -L/usr/pkg/compiler-rt/lib -lCompilerRT-Generic -lsys -lCompilerRT-Generic -lminc
-DPADD+= ${LIBC}
-.endif
+LDFLAGS+= -nostdlib
+CFLAGS += -fno-stack-protector
-CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}/include -I${NETBSDSRCDIR}
+CPPFLAGS+= -D_NETBSD_SOURCE -D_MINIX -D__kernel__
-BINDIR= /usr/sbin
-MAN=
+# kernel headers are always called through kernel/*.h
+CPPFLAGS+= -I${NETBSDSRCDIR}
+
+# kernel headers are always called through kernel/*.hi, this
+# time for generated headers, during cross compilation
+CPPFLAGS+= -I${.OBJDIR}/..
+
+# Machine-dependent headers, order is important!
+CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}
+CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}/include
+CPPFLAGS+= -I${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include
.include "system/Makefile.inc"
CPPFLAGS+= -DUSE_TRACE
.endif
-.include <bsd.prog.mk>
+CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
debug.d: extracted-errno.h extracted-mfield.h extracted-mtype.h
-CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
-
extracted-errno.h: extract-errno.sh ../include/errno.h
${_MKTARGET_CREATE}
cd ${.CURDIR} ; ${HOST_SH} extract-errno.sh > ${.OBJDIR}/extracted-errno.h
${_MKTARGET_CREATE}
cd ${.CURDIR} ; ${HOST_SH} extract-mtype.sh > ${.OBJDIR}/extracted-mtype.h
-clean:
- rm -f extracted-errno.h extracted-mfield.h extracted-mtype.h
-
-
+.include <minix.bootprog.mk>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/minlib.h>
#include <minix/const.h>
#include <minix/cpufeature.h>
/* sections */
#include <machine/vm.h>
-#include "../../kernel.h"
+#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>
#include <minix/type.h>
#include <libexec.h>
#include <assert.h>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_proto.h"
#include <machine/cpu.h>
#define UNPAGED 1 /* for proper kmain() prototype */
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <assert.h>
#include <stdlib.h>
#include <minix/minlib.h>
-include "kernel.h"
-include "proc.h"
+include "kernel/kernel.h"
+include "kernel/proc.h"
struct proc
member REG0 p_reg.retreg
-
# Makefile for arch-dependent kernel code
.include <bsd.own.mk>
HERE=${.CURDIR}/arch/${MACHINE_ARCH}
.PATH: ${HERE}
-# objects we want unpaged from -lminlib, -lminc
+# objects we want unpaged from -lminlib
MINLIB_OBJS_UNPAGED=_cpufeature.o _cpuid.o get_bp.o
-MINC_OBJS_UNPAGED=strcat.o strlen.o memcpy.o strcpy.o strncmp.o memset.o \
- memmove.o strcmp.o atoi.o ctype_.o _stdfile.o strtol.o _errno.o errno.o \
- udivdi3.o umoddi3.o qdivrem.o
-SYS_OBJS_UNPAGED=kprintf.o vprintf.o assert.o stacktrace.o
+_cpufeature.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/_cpufeature.c
+_cpuid.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/_cpuid.S
+get_bp.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/get_bp.S
+
+# objects we want unpaged from -lsys
+SYS_OBJS_UNPAGED=assert.o kprintf.o stacktrace.o vprintf.o
+assert.o: ${NETBSDSRCDIR}/lib/libsys/assert.c
+kprintf.o: ${NETBSDSRCDIR}/lib/libsys/kprintf.c
+stacktrace.o: ${NETBSDSRCDIR}/lib/libsys/stacktrace.c
+vprintf.o: ${NETBSDSRCDIR}/lib/libsys/vprintf.c
+
+# objects we want unpaged from -lminc
+MINC_OBJS_UNPAGED=findfp.o strcat.o strlen.o memcpy.o strcpy.o strncmp.o \
+ memset.o memmove.o strcmp.o atoi.o ctype_.o strtol.o \
+ _errno.o errno.o udivdi3.o umoddi3.o qdivrem.o
+memcpy.o: ${NETBSDSRCDIR}/common/lib/libc/string/memcpy.c
+memmove.o: ${NETBSDSRCDIR}/common/lib/libc/string/memmove.c
+memset.o: ${NETBSDSRCDIR}/common/lib/libc/string/memset.c
+strcat.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcat.c
+strlen.o: ${NETBSDSRCDIR}/common/lib/libc/string/strlen.c
+strcpy.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcpy.c
+strcmp.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcmp.c
+strncmp.o: ${NETBSDSRCDIR}/common/lib/libc/string/strncmp.c
+udivdi3.o: ${NETBSDSRCDIR}/common/lib/libc/quad/udivdi3.c
+umoddi3.o: ${NETBSDSRCDIR}/common/lib/libc/quad/umoddi3.c
+qdivrem.o: ${NETBSDSRCDIR}/common/lib/libc/quad/qdivrem.c
+atoi.o: ${NETBSDSRCDIR}/lib/libc/stdlib/atoi.c
+strtol.o: ${NETBSDSRCDIR}/lib/libc/stdlib/strtol.c
+findfp.o: ${NETBSDSRCDIR}/lib/libc/stdio/findfp.c
+ctype_.o: ${NETBSDSRCDIR}/lib/libc/gen/ctype_.c
+_errno.o: ${NETBSDSRCDIR}/lib/libc/gen/_errno.c
+errno.o: ${NETBSDSRCDIR}/lib/libc/gen/errno.c
+
+# Specific flags needed to compile a few of the object files.
+CPPFLAGS.strtol.c+= -I ${NETBSDSRCDIR}/common/lib/libc/stdlib
+CPPFLAGS.ctype_.c+= -I ${NETBSDSRCDIR}/lib/libc/locale
+CPPFLAGS._errno.c+= -I ${NETBSDSRCDIR}/lib/libc/include
+CPPFLAGS.assert.c+= -I ${NETBSDSRCDIR}/lib/libc/include
+CPPFLAGS.findfp.c+= -I ${NETBSDSRCDIR}/lib/libc/include
# some object files we give a symbol prefix (or namespace) of __k_unpaged_
# that must live in their own unique namespace.
io_inb.o pg_utils.o klib.o utility.o arch_reset.o \
${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}
unpaged_${UNPAGED_OBJ}: ${UNPAGED_OBJ}
- ${OBJCOPY} --prefix-symbols=__k_unpaged_ ${UNPAGED_OBJ} unpaged_${UNPAGED_OBJ}
+ ${OBJCOPY} --prefix-symbols=__k_unpaged_ ${.OBJDIR}/${UNPAGED_OBJ} $@
UNPAGED_OBJS += unpaged_${UNPAGED_OBJ}
ORIG_UNPAGED_OBJS += ${UNPAGED_OBJ}
.endfor
-# we have to extract some object files from libminc.a and libminlib.a
-${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}: ${LIBMINLIB} ${LIBMINC} ${LIBSYS}
- ${AR} x ${LIBMINLIB} ${MINLIB_OBJS_UNPAGED}
- ${AR} x ${LIBMINC} ${MINC_OBJS_UNPAGED}
- ${AR} x ${LIBSYS} ${SYS_OBJS_UNPAGED}
-
-CLEANFILES+= $(ORIG_UNPAGED_OBJS)
+CLEANFILES+= ${ORIG_UNPAGED_OBJS}
SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c \
do_iopenable.c do_readbios.c do_sdevio.c exception.c i8259.c io_inb.S \
OBJS.kernel+= ${UNPAGED_OBJS}
+.ifdef CONFIG_SMP
+SRCS += arch_smp.c trampoline.S
+.endif
+
.if ${USE_ACPI} != "no"
SRCS+= acpi.c
CPPFLAGS+= -DUSE_ACPI
CPPFLAGS+= -DUSE_WATCHDOG
.endif
-sconst.h: procoffsets.h
-apic_asm.S head.S klib16.S klib.S mpx.S: sconst.h
SRCS+= procoffsets.h
-CPPFLAGS+=-I.
-# It's OK to hardcode the arch as i386 here as this and procoffsets.cf
-# are i386-specific.
-TMP=procoffsets.h.tmp
-INCLS=../include/arch/i386/include/
PROCOFFSETSCF=procoffsets.cf
-procoffsets.h: ${PROCOFFSETSCF} kernel.h proc.h ${INCLS}/stackframe.h ${INCLS}/archtypes.h
+.PATH: ${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include
+
+procoffsets.h: ${PROCOFFSETSCF} kernel.h proc.h stackframe.h archtypes.h
${_MKTARGET_CREATE}
${TOOL_CAT} ${HERE}/${PROCOFFSETSCF} | \
- ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$TMP && \
- mv -f $TMP $@
-
-.ifdef CONFIG_SMP
-SRCS += arch_smp.c trampoline.S
-.endif
+ ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$@.tmp && \
+ mv -f $@.tmp $@
+sconst.h: procoffsets.h
+apic_asm.S head.S klib16.S klib.S mpx.S: sconst.h
#include "kernel/interrupt.h"
#include <minix/u64.h>
#include "glo.h"
-#include "profile.h"
+#include "kernel/profile.h"
#ifdef USE_APIC
#include "apic.h"
#endif
-#include "spinlock.h"
+#include "kernel/spinlock.h"
#ifdef CONFIG_SMP
#include "kernel/smp.h"
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/minlib.h>
#include <minix/const.h>
#include <minix/cpufeature.h>
/* sections */
#include <machine/vm.h>
-#include "../../kernel.h"
+#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>
* either
*/
#if defined(USE_APIC)
-#include "arch/i386/apic.h"
+#include "kernel/arch/i386/apic.h"
#define hw_intr_mask(irq) ioapic_mask_irq(irq)
#define hw_intr_unmask(irq) ioapic_unmask_irq(irq)
__k_unpaged__kern_size = . - _kern_vir_base;
_kern_size = __k_unpaged__kern_size;
}
+ _end = .;
}
/* sections */
#include <machine/vm.h>
-#include "../../kernel.h"
+#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>
#include <minix/cpufeature.h>
#include <assert.h>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <libexec.h>
#include "arch_proto.h"
#define UNPAGED 1 /* for proper kmain() prototype */
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <assert.h>
#include <stdlib.h>
#include <minix/minlib.h>
-include "kernel.h"
+include "kernel/kernel.h"
struct proc
member DIREG p_reg.di
#ifndef __SCONST_H__
#define __SCONST_H__
-/*
- * LSC Weirdness going on with the const.h header: FIXME
#include "kernel/const.h"
#include "kernel/procoffsets.h"
- */
-#include "const.h"
-#include "procoffsets.h"
/*
* offset to current process pointer right after trap, we assume we always have
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_proto.h"
struct minix_ipcvecs minix_ipcvecs_softint = {
* Instead, notify(), which always returns, should be used.
*/
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/endpoint.h>
#include <assert.h>
#ifndef __CLOCK_H__
#define __CLOCK_H__
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_clock.h"
int boot_cpu_init_timer(unsigned freq);
-#include "kernel.h"
+#include "kernel/kernel.h"
DEFINE_CPULOCAL_VARS;
* functions and sanity checking of the scheduling queues.
*/
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/callnr.h>
#include <minix/sysutil.h>
set -e
# grep message type and errno constants and make them into a .h file
-cat ../include/sys/errno.h | \
+cat ../sys/sys/errno.h | \
tr -s ' \t' ' ' | \
sed 's/^# /#/' | \
egrep '^#define [A-Z_][A-Z0-9_]* \( ?_SIGN ?[0-9]+ ?\)' | \
#include <assert.h>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "archconst.h"
#include "hw_intr.h"
#include <minix/param.h>
/* Important kernel header files. */
-#include "config.h" /* configuration, MUST be first */
-#include "const.h" /* constants, MUST be second */
-#include "type.h" /* type definitions, MUST be third */
-#include "proto.h" /* function prototypes */
-#include "glo.h" /* global variables */
-#include "ipc.h" /* IPC constants */
-#include "profile.h" /* system profiling */
-#include "proc.h" /* process table */
-#include "cpulocals.h" /* CPU-local variables */
-#include "debug.h" /* debugging, MUST be last kernel header */
+#include "kernel/config.h" /* configuration, MUST be first */
+#include "kernel/const.h" /* constants, MUST be second */
+#include "kernel/type.h" /* type definitions, MUST be third */
+#include "kernel/proto.h" /* function prototypes */
+#include "kernel/glo.h" /* global variables */
+#include "kernel/ipc.h" /* IPC constants */
+#include "kernel/profile.h" /* system profiling */
+#include "kernel/proc.h" /* process table */
+#include "kernel/cpulocals.h" /* CPU-local variables */
+#include "kernel/debug.h" /* debugging, MUST be last kernel header */
#ifndef CONFIG_SMP
/* We only support 1 cpu now */
#else
-#include "smp.h"
+#include "kernel/smp.h"
#endif
* main: MINIX main program
* prepare_shutdown: prepare to take MINIX down
*/
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <minix/com.h>
#include <minix/const.h>
#include <minix/priv.h>
-#include "const.h"
-#include "type.h"
+#include "kernel/const.h"
+#include "kernel/type.h"
struct priv {
proc_nr_t s_proc_nr; /* number of associated process */
#include <signal.h>
#include <assert.h>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "vm.h"
#include "clock.h"
#include "spinlock.h"
#include <minix/config.h>
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/profile.h>
#include <minix/portio.h>
#ifndef __ASSEMBLY__
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_smp.h"
#include "spinlock.h"
#ifndef __SPINLOCK_H__
#define __SPINLOCK_H__
-#include "kernel.h"
+#include "kernel/kernel.h"
typedef struct spinlock {
atomic_t val;
* Sep 30, 2004 source code documentation updated (Jorrit N. Herder)
*/
-#include "kernel.h"
-#include "system.h"
-#include "vm.h"
+#include "kernel/kernel.h"
+#include "kernel/system.h"
+#include "kernel/vm.h"
#include "kernel/clock.h"
#include <stdlib.h>
#include <assert.h>
#ifndef SYSTEM_H
#define SYSTEM_H
-#include "kernel.h"
+#include "kernel/kernel.h"
int do_exec(struct proc * caller, message *m_ptr);
#if ! USE_EXEC
#include <assert.h>
#include "kernel/system.h"
-#include "kernel.h"
+#include "kernel/kernel.h"
#define MAX_INDIRECT_DEPTH 5 /* up to how many indirect grants to follow? */
#include <minix/safecopies.h>
#include "kernel/system.h"
-#include "kernel.h"
+#include "kernel/kernel.h"
/*===========================================================================*
* do_safememset *
*/
#include "kernel/system.h"
-#include "watchdog.h"
+#include "kernel/watchdog.h"
#if SPROFILE
*/
#define _TABLE
-#include "kernel.h"
+#include "kernel/kernel.h"
#include <minix/com.h>
/* The system image table lists all programs that are part of the boot image.
-#include "kernel.h"
+#include "kernel/kernel.h"
/* This is the user-visible struct that has pointers to other bits of data. */
struct minix_kerninfo minix_kerninfo;
* kputc: buffered putc used by kernel printf
*/
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_proto.h"
#include <minix/syslib.h>
return;
}
+/*===========================================================================*
+ * _exit *
+ *===========================================================================*/
+void _exit(e)
+int e; /* error code */
+{
+ panic("_exit called from within the kernel, should not happen. (err %i)", e);
+}
#ifndef __WATCHDOG_H__
#define __WATCHDOG_H__
-#include "kernel.h"
+#include "kernel/kernel.h"
#include "arch_watchdog.h"
extern int watchdog_enabled; /* if set to non-zero the watch dog is enabled */
-/* $NetBSD: crt0.c,v 1.24 2003/07/26 19:24:25 salo Exp $ */
+/* $NetBSD: crt0.c,v 1.27 2012/03/22 13:02:15 he Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
struct ps_strings *));
void
-__start(sp, cleanup, obj, ps_strings)
- char **sp;
- void (*cleanup) __P((void)); /* from shared loader */
- const Obj_Entry *obj; /* from shared loader */
- struct ps_strings *ps_strings;
+__start(char **sp, void (*cleanup)(void),
+ const Obj_Entry *obj, struct ps_strings *ps_strings)
{
long argc;
char **argv, *namep;
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.24 2003/07/26 19:24:25 salo Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.27 2012/03/22 13:02:15 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:33 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.2 2012/09/16 13:46:49 skrll Exp $
CPPFLAGS+= -DELFSIZE=32
-
-
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $ */
-/*
- * Copyright (C) 1997 Mark Brinicombe
- * Copyright (C) 1995 Wolfgang Solfrank.
- * Copyright (C) 1995 TooLs GmbH.
+/*-
+ * 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:
* 2. Redistributions in binary form must reproduce 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.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
+#include <arm/asm.h>
+
+RCSID("$NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
- mov r5, r2 /* cleanup */
- mov r4, r1 /* obj_main */
- mov r3, r0 /* ps_strings */
- /* Get argc, argv, and envp from stack */
- ldr r0, [sp, #0x0000]
- add r1, sp, #0x0004
- add r2, r1, r0, lsl #2
- add r2, r2, #0x0004
+ /*
+ * 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
- sub sp, sp, #8
- str r5, [sp, #4]
- str r4, [sp, #0]
+
+ /*
+ * void ___start(void (*cleanup)(void),
+ * const Obj_Entry *obj,
+ * struct ps_strings *ps_strings);
+ */
b ___start
--- /dev/null
+/* $NetBSD: crtbegin.S,v 1.4 2012/08/25 15:39:05 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 <arm/asm.h>
+
+RCSID("$NetBSD: crtbegin.S,v 1.4 2012/08/25 15:39:05 matt Exp $")
+
+ .section .ctors, "aw", %progbits
+ .p2align 2
+__CTOR_LIST__:
+ .word -1
+
+ .section .dtors, "aw", %progbits
+ .p2align 2
+__DTOR_LIST__:
+ .word -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
+ .word __dso_handle
+#else
+ .word 0
+#endif
+
+ .local __dwarf_eh_object
+ .comm __dwarf_eh_object,24
+ .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.
+ */
+
+ .type __do_global_dtors_aux, %function
+__do_global_dtors_aux:
+ GOT_INIT(r3, .Ldtors_got, .Ldtors) /* use r3 temporarily */
+ ldr r1, .L__finished
+#ifdef PIC
+ ldrb r0, [r1, r3]!
+#else
+ ldrb r0, [r1]
+#endif
+ cmp r0, #0 /* done this already? */
+ RETc(ne)
+ mov r0, #1
+ strb r0, [r1] /* mark it as done */
+
+ mov ip, sp
+ stmfd sp!, {r4, r5, r6, r7, fp, ip, lr, pc}
+ sub fp, ip, #4
+ mov r7, r3 /* now that r7 is saved ... */
+
+#ifdef SHARED
+ GOT_GET(ip, r7, .L__cxa_finalize)
+ cmp ip, #0
+ ldrne r2, .L__dso_handle /* GOTOFF */
+ ldrne r0, [r2, r7] /* load relative to GOT */
+#ifdef _ARM_ARCH_4T
+ blxne ip
+#else
+ movne lr, pc
+ movne pc, ip
+#endif
+#endif /* SHARED */
+
+ /*
+ * We know the first entry is -1 so skip it. We use load with
+ * preincrement to advance the pointer along.
+ */
+ ldr r4, .L__DTOR_LIST__
+ ldr r5, .L__DTOR_LIST_END__
+#ifdef PIC
+ add r4, r4, r7 /* addr = offset + got */
+ add r5, r5, r7 /* addr = offset + got */
+#endif
+ add r4, r4, #4 /* skip first entry */
+1:
+ cmp r4, r5 /* end of list */
+ ldrne ip, [r4], #4 /* ip = *r4++; */
+#ifndef SHARED
+ ldmeqfd sp, {r4, r5, r6, r7, fp, sp, pc} /* restore and return */
+#endif
+ adrne lr, 1b /* set up to return to loop start */
+#ifdef _ARM_ARCH_4T
+ bxne ip /* call it */
+#else
+ movne pc, ip /* call entry */
+#endif
+
+#ifdef SHARED
+ /*
+ * if (__deregister_frame_info)
+ * __deregister_frame_info(&__EH_FRAME_LIST__[0]);
+ */
+ GOT_GET(ip, r7, .L__deregister_frame_info)
+ cmp ip, #0
+ ldmeqfd sp, {r4-r7, fp, sp, pc} /* restore and return */
+
+ ldr r1, .L__EH_FRAME_LIST__
+#ifdef PIC
+ add r0, r1, r7 /* add offset to GOT addr */
+#endif
+ ldmfd sp, {r4-r7, fp, sp, lr} /* restore everthing */
+#ifdef _ARM_ARCH_4T
+ bx ip /* tail call it */
+#else
+ mov pc, ip /* tail call it */
+#endif
+#endif /* SHARED */
+
+ .weak __deregister_frame_info
+ .weak __cxa_finalize
+ .hidden _C_LABEL(__DTOR_LIST_END__)
+
+ .align 2
+ GOT_INITSYM(.Ldtors_got, .Ldtors)
+#ifdef SHARED
+.L__deregister_frame_info:
+ .word PIC_SYM(_C_LABEL(__deregister_frame_info), GOT)
+.L__cxa_finalize:
+ .word PIC_SYM(_C_LABEL(__cxa_finalize), GOT)
+.L__dso_handle:
+ .word PIC_SYM(_C_LABEL(__dso_handle), GOTOFF)
+#endif
+.L__finished:
+ .word PIC_SYM(_C_LABEL(__finished), GOTOFF)
+.L__DTOR_LIST__:
+ .word PIC_SYM(_C_LABEL(__DTOR_LIST__), GOTOFF)
+.L__DTOR_LIST_END__:
+ .word PIC_SYM(_C_LABEL(__DTOR_LIST_END__), GOTOFF)
+.L__EH_FRAME_LIST__:
+ .word PIC_SYM(_C_LABEL(__EH_FRAME_LIST__), GOTOFF)
+
+
+ .weak __register_frame_info
+ .weak _Jv_RegisterClasses
+
+ .type __do_global_ctors_aux, %function
+__do_global_ctors_aux:
+ GOT_INIT(r3, .Lctors_got, .Lctors)
+ ldr r1, .L__initialized
+#ifdef PIC
+ ldrb r0, [r1, r3]!
+#else
+ ldrb r0, [r1]
+#endif
+ cmp r0, #0 /* done this already? */
+ RETc(ne)
+ mov r0, #1
+ strb r0, [r1] /* mark it as done */
+
+ mov ip, sp
+ stmfd sp!, {r4, r5, r6, r7, fp, ip, lr, pc}
+ sub fp, ip, #4
+ mov r7, r3 /* now that r7 is saved ... */
+
+ /*
+ * if (__register_frame_info)
+ * __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
+ */
+ GOT_GET(ip, r7, .L__register_frame_info)
+ cmp ip, #0
+ beq 1f
+
+ ldr r0, .L__EH_FRAME_LIST__
+ ldr r1, .L__dwarf_eh_object
+#ifdef PIC
+ add r0, r0, r7 /* object addr = got addr + offset */
+ add r1, r1, r7 /* object addr = got addr + offset */
+#endif
+
+#ifdef _ARM_ARCH_4T
+ blx ip
+#else
+ mov lr, pc
+ mov pc, ip
+#endif
+1:
+ /*
+ * if (_Jv_RegisterClasses && __JCR_LIST__[0])
+ * _Jv_RegisterClasses(&__JCR_LIST__[0]);
+ */
+ GOT_GET(ip, r7, .L_Jv_RegisterClasses)
+ cmp ip, #0
+
+ ldrne r0, .L__JCR_LIST__
+#ifdef PIC
+ ldrne r2, [r0, r7]! /* load 1st one, make r0 point to it */
+#else
+ ldrne r2, [r0] /* load 1st one */
+#endif
+ cmpne r2, #0
+#ifdef _ARM_ARCH_4T
+ blxne ip
+#else
+ movne lr, pc
+ movne pc, ip
+#endif
+
+ /*
+ * Get the start and end of the CTOR list.
+ */
+
+ ldr r4, .L__CTOR_LIST__
+ ldr r5, .L__CTOR_LIST_END__
+#ifdef PIC
+ add r4, r4, r7 /* object addr = got addr + offset */
+ add r5, r5, r7 /* object addr = got addr + offset */
+#endif
+ sub r5, r5, #4 /* ignore first entry */
+3:
+ cmp r4, r5 /* at first entry? */
+ ldmeqfd sp, {r4-r7, fp, sp, pc} /* then return */
+ adr lr, 3b /* return to start of loop */
+ ldr ip, [r5], #-4 /* get entry */
+#ifdef _ARM_ARCH_4T
+ bx ip
+#else
+ mov pc, ip /* get entry */
+#endif
+
+ .hidden _C_LABEL(__CTOR_LIST_END__)
+
+ .align 2
+ GOT_INITSYM(.Lctors_got, .Lctors)
+.L_Jv_RegisterClasses:
+ .word PIC_SYM(_C_LABEL(_Jv_RegisterClasses), GOT)
+.L__register_frame_info:
+ .word PIC_SYM(_C_LABEL(__register_frame_info), GOT)
+.L__initialized:
+ .word PIC_SYM(_C_LABEL(__initialized), GOTOFF)
+.L__CTOR_LIST__:
+ .word PIC_SYM(_C_LABEL(__CTOR_LIST__), GOTOFF)
+.L__CTOR_LIST_END__:
+ .word PIC_SYM(_C_LABEL(__CTOR_LIST_END__), GOTOFF)
+.L__dwarf_eh_object:
+ .word PIC_SYM(_C_LABEL(__dwarf_eh_object), GOTOFF)
+.L__JCR_LIST__:
+ .word PIC_SYM(_C_LABEL(__JCR_LIST__), GOTOFF)
+
+ .section .init, "ax", %progbits
+ bl __do_global_ctors_aux
+ .section .fini, "ax", %progbits
+ bl __do_global_dtors_aux
--- /dev/null
+/* $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 <arm/asm.h>
+
+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
-/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
#include <machine/asm.h>
-RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
+RCSID("$NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $")
#include "sysident.S"
- .section ".init", "ax", @progbits
+ .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
+ .section ".fini", "ax", %progbits
.align 0
.globl _fini
+ .type _fini,%function
_fini:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
-/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
#include <machine/asm.h>
-RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
+RCSID("$NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $")
- .section ".init", "ax", @progbits
+ .section ".init", "ax", %progbits
ldmea fp, {fp, sp, pc}
- .section ".fini", "ax", @progbits
+ .section ".fini", "ax", %progbits
ldmea fp, {fp, sp, pc}
--- /dev/null
+# $NetBSD: Makefile.inc,v 1.1 2012/08/13 02:49:04 matt Exp $
+
+CPPFLAGS+= -DELFSIZE=32
+CPPFLAGS+= -DHAVE_INITFINI_ARRAY
+
--- /dev/null
+/* $NetBSD: crt0.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 <arm/asm.h>
+
+RCSID("$NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 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
--- /dev/null
+/* $NetBSD: crtbegin.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 <arm/asm.h>
+
+RCSID("$NetBSD: crtbegin.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
+
+ .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
+ .word __dso_handle
+#else
+ .word 0
+#endif
+
+ .text
+#ifdef SHARED
+ /*
+ * If we aren't shared, all we do is set finished
+ * to 1 if it isn't 1 already. So why bother do that at all?
+ */
+ .type __do_global_dtors_aux, %function
+__do_global_dtors_aux:
+ GOT_INIT(r3, .Ldtors_got, .Ldtors) /* use r3 temporarily */
+ ldr r1, .L__finished /* GOTOFF */
+ ldrb r0, [r1, r3]!
+ cmp r0, #0 /* done this already? */
+ RETc(ne)
+ mov r0, #1
+ strb r0, [r1] /* mark it as done */
+
+ GOT_GET(ip, r3, .L__cxa_finalize)
+ cmp ip, #0
+ RETc(eq)
+ ldr r0, .L__dso_handle /* GOTOFF */
+ ldr r0, [r0, r3] /* load relative to got */
+#if defined(_ARM_ARCH_4T)
+ bx ip /* tail call */
+#else
+ mov pc, ip
+#endif
+
+#if 0 /* not used */
+ /*
+ * if (__deregister_frame_info)
+ * __deregister_frame_info(&__EH_FRAME_LIST__[0]);
+ */
+ GOT_GET(ip, r3, .L__deregister_frame_info)
+ cmp ip, #0
+ ldmeqfd sp, {r4, r5, fp, sp, pc} /* restore and return */
+
+ ldr r1, .L__EH_FRAME_LIST__ /* GOTOFF */
+ add r1, r1, r4 /* add got addr */
+ ldmfd sp, {r4, r5, fp, sp, lr} /* restore everthing */
+#if !defined(_ARM_ARCH_4T)
+ bx ip /* tail call it */
+#else
+ mov pc, ip /* tail call it */
+#endif
+#endif /* notused */
+
+ .weak __cxa_finalize
+ .weak __deregister_frame_info
+
+ .align 2
+ GOT_INITSYM(.Ldtors_got, .Ldtors)
+.L__cxa_finalize:
+ .word PIC_SYM(_C_LABEL(__cxa_finalize), GOT)
+#if 0
+.L__deregister_frame_info:
+ .word PIC_SYM(_C_LABEL(__deregister_frame_info), GOT)
+#endif
+.L__finished:
+ .word PIC_SYM(_C_LABEL(__finished), GOTOFF)
+.L__dso_handle:
+ .word PIC_SYM(_C_LABEL(__dso_handle), GOTOFF)
+
+ .pushsection .fini_array,"aw",%fini_array
+ .p2align 2
+ .word __do_global_dtors_aux
+ .popsection
+#endif /* SHARED */
+
+ .local __finished
+ .comm __finished,1,1
+
+ .weak __register_frame_info
+ .weak _Jv_RegisterClasses
+
+ .type __do_global_ctors_aux, %function
+__do_global_ctors_aux:
+ GOT_INIT(r3, .Lctors_got, .Lctors)
+ ldr r1, .L__initialized /* GOTOFF if PIC */
+#ifdef PIC
+ ldrb r0, [r1, r3]! /* r1 = r1 + got */
+#else
+ ldrb r0, [r1]
+#endif
+ cmp r0, #0 /* done this already? */
+ RETc(ne)
+ mov r0, #1
+ strb r0, [r1] /* mark it as done */
+
+ mov ip, sp
+ stmfd sp!, {r4, r5, fp, ip, lr, pc}
+ sub fp, ip, #4
+ mov r4, r3 /* now that r4 is saved ... */
+
+ /*
+ * if (__register_frame_info)
+ * __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
+ */
+ GOT_GET(ip, r4, .L__register_frame_info)
+ cmp ip, #0
+ beq 1f
+
+ ldr r0, .L__EH_FRAME_LIST__
+ ldr r1, .L__dwarf_eh_object
+#ifdef PIC
+ add r0, r0, r4
+ add r1, r1, r4
+#endif
+
+#if defined(_ARM_ARCH_4T)
+ blx ip
+#else
+ mov lr, pc
+ mov pc, ip
+#endif
+1:
+ /*
+ * if (_Jv_RegisterClasses && __JCR_LIST__[0])
+ * _Jv_RegisterClasses(&__JCR_LIST__[0]);
+ */
+ GOT_GET(ip, r4, .L_Jv_RegisterClasses)
+ cmp ip, #0
+ ldmeqfd sp, {r4, r5, fp, sp, pc} /* return if null */
+
+ ldr r0, .L__JCR_LIST__
+#ifdef PIC
+ ldr r2, [r0, r4]! /* GOTOFF + got == address */
+#else
+ ldr r2, [r0]
+#endif
+ cmp r2, #0
+ ldmfd sp, {r4, r5, fp, sp, lr} /* restore everything */
+ RETc(eq) /* return if null */
+#if defined(_ARM_ARCH_4T)
+ bx ip /* return or tail call */
+#else
+ mov pc, ip /* return or tail call */
+#endif
+
+ .p2align 2
+ GOT_INITSYM(.Lctors_got, .Lctors)
+.L__register_frame_info:
+ .word PIC_SYM(_C_LABEL(__register_frame_info), GOT)
+.L_Jv_RegisterClasses:
+ .word PIC_SYM(_C_LABEL(_Jv_RegisterClasses), GOT)
+.L__initialized:
+ .word PIC_SYM(_C_LABEL(__initialized), GOTOFF)
+.L__EH_FRAME_LIST__:
+ .word PIC_SYM(_C_LABEL(__EH_FRAME_LIST__), GOTOFF)
+.L__dwarf_eh_object:
+ .word PIC_SYM(_C_LABEL(__dwarf_eh_object), GOTOFF)
+.L__JCR_LIST__:
+ .word PIC_SYM(_C_LABEL(__JCR_LIST__), GOTOFF)
+
+ .local __initialized
+ .comm __initialized,1,1
+ .local __dwarf_eh_object
+ .comm __dwarf_eh_object,24,4
+
+ .section .init_array,"aw",%init_array
+ .p2align 2
+ .word __do_global_ctors_aux
--- /dev/null
+/* $NetBSD: crtend.S,v 1.1 2012/08/13 02:49:04 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 <arm/asm.h>
+
+RCSID("$NetBSD: crtend.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
+
+ .fpu softvfp
+ .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
--- /dev/null
+/* $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 <arm/asm.h>
+
+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
+ */
--- /dev/null
+/* $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 */
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
#include <machine/asm.h>
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
+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
- movl 12(%esp),%eax
- leal 16(%esp),%edx
- leal 20(%esp,%eax,4),%ecx
- pushl %ecx
- pushl %edx
- pushl %eax
+#ifdef __minix
+ movl 12(%esp),%eax
+ leal 16(%esp),%edx
+ leal 20(%esp,%eax,4),%ecx
+ pushl %ecx
+ pushl %edx
+ pushl %eax
+#endif /* __minix */
call ___start
--- /dev/null
+# $NetBSD: Makefile.inc,v 1.1 2011/02/08 02:02:25 matt Exp $
+
+CPPFLAGS+= -DELFSIZE=32
+
+
--- /dev/null
+/*-
+ * 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 <powerpc/asm.h>
+
+RCSID("$NetBSD: crt0.S,v 1.4 2011/07/02 20:16:09 matt Exp $")
+
+STRONG_ALIAS(_start,__start)
+
+ .hidden ___start
+
+ .weak _SDA_BASE_
+
+ENTRY_NOPROFILE(__start)
+ 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
+
+ mr %r3,%r7 /* cleanup */
+ mr %r4,%r6 /* obj */
+ mr %r5,%r8 /* ps_strings */
+
+ b ___start
+END(__start)
--- /dev/null
+/* $NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 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 <powerpc/asm.h>
+
+RCSID("$NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 matt 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 ".got2","aw", @progbits
+.LCTOC = . + 32768
+
+ .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
+
+ .lcomm __dwarf_eh_object,8*SZREG,SZREG
+ .lcomm __initialized,1,1
+ .lcomm __finished,1,1
+
+ .text
+ .weak __cxa_finalize
+ .weak __deregister_frame_info
+ .weak __register_frame_info
+ .weak _Jv_RegisterClasses
+
+/*
+ * 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.
+ */
+
+__do_global_dtors_aux:
+ mflr %r7 /* save return address */
+ bcl 20,31,1f /* find out what address */
+1: mflr %r3 /* we are at */
+ mtlr %r7 /* restore return address */
+
+ addis %r4,%r3,__finished-1b@ha /* PCREL ref (upper) */
+ lbzu %r0,__finished-1b@l(%r4) /* PCREL ref (lower) & load */
+ cmpwi %r0,0 /* done this already? */
+ bnelr /* yep, return */
+
+ li %r0, 1
+ stb %r0, 0(%r4) /* remember we've done this */
+
+ stw %r7,(1*SZREG)(%r1) /* save LR */
+ stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
+ stw %r31,(7*SZREG)(%r1) /* save some registers */
+ stw %r30,(6*SZREG)(%r1)
+ stw %r29,(5*SZREG)(%r1)
+ stw %r28,(4*SZREG)(%r1)
+
+ mr %r29,%r3 /* move this to a safe place */
+
+ /*
+ * Get a reference to our TOC.
+ */
+ addis %r30,%r29,.LCTOC-1b@ha
+ addi %r30,%r30,.LCTOC-1b@l
+
+ /*
+ * Get a reference to the GOT.
+ */
+ addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
+ addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
+
+#ifdef SHARED
+ /*
+ * if (__cxa_finalize)
+ * __cxa_finalize(&__dso_handle);
+ */
+ lwz %r0, __cxa_finalize@got(%r31)
+ cmpwi %r0, 0
+ beq 2f
+
+ addis %r3,%r29,__dso_handle-1b@ha /* get &__dso_handle (pcrel) */
+ addi %r3,%r3,__dso_handle-1b@l
+ mtctr %r0 /* setup for indirect branch */
+ bctrl /* and call the routine */
+2:
+#endif
+
+ addis %r28,%r29,__DTOR_LIST__-1b@ha /* get &__DTOR_LIST__ */
+ addi %r28,%r28,__DTOR_LIST__-1b@l
+ /*
+ * We know the first entry is -1 so skip it. We use load with update
+ * to advance the pointer along.
+ */
+3:
+ lwzu %r0, 4(%r28) /* get entry */
+ cmpwi %r0, 0 /* end of list? */
+ beq 4f /* yep. */
+ mtctr %r0 /* setup for indirect branch */
+ bctrl /* and call the routine */
+ b 3b /* do it again */
+
+4:
+ /*
+ * if (__deregister_frame_info)
+ * __deregister_frame_info(&__EH_FRAME_LIST__[0]);
+ */
+ lwz %r0,__deregister_frame_info@got(%r31)
+ cmpwi %r0, 0 /* routine actually exist? */
+ beq 5f /* nope, skip call */
+
+ addis %r3,%r29,__EH_FRAME_LIST__-1b@ha
+ addi %r3,%r3,__EH_FRAME_LIST__-1b@l
+ mtctr %r0 /* setup for indirect branch */
+ bctrl /* and call the routine */
+5:
+ lwz %r28,(4*SZREG)(%r1) /* restore registers */
+ lwz %r29,(5*SZREG)(%r1)
+ lwz %r30,(6*SZREG)(%r1)
+ lwz %r31,(7*SZREG)(%r1)
+ addi %r1,%r1,8*SZREG /* adjust stack */
+ lwz %r0,(1*SZREG)(%r1) /* get return addr */
+ mtlr %r0
+ blr /* and return */
+
+__do_global_ctors_aux:
+ mflr %r7 /* save return address */
+ bcl 20,31,1f /* find out what address */
+1: mflr %r3 /* we are at */
+ mtlr %r7 /* restore return address */
+
+ addis %r4,%r3,__initialized-1b@ha /* pcrel (hi) */
+ lbzu %r0,__initialized-1b@l(%r4) /* pcrel (lo) load+update */
+ cmpwi %r0,0 /* have we already done this? */
+ bnelr /* yep, return */
+
+ li %r0,1
+ stb %r0,0(%r4) /* remember we've been here */
+
+ stw %r7,(1*SZREG)(%r1) /* save LR */
+ stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
+ stw %r31,(7*SZREG)(%r1) /* save some registers */
+ stw %r30,(6*SZREG)(%r1)
+ stw %r29,(5*SZREG)(%r1)
+ stw %r28,(4*SZREG)(%r1)
+
+ mr %r29,%r3 /* move this to a safe place */
+
+ /*
+ * Get a reference to our TOC.
+ */
+ addis %r30,%r29,.LCTOC-1b@ha
+ addi %r30,%r30,.LCTOC-1b@l
+
+ /*
+ * Get a reference to the GOT.
+ */
+ addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
+ addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
+
+ /*
+ * if (__register_frame_info)
+ * __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
+ */
+ lwz %r0, __register_frame_info@got(%r31)
+ cmpwi %r0, 0
+ beq 2f
+
+ addis %r3,%r29,__EH_FRAME_LIST__-1b@ha /* pcrel (hi) */
+ addi %r3,%r3,__EH_FRAME_LIST__-1b@l /* pcrel (lo) */
+ addis %r4,%r29,__dwarf_eh_object-1b@ha /* pcrel (hi) */
+ addi %r4,%r4,__dwarf_eh_object-1b@l /* pcrel (lo) */
+ mtctr %r0 /* setup for indirect branch */
+ bctrl /* and call the routine */
+
+2:
+ /*
+ * if (_Jv_RegisterClasses && __JCR_LIST__[0])
+ * _Jv_RegisterClasses(&__JCR_LIST__[0]);
+ */
+ lwz %r0, _Jv_RegisterClasses@got(%r31)
+ cmpwi %r0, 0
+ beq 3f
+
+ mtctr %r0 /* setup for indirect branch */
+ addis %r3, %r29, __JCR_LIST__-1b@ha /* pcrel (hi) */
+ addi %r3, %r3, __JCR_LIST__-1b@l /* pcrel (lo) */
+ lwz %r4, 0(%r3) /* load first entry */
+ cmpwi %r4, 0 /* is the list empty? */
+ bnectrl /* call the routine if not */
+3:
+
+ /*
+ * Get end of list of CTOR list.
+ */
+ addis %r28,%r29,__CTOR_LIST_END__-1b@ha
+ addi %r28,%r28,__CTOR_LIST_END__-1b@l
+4:
+ lwzu %r0, -4(%r28) /* get entry */
+ cmpwi %r0, -1 /* first entry? */
+ beq 5f /* yes, we're done */
+ mtctr %r0 /* setup for indirect branch */
+ bctrl /* call the routine */
+ b 4b /* do it again */
+5:
+ lwz %r28,(4*SZREG)(%r1) /* restore registers */
+ lwz %r29,(5*SZREG)(%r1)
+ lwz %r30,(6*SZREG)(%r1)
+ lwz %r31,(7*SZREG)(%r1)
+ addi %r1,%r1,8*SZREG /* adjust stack */
+ lwz %r0,(1*SZREG)(%r1) /* get return addr */
+ mtlr %r0
+ blr /* and return */
+
+ .section .init, "ax", @progbits
+ bl __do_global_ctors_aux
+ .section .fini, "ax", @progbits
+ bl __do_global_dtors_aux
--- /dev/null
+/* $NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 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 <powerpc/asm.h>
+
+RCSID("$NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 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
+ .long 0
+
+ .section .eh_frame, "a", @progbits
+ .p2align 2
+ .long 0
+
+ .section .jcr, "aw", @progbits
+ .p2align 2
+ .long 0
--- /dev/null
+/* $NetBSD: crti.S,v 1.1 2011/02/08 02:02:25 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 <powerpc/asm.h>
+
+RCSID("$NetBSD: crti.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
+
+#include "sysident.S"
+
+ .section ".init", "ax", @progbits
+ .align 2; .globl _init; .type _init,@function
+_init:
+ mflr %r0
+ stw %r0, (1*SZREG)(%r1)
+ stwu %r1, -(4*SZREG)(%r1)
+
+ .section ".fini", "ax", @progbits
+ .align 2; .globl _fini; .type _fini,@function
+_fini:
+ mflr %r0
+ stw %r0, (1*SZREG)(%r1)
+ stwu %r1, -(4*SZREG)(%r1)
--- /dev/null
+/*-
+ * 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 <powerpc/asm.h>
+
+RCSID("$NetBSD: crtn.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
+
+ .section ".init", "ax", @progbits
+ addi %r1, %r1, (4*SZREG)
+ lwz %r0, (1*SZREG)(%r1)
+ mtlr %r0
+ blr
+
+ .section ".fini", "ax", @progbits
+ addi %r1, %r1, (4*SZREG)
+ lwz %r0, (1*SZREG)(%r1)
+ mtlr %r0
+ blr
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.4 2012/01/31 20:17:57 uwe Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
#include <machine/asm.h>
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+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 r9,@-r15
- bra ___start
- mov.l r8,@-r15
+ 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)
--- /dev/null
+/* $NetBSD: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe 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 <machine/asm.h>
+
+RCSID("$NetBSD: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe 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)
--- /dev/null
+/* $NetBSD: crtend.S,v 1.2 2012/01/31 20:12:47 uwe Exp $ */
+/*-
+ * Copyright (c) 2010 Joerg Sonnenberger <joerg@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.
+ *
+ * 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 <machine/asm.h>
+
+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
-/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crti.S,v 1.3 2012/01/31 20:12:47 uwe Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
#include <machine/asm.h>
-RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+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
- .align 4
+ .p2align 2
.globl _init
_init:
mov.l r14, @-sp
mov sp, r14
.section ".fini", "ax", @progbits
- .align 4
+ .p2align 2
.globl _fini
_fini:
mov.l r14, @-sp
-/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crtn.S,v 1.2 2012/01/28 12:45:43 uwe Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
#include <machine/asm.h>
-RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+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
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.2 2011/07/02 20:14:10 matt Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
#include <machine/asm.h>
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+RCSID("$NetBSD: crt0.S,v 1.2 2011/07/02 20:14:10 matt Exp $")
STRONG_ALIAS(_start,__start)
pushl %r9 /* ps_strings */
pushl %r8 /* obj */
pushl %r7 /* cleanup */
- movl (%r6),%r0 /* argc */
- pushal 8(%r6)[%r0] /* envp = &argv[argc + 1] */
- pushal 4(%r6) /* argv */
- pushl %r0 /* argc */
- calls $6,___start
+ calls $3,___start
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
#include <machine/asm.h>
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+RCSID("$NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $")
STRONG_ALIAS(_start,__start)
+ .hidden ___start
_ENTRY(__start)
- movq %rbx,%r9
- movq %rcx,%r8
- movq %rdx,%rcx
- movq (%rsp),%rdi
- leaq 16(%rsp,%rdi,8),%rdx
- leaq 8(%rsp),%rsi
- subq $8,%rsp
- andq $~15,%rsp
- addq $8,%rsp
+ andq $~15,%rsp
+ subq $8,%rsp
+ movq %rdx, %rdi
+ movq %rcx, %rsi
+ movq %rbx, %rdx
jmp ___start
-/* $NetBSD: crt0.c,v 1.7 2008/06/21 00:52:52 gmcgarry Exp $ */
+/* $NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
" add r2, r2, #0x0004 \n"
"\n"
" /* Ensure the stack is properly aligned before calling C code. */\n"
-" bic sp, sp, #" ___STRING(STACKALIGNBYTES) " \n"
+" bic sp, sp, #" ___STRING(STACK_ALIGNBYTES) "\n"
" sub sp, sp, #8 \n"
" str r5, [sp, #4] \n"
" str r4, [sp, #0] \n"
" b " ___STRING(_C_LABEL(___start)) " ");
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.7 2008/06/21 00:52:52 gmcgarry Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $");
#endif /* LIBC_SCCS and not lint */
void
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
- if (&_DYNAMIC)
+ if (&rtld_DYNAMIC)
_rtld_setup(cleanup, obj);
#endif /* DYNAMIC */
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
-/* $NetBSD: dot_init.h,v 1.6 2008/05/10 15:31:03 martin Exp $ */
+/* $NetBSD: dot_init.h,v 1.9 2012/08/05 01:44:43 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
CLEANFILES+=${OBJS}
SYMLINKS+= crtbegin.o ${LIBDIR}/crtbeginT.o
SYMLINKS+= crtend.o ${LIBDIR}/crtendS.o
-SYMLINKS+= crt0.o ${LIBDIR}/crt1.o
.include <bsd.prog.mk>
-/* $NetBSD: crt0-common.c,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.1 2010/08/07 18:01:33 joerg Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $");
#include <sys/types.h>
+#include <sys/exec.h>
#ifndef __minix
#include <sys/syscall.h>
#endif
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
* shared libs present, things will still work.
*/
-#if __GNUC_PREREQ__(4,2)
-static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
-#define DYNAMIC_SYM rtld_DYNAMIC
-#else
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
-#define DYNAMIC_SYM _DYNAMIC
-#endif
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#ifdef MCRT0
extern void monstartup(u_long, u_long);
static char empty_string[] = "";
char *__progname = empty_string;
-void ___start(int, char **, char **, void (*)(void),
- const Obj_Entry *, struct ps_strings *);
-
#ifndef __minix
+__dead __dso_hidden void ___start(void (*)(void), const Obj_Entry *,
+ struct ps_strings *);
+
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
#else
+__dead __dso_hidden void ___start(int, char **, char **, void (*)(void),
+ const Obj_Entry *, struct ps_strings *);
+
#define write(fd, s, n) /* NO write() from here on minix */
#endif
_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.
+ */
+static const fptr_t init_array_start[] __weak_reference(__init_array_start);
+static const fptr_t init_array_end[] __weak_reference(__init_array_end);
+static const fptr_t fini_array_start[] __weak_reference(__fini_array_start);
+static const fptr_t fini_array_end[] __weak_reference(__fini_array_end);
+
+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
+#ifdef __minix
___start(int argc, char **argv, char **envp,
- void (*cleanup)(void), /* from shared loader */
+ void (*cleanup)(void), /* from shared loader */
+#else
+___start(void (*cleanup)(void), /* from shared loader */
+#endif /* __minix */
const Obj_Entry *obj, /* from shared loader */
struct ps_strings *ps_strings)
{
- environ = envp;
+#ifdef __minix
+ /* LSC: We have not yet updated the way we pass arguments to
+ the userspace, so here some code to adapt this to the new
+ ways. */
+ struct ps_strings minix_ps_strings;
+
+ if (ps_strings == NULL) {
+ minix_ps_strings.ps_envstr = envp;
+ minix_ps_strings.ps_argvstr = argv;
+ minix_ps_strings.ps_nargvstr = argc;
+ ps_strings = &minix_ps_strings;
+ }
+#endif /* __minix */
+ if (ps_strings == NULL)
+ _FATAL("ps_strings missing\n");
+ __ps_strings = ps_strings;
+
+ environ = ps_strings->ps_envstr;
- if (argv[0] != NULL) {
+ if (ps_strings->ps_argvstr[0] != NULL) {
char *c;
- __progname = argv[0];
- for (c = argv[0]; *c; ++c) {
+ __progname = ps_strings->ps_argvstr[0];
+ for (c = ps_strings->ps_argvstr[0]; *c; ++c) {
if (*c == '/')
__progname = c + 1;
}
__progname = empty_string;
}
- if (ps_strings != NULL)
- __ps_strings = ps_strings;
-
- if (&DYNAMIC_SYM != NULL) {
- if ((obj == NULL) || (obj->magic != RTLD_MAGIC))
+ 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 MCRT0
atexit(_mcleanup);
monstartup((u_long)&__eprol, (u_long)&__etext);
atexit(_fini);
_init();
- exit(main(argc, argv, environ));
+ exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));
}
.include "../../Makefile.inc"
-.if defined(__MINIX) && ${MACHINE_ARCH} == "arm"
-CPPFLAGS+= -DLIBC_SCCS -DPIC -DELFSIZE=${ELFSIZE}
-.else
CPPFLAGS+= -DLIBC_SCCS -DPIC -DDYNAMIC -DELFSIZE=${ELFSIZE}
-.endif
CPPFLAGS+= -I${NETBSDSRCDIR}/libexec/ld.elf_so
CPPFLAGS+= -I${.CURDIR}/../common_elf
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/dlfcn
-/* $NetBSD: common.h,v 1.13 2009/12/14 01:04:02 matt Exp $ */
+/* $NetBSD: common.h,v 1.16 2012/03/21 10:09:20 matt Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
static char *_strrchr(char *, int);
char **environ;
-char *__progname = "";
+char *__progname = __UNCONST("");
struct ps_strings *__ps_strings = 0;
extern void _init(void);
extern void _fini(void);
+extern void _libc_init(void);
#ifdef DYNAMIC
void _rtld_setup(void (*)(void), const Obj_Entry *obj);
* if we happen to be compiling without -static but with without any
* shared libs present, things will still work.
*/
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
-/* $NetBSD: crt0.c,v 1.7 2004/08/26 21:07:14 thorpej Exp $ */
+/* $NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 2002 Matt Fredette
__ps_strings = ps_strings;
#ifdef DYNAMIC
- /*
- * XXX fredette - when not compiling PIC, you currently
- * can't detect an undefined weak symbol by seeing if
- * its address is NULL. The compiler emits code to find
- * _DYNAMIC relative to %dp, the assembler notes the
- * needed relocations, but when the linker sees that the
- * (weak) symbol isn't defined it drops the ball - the
- * relocations are never filled, and the binary ends up
- * with code that sees an address of %dp plus zero,
- * which != NULL.
- *
- * Arguably the linker could/should distinguish between
- * code that is after a weak undefined symbol's contents
- * from code that is after its address. In the first case,
- * it would warn and/or bail. In the second case, it
- * would fix up instructions to give a symbol address
- * of NULL.
- *
- * For now, we take the easy way out and compare &_DYNAMIC
- * to %dp, as well as to NULL.
- */
- if (&_DYNAMIC != NULL && (int)&_DYNAMIC != dp)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.7 2004/08/26 21:07:14 thorpej Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.2 2006/09/15 05:29:44 skrll Exp $ */
+/* $NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.2 2006/09/15 05:29:44 skrll Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.11 2004/08/26 21:09:52 thorpej Exp $ */
+/* $NetBSD: crt0.c,v 1.13 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1999 Klaus Klein
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.11 2004/08/26 21:09:52 thorpej Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.13 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.20 2009/12/14 01:04:02 matt Exp $ */
+/* $NetBSD: crt0.c,v 1.22 2011/02/22 05:45:07 joerg Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
* as well as the usual registers (pc, sp, and t9 == pc for ABI).
*/
-void __start(u_long, void (*)(void), const Obj_Entry *,
+void __start(uintptr_t, void (*)(void), const Obj_Entry *,
struct ps_strings *);
__asm(".text; .align 4; .globl _start; _start:");
void
-__start(u_long sp,
+__start(uintptr_t sp,
void (*cleanup)(void), /* from shared loader */
const Obj_Entry *obj, /* from shared loader */
struct ps_strings *ps_strings)
#endif
- argc = *(int *)ksp;
+ argc = *(long *)ksp;
argv = ksp + 1;
environ = ksp + 2 + argc; /* 2: argc + NULL ending argv */
* XXX If we were loaded by that loader, just abort
* XXX the rtld setup.
*/
- if (&_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
+ if (&rtld_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
_rtld_setup(cleanup, obj);
#endif
}
#ifdef MCRT0
atexit(_mcleanup);
- monstartup((u_long)&_eprol, (u_long)&_etext);
+ monstartup((uintptr_t)&_eprol, (uintptr_t)&_etext);
#endif
atexit(_fini);
* is the entrypoint. (Only needed for old toolchains).
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.20 2009/12/14 01:04:02 matt Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.22 2011/02/22 05:45:07 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.26 2006/05/18 17:54:19 christos Exp $ */
+/* $NetBSD: crt0.c,v 1.30 2011/03/12 07:56:36 matt Exp $ */
/*
* Copyright (c) 1997 Jason R. Thorpe.
* Small Data Area designators. If not defined, will show up as being
* at address zero.
*/
-extern int _SDA_BASE_[] __weak_reference(_SDA_BASE_);
-extern int _SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
+__weakref_visible int rtld_SDA_BASE_[] __weak_reference(_SDA_BASE_);
+__weakref_visible int rtld_SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
/*
* First 5 arguments are specified by the PowerPC SVR4 ABI. The
/*
* Initialize the Small Data Area registers.
* _SDA_BASE is defined in the SVR4 ABI for PPC.
- * _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
+ *
+ * Do the initialization in a PIC manner.
*/
- __asm( "lis %r13,_SDA_BASE_@ha;"
- "addi %r13,%r13,_SDA_BASE_@l;"
- "lis %r2,_SDA2_BASE_@ha;"
- "addi %r2,%r2,_SDA2_BASE_@l" );
+ __asm(
+ "bcl 20,31,1f;"
+ "1: mflr 11;"
+ "addis 13,11,rtld_SDA_BASE_-1b@ha;"
+ "addi 13,13,rtld_SDA_BASE_-1b@l;"
+ ::: "lr" );
if ((namep = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
if ((__progname = _strrchr(namep, '/')) == NULL)
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.26 2006/05/18 17:54:19 christos Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.30 2011/03/12 07:56:36 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: dot_init.h,v 1.7 2008/05/10 15:31:04 martin Exp $ */
+/* $NetBSD: dot_init.h,v 1.8 2011/07/02 07:28:08 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
".section "#sect",\"ax\",@progbits \n" \
".global "#entry_pt" \n" \
#entry_pt": \n" \
- " stwu %r1,-16(%r1) \n" \
" mflr %r0 \n" \
- " stw %r0,12(%r1) \n" \
+ " stw %r0,4(%r1) \n" \
+ " stwu %r1,-16(%r1) \n" \
" /* fall thru */ \n" \
".previous")
#define MD_SECTION_EPILOGUE(sect) \
__asm ( \
".section "#sect",\"ax\",@progbits \n" \
- " lwz %r0,12(%r1) \n" \
+ " addi %r1,%r1,16 \n" \
+ " lwz %r0,4(%r1) \n" \
" mtlr %r0 \n" \
- " la %r1,16(%r1) \n" \
" blr \n" \
".previous")
-# $NetBSD: Makefile,v 1.1 2006/06/30 22:49:50 ross Exp $
+# $NetBSD: Makefile,v 1.2 2011/10/29 10:28:37 mrg Exp $
-CPPFLAGS+= -I- -I${.CURDIR}
+CPPFLAGS+= -I${.CURDIR}
.include "${.CURDIR}/../common_elf/Makefile.inc"
-/* $NetBSD: crt0.c,v 1.2 2006/07/01 01:39:17 ross Exp $ */
+/* $NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1997 Jason R. Thorpe.
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.2 2006/07/01 01:39:17 ross Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.10 2004/08/26 21:16:41 thorpej Exp $ */
+/* $NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.10 2004/08/26 21:16:41 thorpej Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-# $NetBSD: Makefile,v 1.6 2006/05/19 19:11:12 christos Exp $
+# $NetBSD: Makefile,v 1.9 2012/08/10 16:37:31 martin Exp $
-#Uncomment the next line to enable the new .init fallthru
CPPFLAGS+= -I${.CURDIR}/../sparc_elf
+CFLAGS+= -fPIC
ELFSIZE=64
-/* $NetBSD: crt0.c,v 1.24 2005/12/24 21:38:40 perry Exp $ */
+/* $NetBSD: crt0.c,v 1.27 2012/08/10 16:37:31 martin Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
*/
__asm("\n\
- .data\n\
-__data_start: ! Start of data section\n\
.text\n\
.align 4\n\
.global _start\n\
.register %g2,#scratch\n\
_start:\n\
__start:\n\
- setx __data_start, %o0, %g4 ! Point %g4 to start of data section\n\
- clr %g4 ! egcs thinks this is zero. XXX\n\
+ clr %g4 ! XXX depends on memory model used \n\
clr %fp\n\
add %sp, 8*16 + 0x7ff, %o0 ! start of stack\n\
- mov %g1, %o1 ! Cleanup routine\n\
mov %g3, %o1 ! XXXX our rtld uses %g3\n\
mov %g2, %o2 ! XXXX obj from rtld.\n\
ba,pt %icc, ___start ! XXXX jump over the retl egcs 2.96 inserts\n\
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ _start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.24 2005/12/24 21:38:40 perry Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.27 2012/08/10 16:37:31 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-# $NetBSD: Makefile,v 1.6 2006/05/19 19:11:12 christos Exp $
+# $NetBSD: Makefile,v 1.7 2012/08/10 12:37:39 martin Exp $
-#Uncomment the next line to enable the new .init fallthru
CPPFLAGS+= -I${.CURDIR}
+CFLAGS+= -fPIC
.include "${.CURDIR}/../common_elf/Makefile.inc"
-/* $NetBSD: crt0.c,v 1.12 2004/08/26 21:18:36 thorpej Exp $ */
+/* $NetBSD: crt0.c,v 1.15 2012/08/10 12:37:39 martin Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
sub %sp, 24, %sp ! expand to standard stack frame size\n\
mov %g3, %o3\n\
mov %g2, %o4\n\
- call ___start\n\
+ ba ___start\n\
mov %g1, %o5\n\
");
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.12 2004/08/26 21:18:36 thorpej Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.15 2012/08/10 12:37:39 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: crt0.c,v 1.10 2004/08/26 21:24:09 thorpej Exp $ */
+/* $NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
+ _libc_init();
+
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.10 2004/08/26 21:24:09 thorpej Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"
-/* $NetBSD: dot_init.h,v 1.7 2008/05/10 15:31:04 martin Exp $ */
+/* $NetBSD: dot_init.h,v 1.8 2011/07/30 15:28:58 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-#include <machine/asm.h>
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
__asm ( \
SUBDIR=compat
.include <bsd.subdir.mk>
.else
-.if !defined(__MINIX)
COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/compat/Makefile.inc"
-.else
+.if defined(__MINIX)
SUBDIR+= pkgconfig
.include <bsd.subdir.mk>
-.endif
+.endif # defined(__MINIX)
.endif
.include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
-# $NetBSD: Makefile.inc,v 1.9 2010/07/06 05:59:52 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.16 2012/09/27 11:20:20 skrll Exp $
.include <bsd.own.mk>
.if !defined(__MINIX)
-SRCS+= __sigaction14_sigtramp.c __sigtramp2.S
+SRCS+= __aeabi_read_tp.S __sigaction14_sigtramp.c __sigtramp2.S
.endif
+CPPFLAGS += -I.
CPPFLAGS += -DSOFTFLOAT
+.if ${MACHINE_ARCH} == "earm" || ${MACHINE_ARCH} == "earmeb"
+SRCS+= __aeabi_ldivmod.S __aeabi_uldivmod.S
+SRCS+= __aeabi_lcmp.c __aeabi_ulcmp.c
+SRCS+= fixunsgen_ieee754.c fixunssfsi_ieee754.c
+SRCS+= fixunsgen64_ieee754.c fixunsdfsi_ieee754.c
+.endif
+
+# for earm, use the 64-bit softfloat
+.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "armeb"
SOFTFLOAT_BITS=32
+.endif
+
.include <softfloat/Makefile.inc>
-# $NetBSD: Makefile.inc,v 1.16 2009/12/06 07:12:17 uebayasi Exp $
+# $NetBSD: Makefile.inc,v 1.19 2012/10/10 02:15:03 christos Exp $
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S bswap64.c divsi3.S \
- fabs.c flt_rounds.c
+ fabs.c flt_rounds.c modsi3.S umodsi3.S
# Common ieee754 constants and functions
SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c
-/* $NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $ */
+/* $NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
- void **sp;
+ uintptr_t 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);
-
+ 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) arg;
- u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~7;
- u->uc_mcontext.__gregs[_REG_LR] = (__greg_t) _lwp_exit;
- u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
+ 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;
}
-/* $NetBSD: _setjmp.S,v 1.6 2004/08/21 11:20:10 rearnsha Exp $ */
+/* $NetBSD: _setjmp.S,v 1.7 2012/08/01 06:02:13 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
str r1, [r0], #4
#ifdef SOFTFLOAT
add r0, r0, #52
+#elif defined(__VFP_FP__)
+#error _setjmp VFP support missing
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
#ifdef SOFTFLOAT
add r0, r0, #52
+#elif defined(__VFP_FP__)
+#error _longjmp VFP support missing
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48
-/* $NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $ */
+/* $NetBSD: flt_rounds.c,v 1.4 2012/03/21 20:04:57 he Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $");
+__RCSID("$NetBSD: flt_rounds.c,v 1.4 2012/03/21 20:04:57 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
int __flt_rounds(void);
int
-__flt_rounds()
+__flt_rounds(void)
{
return(map[fpgetround()]);
}
-/* $NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:55 martin Exp $ */
+/* $NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:55 martin Exp $");
+__RCSID("$NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $");
#endif
#include <stddef.h>
/* Allocate necessary stack space for arguments exceeding r0-3. */
if (argc > 4)
sp -= argc - 4;
- gr[_REG_SP] = (__greg_t)sp;
+ 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)_resumecontext;
- gr[_REG_PC] = (__greg_t)func;
+ 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. */
-/* $NetBSD: resumecontext.c,v 1.4 2008/04/28 20:22:55 martin Exp $ */
+/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: resumecontext.c,v 1.4 2008/04/28 20:22:55 martin Exp $");
+__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $");
#endif
#include "namespace.h"
#include "extern.h"
void
-_resumecontext()
+_resumecontext(void)
{
ucontext_t uct;
-/* $NetBSD: setjmp.S,v 1.8 2005/10/16 17:26:24 christos Exp $ */
+/* $NetBSD: setjmp.S,v 1.9 2012/08/01 06:02:13 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
#ifdef SOFTFLOAT
add r0, r0, #52
+#elif defined(__VFP_FP__)
+#error __setjmp14 VFP support missing
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
add r0, r0, #4
#ifdef SOFTFLOAT
add r0, r0, #52
+#elif defined(__VFP_FP__)
+#error __longjmp14 VFP support missing
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48
-/* $NetBSD: swapcontext.S,v 1.5 2008/04/28 20:22:55 martin Exp $ */
+/* $NetBSD: swapcontext.S,v 1.8 2012/09/27 11:20:20 skrll Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
*/
#include "SYS.h"
+#include "assym.h"
#if defined(LIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: swapcontext.S,v 1.5 2008/04/28 20:22:55 martin Exp $")
+ RCSID("$NetBSD: swapcontext.S,v 1.8 2012/09/27 11:20:20 skrll Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
stmfd sp!, {r0-r1, lr} /* Must save oucp, ucp, lr. */
+ sub sp, #4
bl PIC_SYM(_C_LABEL(_getcontext), PLT) /* getcontext(oucp) */
cmp r0, #0
+ add sp, #4
ldmfd sp!, {r0-r1, lr}
RETc(ne)
- str lr, [r0, #(36 + 15*4)] /* Adjust saved PC. */
+ str sp, [r0, #_UC_REGS_SP] /* Adjust saved SP. */
+ str lr, [r0, #_UC_REGS_PC] /* Adjust saved PC. */
#ifdef SOFTFLOAT
/* Ahem. */
#endif
--- /dev/null
+# $NetBSD: genassym.cf,v 1.1 2012/09/27 11:20:20 skrll Exp $
+
+#
+# Copyright (c) 2012 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/types.h>
+include <ucontext.h>
+
+define _UC_REGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP])
+define _UC_REGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC])
-/* $NetBSD: fpgetmask.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
+/* $NetBSD: fpgetmask.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#else
ENTRY(fpgetmask)
#endif
+#ifdef __VFP_FP__
+#error _fpgetmask VFP support missing
+#else
rfs r0
mov r0, r0, lsr #16
and r0, r0, #0x1f
RET
+#endif
-/* $NetBSD: fpgetround.c,v 1.4 2006/02/25 02:28:55 wiz Exp $ */
+/* $NetBSD: fpgetround.c,v 1.5 2012/06/24 15:26:02 christos Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fpgetround.c,v 1.4 2006/02/25 02:28:55 wiz Exp $");
+__RCSID("$NetBSD: fpgetround.c,v 1.5 2012/06/24 15:26:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
*/
fp_rnd
-fpgetround()
+fpgetround(void)
{
return(FP_RN);
-/* $NetBSD: fpgetsticky.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
+/* $NetBSD: fpgetsticky.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#else
ENTRY(fpgetsticky)
#endif
+#ifdef __VFP_FP__
+#error _fpgetsticky VFP support missing
+#else
rfs r0
and r0, r0, #0x1f
RET
+#endif
-/* $NetBSD: fpsetmask.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
+/* $NetBSD: fpsetmask.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#else
ENTRY(fpsetmask)
#endif
+#ifdef __VFP_FP__
+#error _fpsetmask VFP support missing
+#else
rfs r1
bic r1, r1, #0x001f0000
and r0, r0, #0x0000001f
wfs r0
mov r0, r1, lsr #16 /* Return old mask */
RET
+#endif
-/* $NetBSD: fpsetsticky.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
+/* $NetBSD: fpsetsticky.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
#else
ENTRY(fpsetsticky)
#endif
+#ifdef __VFP_FP__
+#error _fpsetsticky VFP support missing
+#else
rfs r1
bic r1, r1, #0x1f
and r0, r0, #0x1f
wfs r0
mov r0, r1 /* Return old mask */
RET
+#endif
-/* $NetBSD: softfloat.h,v 1.7 2006/05/16 20:55:51 mrg Exp $ */
+/* $NetBSD: softfloat.h,v 1.9 2011/07/07 07:14:57 matt Exp $ */
/* This is a derivative work. */
-------------------------------------------------------------------------------
*/
extern fp_rnd float_rounding_mode;
-enum {
- float_round_nearest_even = FP_RN,
- float_round_to_zero = FP_RZ,
- float_round_down = FP_RM,
- float_round_up = FP_RP
-};
+#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 integer-to-floating-point conversion routines.
-------------------------------------------------------------------------------
*/
-float32 int32_to_float32( int );
-float64 int32_to_float64( int );
+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( int );
+floatx80 int32_to_floatx80( int32 );
+floatx80 uint32_to_floatx80( uint32 );
#endif
#ifdef FLOAT128
-float128 int32_to_float128( int );
+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 );
HERE=${.CURDIR}/arch/${MACHINE_ARCH}/sys-minix
.PATH: ${HERE}
+ARCHINCLS=${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include/
TMP=ucontextoffsets.h.tmp
-INCLS=../../include
-ARCHINCLS=$(INCLS)/arch/arm/include/
CF=ucontextoffsets.cf
INCS+=ucontextoffsets.h
brksize.S \
ucontext.S
-ucontextoffsets.h: $(CF) $(ARCHINCLS)/stackframe.h $(INCLS)/sys/ucontext.h
+ucontextoffsets.h: ${CF} ${ARCHINCLS}/stackframe.h ${NETBSDSRCDIR}/sys/sys/ucontext.h
${_MKTARGET_CREATE}
cat ${HERE}/$(CF) | \
${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$TMP && \
mv -f $TMP $@
+
--- /dev/null
+#include "SYS.h"
+
+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 */
+ push {r1} /* syscall zeroes r1 */
+ SYSTRAP(_lwp_getprivate) /* can't fail */
+ pop {r1} /* restore r1 */
+#endif
+ RET
+_END(__aeabi_read_tp)
-/* $NetBSD: brk.S,v 1.8 2004/08/21 11:30:17 rearnsha Exp $ */
+/* $NetBSD: brk.S,v 1.9 2011/05/13 23:14:36 nonaka Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include "SYS.h"
- .globl _C_LABEL(end)
+ .globl _C_LABEL(_end)
.globl CURBRK
#ifdef WEAK_ALIAS
.globl _C_LABEL(__minbrk)
.type _C_LABEL(__minbrk),#object
_C_LABEL(__minbrk):
- .word _C_LABEL(end)
+ .word _C_LABEL(_end)
/*
* Change the data segment size
-/* $NetBSD: cerror.S,v 1.7 2011/01/14 06:12:17 matt Exp $ */
+/* $NetBSD: cerror.S,v 1.8 2012/02/27 12:26:21 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include "SYS.h"
#ifdef PIC
- .hidden CERROR
+ .protected CERROR
#endif
ASENTRY(CERROR)
-/* $NetBSD: sbrk.S,v 1.8 2004/08/21 11:30:17 rearnsha Exp $ */
+/* $NetBSD: sbrk.S,v 1.9 2011/05/13 23:14:36 nonaka Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include "SYS.h"
- .globl _C_LABEL(end)
+ .globl _C_LABEL(_end)
#ifdef WEAK_ALIAS
WEAK_ALIAS(sbrk, _sbrk)
.globl CURBRK
.type CURBRK,#object
CURBRK:
- .word _C_LABEL(end)
+ .word _C_LABEL(_end)
/*
* Change the data segment size
-/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
+/* $NetBSD: gd_qnan.h,v 1.2 2011/06/05 14:43:12 christos Exp $ */
#define f_QNAN 0x7fc00000
#define d_QNAN0 0x0
#define ldus_QNAN0 0x0
#define ldus_QNAN1 0x0
#define ldus_QNAN2 0x0
-#define ldus_QNAN3 0x4000
+#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0x7fff
/* 2 bytes of tail padding follow, per i386 ABI */
-# $NetBSD: Makefile.inc,v 1.26 2009/12/06 07:12:17 uebayasi Exp $
+# $NetBSD: Makefile.inc,v 1.27 2011/03/26 19:51:41 christos 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
+ fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
+ fpsetprec.S
SRCS+= setjmp.S _setjmp.S sigsetjmp.S
-/* $NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $ */
+/* $NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
/* LINTED uintptr_t is safe */
u->uc_mcontext.__gregs[_REG_EIP] = (uintptr_t)start;
- /* Align to a word */
+ /* Align to a 16-byte boundary for SSE */
/* LINTED uintptr_t is safe */
- sp = (void **) ((uintptr_t)(stack_base + stack_size) & ~0x3);
+ 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;
- /* LINTED private is currently unused */
+ u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+ u->uc_flags |= _UC_TLSBASE;
}
-/* $NetBSD: fixunsdfsi.S,v 1.11 2003/08/07 16:42:07 agc Exp $ */
+/* $NetBSD: fixunsdfsi.S,v 1.12 2011/05/22 20:11:47 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(LIBC_SCCS)
- RCSID("$NetBSD: fixunsdfsi.S,v 1.11 2003/08/07 16:42:07 agc Exp $")
+ RCSID("$NetBSD: fixunsdfsi.S,v 1.12 2011/05/22 20:11:47 joerg Exp $")
#endif
ENTRY(__fixunsdfsi)
orl $0x80000000,%eax /* restore bias */
ret
-fbiggestsigned: .double 0r2147483648.0
+fbiggestsigned: .double 2147483648.0
-/* $NetBSD: flt_rounds.S,v 1.6 1999/08/23 08:45:09 kleink Exp $ */
-
-/*
- * Written by J.T. Conklin, Apr 4, 1995
- * Public domain.
- */
+/* $NetBSD: flt_rounds.S,v 1.9 2011/09/30 23:42:00 christos Exp $ */
#include <machine/asm.h>
+/*
+ * 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
-_map:
- .byte 1 /* round to nearest */
- .byte 3 /* round to negative infinity */
- .byte 2 /* round to positive infinity */
- .byte 0 /* round to zero */
-
ENTRY(__flt_rounds)
- subl $4,%esp
- fnstcw (%esp)
- movl (%esp),%eax
- shrl $10,%eax
- andl $3,%eax
-#ifdef PIC
- PIC_PROLOGUE
- leal PIC_GOTOFF(_map),%ecx
- PIC_EPILOGUE
- movb (%ecx,%eax,1),%al
-#else
- movb _map(,%eax,1),%al
-#endif
- addl $4,%esp
+ 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
--- /dev/null
+/* $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $ */
+
+/*
+ * Written by J.T. Conklin, Apr 4, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#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
-/* $NetBSD: fpgetround.S,v 1.5 2002/01/13 21:45:43 thorpej Exp $ */
+/* $NetBSD: fpgetround.S,v 1.6 2011/09/30 23:42:00 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
#include <machine/asm.h>
+/*
+ * XXX load only x87 state.
+ */
+
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpgetround, _fpgetround)
ENTRY(_fpgetround)
#else
ENTRY(fpgetround)
#endif
- subl $4,%esp
- fnstcw (%esp)
- movl (%esp),%eax
- rorl $10,%eax
- andl $3,%eax
- addl $4,%esp
+ fnstcw -4(%esp)
+ movl -4(%esp), %eax
+ andl $0x00000c00, %eax
ret
--- /dev/null
+/* $NetBSD: fpsetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $ */
+
+/*
+ * Written by Charles M. Hannum, Apr 9, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#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
-/* $NetBSD: fpsetround.S,v 1.3 2002/01/13 21:45:43 thorpej Exp $ */
+/* $NetBSD: fpsetround.S,v 1.5 2011/09/30 23:45:41 christos Exp $ */
/*
- * Written by Charles M. Hannum, Apr 9, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
* Public domain.
*/
#include <machine/asm.h>
+/*
+ * 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
- subl $4,%esp
-
- fnstcw (%esp)
- movl (%esp),%eax
-
- rorl $10,%eax
- movl %eax,%edx
- andl $3,%eax
- subl %eax,%edx
- movl 8(%esp),%ecx
- andl $3,%ecx
- orl %ecx,%edx
- roll $10,%edx
- movl %edx,(%esp)
- fldcw (%esp)
+ 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)
- addl $4,%esp
ret
-/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $ */
+/* $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.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $");
+__RCSID("$NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:30 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include <math.h>
-/* $NetBSD: isnanl.c,v 1.6 2007/02/02 23:14:09 christos Exp $ */
+/* $NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: isnanl.c,v 1.6 2007/02/02 23:14:09 christos Exp $");
+__RCSID("$NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* $NetBSD: div.S,v 1.8 2003/07/26 19:24:33 salo Exp $ */
+/* $NetBSD: div.S,v 1.9 2011/06/12 20:29:25 plunky Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
#include <machine/asm.h>
#if defined(LIBC_SCCS)
-RCSID("$NetBSD: div.S,v 1.8 2003/07/26 19:24:33 salo Exp $")
+RCSID("$NetBSD: div.S,v 1.9 2011/06/12 20:29:25 plunky Exp $")
#endif
ENTRY(div)
idiv %ecx
movl %eax,(%ebx)
movl %edx,4(%ebx)
+ movl %ebx,%eax
popl %ebx
ret $4
-/* $NetBSD: ldiv.S,v 1.8 2003/07/26 19:24:33 salo Exp $ */
+/* $NetBSD: ldiv.S,v 1.9 2011/06/12 20:29:25 plunky Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
#include <machine/asm.h>
#if defined(LIBC_SCCS)
-RCSID("$NetBSD: ldiv.S,v 1.8 2003/07/26 19:24:33 salo Exp $")
+RCSID("$NetBSD: ldiv.S,v 1.9 2011/06/12 20:29:25 plunky Exp $")
#endif
ENTRY(ldiv)
idiv %ecx
movl %eax,(%ebx)
movl %edx,4(%ebx)
+ movl %ebx,%eax
popl %ebx
ret $4
-/* $NetBSD: __clone.S,v 1.3 2001/07/18 12:24:53 fvdl Exp $ */
+/* $NetBSD: __clone.S,v 1.4 2011/11/18 20:21:41 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
addl $12,%esp
5:
popl %ebp
-#ifdef PIC
- PIC_PROLOGUE
- movl PIC_GOT(CERROR),%edx
- PIC_EPILOGUE
- jmp *%edx
-#else
jmp CERROR
-#endif
-/* $NetBSD: __syscall.S,v 1.3 2003/08/07 16:42:08 agc Exp $ */
+/* $NetBSD: __syscall.S,v 1.4 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: __syscall.S,v 1.3 2003/08/07 16:42:08 agc Exp $")
+ RCSID("$NetBSD: __syscall.S,v 1.4 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jc err
ret
err:
-#ifdef PIC
- PIC_PROLOGUE
- mov PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
jmp CERROR
-#endif
-/* $NetBSD: __vfork14.S,v 1.8 2007/03/09 14:30:48 ad Exp $ */
+/* $NetBSD: __vfork14.S,v 1.9 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: __vfork14.S,v 1.8 2007/03/09 14:30:48 ad Exp $")
+ RCSID("$NetBSD: __vfork14.S,v 1.9 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jmp *%ecx
err:
pushl %ecx
-#ifdef PIC
- PIC_PROLOGUE
- mov PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
jmp CERROR
-#endif
-/* $NetBSD: brk.S,v 1.21 2007/03/09 14:30:56 ad Exp $ */
+/* $NetBSD: brk.S,v 1.22 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: brk.S,v 1.21 2007/03/09 14:30:56 ad Exp $")
+ RCSID("$NetBSD: brk.S,v 1.22 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
xorl %eax,%eax
ret
err:
- PIC_PROLOGUE
- mov PIC_GOT(CERROR),%edx
- PIC_EPILOGUE
- jmp *%edx
+ jmp CERROR
#else
movl 4(%esp),%ecx
cmpl %ecx,_C_LABEL(__minbrk)
-/* $NetBSD: cerror.S,v 1.14 2003/08/07 16:42:08 agc Exp $ */
+/* $NetBSD: cerror.S,v 1.16 2012/02/27 12:26:21 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: cerror.S,v 1.14 2003/08/07 16:42:08 agc Exp $")
+ RCSID("$NetBSD: cerror.S,v 1.16 2012/02/27 12:26:21 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
.globl _C_LABEL(__errno)
+ .protected CERROR
_ENTRY(CERROR)
pushl %eax
-/* $NetBSD: exect.S,v 1.13 2003/08/07 16:42:08 agc Exp $ */
+/* $NetBSD: exect.S,v 1.14 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: exect.S,v 1.13 2003/08/07 16:42:08 agc Exp $")
+ RCSID("$NetBSD: exect.S,v 1.14 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
orb $(PSL_T>>8),1(%esp)
popfl
SYSTRAP(execve)
-#ifdef PIC
- PIC_PROLOGUE
- mov PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
jmp CERROR
-#endif
-/* $NetBSD: ptrace.S,v 1.16 2003/08/07 16:42:09 agc Exp $ */
+/* $NetBSD: ptrace.S,v 1.17 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: ptrace.S,v 1.16 2003/08/07 16:42:09 agc Exp $")
+ RCSID("$NetBSD: ptrace.S,v 1.17 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jc err
ret
err:
-#ifdef PIC
- PIC_PROLOGUE
- mov PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
jmp CERROR
-#endif
-/* $NetBSD: sbrk.S,v 1.19 2008/07/02 20:07:43 rmind Exp $ */
+/* $NetBSD: sbrk.S,v 1.20 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: sbrk.S,v 1.19 2008/07/02 20:07:43 rmind Exp $")
+ RCSID("$NetBSD: sbrk.S,v 1.20 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
out:
ret
err:
- PIC_PROLOGUE
- mov PIC_GOT(CERROR),%edx
- PIC_EPILOGUE
- jmp *%edx
+ jmp CERROR
#else
movl 4(%esp),%ecx
movl CURBRK,%eax
-/* $NetBSD: syscall.S,v 1.11 2003/08/07 16:42:09 agc Exp $ */
+/* $NetBSD: syscall.S,v 1.12 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: syscall.S,v 1.11 2003/08/07 16:42:09 agc Exp $")
+ RCSID("$NetBSD: syscall.S,v 1.12 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jc err
ret
err:
-#ifdef PIC
- PIC_PROLOGUE
- mov PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
jmp CERROR
-#endif
-/* $NetBSD: swapcontext.S,v 1.6 2012/09/12 02:00:53 manu Exp $ */
+/* $NetBSD: swapcontext.S,v 1.7 2012/09/13 11:47:46 martin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: swapcontext.S,v 1.6 2012/09/12 02:00:53 manu Exp $")
+ RCSID("$NetBSD: swapcontext.S,v 1.7 2012/09/13 11:47:46 martin Exp $")
#endif /* LIBC_SCCS && !lint */
#ifdef PIC
PIC_PROLOGUE(%g5,%o4) /* %g5 = _GLOBAL_OFFSET_TABLE */
#ifdef BIGPIC
- set _C_LABEL(setcontext), %o6
- ldx [%g5+%o6], %o5
+ set _C_LABEL(setcontext), %o5
+ ldx [%g5+%o5], %o4
#else
- ldx [%g5+_C_LABEL(setcontext)], %o5
+ ldx [%g5+_C_LABEL(setcontext)], %o4
#endif
- jmp %o5
+ jmp %o4
mov %o3, %o0
#else
ba,a _C_LABEL(setcontext)
* SUCH DAMAGE.
*
* from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
- * $NetBSD: SYS.h,v 1.10 2007/11/23 07:36:05 dsl Exp $
+ * $NetBSD: SYS.h,v 1.11 2011/11/18 20:43:01 joerg Exp $
*/
#include <machine/asm.h>
ENTRY(x); \
SYSTRAP(y)
-#ifdef PIC
#define _SYSCALL_ERR \
- mov PIC_GOT(CERROR), %rcx; \
- jmp *%rcx
-#else
-#define _SYSCALL_ERR \
jmp CERROR
-#endif
#define _SYSCALL(x,y) \
.text; _ALIGN_TEXT; \
-/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
+/* $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 0x4000
+#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0x7fff
/* 6 bytes of tail padding follow, per AMD64 ABI */
-# $NetBSD: Makefile.inc,v 1.15 2010/01/14 02:09:46 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.16 2011/03/26 19:51:42 christos 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
+ fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
+ fpsetprec.S
SRCS+= __setjmp14.S
SRCS+= _setjmp.S
-/* $NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $ */
+/* $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
/* LINTED uintptr_t is safe */
gr[_REG_URSP] = (uintptr_t) sp;
- /* LINTED private is currently unused */
+ u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+ u->uc_flags |= _UC_TLSBASE;
}
-/* $NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $ */
-
-/*
- * Written by J.T. Conklin, Apr 4, 1995
- * Public domain.
- */
+/* $NetBSD: flt_rounds.S,v 1.6 2011/09/30 17:42:34 christos Exp $ */
#include <machine/asm.h>
+/*
+ * 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
-_map:
- .byte 1 /* round to nearest */
- .byte 3 /* round to negative infinity */
- .byte 2 /* round to positive infinity */
- .byte 0 /* round to zero */
-
ENTRY(__flt_rounds)
- fnstcw -4(%rsp)
- movl -4(%rsp),%eax
- shrl $10,%eax
- andl $3,%eax
-#ifdef PIC
- leaq PIC_GOT(_map),%rcx
- movb (%rcx,%rax,1),%al
-#else
- movb _map(,%rax,1),%al
-#endif
+ 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
--- /dev/null
+/* $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:42 christos Exp $ */
+
+/*
+ * Written by J.T. Conklin, Apr 4, 1995
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * 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
-/* $NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
+/* $NetBSD: fpgetround.S,v 1.4 2011/09/30 17:42:34 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
#include <machine/asm.h>
/*
- * XXX store only x87 state. If an application only uses the fp*
+ * XXX load only x87 state. If an application only uses the fp*
* interface, this should be in sync with the SSE mxcsr register.
*/
ENTRY(fpgetround)
#endif
fnstcw -4(%rsp)
- movl -4(%rsp),%eax
- rorl $10,%eax
- andl $3,%eax
+ movl -4(%rsp), %eax
+ andl $0x00000c00, %eax
ret
-/* $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
+/* $NetBSD: fpsetmask.S,v 1.5 2012/01/19 16:37:18 drochner Exp $ */
/*
* Written by Frank van der Linden at Wasabi Systems for NetBSD.
#else
ENTRY(fpsetmask)
#endif
- fnstcw -4(%rsp)
- stmxcsr -8(%rsp)
- andl $63,%edi
notl %edi
+ andl $0x0000003f,%edi
- movl -4(%rsp),%edx
- movl %edx,%eax
- andl %edi,%edx
+ fnstcw -4(%rsp)
+ movl -4(%rsp), %edx
+ movl %edx, %eax
+ andl $0xffffffc0, %edx
+ orl %edi, %edx
movl %edx,-4(%rsp)
+ fldcw -4(%rsp)
- movl -8(%rsp),%edx
- roll $7,%edi
- andl %edi,%edx
- movl %edx,-8(%rsp)
+ stmxcsr -4(%rsp)
+ movl -4(%rsp), %edx
+ andl $0xffffe07f, %edx
+ sall $7, %edi
+ orl %edi, %edx
+ movl %edx,-4(%rsp)
+ ldmxcsr -4(%rsp)
- fldcw -4(%rsp)
- ldmxcsr -8(%rsp)
- andl $63,%eax
+ notl %eax
+ andl $0x0000003f, %eax
ret
--- /dev/null
+/* $NetBSD: fpsetprec.S,v 1.1 2011/03/26 19:51:42 christos Exp $ */
+
+/*
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * 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
-/* $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
+/* $NetBSD: fpsetround.S,v 1.4 2011/09/30 17:42:34 christos Exp $ */
/*
* Written by Frank van der Linden at Wasabi Systems for NetBSD.
#else
ENTRY(fpsetround)
#endif
- fnstcw -4(%rsp)
- stmxcsr -8(%rsp)
-
- andl $3,%edi
- movl -4(%rsp),%edx
- rorl $10,%edx
- movl %edx,%eax
- andl $3,%eax
+ 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)
- andl $~3,%edx
+ stmxcsr -4(%rsp)
+ movl -4(%rsp), %edx
+ andl $0xffff9fff, %edx
+ sall $3, %edi
orl %edi,%edx
- roll $10,%edx
movl %edx,-4(%rsp)
+ ldmxcsr -4(%rsp)
- movl -8(%rsp),%edx
- rorl $13,%edx
- andl $~3,%edx
- orl %edi,%edx
- roll $13,%edx
- movl %edx,-8(%rsp)
-
- ldmxcsr -8(%rsp)
- fldcw -4(%rsp)
ret
-/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $ */
+/* $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.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $");
+__RCSID("$NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:29 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include <math.h>
-/* $NetBSD: isnanl.c,v 1.6 2007/02/02 23:19:25 christos Exp $ */
+/* $NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: isnanl.c,v 1.6 2007/02/02 23:19:25 christos Exp $");
+__RCSID("$NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* $NetBSD: __clone.S,v 1.2 2002/06/06 20:51:17 fvdl Exp $ */
+/* $NetBSD: __clone.S,v 1.3 2011/11/18 20:43:01 joerg Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
5:
popq %r13
popq %r12
-#ifdef PIC
- movq PIC_GOT(CERROR),%rdx
- jmp *%rdx
-#else
jmp CERROR
-#endif
-/* $NetBSD: __vfork14.S,v 1.3 2003/08/07 16:42:37 agc Exp $ */
+/* $NetBSD: __vfork14.S,v 1.4 2011/11/18 20:43:01 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: __vfork14.S,v 1.3 2003/08/07 16:42:37 agc Exp $")
+ RCSID("$NetBSD: __vfork14.S,v 1.4 2011/11/18 20:43:01 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jmp *%r9
err:
pushq %r9
-#ifdef PIC
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
jmp CERROR
-#endif
-/* $NetBSD: brk.S,v 1.3 2003/08/07 16:42:37 agc Exp $ */
+/* $NetBSD: brk.S,v 1.4 2011/11/18 20:43:01 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: brk.S,v 1.3 2003/08/07 16:42:37 agc Exp $")
+ RCSID("$NetBSD: brk.S,v 1.4 2011/11/18 20:43:01 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
xorl %eax,%eax
ret
err:
- movq PIC_GOT(CERROR),%rdx
- jmp *%rdx
+ jmp CERROR
#else
cmpq %rdi,_C_LABEL(__minbrk)(%rip)
jb 1f
-/* $NetBSD: cerror.S,v 1.3 2003/08/07 16:42:37 agc Exp $ */
+/* $NetBSD: cerror.S,v 1.5 2012/02/27 12:26:21 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: cerror.S,v 1.3 2003/08/07 16:42:37 agc Exp $")
+ RCSID("$NetBSD: cerror.S,v 1.5 2012/02/27 12:26:21 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
.globl _C_LABEL(__errno)
+ .protected CERROR
_ENTRY(CERROR)
pushq %r12
-/* $NetBSD: exect.S,v 1.2 2003/08/07 16:42:37 agc Exp $ */
+/* $NetBSD: exect.S,v 1.3 2011/11/18 20:43:01 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: exect.S,v 1.2 2003/08/07 16:42:37 agc Exp $")
+ RCSID("$NetBSD: exect.S,v 1.3 2011/11/18 20:43:01 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
orb $(PSL_T>>8),1(%rsp)
popfq
SYSTRAP(execve)
-#ifdef PIC
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
jmp CERROR
-#endif
-/* $NetBSD: ptrace.S,v 1.2 2003/08/07 16:42:37 agc Exp $ */
+/* $NetBSD: ptrace.S,v 1.3 2011/11/18 20:43:01 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: ptrace.S,v 1.2 2003/08/07 16:42:37 agc Exp $")
+ RCSID("$NetBSD: ptrace.S,v 1.3 2011/11/18 20:43:01 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
jc err
ret
err:
-#ifdef PIC
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
jmp CERROR
-#endif
-/* $NetBSD: sbrk.S,v 1.3 2008/07/02 20:07:43 rmind Exp $ */
+/* $NetBSD: sbrk.S,v 1.4 2011/11/18 20:43:01 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: sbrk.S,v 1.3 2008/07/02 20:07:43 rmind Exp $")
+ RCSID("$NetBSD: sbrk.S,v 1.4 2011/11/18 20:43:01 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
out:
ret
err:
- mov PIC_GOT(CERROR),%rdx
- jmp *%rdx
+ jmp CERROR
#else
movq CURBRK(%rip),%rax
test %rdi,%rdi
-.\" $NetBSD: membar_ops.3,v 1.2 2009/05/18 12:39:17 wiz Exp $
+.\" $NetBSD: membar_ops.3,v 1.3 2011/04/28 11:56:26 wiz Exp $
.\"
.\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.Pp
.Bl -tag -width "mem"
.It Fn membar_enter
-Any store preceeding
+Any store preceding
.Fn membar_enter
will reach global visibility before all loads and stores following it.
.Pp
-/* $NetBSD: cdbr.c,v 1.2 2010/06/03 12:40:52 veego Exp $ */
+/* $NetBSD: cdbr.c,v 1.4 2012/09/27 00:37:43 joerg Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cdbr.c,v 1.2 2010/06/03 12:40:52 veego Exp $");
+__RCSID("$NetBSD: cdbr.c,v 1.4 2012/09/27 00:37:43 joerg Exp $");
#include "namespace.h"
+#if !HAVE_NBTOOL_CONFIG_H
#include <sys/bitops.h>
+#endif
+#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
+#endif
+
#include <sys/mman.h>
#include <sys/stat.h>
#include <cdbr.h>
__weak_alias(cdbr_open,_cdbr_open)
#endif
+#if HAVE_NBTOOL_CONFIG_H
+#define fast_divide32_prepare(d,m,s1,s2) (void)0
+#define fast_remainder32(v,d,m,s1,s2) (v%d)
+#endif
+
struct cdbr {
uint8_t *mmap_base;
size_t mmap_size;
cdbr->data_base < cdbr->mmap_base ||
cdbr->data_base + cdbr->data_size < cdbr->mmap_base ||
cdbr->data_base + cdbr->data_size >
- cdbr->mmap_base + cdbr->mmap_size ||
- cdbr->entries == 0 || cdbr->entries_index == 0) {
+ cdbr->mmap_base + cdbr->mmap_size) {
errno = EINVAL;
cdbr_close(cdbr);
return NULL;
}
- fast_divide32_prepare(cdbr->entries, &cdbr->entries_m,
- &cdbr->entries_s1, &cdbr->entries_s2);
- fast_divide32_prepare(cdbr->entries_index, &cdbr->entries_index_m,
- &cdbr->entries_index_s1, &cdbr->entries_index_s2);
+ if (cdbr->entries) {
+ fast_divide32_prepare(cdbr->entries, &cdbr->entries_m,
+ &cdbr->entries_s1, &cdbr->entries_s2);
+ }
+ if (cdbr->entries_index) {
+ fast_divide32_prepare(cdbr->entries_index,
+ &cdbr->entries_index_m,
+ &cdbr->entries_index_s1, &cdbr->entries_index_s2);
+ }
return cdbr;
}
-.\" $NetBSD: cdbw.3,v 1.3 2010/11/03 16:17:48 plunky Exp $
+.\" $NetBSD: cdbw.3,v 1.5 2012/06/04 00:26:29 wiz Exp $
.\"
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" OR TORT (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 3, 2010
+.Dd June 3, 2012
.Dt CDBW 3
.Os
.Sh NAME
.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
.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"
The
.Fn seedgen
parameter can be used to override the default PRNG.
-The function should return a different value for each invokation.
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
-/* $NetBSD: cdbw.c,v 1.1 2010/04/25 00:54:46 joerg Exp $ */
+/* $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.
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cdbw.c,v 1.1 2010/04/25 00:54:46 joerg Exp $");
+__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 <sys/endian.h>
+#endif
#include <sys/queue.h>
#include <cdbw.h>
#include <stdlib.h>
free(cdbw);
}
+uint32_t
+cdbw_stable_seeder(void)
+{
+ return 0;
+}
+
#define unused 0xffffffffU
struct vertex {
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;
}
}
return 0;
}
+#if HAVE_NBTOOL_CONFIG_H
+ if (seedgen == NULL)
+ seedgen = cdbw_stable_seeder;
+#else
if (seedgen == NULL)
seedgen = arc4random;
+#endif
rv = 0;
goto release;
}
+ state.seed = 0;
do {
- state.seed = (*seedgen)();
+ if (seedgen == cdbw_stable_seeder)
+ ++state.seed;
+ else
+ state.seed = (*seedgen)();
} while (build_graph(cdbw, &state));
assign_nodes(&state);
# sources
.PATH: ${ARCHDIR}/citrus ${.CURDIR}/citrus
-#MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major
-#CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR}
+.if !defined(__MINIX)
+MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major
+CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR}
+.endif # !defined(__MINIX)
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 \
-/* $NetBSD: citrus_csmapper.c,v 1.10 2009/01/11 02:46:24 christos Exp $ */
+/* $NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_csmapper.c,v 1.10 2009/01/11 02:46:24 christos Exp $");
+__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"
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);
-/* $NetBSD: citrus_ctype.c,v 1.5 2008/06/14 16:01:07 tnozaki Exp $ */
+/* $NetBSD: citrus_ctype.c,v 1.6 2011/11/19 18:34:21 tnozaki Exp $ */
/*-
* Copyright (c)1999, 2000, 2001, 2002 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_ctype.c,v 1.5 2008/06/14 16:01:07 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_ctype.c,v 1.6 2011/11/19 18:34:21 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
cc->cc_ops->co_wcstombs == NULL ||
cc->cc_ops->co_wctomb == NULL ||
cc->cc_ops->co_btowc == NULL ||
- cc->cc_ops->co_wctob == NULL)
+ cc->cc_ops->co_wctob == NULL) {
+ ret = EINVAL;
goto bad;
+ }
/* init and get closure */
ret = (*cc->cc_ops->co_init)(
-/* $NetBSD: citrus_iconv.c,v 1.8 2009/09/05 06:44:27 dholland Exp $ */
+/* $NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_iconv.c,v 1.8 2009/09/05 06:44:27 dholland Exp $");
+__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 <sys/types.h>
+#include <sys/queue.h>
+
#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <limits.h>
#include <unistd.h>
-#include <paths.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/queue.h>
#include "citrus_namespace.h"
#include "citrus_bcs.h"
#ifdef _REENTRANT
static rwlock_t lock = RWLOCK_INITIALIZER;
#endif
-static int isinit = 0;
+
+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;
shared_max_reuse = atoi(getenv(CI_ENV_MAX_REUSE));
if (shared_max_reuse < 0)
shared_max_reuse = CI_INITIAL_MAX_REUSE;
- isinit = 1;
+ isinit = true;
}
rwlock_unlock(&lock);
}
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)
+ ci->ci_ops->io_convert == NULL) {
+ ret = EINVAL;
goto err;
+ }
/* initialize the converter */
ret = (*ci->ci_ops->io_init_shared)(ci, basedir, src, dst,
-/* $NetBSD: citrus_lc_ctype.c,v 1.9 2010/06/19 13:26:51 tnozaki Exp $ */
+/* $NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.9 2010/06/19 13:26:51 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#define _CATEGORY_DEFAULT _DefaultRuneLocale
#include "nb_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_citrus_LC_CTYPE_);
-/* $NetBSD: citrus_lc_messages.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: citrus_lc_messages.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_messages.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $");
+__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"
#define _CATEGORY_MAGIC _CITRUS_LC_MESSAGES_MAGIC_1
#include "citrus_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_citrus_LC_MESSAGES_);
-/* $NetBSD: citrus_lc_monetary.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: citrus_lc_monetary.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_monetary.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $");
+__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"
#define _CATEGORY_MAGIC _CITRUS_LC_MONETARY_MAGIC_1
#include "citrus_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_citrus_LC_MONETARY_);
-/* $NetBSD: citrus_lc_numeric.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: citrus_lc_numeric.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_numeric.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $");
+__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"
#define _CATEGORY_MAGIC _CITRUS_LC_NUMERIC_MAGIC_1
#include "citrus_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_citrus_LC_NUMERIC_);
-/* $NetBSD: citrus_lc_time.c,v 1.5 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: citrus_lc_time.c,v 1.6 2012/03/04 21:14:55 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_time.c,v 1.5 2010/06/13 04:14:57 tnozaki Exp $");
+__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"
#define _CATEGORY_MAGIC _CITRUS_LC_TIME_MAGIC_1
#include "citrus_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_citrus_LC_TIME_);
-/* $NetBSD: citrus_lookup.c,v 1.6 2009/02/03 04:58:38 lukem Exp $ */
+/* $NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lookup.c,v 1.6 2009/02/03 04:58:38 lukem Exp $");
+__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"
cl = malloc(sizeof(*cl));
if (cl == NULL)
- return errno;
+ return ENOMEM;
cl->cl_key = NULL;
cl->cl_keylen = 0;
-/* $NetBSD: citrus_mapper.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
+/* $NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_mapper.c,v 1.7 2008/07/25 14:05:25 christos Exp $");
+__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"
}
ma->ma_dir = strdup(area);
if (ma->ma_dir == NULL) {
+ free(ma);
ret = errno;
- free(ma->ma_dir);
goto quit;
}
_CITRUS_HASH_INIT(&ma->ma_cache, CM_HASH_SIZE);
if (!cm->cm_ops->mo_init ||
!cm->cm_ops->mo_uninit ||
!cm->cm_ops->mo_convert ||
- !cm->cm_ops->mo_init_state)
+ !cm->cm_ops->mo_init_state) {
+ ret = EINVAL;
goto err;
+ }
/* allocate traits structure */
cm->cm_traits = malloc(sizeof(*cm->cm_traits));
-/* $NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $ */
+/* $NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $");
+__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"
_citrus_memory_stream_getln(struct _citrus_memory_stream * __restrict ms,
size_t * __restrict rlen)
{
- int i;
+ size_t i;
const uint8_t *h, *p;
size_t ret;
-/* $NetBSD: citrus_mmap.c,v 1.3 2005/01/19 00:52:37 mycroft Exp $ */
+/* $NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_mmap.c,v 1.3 2005/01/19 00:52:37 mycroft Exp $");
+__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 "citrus_region.h"
#include "citrus_mmap.h"
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
int
_citrus_map_file(struct _citrus_region * __restrict r,
const char * __restrict path)
_region_init(r, NULL, 0);
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
return errno;
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- ret = errno;
- goto error;
- }
if (fstat(fd, &st) == -1) {
ret = errno;
-/* $NetBSD: citrus_module.c,v 1.9 2009/01/11 02:46:24 christos Exp $ */
+/* $NetBSD: citrus_module.c,v 1.10 2012/10/15 22:22:01 msaitoh Exp $ */
/*-
* Copyright (c)1999, 2000, 2001, 2002 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_module.c,v 1.9 2009/01/11 02:46:24 christos Exp $");
+__RCSID("$NetBSD: citrus_module.c,v 1.10 2012/10/15 22:22:01 msaitoh Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#ifdef _I18N_DYNAMIC
-static int _getdewey(int [], char *);
-static int _cmpndewey(int [], int, int [], int);
+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;
#undef minor
#define MAXDEWEY 3 /*ELF*/
-static int
+static unsigned int
_getdewey(int dewey[], char *cp)
{
- int i, n;
+ unsigned int i, n;
_DIAGASSERT(dewey != NULL);
_DIAGASSERT(cp != NULL);
* Return 0 if equal.
*/
static int
-_cmpndewey(int d1[], int n1, int d2[], int n2)
+_cmpndewey(int d1[], unsigned int n1, int d2[], unsigned int n2)
{
- register int i;
+ register unsigned int i;
_DIAGASSERT(d1 != NULL);
_DIAGASSERT(d2 != NULL);
_findshlib(char *name, int *majorp, int *minorp)
{
int dewey[MAXDEWEY];
- int ndewey;
+ unsigned int ndewey;
int tmp[MAXDEWEY];
int i;
int len;
continue;
while ((dp = readdir(dd)) != NULL) {
- int n;
+ unsigned int n;
if (dp->d_namlen < len + 4)
continue;
-/* $NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
-#include <limits.h>
#include <errno.h>
+#include <limits.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
_citrus_prop_type_t type;
union {
const char *str;
- int bool, chr;
+ int chr;
+ bool boolean;
uint64_t num;
} u;
} _citrus_prop_object_t;
if (_bcs_tolower(_memstream_getc(ms)) == 'r' &&
_bcs_tolower(_memstream_getc(ms)) == 'u' &&
_bcs_tolower(_memstream_getc(ms)) == 'e') {
- obj->u.bool = 1;
+ obj->u.boolean = true;
return 0;
}
break;
_bcs_tolower(_memstream_getc(ms)) == 'l' &&
_bcs_tolower(_memstream_getc(ms)) == 's' &&
_bcs_tolower(_memstream_getc(ms)) == 'e') {
- obj->u.bool = 0;
+ obj->u.boolean = false;
return 0;
}
}
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(bool); break;
- case _CITRUS_PROP_STR : CALL0( str); break;
- case _CITRUS_PROP_CHR : CALL1( chr); break;
- case _CITRUS_PROP_NUM : CALL1( num); break;
+
+ 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*/
-/* $NetBSD: citrus_prop.h,v 1.3 2006/11/23 13:59:03 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.h,v 1.5 2011/05/23 14:52:32 joerg Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
typedef struct { \
_citrus_prop_##_func_##_cb_func_t func; \
} _citrus_prop_##_func_##_cb_t;
-_CITRUS_PROP_CB0_T(bool, int)
+_CITRUS_PROP_CB0_T(boolean, int)
_CITRUS_PROP_CB0_T(str, const char *)
#undef _CITRUS_PROP_CB0_T
#define _CITRUS_PROP_CB_T_OPS(_name_) \
_citrus_prop_##_name_##_cb_t _name_
union {
- _CITRUS_PROP_CB_T_OPS(bool);
+ _CITRUS_PROP_CB_T_OPS(boolean);
_CITRUS_PROP_CB_T_OPS(str);
_CITRUS_PROP_CB_T_OPS(chr);
_CITRUS_PROP_CB_T_OPS(num);
};
#define _CITRUS_PROP_HINT_BOOL(name, cb) \
- { name, _CITRUS_PROP_BOOL, { .bool = { 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) \
#define _CITRUS_PROP_HINT_NUM(name, cb) \
{ name, _CITRUS_PROP_NUM, { .num = { cb } } }
#define _CITRUS_PROP_HINT_END \
- { NULL }
+ { .name = NULL }
__BEGIN_DECLS
int _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict,
-/* $NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */
+/* $NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $");
+__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"
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)
+ ce->ce_ops->eo_get_state_desc == NULL) {
+ ret = EINVAL;
goto bad;
+ }
/* allocate traits */
ce->ce_traits = malloc(sizeof(*ce->ce_traits));
-/* $NetBSD: citrus_big5.c,v 1.12 2008/06/14 16:01:07 tnozaki Exp $ */
+/* $NetBSD: citrus_big5.c,v 1.13 2011/05/23 14:53:46 joerg Exp $ */
/*-
* Copyright (c)2002, 2006 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_big5.c,v 1.12 2008/06/14 16:01:07 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_big5.c,v 1.13 2011/05/23 14:53:46 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/queue.h>
size_t n, wchar_t wc, _BIG5State * __restrict psenc,
size_t * __restrict nresult)
{
- int l, ret;
+ size_t l, ret;
_DIAGASSERT(ei != NULL);
_DIAGASSERT(nresult != 0);
-/* $NetBSD: citrus_dechanyu.c,v 1.3 2008/06/14 16:01:07 tnozaki Exp $ */
+/* $NetBSD: citrus_dechanyu.c,v 1.4 2011/11/19 18:20:13 tnozaki Exp $ */
/*-
* Copyright (c)2007 Citrus Project,
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_dechanyu.c,v 1.3 2008/06/14 16:01:07 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_dechanyu.c,v 1.4 2011/11/19 18:20:13 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
_DECHanyuState * __restrict psenc, size_t * __restrict nresult)
{
const char *s0;
- int ch, i;
+ int ch;
wchar_t wc;
/* ei may be unused */
-/* $NetBSD: citrus_iconv_none.c,v 1.2 2003/07/01 09:42:16 tshiozak Exp $ */
+/* $NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_iconv_none.c,v 1.2 2003/07/01 09:42:16 tshiozak Exp $");
+__RCSID("$NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
_citrus_iconv_none_iconv_init_context(struct _citrus_iconv *cv)
{
cv->cv_closure = NULL;
+ return 0;
}
static void
-/* $NetBSD: citrus_iconv_std.c,v 1.15 2006/11/13 19:08:19 tnozaki Exp $ */
+/* $NetBSD: citrus_iconv_std.c,v 1.16 2012/02/12 13:51:29 wiz Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_iconv_std.c,v 1.15 2006/11/13 19:08:19 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_iconv_std.c,v 1.16 2012/02/12 13:51:29 wiz Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
{
const struct _citrus_iconv_std_shared *is = cv->cv_shared->ci_closure;
struct _citrus_iconv_std_context *sc;
- int ret;
size_t szpssrc, szpsdst, sz;
char *ptr;
-/* $NetBSD: citrus_iso2022.c,v 1.20 2010/12/07 22:01:45 joerg Exp $ */
+/* $NetBSD: citrus_iso2022.c,v 1.22 2011/10/10 22:45:45 tnozaki Exp $ */
/*-
* Copyright (c)1999, 2002 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_iso2022.c,v 1.20 2010/12/07 22:01:45 joerg Exp $");
+__RCSID("$NetBSD: citrus_iso2022.c,v 1.22 2011/10/10 22:45:45 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
-/* $NetBSD: citrus_mapper_std.c,v 1.8 2006/09/11 13:06:33 tnozaki Exp $ */
+/* $NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $ */
/*-
* Copyright (c)2003, 2006 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_mapper_std.c,v 1.8 2006/09/11 13:06:33 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
n = be32toh(rcx->rcx_src_row_end);
if (m + n > 0) {
ret = set_linear_zone(lz, m, n);
- if (ret != 0)
+ 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);
{
struct _citrus_mapper_std *ms;
- _DIAGASSERT(cm!=NULL & cm->cm_closure!=NULL);
+ _DIAGASSERT(cm!=NULL && cm->cm_closure!=NULL);
ms = cm->cm_closure;
if (ms->ms_uninit)
-/* $NetBSD: citrus_ues.c,v 1.2 2010/12/07 22:01:22 joerg Exp $ */
+/* $NetBSD: citrus_ues.c,v 1.3 2012/02/12 13:51:29 wiz Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_ues.c,v 1.2 2010/12/07 22:01:22 joerg Exp $");
+__RCSID("$NetBSD: citrus_ues.c,v 1.3 2012/02/12 13:51:29 wiz Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
_UESState * __restrict psenc, size_t * __restrict nresult)
{
const char *s0;
- int ch, head, tail, i, num;
+ int ch, head, tail, num;
wchar_t hi, wc;
_DIAGASSERT(ei != NULL);
-/* $NetBSD: citrus_utf1632.c,v 1.11 2010/03/20 18:15:32 tnozaki Exp $ */
+/* $NetBSD: citrus_utf1632.c,v 1.12 2012/02/12 13:51:29 wiz Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_utf1632.c,v 1.11 2010/03/20 18:15:32 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_utf1632.c,v 1.12 2012/02/12 13:51:29 wiz Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
wchar_t wc, _UTF1632State *psenc,
size_t *nresult)
{
- int ret;
wchar_t wc2;
static const char _bom[4] = {
#if BYTE_ORDER == BIG_ENDIAN
-/* $NetBSD: citrus_viqr.c,v 1.4 2008/06/14 16:01:08 tnozaki Exp $ */
+/* $NetBSD: citrus_viqr.c,v 1.5 2011/11/19 18:20:13 tnozaki Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_viqr.c,v 1.4 2008/06/14 16:01:08 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_viqr.c,v 1.5 2011/11/19 18:20:13 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/queue.h>
_VIQRState * __restrict psenc, size_t * __restrict nresult)
{
mnemonic_t *m;
- int ch, escape;
+ int ch;
const char *p;
_DIAGASSERT(ei != NULL);
.\" SUCH DAMAGE.
.\"
.\" from: @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93
-.\" $NetBSD: getdtablesize.3,v 1.13 2003/08/07 16:42:39 agc Exp $
+.\" $NetBSD: getdtablesize.3,v 1.14 2012/01/05 07:05:59 yamt Exp $
.\"
-.Dd June 4, 1993
+.Dd January 5, 2012
.Dt GETDTABLESIZE 3
.Os
.Sh NAME
.Ft int
.Fn getdtablesize void
.Sh DESCRIPTION
-Each process has a fixed size descriptor table,
-which is guaranteed to have at least 20 slots.
-The entries in
-the descriptor table are numbered with small integers starting at 0.
-The call
-.Fn getdtablesize
-returns the size of this table.
+The
+.Nm
+function is an equivalent of
+.Fn sysconf
+with
+.Dv _SC_OPEN_MAX .
.Sh SEE ALSO
.Xr close 2 ,
.Xr dup 2 ,
.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.
-/* $NetBSD: getdtablesize.c,v 1.9 2003/07/26 19:24:41 salo Exp $ */
+/* $NetBSD: getdtablesize.c,v 1.10 2012/06/24 15:26:03 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getdtablesize.c,v 1.9 2003/07/26 19:24:41 salo Exp $");
+__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 <unistd.h>
int
-getdtablesize()
+getdtablesize(void)
{
return ((int)sysconf(_SC_OPEN_MAX));
}
-/* $NetBSD: getwd.c,v 1.14 2003/08/07 16:42:39 agc Exp $ */
+/* $NetBSD: getwd.c,v 1.15 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)getwd.c 8.1 (Berkeley) 6/2/93";
#else
-__RCSID("$NetBSD: getwd.c,v 1.14 2003/08/07 16:42:39 agc Exp $");
+__RCSID("$NetBSD: getwd.c,v 1.15 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
"warning: getwd() possibly used unsafely, consider using getcwd()")
char *
-getwd(buf)
- char *buf;
+getwd(char *buf)
{
char *p;
.include "${.CURDIR}/Makefile.inc"
+.if !defined(__MINIX)
.include "${.CURDIR}/db/Makefile.inc"
+.endif # !defined(__MINIX)
.include "${.CURDIR}/gen/Makefile.inc"
+.if !defined(__MINIX)
.include "${.CURDIR}/locale/Makefile.inc"
.include "${.CURDIR}/net/Makefile.inc"
.include "${.CURDIR}/rpc/Makefile.inc"
.include "${.CURDIR}/stdio/Makefile.inc"
+.endif # !defined(__MINIX)
.include "${.CURDIR}/stdlib/Makefile.inc"
+.if !defined(__MINIX)
.include "${.CURDIR}/sys/Makefile.inc"
+.endif # !defined(__MINIX)
COMPATARCHDIR=${.CURDIR}/arch/${ARCHSUBDIR}
.PATH: ${COMPATARCHDIR}/gen ${COMPATARCHDIR}/sys
COMPATARCHDIR=${COMPATDIR}/arch/${ARCHSUBDIR}
.PATH: ${COMPATARCHDIR}/gen ${COMPATARCHDIR}/sys
+.if !defined(__MINIX)
.include "${COMPATDIR}/db/Makefile.inc"
.include "${COMPATDIR}/locale/Makefile.inc"
+.endif #!defined(__MINIX)
.include "${COMPATDIR}/gen/Makefile.inc"
+.if !defined(__MINIX)
.include "${COMPATDIR}/net/Makefile.inc"
.include "${COMPATDIR}/rpc/Makefile.inc"
.include "${COMPATDIR}/stdio/Makefile.inc"
+.if !defined(__MINIX)
.include "${COMPATDIR}/stdlib/Makefile.inc"
+.endif #!defined(__MINIX)
.include "${COMPATDIR}/sys/Makefile.inc"
.include "${COMPATDIR}/time/Makefile.inc"
.include "${COMPATARCHDIR}/Makefile.inc"
+.endif #!defined(__MINIX)
-# $NetBSD: Makefile.inc,v 1.1 2005/10/16 17:27:50 christos Exp $
+# $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_sigsuspend.S compat_quotactl.S
--- /dev/null
+/* $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 <sys/quota.h> for correct reference")
+
+PSEUDO(quotactl,compat_50_quotactl)
-# $NetBSD: Makefile.inc,v 1.1 2005/09/13 01:44:08 christos Exp $
+# $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_sigsuspend.S compat_quotactl.S
--- /dev/null
+/* $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 <sys/quota.h> for correct reference")
+
+PSEUDO(quotactl,compat_50_quotactl)
-# $NetBSD: Makefile.inc,v 1.1 2006/03/11 18:59:21 christos Exp $
+# $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_sigsuspend.S compat_quotactl.S
--- /dev/null
+/* $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 <sys/quota.h> for correct reference")
+
+PSEUDO(quotactl,compat_50_quotactl)
-/* $NetBSD: compat_ndbmdatum.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_ndbmdatum.c,v 1.2 2012/03/13 21:13:31 christos Exp $ */
/*
* Written by Klaus Klein <kleink@NetBSD.org>, April 28, 2004.
" include <ndbm.h> for correct reference")
#define datum datum12
+#define datum_truncate(a) ((a) > INT_MAX ? INT_MAX : (int)(a))
+
#include "db/hash/ndbmdatum.c"
-# $NetBSD: Makefile.inc,v 1.13 2010/04/23 19:04:54 drochner Exp $
+# $NetBSD: Makefile.inc,v 1.15 2012/10/10 22:52:26 christos Exp $
.PATH: ${COMPATDIR}/gen
+.if !defined(__MINIX)
SRCS+=compat_errlist.c compat_fts.c compat___fts13.c compat___fts30.c \
compat___fts31.c compat_getmntinfo.c compat_glob.c compat___glob13.c \
compat_opendir.c compat_readdir.c compat__readdir_unlocked30.c \
compat_times.c compat_timezone.c compat_unvis.c compat_utmpx.c \
compat__sys_errlist.c compat__sys_nerr.c compat__sys_siglist.c \
compat_time.c compat_utime.c compat_devname.c compat_alphasort.c \
- compat_getpwent.c compat___fts32.c compat_utmp.c compat___fts50.c
+ compat_getpwent.c compat___fts32.c compat_utmp.c compat___fts50.c \
+ compat___unvis13.c compat_syslog.c
+.else
+SRCS+= \
+ compat___unvis13.c compat_syslog.c
+.endif # !defined(__MINIX)
-/* $NetBSD: compat___fts13.c,v 1.6 2009/10/19 17:52:01 christos Exp $ */
+/* $NetBSD: compat___fts13.c,v 1.9 2012/03/14 00:25:19 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
#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 __stat13
#define lstat __lstat13
#define fstat __fstat13
-/* $NetBSD: compat___fts30.c,v 1.3 2009/10/19 17:52:04 christos Exp $ */
+/* $NetBSD: compat___fts30.c,v 1.6 2012/03/14 00:25:19 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
#define lstat __lstat30
#define fstat __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
-/* $NetBSD: compat___fts31.c,v 1.2 2009/10/19 17:52:05 christos Exp $ */
+/* $NetBSD: compat___fts31.c,v 1.4 2012/03/14 00:25:19 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
#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 __stat30
#define lstat __lstat30
#define fstat __fstat30
--- /dev/null
+/* $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 <sys/cdefs.h>
+#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 <sys/types.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <vis.h>
+#include <compat/include/vis.h>
+
+#ifdef __warn_references
+__warn_references(__unvis13,
+ "warning: reference to compatibility __unvis13(); include <vis.h> 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);
+}
-/* $NetBSD: compat_fts.c,v 1.4 2009/10/19 17:52:05 christos Exp $ */
+/* $NetBSD: compat_fts.c,v 1.6 2012/03/15 16:47:38 christos Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
#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 <fts.h>
#include <compat/include/fts.h>
-/* $NetBSD: compat_getmntinfo.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_getmntinfo.c,v 1.2 2012/03/20 17:05:59 matt Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_getmntinfo.c,v 1.1 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: compat_getmntinfo.c,v 1.2 2012/03/20 17:05:59 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Return information about mounted filesystems.
*/
int
-getmntinfo(mntbufp, flags)
- struct statfs12 **mntbufp;
- int flags;
+getmntinfo(struct statfs12 **mntbufp, int flags)
{
static struct statfs12 *mntbuf;
static int mntsize;
-/* $NetBSD: compat_readdir.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_readdir.c,v 1.3 2012/02/08 12:10:17 mbalmer Exp $ */
#define __LIBC12_SOURCE__
#include "namespace.h"
+#include <sys/param.h>
#include <dirent.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
#include <compat/include/dirent.h>
#ifdef __weak_alias
"warning: reference to compatibility readdir_r(); include <dirent.h> for correct reference")
#endif
-#define dirent dirent12
+static struct dirent12 *
+direnttodirent12(struct dirent12 *d12, const struct dirent *d)
+{
+ if (d == NULL)
+ return NULL;
-#include "gen/readdir.c"
+ 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;
+}
-/* $NetBSD: compat_sigsetops.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */
+/* $NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_sigsetops.c,v 1.2 2009/01/11 02:46:25 christos Exp $");
+__RCSID("$NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
"warning: reference to compatibility sigismember(); include <signal.h> for correct reference")
int
-sigemptyset(set)
- sigset13_t *set;
+sigemptyset(sigset13_t *set)
{
*set = 0;
return (0);
}
int
-sigfillset(set)
- sigset13_t *set;
+sigfillset(sigset13_t *set)
{
*set = ~(sigset13_t)0;
return (0);
}
int
-sigaddset(set, signo)
- sigset13_t *set;
- int signo;
+sigaddset(sigset13_t *set, int signo)
{
if (signo <= 0 || signo >= NSIG13) {
errno = EINVAL;
}
int
-sigdelset(set, signo)
- sigset13_t *set;
- int signo;
+sigdelset(sigset13_t *set, int signo)
{
if (signo <= 0 || signo >= NSIG13) {
errno = EINVAL;
}
int
-sigismember(set, signo)
- const sigset13_t *set;
- int signo;
+sigismember(const sigset13_t *set, int signo)
{
if (signo <= 0 || signo >= NSIG13) {
errno = EINVAL;
--- /dev/null
+/* $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 <sys/cdefs.h>
+
+#define __LIBC12_SOURCE__
+#include <stdarg.h>
+
+#include <sys/types.h>
+#include <sys/syslog.h>
+#include <compat/sys/syslog.h>
+
+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 <sys/syslog.h> for correct reference")
+__warn_references(openlog_r,
+ "warning: reference to compatibility openlog_r();"
+ " include <sys/syslog.h> for correct reference")
+__warn_references(setlogmask_r,
+ "warning: reference to compatibility setlogmask_r();"
+ " include <sys/syslog.h> for correct reference")
+__warn_references(syslog_r,
+ "warning: reference to compatibility syslog_r();"
+ " include <sys/syslog.h> for correct reference")
+__warn_references(vsyslog_r,
+ "warning: reference to compatibility vsyslog_r();"
+ " include <sys/syslog.h> for correct reference")
+__warn_references(syslogp_r,
+ "warning: reference to compatibility syslogp_r();"
+ " include <sys/syslog.h> for correct reference")
+__warn_references(vsyslogp_r,
+ "warning: reference to compatibility vsyslogp_r();"
+ " include <sys/syslog.h> 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);
+}
-/* $NetBSD: compat_timezone.c,v 1.3 2009/01/11 02:46:25 christos Exp $ */
+/* $NetBSD: compat_timezone.c,v 1.4 2012/03/20 17:05:59 matt Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_timezone.c,v 1.3 2009/01/11 02:46:25 christos Exp $");
+__RCSID("$NetBSD: compat_timezone.c,v 1.4 2012/03/20 17:05:59 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* STANDARD LIBRARY.
*/
char *
-_tztab(zone,dst)
- int zone;
- int dst;
+_tztab(int zone, int dst)
{
const struct zone *zp;
char sign;
-/* $NetBSD: compat_unvis.c,v 1.2 2007/03/10 01:13:14 hubertf Exp $ */
+/* $NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_unvis.c,v 1.2 2007/03/10 01:13:14 hubertf Exp $");
+__RCSID("$NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <vis.h>
#include <compat/include/vis.h>
-#ifdef __weak_alias
-__weak_alias(unvis,_unvis)
-#endif
-
#ifdef __warn_references
__warn_references(unvis,
"warning: reference to compatibility unvis(); include <vis.h> for correct reference")
int
unvis(char *cp, int c, int *astate, int flag)
{
- return __unvis13(cp, c, astate, flag);
+ flag = (flag & ~1) | ((flag & 1) ? UNVIS_END : 0);
+ return __unvis50(cp, c, astate, flag);
}
-/* $NetBSD: compat_utmpx.c,v 1.3 2009/01/11 02:46:25 christos Exp $ */
+/* $NetBSD: compat_utmpx.c,v 1.4 2011/07/01 01:08:59 joerg Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_utmpx.c,v 1.3 2009/01/11 02:46:25 christos Exp $");
+__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"
{
(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));
+ (void)memcpy(&ll->ll_ss, &ll50->ll_ss, sizeof(ll->ll_ss));
timeval50_to_timeval(&ll50->ll_tv, &ll->ll_tv);
}
{
(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));
+ (void)memcpy(&ll50->ll_ss, &ll->ll_ss, sizeof(ll50->ll_ss));
timeval_to_timeval50(&ll->ll_tv, &ll50->ll_tv);
}
-/* $NetBSD: setjmp.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: setjmp.h,v 1.2 2011/11/05 09:27:06 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
#define _COMPAT_SETJMP_H_
__BEGIN_DECLS
-int __setjmp14(jmp_buf);
-void __longjmp14(jmp_buf, int) __attribute__((__noreturn__));
+int __setjmp14(jmp_buf) __returns_twice;
+void __longjmp14(jmp_buf, int) __dead;
-int __sigsetjmp14(sigjmp_buf, int);
-void __siglongjmp14(sigjmp_buf, int) __attribute__((__noreturn__));
+int __sigsetjmp14(sigjmp_buf, int) __returns_twice;
+void __siglongjmp14(sigjmp_buf, int) __dead;
__END_DECLS
#endif /* !_COMPAT_SETJMP_H_ */
-/* $NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $ */
+/* $NetBSD: stdio.h,v 1.1 2012/01/22 18:36:14 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
* LIABILITY, OR TORT (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
+ *
*/
-#include <stdio.h>
-#include <unistd.h>
+#ifndef _COMPAT_STDIO_H_
+#define _COMPAT_STDIO_H_
-#define std(flags, file) \
-/* p r w flags file bf lfbsize cookie close */ \
- { NULL, 0, 0, flags, file, { NULL, 0 }, 0, __sF + file, NULL, \
-/* read seek write ext up */ \
- NULL, NULL, NULL, { NULL, 0 }, NULL, \
-/* ur ubuf, nbuf lb blksize offset */ \
- 0, { '\0', '\0', '\0' }, { '\0' }, { NULL, 0 }, 0, (fpos_t)0 }
+__BEGIN_DECLS
+int fgetpos(FILE * __restrict, off_t * __restrict);
+int fsetpos(FILE *, const off_t *);
+__END_DECLS
-FILE __sF[3] = {
- std(__SRD, STDIN_FILENO), /* stdin */
- std(__SWR, STDOUT_FILENO), /* stdout */
- std(__SWR|__SNBF, STDERR_FILENO) /* stderr */
-};
+#endif /* _COMPAT_STDIO_H_ */
-/* $NetBSD: stdlib.h,v 1.4 2009/01/26 15:05:56 drochner Exp $ */
+/* $NetBSD: stdlib.h,v 1.5 2012/04/20 17:31:29 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
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);
-/* $NetBSD: vis.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: vis.h,v 1.2 2011/03/12 19:52:47 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
__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_ */
-# $NetBSD: Makefile.inc,v 1.1 2006/08/26 16:07:01 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2012/01/20 14:08:05 joerg Exp $
.PATH: ${COMPATDIR}/net
-SRCS+=compat_ns_addr.c compat_ns_ntoa.c
+SRCS+= __cmsg_alignbytes.c compat_ns_addr.c compat_ns_ntoa.c
-/* $NetBSD: __cmsg_alignbytes.c,v 1.3 2009/03/16 05:59:21 cegger Exp $ */
+/* $NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __cmsg_alignbytes.c,v 1.3 2009/03/16 05:59:21 cegger Exp $");
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $");
#include "namespace.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
-#else
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#endif
+
+int __cmsg_alignbytes(void);
int
__cmsg_alignbytes(void)
-/* $NetBSD: compat_ns_addr.c,v 1.1 2006/08/26 16:07:01 matt Exp $ */
+/* $NetBSD: compat_ns_addr.c,v 1.3 2012/10/15 22:22:01 msaitoh Exp $ */
/*
* Copyright (c) 1986, 1993
#if 0
static char sccsid[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93";
#else
-__RCSID("$NetBSD: compat_ns_addr.c,v 1.1 2006/08/26 16:07:01 matt Exp $");
+__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 <stdio.h>
#include <string.h>
-static void Field __P((char *, u_int8_t *, int));
-static void cvtbase __P((long, int, int[], int, u_int8_t[], int));
+static void Field(char *, uint8_t *, int);
+static void cvtbase(long, int, int[], int, uint8_t [], int);
struct ns_addr
-ns_addr(name)
- const char *name;
+ns_addr(const char *name)
{
char separator;
char *hostname, *socketname, *cp;
socketname = strchr(hostname, separator);
if (socketname) {
*socketname++ = 0;
- Field(socketname, (u_int8_t *)(void *)&addr.x_port, 2);
+ Field(socketname, (uint8_t *)(void *)&addr.x_port, 2);
}
Field(hostname, addr.x_host.c_host, 6);
}
static void
-Field(buf, out, len)
- char *buf;
- u_int8_t *out;
- int len;
+Field(char *buf, uint8_t *out, int len)
{
register char *bp = buf;
- int i, ibase, base16 = 0, base10 = 0, clen = 0;
+ int i, ibase, base16 = 0, base10 = 0;
+ unsigned int clen = 0;
int hb[6], *hp;
_DIAGASSERT(buf != NULL);
}
static void
-cvtbase(oldbase,newbase,input,inlen,result,reslen)
- long oldbase;
- int newbase;
- int input[];
- int inlen;
- unsigned char result[];
- int reslen;
+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) {
-/* $NetBSD: compat_ns_ntoa.c,v 1.1 2006/08/26 16:07:01 matt Exp $ */
+/* $NetBSD: compat_ns_ntoa.c,v 1.2 2012/03/20 17:05:59 matt Exp $ */
/*
* Copyright (c) 1986, 1993
#if 0
static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_ns_ntoa.c,v 1.1 2006/08/26 16:07:01 matt Exp $");
+__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 <assert.h>
#include <stdio.h>
-static char *spectHex __P((char *));
+static char *spectHex(char *);
char *
-ns_ntoa(addr)
- struct ns_addr addr;
+ns_ntoa(struct ns_addr addr)
{
static char obuf[40];
- union { union ns_net net_e; u_int32_t long_e; } net;
- u_int16_t port = htons(addr.x_port);
+ union { union ns_net net_e; uint32_t long_e; } net;
+ uint16_t port = htons(addr.x_port);
char *cp;
char *cp2;
- u_int8_t *up = addr.x_host.c_host;
- u_int8_t *uplim = up + 6;
+ 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));
}
static char *
-spectHex(p0)
- char *p0;
+spectHex(char *p0)
{
int ok = 0;
int nonzero = 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
--- /dev/null
+# $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
--- /dev/null
+/* $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 <sys/cdefs.h>
+#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 <sys/types.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <compat/include/stdio.h>
+
+#ifdef __warn_references
+__warn_references(fgetpos,
+ "warning: reference to compatibility fgetpos(); include <stdio.h> 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;
+}
--- /dev/null
+/* $NetBSD: compat_fsetpos.c,v 1.1 2012/01/22 18:36:19 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: fsetpos.c,v 1.10 2003/08/07 16:43:25 agc Exp
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: compat_fsetpos.c,v 1.1 2012/01/22 18:36:19 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#define __LIBC12_SOURCE__
+
+#include "namespace.h"
+#include <sys/types.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <compat/include/stdio.h>
+
+#ifdef __warn_references
+__warn_references(fsetpos,
+ "warning: reference to compatibility fsetpos(); include <stdio.h> for correc t 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;
+}
-# $NetBSD: Makefile.inc,v 1.2 2006/03/11 21:07:18 christos Exp $
+# $NetBSD: Makefile.inc,v 1.3 2012/04/20 17:31:30 christos Exp $
.PATH: ${COMPATDIR}/stdlib
CPPFLAGS+=-I${COMPATDIR}/stdlib -I${COMPATDIR}/../stdlib
-SRCS+=compat_unsetenv.c
+SRCS+=compat_putenv.c compat_unsetenv.c
-/* $NetBSD: localeio_lc_time.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: compat_putenv.c,v 1.2 2012/04/22 15:55:41 christos Exp $ */
-/*
- * Copyright (c) 2008, The NetBSD Foundation, Inc.
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
- *
+ *
* This code is derived from software contributed to The NetBSD Foundation
- * by Brian Ginsbach.
+ * by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio_lc_time.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: compat_putenv.c,v 1.2 2012/04/22 15:55:41 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#include "reentrant.h"
-#include <sys/types.h>
-#include <sys/localedef.h>
-#include <sys/queue.h>
+#define __LIBC12_SOURCE__
+#include "namespace.h"
+
#include <assert.h>
#include <errno.h>
-#include <langinfo.h>
-#include <limits.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <compat/include/stdlib.h>
-#include "setlocale_local.h"
+#include "env.h"
+#include "reentrant.h"
+#include "local.h"
-#include "aliasname_local.h"
-#include "fix_grouping.h"
-#include "localeio.h"
+#ifdef __weak_alias
+__weak_alias(putenv,_putenv)
+#endif
+
+__warn_references(putenv,
+ "warning: reference to compatibility putenv();"
+ " include <stdlib.h> for correct reference")
/*
- * macro required by all template headers
+ * putenv(name) --
+ * This version implicitly copies the string for compatibility.
*/
-#define _PREFIX(name) __CONCAT(_localeio_LC_TIME_, name)
+int
+putenv(char *name)
+{
+ size_t l_name;
+ char *copy;
+ int rv;
-#include "nb_lc_time_misc.h"
-#include "nb_lc_template_decl.h"
+ _DIAGASSERT(name != NULL);
-#define NSTRINGS (sizeof(_TimeLocale)/sizeof(const char **))
+ l_name = __envvarnamelen(name, true);
+ if (l_name == 0) {
+ errno = EINVAL;
+ return -1;
+ }
-static int
-_localeio_LC_TIME_create_impl(const char * __restrict root,
- const char * __restrict name, _TimeLocale ** __restrict pdata)
-{
- char path[PATH_MAX + 1];
+ if ((copy = strdup(name)) == NULL)
+ return -1;
+ copy[l_name++] = '\0';
- _DIAGASSERT(root != NULL);
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(pdata != NULL);
+ rv = setenv(copy, copy + l_name, 1);
- snprintf(path, sizeof(path),
- "%s/%s/LC_TIME", root, name);
- return __loadlocale(path, NSTRINGS, 0, sizeof(_TimeLocale),
- (void *)pdata);
+ free(copy);
+ return rv;
}
-
-#include "nb_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_localeio_LC_TIME_);
-/* $NetBSD: compat___semctl13.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */
+/* $NetBSD: compat___semctl13.c,v 1.3 2011/01/31 22:51:39 christos Exp $ */
-/* $NetBSD: compat___semctl13.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */
+/* $NetBSD: compat___semctl13.c,v 1.3 2011/01/31 22:51:39 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat___semctl13.c,v 1.2 2009/01/11 02:46:26 christos Exp $");
+__RCSID("$NetBSD: compat___semctl13.c,v 1.3 2011/01/31 22:51:39 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#else
semun = va_arg(ap, union __semun);
#endif
+ break;
+ default:
+ break;
}
va_end(ap);
- ds13 = (struct semid_ds13 *)(void *)semun.buf;
- semun.buf = &ds;
+ 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;
+ }
- if (cmd == IPC_SET)
- __semid_ds13_to_native(ds13, &ds);
error = ____semctl50(semid, semnum, cmd, &semun);
if (error)
if (cmd == IPC_STAT)
__native_to_semid_ds13(&ds, ds13);
-
- semun.buf = (struct semid_ds *)(void *)ds13;
return 0;
}
-/* $NetBSD: compat_getdents.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: compat_getdents.c,v 1.6 2012/03/13 22:24:48 joerg Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_getdents.c,v 1.3 2008/04/28 20:22:59 martin Exp $");
+__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 <sys/types.h>
+#include <assert.h>
#include <dirent.h>
+#include <stddef.h>
#include <compat/include/dirent.h>
#include <string.h>
{
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;
for (; ndp < endp; ndp = nndp) {
nndp = _DIRENT_NEXT(ndp);
/* XXX: avoid unaligned 64-bit access on sparc64 */
- odp->d_ino = ((u_int32_t *)(void *)&ndp->d_ino)[_QUAD_LOWWORD];
+ /* 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_type = ndp->d_type;
(void)memcpy(odp->d_name, ndp->d_name, (size_t)odp->d_namlen);
odp->d_name[odp->d_namlen] = '\0';
- odp->d_reclen = _DIRENT_SIZE(odp);
+ len = _DIRENT_SIZE(odp);
+ _DIAGASSERT(__type_fit(uint16_t, len));
+ odp->d_reclen = (uint16_t)len;
odp = _DIRENT_NEXT(odp);
}
- return ((char *)(void *)odp) - buf;
+ ptrdiff_t td = (((char *)(void *)odp) - buf);
+ _DIAGASSERT(__type_fit(int, td));
+ return (int)td;
}
-/* $NetBSD: compat_getdirentries.c,v 1.2 2009/02/22 06:33:38 dholland Exp $ */
+/* $NetBSD: compat_getdirentries.c,v 1.3 2012/03/20 17:06:00 matt Exp $ */
/*
* Copyright (c) 1997 Frank van der Linden
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_getdirentries.c,v 1.2 2009/02/22 06:33:38 dholland Exp $");
+__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__
"reference to compatibility-only getdirentries(); this will break; use getdents() or readdir() instead")
int
-getdirentries(fd, buf, nbytes, basep)
- int fd, nbytes;
- char *buf;
- long *basep;
+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);
-/* $NetBSD: compat_msync.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_msync.c,v 1.2 2012/03/20 17:06:00 matt Exp $ */
/*
* Copyright (c) 1997 Frank van der Linden
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_msync.c,v 1.1 2005/09/13 01:44:09 christos Exp $");
+__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__
"warning: reference to compatibility msync(); include <sys/mman.h> for correct reference")
int
-msync(addr, size)
- void *addr;
- size_t size;
+msync(void *addr, size_t size)
{
return __msync13(addr, size, MS_SYNC|MS_INVALIDATE);
}
-/* $NetBSD: compat_semctl.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */
+/* $NetBSD: compat_semctl.c,v 1.3 2011/01/31 22:51:39 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Christopher G. Demetriou
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_semctl.c,v 1.2 2009/01/11 02:46:26 christos Exp $");
+__RCSID("$NetBSD: compat_semctl.c,v 1.3 2011/01/31 22:51:39 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#define __LIBC12_SOURCE__
va_list ap;
union __semun semun;
struct semid_ds ds;
- struct semid_ds14 *ds14 = NULL;
+ struct semid_ds14 *ds14;
int error;
va_start(ap, cmd);
#else
semun = va_arg(ap, union __semun);
#endif
+ break;
+ default:
+ break;
}
va_end(ap);
switch (cmd) {
case IPC_SET:
case IPC_STAT:
- ds14 = (struct semid_ds14 *)(void *)semun.buf;
+ 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);
- switch (cmd) {
- case IPC_SET:
- case IPC_STAT:
- semun.buf = (struct semid_ds *)(void *)ds14;
- if (cmd == IPC_STAT && error == 0)
- __native_to_semid_ds14(&ds, ds14);
- break;
- }
- return error;
+ if (error)
+ return error;
+
+ if (cmd == IPC_STAT)
+ __native_to_semid_ds14(&ds, ds14);
+ return 0;
}
-/* $NetBSD: compat_sigaltstack.c,v 1.3 2009/01/11 02:46:26 christos Exp $ */
+/* $NetBSD: compat_sigaltstack.c,v 1.5 2012/03/20 17:06:00 matt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_sigaltstack.c,v 1.3 2009/01/11 02:46:26 christos Exp $");
+__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 <stddef.h>
int
-sigaltstack(onss, ooss)
- const struct sigaltstack13 *onss;
- struct sigaltstack13 *ooss;
+sigaltstack(const struct sigaltstack13 *onss, struct sigaltstack13 *ooss)
{
stack_t nss, oss;
int error;
if (oss.ss_size > INT_MAX)
ooss->ss_size = INT_MAX;
else
- ooss->ss_size = oss.ss_size;
+ ooss->ss_size = (int)oss.ss_size;
ooss->ss_flags = oss.ss_flags;
}
-/* $NetBSD: compat_localtime.c,v 1.2 2009/01/11 03:46:25 christos Exp $ */
+/* $NetBSD: compat_localtime.c,v 1.3 2011/02/21 22:07:44 christos Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
#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)
__warn_references(ctime_r,
"warning: reference to compatibility ctime_r();"
" include <time.h> for correct reference")
+__warn_references(ctime_rz,
+ "warning: reference to compatibility ctime_rz();"
+ " include <time.h> for correct reference")
__warn_references(gmtime_r,
"warning: reference to compatibility gmtime_r();"
" include <time.h> for correct reference")
__warn_references(localtime_r,
"warning: reference to compatibility localtime_r();"
" include <time.h> for correct reference")
+__warn_references(localtime_rz,
+ "warning: reference to compatibility localtime_rz();"
+ " include <time.h> for correct reference")
+__warn_references(mktime_z,
+ "warning: reference to compatibility mktime_z();"
+ " include <time.h> for correct reference")
__warn_references(offtime,
"warning: reference to compatibility offtime();"
" include <time.h> for correct reference")
__warn_references(posix2time,
"warning: reference to compatibility posix2time();"
" include <time.h> for correct reference")
+__warn_references(posix2time_z,
+ "warning: reference to compatibility posix2time_z();"
+ " include <time.h> for correct reference")
__warn_references(time2posix,
"warning: reference to compatibility time2posix();"
" include <time.h> for correct reference")
-/* $NetBSD: bt_debug.c,v 1.15 2008/09/10 17:52:35 joerg Exp $ */
+/* $NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_debug.c,v 1.15 2008/09/10 17:52:35 joerg Exp $");
+__RCSID("$NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $");
#include <assert.h>
#include <stdio.h>
}
}
+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
*
if (bl->flags & P_BIGKEY)
(void)fprintf(stderr,
"big key page %lu size %u/",
- (unsigned long) *(pgno_t *)(void *)bl->bytes,
- *(uint32_t *)(void *)(bl->bytes + sizeof(pgno_t)));
+ (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) *(pgno_t *)(void *)(bl->bytes + bl->ksize),
- *(uint32_t *)(void *)(bl->bytes + bl->ksize +
+ (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",
if (rl->flags & P_BIGDATA)
(void)fprintf(stderr,
"big data page %lu size %u",
- (unsigned long) *(pgno_t *)(void *)rl->bytes,
- *(uint32_t *)(void *)(rl->bytes + sizeof(pgno_t)));
+ (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);
-/* $NetBSD: bt_open.c,v 1.24 2008/09/11 12:58:00 joerg Exp $ */
+/* $NetBSD: bt_open.c,v 1.26 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_open.c,v 1.24 2008/09/11 12:58:00 joerg Exp $");
+__RCSID("$NetBSD: bt_open.c,v 1.26 2012/03/13 21:13:32 christos Exp $");
/*
* Implementation of btree access method for 4.4BSD.
b.psize = MINIX_ST_BLKSIZE;
} else
#endif
- b.psize = sb.st_blksize;
-
+ b.psize = sb.st_blksize;
if (b.psize < MINPSIZE)
b.psize = MINPSIZE;
if (b.psize > MAX_PAGE_OFFSET + 1)
(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))
- t->bt_ovflsize =
- NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t);
+ 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 =
tmp(void)
{
sigset_t set, oset;
- size_t len;
+ int len;
int fd;
char *envtmp;
char path[PATH_MAX];
len = snprintf(path,
sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : _PATH_TMP);
- if (len >= sizeof(path))
+ if (len < 0 || (size_t)len >= sizeof(path)) {
+ errno = ENAMETOOLONG;
return -1;
+ }
(void)sigfillset(&set);
(void)sigprocmask(SIG_BLOCK, &set, &oset);
-/* $NetBSD: bt_overflow.c,v 1.16 2008/09/11 12:58:00 joerg Exp $ */
+/* $NetBSD: bt_overflow.c,v 1.18 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_overflow.c,v 1.16 2008/09/11 12:58:00 joerg Exp $");
+__RCSID("$NetBSD: bt_overflow.c,v 1.18 2012/03/13 21:13:32 christos Exp $");
#include "namespace.h"
#include <sys/param.h>
uint32_t sz, nb, plen;
size_t temp;
- memmove(&pg, p, sizeof(pgno_t));
+ memmove(&pg, p, sizeof(pg));
memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(uint32_t));
*ssz = sz;
#endif
/* Make the buffer bigger as necessary. */
if (*bufsz < sz) {
- *buf = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz));
+ *buf = (*buf == NULL ? malloc(sz) : realloc(*buf, sz));
if (*buf == NULL)
return (RET_ERROR);
*bufsz = sz;
p = dbt->data;
temp = dbt->size;
_DBFIT(temp, uint32_t);
- sz = temp;
+ sz = (uint32_t)temp;
for (;; p = (char *)p + plen, last = h) {
if ((h = __bt_new(t, &npg)) == NULL)
return (RET_ERROR);
uint32_t sz, plen;
size_t temp;
- (void)memmove(&pg, p, sizeof(pgno_t));
+ (void)memmove(&pg, p, sizeof(pg));
(void)memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(uint32_t));
#ifdef DEBUG
-/* $NetBSD: bt_put.c,v 1.19 2009/02/12 06:40:14 lukem Exp $ */
+/* $NetBSD: bt_put.c,v 1.20 2011/06/26 22:20:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_put.c,v 1.19 2009/02/12 06:40:14 lukem Exp $");
+__RCSID("$NetBSD: bt_put.c,v 1.20 2011/06/26 22:20:31 christos Exp $");
#include "namespace.h"
#include <sys/types.h>
return (RET_ERROR);
tkey.data = kb;
tkey.size = NOVFLSIZE;
- memmove(kb, &pg, sizeof(pgno_t));
+ memmove(kb, &pg, sizeof(pg));
memmove(kb + sizeof(pgno_t),
&key->size, sizeof(uint32_t));
dflags |= P_BIGKEY;
return (RET_ERROR);
tdata.data = db;
tdata.size = NOVFLSIZE;
- memmove(db, &pg, sizeof(pgno_t));
+ memmove(db, &pg, sizeof(pg));
_DBFIT(data->size, uint32_t);
temp = (uint32_t)data->size;
(void)memmove(db + sizeof(pgno_t),
-/* $NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $ */
+/* $NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $");
+__RCSID("$NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $");
#include "namespace.h"
#include <sys/types.h>
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 &&
- bt_preserve(t, *(pgno_t *)(void *)bl->bytes) ==
- RET_ERROR)
- goto err1;
+ 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:
/*
* 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 &&
- bt_preserve(t, *(pgno_t *)(void *)bl->bytes) == RET_ERROR)
- return (RET_ERROR);
+ 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);
-/* $NetBSD: hash.c,v 1.31 2009/02/12 06:35:54 lukem Exp $ */
+/* $NetBSD: hash.c,v 1.32 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hash.c,v 1.31 2009/02/12 06:35:54 lukem Exp $");
+__RCSID("$NetBSD: hash.c,v 1.32 2012/03/13 21:13:32 christos Exp $");
#include "namespace.h"
#include <sys/param.h>
dbp->sync = hash_sync;
dbp->type = DB_HASH;
-#ifdef DEBUG
+#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:",
hashp->BSIZE = MIN(MINIX_ST_BLKSIZE, MAX_BSIZE);
} else
#endif
- hashp->BSIZE = MIN(statbuf.st_blksize, MAX_BSIZE);
-
+ hashp->BSIZE = MIN(statbuf.st_blksize, MAX_BSIZE);
hashp->BSHIFT = __log2((uint32_t)hashp->BSIZE);
}
dirsize = hashp->DSIZE * sizeof(SEGMENT *);
if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1))
return (-1);
- hashp->DSIZE = dirsize << 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)
-/* $NetBSD: hash_bigkey.c,v 1.23 2009/02/12 06:33:13 lukem Exp $ */
+/* $NetBSD: hash_bigkey.c,v 1.24 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hash_bigkey.c,v 1.23 2009/02/12 06:33:13 lukem Exp $");
+__RCSID("$NetBSD: hash_bigkey.c,v 1.24 2012/03/13 21:13:32 christos Exp $");
/*
* PACKAGE: hash
_DBFIT(temp, uint16_t);
space = (uint16_t)temp;
while (key_size) {
- move_bytes = MIN(space, 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;
if (!key_size) {
space = FREESPACE(p);
if (space) {
- move_bytes = MIN(space, val_size);
+ 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
_DBFIT(temp, uint16_t);
space = (uint16_t)temp;
while (val_size) {
- move_bytes = MIN(space, 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.
-/* $NetBSD: hash_page.c,v 1.23 2008/09/11 12:58:00 joerg Exp $ */
+/* $NetBSD: hash_page.c,v 1.25 2012/03/13 21:13:33 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hash_page.c,v 1.23 2008/09/11 12:58:00 joerg Exp $");
+__RCSID("$NetBSD: hash_page.c,v 1.25 2012/03/13 21:13:33 christos Exp $");
/*
* PACKAGE: hashing
#define PAGE_INIT(P) { \
((uint16_t *)(void *)(P))[0] = 0; \
temp = 3 * sizeof(uint16_t); \
- _DIAGASSERT(hashp->BSIZE >= temp); \
+ _DIAGASSERT((size_t)hashp->BSIZE >= temp); \
((uint16_t *)(void *)(P))[1] = (uint16_t)(hashp->BSIZE - temp); \
((uint16_t *)(void *)(P))[2] = hashp->BSIZE; \
}
sigset_t set, oset;
char *envtmp;
char namestr[PATH_MAX];
+ int len;
if (issetugid())
envtmp = NULL;
else
envtmp = getenv("TMPDIR");
- if (-1 == snprintf(namestr, sizeof(namestr), "%s/_hashXXXXXX",
- envtmp ? envtmp : _PATH_TMP))
+ len = snprintf(namestr, sizeof(namestr), "%s/_hashXXXXXX",
+ envtmp ? envtmp : _PATH_TMP);
+ if (len < 0 || (size_t)len >= sizeof(namestr)) {
+ errno = ENAMETOOLONG;
return -1;
+ }
/* Block signals; make sure file goes away at process exit. */
(void)sigfillset(&set);
-/* $NetBSD: ndbmdatum.c,v 1.4 2008/09/11 12:58:00 joerg Exp $ */
+/* $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 */
/*-
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ndbmdatum.c,v 1.4 2008/09/11 12:58:00 joerg Exp $");
+__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
#include <ndbm.h>
#include "hash.h"
+#ifndef datum_truncate
+#define datum_truncate(a) (a)
+#endif
/*
* Returns:
* DATUM on success
dbtretdata.size = 0;
}
retdata.dptr = dbtretdata.data;
- retdata.dsize = dbtretdata.size;
+ retdata.dsize = datum_truncate(dbtretdata.size);
return (retdata);
}
if (status)
dbtretkey.data = NULL;
retkey.dptr = dbtretkey.data;
- retkey.dsize = dbtretkey.size;
+ retkey.dsize = datum_truncate(dbtretkey.size);
return (retkey);
}
if (status)
dbtretkey.data = NULL;
retkey.dptr = dbtretkey.data;
- retkey.dsize = dbtretkey.size;
+ retkey.dsize = datum_truncate(dbtretkey.size);
return (retkey);
}
-.\" $NetBSD: btree.3,v 1.12 2010/03/22 19:30:53 joerg Exp $
+.\" $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.
.Xr hash 3 ,
.Xr mpool 3 ,
.Xr recno 3
-.Pp
.Rs
.%T "The Ubiquitous B-tree"
.%A "Douglas Comer"
-/* $NetBSD: rec_open.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */
+/* $NetBSD: rec_open.c,v 1.19 2011/06/26 22:27:14 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: rec_open.c,v 1.17 2008/09/11 12:58:00 joerg Exp $");
+__RCSID("$NetBSD: rec_open.c,v 1.19 2011/06/26 22:27:14 christos Exp $");
#include "namespace.h"
#include <sys/types.h>
dbp = NULL;
/* Open the user's file -- if this fails, we're done. */
if (fname != NULL) {
- if ((rfd = open(fname, flags, mode)) == -1)
- return (NULL);
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+ if ((rfd = open(fname, flags | O_CLOEXEC, mode)) == -1)
+ return NULL;
+#if O_CLOEXEC == 0
if (fcntl(rfd, F_SETFD, FD_CLOEXEC) == -1)
goto err;
+#endif
}
/* Create a btree in memory (backed by disk). */
-/* $NetBSD: rec_put.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */
+/* $NetBSD: rec_put.c,v 1.19 2011/06/26 22:18:16 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: rec_put.c,v 1.17 2008/09/11 12:58:00 joerg Exp $");
+__RCSID("$NetBSD: rec_put.c,v 1.19 2011/06/26 22:18:16 christos Exp $");
#include "namespace.h"
#include <sys/types.h>
if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS)
return (status);
- if (flags == R_SETCURSOR)
+ 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));
return (RET_ERROR);
tdata.data = db;
tdata.size = NOVFLSIZE;
- *(pgno_t *)(void *)db = pg;
+ memcpy(db, &pg, sizeof(pg));
_DBFIT(data->size, uint32_t);
*(uint32_t *)(void *)(db + sizeof(pgno_t)) =
(uint32_t)data->size;
-/* $NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $ */
+/* $NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $ */
/*
* Copyright (c) 2000 Takuya SHIOZAKI
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $");
+__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 <sys/atomic.h>
+#include <assert.h>
+#include <elf.h>
+#include <errno.h>
+#include <string.h>
+#include <stdbool.h>
#undef dlopen
#undef dlclose
#define dlopen ___dlopen
#define dlclose ___dlclose
#define dlsym ___dlsym
+#define dlvsym ___dlvsym
#define dlerror ___dlerror
#define dladdr ___dladdr
#define dlinfo ___dlinfo
__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(__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)
return NULL;
}
+/*ARGSUSED*/
+void *
+dlvsym(void *handle, const char *name, const char *version)
+{
+
+ return NULL;
+}
+
/*ARGSUSED*/
__aconst char *
-dlerror()
+dlerror(void)
{
return dlfcn_error;
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)
{
-
- return 0;
+ 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();
+ membar_producer();
+ 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);
}
-$NetBSD: README,v 1.1.1.1 2006/01/25 15:18:40 kleink Exp $
-
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
whose sum is the desired value
For decimal -> binary conversions, there are three families of
-helper routines: one for round-nearest:
+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
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".
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 ".").
-/* $NetBSD: arithchk.c,v 1.3 2010/01/17 23:06:31 wiz Exp $ */
+/* $NetBSD: arithchk.c,v 1.4 2012/06/24 15:26:03 christos Exp $ */
/****************************************************************
Copyright (C) 1997, 1998 Lucent Technologies
#include <stdio.h>
- static int dalign;
- typedef struct
+static int dalign;
+typedef struct
Akind {
char *name;
int kind;
} Akind;
- static 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()
+static Akind *
+Lcheck(void)
{
union {
double d;
return 0;
}
- static Akind *
-icheck()
+static Akind *
+icheck(void)
{
union {
double d;
char *emptyfmt = ""; /* avoid possible warning message with printf("") */
- static Akind *
-ccheck()
+static Akind *
+ccheck(void)
{
union {
double d;
return 0;
}
- static int
-fzcheck()
+static int
+fzcheck(void)
{
double a, b;
int i;
return b == 0.;
}
- int
-main()
+int
+main(void)
{
Akind *a = 0;
int Ldef = 0;
-/* $NetBSD: dtoa.c,v 1.5 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: dtoa.c,v 1.10 2012/05/16 17:48:59 alnsn Exp $ */
/****************************************************************
*/
#ifdef Honor_FLT_ROUNDS
-#define Rounding rounding
#undef Check_FLT_ROUNDS
#define Check_FLT_ROUNDS
#else
char *
dtoa
#ifdef KR_headers
- (d, mode, ndigits, decpt, sign, rve)
- double d; int mode, ndigits, *decpt, *sign; char **rve;
+ (d0, mode, ndigits, decpt, sign, rve)
+ double d0; int mode, ndigits, *decpt, *sign; char **rve;
#else
- (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
+ (double d0, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
{
/* Arguments ndigits, decpt, sign are similar to those
#endif
Bigint *b, *b1, *delta, *mhi, *S;
Bigint *mlo = NULL; /* pacify gcc */
- double d2, ds, eps;
+ U d, d2, eps;
+ double ds;
char *s, *s0;
-#ifdef Honor_FLT_ROUNDS
- int rounding;
-#endif
#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) {
dtoa_result = 0;
}
#endif
-
- if (word0(d) & Sign_bit) {
+ 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 */
+ 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)
+ if ((word0(&d) & Exp_mask) == Exp_mask)
#else
- if (word0(d) == 0x8000)
+ if (word0(&d) == 0x8000)
#endif
{
/* Infinity or NaN */
*decpt = 9999;
#ifdef IEEE_Arith
- if (!word1(d) && !(word0(d) & 0xfffff))
+ 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 */
+ dval(&d) += 0; /* normalize */
#endif
- if (!dval(d)) {
+ if (!dval(&d)) {
*decpt = 1;
return nrv_alloc("0", rve, 1);
}
inexact = 1;
#endif
#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
+ if (Rounding >= 2) {
if (*sign)
- rounding = rounding == 2 ? 0 : 2;
+ Rounding = Rounding == 2 ? 0 : 2;
else
- if (rounding != 2)
- rounding = 0;
+ if (Rounding != 2)
+ Rounding = 0;
}
#endif
- b = d2b(dval(d), &be, &bbits);
+ b = d2b(dval(&d), &be, &bbits);
if (b == NULL)
return NULL;
#ifdef Sudden_Underflow
- i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
+ i = (int)(word0(&d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
#else
- if (( i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)) )!=0) {
+ 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;
+ 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;
+ 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)
+ * log10(&d) = (i-Bias)*log(2)/log(10) + log10(&d2)
*
- * This suggests computing an approximation k to log10(d) by
+ * This suggests computing an approximation k to log10(&d) by
*
* k = (i - Bias)*0.301029995663981
* + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
/* 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 */
+ 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;
+ 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])
+ if (dval(&d) < tens[k])
k--;
k_check = 0;
}
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:
- ilim = ilim1 = -1;
i = 18;
ndigits = 0;
break;
return NULL;
#ifdef Honor_FLT_ROUNDS
- if (mode > 1 && rounding != 1)
+ if (mode > 1 && Rounding != 1)
leftright = 0;
#endif
/* Try to get by with floating-point arithmetic. */
i = 0;
- dval(d2) = dval(d);
+ dval(&d2) = dval(&d);
k0 = k;
ilim0 = ilim;
ieps = 2; /* conservative */
if (j & Bletch) {
/* prevent overflows */
j &= Bletch - 1;
- dval(d) /= bigtens[n_bigtens-1];
+ dval(&d) /= bigtens[n_bigtens-1];
ieps++;
}
for(; j; j = (unsigned int)j >> 1, i++)
ieps++;
ds *= bigtens[i];
}
- dval(d) /= ds;
+ dval(&d) /= ds;
}
else if (( jj1 = -k )!=0) {
- dval(d) *= tens[jj1 & 0xf];
+ dval(&d) *= tens[jj1 & 0xf];
for(j = jj1 >> 4; j; j >>= 1, i++)
if (j & 1) {
ieps++;
- dval(d) *= bigtens[i];
+ dval(&d) *= bigtens[i];
}
}
- if (k_check && dval(d) < 1. && ilim > 0) {
+ if (k_check && dval(&d) < 1. && ilim > 0) {
if (ilim1 <= 0)
goto fast_failed;
ilim = ilim1;
k--;
- dval(d) *= 10.;
+ dval(&d) *= 10.;
ieps++;
}
- dval(eps) = ieps*dval(d) + 7.;
- word0(eps) -= (P-1)*Exp_msk1;
+ 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))
+ dval(&d) -= 5.;
+ if (dval(&d) > dval(&eps))
goto one_digit;
- if (dval(d) < -dval(eps))
+ if (dval(&d) < -dval(&eps))
goto no_digits;
goto fast_failed;
}
/* Use Steele & White method of only
* generating digits needed.
*/
- dval(eps) = 0.5/tens[ilim-1] - dval(eps);
+ dval(&eps) = 0.5/tens[ilim-1] - dval(&eps);
for(i = 0;;) {
- L = dval(d);
- dval(d) -= L;
+ L = dval(&d);
+ dval(&d) -= L;
*s++ = '0' + (int)L;
- if (dval(d) < dval(eps))
+ if (dval(&d) < dval(&eps))
goto ret1;
- if (1. - dval(d) < dval(eps))
+ if (1. - dval(&d) < dval(&eps))
goto bump_up;
if (++i >= ilim)
break;
- dval(eps) *= 10.;
- dval(d) *= 10.;
+ 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))
+ 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))
+ if (dval(&d) > 0.5 + dval(&eps))
goto bump_up;
- else if (dval(d) < 0.5 - dval(eps)) {
+ else if (dval(&d) < 0.5 - dval(&eps)) {
while(*--s == '0');
s++;
goto ret1;
#endif
fast_failed:
s = s0;
- dval(d) = dval(d2);
+ dval(&d) = dval(&d2);
k = k0;
ilim = ilim0;
}
ds = tens[k];
if (ndigits < 0 && ilim <= 0) {
S = mhi = 0;
- if (ilim < 0 || dval(d) <= 5*ds)
+ 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;
+ 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) {
+ if (dval(&d) < 0) {
L--;
- dval(d) += ds;
+ dval(&d) += ds;
}
#endif
*s++ = '0' + (int)L;
- if (!dval(d)) {
+ if (!dval(&d)) {
#ifdef SET_INEXACT
inexact = 0;
#endif
if (i == ilim) {
#ifdef Honor_FLT_ROUNDS
if (mode > 1)
- switch(rounding) {
+ switch(Rounding) {
case 0: goto ret1;
case 2: goto bump_up;
}
#endif
- dval(d) += dval(d);
- if (dval(d) > ds || (dval(d) == ds && L & 1)) {
+ 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) {
Bfree(b);
b = b1;
}
- if (( j = b5 - m5 )!=0)
+ if (( j = b5 - m5 )!=0) {
b = pow5mult(b, j);
if (b == NULL)
return NULL;
+ }
}
- else
+ else {
b = pow5mult(b, b5);
if (b == NULL)
return NULL;
+ }
}
S = i2b(1);
if (S == NULL)
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
+ && Rounding == 1
#endif
) {
- if (!word1(d) && !(word0(d) & Bndry_mask)
+ if (!word1(&d) && !(word0(&d) & Bndry_mask)
#ifndef Sudden_Underflow
- && word0(d) & (Exp_mask & ~Exp_msk1)
+ && word0(&d) & (Exp_mask & ~Exp_msk1)
#endif
) {
/* The special case */
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--;
mhi = multadd(mhi, 10, 0);
if (mhi == NULL)
return NULL;
- }
+ }
ilim = ilim1;
}
}
mhi = lshift(mhi, m2);
if (mhi == NULL)
return NULL;
- }
+ }
/* Compute mlo -- check for special case
* that d is a normalized power of 2.
jj1 = delta->sign ? 1 : cmp(b, delta);
Bfree(delta);
#ifndef ROUND_BIASED
- if (jj1 == 0 && mode != 1 && !(word1(d) & 1)
+ if (jj1 == 0 && mode != 1 && !(word1(&d) & 1)
#ifdef Honor_FLT_ROUNDS
- && rounding >= 1
+ && Rounding >= 1
#endif
) {
if (dig == '9')
#endif
if (j < 0 || (j == 0 && mode != 1
#ifndef ROUND_BIASED
- && !(word1(d) & 1)
+ && !(word1(&d) & 1)
#endif
)) {
if (!b->x[0] && b->wds <= 1) {
}
#ifdef Honor_FLT_ROUNDS
if (mode > 1)
- switch(rounding) {
+ switch(Rounding) {
case 0: goto accept_dig;
case 2: goto keep_dig;
}
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;
}
}
if (jj1 > 0) {
#ifdef Honor_FLT_ROUNDS
- if (!rounding)
+ if (!Rounding)
goto accept_dig;
#endif
if (dig == '9') { /* possible if i == 1 */
/* Round off last digit */
#ifdef Honor_FLT_ROUNDS
- switch(rounding) {
+ switch(Rounding) {
case 0: goto trimzeros;
case 2: goto roundoff;
}
#endif
b = lshift(b, 1);
j = cmp(b, S);
- if (j > 0 || (j == 0 && dig & 1)) {
+#ifdef ROUND_BIASED
+ if (j >= 0)
+#else
+ if (j > 0 || (j == 0 && dig & 1))
+#endif
+ {
roundoff:
while(*--s == '9')
if (s == s0) {
#ifdef SET_INEXACT
if (inexact) {
if (!oldinexact) {
- word0(d) = Exp_1 + (70 << Exp_shift);
- word1(d) = 0;
- dval(d) += 1.;
+ word0(&d) = Exp_1 + (70 << Exp_shift);
+ word1(&d) = 0;
+ dval(&d) += 1.;
}
}
else if (!oldinexact)
-/* $NetBSD: g_Qfmt.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_Qfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char*
#ifdef KR_headers
-g_Qfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+g_Qfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
-g_Qfmt(char *buf, void *V, int ndig, unsigned bufsize)
+g_Qfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
- static FPI fpi = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0 };
+ 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;
return 0;
mode = 0;
}
- s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+ s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
if (s == NULL)
return NULL;
- return g__fmt(buf, s, se, decpt, sign);
+ return g__fmt(buf, s, se, decpt, sign, bufsize);
}
-/* $NetBSD: g__fmt.c,v 1.1.1.1 2006/01/25 15:18:41 kleink Exp $ */
-
/****************************************************************
The author of this software is David M. Gay.
char *
#ifdef KR_headers
-g__fmt(b, s, se, decpt, sign) char *b; char *s; char *se; int decpt; ULong sign;
+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)
+g__fmt(char *b, char *s, char *se, int decpt, ULong sign, size_t blen)
#endif
{
int i, j, k;
- char *s0 = s;
+ char *be, *s0;
+ size_t len;
#ifdef USE_LOCALE
- char decimalpoint = *localeconv()->decimal_point;
+#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 decimalpoint '.'
+#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) {
- *b++ = decimalpoint;
+#ifdef USE_LOCALE
+ while((*b = *decimalpoint++))
+ ++b;
+#else
+ *b++ = '.';
+#endif
while((*b = *s++) !=0)
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;
*b = 0;
}
else if (decpt <= 0) {
- *b++ = decimalpoint;
+#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)
+ while((*b = *s++) != 0)
b++;
}
else {
- while((*b = *s++) !=0) {
+ while((*b = *s++) != 0) {
b++;
- if (--decpt == 0 && *s)
- *b++ = decimalpoint;
+ 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;
}
-/* $NetBSD: g_ddfmt.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_ddfmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char *
#ifdef KR_headers
-g_ddfmt(buf, dd, ndig, bufsize) char *buf; double *dd; int ndig; unsigned bufsize;
+g_ddfmt(buf, dd0, ndig, bufsize) char *buf; double *dd0; int ndig; size_t bufsize;
#else
-g_ddfmt(char *buf, double *dd, int ndig, unsigned bufsize)
+g_ddfmt(char *buf, double *dd0, int ndig, size_t bufsize)
#endif
{
FPI fpi;
ULong *L, bits0[4], *bits, *zx;
int bx, by, decpt, ex, ey, i, j, mode;
Bigint *x, *y, *z;
- double ddx[2];
+ 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;
- L = (ULong*)dd;
+ dd = (U*)dd0;
+ L = dd->L;
if ((L[_0] & 0x7ff00000L) == 0x7ff00000L) {
/* Infinity or NaN */
if (L[_0] & 0xfffff || L[_1]) {
goto nanret;
goto infret;
}
- if (dd[0] + dd[1] == 0.) {
+ if (dval(&dd[0]) + dval(&dd[1]) == 0.) {
b = buf;
#ifndef IGNORE_ZERO_SIGN
if (L[_0] & L[2+_0] & 0x80000000L)
return b;
}
if ((L[_0] & 0x7ff00000L) < (L[2+_0] & 0x7ff00000L)) {
- ddx[1] = dd[0];
- ddx[0] = dd[1];
+ dval(&ddx[1]) = dval(&dd[0]);
+ dval(&ddx[0]) = dval(&dd[1]);
dd = ddx;
- L = (ULong*)dd;
+ L = dd->L;
}
- z = d2b(dd[0], &ex, &bx);
+ z = d2b(dval(&dd[0]), &ex, &bx);
if (z == NULL)
return NULL;
- if (dd[1] == 0.)
+ if (dval(&dd[1]) == 0.)
goto no_y;
x = z;
- y = d2b(dd[1], &ey, &by);
+ y = d2b(dval(&dd[1]), &ey, &by);
if (y == NULL)
return NULL;
if ( (i = ex - ey) !=0) {
}
fpi.emin = 1-1023-53+1;
fpi.emax = 2046-1023-106+1;
- fpi.rounding = FPI_Round_near;
+ 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);
+ b = g__fmt(buf, s, se, decpt, z->sign, bufsize);
if (b == NULL)
return NULL;
Bfree(z);
-/* $NetBSD: g_dfmt.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_dfmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char*
#ifdef KR_headers
-g_dfmt(buf, d, ndig, bufsize) char *buf; double *d; int ndig; unsigned bufsize;
+g_dfmt(buf, d, ndig, bufsize) char *buf; double *d; int ndig; size_t bufsize;
#else
-g_dfmt(char *buf, double *d, int ndig, unsigned bufsize)
+g_dfmt(char *buf, double *d, int ndig, size_t bufsize)
#endif
{
- static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0 };
+ 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;
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");
}
ex = 1;
ex -= 0x3ff + 52;
mode = 2;
- if (ndig <= 0) {
- if (bufsize < 25)
- return 0;
+ if (ndig <= 0)
mode = 0;
- }
i = STRTOG_Normal;
- s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+ 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);
+ return g__fmt(buf, s, se, decpt, sign, bufsize);
}
-/* $NetBSD: g_ffmt.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_ffmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char*
#ifdef KR_headers
-g_ffmt(buf, f, ndig, bufsize) char *buf; float *f; int ndig; unsigned bufsize;
+g_ffmt(buf, f, ndig, bufsize) char *buf; float *f; int ndig; size_t bufsize;
#else
-g_ffmt(char *buf, float *f, int ndig, unsigned bufsize)
+g_ffmt(char *buf, float *f, int ndig, size_t bufsize)
#endif
{
- static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, 0 };
+ 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;
mode = 0;
}
i = STRTOG_Normal;
- s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+ s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
if (s == NULL)
return NULL;
- return g__fmt(buf, s, se, decpt, sign);
+ return g__fmt(buf, s, se, decpt, sign, bufsize);
}
-/* $NetBSD: g_xLfmt.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_xLfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char*
#ifdef KR_headers
-g_xLfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+g_xLfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
-g_xLfmt(char *buf, void *V, int ndig, unsigned bufsize)
+g_xLfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
- static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+ 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;
return 0;
mode = 0;
}
- s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+ s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
if (s == NULL)
return NULL;
- return g__fmt(buf, s, se, decpt, sign);
+ return g__fmt(buf, s, se, decpt, sign, bufsize);
}
-/* $NetBSD: g_xfmt.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: g_xfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
char*
#ifdef KR_headers
-g_xfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+g_xfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
-g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
+g_xfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
- static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+ 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;
return 0;
mode = 0;
}
- s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+ s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
if (s == NULL)
return NULL;
- return g__fmt(buf, s, se, decpt, sign);
+ return g__fmt(buf, s, se, decpt, sign, bufsize);
}
-/* $NetBSD: gdtoa.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: gdtoa.c,v 1.6 2012/03/13 21:13:33 christos Exp $ */
/****************************************************************
*x++ = (*bits >> 16) & ALL_ON;
#endif
} while(++bits <= be);
- i = x - x0;
+ ptrdiff_t td = x - x0;
+ _DIAGASSERT(__type_fit(int, td));
+ i = (int)td;
while(!x0[--i])
if (!i) {
b->wds = 0;
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
int rdir, s2, s5, spec_case, try_quick;
Long L;
Bigint *b, *b1, *delta, *mlo, *mhi, *mhi1, *S;
- double d, d2, ds, eps;
+ double d2, ds;
char *s, *s0;
+ U d, eps;
#ifndef MULTIPLE_THREADS
if (dtoa_result) {
return nrv_alloc("0", rve, 1);
}
- dval(d) = b2d(b, &i);
+ dval(&d) = b2d(b, &i);
i = be + bbits - 1;
- word0(d) &= Frac_mask1;
- word0(d) |= Exp_11;
+ word0(&d) &= Frac_mask1;
+ word0(&d) |= Exp_11;
#ifdef IBM
- if ( (j = 11 - hi0bits(word0(d) & Frac_mask)) !=0)
- dval(d) /= 1 << j;
+ 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)
+ * log10(&d) = (i-Bias)*log(2)/log(10) + log10(d2)
*
- * This suggests computing an approximation k to log10(d) by
+ * This suggests computing an approximation k to log10(&d) by
*
* k = (i - Bias)*0.301029995663981
* + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
i <<= 2;
i += j;
#endif
- ds = (dval(d)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
+ ds = (dval(&d)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
/* correct assumption about exponent range */
if ((j = i) < 0)
#ifdef IBM
j = be + bbits - 1;
if ( (jj1 = j & 3) !=0)
- dval(d) *= 1 << jj1;
- word0(d) += j << Exp_shift - 2 & Exp_mask;
+ dval(&d) *= 1 << jj1;
+ word0(&d) += j << Exp_shift - 2 & Exp_mask;
#else
- word0(d) += (be + bbits - 1) << Exp_shift;
+ word0(&d) += (be + bbits - 1) << Exp_shift;
#endif
if (k >= 0 && k <= Ten_pmax) {
- if (dval(d) < tens[k])
+ if (dval(&d) < tens[k])
k--;
k_check = 0;
}
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:
- ilim = ilim1 = -1;
i = (int)(nbits * .30103) + 3;
ndigits = 0;
break;
/* Try to get by with floating-point arithmetic. */
i = 0;
- d2 = dval(d);
+ d2 = dval(&d);
#ifdef IBM
- if ( (j = 11 - hi0bits(word0(d) & Frac_mask)) !=0)
- dval(d) /= 1 << j;
+ if ( (j = 11 - hi0bits(word0(&d) & Frac_mask)) !=0)
+ dval(&d) /= 1 << j;
#endif
k0 = k;
ilim0 = ilim;
if (j & Bletch) {
/* prevent overflows */
j &= Bletch - 1;
- dval(d) /= bigtens[n_bigtens-1];
+ dval(&d) /= bigtens[n_bigtens-1];
ieps++;
}
for(; j; j /= 2, i++)
else {
ds = 1.;
if ( (jj1 = -k) !=0) {
- dval(d) *= tens[jj1 & 0xf];
+ dval(&d) *= tens[jj1 & 0xf];
for(j = jj1 >> 4; j; j >>= 1, i++)
if (j & 1) {
ieps++;
- dval(d) *= bigtens[i];
+ dval(&d) *= bigtens[i];
}
}
}
- if (k_check && dval(d) < 1. && ilim > 0) {
+ if (k_check && dval(&d) < 1. && ilim > 0) {
if (ilim1 <= 0)
goto fast_failed;
ilim = ilim1;
k--;
- dval(d) *= 10.;
+ dval(&d) *= 10.;
ieps++;
}
- dval(eps) = ieps*dval(d) + 7.;
- word0(eps) -= (P-1)*Exp_msk1;
+ 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))
+ dval(&d) -= 5.;
+ if (dval(&d) > dval(&eps))
goto one_digit;
- if (dval(d) < -dval(eps))
+ if (dval(&d) < -dval(&eps))
goto no_digits;
goto fast_failed;
}
/* Use Steele & White method of only
* generating digits needed.
*/
- dval(eps) = ds*0.5/tens[ilim-1] - dval(eps);
+ dval(&eps) = ds*0.5/tens[ilim-1] - dval(&eps);
for(i = 0;;) {
- L = (Long)(dval(d)/ds);
- dval(d) -= L*ds;
+ L = (Long)(dval(&d)/ds);
+ dval(&d) -= L*ds;
*s++ = '0' + (int)L;
- if (dval(d) < dval(eps)) {
- if (dval(d))
+ if (dval(&d) < dval(&eps)) {
+ if (dval(&d))
inex = STRTOG_Inexlo;
goto ret1;
}
- if (ds - dval(d) < dval(eps))
+ if (ds - dval(&d) < dval(&eps))
goto bump_up;
if (++i >= ilim)
break;
- dval(eps) *= 10.;
- dval(d) *= 10.;
+ 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;
+ 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))
+ if (dval(&d) > ds + dval(&eps))
goto bump_up;
- else if (dval(d) < ds - dval(eps)) {
- while(*--s == '0'){}
- s++;
- if (dval(d))
+ else if (dval(&d) < ds - dval(&eps)) {
+ if (dval(&d))
inex = STRTOG_Inexlo;
- goto ret1;
+ goto clear_trailing0;
}
break;
}
#endif
fast_failed:
s = s0;
- dval(d) = d2;
+ dval(&d) = d2;
k = k0;
ilim = ilim0;
}
ds = tens[k];
if (ndigits < 0 && ilim <= 0) {
S = mhi = 0;
- if (ilim < 0 || dval(d) <= 5*ds)
+ 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;
+ 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) {
+ if (dval(&d) < 0) {
L--;
- dval(d) += ds;
+ dval(&d) += ds;
}
#endif
*s++ = '0' + (int)L;
- if (dval(d) == 0.)
+ if (dval(&d) == 0.)
break;
if (i == ilim) {
if (rdir) {
inex = STRTOG_Inexlo;
goto ret1;
}
- dval(d) += dval(d);
- if (dval(d) > ds || (dval(d) == ds && L & 1)) {
+ 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')
}
++*s++;
}
- else
+ else {
inex = STRTOG_Inexlo;
+ clear_trailing0:
+ while(*--s == '0'){}
+ ++s;
+ }
break;
}
}
m5 = b5;
mhi = mlo = 0;
if (leftright) {
- if (mode < 2) {
- i = nbits - bbits;
- if (be - i++ < fpi->emin)
- /* denormal */
- i = be - fpi->emin + 1;
+ 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 {
+ else if (mode >= 2) {
+ small_ilim:
j = ilim - 1;
if (m5 >= j)
m5 -= j;
* 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)
+ 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 > 0)
+ if ((s2 += i) > 0)
S = lshift(S, s2);
if (k_check) {
if (cmp(b,S) < 0) {
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 == NULL)
return NULL;
j = cmp(b, S);
- if (j > 0 || (j == 0 && dig & 1)) {
+#ifdef ROUND_BIASED
+ if (j >= 0)
+#else
+ if (j > 0 || (j == 0 && dig & 1))
+#endif
+ {
roundoff:
inex = STRTOG_Inexhi;
while(*--s == '9')
if (b->wds > 1 || b->x[0])
inex = STRTOG_Inexlo;
while(*--s == '0'){}
- s++;
+ ++s;
}
ret:
Bfree(S);
-/* $NetBSD: gdtoa.h,v 1.8 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: gdtoa.h,v 1.9 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
#define GDTOA_H_INCLUDED
#include "arith.h"
+#include <stddef.h> /* for size_t */
+#include <stdint.h>
#ifndef Long
#define Long int32_t
/* The following may be or-ed into one of the above values. */
- STRTOG_Neg = 0x08,
- STRTOG_Inexlo = 0x10,
- STRTOG_Inexhi = 0x20,
+ 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,
extern double strtod ANSI((CONST char *, char **));
extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*));
-extern char* g_ddfmt ANSI((char*, double*, int, unsigned));
-extern char* g_dfmt ANSI((char*, double*, int, unsigned));
-extern char* g_ffmt ANSI((char*, float*, int, unsigned));
-extern char* g_Qfmt ANSI((char*, void*, int, unsigned));
-extern char* g_xfmt ANSI((char*, void*, int, unsigned));
-extern char* g_xLfmt ANSI((char*, void*, int, unsigned));
+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*));
--- /dev/null
+ 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;
+ }
-/* $NetBSD: gdtoaimp.h,v 1.8 2011/01/21 23:36:49 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.13 2012/03/13 21:13:34 christos Exp $ */
/****************************************************************
* #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.
+ * #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"
* #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.
+ * 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,
* 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 INFNAN_CHECK on IEEE systems to cause strtod to check for
- * Infinity and NaN (case insensitively).
+ * #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 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.
+ * 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
* 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 strtog in
+ * 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 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 YES_ALIAS to permit aliasing certain double values with
- * arrays of ULongs. This leads to slightly better code with
- * some compilers and was always used prior to 19990916, but it
- * is not strictly legal and can cause trouble with aggressively
- * optimizing compilers (e.g., gcc 2.95.1 under -O2).
* #define USE_LOCALE to use the current locale's decimal_point value.
*/
/* #define IEEE_{BIG,LITTLE}_ENDIAN in ${ARCHDIR}/gdtoa/arith.h */
+#include <assert.h>
#include <stdint.h>
#define Short int16_t
#define UShort uint16_t
#define GDTOAIMP_H_INCLUDED
#include "gdtoa.h"
#include "gd_qnan.h"
+#ifdef Honor_FLT_ROUNDS
+#include <fenv.h>
+#endif
#ifdef DEBUG
#include "stdio.h"
#ifdef YES_ALIAS
#define dval(x) x
#ifdef IEEE_LITTLE_ENDIAN
-#define word0(x) ((ULong *)&x)[1]
-#define word1(x) ((ULong *)&x)[0]
+#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]
+#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]
+#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]
+#define word0(x) ( /* LINTED */ (U*)x)->L[0]
+#define word1(x) ( /* LINTED */ (U*)x)->L[1]
#endif
-#define dval(x) ( /* LINTED */ (U*)&x)->d
+#define dval(x) ( /* LINTED */ (U*)x)->d
#endif /* YES_ALIAS */
/* The following definition of Storeinc is appropriate for MIPS processors.
#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
#ifndef IEEE_Arith
#define ROUND_BIASED
+#else
+#ifdef ROUND_BIASED_without_Round_Up
+#undef ROUND_BIASED
+#define ROUND_BIASED
+#endif
#endif
#ifdef RND_PRODQUOT
extern int cmp ANSI((Bigint*, Bigint*));
extern void copybits ANSI((ULong*, int, Bigint*));
extern Bigint *d2b ANSI((double, int*, int*));
- extern int decrement ANSI((Bigint*));
+ 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));
+ extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t));
extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int));
extern void hexdig_init_D2A(Void);
extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*));
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));
+ 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((double));
+ extern double ulp ANSI((U*));
#ifdef __cplusplus
}
* (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
-/* $NetBSD: gethex.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: gethex.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
#endif
{
Bigint *b;
- CONST unsigned char *decpt, *s0, *s, *s1;
- int esign, havedig, irv, k, n, nbits, up, zret;
+ 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
- unsigned char decimalpoint = *localeconv()->decimal_point;
+ int i;
+#ifdef NO_LOCALE_CACHE
+ const char *decimalpoint = localeconv()->decimal_point;
#else
-#define decimalpoint '.'
+ const unsigned char *decimalpoint;
+ static char *decimalpoint_cache;
+ if (!(s0 = decimalpoint_cache)) {
+ s0 = localeconv()->decimal_point;
+ if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
+ strcpy(decimalpoint_cache, s0);
+ s0 = decimalpoint_cache;
+ }
+ }
+ decimalpoint = __UNCONST(s0);
+#endif
#endif
- if (!hexdig['0'])
+ if (!hexdig[(unsigned char)'0'])
hexdig_init_D2A();
+ *bp = 0;
havedig = 0;
- s0 = *(CONST unsigned char **)sp + 2;
+ s0 = *(CONST char **)sp + 2;
while(s0[havedig] == '0')
havedig++;
s0 += havedig;
decpt = 0;
zret = 0;
e = 0;
- if (!hexdig[*s]) {
+ if (hexdig[(unsigned char)*s])
+ havedig++;
+ else {
zret = 1;
- if (*s != decimalpoint)
+#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;
- if (!hexdig[*s])
+#endif
+ if (!hexdig[(unsigned char)*s])
goto pcheck;
while(*s == '0')
s++;
- if (hexdig[*s])
+ if (hexdig[(unsigned char)*s])
zret = 0;
havedig = 1;
s0 = s;
}
- while(hexdig[*s])
+ while(hexdig[(unsigned char)*s])
s++;
- if (*s == decimalpoint && !decpt) {
+#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;
- while(hexdig[*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':
- esign = 0;
switch(*++s) {
case '-':
esign = 1;
case '+':
s++;
}
- if ((n = hexdig[*s]) == 0 || n > 0x19) {
+ if ((n = hexdig[(unsigned char)*s]) == 0 || n > 0x19) {
s = s1;
break;
}
e1 = n - 0x10;
- while((n = hexdig[*++s]) !=0 && n <= 0x19)
+ 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 havedig ? STRTOG_Zero : STRTOG_NoNumber;
- n = s1 - s0 - 1;
- for(k = 0; n > 7; n = (unsigned int)n >> 1)
+ 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)
x = b->x;
n = 0;
L = 0;
+#ifdef USE_LOCALE
+ for(i = 0; decimalpoint[i+1]; ++i);
+#endif
while(s1 > s0) {
- if (*--s1 == decimalpoint)
+#ifdef USE_LOCALE
+ if (*--s1 == decimalpoint[i]) {
+ s1 -= i;
continue;
- if (n == 32) {
+ }
+#else
+ if (*--s1 == '.')
+ continue;
+#endif
+ if (n == ULbits) {
*x++ = L;
L = 0;
n = 0;
}
- L |= (hexdig[*s1] & 0x0f) << n;
+ L |= (hexdig[(unsigned char)*s1] & 0x0f) << n;
n += 4;
}
*x++ = L;
- b->wds = n = x - b->x;
- n = 32*n - hi0bits(L);
+ b->wds = n = (int)(x - b->x);
+ n = ULbits*n - hi0bits(L);
nbits = fpi->nbits;
lostbits = 0;
x = b->x;
k = n - 1;
if (x[(unsigned int)k>>kshift] & 1 << (k & kmask)) {
lostbits = 2;
- if (k > 1 && any_on(b,k-1))
+ if (k > 0 && any_on(b,k))
lostbits = 3;
}
}
if (e > fpi->emax) {
ovfl:
Bfree(b);
- *bp = 0;
+ ovfl1:
+#ifndef NO_ERRNO
+ errno = ERANGE;
+#endif
return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi;
}
irv = STRTOG_Normal;
case FPI_Round_down:
if (sign) {
one_bit:
- *expt = fpi->emin;
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);
- *bp = 0;
+ retz:
+#ifndef NO_ERRNO
+ errno = ERANGE;
+#endif
return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow;
}
k = n - 1;
break;
case FPI_Round_near:
if (lostbits & 2
- && (lostbits & 1) | (x[0] & 1))
+ && (lostbits | x[0]) & 1)
up = 1;
break;
case FPI_Round_up:
}
else if (b->wds > k
|| ((n = nbits & kmask) !=0
- && hi0bits(x[k-1]) < 32-n)) {
+ && hi0bits(x[k-1]) < 32-n)) {
rshift(b,1);
if (++e > fpi->emax)
goto ovfl;
-/* $NetBSD: gmisc.c,v 1.3 2006/03/11 18:38:14 kleink Exp $ */
+/* $NetBSD: gmisc.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */
/****************************************************************
while(x < xe)
*x1++ = *x++;
}
- if ((b->wds = x1 - b->x) == 0)
+
+ ptrdiff_t td = x1 - b->x;
+ _DIAGASSERT(__type_fit(int, td));
+ if ((b->wds = (int)td) == 0)
b->x[0] = 0;
}
-/* $NetBSD: hdtoa.c,v 1.6 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $ */
/*-
* Copyright (c) 2004, 2005 David Schultz <das@FreeBSD.ORG>
#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.6 2008/03/21 23:13:48 christos Exp $");
+__RCSID("$NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $");
#endif
#include <float.h>
*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;
char *s, *s0;
size_t bufsize;
+ memset(&u, 0, sizeof u);
u.extu_ld = e;
*sign = u.extu_ext.ext_sign;
-/* $NetBSD: hexnan.c,v 1.3 2006/03/11 18:38:14 kleink Exp $ */
+/* $NetBSD: hexnan.c,v 1.5 2011/03/21 04:52:09 christos Exp $ */
/****************************************************************
x1 = xe = x;
havedig = hd0 = i = 0;
s = *sp;
- while((c = *(CONST unsigned char*)++s) != 0) {
+ /* 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) {
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++;
-# $NetBSD: makefile,v 1.3 2006/01/25 16:40:57 kleink Exp $
+# $NetBSD: makefile,v 1.4 2011/03/20 23:15:35 christos Exp $
# /****************************************************************
# Copyright (C) 1998 by Lucent Technologies
.SUFFIXES: .c .o
CC = cc
-CFLAGS = -g -DINFNAN_CHECK
+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
./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
+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 gdtoaimp.h gethex.c\
- gmisc.c hd_init.c hexnan.c makefile misc.c qnan.c smisc.c 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
+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 xsum.out" to check for transmission errors; source for xsum is
+# "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
cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out
clean:
- rm -f arith.h gd_qnan.h *.[ao] xsum.out xsum1.out
+ rm -f arith.h gd_qnan.h *.[ao] Printf xsum.out xsum1.out
-/* $NetBSD: misc.c,v 1.5 2009/01/30 23:35:35 lukem Exp $ */
+/* $NetBSD: misc.c,v 1.11 2011/11/21 09:46:19 mlelstv Exp $ */
/****************************************************************
int x;
Bigint *rv;
#ifndef Omit_Private_Memory
- unsigned int len;
+ size_t len;
#endif
ACQUIRE_DTOA_LOCK(0);
- if ( (rv = freelist[k]) !=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 {
#else
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
/sizeof(double);
- if ((double *)(pmem_next - private_mem + len) <= (double *)PRIVATE_mem) {
+ 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)
+ if (rv == NULL) {
+ FREE_DTOA_LOCK(0);
return NULL;
+ }
rv->k = k;
rv->maxwds = x;
}
#endif
{
if (v) {
- ACQUIRE_DTOA_LOCK(0);
- v->next = freelist[v->k];
- freelist[v->k] = v;
- FREE_DTOA_LOCK(0);
+ 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);
+ }
}
}
ACQUIRE_DTOA_LOCK(1);
if (!(p5 = p5s)) {
p5 = p5s = i2b(625);
- if (p5 == NULL)
+ if (p5 == NULL) {
+ FREE_DTOA_LOCK(1);
return NULL;
+ }
p5->next = 0;
}
FREE_DTOA_LOCK(1);
b1 = mult(b, p5);
if (b1 == NULL)
return NULL;
+ Bfree(b);
b = b1;
}
if (!(k = (unsigned int)k >> 1))
ACQUIRE_DTOA_LOCK(1);
if (!(p51 = p5->next)) {
p51 = p5->next = mult(p5,p5);
- if (p51 == NULL)
+ if (p51 == NULL) {
+ FREE_DTOA_LOCK(1);
return NULL;
+ }
p51->next = 0;
}
FREE_DTOA_LOCK(1);
{
ULong *xa, *xa0, w, y, z;
int k;
- double d;
+ U d;
#ifdef VAX
ULong d0, d1;
#else
-#define d0 word0(d)
-#define d1 word1(d)
+#define d0 word0(&d)
+#define d1 word1(&d)
#endif
xa0 = a->x;
#endif
ret_d:
#ifdef VAX
- word0(d) = d0 >> 16 | d0 << 16;
- word1(d) = d1 >> 16 | d1 << 16;
+ word0(&d) = d0 >> 16 | d0 << 16;
+ word1(&d) = d1 >> 16 | d1 << 16;
#endif
- return dval(d);
+ return dval(&d);
}
#undef d0
#undef d1
Bigint *
d2b
#ifdef KR_headers
- (d, e, bits) double d; int *e, *bits;
+ (dd, e, bits) double dd; int *e, *bits;
#else
- (double d, int *e, int *bits)
+ (double dd, int *e, int *bits)
#endif
{
Bigint *b;
+ U d;
#ifndef Sudden_Underflow
int i;
#endif
ULong *x, y, z;
#ifdef VAX
ULong d0, d1;
- d0 = word0(d) >> 16 | word0(d) << 16;
- d1 = word1(d) >> 16 | word1(d) << 16;
#else
-#define d0 word0(d)
-#define d1 word1(d)
+#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->wds = (x[1] = z) !=0 ? 2 : 1;
}
else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
k = lo0bits(&z);
x[0] = z;
#ifndef Sudden_Underflow
#endif
#ifdef IBM
*e = (de - Bias - (P-1) << 2) + k;
- *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
+ *bits = 4*P + 8 - k - hi0bits(word0(&d) & Frac_mask);
#else
*e = de - Bias - (P-1) + k;
*bits = P - k;
-/* $NetBSD: smisc.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: smisc.c,v 1.5 2012/03/13 21:13:34 christos Exp $ */
/****************************************************************
Bigint *
s2b
#ifdef KR_headers
- (s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9;
+ (s, nd0, nd, y9, dplen) CONST char *s; int dplen, nd0, nd; ULong y9;
#else
- (CONST char *s, int nd0, int nd, ULong y9)
+ (CONST char *s, int nd0, int nd, ULong y9, size_t dplen)
#endif
{
Bigint *b;
i = 9;
if (9 < nd0) {
s += 9;
- do {
+ do {
b = multadd(b, 10, *s++ - '0');
if (b == NULL)
return NULL;
} while(++i < nd0);
- s++;
+ s += dplen;
}
else
- s += 10;
+ s += dplen + 9;
for(; i < nd; i++) {
b = multadd(b, 10, *s++ - '0');
if (b == NULL)
}
return b;
}
-
double
ratio
#ifdef KR_headers
(Bigint *a, Bigint *b)
#endif
{
- double da, db;
+ U da, db;
int k, ka, kb;
- dval(da) = b2d(a, &ka);
- dval(db) = b2d(b, &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;
+ word0(&da) += (k >> 2)*Exp_msk1;
if (k &= 3)
- dval(da) *= 1 << k;
+ dval(&da) *= 1 << k;
}
else {
k = -k;
- word0(db) += (k >> 2)*Exp_msk1;
+ word0(&db) += (k >> 2)*Exp_msk1;
if (k &= 3)
- dval(db) *= 1 << k;
+ dval(&db) *= 1 << k;
}
#else
if (k > 0)
- word0(da) += k*Exp_msk1;
+ word0(&da) += k*Exp_msk1;
else {
k = -k;
- word0(db) += k*Exp_msk1;
+ word0(&db) += k*Exp_msk1;
}
#endif
- return dval(da) / dval(db);
+ return dval(&da) / dval(&db);
}
#ifdef INFNAN_CHECK
-/* $NetBSD: strtoIg.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtoIg.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
if (rv & STRTOG_Inexlo) {
swap = 0;
b1 = increment(b1);
- if (fpi->sudden_underflow
- && (rv & STRTOG_Retmask) == STRTOG_Zero) {
- b1->x[0] = 0;
- b1->x[nw1] = 1L << nb11;
- rv1 += STRTOG_Normal - STRTOG_Zero;
- rv1 &= ~STRTOG_Underflow;
+ 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) {
+ || (nb1 && b1->x[nw1] & 1L << nb1)) {
if (++e1 > fpi->emax)
rv1 = STRTOG_Infinite | STRTOG_Inexhi;
rshift(b1, 1);
-/* $NetBSD: strtod.c,v 1.5 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.11 2012/03/22 15:34:14 christos Exp $ */
/****************************************************************
#ifndef NO_IEEE_Scale
#define Avoid_Underflow
#undef tinytens
-/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
+/* 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.e-256
+ 9007199254740992.*9007199254740992.e-256
};
#endif
#endif
#ifdef Honor_FLT_ROUNDS
-#define Rounding rounding
#undef Check_FLT_ROUNDS
#define Check_FLT_ROUNDS
#else
__weak_alias(strtold, _strtold)
#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 /*}*/
+
double
strtod
#ifdef KR_headers
#ifdef Avoid_Underflow
int scale;
#endif
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign,
+#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, aadj1, adj, rv, rv0;
+ 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 Honor_FLT_ROUNDS
- int rounding;
-#endif
+#ifdef USE_LOCALE /*{{*/
+#ifdef NO_LOCALE_CACHE
+ char *decimalpoint = localeconv()->decimal_point;
+ size_t dplen = strlen(decimalpoint);
+#else
+ char *decimalpoint;
+ static char *decimalpoint_cache;
+ static size_t dplen;
+ if (!(s0 = decimalpoint_cache)) {
+ s0 = localeconv()->decimal_point;
+ if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
+ strcpy(decimalpoint_cache, s0);
+ s0 = decimalpoint_cache;
+ }
+ dplen = strlen(s0);
+ }
+ decimalpoint = __UNCONST(s0);
+#endif /*NO_LOCALE_CACHE*/
+#else /*USE_LOCALE}{*/
+#define dplen 1
+#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 /*}*/
- sign = nz0 = nz = decpt = 0;
- dval(rv) = 0.;
+#ifdef INFNAN_CHECK
+ decpt = 0;
+#endif
+ sign = nz0 = nz = 0;
+ dval(&rv) = 0.;
for(s = s00;;s++) switch(*s) {
case '-':
sign = 1;
}
break2:
if (*s == '0') {
-#ifndef NO_HEX_FP
+#ifndef NO_HEX_FP /*{*/
{
static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
Long expt;
case 'x':
case 'X':
{
-#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD)
+#ifdef Honor_FLT_ROUNDS
FPI fpi1 = fpi;
- switch(fegetround()) {
- case FE_TOWARDZERO: fpi1.rounding = 0; break;
- case FE_UPWARD: fpi1.rounding = 2; break;
- case FE_DOWNWARD: fpi1.rounding = 3;
- }
+ fpi1.rounding = Rounding;
#else
#define fpi1 fpi
#endif
goto ret;
}
}
-#endif
+#endif /*}*/
nz0 = 1;
while(*++s == '0') ;
if (!*s)
z = 10*z + c - '0';
nd0 = nd;
#ifdef USE_LOCALE
- if (c == *localeconv()->decimal_point)
+ if (c == *decimalpoint) {
+ for(i = 1; decimalpoint[i]; ++i)
+ if (s[i] != decimalpoint[i])
+ goto dig_done;
+ s += i;
+ c = *s;
#else
- if (c == '.')
+ if (c == '.') {
+ c = *++s;
#endif
- {
+#ifdef INFNAN_CHECK
decpt = 1;
- c = *++s;
+#endif
if (!nd) {
for(; c == '0'; c = *++s)
nz++;
nz = 0;
}
}
- }
+ }/*}*/
dig_done:
e = 0;
if (c == 'e' || c == 'E') {
--s;
if (!match(&s,"inity"))
++s;
- word0(rv) = 0x7ff00000;
- word1(rv) = 0;
+ word0(&rv) = 0x7ff00000;
+ word1(&rv) = 0;
goto ret;
}
break;
if (*s == '(' /*)*/
&& hexnan(&s, &fpinan, bits)
== STRTOG_NaNbits) {
- word0(rv) = 0x7ff00000 | bits[1];
- word1(rv) = bits[0];
+ word0(&rv) = 0x7ff00000 | bits[1];
+ word1(&rv) = bits[0];
}
else {
#endif
- word0(rv) = NAN_WORD0;
- word1(rv) = NAN_WORD1;
+ word0(&rv) = NAN_WORD0;
+ word1(&rv) = NAN_WORD1;
#ifndef No_Hex_NaN
}
#endif
if (!nd0)
nd0 = nd;
k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
- dval(rv) = y;
+ 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;
+ dval(&rv) = tens[k - 9] * dval(&rv) + z;
}
bd0 = 0;
if (nd <= DBL_DIG
) {
if (!e)
goto ret;
+#ifndef ROUND_BIASED_without_Round_Up
if (e > 0) {
if (e <= Ten_pmax) {
#ifdef VAX
#ifdef Honor_FLT_ROUNDS
/* round correctly FLT_ROUNDS = 2 or 3 */
if (sign) {
- rv = -rv;
+ rv.d = -rv.d;
sign = 0;
}
#endif
- /* rv = */ rounded_product(dval(rv), tens[e]);
+ /* rv = */ rounded_product(dval(&rv), tens[e]);
goto ret;
#endif
}
#ifdef Honor_FLT_ROUNDS
/* round correctly FLT_ROUNDS = 2 or 3 */
if (sign) {
- rv = -rv;
+ rv.d = -rv.d;
sign = 0;
}
#endif
e -= i;
- dval(rv) *= tens[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)
+ 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;
+ word0(&rv) += P*Exp_msk1;
#else
- /* rv = */ rounded_product(dval(rv), tens[e]);
+ /* rv = */ rounded_product(dval(&rv), tens[e]);
#endif
goto ret;
}
#ifdef Honor_FLT_ROUNDS
/* round correctly FLT_ROUNDS = 2 or 3 */
if (sign) {
- rv = -rv;
+ rv.d = -rv.d;
sign = 0;
}
#endif
- /* rv = */ rounded_quotient(dval(rv), tens[-e]);
+ /* rv = */ rounded_quotient(dval(&rv), tens[-e]);
goto ret;
}
#endif
+#endif /* ROUND_BIASED_without_Round_Up */
}
e1 += nd - k;
scale = 0;
#endif
#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
+ if (Rounding >= 2) {
if (sign)
- rounding = rounding == 2 ? 0 : 2;
+ Rounding = Rounding == 2 ? 0 : 2;
else
- if (rounding != 2)
- rounding = 0;
+ if (Rounding != 2)
+ Rounding = 0;
}
#endif
#endif /*IEEE_Arith*/
if (e1 > 0) {
if ( (i = e1 & 15) !=0)
- dval(rv) *= tens[i];
+ dval(&rv) *= tens[i];
if (e1 &= ~15) {
if (e1 > DBL_MAX_10_EXP) {
ovfl:
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
/* Can't trust HUGE_VAL */
#ifdef IEEE_Arith
#ifdef Honor_FLT_ROUNDS
- switch(rounding) {
+ switch(Rounding) {
case 0: /* toward 0 */
case 3: /* toward -infinity */
- word0(rv) = Big0;
- word1(rv) = Big1;
+ word0(&rv) = Big0;
+ word1(&rv) = Big1;
break;
default:
- word0(rv) = Exp_mask;
- word1(rv) = 0;
+ word0(&rv) = Exp_mask;
+ word1(&rv) = 0;
}
#else /*Honor_FLT_ROUNDS*/
- word0(rv) = Exp_mask;
- word1(rv) = 0;
+ word0(&rv) = Exp_mask;
+ word1(&rv) = 0;
#endif /*Honor_FLT_ROUNDS*/
#ifdef SET_INEXACT
/* set overflow bit */
- dval(rv0) = 1e300;
- dval(rv0) *= dval(rv0);
+ dval(&rv0) = 1e300;
+ dval(&rv0) *= dval(&rv0);
#endif
#else /*IEEE_Arith*/
- word0(rv) = Big0;
- word1(rv) = Big1;
+ word0(&rv) = Big0;
+ word1(&rv) = Big1;
#endif /*IEEE_Arith*/
- if (bd0)
- goto retfree;
+ 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];
+ dval(&rv) *= bigtens[j];
/* The last multiplication could overflow. */
- word0(rv) -= P*Exp_msk1;
- dval(rv) *= bigtens[j];
- if ((z = word0(rv) & Exp_mask)
+ 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;
+ word0(&rv) = Big0;
+ word1(&rv) = Big1;
}
else
- word0(rv) += P*Exp_msk1;
+ word0(&rv) += P*Exp_msk1;
}
}
else if (e1 < 0) {
e1 = -e1;
if ( (i = e1 & 15) !=0)
- dval(rv) /= tens[i];
+ dval(&rv) /= tens[i];
if (e1 >>= 4) {
if (e1 >= 1 << n_bigtens)
goto undfl;
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)
+ 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;
+ word1(&rv) = 0;
if (j >= 53)
- word0(rv) = (P+2)*Exp_msk1;
+ word0(&rv) = (P+2)*Exp_msk1;
else
- word0(rv) &= 0xffffffff << (j-32);
+ word0(&rv) &= 0xffffffffU << (j-32);
}
else
- word1(rv) &= 0xffffffff << j;
+ word1(&rv) &= 0xffffffffU << j;
}
#else
- for(j = 0; e1 > 1; j++, e1 >>= 1)
+ for(j = 0; e1 > 1; j++, e1 = (unsigned int)e1 >> 1)
if (e1 & 1)
- dval(rv) *= tinytens[j];
+ 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];
+ dval(&rv0) = dval(&rv);
+ dval(&rv) *= tinytens[j];
+ if (!dval(&rv)) {
+ dval(&rv) = 2.*dval(&rv0);
+ dval(&rv) *= tinytens[j];
#endif
- if (!dval(rv)) {
+ if (!dval(&rv)) {
undfl:
- dval(rv) = 0.;
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
- if (bd0)
- goto retfree;
- goto ret;
+ dval(&rv) = 0.;
+ goto range_err;
}
#ifndef Avoid_Underflow
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
+ word0(&rv) = Tiny0;
+ word1(&rv) = Tiny1;
/* The refinement below will clean
* this approximation up.
*/
/* Put digits into bd: true value = bd * 10^e */
- bd0 = s2b(s0, nd0, nd, y);
+ bd0 = s2b(s0, nd0, nd, y, dplen);
if (bd0 == NULL)
goto ovfl;
if (bd == NULL)
goto ovfl;
Bcopy(bd, bd0);
- bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
+ bb = d2b(dval(&rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
if (bb == NULL)
goto ovfl;
bs = i2b(1);
bd2 -= bbe;
bs2 = bb2;
#ifdef Honor_FLT_ROUNDS
- if (rounding != 1)
+ if (Rounding != 1)
bs2++;
#endif
#ifdef Avoid_Underflow
+ Lsb = LSB;
+ Lsb1 = 0;
j = bbe - scale;
i = j + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j += P - Emin;
- else
- j = P + 1 - bbbits;
+ 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
#endif
#else /*Sudden_Underflow*/
j = bbe;
- i = j + bbbits - 1; /* logb(rv) */
+ i = j + bbbits - 1; /* logb(&rv) */
if (i < Emin) /* denormal */
j += P - Emin;
else
delta->sign = 0;
i = cmp(delta, bs);
#ifdef Honor_FLT_ROUNDS
- if (rounding != 1) {
+ if (Rounding != 1) {
if (i < 0) {
/* Error is less than an ulp */
if (!delta->x[0] && delta->wds <= 1) {
#endif
break;
}
- if (rounding) {
+ if (Rounding) {
if (dsign) {
- adj = 1.;
+ dval(&adj) = 1.;
goto apply_adj;
}
}
else if (!dsign) {
- adj = -1.;
- if (!word1(rv)
- && !(word0(rv) & Frac_mask)) {
- y = word0(rv) & Exp_mask;
+ 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
{
delta = lshift(delta,Log2P);
if (cmp(delta, bs) <= 0)
- adj = -0.5;
+ dval(&adj) = -0.5;
}
}
apply_adj:
#ifdef Avoid_Underflow
- if (scale && (y = word0(rv) & Exp_mask)
+ if (scale && (y = word0(&rv) & Exp_mask)
<= 2*P*Exp_msk1)
- word0(adj) += (2*P+1)*Exp_msk1 - y;
+ word0(&adj) += (2*P+1)*Exp_msk1 - y;
#else
#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <=
+ if ((word0(&rv) & Exp_mask) <=
P*Exp_msk1) {
- word0(rv) += P*Exp_msk1;
- dval(rv) += adj*ulp(dval(rv));
- word0(rv) -= 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*ulp(dval(rv));
+ dval(&rv) += adj.d*ulp(&rv);
}
break;
}
- adj = ratio(delta, bs);
- if (adj < 1.)
- adj = 1.;
- if (adj <= 0x7ffffffe) {
- /* adj = rounding ? ceil(adj) : floor(adj); */
- y = adj;
- if (y != adj) {
- if (!((rounding>>1) ^ dsign))
+ 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++;
- adj = 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;
+ 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;
- adj *= ulp(dval(rv));
+ if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) {
+ word0(&rv) += P*Exp_msk1;
+ dval(&adj) *= ulp(&rv);
if (dsign)
- dval(rv) += adj;
+ dval(&rv) += adj;
else
- dval(rv) -= adj;
- word0(rv) -= P*Exp_msk1;
+ dval(&rv) -= adj;
+ word0(&rv) -= P*Exp_msk1;
goto cont;
}
#endif /*Sudden_Underflow*/
#endif /*Avoid_Underflow*/
- adj *= ulp(dval(rv));
- if (dsign)
- dval(rv) += adj;
+ dval(&adj) *= ulp(&rv);
+ if (dsign) {
+ if (word0(&rv) == Big0 && word1(&rv) == Big1)
+ goto ovfl;
+ dval(&rv) += adj.d;
+ }
else
- dval(rv) -= adj;
+ dval(&rv) -= adj.d;
goto cont;
}
#endif /*Honor_FLT_ROUNDS*/
/* 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
+ if (dsign || word1(&rv) || word0(&rv) & Bndry_mask
#ifdef IEEE_Arith
#ifdef Avoid_Underflow
- || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
+ || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1
#else
- || (word0(rv) & Exp_mask) <= Exp_msk1
+ || (word0(&rv) & Exp_mask) <= Exp_msk1
#endif
#endif
) {
if (i == 0) {
/* exactly half-way between */
if (dsign) {
- if ((word0(rv) & Bndry_mask1) == Bndry_mask1
- && word1(rv) == (
+ if ((word0(&rv) & Bndry_mask1) == Bndry_mask1
+ && word1(&rv) == (
#ifdef Avoid_Underflow
- (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
+ (scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1)
? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
#endif
0xffffffff)) {
/*boundary case -- increment exponent*/
- word0(rv) = (word0(rv) & Exp_mask)
+ 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;
+ word1(&rv) = 0;
#ifdef Avoid_Underflow
dsign = 0;
#endif
break;
}
}
- else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
+ else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) {
drop_down:
/* boundary case -- decrement exponent */
#ifdef Sudden_Underflow /*{{*/
- L = word0(rv) & Exp_mask;
+ L = word0(&rv) & Exp_mask;
#ifdef IBM
if (L < Exp_msk1)
#else
#else /*Sudden_Underflow}{*/
#ifdef Avoid_Underflow
if (scale) {
- L = word0(rv) & Exp_mask;
+ L = word0(&rv) & Exp_mask;
if (L <= (2*P+1)*Exp_msk1) {
if (L > (P+2)*Exp_msk1)
/* round even ==> */
}
}
#endif /*Avoid_Underflow*/
- L = (word0(rv) & Exp_mask) - Exp_msk1;
-#endif /*Sudden_Underflow}*/
- word0(rv) = L | Bndry_mask1;
- word1(rv) = 0xffffffff;
+ L = (word0(&rv) & Exp_mask) - Exp_msk1;
+#endif /*Sudden_Underflow}}*/
+ word0(&rv) = L | Bndry_mask1;
+ word1(&rv) = 0xffffffff;
#ifdef IBM
goto cont;
#else
#endif
}
#ifndef ROUND_BIASED
- if (!(word1(rv) & LSB))
+#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)
- dval(rv) += ulp(dval(rv));
+#ifdef Avoid_Underflow
+ dval(&rv) += sulp(&rv, scale);
+#else
+ dval(&rv) += ulp(&rv);
+#endif
#ifndef ROUND_BIASED
else {
- dval(rv) -= ulp(dval(rv));
+#ifdef Avoid_Underflow
+ dval(&rv) -= sulp(&rv, scale);
+#else
+ dval(&rv) -= ulp(&rv);
+#endif
#ifndef Sudden_Underflow
- if (!dval(rv))
+ if (!dval(&rv))
goto undfl;
#endif
}
}
if ((aadj = ratio(delta, bs)) <= 2.) {
if (dsign)
- aadj = aadj1 = 1.;
- else if (word1(rv) || word0(rv) & Bndry_mask) {
+ aadj = dval(&aadj1) = 1.;
+ else if (word1(&rv) || word0(&rv) & Bndry_mask) {
#ifndef Sudden_Underflow
- if (word1(rv) == Tiny1 && !word0(rv))
+ if (word1(&rv) == Tiny1 && !word0(&rv))
goto undfl;
#endif
aadj = 1.;
- aadj1 = -1.;
+ dval(&aadj1) = -1.;
}
else {
/* special case -- power of FLT_RADIX to be */
aadj = 1./FLT_RADIX;
else
aadj *= 0.5;
- aadj1 = -aadj;
+ dval(&aadj1) = -aadj;
}
}
else {
aadj *= 0.5;
- aadj1 = dsign ? aadj : -aadj;
+ dval(&aadj1) = dsign ? aadj : -aadj;
#ifdef Check_FLT_ROUNDS
+ /* CONSTCOND */
switch(Rounding) {
case 2: /* towards +infinity */
- aadj1 -= 0.5;
+ dval(&aadj1) -= 0.5;
break;
case 0: /* towards 0 */
case 3: /* towards -infinity */
- aadj1 += 0.5;
+ dval(&aadj1) += 0.5;
}
#else
+ /* CONSTCOND */
if (Flt_Rounds == 0)
- aadj1 += 0.5;
+ dval(&aadj1) += 0.5;
#endif /*Check_FLT_ROUNDS*/
}
- y = word0(rv) & Exp_mask;
+ 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;
- adj = aadj1 * ulp(dval(rv));
- dval(rv) += adj;
- if ((word0(rv) & Exp_mask) >=
+ 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)
+ if (word0(&rv0) == Big0 && word1(&rv0) == Big1)
goto ovfl;
- word0(rv) = Big0;
- word1(rv) = Big1;
+ word0(&rv) = Big0;
+ word1(&rv) = Big1;
goto cont;
}
else
- word0(rv) += P*Exp_msk1;
+ word0(&rv) += P*Exp_msk1;
}
else {
#ifdef Avoid_Underflow
if ((z = aadj) == 0)
z = 1;
aadj = z;
- aadj1 = dsign ? aadj : -aadj;
+ dval(&aadj1) = dsign ? aadj : -aadj;
}
- word0(aadj1) += (2*P+1)*Exp_msk1 - y;
+ word0(&aadj1) += (2*P+1)*Exp_msk1 - y;
}
- adj = aadj1 * ulp(dval(rv));
- dval(rv) += adj;
+ 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;
- adj = aadj1 * ulp(dval(rv));
- dval(rv) += adj;
+ 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)
+ if ((word0(&rv) & Exp_mask) < P*Exp_msk1)
#else
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
+ if ((word0(&rv) & Exp_mask) <= P*Exp_msk1)
#endif
{
- if (word0(rv0) == Tiny0
- && word1(rv0) == Tiny1)
+ if (word0(&rv0) == Tiny0
+ && word1(&rv0) == Tiny1)
goto undfl;
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
+ word0(&rv) = Tiny0;
+ word1(&rv) = Tiny1;
goto cont;
}
else
- word0(rv) -= P*Exp_msk1;
+ word0(&rv) -= P*Exp_msk1;
}
else {
- adj = aadj1 * ulp(dval(rv));
- dval(rv) += adj;
+ dval(&adj) = dval(&aadj1) * ulp(&rv);
+ dval(&rv) += dval(&adj);
}
#else /*Sudden_Underflow*/
- /* Compute adj so that the IEEE rounding rules will
- * correctly round rv + adj in some half-way cases.
- * If rv * ulp(rv) is denormalized (i.e.,
+ /* 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.) {
- aadj1 = (double)(int)(aadj + 0.5);
+ dval(&aadj1) = (double)(int)(aadj + 0.5);
if (!dsign)
- aadj1 = -aadj1;
+ dval(&aadj1) = -dval(&aadj1);
}
- adj = aadj1 * ulp(dval(rv));
- dval(rv) += adj;
+ dval(&adj) = dval(&aadj1) * ulp(&rv);
+ dval(&rv) += adj;
#endif /*Sudden_Underflow*/
#endif /*Avoid_Underflow*/
}
- z = word0(rv) & Exp_mask;
+ z = word0(&rv) & Exp_mask;
#ifndef SET_INEXACT
#ifdef Avoid_Underflow
if (!scale)
L = (Long)aadj;
aadj -= L;
/* The tolerances below are conservative. */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
+ if (dsign || word1(&rv) || word0(&rv) & Bndry_mask) {
if (aadj < .4999999 || aadj > .5000001)
break;
}
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.;
+ word0(&rv0) = Exp_1 + (70 << Exp_shift);
+ word1(&rv0) = 0;
+ dval(&rv0) += 1.;
}
}
else if (!oldinexact)
#endif
#ifdef Avoid_Underflow
if (scale) {
- word0(rv0) = Exp_1 - 2*P*Exp_msk1;
- word1(rv0) = 0;
- dval(rv) *= dval(rv0);
+ 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 */
- if (word0(rv) == 0 && word1(rv) == 0)
+#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)) {
+ if (inexact && !(word0(&rv) & Exp_mask)) {
/* set underflow bit */
- dval(rv0) = 1e-300;
- dval(rv0) *= dval(rv0);
+ dval(&rv0) = 1e-300;
+ dval(&rv0) *= dval(&rv0);
}
#endif
- retfree:
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(bd0);
- Bfree(delta);
ret:
if (se)
*se = __UNCONST(s);
- return sign ? -dval(rv) : dval(rv);
+ return sign ? -dval(&rv) : dval(&rv);
}
-/* $NetBSD: strtodI.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtodI.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
static double
#ifdef KR_headers
-ulpdown(d) double *d;
+ulpdown(d) U *d;
#else
-ulpdown(double *d)
+ulpdown(U *d)
#endif
{
double u;
- ULong *L = (ULong*)d;
+ ULong *L = d->L;
- u = ulp(*d);
- if (!(L[_1] | L[_0] & 0xfffff)
+ u = ulp(d);
+ if (!(L[_1] | (L[_0] & 0xfffff))
&& (L[_0] & 0x7ff00000) > 0x00100000)
u *= 0.5;
return u;
ULong bits[2], sign;
Long exp;
int j, k;
- typedef union {
- double d[2];
- ULong L[4];
- } U;
U *u;
k = strtodg(s, sp, &fpi, &exp, bits);
sign = k & STRTOG_Neg ? 0x80000000L : 0;
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
- u->d[0] = u->d[1] = 0.;
+ dval(&u[0]) = dval(&u[1]) = 0.;
break;
case STRTOG_Zero:
- u->d[0] = u->d[1] = 0.;
+ dval(&u[0]) = dval(&u[1]) = 0.;
#ifdef Sudden_Underflow
if (k & STRTOG_Inexact) {
if (sign)
- u->L[_0] = 0x80100000L;
+ word0(&u[0]) = 0x80100000L;
else
- u->L[2+_0] = 0x100000L;
+ word0(&u[1]) = 0x100000L;
}
break;
#else
#endif
case STRTOG_Denormal:
- u->L[_1] = bits[0];
- u->L[_0] = bits[1];
+ word1(&u[0]) = bits[0];
+ word0(&u[0]) = bits[1];
goto contain;
case STRTOG_Normal:
- u->L[_1] = bits[0];
- u->L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
+ word1(&u[0]) = bits[0];
+ word0(&u[0]) = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
contain:
j = k & STRTOG_Inexact;
if (sign) {
- u->L[_0] |= sign;
+ word0(&u[0]) |= sign;
j = STRTOG_Inexact - j;
}
switch(j) {
case STRTOG_Inexlo:
#ifdef Sudden_Underflow
if ((u->L[_0] & 0x7ff00000) < 0x3500000) {
- u->L[2+_0] = u->L[_0] + 0x3500000;
- u->L[2+_1] = u->L[_1];
- u->d[1] += ulp(u->d[1]);
- u->L[2+_0] -= 0x3500000;
- if (!(u->L[2+_0] & 0x7ff00000)) {
- u->L[2+_0] = sign;
- u->L[2+_1] = 0;
+ 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
- u->d[1] = u->d[0] + ulp(u->d[0]);
+ dval(&u[1]) = dval(&u[0]) + ulp(&u[0]);
break;
case STRTOG_Inexhi:
- u->d[1] = u->d[0];
+ dval(&u[1]) = dval(&u[0]);
#ifdef Sudden_Underflow
- if ((u->L[_0] & 0x7ff00000) < 0x3500000) {
- u->L[_0] += 0x3500000;
- u->d[0] -= ulpdown(u->d);
- u->L[_0] -= 0x3500000;
- if (!(u->L[_0] & 0x7ff00000)) {
- u->L[_0] = sign;
- u->L[_1] = 0;
+ 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
- u->d[0] -= ulpdown(u->d);
+ dval(&u[0]) -= ulpdown(u);
break;
default:
- u->d[1] = u->d[0];
+ dval(&u[1]) = dval(&u[0]);
}
break;
case STRTOG_Infinite:
- u->L[_0] = u->L[2+_0] = sign | 0x7ff00000;
- u->L[_1] = u->L[2+_1] = 0;
+ word0(&u[0]) = word0(&u[1]) = sign | 0x7ff00000;
+ word1(&u[0]) = word1(&u[1]) = 0;
if (k & STRTOG_Inexact) {
if (sign) {
- u->L[2+_0] = 0xffefffffL;
- u->L[2+_1] = 0xffffffffL;
+ word0(&u[1]) = 0xffefffffL;
+ word1(&u[1]) = 0xffffffffL;
}
else {
- u->L[_0] = 0x7fefffffL;
- u->L[_1] = 0xffffffffL;
+ word0(&u[0]) = 0x7fefffffL;
+ word1(&u[0]) = 0xffffffffL;
}
}
break;
case STRTOG_NaN:
- u->L[0] = u->L[2] = d_QNAN0;
- u->L[1] = u->L[3] = d_QNAN1;
+ u->L[0] = (u+1)->L[0] = d_QNAN0;
+ u->L[1] = (u+1)->L[1] = d_QNAN1;
break;
case STRTOG_NaNbits:
- u->L[_0] = u->L[2+_0] = 0x7ff00000 | sign | bits[1];
- u->L[_1] = u->L[2+_1] = bits[0];
+ word0(&u[0]) = word0(&u[1]) = 0x7ff00000 | sign | bits[1];
+ word1(&u[0]) = word1(&u[1]) = bits[0];
}
return k;
}
-/* $NetBSD: strtodg.c,v 1.6 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtodg.c,v 1.10 2012/03/22 13:09:12 he Exp $ */
/****************************************************************
#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
-#ifdef VAX
- , 54, 56
-#endif
};
+#endif
Bigint *
#ifdef KR_headers
return b;
}
- int
+ void
#ifdef KR_headers
decrement(b) Bigint *b;
#else
*x++ = y & 0xffff;
} while(borrow && x < xe);
#endif
- return STRTOG_Inexlo;
}
static int
rvOK
#ifdef KR_headers
(d, fpi, expt, bits, exact, rd, irv)
- double d; CONST FPI *fpi; Long *expt; ULong *bits; int exact, rd, *irv;
+ U *d; CONST FPI *fpi; Long *expt; ULong *bits; int exact, rd, *irv;
#else
- (double d, CONST FPI *fpi, Long *expt, ULong *bits, int exact, int rd, int *irv)
+ (U *d, CONST FPI *fpi, Long *expt, ULong *bits, int exact, int rd, int *irv)
#endif
{
Bigint *b;
int bdif, e, j, k, k1, nb, rv;
carry = rv = 0;
- b = d2b(d, &e, &bdif);
+ b = d2b(dval(d), &e, &bdif);
bdif -= nb = fpi->nbits;
e += bdif;
if (bdif <= 0) {
goto ret;
}
switch(rd) {
- case 1:
+ case 1: /* round down (toward -Infinity) */
goto trunc;
- case 2:
+ case 2: /* round up (toward +Infinity) */
break;
default: /* round near */
k = bdif - 1;
#ifndef VAX
static int
#ifdef KR_headers
-mantbits(d) double d;
+mantbits(d) U *d;
#else
-mantbits(double d)
+mantbits(U *d)
#endif
{
ULong L;
#endif
{
int abe, abits, asub;
- int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, denorm;
+#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 adj, adj0, rv, tol;
+ double adj0, tol;
Long L;
- ULong y, z;
+ U adj, rv;
+ ULong *b, *be, y, z;
Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0;
+#ifdef USE_LOCALE /*{{*/
+#ifdef NO_LOCALE_CACHE
+ char *decimalpoint = localeconv()->decimal_point;
+ size_t dplen = strlen(decimalpoint);
+#else
+ char *decimalpoint;
+ static char *decimalpoint_cache;
+ static size_t dplen;
+ if (!(s0 = decimalpoint_cache)) {
+ s0 = localeconv()->decimal_point;
+ if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
+ strcpy(decimalpoint_cache, s0);
+ s0 = decimalpoint_cache;
+ }
+ dplen = strlen(s0);
+ }
+ decimalpoint = __UNCONST(s0);
+#endif /*NO_LOCALE_CACHE*/
+#else /*USE_LOCALE}{*/
+#define dplen 1
+#endif /*USE_LOCALE}}*/
e2 = 0; /* XXX gcc */
irv = STRTOG_Zero;
denorm = sign = nz0 = nz = 0;
- dval(rv) = 0.;
+ dval(&rv) = 0.;
rvb = 0;
nbits = fpi->nbits;
for(s = s00;;s++) switch(*s) {
sudden_underflow = fpi->sudden_underflow;
s0 = s;
y = z = 0;
- for(decpt = nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
+#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 == *localeconv()->decimal_point)
+ if (c == *decimalpoint) {
+ for(i = 1; decimalpoint[i]; ++i)
+ if (s[i] != decimalpoint[i])
+ goto dig_done;
+ s += i;
+ c = *s;
#else
- if (c == '.')
+ if (c == '.') {
+ c = *++s;
#endif
- {
+#ifdef INFNAN_CHECK
decpt = 1;
- c = *++s;
+#endif
if (!nd) {
for(; c == '0'; c = *++s)
nz++;
nz = 0;
}
}
- }
+ }/*}*/
dig_done:
e = 0;
if (c == 'e' || c == 'E') {
if (!nd0)
nd0 = nd;
k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
- dval(rv) = y;
+ dval(&rv) = y;
if (k > 9)
- dval(rv) = tens[k - 9] * dval(rv) + z;
+ dval(&rv) = tens[k - 9] * dval(&rv) + z;
bd0 = 0;
if (nbits <= P && nd <= DBL_DIG) {
if (!e) {
- if (rvOK(dval(rv), fpi, expt, bits, 1, rd, &irv))
+ if (rvOK(&rv, fpi, expt, bits, 1, rd, &irv))
goto ret;
}
else if (e > 0) {
#ifdef VAX
goto vax_ovfl_check;
#else
- i = fivesbits[e] + mantbits(dval(rv)) <= P;
- /* rv = */ rounded_product(dval(rv), tens[e]);
- if (rvOK(dval(rv), fpi, expt, bits, i, rd, &irv))
+ 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;
*/
e2 = e - i;
e1 -= i;
- dval(rv) *= tens[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)
+ 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);
+ word0(&adj) += P*Exp_msk1;
+ dval(&rv) = dval(&adj);
#else
- /* rv = */ rounded_product(dval(rv), tens[e2]);
+ /* rv = */ rounded_product(dval(&rv), tens[e2]);
#endif
- if (rvOK(dval(rv), fpi, expt, bits, 0, rd, &irv))
+ 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(dval(rv), fpi, expt, bits, 0, rd, &irv))
+ /* rv = */ rounded_quotient(dval(&rv), tens[-e]);
+ if (rvOK(&rv, fpi, expt, bits, 0, rd, &irv))
goto ret;
e1 -= e;
}
e2 = 0;
if (e1 > 0) {
if ( (i = e1 & 15) !=0)
- dval(rv) *= tens[i];
+ dval(&rv) *= tens[i];
if (e1 &= ~15) {
e1 = (unsigned int)e1 >> 4;
while(e1 >= (1 << (n_bigtens-1))) {
- e2 += ((word0(rv) & Exp_mask)
+ e2 += ((word0(&rv) & Exp_mask)
>> Exp_shift1) - Bias;
- word0(rv) &= ~Exp_mask;
- word0(rv) |= Bias << Exp_shift1;
- dval(rv) *= bigtens[n_bigtens-1];
+ 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;
+ 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];
+ dval(&rv) *= bigtens[j];
}
}
else if (e1 < 0) {
e1 = -e1;
if ( (i = e1 & 15) !=0)
- dval(rv) /= tens[i];
+ dval(&rv) /= tens[i];
if (e1 &= ~15) {
e1 = (unsigned int)e1 >> 4;
while(e1 >= (1 << (n_bigtens-1))) {
- e2 += ((word0(rv) & Exp_mask)
+ e2 += ((word0(&rv) & Exp_mask)
>> Exp_shift1) - Bias;
- word0(rv) &= ~Exp_mask;
- word0(rv) |= Bias << Exp_shift1;
- dval(rv) *= tinytens[n_bigtens-1];
+ 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;
+ 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];
+ dval(&rv) *= tinytens[j];
}
}
#ifdef IBM
*/
e2 <<= 2;
#endif
- rvb = d2b(dval(rv), &rve, &rvbits); /* rv = rvb * 2^rve */
+ rvb = d2b(dval(&rv), &rve, &rvbits); /* rv = rvb * 2^rve */
if (rvb == NULL)
return STRTOG_NoMemory;
rve += e2;
/* Put digits into bd: true value = bd * 10^e */
- bd0 = s2b(s0, nd0, nd, y);
+ bd0 = s2b(s0, nd0, nd, y, dplen);
for(;;) {
bd = Balloc(bd0->k);
rvb = increment(rvb);
if (rvb == NULL)
return STRTOG_NoMemory;
- if ( (j = rvbits & kmask) !=0)
- j = ULbits - j;
- if (hi0bits(rvb->x[(unsigned int)(rvb->wds - 1)
- >> kshift])
- != j)
+ j = kmask & (ULbits - (rvbits & kmask));
+ if (hi0bits(rvb->x[rvb->wds - 1]) != j)
rvbits++;
irv = STRTOG_Normal | STRTOG_Inexhi;
}
}
break;
}
- if ((dval(adj) = ratio(delta, bs)) <= 2.) {
+ if ((dval(&adj) = ratio(delta, bs)) <= 2.) {
adj1:
inex = STRTOG_Inexlo;
if (dsign) {
irv = STRTOG_Underflow | STRTOG_Inexlo;
break;
}
- adj0 = dval(adj) = 1.;
+ adj0 = dval(&adj) = 1.;
}
else {
- adj0 = dval(adj) *= 0.5;
+ adj0 = dval(&adj) *= 0.5;
if (dsign) {
asub = 0;
inex = STRTOG_Inexlo;
}
- if (dval(adj) < 2147483647.) {
+ if (dval(&adj) < 2147483647.) {
L = adj0;
adj0 -= L;
switch(rd) {
inex = STRTOG_Inexact - inex;
}
}
- dval(adj) = L;
+ dval(&adj) = L;
}
}
y = rve + rvbits;
- /* adj *= ulp(dval(rv)); */
+ /* adj *= ulp(dval(&rv)); */
/* if (asub) rv -= adj; else rv += adj; */
if (!denorm && rvbits < nbits) {
rve -= j;
rvbits = nbits;
}
- ab = d2b(dval(adj), &abe, &abits);
+ ab = d2b(dval(&adj), &abe, &abits);
if (ab == NULL)
return STRTOG_NoMemory;
if (abe < 0)
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) {
+ 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) {
+ else if (dval(&adj) > tol && adj0 < 1. - tol) {
irv |= inex;
break;
}
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;
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)
+ if (irv & STRTOG_Inexact) {
irv |= STRTOG_Underflow;
+#ifndef NO_ERRNO
+ errno = ERANGE;
+#endif
+ }
}
}
if (se)
-/* $NetBSD: strtodnrp.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtodnrp.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
strtod(CONST char *s, char **sp)
#endif
{
- static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+ static const FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
ULong bits[2];
- Long exp;
+ Long expt;
int k;
union { ULong L[2]; double d; } u;
- k = strtodg(s, sp, &fpi, &exp, bits);
+ k = strtodg(s, sp, &fpi, &expt, bits);
if (k == STRTOG_NoMemory) {
errno = ERANGE;
u.L[0] = Big0;
case STRTOG_Normal:
u.L[_1] = bits[0];
- u.L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
+ u.L[_0] = (bits[1] & ~0x100000) | ((expt + 0x3ff + 52) << 20);
break;
case STRTOG_Denormal:
-/* $NetBSD: strtof.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtof.c,v 1.5 2011/06/20 09:11:17 mrg Exp $ */
/****************************************************************
strtof(CONST char *s, char **sp)
#endif
{
- static CONST FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
+ 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);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory) {
errno = ERANGE;
return HUGE_VALF;
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;
-/* $NetBSD: strtof_vaxf.c,v 1.5 2008/03/28 00:56:54 he Exp $ */
+/* $NetBSD: strtof_vaxf.c,v 1.6 2011/07/01 03:20:06 matt Exp $ */
/****************************************************************
k = strtodg(s, sp, &fpi, &expt, bits);
if (k == STRTOG_NoMemory) {
errno = ERANGE;
- u.L[0] = Big0;
- u.L[1] = Big1;
- return u.f;
+ return HUGE_VALF;
}
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
- u.L[0] = 0;
+ default:
+ u.f = 0.0;
break;
case STRTOG_Normal:
break;
case STRTOG_Infinite:
- u.L[0] = 0xffff7fff;
+ u.f = HUGE_VALF;
break;
}
if (k & STRTOG_Neg)
u.L[0] |= 0x00008000L;
return u.f;
- }
+}
-/* $NetBSD: strtopQ.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopQ.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
strtopQ(CONST char *s, char **sp, void *V)
#endif
{
- static CONST FPI fpi = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, SI };
+ 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);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
switch(k & STRTOG_Retmask) {
-/* $NetBSD: strtopd.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
{
static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
ULong bits[2];
- Long exp;
+ Long expt;
int k;
+#ifdef Honor_FLT_ROUNDS
+#include "gdtoa_fltrnds.h"
+#else
+#define fpi &fpi0
+#endif
- k = strtodg(s, sp, &fpi0, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtod((ULong*)d, bits, exp, k);
+ ULtod((ULong*)d, bits, expt, k);
return k;
}
-/* $NetBSD: strtopdd.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopdd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
#endif
{
#ifdef Sudden_Underflow
- static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
+ static FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
#else
- static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
+ static FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
#endif
ULong bits[4];
- Long exp;
+ 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, &exp, bits);
+ rv = strtodg(s, sp, fpi, &expt, bits);
if (rv == STRTOG_NoMemory)
return rv;
u = (U*)dd;
case STRTOG_Normal:
u->L[_1] = (bits[1] >> 21 | bits[2] << 11) & 0xffffffffL;
- u->L[_0] = bits[2] >> 21 | bits[3] << 11 & 0xfffff
- | exp + 0x3ff + 105 << 20;
- exp += 0x3ff + 52;
+ 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 >= exp) {
- i = exp - 1;
- exp = 0;
+ if (i >= expt) {
+ i = expt - 1;
+ expt = 0;
}
else
- exp -= i;
+ expt -= i;
if (i > 0) {
- bits[1] = bits[1] << i | bits[0] >> 32-i;
+ 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 >= exp) {
- i = exp - 1;
- exp = 0;
+ if (i >= expt) {
+ i = expt - 1;
+ expt = 0;
}
else
- exp -= i;
+ expt -= i;
if (i < 32) {
- bits[1] = bits[0] >> 32 - i;
+ bits[1] = bits[0] >> (32 - i);
bits[0] = bits[0] << i & 0xffffffffL;
}
else {
- bits[1] = bits[0] << i - 32;
+ bits[1] = bits[0] << (i - 32);
bits[0] = 0;
}
}
break;
}
u->L[2+_1] = bits[0];
- u->L[2+_0] = bits[1] & 0xfffff | exp << 20;
+ u->L[2+_0] = (bits[1] & 0xfffff) | (expt << 20);
break;
case STRTOG_Denormal:
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[_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+_0] = bits[1] & ((1L << j) - 1);
u->L[2+_1] = bits[0];
break;
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[_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[_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[_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;
+ 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[_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;
+ u->L[2+_1] = bits[0] & ((1L << j) - 1);
break;
case STRTOG_Infinite:
-/* $NetBSD: strtopf.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopf.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
strtopf(CONST char *s, char **sp, float *f)
#endif
{
- static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
+ static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
ULong bits[1], *L;
- Long exp;
+ Long expt;
int k;
+#ifdef Honor_FLT_ROUNDS
+#include "gdtoa_fltrnds.h"
+#else
+#define fpi &fpi0
+#endif
- k = strtodg(s, sp, &fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
L = (ULong*)f;
case STRTOG_Normal:
case STRTOG_NaNbits:
- L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23;
+ L[0] = (bits[0] & 0x7fffff) | ((expt + 0x7f + 23) << 23);
break;
case STRTOG_Denormal:
-/* $NetBSD: strtopx.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopx.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
strtopx(CONST char *s, char **sp, void *V)
#endif
{
- static CONST FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+ 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);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
switch(k & STRTOG_Retmask) {
case STRTOG_Infinite:
L[_0] = 0x7fff;
- L[_1] = L[_2] = L[_3] = L[_4] = 0;
+ L[_1] = 0x8000;
+ L[_2] = L[_3] = L[_4] = 0;
break;
case STRTOG_NaN:
-/* $NetBSD: strtopxL.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtopxL.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
strtopxL(CONST char *s, char **sp, void *V)
#endif
{
- static CONST FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+ 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);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
switch(k & STRTOG_Retmask) {
case STRTOG_Infinite:
L[_0] = 0x7fff << 16;
- L[_1] = L[_2] = 0;
+ L[_1] = 0x80000000;
+ L[_2] = 0;
break;
case STRTOG_NaN:
-/* $NetBSD: strtorQ.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtorQ.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
void
#ifdef KR_headers
-ULtoQ(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+ULtoQ(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k;
#else
-ULtoQ(ULong *L, ULong *bits, Long exp, int k)
+ULtoQ(ULong *L, ULong *bits, Long expt, int k)
#endif
{
switch(k & STRTOG_Retmask) {
L[_3] = bits[0];
L[_2] = bits[1];
L[_1] = bits[2];
- L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);
+ L[_0] = (bits[3] & ~0x10000) | ((expt + 0x3fff + 112) << 16);
break;
case STRTOG_Denormal:
static FPI fpi0 = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI };
FPI *fpi, fpi1;
ULong bits[4];
- Long exp;
+ Long expt;
int k;
fpi = &fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
- k = strtodg(s, sp, fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtoQ((ULong*)L, bits, exp, k);
+ ULtoQ((ULong*)L, bits, expt, k);
return k;
}
-/* $NetBSD: strtordd.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtordd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
void
#ifdef KR_headers
-ULtodd(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+ULtodd(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k;
#else
-ULtodd(ULong *L, ULong *bits, Long exp, int k)
+ULtodd(ULong *L, ULong *bits, Long expt, int k)
#endif
{
int i, j;
case STRTOG_Normal:
L[_1] = (bits[1] >> 21 | bits[2] << 11) & (ULong)0xffffffffL;
- L[_0] = bits[2] >> 21 | bits[3] << 11 & 0xfffff
- | exp + 0x3ff + 105 << 20;
- exp += 0x3ff + 52;
+ 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 >= exp) {
- i = exp - 1;
- exp = 0;
+ if (i >= expt) {
+ i = expt - 1;
+ expt = 0;
}
else
- exp -= i;
+ expt -= i;
if (i > 0) {
- bits[1] = bits[1] << i | bits[0] >> 32-i;
+ 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 >= exp) {
- i = exp - 1;
- exp = 0;
+ if (i >= expt) {
+ i = expt - 1;
+ expt = 0;
}
else
- exp -= i;
+ expt -= i;
if (i < 32) {
- bits[1] = bits[0] >> 32 - i;
+ bits[1] = bits[0] >> (32 - i);
bits[0] = bits[0] << i & (ULong)0xffffffffL;
}
else {
- bits[1] = bits[0] << i - 32;
+ bits[1] = bits[0] << (i - 32);
bits[0] = 0;
}
}
break;
}
L[2+_1] = bits[0];
- L[2+_0] = bits[1] & 0xfffff | exp << 20;
+ L[2+_0] = (bits[1] & 0xfffff) | (expt << 20);
break;
case STRTOG_Denormal:
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[_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+_0] = bits[1] & (((ULong)1L << j) - 1);
L[2+_1] = bits[0];
break;
if (i < 0) {
j = -i;
i += 32;
- L[_0] = bits[2] >> j & 0xfffff | (33 + j) << 20;
+ 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+_0] = bits[1] & (((ULong)1L << j) - 1);
L[2+_1] = bits[0];
break;
}
if (i == 0) {
- L[_0] = bits[2] & 0xfffff | 33 << 20;
+ 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[_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;
+ 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[_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;
+ L[2+_1] = bits[0] & (((ULong)1L << j) - 1);
break;
case STRTOG_Infinite:
#endif
{
#ifdef Sudden_Underflow
- static FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
+ static CONST 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 };
+ static CONST FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
#endif
- FPI *fpi, fpi1;
+ CONST FPI *fpi;
+ FPI fpi1;
ULong bits[4];
- Long exp;
+ Long expt;
int k;
fpi = &fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
- k = strtodg(s, sp, fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtodd((ULong*)dd, bits, exp, k);
+ ULtodd((ULong*)dd, bits, expt, k);
return k;
}
-/* $NetBSD: strtorf.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtorf.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
void
#ifdef KR_headers
-ULtof(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+ULtof(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k;
#else
-ULtof(ULong *L, ULong *bits, Long exp, int k)
+ULtof(ULong *L, ULong *bits, Long expt, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_Normal:
case STRTOG_NaNbits:
- L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23;
+ L[0] = (bits[0] & 0x7fffff) | ((expt + 0x7f + 23) << 23);
break;
case STRTOG_Denormal:
strtorf(CONST char *s, char **sp, int rounding, float *f)
#endif
{
- static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
- FPI *fpi, fpi1;
+ static CONST FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
+ CONST FPI *fpi;
+ FPI fpi1;
ULong bits[1];
- Long exp;
+ Long expt;
int k;
fpi = &fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
- k = strtodg(s, sp, fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtof((ULong*)f, bits, exp, k);
+ ULtof((ULong*)f, bits, expt, k);
return k;
}
-/* $NetBSD: strtorx.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtorx.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
void
#ifdef KR_headers
-ULtox(L, bits, exp, k) UShort *L; ULong *bits; Long exp; int k;
+ULtox(L, bits, expt, k) UShort *L; ULong *bits; Long expt; int k;
#else
-ULtox(UShort *L, ULong *bits, Long exp, int k)
+ULtox(UShort *L, ULong *bits, Long expt, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_Normal:
case STRTOG_NaNbits:
- L[_0] = exp + 0x3fff + 63;
+ L[_0] = expt + 0x3fff + 63;
normal_bits:
L[_4] = (UShort)bits[0];
L[_3] = (UShort)(bits[0] >> 16);
case STRTOG_Infinite:
L[_0] = 0x7fff;
- L[_1] = L[_2] = L[_3] = L[_4] = 0;
+ L[_1] = 0x8000;
+ L[_2] = L[_3] = L[_4] = 0;
break;
case STRTOG_NaN:
strtorx(CONST char *s, char **sp, int rounding, void *L)
#endif
{
- static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
- FPI *fpi, fpi1;
+ static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+ CONST FPI *fpi;
+ FPI fpi1;
ULong bits[2];
- Long exp;
+ Long expt;
int k;
fpi = &fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
- k = strtodg(s, sp, fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtox((UShort*)L, bits, exp, k);
+ ULtox((UShort*)L, bits, expt, k);
return k;
}
-/* $NetBSD: strtorxL.c,v 1.3 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtorxL.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
void
#ifdef KR_headers
-ULtoxL(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+ULtoxL(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k;
#else
-ULtoxL(ULong *L, ULong *bits, Long exp, int k)
+ULtoxL(ULong *L, ULong *bits, Long expt, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_Normal:
case STRTOG_Denormal:
case STRTOG_NaNbits:
- L[_0] = (exp + 0x3fff + 63) << 16;
+ L[_0] = (expt + 0x3fff + 63) << 16;
L[_1] = bits[1];
L[_2] = bits[0];
break;
case STRTOG_Infinite:
L[_0] = 0x7fff << 16;
- L[_1] = L[_2] = 0;
+ L[_1] = 0x80000000;
+ L[_2] = 0;
break;
case STRTOG_NaN:
strtorxL(CONST char *s, char **sp, int rounding, void *L)
#endif
{
- static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
- FPI *fpi, fpi1;
+ static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+ CONST FPI *fpi;
+ FPI fpi1;
ULong bits[2];
- Long exp;
+ Long expt;
int k;
fpi = &fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
- k = strtodg(s, sp, fpi, &exp, bits);
+ k = strtodg(s, sp, fpi, &expt, bits);
if (k == STRTOG_NoMemory)
return k;
- ULtoxL((ULong*)L, bits, exp, k);
+ ULtoxL((ULong*)L, bits, expt, k);
return k;
}
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ 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 : "<null>");
+ 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;
+ }
--- /dev/null
+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 .
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+
+ 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;
+ }
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+
+ 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 : "<null>");
+ 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;
+ }
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include "gdtoa.h"
+int STRTOD_DIGLIM = 24;
+#ifdef KR_headers
+#define Void /*void*/
+#else
+#define Void void
+#endif
+
+#ifdef __STDC__
+#include <stdlib.h>
+#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;
+ }
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+
+ 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 : "<null>");
+ 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;
+ }
--- /dev/null
+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
--- /dev/null
+
+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
+
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+
+ 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 : "<null>");
+ 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;
+ }
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+
+static char *dir[4] = { "toward zero", "nearest", "toward +Infinity",
+ "toward -Infinity" };
+
+#ifdef Honor_FLT_ROUNDS
+#include <fenv.h>
+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 <locale.h>
+
+ struct lconv *
+localeconv(void)
+{
+ static struct lconv mylocale;
+ mylocale.decimal_point = "<Pt>";
+ return &mylocale;
+ }
+#endif
+
--- /dev/null
+# /****************************************************************
+# 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 <testnos $(INFFIX) >zap 2>&1
+ cmp dI.out zap || mv zap bad/dI.out
+ ./dItestsi <testnos $(INFFIX) >zap 2>&1
+ cmp dIsi.out zap || mv zap bad/dIsi.out
+ ./ddtestsi <testnos $(INFFIX) >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 <pftestnos >zap
+ cmp pftest.out zap && rm zap
+
+pf_testLq: pftest
+ ./pftest <pfLqtestnos >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
--- /dev/null
+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
--- /dev/null
+
+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
+
--- /dev/null
+%.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
--- /dev/null
+/****************************************************************
+
+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 <string.h>
+
+#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;
+ }
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+%.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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#define Sudden_Underflow
+#include "../strtoId.c"
--- /dev/null
+#define Sudden_Underflow
+#include "../strtoIdd.c"
--- /dev/null
+#define Sudden_Underflow
+#include "../strtodI.c"
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ 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>", 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;
+ }
--- /dev/null
+#define Sudden_Underflow
+#include "../strtopdd.c"
--- /dev/null
+#define Sudden_Underflow
+#include "../strtordd.c"
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+# 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
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+
+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
+
--- /dev/null
+***** 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
+
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ 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 : "<null>");
+ 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;
+ }
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+
+ 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;
+ }
--- /dev/null
+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
--- /dev/null
+/****************************************************************
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ 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 : "<null>");
+ 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;
+ }
-/* $NetBSD: ulp.c,v 1.2 2006/01/25 15:27:42 kleink Exp $ */
+/* $NetBSD: ulp.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */
/****************************************************************
double
ulp
#ifdef KR_headers
- (x) double x;
+ (x) U *x;
#else
- (double x)
+ (U *x)
#endif
{
Long L;
- double a;
+ U a;
L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
#ifndef Sudden_Underflow
#ifdef IBM
L |= Exp_msk1 >> 4;
#endif
- word0(a) = L;
- word1(a) = 0;
+ 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;
+ word0(&a) = 0x80000 >> L;
+ word1(&a) = 0;
}
else {
- word0(a) = 0;
+ word0(&a) = 0;
L -= Exp_shift;
- word1(a) = L >= 31 ? 1 : 1 << (31 - L);
+ word1(&a) = L >= 31 ? 1 : 1 << (31 - L);
}
}
#endif
- return a;
+ return dval(&a);
}
-README f2477cff 14190
+README 664d441 15750
arithchk.c ebbe5bc7 4075
dmisc.c c8daa18 4682
-dtoa.c 6a7b6fe 16876
-g_Qfmt.c f791d807 2839
-g__fmt.c 14dca85 2504
-g_ddfmt.c 10eae12a 3695
-g_dfmt.c f36c1014 2503
-g_ffmt.c fb83cfb5 2429
-g_xLfmt.c f216a096 2686
-g_xfmt.c ed824bf3 2775
-gdtoa.c e29409a6 16988
-gdtoa.h f208c204 4780
-gdtoaimp.h e3c2a970 19441
-gethex.c dba1616 5201
+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 f7ea38f9 2958
-makefile f890b12 2932
-misc.c 1757f7fc 14252
+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 e282e715 3655
+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 ef30d392 3454
+strtoIg.c fe47bc72 3591
strtoIx.c e50f716d 1960
strtoIxL.c ea0b821b 1931
-strtod.c eec1df60 20532
-strtodI.c 1c2440ce 3915
-strtodg.c f6c3dd52 19911
+strtod.c 1dabf6 22744
+strtodI.c f1dbb0af 4004
+strtodg.c eacc7424 21188
strtodnrp.c af895e9 2538
-strtof.c 1c5192d3 2073
-strtopQ.c f116d4f0 2563
-strtopd.c f7681c7a 1671
-strtopdd.c 9864fba 4497
-strtopf.c eb15b627 2067
-strtopx.c 1cafe482 2618
-strtopxL.c 1e4b77e9 2373
+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 1b266865 4936
-strtorf.c f0d86e2b 2396
-strtorx.c f19a56af 2947
-strtorxL.c 167fe87c 2704
+strtordd.c e3d20ab 4992
+strtorf.c fbe2ea18 2402
+strtorx.c 168faee5 2957
+strtorxL.c 42c6cec 2718
sum.c f525bad9 2494
-ulp.c 1e2e148f 1864
+ulp.c edb56c0b 1866
-/* $NetBSD: Lint_flt_rounds.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */
+/* $NetBSD: Lint_flt_rounds.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
int
-__flt_rounds()
+__flt_rounds(void)
{
return (0);
}
-/* $NetBSD: Lint_fpgetmask.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */
+/* $NetBSD: Lint_fpgetmask.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
fp_except
-fpgetmask()
+fpgetmask(void)
{
fp_except rv = { 0 };
-/* $NetBSD: Lint_fpgetround.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */
+/* $NetBSD: Lint_fpgetround.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
fp_rnd
-fpgetround()
+fpgetround(void)
{
fp_rnd rv = { 0 };
-/* $NetBSD: Lint_fpgetsticky.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */
+/* $NetBSD: Lint_fpgetsticky.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
fp_except
-fpgetsticky()
+fpgetsticky(void)
{
fp_except rv = { 0 };
-/* $NetBSD: Lint_resumecontext.c,v 1.2 2003/01/18 11:38:46 thorpej Exp $ */
+/* $NetBSD: Lint_resumecontext.c,v 1.3 2011/09/19 21:24:58 joerg Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
void
-_resumecontext()
+_resumecontext(void)
{
}
-# $NetBSD: Makefile.inc,v 1.173 2010/12/12 20:22:48 christos Exp $
+# $NetBSD: Makefile.inc,v 1.184 2012/04/12 22:08:32 christos Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
# setprogname.c
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
- closedir.c ctermid.c ctype_.c daemon.c \
+ closedir.c \
+ ctermid.c ctype_.c daemon.c \
dehumanize_number.c dirname.c err.c errx.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 \
getusershell.c glob.c humanize_number.c initdir.c initgroups.c \
isascii.c isatty.c isctype.c lockf.c nftw.c \
nice.c \
- opendir.c \
- pause.c popen.c psignal.c ptree.c pwcache.c \
- pw_scan.c raise.c randomid.c rb.c readdir.c rewinddir.c \
- scandir.c seekdir.c \
+ opendir.c pause.c popen.c \
+ psignal.c \
+ ptree.c pwcache.c pw_scan.c raise.c randomid.c rb.c readdir.c \
+ rewinddir.c scandir.c seekdir.c \
setjmperr.c setmode.c \
shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \
siglist.c signal.c signame.c sigrelse.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 utmp.c \
- utmpx.c valloc.c vis.c warn.c warnx.c \
- vwarn.c vwarnx.c verr.c verrx.c wait.c waitpid.c wordexp.c
-.else
-SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
- closedir.c closefrom.c \
- confstr.c ctermid.c ctype_.c daemon.c \
- dehumanize_number.c devname.c dirname.c disklabel.c err.c errx.c \
- errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
- extattr.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 pthread_atfork.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 utmp.c \
- utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \
+ utmpx.c valloc.c vis.c wait.c waitpid.c warn.c warnx.c \
vwarn.c vwarnx.c verr.c verrx.c wordexp.c
.endif
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.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 \
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 psignal.3 pwcache.3 pthread_atfork.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 \
err.3 warnx.3 err.3 vwarnx.3
MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 execv.3 \
exec.3 execvp.3 exec.3 exect.3
-MLINKS+=extattr.3 extattr_namespace_to_string.3 \
- extattr.3 extattr_string_to_namespace.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 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
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 \
MLINKS+=humanize_number.3 dehumanize_number.3
MLINKS+=makecontext.3 swapcontext.3
MLINKS+=popen.3 pclose.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
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 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)
-errlist.c: errlist.awk ${NETBSDSRCDIR}/include/sys/errno.h
- cat ${NETBSDSRCDIR}/include/sys/errno.h | ${TOOL_SED} 's/(_SIGN//' | ${TOOL_AWK} -f ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk > ${.TARGET}
+ ${TOOL_CAT} ${NETBSDSRCDIR}/sys/sys/errno.h | ${TOOL_SED} 's/(_SIGN//' | ${TOOL_AWK} -f ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk > ${.TARGET}
.else
-errlist.c: errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
.endif
-/* $NetBSD: _err.c,v 1.11 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _err.c,v 1.12 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _err.c,v 1.11 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _err.c,v 1.12 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
#include <stdarg.h>
-__dead void _verr(int eval, const char *, _BSD_VA_LIST_);
+__dead void _verr(int eval, const char *, va_list);
__dead void
err(int eval, const char *fmt, ...)
-/* $NetBSD: _errx.c,v 1.11 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _errx.c,v 1.12 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _errx.c,v 1.11 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _errx.c,v 1.12 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
#include <stdarg.h>
-__dead void _verrx(int eval, const char *, _BSD_VA_LIST_);
+__dead void _verrx(int eval, const char *, va_list);
__dead void
errx(int eval, const char *fmt, ...)
-/* $NetBSD: _sysconf.c,v 1.5 2009/10/21 01:07:45 snj Exp $ */
+/* $NetBSD: _sysconf.c,v 1.6 2012/03/20 16:36:04 matt Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _sysconf.c,v 1.5 2009/10/21 01:07:45 snj Exp $");
+__RCSID("$NetBSD: _sysconf.c,v 1.6 2012/03/20 16:36:04 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
#else
#include <unistd.h>
-long __sysconf __P((int)); /* XXX */
+long __sysconf(int); /* XXX */
long
-sysconf(name)
- int name;
+sysconf(int name)
{
return __sysconf(name);
-/* $NetBSD: _verr.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _verr.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _verr.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _verr.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
+#include <stdarg.h>
+
#if defined(__indr_reference)
__indr_reference(_verr, verr)
#else
-#ifdef __minix
-#include <stdarg.h>
-#endif
-__dead void _verr(int, const char *, _BSD_VA_LIST_);
+__dead void _verr(int, const char *, va_list);
void
-verr(int eval, const char *fmt, _BSD_VA_LIST_ ap)
+verr(int eval, const char *fmt, va_list ap)
{
_verr(eval, fmt, ap);
}
-/* $NetBSD: _verrx.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _verrx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _verrx.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _verrx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
+#include <stdarg.h>
+
#if defined(__indr_reference)
__indr_reference(_verrx, verrx)
#else
-#ifdef __minix
-#include <stdarg.h>
-#endif
-__dead void _verrx(int, const char *, _BSD_VA_LIST_);
+__dead void _verrx(int, const char *, va_list);
void
-verrx(int eval, const char *fmt, _BSD_VA_LIST_ ap)
+verrx(int eval, const char *fmt, va_list ap)
{
_verrx(eval, fmt, ap);
}
-/* $NetBSD: _vwarn.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _vwarn.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _vwarn.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _vwarn.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
+#include <stdarg.h>
+
#if defined(__indr_reference)
__indr_reference(_vwarn, vwarn)
#else
-#ifdef __minix
-#include <stdarg.h>
-#endif
-void _vwarn(const char *, _BSD_VA_LIST_);
+void _vwarn(const char *, va_list);
void
-vwarn(const char *fmt, _BSD_VA_LIST_ ap)
+vwarn(const char *fmt, va_list ap)
{
_vwarn(fmt, ap);
}
-/* $NetBSD: _vwarnx.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _vwarnx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _vwarnx.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _vwarnx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
+#include <stdarg.h>
+
#if defined(__indr_reference)
__indr_reference(_vwarnx, vwarnx)
#else
-#ifdef __minix
-#include <stdarg.h>
-#endif
-void _vwarnx(const char *, _BSD_VA_LIST_);
+void _vwarnx(const char *, va_list);
void
-vwarnx(const char *fmt, _BSD_VA_LIST_ ap)
+vwarnx(const char *fmt, va_list ap)
{
_vwarnx(fmt, ap);
}
-/* $NetBSD: _warn.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _warn.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _warn.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _warn.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
#include <stdarg.h>
-void _vwarn(const char *, _BSD_VA_LIST_);
+void _vwarn(const char *, va_list);
void
warn(const char *fmt, ...)
-/* $NetBSD: _warnx.c,v 1.10 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: _warnx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $ */
/*
* J.T. Conklin, December 12, 1994
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _warnx.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: _warnx.c,v 1.11 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
#include <stdarg.h>
-void _vwarnx(const char *, _BSD_VA_LIST_);
+void _vwarnx(const char *, va_list);
void
warnx(const char *fmt, ...)
-/* $NetBSD: alarm.c,v 1.10 2003/08/07 16:42:45 agc Exp $ */
+/* $NetBSD: alarm.c,v 1.11 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: alarm.c,v 1.10 2003/08/07 16:42:45 agc Exp $");
+__RCSID("$NetBSD: alarm.c,v 1.11 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
unsigned int
-alarm(secs)
- unsigned int secs;
+alarm(unsigned int secs)
{
struct itimerval it, oitv;
struct itimerval *itp = ⁢
-.\" $NetBSD: arc4random.3,v 1.7 2005/12/26 19:40:14 perry Exp $
+.\" $NetBSD: arc4random.3,v 1.9 2011/02/05 00:24:08 wiz Exp $
.\" $OpenBSD: arc4random.3,v 1.17 2000/12/21 14:07:41 aaron Exp $
.\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\"
.\" Manual page, using -mandoc macros
.\"
-.Dd April 15, 1997
+.Dd February 4, 2011
.Dt ARC4RANDOM 3
.Os
.Sh NAME
.Nm arc4random ,
+.Nm arc4random_buf ,
+.Nm arc4random_uniform ,
.Nm arc4random_stir ,
.Nm arc4random_addrandom
.Nd arc4 random number generator
.Ft uint32_t
.Fn arc4random "void"
.Ft void
+.Fn arc4random_buf "void *buffer" "size_t length"
+.Ft uint32_t
+.Fn arc4random_uniform "uint32_t upper_bound"
+.Ft void
.Fn arc4random_stir "void"
.Ft void
.Fn arc4random_addrandom "u_char *dat" "int datlen"
.Xr drand48 3 .
.Pp
The
+.Fn arc4random_buf
+function fills the
+.Fa buffer
+with
+.Fa length
+bytes of ARC4-derived random data.
+.Pp
+The
+.Fn arc4random_uniform
+function returns a uniformly distributed random number less than
+.Fa upper_bound
+avoiding modulo bias when the upper bound is not a power of two.
+.Pp
+The
.Fn arc4random_stir
function reads data from
.Pa /dev/urandom
-/* $NetBSD: arc4random.c,v 1.9 2005/12/24 21:11:16 perry Exp $ */
+/* $NetBSD: arc4random.c,v 1.20 2012/08/20 21:38:09 dsl Exp $ */
/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
/*
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: arc4random.c,v 1.9 2005/12/24 21:11:16 perry Exp $");
+__RCSID("$NetBSD: arc4random.c,v 1.20 2012/08/20 21:38:09 dsl Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
+#include "reentrant.h"
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#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
struct arc4_stream {
- u_int8_t i;
- u_int8_t j;
- u_int8_t s[256];
+ uint8_t stirred;
+ uint8_t pad;
+ uint8_t i;
+ uint8_t j;
+ uint8_t s[(uint8_t)~0u + 1u]; /* 256 to you and me */
+#ifdef _REENTRANT
+ mutex_t mtx;
+#endif
};
-static int rs_initialized;
-static struct arc4_stream rs;
+#ifdef _REENTRANT
+#define LOCK(rs) { \
+ int isthreaded = __isthreaded; \
+ if (isthreaded) \
+ mutex_lock(&(rs)->mtx);
+#define UNLOCK(rs) \
+ if (isthreaded) \
+ mutex_unlock(&(rs)->mtx); \
+ }
+#else
+#define LOCK(rs)
+#define UNLOCK(rs)
+#endif
+
+#define S(n) (n)
+#define S4(n) S(n), S(n + 1), S(n + 2), S(n + 3)
+#define S16(n) S4(n), S4(n + 4), S4(n + 8), S4(n + 12)
+#define S64(n) S16(n), S16(n + 16), S16(n + 32), S16(n + 48)
+#define S256 S64(0), S64(64), S64(128), S64(192)
+
+static struct arc4_stream rs = { .i = 0xff, .j = 0, .s = { S256 },
+#ifdef _REENTRANT
+ .stirred = 0, .mtx = MUTEX_INITIALIZER };
+#else
+ .stirred = 0 };
+#endif
+
+#undef S
+#undef S4
+#undef S16
+#undef S64
+#undef S256
-static inline void arc4_init(struct arc4_stream *);
static inline void arc4_addrandom(struct arc4_stream *, u_char *, int);
-static void arc4_stir(struct arc4_stream *);
-static inline u_int8_t arc4_getbyte(struct arc4_stream *);
-static inline u_int32_t arc4_getword(struct arc4_stream *);
+static __noinline void arc4_stir(struct arc4_stream *);
+static inline uint8_t arc4_getbyte(struct arc4_stream *);
+static inline uint32_t arc4_getword(struct arc4_stream *);
-static inline void
-arc4_init(as)
- struct arc4_stream *as;
+static inline int
+arc4_check_init(struct arc4_stream *as)
{
- int n;
+ if (__predict_true(rs.stirred))
+ return 0;
- for (n = 0; n < 256; n++)
- as->s[n] = n;
- as->i = 0;
- as->j = 0;
+ arc4_stir(as);
+ return 1;
}
static inline void
-arc4_addrandom(as, dat, datlen)
- struct arc4_stream *as;
- u_char *dat;
- int datlen;
+arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
{
- int n;
- u_int8_t si;
+ uint8_t si;
+ size_t n;
- as->i--;
- for (n = 0; n < 256; n++) {
+ for (n = 0; n < __arraycount(as->s); n++) {
as->i = (as->i + 1);
si = as->s[as->i];
as->j = (as->j + si + dat[n % datlen]);
as->s[as->i] = as->s[as->j];
as->s[as->j] = si;
}
- as->j = as->i;
}
-static void
-arc4_stir(as)
- struct arc4_stream *as;
+static __noinline void
+arc4_stir(struct arc4_stream *as)
{
- int fd;
+#ifdef __minix
+ /* LSC: We do not have a compatibility layer for the
+ * KERN_URND call, so use the old way... */
+ int fd;
+ size_t j;
struct {
struct timeval tv;
u_int rnd[(128 - sizeof(struct timeval)) / sizeof(u_int)];
} rdat;
- int n;
gettimeofday(&rdat.tv, NULL);
fd = open("/dev/urandom", O_RDONLY);
read(fd, rdat.rnd, sizeof(rdat.rnd));
close(fd);
}
-#ifdef KERN_URND
- else {
- int mib[2];
- u_int i;
- size_t len;
-
- /* Device could not be opened, we might be chrooted, take
- * randomness from sysctl. */
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_URND;
-
- for (i = 0; i < sizeof(rdat.rnd) / sizeof(u_int); i++) {
- len = sizeof(u_int);
- if (sysctl(mib, 2, &rdat.rnd[i], &len, NULL, 0) == -1)
- break;
- }
- }
-#endif
+
/* fd < 0 or failed sysctl ? Ah, what the heck. We'll just take
* whatever was on the stack... */
+#else
+ int rdat[32];
+ int mib[] = { CTL_KERN, KERN_URND };
+ size_t len;
+ size_t i, j;
- arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
+ /*
+ * This code once opened and read /dev/urandom on each
+ * call. That causes repeated rekeying of the kernel stream
+ * generator, which is very wasteful. Because of application
+ * behavior, caching the fd doesn't really help. So we just
+ * fill up the tank from sysctl, which is a tiny bit slower
+ * for us but much friendlier to other entropy consumers.
+ */
+
+ for (i = 0; i < __arraycount(rdat); i++) {
+ len = sizeof(rdat[i]);
+ if (sysctl(mib, 2, &rdat[i], &len, NULL, 0) == -1)
+ abort();
+ }
+#endif
+
+ arc4_addrandom(as, (void *) &rdat, (int)sizeof(rdat));
/*
* Throw away the first N words of output, as suggested in the
* paper "Weaknesses in the Key Scheduling Algorithm of RC4"
* by Fluher, Mantin, and Shamir. (N = 256 in our case.)
*/
- for (n = 0; n < 256 * 4; n++)
+ for (j = 0; j < __arraycount(as->s) * 4; j++)
arc4_getbyte(as);
+
+ as->stirred = 1;
}
-static inline u_int8_t
-arc4_getbyte(as)
- struct arc4_stream *as;
+static __always_inline uint8_t
+arc4_getbyte_ij(struct arc4_stream *as, uint8_t *i, uint8_t *j)
{
- u_int8_t si, sj;
-
- as->i = (as->i + 1);
- si = as->s[as->i];
- as->j = (as->j + si);
- sj = as->s[as->j];
- as->s[as->i] = sj;
- as->s[as->j] = si;
+ uint8_t si, sj;
+
+ *i = *i + 1;
+ si = as->s[*i];
+ *j = *j + si;
+ sj = as->s[*j];
+ as->s[*i] = sj;
+ as->s[*j] = si;
return (as->s[(si + sj) & 0xff]);
}
-static inline u_int32_t
-arc4_getword(as)
- struct arc4_stream *as;
+static inline uint8_t
+arc4_getbyte(struct arc4_stream *as)
+{
+ return arc4_getbyte_ij(as, &as->i, &as->j);
+}
+
+static inline uint32_t
+arc4_getword(struct arc4_stream *as)
{
- u_int32_t val;
+ uint32_t val;
val = arc4_getbyte(as) << 24;
val |= arc4_getbyte(as) << 16;
val |= arc4_getbyte(as) << 8;
}
void
-arc4random_stir()
+arc4random_stir(void)
{
- if (!rs_initialized) {
- arc4_init(&rs);
- rs_initialized = 1;
- }
+ LOCK(&rs);
arc4_stir(&rs);
+ UNLOCK(&rs);
}
void
-arc4random_addrandom(dat, datlen)
- u_char *dat;
- int datlen;
+arc4random_addrandom(u_char *dat, int datlen)
{
- if (!rs_initialized)
- arc4random_stir();
+ LOCK(&rs);
+ arc4_check_init(&rs);
arc4_addrandom(&rs, dat, datlen);
+ UNLOCK(&rs);
}
-u_int32_t
-arc4random()
+uint32_t
+arc4random(void)
{
- if (!rs_initialized)
- arc4random_stir();
- return arc4_getword(&rs);
+ uint32_t v;
+
+ LOCK(&rs);
+ arc4_check_init(&rs);
+ v = arc4_getword(&rs);
+ UNLOCK(&rs);
+ return v;
}
-#if 0
-/*-------- Test code for i386 --------*/
-#include <stdio.h>
-#include <machine/pctr.h>
-int
-main(int argc, char **argv)
+void
+arc4random_buf(void *buf, size_t len)
{
- const int iter = 1000000;
- int i;
- pctrval v;
+ uint8_t *bp = buf;
+ uint8_t *ep = bp + len;
+ uint8_t i, j;
- v = rdtsc();
- for (i = 0; i < iter; i++)
- arc4random();
- v = rdtsc() - v;
- v /= iter;
+ LOCK(&rs);
+ arc4_check_init(&rs);
- printf("%qd cycles\n", v);
+ /* cache i and j - compiler can't know 'buf' doesn't alias them */
+ i = rs.i;
+ j = rs.j;
+
+ while (bp < ep)
+ *bp++ = arc4_getbyte_ij(&rs, &i, &j);
+ rs.i = i;
+ rs.j = j;
+
+ UNLOCK(&rs);
+}
+
+/*-
+ * Written by Damien Miller.
+ * With simplifications by Jinmei Tatuya.
+ */
+
+/*
+ * Calculate a uniformly distributed random number less than
+ * upper_bound avoiding "modulo bias".
+ *
+ * Uniformity is achieved by generating new random numbers
+ * until the one returned is outside the range
+ * [0, 2^32 % upper_bound[. This guarantees the selected
+ * random number will be inside the range
+ * [2^32 % upper_bound, 2^32[ which maps back to
+ * [0, upper_bound[ after reduction modulo upper_bound.
+ */
+uint32_t
+arc4random_uniform(uint32_t upper_bound)
+{
+ uint32_t r, min;
+
+ if (upper_bound < 2)
+ return 0;
+
+ /* calculate (2^32 % upper_bound) avoiding 64-bit math */
+ /* ((2^32 - x) % x) == (2^32 % x) when x <= 2^31 */
+ min = (0xFFFFFFFFU - upper_bound + 1) % upper_bound;
+
+ LOCK(&rs);
+ arc4_check_init(&rs);
+
+ /*
+ * This could theoretically loop forever but each retry has
+ * p > 0.5 (worst case, usually far better) of selecting a
+ * number inside the range we need, so it should rarely need
+ * to re-roll (at all).
+ */
+ do
+ r = arc4_getword(&rs);
+ while (r < min);
+ UNLOCK(&rs);
+
+ return r % upper_bound;
}
-#endif
-/* $NetBSD: assert.c,v 1.16 2005/02/09 21:35:46 kleink Exp $ */
+/* $NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: assert.c,v 1.16 2005/02/09 21:35:46 kleink Exp $");
+__RCSID("$NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <syslog.h>
void
-__assert13(file, line, function, failedexpr)
- const char *file, *function, *failedexpr;
- int line;
+__assert13(const char *file, int line, const char *function,
+ const char *failedexpr)
{
(void)fprintf(stderr,
}
void
-__assert(file, line, failedexpr)
- const char *file, *failedexpr;
- int line;
+__assert(const char *file, int line, const char *failedexpr)
{
__assert13(file, line, NULL, failedexpr);
static int diagassert_flags = -1;
void
-__diagassert13(file, line, function, failedexpr)
- const char *file, *function, *failedexpr;
- int line;
+__diagassert13(const char *file, int line, const char *function,
+ const char *failedexpr)
{
char buf[1024];
}
void
-__diagassert(file, line, failedexpr)
- const char *file, *failedexpr;
- int line;
+__diagassert(const char *file, int line, const char *failedexpr)
{
__diagassert13(file, line, NULL, failedexpr);
-.\" $NetBSD: cgetcap.3,v 1.6 2009/08/19 15:43:02 joerg Exp $
+.\" $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.
.\"
.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
.\"
-.Dd February 1, 2008
+.Dd April 5, 2012
.Dt CGETCAP 3
.Os
.Sh NAME
.Dv NULL
if the requested capability couldn't be found.
The end of the capability value is signaled by a
-.Sq \&:
-or
-.Tn ASCII
-.Dv NUL
-(see below for capability database syntax).
+.Sq \&: .
+See
+.Xr capfile 5
+for a description of the capability syntax.
.Pp
.Fn cgetnum
retrieves the value of the numeric capability
being used.
Note that it does not erase the buffer pushed by a call to
.Fn cgetset .
-.Sh CAPABILITY DATABASE SYNTAX
-Capability databases are normally
-.Tn ASCII
-and may be edited with standard text editors.
-Blank lines and lines beginning with a
-.Sq #
-are comments and are ignored.
-Lines ending with a
-.Sq \|\e
-indicate that the next line is a continuation
-of the current line; the
-.Sq \|\e
-and following newline are ignored.
-Long lines are usually continued onto several physical
-lines by ending each line except the last with a
-.Sq \|\e .
-.Pp
-Capability databases consist of a series of records, one per logical line.
-Each record contains a variable number of
-.So \&: Sc Ns -separated
-fields (capabilities).
-Empty fields consisting entirely of white space
-characters (spaces and tabs) are ignored.
-.Pp
-The first capability of each record specifies its names, separated by
-.Sq |
-characters.
-These names are used to reference records in the database.
-By convention, the last name is usually a comment and is not intended as
-a lookup tag.
-For example, the
-.Em vt100
-record from the
-.Pa termcap
-database begins:
-.Pp
-.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:"
-.Pp
-giving four names that can be used to access the record.
-.Pp
-The remaining non-empty capabilities describe a set of (name, value)
-bindings, consisting of a name optionally followed by a typed value:
-.Bl -column "nameTvalue"
-.It name Ta "typeless [boolean] capability"
-.Em name No "is present [true]"
-.It name Ns Em \&T Ns value Ta capability
-.Pq Em name , \&T
-has value
-.Em value
-.It name@ Ta "no capability" Em name No exists
-.It name Ns Em T Ns \&@ Ta capability
-.Pq Em name , T
-does not exist
-.El
-.Pp
-Names consist of one or more characters.
-Names may contain any character except
-.Sq \&: ,
-but it's usually best
-to restrict them to the printable characters and avoid use of
-graphics like
-.Sq # ,
-.Sq = ,
-.Sq % ,
-.Sq @ ,
-etc.
-.Pp
-Types are single characters used to separate capability names from
-their associated typed values.
-Types may be any character except a
-.Sq \&: .
-Typically, graphics like
-.Sq # ,
-.Sq = ,
-.Sq % ,
-etc. are used.
-Values may be any number of characters and may contain any character except
-.Sq \&: .
.Sh CAPABILITY DATABASE SEMANTICS
Capability records describe a set of (name, value) bindings.
Names may have multiple values bound to them.
can be used to control if
.Qq tc
expansion is performed or not.
-.Pp
-When a database is searched for a capability record, the first matching
-record in the search is returned.
-When a record is scanned for a capability, the first matching
-capability is returned; the capability
-.Qq :nameT@:
-will hide any following definition of a value of type
-.Em T
-for
-.Fa name ;
-and the capability
-.Qq :name@:
-will prevent any following values of
-.Fa name
-from being seen.
-.Pp
-These features combined with
-.Qq tc
-capabilities can be used to generate variations of other databases and
-records by either adding new capabilities, overriding definitions with new
-definitions, or hiding following definitions via
-.Sq @
-capabilities.
-.Sh EXAMPLES
-.Bd -unfilled -offset indent
-example\||\|an example of binding multiple values to names:\e
- :foo%bar:foo^blah:foo@:\e
- :abc%xyz:abc^frap:abc$@:\e
- :tc=more:
-.Ed
-.Pp
-The capability
-.Em foo
-has two values bound to it
-.Po
-.Em bar
-of type
-.Sq %
-and
-.Em blah
-of type
-.Sq ^
-.Pc
-and any other value bindings are hidden.
-The capability
-.Em abc
-also has two values bound but only a value of type
-.Sq $
-is prevented from
-being defined in the capability record more.
-.Pp
-.Bd -unfilled -offset indent
-file1:
- new\||\|new_record\||\|a modification of "old":\e
- :fript=bar:who-cares@:tc=old:blah:tc=extensions:
-file2:
- old\||\|old_record\||\|an old database record:\e
- :fript=foo:who-cares:glork#200:
-.Ed
-.Pp
-The records are extracted by calling
-.Fn cgetent
-with
-.Fa file1
-preceding
-.Fa file2 .
-In the capability record
-.Em new
-in
-.Fa file1 ,
-.Qq fript=bar
-overrides the definition of
-.Qq fript=foo
-interpolated from the capability record
-.Em old
-in
-.Fa file2 ,
-.Qq who-cares@
-prevents the definition of any who-cares definitions in
-.Em old
-from being seen,
-.Qq glork#200
-is inherited from
-.Em old ,
-and
-.Em blah
-and anything defined by the record extensions is added to those
-definitions in
-.Em old .
-Note that the position of the
-.Qq fript=bar
-and
-.Qq who-cares@
-definitions before
-.Qq tc=old
-is important here.
-If they were after, the definitions in
-.Em old
-would take precedence.
-.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS
-Two types are predefined by
-.Fn cgetnum
-and
-.Fn cgetstr :
-.Bl -column "nameXnumber"
-.It Em name Ns \&# Ns Em number Ta numeric
-capability
-.Em name
-has value
-.Em number
-.It Em name Ns = Ns Em string Ta "string capability"
-.Em name
-has value
-.Em string
-.It Em name Ns \&#@ Ns Ta "the numeric capability"
-.Em name
-does not exist
-.It Em name Ns \&=@ Ns Ta "the string capability"
-.Em name
-does not exist
-.El
-.Pp
-Numeric capability values may be given in one of three numeric bases.
-If the number starts with either
-.Ql 0x
-or
-.Ql 0X
-it is interpreted as a hexadecimal number (both upper and lower case a-f
-may be used to denote the extended hexadecimal digits).
-Otherwise, if the number starts with a
-.Ql 0
-it is interpreted as an octal number.
-Otherwise the number is interpreted as a decimal number.
-.Pp
-String capability values may contain any character.
-Non-printable
-.Dv ASCII
-codes, new lines, and colons may be conveniently represented by the use
-of escape sequences:
-.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)"
-.It ^X ('\fIX\fP' \*[Am] 037) control-\fIX\fP
-.It \e\|b, \e\|B (ASCII 010) backspace
-.It \e\|t, \e\|T (ASCII 011) tab
-.It \e\|n, \e\|N (ASCII 012) line feed (newline)
-.It \e\|f, \e\|F (ASCII 014) form feed
-.It \e\|r, \e\|R (ASCII 015) carriage return
-.It \e\|e, \e\|E (ASCII 027) escape
-.It \e\|c, \e\|C (:) colon
-.It \e\|\e (\e\|) back slash
-.It \e\|^ (^) caret
-.It \e\|\fInnn\fP (ASCII octal \fInnn\fP)
-.El
-.Pp
-A
-.Sq \|\e
-followed by up to three octal digits directly specifies
-the numeric code for a character.
-The use of
-.Tn ASCII
-.Dv NUL Ns s ,
-while easily
-encoded, causes all sorts of problems and must be used with care since
-.Dv NUL Ns s
-are typically used to denote the end of strings; many applications
-use
-.Sq \e\|200
-to represent a
-.Dv NUL .
.Sh DIAGNOSTICS
.Fn cgetent ,
.Fn cgetset ,
.El
.Sh SEE ALSO
.Xr cap_mkdb 1 ,
-.Xr malloc 3
+.Xr malloc 3 ,
+.Xr capfile 5
.Sh BUGS
-Colons
-.Pq Sq \&:
-can't be used in names, types, or values.
-.Pp
There are no checks for
.Qq tc=name
loops in
-/* $NetBSD: confstr.c,v 1.12 2006/12/03 00:39:19 christos Exp $ */
+/* $NetBSD: confstr.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)confstr.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: confstr.c,v 1.12 2006/12/03 00:39:19 christos Exp $");
+__RCSID("$NetBSD: confstr.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
size_t
-confstr(name, buf, len)
- int name;
- char *buf;
- size_t len;
+confstr(int name, char *buf, size_t len)
{
size_t tlen;
int mib[2], sverrno;
-.\" $NetBSD: cpuset.3,v 1.3 2008/09/12 13:39:04 rmind Exp $
+.\" $NetBSD: cpuset.3,v 1.6 2011/11/02 20:25:20 wiz Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 12, 2008
+.Dd November 2, 2011
.Dt CPUSET 3
.Os
.Sh NAME
.Nd dynamic CPU sets
.Sh SYNOPSIS
.In sched.h
-.Ft cpuset_t
+.Ft cpuset_t *
.Fn cpuset_create "void"
.Ft void
.Fn cpuset_destroy "cpuset_t *set"
.Xr affinity 3 ,
.Xr pset 3 ,
.Xr sched 3 ,
-.Xr schedctl 8
+.Xr schedctl 8 ,
+.Xr kcpuset 9
.Sh HISTORY
The dynamic CPU sets appeared in
.Nx 5.0 .
-/* $NetBSD: ctermid.c,v 1.10 2003/08/07 16:42:46 agc Exp $ */
+/* $NetBSD: ctermid.c,v 1.11 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)ctermid.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ctermid.c,v 1.10 2003/08/07 16:42:46 agc Exp $");
+__RCSID("$NetBSD: ctermid.c,v 1.11 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
char *
-ctermid(s)
- char *s;
+ctermid(char *s)
{
static char def[] = _PATH_TTY;
-/* $NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $ */
+/* $NetBSD: daemon.c,v 1.10 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $");
+__RCSID("$NetBSD: daemon.c,v 1.10 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-daemon(nochdir, noclose)
- int nochdir, noclose;
+daemon(int nochdir, int noclose)
{
int fd;
-/* $NetBSD: dehumanize_number.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: dehumanize_number.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */
/*
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dehumanize_number.c,v 1.3 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: dehumanize_number.c,v 1.4 2012/03/13 21:13:34 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
+#include <assert.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdlib.h>
errno = ERANGE;
return -1; /* Out of range. */
}
- *size = tmp * multiplier;
+ tmp *= multiplier;
+ _DIAGASSERT(__type_fit(int64_t, tmp));
+ *size = (int64_t)tmp;
return 0;
}
-.\" $NetBSD: devname.3,v 1.11 2003/08/07 16:42:46 agc Exp $
+.\" $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.
.\"
.\" @(#)devname.3 8.2 (Berkeley) 4/29/95
.\"
-.Dd April 29, 1995
+.Dd June 3, 2012
.Dt DEVNAME 3
.Os
.Sh NAME
and a file type matching the one encoded in
.Fa type
which must be one of S_IFBLK or S_IFCHR.
-The device name is cached so that multiple calls with the same
-.Fa dev
-and
-.Fa type
-do not require additional queries of the device database file.
If no device matches the specified values, or no information is
available,
.Dv NULL
found is the string
.Dq ?? .
.Sh FILES
-.Bl -tag -width /var/run/dev.db -compact
-.It Pa /var/run/dev.db
+.Bl -tag -width /var/run/dev.cdb -compact
+.It Pa /var/run/dev.cdb
Device database file.
.El
.Sh SEE ALSO
-/* $NetBSD: devname.c,v 1.21 2010/03/23 20:28:59 drochner Exp $ */
+/* $NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $ */
/*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
- * Copyright (c) 1992 Keith Muller.
- * Copyright (c) 1989, 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.
- */
-
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
-#else
-__RCSID("$NetBSD: devname.c,v 1.21 2010/03/23 20:28:59 drochner Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $");
#include "namespace.h"
-#include <sys/types.h>
+#include "reentrant.h"
#include <sys/stat.h>
-#include <sys/param.h>
-#include <db.h>
-#include <fcntl.h>
+#include <cdbr.h>
+#include <errno.h>
+#include <fts.h>
+#include <limits.h>
#include <paths.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <err.h>
-#define DEV_SZ 317 /* show be prime for best results */
-#define VALID 1 /* entry and devname are valid */
-#define INVALID 2 /* entry valid, devname NOT valid */
+#ifdef __weak_alias
+__weak_alias(devname_r,_devname_r)
+#endif
-typedef struct devc {
- int valid; /* entry valid? */
- dev_t dev; /* cached device */
- mode_t type; /* cached file type */
- char name[NAME_MAX]; /* device name */
-} DEVC;
+static once_t db_opened = ONCE_INITIALIZER;
+static struct cdbr *db;
+static devmajor_t pts;
-char *
-devname(dev, type)
- dev_t dev;
- mode_t type;
+static void
+devname_dbopen(void)
{
- struct {
- mode_t type;
- dev_t dev;
- } bkey;
- struct {
- mode_t type;
- int32_t dev;
- } obkey;
- static DB *db;
- static int failure;
- DBT data, key;
- DEVC *ptr, **pptr;
- static DEVC **devtb = NULL;
- static devmajor_t pts;
- static int pts_valid = 0;
-
- if (!db && !failure &&
- !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
- warn("warning: %s", _PATH_DEVDB);
- failure = 1;
- }
- /* initialise dev cache */
- if (!failure && devtb == NULL) {
- devtb = calloc(DEV_SZ, sizeof(DEVC *));
- if (devtb == NULL)
- failure= 1;
- }
- if (failure)
- return (NULL);
+ db = cdbr_open(_PATH_DEVCDB, CDBR_DEFAULT);
+ pts = getdevmajor("pts", S_IFCHR);
+}
- /* see if we have this dev/type cached */
- pptr = devtb + (size_t)((dev + type) % DEV_SZ);
- ptr = *pptr;
+__CTASSERT(sizeof(dev_t) == 8);
- if (ptr && ptr->valid > 0 && ptr->dev == dev && ptr->type == type) {
- if (ptr->valid == VALID)
- return (ptr->name);
- return (NULL);
- }
+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;
+
+ rv = snprintf(path, len, "%s%d", _PATH_DEV_PTS + sizeof(_PATH_DEV) - 1,
+ minor(dev));
+ if (rv < 0 || (size_t)rv >= len)
+ return ERANGE;
+ return 0;
+}
- if (ptr == NULL)
- *pptr = ptr = malloc(sizeof(DEVC));
-
- /*
- * Keys are a mode_t followed by a dev_t. The former is the type of
- * the file (mode & S_IFMT), the latter is the st_rdev field. Be
- * sure to clear any padding that may be found in bkey.
- */
- (void)memset(&bkey, 0, sizeof(bkey));
- bkey.dev = dev;
- bkey.type = type;
- key.data = &bkey;
- key.size = sizeof(bkey);
- if ((db->get)(db, &key, &data, 0) == 0) {
-found_it:
- if (ptr == NULL)
- return (char *)data.data;
- ptr->dev = dev;
- ptr->type = type;
- strncpy(ptr->name, (char *)data.data, NAME_MAX);
- ptr->name[NAME_MAX - 1] = '\0';
- ptr->valid = VALID;
- } else {
- /* Look for a 32 bit dev_t. */
- (void)memset(&obkey, 0, sizeof(obkey));
- obkey.dev = (int32_t)(uint32_t)dev;
- obkey.type = type;
- key.data = &obkey;
- key.size = sizeof(obkey);
- if ((db->get)(db, &key, &data, 0) == 0)
- goto found_it;
-
- if (ptr == NULL)
- return (NULL);
- ptr->valid = INVALID;
- if (type == S_IFCHR) {
- if (!pts_valid) {
- pts = getdevmajor("pts", S_IFCHR);
- pts_valid = 1;
- }
- if (pts != NODEVMAJOR && major(dev) == pts) {
- (void)snprintf(ptr->name, sizeof(ptr->name),
- "%s%d", _PATH_DEV_PTS +
- sizeof(_PATH_DEV) - 1,
- minor(dev));
- ptr->valid = VALID;
- }
+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;
}
- ptr->dev = dev;
- ptr->type = type;
}
- if (ptr->valid == VALID)
- return (ptr->name);
- else
- return (NULL);
+
+ 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;
}
-.\" $NetBSD: directory.3,v 1.36 2010/12/17 19:20:42 njoly Exp $
+.\" $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.
.\"
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 2010
+.Dd October 15, 2011
.Dt DIRECTORY 3
.Os
.Sh NAME
.Ft long
.Fn telldir "DIR *dirp"
.Ft void
-.Fn seekdir "DIR *dirp" "long loc"
+.Fn seekdir "DIR *dirp" "long loc"
.Ft void
.Fn rewinddir "DIR *dirp"
.Ft int
.Fn dirfd
functions appeared in
.Bx 4.2 .
+The
+.Fn fdopendir
+function appeared in
+.Nx 6.0 .
-/* $NetBSD: disklabel.c,v 1.34 2006/03/19 02:17:16 christos Exp $ */
+/* $NetBSD: disklabel.c,v 1.37 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1983, 1987, 1993
#if 0
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: disklabel.c,v 1.34 2006/03/19 02:17:16 christos Exp $");
+__RCSID("$NetBSD: disklabel.c,v 1.37 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
#if 0
-static void error __P((int));
+static void error(int);
#endif
-static int gettype __P((char *, const char *const *));
+static int gettype(char *, const char *const *);
static const char *db_array[2] = { _PATH_DISKTAB, 0 };
int
-setdisktab(name)
- const char *name;
+setdisktab(const char *name)
{
if (!name || !*name)
return -1;
struct disklabel *
-getdiskbyname(name)
- const char *name;
+getdiskbyname(const char *name)
{
static struct disklabel disk;
struct disklabel *dp = &disk;
}
static int
-gettype(t, names)
- char *t;
- const char *const *names;
+gettype(char *t, const char *const *names)
{
const char *const *nm;
for (nm = names; *nm; nm++)
if (strcasecmp(t, *nm) == 0)
- return (nm - names);
+ return (int)(nm - names);
if (isdigit((unsigned char) *t))
return (atoi(t));
return (0);
-/* $NetBSD: execl.c,v 1.16 2008/01/09 11:26:03 simonb Exp $ */
+/* $NetBSD: execl.c,v 1.17 2011/06/30 19:46:07 joerg Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: execl.c,v 1.16 2008/01/09 11:26:03 simonb Exp $");
+__RCSID("$NetBSD: execl.c,v 1.17 2011/06/30 19:46:07 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
execl(const char *name, const char *arg, ...)
{
int r;
-#if (defined(__i386__) || defined(__m68k__)) && !defined(__minix)
- r = execve(name, __UNCONST(&arg), environ);
- return r;
-#else
va_list ap;
char **argv;
int i;
r = execve(name, argv, environ);
return r;
-#endif
}
-/* $NetBSD: execle.c,v 1.11 2008/01/09 11:26:03 simonb Exp $ */
+/* $NetBSD: execle.c,v 1.12 2011/06/30 19:46:07 joerg Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: execle.c,v 1.11 2008/01/09 11:26:03 simonb Exp $");
+__RCSID("$NetBSD: execle.c,v 1.12 2011/06/30 19:46:07 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
int
execle(const char *name, const char *arg, ...)
{
-#if (defined(__i386__) || defined(__m68k__)) && !defined(__minix)
- va_list ap;
- char **envp;
-
- va_start(ap, arg);
- while ((va_arg(ap, char *)) != NULL)
- continue;
- envp = va_arg(ap, char **);
- va_end(ap);
-
- return execve(name, __UNCONST(&arg), envp);
-#else
va_list ap;
char **argv, **envp;
int i;
va_end(ap);
return execve(name, argv, envp);
-#endif
}
-/* $NetBSD: execlp.c,v 1.11 2008/01/09 11:26:03 simonb Exp $ */
+/* $NetBSD: execlp.c,v 1.12 2011/06/30 19:46:07 joerg Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: execlp.c,v 1.11 2008/01/09 11:26:03 simonb Exp $");
+__RCSID("$NetBSD: execlp.c,v 1.12 2011/06/30 19:46:07 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
int
execlp(const char *name, const char *arg, ...)
{
-#if (defined(__i386__) || defined(__m68k__)) && !defined(__minix)
- return execvp(name, __UNCONST(&arg));
-#else
va_list ap;
char **argv;
int i;
va_end(ap);
return execvp(name, argv);
-#endif
}
-/* $NetBSD: execv.c,v 1.9 2005/11/29 13:30:49 christos Exp $ */
+/* $NetBSD: execv.c,v 1.10 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: execv.c,v 1.9 2005/11/29 13:30:49 christos Exp $");
+__RCSID("$NetBSD: execv.c,v 1.10 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
extern char **environ;
int
-execv(name, argv)
- const char *name;
- char * const *argv;
+execv(const char *name, char * const *argv)
{
return execve(name, argv, environ);
}
-/* $NetBSD: extattr.c,v 1.2 2005/02/09 21:35:46 kleink Exp $ */
+/* $NetBSD: extattr.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */
/*-
* Copyright (c) 2001 Robert N. M. Watson
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: extattr.c,v 1.2 2005/02/09 21:35:46 kleink Exp $");
+__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 <sys/types.h>
+#include <sys/param.h>
#include <sys/extattr.h>
#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
#include <string.h>
+const int extattr_namespaces[] = {
+ EXTATTR_NAMESPACE_USER,
+ EXTATTR_NAMESPACE_SYSTEM,
+ 0,
+};
+
int
extattr_namespace_to_string(int attrnamespace, char **string)
{
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;
+}
--- /dev/null
+.\" $NetBSD: extattr_copy_file.3,v 1.2 2011/12/16 15:21:13 manu Exp $
+.\"
+.\" Copyright (c) 2001 Dima Dorfman <dd@FreeBSD.org>
+.\" Copyright (c) 2011 Emmanuel Dreyfus <manu@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.
+.\"
+.\" 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.
-.\" $NetBSD: extattr.3,v 1.3 2005/01/02 18:25:09 wiz Exp $
+.\" $NetBSD: extattr_namespace_to_string.3,v 1.1 2011/12/16 12:46:00 wiz Exp $
.\"
.\" Copyright (c) 2001 Dima Dorfman <dd@FreeBSD.org>
+.\" Copyright (c) 2011 Emmanuel Dreyfus <manu@NetBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\"
.\" FreeBSD: src/lib/libc/posix1e/extattr.3,v 1.5 2002/12/12 17:25:53 ru Exp
.\"
-.Dd January 2, 2004
-.Dt EXTATTR 3
+.Dd December 16, 2011
+.Dt EXTATTR_NAMESPACE_TO_STRING 3
.Os
.Sh NAME
.Nm extattr_namespace_to_string ,
.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
--- /dev/null
+/* $NetBSD: fixunsdfsi_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 <sys/cdefs.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fixunsdfsi_ieee754.c,v 1.2 2012/08/05 04:28:58 matt Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <float.h>
+#include <machine/ieee.h>
+
+#ifdef SOFTFLOAT
+#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]);
+}
-/* $NetBSD: bsdctype_file.h,v 1.1 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: fixunsgen64_ieee754.c,v 1.1 2011/07/09 02:30:27 matt Exp $ */
/*-
- * Copyright (c)2008 Citrus Project,
- * 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.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its 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
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, 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
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* SUCH DAMAGE.
*/
-#ifndef _BSDCTYPE_FILE_H_
-#define _BSDCTYPE_FILE_H_
-
-#include "ctype_local.h"
+#include <sys/cdefs.h>
-typedef struct {
- char fbl_id[8];
- uint32_t fbl_rev;
- uint32_t fbl_num_chars;
- uint8_t fbl_ctype_tab [_CTYPE_CACHE_SIZE];
- int16_t fbl_tolower_tab[_CTYPE_CACHE_SIZE];
- int16_t fbl_toupper_tab[_CTYPE_CACHE_SIZE];
-} __packed _FileBSDCTypeLocale;
+#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 _CTYPE_ID "BSDCTYPE"
-#define _CTYPE_REV 2
+#define FIXUNSNAME(n) n##64
+#define UINTXX_T uint64_t
-#endif /*_BSDCTYPE_FILE_H_*/
+#include "fixunsgen_ieee754.c"
--- /dev/null
+/* $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 <sys/cdefs.h>
+
+#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 <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <float.h>
+
+#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;
+}
--- /dev/null
+/* $NetBSD: fixunssfsi_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 <sys/cdefs.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fixunssfsi_ieee754.c,v 1.2 2012/08/05 04:28:58 matt Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <float.h>
+#include <machine/ieee.h>
+
+#ifdef SOFTFLOAT
+#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]);
+}
--- /dev/null
+/* $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 <sys/cdefs.h>
+
+#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 <stdbool.h>
+#include <stdint.h>
+#include <float.h>
+#include <machine/ieee.h>
+
+#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]);
+}
-/* $NetBSD: localeio_lc_numeric.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
-
-/*
- * Copyright (c) 2008, The NetBSD Foundation, Inc.
+/* $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 Brian Ginsbach.
+ * 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
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
*/
#include <sys/cdefs.h>
+
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio_lc_numeric.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: fixunstfsi_ieee754.c,v 1.2 2012/08/05 04:28:58 matt Exp $");
#endif /* LIBC_SCCS and not lint */
-#include "reentrant.h"
-#include <sys/types.h>
-#include <sys/localedef.h>
-#include <sys/queue.h>
-#include <assert.h>
-#include <errno.h>
-#include <langinfo.h>
-#include <limits.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "setlocale_local.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include <float.h>
+#include <machine/ieee.h>
-#include "aliasname_local.h"
-#include "fix_grouping.h"
-#include "localeio.h"
+#ifdef SOFTFLOAT
+#include "softfloat/softfloat-for-gcc.h"
+#endif
-/*
- * macro required by all template headers
- */
-#define _PREFIX(name) __CONCAT(_localeio_LC_NUMERIC_, name)
+#if defined(__x86_64__) || defined(__i486__)
+#define FIXUNS __fixunsxfsi
+#else
+#define FIXUNS __fixunstfsi
+#endif
-#include "nb_lc_numeric_misc.h"
-#include "nb_lc_template_decl.h"
+uint32_t __fixunsgen32(int, bool, size_t, size_t, const uint32_t *);
-#define NSTRINGS (sizeof(_NumericLocale)/sizeof(const char **))
+uint32_t FIXUNS(long double);
-static int
-_localeio_LC_NUMERIC_create_impl(const char * __restrict root,
- const char * __restrict name, _NumericLocale ** __restrict pdata)
+/*
+ * Convert long double to (unsigned) int. All operations are done module 2^32.
+ */
+uint32_t
+FIXUNS(long double x)
{
- char path[PATH_MAX + 1];
- int ret;
+ const union ieee_ext_u extu = { .extu_ld = x };
+ uint32_t frac[(EXT_FRACBITS + 31)/32 + 1];
- _DIAGASSERT(root != NULL);
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(pdata != NULL);
+ frac[0] = 0;
- snprintf(path, sizeof(path),
- "%s/%s/LC_NUMERIC", root, name);
- ret = __loadlocale(path, NSTRINGS, 0, sizeof(_NumericLocale),
- (void *)pdata);
- if (!ret) {
- (*pdata)->grouping =
- __fix_locale_grouping_str((*pdata)->grouping);
- }
- return ret;
-}
+ EXT_TO_ARRAY32(extu, &frac[1]);
-#include "nb_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_localeio_LC_NUMERIC_);
+ 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]);
+}
-.\" $NetBSD: fmtmsg.3,v 1.6 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: fmtmsg.3,v 1.7 2011/04/11 05:59:11 jruoho Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 10, 1999
+.Dd April 11, 2011
.Dt FMTMSG 3
.Os
.Sh NAME
from the condition causing the message and where to display the message
is specified in
.Fa classification .
-.Ss classification
+.Ss Classification
The
.Fa classification
argument consists of a major classification and several sub-classifications.
may be specified for each (sub-)classification.
The following classifications
are available:
-.Bl -tag -width MessageXSourceXSub-classificationsXX
-.It Major Classifications
+.Bl -tag -width "XXX"
+.It Em Major classifications
The source of the condition.
Available identifiers are:
.Dv MM_HARD
(software), and
.Dv MM_FIRM
(firmware).
-.It Message Source Sub-classifications
+.It Em Message source sub-classifications
The type of software detecting the condition.
Available identifiers are:
.Dv MM_APPL
(utility), and
.Dv MM_OPSYS
(operating system).
-.It Display Sub-classifications
+.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 Status Sub-classifications
+.It Em Status sub-classifications
The capability of the calling software to recover from the condition.
Available identifiers are:
.Dv MM_RECOVER
is to be supplied,
.Dv MM_NULLMC
must be specified.
-.Ss label
+.Ss Label
The
.Fa label
argument identifies the source of the message.
is to be supplied,
.Dv MM_NULLLBL
must be specified.
-.Ss severity
+.Ss Severity
The seriousness of the condition causing the message.
The following
.Fa severity
levels are available:
-.Bl -tag -width MM_WARNINGXX
+.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
level is to be supplied,
.Dv MM_NOSEV
must be specified.
-.Ss text
+.Ss Text
The description of the condition the software encountered.
The character
string is not limited to a specific size.
is to be supplied,
.Dv MM_NOTXT
must be specified.
-.Ss action
+.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: .
is to be supplied,
.Dv MM_NOACT
must be specified.
-.Ss tag
+.Ss Tag
The on-line documentation which provides further information about the
condition and the message, such as
.Dq Xr fmtmsg 3 .
-/* $NetBSD: fmtmsg.c,v 1.4 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: fmtmsg.c,v 1.5 2012/03/20 16:36:05 matt Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtmsg.c,v 1.4 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: fmtmsg.c,v 1.5 2012/03/20 16:36:05 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <fmtmsg.h>
#include <stdlib.h>
#include <string.h>
-static unsigned int msgverb __P((const char *));
-static const char * severity2str __P((int));
-static int writeit __P((FILE *, unsigned int, const char *,
+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 *));
+ const char *);
#define MM_VERBLABEL 0x01U
#define MM_VERBSEVERITY 0x02U
* keywords.
*/
static unsigned int
-msgverb(str)
- const char *str;
+msgverb(const char *str)
{
u_int i;
unsigned int result;
return (result);
}
-static const char * const severities[] = {
+static const char severities[][8] = {
"", /* MM_NONE */
"HALT",
"ERROR",
* value, defaulting to NULL for an unknown value.
*/
static const char *
-severity2str(severity)
- int severity;
+severity2str(int severity)
{
const char *result;
* written, or a negative value in case of an error.
*/
static int
-writeit(stream, which, label, sevstr, text, action, tag)
- FILE *stream;
- unsigned int which;
- const char *label;
- const char *sevstr;
- const char *text;
- const char *action;
- const char *tag;
+writeit(FILE *stream, unsigned int which, const char *label,
+ const char *sevstr, const char *text, const char *action,
+ const char *tag)
{
int nwritten;
}
int
-fmtmsg(classification, label, severity, text, action, tag)
- long classification;
- const char *label;
- int severity;
- const char *text;
- const char *action;
- const char *tag;
+fmtmsg(long classification, const char *label, int severity,
+ const char *text, const char *action, const char *tag)
{
FILE *console;
const char *p, *sevstr;
-/* $NetBSD: fnmatch.c,v 1.21 2005/12/24 21:11:16 perry Exp $ */
+/* $NetBSD: fnmatch.c,v 1.25 2012/03/25 16:31:23 christos Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
#if 0
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: fnmatch.c,v 1.21 2005/12/24 21:11:16 perry Exp $");
+__RCSID("$NetBSD: fnmatch.c,v 1.25 2012/03/25 16:31:23 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define EOS '\0'
-static const char *rangematch __P((const char *, int, int));
-
static inline int
foldcase(int ch, int flags)
{
if ((flags & FNM_CASEFOLD) != 0 && isupper(ch))
- return (tolower(ch));
- return (ch);
+ return tolower(ch);
+ return ch;
}
#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags))
-int
-fnmatch(pattern, string, flags)
- const char *pattern, *string;
- int flags;
+static const char *
+rangematch(const char *pattern, int test, int flags)
+{
+ int negate, ok;
+ 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;
+
+ for (ok = 0; (c = FOLDCASE(*pattern++, flags)) != ']';) {
+ 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;
char c, test;
_DIAGASSERT(pattern != NULL);
_DIAGASSERT(string != NULL);
- for (stringstart = string;;)
+ 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);
+ return 0;
+ return *string == EOS ? 0 : FNM_NOMATCH;
case '?':
if (*string == EOS)
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
if (*string == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
++string;
break;
case '*':
if (*string == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
/* Optimize for pattern with * at end or before /. */
if (c == EOS) {
if (flags & FNM_PATHNAME)
- return ((flags & FNM_LEADING_DIR) ||
+ return (flags & FNM_LEADING_DIR) ||
strchr(string, '/') == NULL ?
- 0 : FNM_NOMATCH);
+ 0 : FNM_NOMATCH;
else
- return (0);
+ return 0;
} else if (c == '/' && flags & FNM_PATHNAME) {
if ((string = strchr(string, '/')) == NULL)
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
break;
}
/* General case, use recursion. */
while ((test = FOLDCASE(*string, flags)) != EOS) {
- if (!fnmatch(pattern, string,
- flags & ~FNM_PERIOD))
- return (0);
+ 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);
+ return FNM_NOMATCH;
case '[':
if (*string == EOS)
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
if (*string == '/' && flags & FNM_PATHNAME)
- return (FNM_NOMATCH);
- if ((pattern =
- rangematch(pattern, FOLDCASE(*string, flags),
- flags)) == NULL)
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
+ if ((pattern = rangematch(pattern,
+ FOLDCASE(*string, flags), flags)) == NULL)
+ return FNM_NOMATCH;
++string;
break;
case '\\':
if (!(flags & FNM_NOESCAPE)) {
if ((c = FOLDCASE(*pattern++, flags)) == EOS) {
- c = '\\';
+ c = '\0';
--pattern;
}
}
/* FALLTHROUGH */
default:
if (c != FOLDCASE(*string++, flags))
- return (FNM_NOMATCH);
+ return FNM_NOMATCH;
break;
}
+ }
/* NOTREACHED */
}
-static const char *
-rangematch(pattern, test, flags)
- const char *pattern;
- int test, flags;
+int
+fnmatch(const char *pattern, const char *string, int flags)
{
- int negate, ok;
- 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;
-
- for (ok = 0; (c = FOLDCASE(*pattern++, flags)) != ']';) {
- 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);
+ return fnmatchx(pattern, string, flags, 64);
}
-.\" $NetBSD: fpgetmask.3,v 1.10 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: fpgetmask.3,v 1.12 2011/03/27 22:55:07 wiz Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 4, 2004
+.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
.Lb libc
.Sh SYNOPSIS
.In ieeefp.h
-.Ft fp_except
+.Ft fp_except_t
.Fn fpgetmask void
-.Ft fp_rnd
+.Ft fp_prec_t
+.Fn fpgetprec void
+.Ft fp_rnd_t
.Fn fpgetround void
-.Ft fp_except
+.Ft fp_except_t
.Fn fpgetsticky void
-.Ft fp_except
-.Fn fpsetmask fp_except\ mask
-.Ft fp_rnd
-.Fn fpsetround fp_rnd\ rnd_dir
-.Ft fp_except
-.Fn fpsetsticky fp_except\ sticky
+.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 is one of
-.Dv FP_RZ , FP_RM , FP_RN ,
-or
-.Dv FP_RP ,
-for rounding towards zero, rounding
-.Pq Em Minus infinity
-down, rounding to
-.Em nearest ,
-and rounding
-.Pq Em Plus infinity
-up.
+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
+.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_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
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.
.Pq previous
exception mask and exception history bits.
.Sh SEE ALSO
-.Xr sigaction 2
+.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.
-/* $NetBSD: fstab.c,v 1.28 2006/08/12 23:49:54 christos Exp $ */
+/* $NetBSD: fstab.c,v 1.31 2012/03/13 21:13:34 christos Exp $ */
/*
* Copyright (c) 1980, 1988, 1993
#if 0
static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fstab.c,v 1.28 2006/08/12 23:49:54 christos Exp $");
+__RCSID("$NetBSD: fstab.c,v 1.31 2012/03/13 21:13:34 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
static const char *_fs_file = _PATH_FSTAB;
static struct fstab _fs_fstab;
-static int fstabscan __P((void));
-
static char *nextfld(char **, const char *);
static int fstabscan(void);
(void)memset(&_fs_fstab, 0, sizeof(_fs_fstab));
for (;;) {
- if (!(lp = fgets(line, sizeof(line), _fs_fp)))
+ if (!(lp = fgets(line, (int)sizeof(line), _fs_fp)))
return 0;
_fs_lineno++;
/* OLD_STYLE_FSTAB */
rewind(_fs_fp);
return 1;
}
- if ((_fs_fp = fopen(_PATH_FSTAB, "r")) == NULL) {
+ if ((_fs_fp = fopen(_PATH_FSTAB, "re")) == NULL) {
warn("Cannot open `%s'", _PATH_FSTAB);
return 0;
}
-/* $NetBSD: ftok.c,v 1.10 2004/09/15 19:45:17 hubertf Exp $ */
+/* $NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ftok.c,v 1.10 2004/09/15 19:45:17 hubertf Exp $");
+__RCSID("$NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
key_t
-ftok(path, id)
- const char *path;
- int id;
+ftok(const char *path, int id)
{
struct stat st;
-.\" $NetBSD: fts.3,v 1.29 2010/04/29 17:39:03 jruoho Exp $
+.\" $NetBSD: fts.3,v 1.30 2011/03/30 16:29:26 jruoho Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
.\"
-.Dd April 29, 2010
+.Dd March 30, 2011
.Dt FTS 3
.Os
.Sh NAME
.Fa FTSENT
structure contains at least the following fields, which are
described in greater detail below:
-.Bd -literal
+.Bd -literal -offset 2n
typedef struct _ftsent {
u_short fts_info; /* flags for FTSENT structure */
char *fts_accpath; /* access path */
The options are selected by
.Em or Ns 'ing
the following values:
-.Bl -tag -width "FTS_PHYSICAL"
+.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
.Pp
.Em Option
may be set to the following value:
-.Bl -tag -width FTS_NAMEONLY
+.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
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_PHYSICAL
+.Bl -tag -width "FTS_COMFOLLOW "
.It Dv FTS_AGAIN
Re-visit the file; any file type may be re-visited.
The next call to
-/* $NetBSD: fts.c,v 1.40 2009/11/02 17:17:34 stacktic Exp $ */
+/* $NetBSD: fts.c,v 1.46 2012/09/26 15:33:43 msaitoh Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-__RCSID("$NetBSD: fts.c,v 1.40 2009/11/02 17:17:34 stacktic Exp $");
+__RCSID("$NetBSD: fts.c,v 1.46 2012/09/26 15:33:43 msaitoh Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#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))
}
/* Allocate/initialize the stream */
- if ((sp = malloc((unsigned int)sizeof(FTS))) == NULL)
+ if ((sp = malloc(sizeof(FTS))) == NULL)
return (NULL);
memset(sp, 0, sizeof(FTS));
sp->fts_compar = compar;
sp->fts_cur->fts_info = FTS_INIT;
/*
- * If using chdir(2), grab a file descriptor pointing to dot to insure
+ * If using chdir(2), grab a file descriptor pointing to dot to ensure
* that we can get back here; this could be avoided for some paths,
* but almost certainly not worth the effort. Slashes, symbolic links,
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
if (!ISSET(FTS_NOCHDIR)) {
- if ((sp->fts_rfd = open(".", O_RDONLY, 0)) == -1)
+ if ((sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
SET(FTS_NOCHDIR);
- else if (fcntl(sp->fts_rfd, F_SETFD, FD_CLOEXEC) == -1) {
- close(sp->fts_rfd);
- SET(FTS_NOCHDIR);
- }
}
if (nitems == 0)
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 = len;
+ p->fts_namelen = ftsent_namelen_truncate(len);
}
p->fts_accpath = p->fts_path = sp->fts_path;
sp->fts_dev = p->fts_dev;
(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, 0)) == -1) {
- p->fts_errno = errno;
- p->fts_info = FTS_ERR;
- } else if (fcntl(p->fts_symfd, F_SETFD, FD_CLOEXEC) == -1) {
+ if ((p->fts_symfd = open(".", O_RDONLY | O_CLOEXEC, 0))
+ == -1) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
- close(p->fts_symfd);
} else
p->fts_flags |= FTS_SYMFOLLOW;
}
p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
- open(".", O_RDONLY, 0)) == -1) {
- p->fts_errno = errno;
- p->fts_info = FTS_ERR;
- } else if (fcntl(p->fts_symfd, F_SETFD, FD_CLOEXEC) == -1) {
+ open(".", O_RDONLY | O_CLOEXEC, 0)) == -1) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
- close(p->fts_symfd);
} else
p->fts_flags |= FTS_SYMFOLLOW;
}
return (sp->fts_cur = NULL);
}
- /* Nul terminate the pathname. */
+ /* NUL terminate the pathname. */
sp->fts_path[p->fts_pathlen] = '\0';
/*
}
#endif
p->fts_level = level;
- p->fts_pathlen = len + dnamlen;
+ p->fts_pathlen = ftsent_pathlen_truncate(len + dnamlen);
p->fts_parent = sp->fts_cur;
#ifdef FTS_WHITEOUT
if (new == 0)
return (head);
sp->fts_array = new;
- sp->fts_nitems = nitems + 40;
+ sp->fts_nitems = fts_nitems_truncate(nitems + 40);
}
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
*ap++ = p;
/* Copy the name plus the trailing NULL. */
memmove(p->fts_name, name, namelen + 1);
- p->fts_namelen = namelen;
+ p->fts_namelen = ftsent_namelen_truncate(namelen);
p->fts_path = sp->fts_path;
p->fts_errno = 0;
p->fts_flags = 0;
if (new == 0)
return (1);
sp->fts_path = new;
- sp->fts_pathlen = size;
+ sp->fts_pathlen = fts_pathlen_truncate(size);
return (0);
}
-/* $NetBSD: getbsize.c,v 1.16 2005/11/29 03:11:59 christos Exp $ */
+/* $NetBSD: getbsize.c,v 1.17 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getbsize.c,v 1.16 2005/11/29 03:11:59 christos Exp $");
+__RCSID("$NetBSD: getbsize.c,v 1.17 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* not lint */
#endif
char *
-getbsize(headerlenp, blocksizep)
- int *headerlenp;
- long *blocksizep;
+getbsize(int *headerlenp, long *blocksizep)
{
static char header[20];
long n, max, mul, blocksize;
-/* $NetBSD: getcap.c,v 1.48 2008/02/02 20:56:46 christos Exp $ */
+/* $NetBSD: getcap.c,v 1.52 2012/06/04 20:56:40 joerg Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#else
-__RCSID("$NetBSD: getcap.c,v 1.48 2008/02/02 20:56:46 christos Exp $");
+__RCSID("$NetBSD: getcap.c,v 1.52 2012/06/04 20:56:40 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <assert.h>
+#include <stddef.h>
#include <ctype.h>
#ifndef SMALL
#include <db.h>
#include <string.h>
#include <unistd.h>
-#ifdef __weak_alias
+#if defined(__weak_alias) && !defined(SMALL)
__weak_alias(cgetcap,_cgetcap)
__weak_alias(cgetclose,_cgetclose)
__weak_alias(cgetent,_cgetent)
* return NULL.
*/
char *
-cgetcap(buf, cap, type)
- char *buf;
- const char *cap;
- int type;
+cgetcap(char *buf, const char *cap, int type)
{
char *bp;
const char *cp;
rp = record;
for (;;) {
if (bp >= b_end) {
- int n;
+ ssize_t n;
n = read(fd, buf, sizeof(buf));
if (n <= 0) {
* some more.
*/
if (rp >= r_end) {
- u_int pos;
+ ptrdiff_t pos;
size_t newsize;
pos = rp - record;
if (expandtc) {
char *newicap, *s;
size_t ilen, newilen;
- int diff, iret, tclen;
+ int iret;
+ ptrdiff_t diff, tclen;
char *icap, *scan, *tc, *tcstart, *tcend;
/*
*/
diff = newilen - tclen;
if (diff >= r_end - rp) {
- u_int pos, tcpos, tcposend;
+ ptrdiff_t pos, tcpos, tcposend;
size_t newsize;
pos = rp - record;
if (dbp == NULL)
dbp = db_array;
- if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) {
+ if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return -1;
}
(void)cgetclose();
return 0;
} else if ((pfp =
- fopen(*dbp, "r")) == NULL) {
+ fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return -1;
} else
u_int m_room;
const char *bp;
char *mp;
- int len;
+ ptrdiff_t len;
char *mem, *newmem;
_DIAGASSERT(buf != NULL);
mem = newmem;
}
*str = mem;
- return len;
+ _DIAGASSERT(__type_fit(int, len));
+ return (int)len;
}
/*
u_int m_room;
const char *bp;
char *mp;
- int len;
+ size_t len;
char *mem, *newmem;
_DIAGASSERT(buf != NULL);
mem = newmem;
}
*str = mem;
- return len;
+ _DIAGASSERT(__type_fit(int, len));
+ return (int)len;
}
/*
-/* $NetBSD: getcwd.c,v 1.47 2011/01/20 02:57:00 christos Exp $ */
+/* $NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
#if 0
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
#else
-__RCSID("$NetBSD: getcwd.c,v 1.47 2011/01/20 02:57:00 christos Exp $");
+__RCSID("$NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "extern.h"
#ifdef __weak_alias
-#ifdef __minix
__weak_alias(getcwd,_getcwd)
-#else
-__weak_alias(getcwd,_sys_getcwd)
-__weak_alias(_getcwd,_sys_getcwd)
-#endif
+__weak_alias(_sys_getcwd,_getcwd)
__weak_alias(realpath,_realpath)
-
-#if defined(_FORTIFY_SOURCE) && !defined(__lint__)
-#undef getcwd
-#define getcwd _sys_getcwd
-#endif
-
#endif
/*
- * char *realpath(const char *path, char resolved[MAXPATHLEN]);
+ * 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 *path, char *resolved)
+realpath(const char * __restrict path, char * __restrict resolved)
{
struct stat sb;
- int idx = 0, n, nlnk = 0;
+ int idx = 0, nlnk = 0;
const char *q;
- char *p, wbuf[2][MAXPATHLEN];
+ char *p, wbuf[2][MAXPATHLEN], *fres;
size_t len;
-
- _DIAGASSERT(resolved != NULL);
+ ssize_t n;
/* POSIX sez we must test for this */
if (path == NULL) {
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 = resolved;
- if (*path == 0) {
- *p = 0;
+ if (*path == '\0') {
+ *p = '\0';
errno = ENOENT;
- return (NULL);
+ goto out;
}
/* If relative path, start from current working directory. */
/* check for resolved pointer to appease coverity */
if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) {
p[0] = '.';
- p[1] = 0;
- return (NULL);
+ p[1] = '\0';
+ goto out;
}
len = strlen(resolved);
if (len > 1)
while (*path == '/')
path++;
- if (*path == 0) {
+ if (*path == '\0') {
if (p == resolved)
*p++ = '/';
- *p = 0;
- return (resolved);
+ *p = '\0';
+ return resolved;
}
/* Find the end of this component. */
q = path;
do
q++;
- while (*q != '/' && *q != 0);
+ while (*q != '/' && *q != '\0');
/* Test . or .. */
if (path[0] == '.') {
/* Trim the last component. */
if (p != resolved)
while (*--p != '/')
- ;
+ continue;
path = q;
goto loop;
}
errno = ENAMETOOLONG;
if (p == resolved)
*p++ = '/';
- *p = 0;
- return (NULL);
+ *p = '\0';
+ goto out;
}
p[0] = '/';
memcpy(&p[1], path,
/* LINTED We know q > path. */
q - path);
- p[1 + q - path] = 0;
+ 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) {
- return (NULL);
- }
+ if (lstat(resolved, &sb) == -1)
+ goto out;
+
if (S_ISLNK(sb.st_mode)) {
if (nlnk++ >= MAXSYMLINKS) {
errno = ELOOP;
- return (NULL);
+ goto out;
}
n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
if (n < 0)
- return (NULL);
+ goto out;
if (n == 0) {
errno = ENOENT;
- return (NULL);
+ goto out;
}
/* Append unresolved path to link target and switch to it. */
if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0])) {
errno = ENAMETOOLONG;
- return (NULL);
+ goto out;
}
memcpy(&wbuf[idx][n], q, len + 1);
path = wbuf[idx];
}
if (*q == '/' && !S_ISDIR(sb.st_mode)) {
errno = ENOTDIR;
- return (NULL);
+ goto out;
}
/* Advance both resolved and unresolved path. */
p += 1 + q - path;
path = q;
goto loop;
+out:
+ free(fres);
+ return NULL;
}
char *
-getcwd(char *pt, size_t size)
+__ssp_real(getcwd)(char *pt, size_t size)
{
char *npt;
-/* $NetBSD: getdevmajor.c,v 1.5 2009/01/20 20:08:12 drochner Exp $ */
+/* $NetBSD: getdevmajor.c,v 1.6 2012/03/13 21:13:35 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getdevmajor.c,v 1.5 2009/01/20 20:08:12 drochner Exp $");
+__RCSID("$NetBSD: getdevmajor.c,v 1.6 2012/03/13 21:13:35 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
getdevmajor(const char *name, mode_t type)
{
struct kinfo_drivers kd[200], *kdp = &kd[0];
- int rc, i;
- size_t sz = sizeof(kd);
+ size_t i, sz = sizeof(kd);
+ int rc;
devmajor_t n = NODEVMAJOR;
if (type != S_IFCHR && type != S_IFBLK) {
}
} while (rc == -1);
- rc = sz / sizeof(*kdp);
+ sz /= sizeof(*kdp);
- for (i = 0; i < rc; i++) {
+ for (i = 0; i < sz; i++) {
if (strcmp(name, kdp[i].d_name) == 0) {
if (type == S_IFCHR)
n = kdp[i].d_cmajor;
break;
}
}
- if (i >= rc)
+ if (i >= sz)
errno = ENOENT;
out:
-/* $NetBSD: getdomainname.c,v 1.12 2003/08/07 16:42:49 agc Exp $ */
+/* $NetBSD: getdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getdomainname.c,v 1.12 2003/08/07 16:42:49 agc Exp $");
+__RCSID("$NetBSD: getdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-getdomainname(name, namelen)
- char *name;
- size_t namelen;
+getdomainname(char *name, size_t namelen)
{
int mib[2];
size_t size;
-.\" $NetBSD: getfsent.3,v 1.11 2010/03/22 19:30:53 joerg Exp $
+.\" $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.
.\"
.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd March 6, 2012
.Dt GETFSENT 3
.Os
.Sh NAME
.It Pa /etc/fstab
.El
.Sh SEE ALSO
+.Xr getfsspecname 3 ,
.Xr fstab 5
.Sh HISTORY
The
-.\" $NetBSD: getgrent.3,v 1.30 2010/03/22 19:30:53 joerg Exp $
+.\" $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.
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
+.Va errno
for
.Nm getgrent ,
.Nm getgrent_r ,
and
.Nm setgroupent :
.Bl -tag -width Er
-.It Bq Er EIO
-An I/O error has occurred.
.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
.El
.Pp
The following error code may be set in
-.Va errno
+.Va errno
for
.Nm getgrent_r ,
.Nm getgrnam_r ,
Other
.Dv errno
values may be set depending on the specific database backends.
-.Sh FILES
-.Bl -tag -width /etc/group -compact
-.It Pa /etc/group
-group database file
-.El
.Sh SEE ALSO
.Xr getpwent 3 ,
.Xr group 5 ,
.Fn getgrnam_r
appeared in
.Nx 3.0 .
-.Sh COMPATIBILITY
-The historic function
-.Fn setgrfile ,
-which allowed the specification of alternative group databases, has
-been deprecated and is no longer available.
.Sh BUGS
The functions
.Fn getgrent ,
-/* $NetBSD: getgrent.c,v 1.62 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $ */
/*-
* Copyright (c) 1999-2000, 2004-2005 The NetBSD Foundation, Inc.
#if 0
static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: getgrent.c,v 1.62 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
}
/* 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)
+ if (ep == NULL)
return 0;
+ grp->gr_mem = (char **)ALIGN(ep);
for (memc = 0; *entry != '\0'; memc++) {
count = strcspn(entry, ","); /* parse member */
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 */
_DIAGASSERT(state != NULL);
if (state->fp == NULL) {
- state->fp = fopen(_PATH_GROUP, "r");
+ state->fp = fopen(_PATH_GROUP, "re");
if (state->fp == NULL)
return NS_UNAVAIL;
} else {
rv = NS_NOTFOUND;
/* scan line by line */
- while (fgets(filebuf, sizeof(filebuf), state->fp) != NULL) {
+ while (fgets(filebuf, (int)sizeof(filebuf), state->fp) != NULL) {
ep = strchr(filebuf, '\n');
if (ep == NULL) { /* skip lines that are too big */
int ch;
_DIAGASSERT(result != NULL);
*result = NULL;
- memset(&state, 0, sizeof(state));
- rv = __grscan_nis(retval, grp, buffer, buflen, &state, 1, NULL, gid);
- __grend_nis(&state);
+/* 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;
_DIAGASSERT(result != NULL);
*result = NULL;
- memset(&state, 0, sizeof(state));
- rv = __grscan_nis(retval, grp, buffer, buflen, &state, 1, name, 0);
- __grend_nis(&state);
+/* 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;
_DIAGASSERT(state != NULL);
if (state->fp == NULL) {
- state->fp = fopen(_PATH_GROUP, "r");
+ state->fp = fopen(_PATH_GROUP, "re");
if (state->fp == NULL)
return NS_UNAVAIL;
} else {
}
/* get next file line */
- if (fgets(filebuf, sizeof(filebuf), state->fp) == NULL)
+ if (fgets(filebuf, (int)sizeof(filebuf), state->fp) == NULL)
break;
ep = strchr(filebuf, '\n');
-/* $NetBSD: gethostname.c,v 1.12 2005/10/14 23:53:41 christos Exp $ */
+/* $NetBSD: gethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: gethostname.c,v 1.12 2005/10/14 23:53:41 christos Exp $");
+__RCSID("$NetBSD: gethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-gethostname(name, namelen)
- char *name;
- size_t namelen;
+gethostname(char *name, size_t namelen)
{
int mib[2];
size_t size;
-.\" $NetBSD: getloadavg.3,v 1.14 2003/08/07 16:42:50 agc Exp $
+.\" $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.
.\"
.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd April 12, 2011
.Dt GETLOADAVG 3
.Os
.Sh NAME
.Fa loadavg Ns Bq .
The system imposes a maximum of 3 samples, representing averages
over the last 1, 5, and 15 minutes, respectively.
-.Sh DIAGNOSTICS
+.Sh RETURN VALUES
If the load average was unobtainable, \-1 is returned; otherwise,
the number of samples actually retrieved is returned.
.Sh SEE ALSO
-/* $NetBSD: getloadavg.c,v 1.13 2003/08/07 16:42:50 agc Exp $ */
+/* $NetBSD: getloadavg.c,v 1.14 2012/03/13 21:13:36 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)getloadavg.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getloadavg.c,v 1.13 2003/08/07 16:42:50 agc Exp $");
+__RCSID("$NetBSD: getloadavg.c,v 1.14 2012/03/13 21:13:36 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Return number of samples retrieved, or -1 on error.
*/
int
-getloadavg(loadavg, nelem)
- double loadavg[];
- int nelem;
+getloadavg(double loadavg[], int nelem)
{
struct loadavg loadinfo;
- int i, mib[2];
- size_t size;
+ static const int mib[] = { CTL_VM, VM_LOADAVG };
+ size_t size, i;
_DIAGASSERT(loadavg != NULL);
_DIAGASSERT(nelem >= 0);
- mib[0] = CTL_VM;
- mib[1] = VM_LOADAVG;
size = sizeof(loadinfo);
- if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) < 0)
- return (-1);
+ if (sysctl(mib, (u_int)__arraycount(mib), &loadinfo, &size, NULL, 0)
+ == -1)
+ return -1;
- nelem = MIN((size_t) nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t));
- for (i = 0; i < nelem; i++)
+ size = MIN((size_t)nelem, __arraycount(loadinfo.ldavg));
+ for (i = 0; i < size; i++)
loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale;
- return (nelem);
+ return nelem;
}
-/* $NetBSD: getmntinfo.c,v 1.16 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: getmntinfo.c,v 1.17 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getmntinfo.c,v 1.16 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: getmntinfo.c,v 1.17 2012/03/20 16:36:05 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Return information about mounted filesystems.
*/
int
-getmntinfo(mntbufp, flags)
- struct statvfs **mntbufp;
- int flags;
+getmntinfo(struct statvfs **mntbufp, int flags)
{
static struct statvfs *mntbuf;
static int mntsize;
-/* $NetBSD: getnetgrent.c,v 1.41 2009/10/21 01:07:45 snj Exp $ */
+/* $NetBSD: getnetgrent.c,v 1.42 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnetgrent.c,v 1.41 2009/10/21 01:07:45 snj Exp $");
+__RCSID("$NetBSD: getnetgrent.c,v 1.42 2012/03/20 16:36:05 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
* getnetgroup(): Parse a netgroup, and advance the pointer
*/
static struct netgroup *
-getnetgroup(pp)
- char **pp;
+getnetgroup(char **pp)
{
struct netgroup *ng;
-/* $NetBSD: getpagesize.c,v 1.10 2009/12/14 01:04:46 matt Exp $ */
+/* $NetBSD: getpagesize.c,v 1.11 2012/06/24 15:26:03 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)getpagesize.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getpagesize.c,v 1.10 2009/12/14 01:04:46 matt Exp $");
+__RCSID("$NetBSD: getpagesize.c,v 1.11 2012/06/24 15:26:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-getpagesize()
+getpagesize(void)
{
static int pagsz;
-.\" $NetBSD: getpass.3,v 1.13 2010/05/06 11:09:39 jruoho Exp $
+.\" $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.
.\"
.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd May 6, 2010
+.Dd April 13, 2012
.Dt GETPASS 3
.Os
.Sh NAME
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In pwd.h
.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
displays the prompt on the standard error output and reads from the standard
input.
.Pp
-The password may be up to _PASSWORD_LEN (currently 128)
+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
-returns a pointer to the null terminated password.
+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
.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
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.
-/* $NetBSD: getpass.c,v 1.16 2008/01/01 21:22:55 christos Exp $ */
+/* $NetBSD: getpass.c,v 1.27 2012/05/26 19:34:16 christos Exp $ */
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
+/*-
+ * 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
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: getpass.c,v 1.16 2008/01/01 21:22:55 christos Exp $");
-#endif
+__RCSID("$NetBSD: getpass.c,v 1.27 2012/05/26 19:34:16 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
-#include <paths.h>
-#include <pwd.h>
-#include <signal.h>
+#ifdef TEST
#include <stdio.h>
+#endif
+#include <errno.h>
+#include <ctype.h>
+#include <signal.h>
+#include <string.h>
+#include <paths.h>
+#include <stdbool.h>
+#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
+#include <fcntl.h>
+#include <poll.h>
#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 *
-getpass(prompt)
- const char *prompt;
+/*ARGSUSED*/
+getpassfd(const char *prompt, char *buf, size_t len, int *fd, int flags,
+ int tout)
{
- struct termios term;
- int ch;
- char *p;
- FILE *fp, *outfp;
- int echo;
- static char buf[_PASSWORD_LEN + 1];
- sigset_t oset, nset;
+ struct termios gt;
+ char c;
+ int sig;
+ bool lnext, havetty, allocated, opentty, good;
+ int fdc[3];
_DIAGASSERT(prompt != NULL);
- /*
- * note - blocking signals isn't necessarily the
- * right thing, but we leave it for now.
- */
- sigemptyset(&nset);
- sigaddset(&nset, SIGINT);
- sigaddset(&nset, SIGTSTP);
- (void)sigprocmask(SIG_BLOCK, &nset, &oset);
+ if (buf != NULL && len == 0) {
+ errno = EINVAL;
+ return NULL;
+ }
- /*
- * read and write to /dev/tty if possible; else read from
- * stdin and write to stderr.
- */
- if ((outfp = fp = fopen(_PATH_TTY, "w+")) == NULL) {
- outfp = stderr;
- fp = stdin;
+ 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)) == -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;
}
- (void)tcgetattr(fileno(fp), &term);
- if ((echo = (term.c_lflag & ECHO)) != 0) {
- term.c_lflag &= ~ECHO;
- (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term);
+
+ if (prompt != NULL) {
+ size_t plen = strlen(prompt);
+ (void)write(fd[1], prompt, plen);
}
- if (prompt != NULL)
- (void)fputs(prompt, outfp);
- rewind(outfp); /* implied flush */
- for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';)
- if (p < buf + _PASSWORD_LEN)
- *p++ = ch;
- *p = '\0';
- (void)write(fileno(outfp), "\n", 1);
- if (echo) {
- term.c_lflag |= ECHO;
- (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term);
+
+ if (allocated) {
+ len = 1024;
+ if ((buf = malloc(len)) == NULL)
+ goto restore;
}
- if (fp != stdin)
- (void)fclose(fp);
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
- return(buf);
+
+ 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('l')))
+ 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
-.\" $NetBSD: getprogname.3,v 1.7 2008/03/29 16:51:40 dholland Exp $
+.\" $NetBSD: getprogname.3,v 1.8 2011/05/21 19:06:44 dholland Exp $
.\"
.\" Copyright (c) 2001 Christopher G. Demetriou
.\" All rights reserved.
.\"
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
.\"
-.Dd March 29, 2008
+.Dd May 21, 2011
.Dt GETPROGNAME 3
.Os
.Sh NAME
.Nx ,
calling
.Fn setprogname
+explicitly has no effect.
+However, portable programs that wish to use
+.Fn getprogname
+should call
+.Fn setprogname
from
-.Fn main
-has no effect.
-However, it does serve to increase the portability of the program:
-on other operating systems,
+.Fn main .
+On operating systems where
.Fn getprogname
and
.Fn setprogname
-may be implemented by a portability library, and a call to
-.Fn setprogname
-allows that library to know the program name without
-modifications to that system's program start-up code.
+are implemented via a portability library, this call is needed to
+make the name available.
.Sh SEE ALSO
.Xr err 3 ,
.Xr setproctitle 3
-/* $NetBSD: getprogname.c,v 1.3 2003/07/26 19:24:42 salo Exp $ */
+/* $NetBSD: getprogname.c,v 1.4 2011/10/06 20:31:41 christos Exp $ */
/*
* Copyright (c) 2001 Christopher G. Demetriou
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getprogname.c,v 1.3 2003/07/26 19:24:42 salo Exp $");
+__RCSID("$NetBSD: getprogname.c,v 1.4 2011/10/06 20:31:41 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(getprogname,_getprogname)
#endif
-extern const char *__progname;
+const char *__progname;
const char *
getprogname(void)
-.\" $NetBSD: getpwent.3,v 1.37 2010/03/22 19:30:53 joerg Exp $
+.\" $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.
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
+.Va errno
for
.Nm getpwent ,
.Nm getpwent_r ,
and
.Nm setpassent :
.Bl -tag -width Er
-.It Bq Er EIO
-An I/O error has occurred.
.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
.El
.Pp
The following error code may be set in
-.Va errno
+.Va errno
for
.Nm getpwent_r ,
.Nm getpwnam_r ,
Other
.Dv errno
values may be set depending on the specific database backends.
-.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 SEE ALSO
.Xr getlogin 2 ,
.Xr getgrent 3 ,
makes no attempt to suppress duplicate information if multiple
sources are specified in
.Xr nsswitch.conf 5 .
-.Sh COMPATIBILITY
-The historic function
-.Fn setpwfile
-which allowed the specification of alternative password databases,
-has been deprecated and is no longer available.
-/* $NetBSD: getpwent.c,v 1.77 2010/03/23 20:28:59 drochner Exp $ */
+/* $NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $ */
/*-
* Copyright (c) 1997-2000, 2004-2005 The NetBSD Foundation, Inc.
#if 0
static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: getpwent.c,v 1.77 2010/03/23 20:28:59 drochner Exp $");
+__RCSID("$NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
char *current; /* current first/next match */
int currentlen; /* length of _nis_current */
enum { /* shadow map type */
- NISMAP_UNKNOWN, /* unknown ... */
+ NISMAP_UNKNOWN = 0, /* unknown ... */
NISMAP_NONE, /* none: use "passwd.by*" */
NISMAP_ADJUNCT, /* pw_passwd from "passwd.adjunct.*" */
NISMAP_MASTER /* all from "master.passwd.by*" */
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 \
- ? "master.passwd.byname" : "passwd.byname")
-#define PASSWD_BYUID(x) ((x)->maptype == NISMAP_MASTER \
- ? "master.passwd.byuid" : "passwd.byuid")
+#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(buf != NULL);
_DIAGASSERT(state != NULL);
- elen = strlen(entry);
+ elen = strlen(entry) + 1;
if (elen >= buflen)
return 0;
if (! _pw_parse(entry, pw, buf, buflen,
char *bp, *ep;
/* skip name to get password */
ep = data;
- if ((bp = strsep(&ep, ":")) != NULL &&
+ if (strsep(&ep, ":") != NULL &&
(bp = strsep(&ep, ":")) != NULL) {
/* store new pw_passwd after entry */
- strlcpy(buf + elen, bp, buflen - elen);
+ if (strlcpy(buf + elen, bp, buflen - elen) >=
+ buflen - elen) {
+ free(data);
+ return 0;
+ }
pw->pw_passwd = &buf[elen];
}
free(data);
*/
static int
_nis_pwscan(int *retval, struct passwd *pw, char *buffer, size_t buflen,
- struct nis_state *state, const char *map)
+ struct nis_state *state, const char * const *map_arr, size_t nmaps)
{
char *data;
int nisr, rv, datalen;
_DIAGASSERT(pw != NULL);
_DIAGASSERT(buffer != NULL);
_DIAGASSERT(state != NULL);
- _DIAGASSERT(map != NULL);
+ _DIAGASSERT(map_arr != NULL);
*retval = 0;
data = NULL;
rv = NS_NOTFOUND;
+ _DIAGASSERT(state->maptype != NISMAP_UNKNOWN &&
+ (unsigned)state->maptype < nmaps);
/* search map */
- nisr = yp_match(state->domain, map, buffer, (int)strlen(buffer),
+ nisr = yp_match(state->domain, map_arr[state->maptype], buffer, (int)strlen(buffer),
&data, &datalen);
switch (nisr) {
case 0:
snprintf(_nis_passwdbuf, sizeof(_nis_passwdbuf), "%u", (unsigned int)uid);
rv = _nis_pwscan(&rerror, &_nis_passwd,
_nis_passwdbuf, sizeof(_nis_passwdbuf),
- &_nis_state, PASSWD_BYUID(&_nis_state));
+ &_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)
_DIAGASSERT(result != NULL);
*result = NULL;
- memset(&state, 0, sizeof(state));
- rv = _nis_start(&state);
- if (rv != NS_SUCCESS)
- return rv;
snprintf(buffer, buflen, "%u", (unsigned int)uid);
- rv = _nis_pwscan(retval, pw, buffer, buflen,
- &state, PASSWD_BYUID(&state));
- _nis_end(&state);
+/* 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) {
snprintf(_nis_passwdbuf, sizeof(_nis_passwdbuf), "%s", name);
rv = _nis_pwscan(&rerror, &_nis_passwd,
_nis_passwdbuf, sizeof(_nis_passwdbuf),
- &_nis_state, PASSWD_BYNAME(&_nis_state));
+ &_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)
*result = NULL;
snprintf(buffer, buflen, "%s", name);
- memset(&state, 0, sizeof(state));
- rv = _nis_start(&state);
- if (rv != NS_SUCCESS)
- return rv;
- rv = _nis_pwscan(retval, pw, buffer, buflen,
- &state, PASSWD_BYNAME(&state));
- _nis_end(&state);
+/* 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) {
state->mode = COMPAT_FULL;
/* reset passwd_compat search */
/* XXXREENTRANT: setpassent is not thread safe ? */
- (void) _passwdcompat_setpassent(0);
+ (void) _passwdcompat_setpassent(_compat_state.stayopen);
break;
case '@': /* `+@netgroup' */
state->mode = COMPAT_NETGROUP;
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:
-.\" $NetBSD: getttyent.3,v 1.18 2006/04/23 16:46:32 wiz Exp $
+.\" $NetBSD: getttyent.3,v 1.20 2012/04/22 10:14:18 wiz Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd April 18, 2006
+.Dd April 5, 2012
.Dt GETTTYENT 3
.Os
.Sh NAME
Any trailing comment field, with any leading hash marks (``#'') or
whitespace removed.
.It Fa ty_class
-A key indexing into a termcap-style database (/etc/ttyclasses)
+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.
.Sh SEE ALSO
.Xr login 1 ,
.Xr ttyslot 3 ,
+.Xr capfile 5 ,
.Xr gettytab 5 ,
-.Xr termcap 5 ,
.Xr ttys 5 ,
.Xr getty 8 ,
.Xr init 8 ,
-/* $NetBSD: getttyent.c,v 1.23 2006/04/17 23:29:21 salo Exp $ */
+/* $NetBSD: getttyent.c,v 1.24 2011/10/15 23:00:01 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getttyent.c,v 1.23 2006/04/17 23:29:21 salo Exp $");
+__RCSID("$NetBSD: getttyent.c,v 1.24 2011/10/15 23:00:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* $NetBSD: getusershell.c,v 1.27 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: getusershell.c,v 1.29 2012/03/13 21:13:36 christos Exp $ */
/*-
* Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
#if 0
static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getusershell.c,v 1.27 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: getusershell.c,v 1.29 2012/03/13 21:13:36 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
_DIAGASSERT(state != NULL);
if (state->fp == NULL) {
- state->fp = fopen(_PATH_SHELLS, "r");
+ state->fp = fopen(_PATH_SHELLS, "re");
if (state->fp == NULL)
return NS_UNAVAIL;
} else {
return rv;
}
- while (fgets(curshell, sizeof(curshell) - 1, _files_state.fp) != NULL) {
+ while (fgets(curshell, (int)sizeof(curshell) - 1, _files_state.fp)
+ != NULL) {
sp = cp = curshell;
while (*cp != '#' && *cp != '/' && *cp != '\0')
cp++;
-.\" $NetBSD: glob.3,v 1.39 2010/11/30 21:03:07 jruoho Exp $
+.\" $NetBSD: glob.3,v 1.41 2012/08/12 13:31:41 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)glob.3 8.3 (Berkeley) 4/16/94
.\"
-.Dd November 30, 2010
+.Dd August 12, 2012
.Dt GLOB 3
.Os
.Sh NAME
.Sh SYNOPSIS
.In glob.h
.Ft int
-.Fn glob "const char * restrict pattern" "int flags" "const int (*errfunc)(const char *, int)" "glob_t * restrict pglob"
+.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
.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
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
is provided to simplify implementing the historic
.Xr csh 1
globbing behavior and should probably not be used anywhere else.
-.It Dv GLOB_NOESCAPE
-Disable the use of the backslash
-.Pq Ql \e
-character for quoting.
-.It Dv GLOB_TILDE
-Expand patterns that start with
-.Ql ~
-to user name home directories.
-.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_PERIOD
-Allow metacharacters to match a leading period in a filename.
.It Dv GLOB_NO_DOTDIRS
Hide
.Sq Li \&.
from metacharacter matches, regardless of whether
.Dv GLOB_PERIOD
is set and whether the pattern component begins with a literal period.
-.Dv GLOB_STAR
+.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
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
-.Dv GLOB_LIMIT
and the fields
.Fa gl_matchc
and
-/* $NetBSD: glob.c,v 1.28 2011/01/21 23:30:31 christos Exp $ */
+/* $NetBSD: glob.c,v 1.31 2011/10/30 21:53:43 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
#else
-__RCSID("$NetBSD: glob.c,v 1.28 2011/01/21 23:30:31 christos Exp $");
+__RCSID("$NetBSD: glob.c,v 1.31 2011/10/30 21:53:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
- glob_t *pglob)
+glob(const char * __restrict pattern, int flags, int (*errfunc)(const char *,
+ int), glob_t * __restrict pglob)
{
const u_char *patnext;
int c;
errno = 0;
*pathend++ = SEP;
*pathend = EOS;
-printf("stat limit\n");
return GLOB_NOSPACE;
}
if (((pglob->gl_flags & GLOB_MARK) &&
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
readdirfunc = pglob->gl_readdir;
else
- readdirfunc = (struct dirent *(*)__P((void *))) readdir;
+ readdirfunc = (struct dirent *(*)(void *)) readdir;
while ((dp = (*readdirfunc)(dirp)) != NULL) {
u_char *sc;
Char *dc;
errno = 0;
*pathend++ = SEP;
*pathend = EOS;
- return GLOB_NOSPACE;
+ error = GLOB_NOSPACE;
+ break;
}
/*
-.\" $NetBSD: humanize_number.3,v 1.9 2011/01/14 10:08:57 jruoho Exp $
+.\" $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.
.Sh NAME
.Nm dehumanize_number ,
.Nm humanize_number
-.Nd format a number into a human readable form and viceversa
+.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 *buf" "size_t len" "int64_t number" "const char *suffix" "int scale" "int flags"
+.Fn humanize_number "char *buffer" "size_t len" "int64_t number" "const char *suffix" "int scale" "int flags"
.Sh DESCRIPTION
The
.Fn humanize_number
-/* $NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $ */
+/* $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.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $");
+__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"
const char *suffix, int scale, int flags)
{
const char *prefixes, *sep;
- int b, i, r, maxscale, s1, s2, sign;
- int64_t divisor, max;
- size_t baselen;
+ int b, r, s1, s2, sign;
+ int64_t divisor, max, post = 1;
+ size_t i, baselen, maxscale;
_DIAGASSERT(buf != NULL);
_DIAGASSERT(suffix != NULL);
#define SCALE2PREFIX(scale) (&prefixes[(scale) << 1])
maxscale = 7;
- if (scale >= maxscale &&
+ if ((size_t)scale >= maxscale &&
(scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0)
return (-1);
buf[0] = '\0';
if (bytes < 0) {
sign = -1;
- bytes *= -100;
baselen = 3; /* sign, digit, prefix */
+ if (-bytes < INT64_MAX / 100)
+ bytes *= -100;
+ else {
+ bytes = -bytes;
+ post = 100;
+ baselen += 2;
+ }
} else {
sign = 1;
- bytes *= 100;
baselen = 2; /* digit, prefix */
+ if (bytes < INT64_MAX / 100)
+ bytes *= 100;
+ else {
+ post = 100;
+ baselen += 2;
+ }
}
if (flags & HN_NOSPACE)
sep = "";
for (i = 0; bytes >= max - 50 && i < maxscale; i++)
bytes /= divisor;
- if (scale & HN_GETSCALE)
- return (i);
+ if (scale & HN_GETSCALE) {
+ _DIAGASSERT(__type_fit(int, i));
+ return (int)i;
+ }
} else
- for (i = 0; i < scale && i < maxscale; i++)
+ 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) {
-/* $NetBSD: initdir.c,v 1.1 2010/09/26 02:26:59 yamt Exp $ */
+/* $NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: initdir.c,v 1.1 2010/09/26 02:26:59 yamt Exp $");
+__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 <sys/cdefs.h>
#include <sys/featuretest.h>
#include <sys/types.h>
+
+#if !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
#endif
#include "reentrant.h"
*/
if (flags & DTF_REWIND) {
(void) close(fd);
- if ((fd = open(name, O_RDONLY)) == -1 ||
- fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ if ((fd = open(name, O_RDONLY | O_CLOEXEC)) == -1) {
dirp->dd_buf = buf;
return errno;
}
}
}
- dirp->dd_len = len;
+ _DIAGASSERT(__type_fit(int, len));
+ dirp->dd_len = (int)len;
dirp->dd_size = ddptr - dirp->dd_buf;
} else {
dirp->dd_len = incr;
-/* $NetBSD: initgroups.c,v 1.21 2003/08/07 16:42:51 agc Exp $ */
+/* $NetBSD: initgroups.c,v 1.22 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)initgroups.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: initgroups.c,v 1.21 2003/08/07 16:42:51 agc Exp $");
+__RCSID("$NetBSD: initgroups.c,v 1.22 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-initgroups(uname, agroup)
- const char *uname;
- gid_t agroup;
+initgroups(const char *uname, gid_t agroup)
{
gid_t groups_list[NGROUPS];
int ngroups;
-/* $NetBSD: isascii.c,v 1.3 2010/06/01 13:52:08 tnozaki Exp $ */
+/* $NetBSD: isascii.c,v 1.4 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: isascii.c,v 1.3 2010/06/01 13:52:08 tnozaki Exp $");
+__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 <ctype.h>
int
-isascii(c)
- int c;
+isascii(int c)
{
return ((unsigned)(c) <= 0177);
}
-/* $NetBSD: isatty.c,v 1.12 2003/08/07 16:42:51 agc Exp $ */
+/* $NetBSD: isatty.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: isatty.c,v 1.12 2003/08/07 16:42:51 agc Exp $");
+__RCSID("$NetBSD: isatty.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-isatty(fd)
- int fd;
+isatty(int fd)
{
struct termios t;
-.\" $NetBSD: isfinite.3,v 1.3 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: isfinite.3,v 1.4 2011/08/06 11:02:41 jruoho Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 29, 2003
+.Dd August 6, 2011
.Dt ISFINITE 3
.Os
.Sh NAME
.Sh ERRORS
No errors are defined.
.Sh SEE ALSO
+.Xr finite 3 ,
.Xr fpclassify 3 ,
.Xr isnormal 3 ,
.Xr math 3 ,
-.\" $NetBSD: isspace.3,v 1.14 2008/04/17 16:25:36 apb Exp $
+.\" $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.
.It Li \et
Horizontal tab.
.It Li \ev
-And vertical tab.
+Vertical tab.
.El
.Pp
In the
-.\" $NetBSD: lockf.3,v 1.10 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: lockf.3,v 1.12 2011/10/15 21:35:49 rmind Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 19, 1997
+.Dd October 15, 2011
.Dt LOCKF 3
.Os
.Sh NAME
The permissible values for
.Fa function
are as follows:
+.Pp
.Bl -tag -width F_ULOCKXX -compact -offset indent
.It Sy Function
.Sy Description
.El
.Sh SEE ALSO
.Xr fcntl 2 ,
-.Xr flock 2
+.Xr flock 2 ,
+.Xr flockfile 3
.Sh STANDARDS
The
.Fn lockf
function conforms to
-.St -xpg4.2 .
+.St -xpg4.2
+and
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn lockf
+function first appeared in
+.Fx 1.4 .
-/* $NetBSD: lockf.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: lockf.c,v 1.4 2012/06/25 22:32:43 abs Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: lockf.c,v 1.3 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: lockf.c,v 1.4 2012/06/25 22:32:43 abs Exp $");
#endif
#include "namespace.h"
int
-lockf(filedes, function, size)
- int filedes;
- int function;
- off_t size;
+lockf(int filedes, int function, off_t size)
{
struct flock fl;
int cmd;
-.\" $NetBSD: makecontext.3,v 1.9 2010/04/29 06:07:35 jruoho Exp $
+.\" $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.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 29, 2010
+.Dd May 4, 2012
.Dt MAKECONTEXT 3
.Os
.Sh NAME
.Fn swapcontext
functions first appeared in
.At V.4 .
-.Sh CAVEATS
-Due to limitations in the current pthread implementation,
-.Nm
-should not be used in programs which link against the
-.Xr pthread 3
-library (whether threads are used or not).
-/* $NetBSD: modf_ieee754.c,v 1.3 2010/01/27 14:10:41 drochner Exp $ */
+/* $NetBSD: modf_ieee754.c,v 1.4 2012/03/22 13:25:45 he Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
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 = frac & 0xffffffff;
- v.dblu_dbl.dbl_frach = frac >> 32;
+ 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;
-.\" $NetBSD: nice.3,v 1.13 2003/08/07 16:42:53 agc Exp $
+.\" $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.
.\"
.\" @(#)nice.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd February 16, 1998
+.Dd April 30, 2011
.Dt NICE 3
.Os
.Sh NAME
.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 the super-user may lower priorities.
+Only a process with appropriate privileges may lower priorities.
.Pp
Children inherit the priority of their parent processes via
.Xr fork 2 .
.It Bq Er EPERM
The
.Fa incr
-argument is negative and the caller is not the super-user.
+argument is negative and the caller does not have appropriate privileges.
.El
.Sh SEE ALSO
.Xr nice 1 ,
-/* $NetBSD: nice.c,v 1.12 2003/08/07 16:42:53 agc Exp $ */
+/* $NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: nice.c,v 1.12 2003/08/07 16:42:53 agc Exp $");
+__RCSID("$NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Backwards compatible nice.
*/
int
-nice(incr)
- int incr;
+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) != 0)
- return (-1);
- return (getpriority(PRIO_PROCESS, 0));
+ return -1;
+ if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) {
+ if (errno == EACCES)
+ errno = EPERM;
+ return -1;
+ }
+ return getpriority(PRIO_PROCESS, 0);
}
-/* $NetBSD: nlist.c,v 1.22 2009/08/20 08:30:04 he Exp $ */
+/* $NetBSD: nlist.c,v 1.24 2012/03/21 15:32:26 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: nlist.c,v 1.22 2009/08/20 08:30:04 he Exp $");
+__RCSID("$NetBSD: nlist.c,v 1.24 2012/03/21 15:32:26 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "nlist_private.h"
static const struct {
- int (*fdnlist) __P((int, struct nlist *));
+ int (*fdnlist)(int, struct nlist *);
} fdnlist_fmts[] = {
#ifdef NLIST_AOUT
{ __fdnlist_aout },
};
int
-nlist(name, list)
- const char *name;
- struct nlist *list;
+nlist(const char *name, struct nlist *list)
{
int fd, n;
}
int
-__fdnlist(fd, list)
- int fd;
- struct nlist *list;
+__fdnlist(int fd, struct nlist *list)
{
size_t i;
int rv;
-/* $NetBSD: nlist_aout.c,v 1.22 2009/08/20 11:08:59 martin Exp $ */
+/* $NetBSD: nlist_aout.c,v 1.23 2012/03/21 15:32:26 christos Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: nlist_aout.c,v 1.22 2009/08/20 11:08:59 martin Exp $");
+__RCSID("$NetBSD: nlist_aout.c,v 1.23 2012/03/21 15:32:26 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/exec_aout.h>
int
-__fdnlist_aout(fd, list)
- int fd;
- struct nlist *list;
+__fdnlist_aout(int fd, struct nlist *list)
{
struct nlist *p, *s;
char *strtab;
-/* $NetBSD: nlist_coff.c,v 1.8 2009/08/21 08:42:02 he Exp $ */
+/* $NetBSD: nlist_coff.c,v 1.11 2012/03/22 14:18:34 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_coff.c,v 1.8 2009/08/21 08:42:02 he Exp $");
+__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"
#endif
#ifdef NLIST_COFF
-#define BAD do { rv = -1; goto out; } while (/*CONSTCOND*/0)
-#define BADUNMAP do { rv = -1; goto unmap; } while (/*CONSTCOND*/0)
#define ES_LEN 18
struct coff_extsym {
#define es_offset u.s.u_offset
int
-__fdnlist_coff(fd, list)
- int fd;
- struct nlist *list;
+__fdnlist_coff(int fd, struct nlist *list)
{
struct nlist *p;
struct coff_filehdr *filehdrp;
* If we can't fstat() the file, something bad is going on.
*/
if (fstat(fd, &st) < 0)
- BAD;
+ goto out;
/*
* Map the file in its entirety.
*/
if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) {
errno = EFBIG;
- BAD;
+ goto out;
}
- mappedsize = st.st_size;
+ mappedsize = (size_t)st.st_size;
mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE,
fd, 0);
- if (mappedfile == (char *)-1)
- BAD;
+ if (mappedfile == MAP_FAILED)
+ goto out;
/*
* Make sure we can access the executable's header
* as an COFF binary.
*/
if (mappedsize < sizeof (struct coff_filehdr))
- BADUNMAP;
- filehdrp = (struct coff_filehdr *)&mappedfile[0];
+ goto unmap;
+ filehdrp = (void *)&mappedfile[0];
if (COFF_BADMAG(filehdrp))
- BADUNMAP;
+ goto unmap;
/*
* Find the symbol list.
nesyms = filehdrp->f_nsyms;
if (symoff + ES_LEN * nesyms > mappedsize)
- BADUNMAP;
+ goto unmap;
extstroff = symoff + ES_LEN * nesyms;
nent = 0;
unmap:
munmap(mappedfile, mappedsize);
out:
- return (rv);
+ return rv;
}
#endif /* NLIST_COFF */
-/* $NetBSD: nlist_ecoff.c,v 1.18 2009/08/21 08:42:02 he Exp $ */
+/* $NetBSD: nlist_ecoff.c,v 1.23 2012/03/20 00:31:24 matt Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_ecoff.c,v 1.18 2009/08/21 08:42:02 he Exp $");
+__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"
#endif
#ifdef NLIST_ECOFF
-#define check(off, size) ((off < 0) || (off + size > mappedsize))
-#define BAD do { rv = -1; goto out; } while (/*CONSTCOND*/0)
-#define BADUNMAP do { rv = -1; goto unmap; } while (/*CONSTCOND*/0)
+#define check(off, size) \
+ ((size_t)off >= mappedsize || (size_t)(off + size) > mappedsize)
int
-__fdnlist_ecoff(fd, list)
- int fd;
- struct nlist *list;
+__fdnlist_ecoff(int fd, struct nlist *list)
{
struct nlist *p;
- struct ecoff_exechdr *exechdrp;
- struct ecoff_symhdr *symhdrp;
- struct ecoff_extsym *esyms;
+ const struct ecoff_exechdr *exechdrp;
+ const struct ecoff_symhdr *symhdrp;
+ const struct ecoff_extsym *esyms;
struct stat st;
- char *mappedfile;
+ const char *mappedfile;
size_t mappedsize;
u_long symhdroff, extstroff;
u_int symhdrsize;
* If we can't fstat() the file, something bad is going on.
*/
if (fstat(fd, &st) < 0)
- BAD;
+ goto out;
/*
* Map the file in its entirety.
*/
if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) {
errno = EFBIG;
- BAD;
+ goto out;
}
- mappedsize = st.st_size;
+ mappedsize = (size_t)st.st_size;
mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE,
fd, 0);
- if (mappedfile == (char *)-1)
- BAD;
+ if (mappedfile == MAP_FAILED)
+ goto out;
/*
* Make sure we can access the executable's header
* as an ECOFF binary.
*/
if (check(0, sizeof *exechdrp))
- BADUNMAP;
- exechdrp = (struct ecoff_exechdr *)&mappedfile[0];
+ goto unmap;
+ exechdrp = (const void *)mappedfile;
if (ECOFF_BADMAG(exechdrp))
- BADUNMAP;
+ goto unmap;
/*
* Find the symbol list.
if ((symhdroff + sizeof *symhdrp) > mappedsize ||
sizeof *symhdrp != symhdrsize)
- BADUNMAP;
- symhdrp = (struct ecoff_symhdr *)&mappedfile[symhdroff];
+ goto unmap;
+ symhdrp = (const void *)&mappedfile[symhdroff];
nesyms = symhdrp->esymMax;
if (check(symhdrp->cbExtOffset, nesyms * sizeof *esyms))
- BADUNMAP;
- esyms = (struct ecoff_extsym *)&mappedfile[symhdrp->cbExtOffset];
+ goto unmap;
+ esyms = (const void *)&mappedfile[symhdrp->cbExtOffset];
extstroff = symhdrp->cbSsExtOffset;
/*
for (i = 0; i < nesyms; i++) {
for (p = list; !ISLAST(p); p++) {
const char *nlistname;
- char *symtabname;
+ const char *symtabname;
/* This may be incorrect */
nlistname = N_NAME(p);
done:
rv = nent;
unmap:
- munmap(mappedfile, mappedsize);
+ munmap(__UNCONST(mappedfile), mappedsize);
out:
- return (rv);
+ return rv;
}
#endif /* NLIST_ECOFF */
-/* $NetBSD: nlist_elf32.c,v 1.32 2010/08/28 21:30:02 joerg Exp $ */
+/* $NetBSD: nlist_elf32.c,v 1.35 2012/03/21 02:18:14 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_elf32.c,v 1.32 2010/08/28 21:30:02 joerg Exp $");
+__RCSID("$NetBSD: nlist_elf32.c,v 1.35 2012/03/21 02:18:14 christos Exp $");
#endif /* LIBC_SCCS and not lint */
/* If not included by nlist_elf64.c, ELFSIZE won't be defined. */
#define BADUNMAP goto unmap
int
-ELFNAMEEND(__fdnlist)(fd, list)
- int fd;
- struct nlist *list;
+ELFNAMEEND(__fdnlist)(int fd, struct nlist *list)
{
struct stat st;
- struct nlist *p;
- char *mappedfile, *strtab;
- size_t mappedsize;
- Elf_Ehdr *ehdrp, ehdr;
- Elf_Shdr *shdrp, *symshdrp, *symstrshdrp;
- Elf_Sym *symp;
- Elf_Off shdr_off;
- Elf_Word shdr_size;
+ Elf_Ehdr ehdr;
+#if _LP64 || ELFSIZE == 32
#if (ELFSIZE == 32)
Elf32_Half nshdr;
#elif (ELFSIZE == 64)
Elf64_Word nshdr;
#endif
- size_t i, nsyms;
- int rv, nent;
+ /* Only support 64+32 mode on LP64; 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;
- symshdrp = symstrshdrp = NULL;
-
/*
* If we can't fstat() the file, something bad is going on.
*/
default:
BAD;
}
+#if _LP64 || ELFSIZE == 32
+ symshdrp = symstrshdrp = NULL;
+ /* Only support 64+32 mode on LP64; no support for 64 mode on ILP32 */
if (S_ISCHR(st.st_mode)) {
const char *nlistname;
struct ksyms_gsymbol kg;
kg.kg_name = nlistname;
kg.kg_sym = &sym;
if (ioctl(fd, KIOCGSYMBOL, &kg) == 0) {
- p->n_value = sym.st_value;
+ 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;
if (check(shdr_off, shdr_size) ||
(sizeof *shdrp != ehdrp->e_shentsize))
BADUNMAP;
- shdrp = (Elf_Shdr *)(void *)&mappedfile[shdr_off];
+ shdrp = (void *)&mappedfile[(size_t)shdr_off];
for (i = 0; i < nshdr; i++) {
if (shdrp[i].sh_type == SHT_SYMTAB) {
if (check(symstrshdrp->sh_offset, symstrshdrp->sh_size))
BADUNMAP;
- symp = (Elf_Sym *)(void *)&mappedfile[symshdrp->sh_offset];
- nsyms = symshdrp->sh_size / sizeof(*symp);
- strtab = &mappedfile[symstrshdrp->sh_offset];
+ 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.
/*
* Translate (roughly) from ELF to nlist
*/
- p->n_value = symp[i].st_value;
+ 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:
rv = nent;
unmap:
munmap(mappedfile, mappedsize);
+#endif /* _LP64 || ELFSIZE == 32 */
out:
return (rv);
}
-/* $NetBSD: nlist_private.h,v 1.21 2011/01/17 23:32:31 matt Exp $ */
+/* $NetBSD: nlist_private.h,v 1.22 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
struct nlist;
#ifdef NLIST_AOUT
-int __fdnlist_aout __P((int, struct nlist *));
+int __fdnlist_aout(int, struct nlist *);
#endif
#ifdef NLIST_COFF
-int __fdnlist_coff __P((int, struct nlist *));
+int __fdnlist_coff(int, struct nlist *);
#endif
#ifdef NLIST_ECOFF
-int __fdnlist_ecoff __P((int, struct nlist *));
+int __fdnlist_ecoff(int, struct nlist *);
#endif
#ifdef NLIST_ELF32
-int __fdnlist_elf32 __P((int, struct nlist *));
+int __fdnlist_elf32(int, struct nlist *);
#endif
#ifdef NLIST_ELF64
-int __fdnlist_elf64 __P((int, struct nlist *));
+int __fdnlist_elf64(int, struct nlist *);
#endif
-/* $NetBSD: opendir.c,v 1.37 2010/09/26 02:26:59 yamt Exp $ */
+/* $NetBSD: opendir.c,v 1.38 2011/10/15 23:00:01 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)opendir.c 8.7 (Berkeley) 12/10/94";
#else
-__RCSID("$NetBSD: opendir.c,v 1.37 2010/09/26 02:26:59 yamt Exp $");
+__RCSID("$NetBSD: opendir.c,v 1.38 2011/10/15 23:00:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#ifdef __minix
#include <sys/cdefs.h>
#include <sys/types.h>
+
+#if !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
#endif
#include "extern.h"
{
int fd;
- if ((fd = open(name, O_RDONLY | O_NONBLOCK)) == -1)
+ if ((fd = open(name, O_RDONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
return NULL;
+#if defined(__minix)
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ close(fd);
+ return NULL;
+ }
+#endif /* defined(__minix) */
+
return __opendir_common(fd, name, flags);
}
DIR *
_fdopendir(int fd)
{
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+ return NULL;
return __opendir_common(fd, NULL, DTF_HIDEW|DTF_NODUP);
}
#endif
int error;
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
- goto error;
if (fstat(fd, &sb) || !S_ISDIR(sb.st_mode)) {
errno = ENOTDIR;
goto error;
}
- if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL)
+ if ((dirp = malloc(sizeof(*dirp))) == NULL)
goto error;
dirp->dd_buf = NULL;
dirp->dd_internal = NULL;
-/* $NetBSD: pause.c,v 1.10 2003/08/07 16:42:55 agc Exp $ */
+/* $NetBSD: pause.c,v 1.11 2012/06/24 15:26:03 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)pause.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: pause.c,v 1.10 2003/08/07 16:42:55 agc Exp $");
+__RCSID("$NetBSD: pause.c,v 1.11 2012/06/24 15:26:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Backwards compatible pause.
*/
int
-pause()
+pause(void)
{
sigset_t omask;
-.\" $NetBSD: popen.3,v 1.16 2007/08/02 23:45:10 wiz Exp $
+.\" $NetBSD: popen.3,v 1.18 2011/06/27 08:21:07 wiz Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
.\"
-.Dd August 2, 2007
+.Dd June 24, 2011
.Dt POPEN 3
.Os
.Sh NAME
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
-/* $NetBSD: popen.c,v 1.30 2010/11/14 18:11:42 tron Exp $ */
+/* $NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: popen.c,v 1.30 2010/11/14 18:11:42 tron Exp $");
+__RCSID("$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#include "env.h"
#include "reentrant.h"
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
#ifdef __weak_alias
__weak_alias(popen,_popen)
__weak_alias(pclose,_pclose)
const char * volatile xtype = type;
int pdes[2], pid, serrno;
volatile int twoway;
+ int flags;
_DIAGASSERT(command != NULL);
_DIAGASSERT(xtype != NULL);
+ flags = strchr(xtype, 'e') ? O_CLOEXEC : 0;
if (strchr(xtype, '+')) {
+ int stype = flags ? (SOCK_STREAM | SOCK_CLOEXEC) : SOCK_STREAM;
twoway = 1;
- type = "r+";
- if (socketpair(AF_LOCAL, SOCK_STREAM, 0, pdes) < 0)
- return (NULL);
+ xtype = "r+";
+ if (socketpair(AF_LOCAL, stype, 0, pdes) < 0)
+ return NULL;
} else {
twoway = 0;
- if ((*xtype != 'r' && *xtype != 'w') || xtype[1] ||
- (pipe(pdes) < 0)) {
- errno = EINVAL;
- return (NULL);
- }
+ xtype = strrchr(xtype, 'r') ? "r" : "w";
+ if (pipe2(pdes, flags) == -1)
+ return NULL;
}
if ((cur = malloc(sizeof(struct pid))) == NULL) {
* if already `pclosed', or waitpid returns an error.
*/
int
-pclose(iop)
- FILE *iop;
+pclose(FILE *iop)
{
struct pid *cur, *last;
int pstat;
--- /dev/null
+.\" $NetBSD: posix_spawn.3,v 1.3 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 December 20, 2011
+.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
+.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 .
+.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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawn_file_actions_addopen.3,v 1.2 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 December 20, 2011
+.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 EINVAL
+The value specified by
+.Fa fildes
+or
+.Fa newfildes
+is negative.
+.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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawn_file_actions_init.3,v 1.2 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 December 20, 2011
+.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 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 ed@FreeBSD.org
--- /dev/null
+/*-
+ * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: posix_spawn_fileactions.c,v 1.2 2012/04/08 11:27:44 martin Exp $");
+
+#include "namespace.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <spawn.h>
+
+#define MIN_SIZE 16
+
+/*
+ * File descriptor actions
+ */
+
+int
+posix_spawn_file_actions_init(posix_spawn_file_actions_t *fa)
+{
+ if (fa == NULL)
+ return (-1);
+
+ fa->fae = malloc(MIN_SIZE * sizeof(struct posix_spawn_file_actions_entry));
+ if (fa->fae == NULL)
+ return (-1);
+ 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 (-1);
+
+ 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)
+{
+ if (fa == NULL)
+ return -1;
+
+ if (fa->len < fa->size)
+ return fa->len;
+
+ fa->fae = realloc(fa->fae, (fa->size + MIN_SIZE) *
+ sizeof(struct posix_spawn_file_actions_entry));
+
+ if (fa->fae == NULL)
+ return -1;
+
+ fa->size += MIN_SIZE;
+
+ return fa->len;
+}
+
+int
+posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict fa,
+ int fildes, const char * __restrict path, int oflag, mode_t mode)
+{
+ int i, error;
+
+ if (fildes < 0)
+ return (EBADF);
+
+ i = posix_spawn_file_actions_getentry(fa);
+ if (i < 0)
+ return (ENOMEM);
+
+ fa->fae[i].fae_action = FAE_OPEN;
+ fa->fae[i].fae_path = strdup(path);
+ if (fa->fae[i].fae_path == NULL) {
+ error = errno;
+ return (error);
+ }
+ 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)
+{
+ int i;
+
+ if (fildes < 0 || newfildes < 0)
+ return (EBADF);
+
+ i = posix_spawn_file_actions_getentry(fa);
+ if (i < 0)
+ return (ENOMEM);
+
+ 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)
+{
+ int i;
+
+ if (fildes < 0)
+ return (EBADF);
+
+ i = posix_spawn_file_actions_getentry(fa);
+ if (i < 0)
+ return (ENOMEM);
+
+ fa->fae[i].fae_action = FAE_CLOSE;
+ fa->fae[i].fae_fildes = fildes;
+ fa->len++;
+
+ return (0);
+}
--- /dev/null
+/*-
+ * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: posix_spawn_sched.c,v 1.1 2012/02/11 23:31:24 martin Exp $");
+
+#include "namespace.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <spawn.h>
+
+/*
+ * 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);
+}
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getflags.3,v 1.2 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getpgroup.3,v 1.2 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getschedparam.3,v 1.2 2012/03/23 18:08:34 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getschedpolicy.3,v 1.2 2012/03/23 18:08:35 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getsigdefault.3,v 1.2 2012/03/23 18:08:35 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_getsigmask.3,v 1.2 2012/03/23 18:08:35 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
--- /dev/null
+.\" $NetBSD: posix_spawnattr_init.3,v 1.2 2012/03/23 18:08:35 njoly Exp $
+.\"
+.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" 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 ed@FreeBSD.org
-/* $NetBSD: localeio_lc_messages.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: posix_spawnp.c,v 1.2 2012/02/22 17:51:01 martin Exp $ */
-/*
- * Copyright (c) 2008, The NetBSD Foundation, Inc.
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
- *
+ *
* This code is derived from software contributed to The NetBSD Foundation
- * by Brian Ginsbach.
+ * by Martin Husemann <martin@NetBSD.org>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio_lc_messages.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: posix_spawnp.c,v 1.2 2012/02/22 17:51:01 martin Exp $");
#endif /* LIBC_SCCS and not lint */
-#include "reentrant.h"
-#include <sys/types.h>
-#include <sys/localedef.h>
-#include <sys/queue.h>
-#include <assert.h>
-#include <errno.h>
-#include <langinfo.h>
-#include <limits.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <spawn.h>
-#include "setlocale_local.h"
-
-#include "aliasname_local.h"
-#include "localeio.h"
-
-/*
- * macro required by all template headers
- */
-#define _PREFIX(name) __CONCAT(_localeio_LC_MESSAGES_, name)
-#include "nb_lc_messages_misc.h"
-#include "nb_lc_template_decl.h"
+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;
-#define NSTRINGS (sizeof(_MessagesLocale)/sizeof(const char **))
+ /*
+ * 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);
-static int
-_localeio_LC_MESSAGES_create_impl(const char * __restrict root,
- const char * __restrict name, _MessagesLocale ** __restrict pdata)
-{
- char path[PATH_MAX + 1];
+ path = strdup(path);
+ if (path == NULL)
+ return ENOMEM;
- _DIAGASSERT(root != NULL);
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(pdata != NULL);
+ /*
+ * 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);
- snprintf(path, sizeof(path),
- "%s/%s/LC_MESSAGES/SYS_LC_MESSAGES", root, name);
- return __loadlocale(path, NSTRINGS, 0, sizeof(_MessagesLocale),
- (void *)pdata);
+ /*
+ * Use posix_spawn() with the found binary
+ */
+ return posix_spawn(pid, fpath, fa, sa, cav, env);
}
-#include "nb_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_localeio_LC_MESSAGES_);
-/* $NetBSD: psignal.c,v 1.22 2010/08/27 08:38:41 christos Exp $ */
+/* $NetBSD: psignal.c,v 1.23 2012/03/13 21:13:36 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: psignal.c,v 1.22 2010/08/27 08:38:41 christos Exp $");
+__RCSID("$NetBSD: psignal.c,v 1.23 2012/03/13 21:13:36 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
v++;
v->iov_base = __UNCONST("\n");
v->iov_len = 1;
- (void)writev(STDERR_FILENO, iov, (v - iov) + 1);
+ (void)writev(STDERR_FILENO, iov, (int)((v - iov) + 1));
}
void
-/* $NetBSD: pthread_atfork.c,v 1.8 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: pthread_atfork.c,v 1.9 2012/03/20 16:36:05 matt Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pthread_atfork.c,v 1.8 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: pthread_atfork.c,v 1.9 2012/03/20 16:36:05 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(fork, _fork)
#endif /* __weak_alias */
-pid_t __fork __P((void)); /* XXX */
+pid_t __fork(void); /* XXX */
struct atfork_callback {
SIMPLEQ_ENTRY(atfork_callback) next;
-/* $NetBSD: pw_private.h,v 1.2 2003/07/26 19:24:43 salo Exp $ */
+/* $NetBSD: pw_private.h,v 1.3 2012/03/20 16:36:05 matt Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@NetBSD.org>, June 26, 1998.
* Public domain.
*/
-int __pw_scan __P((char *bp, struct passwd *pw, int *flags));
+int __pw_scan(char *bp, struct passwd *pw, int *flags);
-/* $NetBSD: pw_scan.c,v 1.22 2009/01/29 10:41:39 enami Exp $ */
+/* $NetBSD: pw_scan.c,v 1.23 2012/03/13 21:13:36 christos Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
#else
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pw_scan.c,v 1.22 2009/01/29 10:41:39 enami Exp $");
+__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)
#endif /* ! HAVE_NBTOOL_CONFIG_H */
static int
-gettime(long long *res, const char *p, int *flags, int dowarn, int flag)
+gettime(time_t *res, const char *p, int *flags, int dowarn, int flag)
{
long long l;
char *ep;
vp = strerror(errno);
goto done;
}
-
- *res = l;
+ _DIAGASSERT(__type_fit(time_t, l));
+ *res = (time_t)l;
return 1;
done:
if (dowarn) {
#endif
{
unsigned long id;
- long long ti;
+ time_t ti;
int root, inflags;
int dowarn;
const char *p, *sh;
-.\" $NetBSD: raise.3,v 1.9 2009/01/30 23:52:28 wiz Exp $
+.\" $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.
.\"
.\" @(#)raise.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd January 29, 2009
+.Dd May 9, 2011
.Dt RAISE 3
.Os
.Sh NAME
and
.Xr _lwp_kill 2 .
.Sh SEE ALSO
-.Xr kill 2
+.Xr kill 2 ,
+.Xr raise_default_signal 3
.Sh STANDARDS
The
.Fn raise
-/* $NetBSD: readdir.c,v 1.25 2010/09/16 02:38:50 yamt Exp $ */
+/* $NetBSD: readdir.c,v 1.26 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
#else
-__RCSID("$NetBSD: readdir.c,v 1.25 2010/09/16 02:38:50 yamt Exp $");
+__RCSID("$NetBSD: readdir.c,v 1.26 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
}
struct dirent *
-readdir(dirp)
- DIR *dirp;
+readdir(DIR *dirp)
{
struct dirent *dp;
}
int
-readdir_r(dirp, entry, result)
- DIR *dirp;
- struct dirent *entry;
- struct dirent **result;
+readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
{
struct dirent *dp;
int saved_errno;
-.\" $NetBSD: realpath.3,v 1.12 2005/08/13 19:53:53 elad Exp $
+.\" $NetBSD: realpath.3,v 1.14 2012/06/21 21:35:25 wiz Exp $
.\"
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)realpath.3 8.2 (Berkeley) 2/16/94
.\"
-.Dd August 13, 2005
+.Dd June 21, 2012
.Dt REALPATH 3
.Os
.Sh NAME
.In sys/param.h
.In stdlib.h
.Ft "char *"
-.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]"
+.Fn realpath "const char * restrict pathname" "char * restrict resolvedname"
.Sh DESCRIPTION
The
.Fn realpath
and return the absolute pathname corresponding to
.Fa pathname .
.Sh RETURN VALUES
+If
+.Fa resolvednamed
+is
+.Dv NULL ,
+it will be allocated and the returned pointer can be deallocated using
+.Xr free 3 .
The
.Fn realpath
function returns
.Dv NULL ,
and
.Fa resolvedname
-contains the pathname which caused the problem.
+was not allocated by
+.Nm ,
+it will contain the pathname which caused the problem.
.Sh ERRORS
The function
.Fn realpath
.Xr close 2 ,
.Xr fchdir 2 ,
.Xr lstat 2 ,
+.Xr malloc 3 ,
.Xr open 2 ,
.Xr readlink 2
and
.Xr getcwd 3 .
.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
-/* $NetBSD: scandir.c,v 1.26 2007/06/09 23:57:25 christos Exp $ */
+/* $NetBSD: scandir.c,v 1.27 2012/03/13 21:13:36 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: scandir.c,v 1.26 2007/06/09 23:57:25 christos Exp $");
+__RCSID("$NetBSD: scandir.c,v 1.27 2012/03/13 21:13:36 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if (nitems && dcomp != NULL)
qsort(names, nitems, sizeof(*names), dcomp);
*namelist = names;
- return nitems;
+ _DIAGASSERT(__type_fit(int, nitems));
+ return (int)nitems;
bad2:
while (nitems-- > 0)
-/* $NetBSD: setdomainname.c,v 1.12 2003/08/07 16:42:56 agc Exp $ */
+/* $NetBSD: setdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: setdomainname.c,v 1.12 2003/08/07 16:42:56 agc Exp $");
+__RCSID("$NetBSD: setdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-setdomainname(name, namelen)
- const char *name;
- size_t namelen;
+setdomainname(const char *name, size_t namelen)
{
int mib[2];
-/* $NetBSD: sethostname.c,v 1.12 2003/08/07 16:42:56 agc Exp $ */
+/* $NetBSD: sethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sethostname.c,v 1.12 2003/08/07 16:42:56 agc Exp $");
+__RCSID("$NetBSD: sethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-sethostname(name, namelen)
- const char *name;
- size_t namelen;
+sethostname(const char *name, size_t namelen)
{
int mib[2];
-/* $NetBSD: setjmperr.c,v 1.7 2003/08/07 16:42:56 agc Exp $ */
+/* $NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: setjmperr.c,v 1.7 2003/08/07 16:42:56 agc Exp $");
+__RCSID("$NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <unistd.h>
void
-longjmperror()
+longjmperror(void)
{
#define ERRMSG "longjmp botch.\n"
(void)write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1);
-/* $NetBSD: setmode.c,v 1.31 2005/10/01 20:08:01 christos Exp $ */
+/* $NetBSD: setmode.c,v 1.34 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
#if 0
static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
#else
-__RCSID("$NetBSD: setmode.c,v 1.31 2005/10/01 20:08:01 christos Exp $");
+__RCSID("$NetBSD: setmode.c,v 1.34 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define CMD2_OBITS 0x08
#define CMD2_UBITS 0x10
-static BITCMD *addcmd __P((BITCMD *, mode_t, mode_t, mode_t, mode_t));
-static void compress_mode __P((BITCMD *));
+static BITCMD *addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t);
+static void compress_mode(BITCMD *);
#ifdef SETMODE_DEBUG
-static void dumpmode __P((BITCMD *));
+static void dumpmode(BITCMD *);
#endif
/*
#ifdef SETMODE_DEBUG
static void
-dumpmode(set)
- BITCMD *set;
+dumpmode(BITCMD *set)
{
_DIAGASSERT(set != NULL);
* compacted, but it's not worth the effort.
*/
static void
-compress_mode(set)
- BITCMD *set;
+compress_mode(BITCMD *set)
{
BITCMD *nset;
int setbits, clrbits, Xbits, op;
-/* $NetBSD: siginterrupt.c,v 1.12 2003/08/07 16:42:56 agc Exp $ */
+/* $NetBSD: siginterrupt.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: siginterrupt.c,v 1.12 2003/08/07 16:42:56 agc Exp $");
+__RCSID("$NetBSD: siginterrupt.c,v 1.13 2012/06/25 22:32:43 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* after an instance of the indicated signal.
*/
int
-siginterrupt(sig, flag)
- int sig, flag;
+siginterrupt(int sig, int flag)
{
struct sigaction sa;
int ret;
-/* $NetBSD: signal.c,v 1.12 2003/08/07 16:42:56 agc Exp $ */
+/* $NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
#if 0
static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: signal.c,v 1.12 2003/08/07 16:42:56 agc Exp $");
+__RCSID("$NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
sigset_t __sigintr; /* shared with siginterrupt */
sig_t
-signal(s, a)
- int s;
- sig_t a;
+signal(int s, sig_t a)
{
struct sigaction sa, osa;
-/* $NetBSD: sleep.c,v 1.22 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: sleep.c,v 1.23 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sleep.c,v 1.22 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: sleep.c,v 1.23 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
unsigned int
-sleep(seconds)
- unsigned int seconds;
+sleep(unsigned int seconds)
{
struct timespec rqt, rmt;
-.\" $NetBSD: sysconf.3,v 1.37 2010/03/22 19:30:54 joerg Exp $
+.\" $NetBSD: sysconf.3,v 1.40 2011/08/23 17:28:34 jmcneill Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94
.\"
-.Dd August 6, 2008
+.Dd August 23, 2011
.Dt SYSCONF 3
.Os
.Sh NAME
The maximum bytes of argument to
.Xr execve 2 .
.It Li _SC_ATEXIT_MAX
-The maxmimum number of functions that may be registered with
+The maximum number of functions that may be registered with
.Xr atexit 3 .
.It Li _SC_BARRIERS
The version of
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 NULL.
+The maximum size of a hostname, including
+.Dv NULL .
.It Li _SC_IOV_MAX
The maximum number of
.Va iovec
.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 NULL.
+The maximum length of the password, not counting
+.Dv NULL .
.It Li _SC_READER_WRITER_LOCKS
The version of
.St -p1003.1
argument is invalid.
.El
.Sh SEE ALSO
+.Xr getconf 1 ,
+.Xr limits 3 ,
.Xr sysctl 3
.Sh STANDARDS
The
-/* $NetBSD: sysconf.c,v 1.33 2008/08/06 17:17:04 matt Exp $ */
+/* $NetBSD: sysconf.c,v 1.34 2012/08/01 15:24:22 martin Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: sysconf.c,v 1.33 2008/08/06 17:17:04 matt Exp $");
+__RCSID("$NetBSD: sysconf.c,v 1.34 2012/08/01 15:24:22 martin Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
return _POSIX_REGEXP;
case _SC_SHELL:
return _POSIX_SHELL;
+ case _SC_SPAWN:
+ return _POSIX_SPAWN;
case _SC_SYMLOOP_MAX:
return MAXSYMLINKS;
-/* $NetBSD: sysctl.c,v 1.30 2008/08/27 08:56:49 christos Exp $ */
+/* $NetBSD: sysctl.c,v 1.32 2012/03/20 16:36:05 matt Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94";
#else
-__RCSID("$NetBSD: sysctl.c,v 1.30 2008/08/27 08:56:49 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.32 2012/03/20 16:36:05 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define __COMPAT_SYSCTL
#include <sys/sysctl.h>
+#include <assert.h>
#include <errno.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
int
-sysctl(name, namelen, oldp, oldlenp, newp, newlen)
- const int *name;
- unsigned int namelen;
- void *oldp;
- const void *newp;
- size_t *oldlenp, newlen;
+sysctl(const int *name, unsigned int namelen,
+ void *oldp, size_t *oldlenp,
+ const void *newp, size_t newlen)
{
size_t oldlen, savelen;
int error;
}
static int
-user_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
- const int *name;
- unsigned int namelen;
- void *oldp;
- const void *newp;
- size_t *oldlenp, newlen;
+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| \
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));
- d1->descr_len = strlen(d1->descr_str) + 1;
+ 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)
-/* $NetBSD: sysctlgetmibinfo.c,v 1.9 2010/12/13 23:10:13 pooka Exp $ */
+/* $NetBSD: sysctlgetmibinfo.c,v 1.10 2012/03/13 21:13:37 christos Exp $ */
/*-
* Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.9 2010/12/13 23:10:13 pooka Exp $");
+__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.10 2012/03/13 21:13:37 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifndef RUMP_ACTION
#include <sys/param.h>
#include <sys/sysctl.h>
+#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
{
struct sysctlnode *h, *i, *o, qnode;
size_t si, so;
- int rc, name, nlen, olen, ni, oi;
+ int rc, name;
+ size_t nlen, olen, ni, oi;
uint32_t t;
/*
* order the new copy of the head
*/
nlen = so / sizeof(struct sysctlnode);
- qsort(h, (size_t)nlen, sizeof(struct sysctlnode), compar);
+ qsort(h, nlen, sizeof(struct sysctlnode), compar);
/*
* verify that everything is the same. if it is, we don't
/*
* pop new head in
*/
- sysctl_mibroot.sysctl_clen = nlen;
- sysctl_mibroot.sysctl_csize = nlen;
+ _DIAGASSERT(__type_fit(uint32_t, nlen));
+ sysctl_mibroot.sysctl_csize =
+ sysctl_mibroot.sysctl_clen = (uint32_t)nlen;
sysctl_mibroot.sysctl_child = h;
free(o);
}
/*
* how many did we get?
*/
- pnode->sysctl_clen = sz / sizeof(struct sysctlnode);
- pnode->sysctl_csize = sz / sizeof(struct sysctlnode);
- if (pnode->sysctl_clen * sizeof(struct sysctlnode) != sz) {
+ 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;
-/* $NetBSD: sysctlnametomib.c,v 1.6 2010/12/13 23:10:13 pooka Exp $ */
+/* $NetBSD: sysctlnametomib.c,v 1.7 2012/03/13 21:13:37 christos Exp $ */
/*-
* Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sysctlnametomib.c,v 1.6 2010/12/13 23:10:13 pooka Exp $");
+__RCSID("$NetBSD: sysctlnametomib.c,v 1.7 2012/03/13 21:13:37 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifndef RUMP_ACTION
#endif
#include <sys/param.h>
#include <sys/sysctl.h>
+#include <assert.h>
#ifdef RUMP_ACTION
#include <rump/rump_syscalls.h>
u_int unamelen;
int rc;
- unamelen = *namelenp;
+ _DIAGASSERT(__type_fit(u_int, *namelenp));
+ unamelen = (u_int)*namelenp;
rc = sysctlgetmibinfo(gname, iname, &unamelen, NULL, NULL, NULL,
SYSCTL_VERSION);
*namelenp = unamelen;
-.\" $NetBSD: syslog.3,v 1.28 2010/05/13 18:04:58 jruoho Exp $
+.\" $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
function
is an alternative form in which the arguments have already been captured
using the variable-length argument facilities of
-.Xr varargs 3 .
+.Xr stdarg 3 .
.Pp
The
.Fn syslogp
-/* $NetBSD: syslog.c,v 1.48 2010/05/13 22:40:14 christos Exp $ */
+/* $NetBSD: syslog.c,v 1.53 2012/10/11 17:09:55 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
#if 0
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
#else
-__RCSID("$NetBSD: syslog.c,v 1.48 2010/05/13 22:40:14 christos Exp $");
+__RCSID("$NetBSD: syslog.c,v 1.53 2012/10/11 17:09:55 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__weak_alias(vsyslog,_vsyslog)
__weak_alias(syslogp,_syslogp)
__weak_alias(vsyslogp,_vsyslogp)
-
-__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(syslog_ss,_syslog_ss)
-__weak_alias(vsyslog_ss,_vsyslog_ss)
-__weak_alias(syslogp_r,_syslogp_r)
-__weak_alias(vsyslogp_r,_vsyslogp_r)
-__weak_alias(syslogp_ss,_syslogp_ss)
-__weak_alias(vsyslogp_ss,_vsyslogp_ss)
#endif
static struct syslog_data sdata = SYSLOG_DATA_INIT;
static mutex_t syslog_mutex = MUTEX_INITIALIZER;
#endif
-static char hostname[MAXHOSTNAMELEN];
-
/*
* syslog, vsyslog --
* print message on log file; output is intended for syslogd(8).
}
} else {
prlen = snprintf_ss(p, tbuf_left, "-");
-
- /* if gmtime_r() was signal-safe we could output the UTC-time:
+#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
}
+
+#ifndef __minix
+ if (data == &sdata)
+ mutex_lock(&syslog_mutex);
+#endif
+
+ 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 ", hostname);
- 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 : "-");
+
+#ifndef __minix
+ if (data == &sdata)
+ mutex_unlock(&syslog_mutex);
+#endif
+
if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
iovcnt = 0;
iov[iovcnt].iov_base = p;
if (data == &sdata)
mutex_lock(&syslog_mutex);
#endif
- opened = !data->opened;
+ opened = !data->log_opened;
if (opened)
openlog_unlocked_r(data->log_tag, data->log_stat, 0, data);
connectlog_r(data);
(void)close(data->log_file);
data->log_file = -1;
}
- data->connected = 0; /* retry connect */
+ data->log_connected = 0; /* retry connect */
}
static void
};
if (data->log_file == -1 || fcntl(data->log_file, F_GETFL, 0) == -1) {
- if ((data->log_file = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
+ if ((data->log_file = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC,
+ 0)) == -1)
return;
- (void)fcntl(data->log_file, F_SETFD, FD_CLOEXEC);
- data->connected = 0;
+ data->log_connected = 0;
}
- if (!data->connected) {
+ if (!data->log_connected) {
if (connect(data->log_file,
(const struct sockaddr *)(const void *)&sun,
- sizeof(sun)) == -1) {
+ (socklen_t)sizeof(sun)) == -1) {
(void)close(data->log_file);
data->log_file = -1;
} else
- data->connected = 1;
+ data->log_connected = 1;
}
}
if (data->log_stat & LOG_NDELAY) /* open immediately */
connectlog_r(data);
- /* We could cache this, but then it might change */
- if (gethostname(hostname, sizeof(hostname)) == -1
- || hostname[0] == '\0') {
- /* can this really happen? */
- hostname[0] = '-';
- hostname[1] = '\0';
- }
- data->opened = 1;
+ data->log_opened = 1;
}
void
#endif
(void)close(data->log_file);
data->log_file = -1;
- data->connected = 0;
+ data->log_connected = 0;
data->log_tag = NULL;
#ifndef __minix
if (data == &sdata)
-.\" $NetBSD: time.3,v 1.15 2010/04/24 01:35:50 dholland Exp $
+.\" $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.
.\"
.\" @(#)time.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd April 23, 2010
+.Dd November 5, 2011
.Dt TIME 3
.Os
.Sh NAME
.Va errno
is set to indicate the error.
.Sh ERRORS
-The following error codes may be set in
-.Va errno :
-.Bl -tag -width Er
-.It Bq Er EFAULT
-An argument address referenced invalid memory.
-.El
+No errors are defined.
.Sh SEE ALSO
.Xr gettimeofday 2 ,
.Xr ctime 3
-/* $NetBSD: time.c,v 1.11 2009/01/11 02:46:27 christos Exp $ */
+/* $NetBSD: time.c,v 1.12 2012/03/13 21:13:37 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: time.c,v 1.11 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: time.c,v 1.12 2012/03/13 21:13:37 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if (gettimeofday(&tt, NULL) == -1)
return (time_t)-1;
if (t != NULL)
- *t = tt.tv_sec;
- return tt.tv_sec;
+ *t = (time_t)tt.tv_sec;
+ return (time_t)tt.tv_sec;
}
#ifdef __minix
-/* $NetBSD: toascii.c,v 1.2 2003/08/07 16:42:58 agc Exp $ */
+/* $NetBSD: toascii.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: toascii.c,v 1.2 2003/08/07 16:42:58 agc Exp $");
+__RCSID("$NetBSD: toascii.c,v 1.3 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <ctype.h>
#undef toascii
int
-toascii(c)
- int c;
+toascii(int c)
{
return ((c) & 0177);
}
-.\" $NetBSD: ttyname.3,v 1.21 2008/06/25 11:47:29 ad Exp $
+.\" $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.
.\"
.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 25, 2008
+.Dd June 1, 2012
.Dt TTYNAME 3
.Os
.Sh NAME
.Fn isatty "int fd"
.In stdlib.h
.Ft int
-.Fn ttyslot
+.Fn ttyslot "void"
.Sh DESCRIPTION
These functions operate on the system file descriptors for terminal
type devices.
.Sh IMPLEMENTATION NOTES
As an optimisation, these functions attempt to obtain information about
all devices from the
-.Pa /var/run/dev.db
+.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.
.Fn ttyname_r
function will also fail if:
.Bl -tag -width Er
-.It Bq Er ERANGE
-The buffer provided is not large enough to fit the result.
.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 ,
.Fn ttyslot
functions appeared in
.At v7 .
-.\" Use of the .Pa /var/run/dev.db file was added in ???.
+.\" Use of the .Pa /var/run/dev.cdb file was added in netBSD 6.0.
.Sh BUGS
The
.Fn ttyname
-/* $NetBSD: ttyname.c,v 1.24 2008/06/25 11:47:29 ad Exp $ */
+/* $NetBSD: ttyname.c,v 1.26 2012/06/12 18:17:04 joerg Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
#else
-__RCSID("$NetBSD: ttyname.c,v 1.24 2008/06/25 11:47:29 ad Exp $");
+__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 <sys/types.h>
-#include <sys/param.h>
+#include <sys/ioctl.h>
#include <sys/stat.h>
#include <assert.h>
-#include <db.h>
-#include <dirent.h>
#include <errno.h>
-#include <fcntl.h>
+#include <limits.h>
#include <paths.h>
#include <string.h>
+#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
-#include <sys/ioctl.h>
#ifdef __weak_alias
__weak_alias(ttyname,_ttyname)
__weak_alias(ttyname_r,_ttyname_r)
#endif
-static int oldttyname(const struct stat *, char *, size_t);
-
-int
-ttyname_r(int fd, char *buf, size_t len)
-{
- struct stat sb;
- struct termios ttyb;
- DB *db;
- DBT data, key;
- struct {
- mode_t type;
- dev_t dev;
- } bkey;
-#ifndef __minix
- struct ptmget ptm;
-#endif
-#define DEVSZ (sizeof(_PATH_DEV) - 1)
-
- _DIAGASSERT(fd != -1);
-
- if (len <= DEVSZ) {
- return ERANGE;
- }
-
-#ifndef __minix
- /* 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;
- }
-#endif
- /* Must be a terminal. */
- if (tcgetattr(fd, &ttyb) == -1)
- return errno;
-
- /* Must be a character device. */
- if (fstat(fd, &sb))
- return errno;
- if (!S_ISCHR(sb.st_mode))
- return ENOTTY;
-
- (void)memcpy(buf, _PATH_DEV, DEVSZ);
- if ((db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)) != NULL) {
- (void)memset(&bkey, 0, sizeof(bkey));
- bkey.type = S_IFCHR;
- bkey.dev = sb.st_rdev;
- key.data = &bkey;
- key.size = sizeof(bkey);
- if (!(db->get)(db, &key, &data, 0)) {
- if (len - DEVSZ <= data.size) {
- return ERANGE;
- }
- (void)memcpy(buf + DEVSZ, data.data, data.size);
- (void)(db->close)(db);
- return 0;
- }
- (void)(db->close)(db);
- }
- if (oldttyname(&sb, buf, len) == -1)
- return errno;
- return 0;
-}
-
+#ifdef __minix
+/* LSC: We do not have devname functionality on Minix, so re-import for now
+ * old, manual way of doing it.*/
+#include <dirent.h>
static int
oldttyname(const struct stat *sb, char *buf, size_t len)
{
return -1;
while ((dirp = readdir(dp)) != NULL) {
+#define DEVSZ (sizeof(_PATH_DEV) - 1)
if (dirp->d_fileno != sb->st_ino)
continue;
-#ifdef __minix
dlen = strlen(dirp->d_name);
-#else
- dlen = dirp->d_namlen + 1;
-#endif
if (len - DEVSZ <= dlen) {
/*
* XXX: we return an error if *any* entry does not
continue;
(void)closedir(dp);
return 0;
+#undef DEVSZ
}
(void)closedir(dp);
/*
return -1;
}
+#endif
+
+int
+ttyname_r(int fd, char *buf, size_t len)
+{
+ struct stat sb;
+ struct termios ttyb;
+#ifndef __minix
+ struct ptmget ptm;
+#endif
+
+ _DIAGASSERT(fd != -1);
+
+#ifndef __minix
+ /* 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;
+ }
+#endif
+
+ /* 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;
+
+#ifdef __minix
+ if (oldttyname(&sb, buf, len) == -1)
+ return errno;
+ return 0;
+#else
+ buf += strlen(_PATH_DEV);
+ len -= strlen(_PATH_DEV);
+ return devname_r(sb.st_rdev, sb.st_mode & S_IFMT, buf, len);
+#endif
+}
+
+
char *
ttyname(int fd)
{
- static char buf[MAXPATHLEN];
+ static char buf[PATH_MAX];
int rv;
rv = ttyname_r(fd, buf, sizeof(buf));
-.\" $NetBSD: ualarm.3,v 1.18 2010/04/29 06:07:35 jruoho Exp $
+.\" $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.
.\"
.\" @(#)ualarm.3 8.2 (Berkeley) 4/19/94
.\"
-.Dd April 29, 2010
+.Dd May 2, 2011
.Dt UALARM 3
.Os
.Sh NAME
.Sh STANDARDS
The
.Fn ualarm
-functions conforms to
-.St -xpg4.2
-and
+function conforms to
.St -p1003.1-2001 .
-The latter standard marked
-.Fn ualarm
-as obsolescent and a later revision,
-.St -p1003.1-2008 ,
-removed the specification of
-.Fn ualarm .
+However, the later
+.St -p1003.1-2008
+revision removed the function from the specification.
.Sh HISTORY
The
.Fn ualarm
-/* $NetBSD: ualarm.c,v 1.10 2003/08/07 16:42:58 agc Exp $ */
+/* $NetBSD: ualarm.c,v 1.11 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1985, 1993
#if 0
static char sccsid[] = "@(#)ualarm.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ualarm.c,v 1.10 2003/08/07 16:42:58 agc Exp $");
+__RCSID("$NetBSD: ualarm.c,v 1.11 2012/06/25 22:32:44 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* every ``reload'' microseconds after the first signal.
*/
useconds_t
-ualarm(usecs, reload)
- useconds_t usecs;
- useconds_t reload;
+ualarm(useconds_t usecs, useconds_t reload)
{
struct itimerval new, old;
{
va_list ap;
struct rlimit rlimit;
- long int result;
#ifndef __minix
- long int new_limit;
+ long int new_limit, result;
+#else
+ long int result;
#endif
va_start(ap, cmd);
-.\" $NetBSD: uname.3,v 1.11 2010/04/27 15:16:28 jruoho Exp $
+.\" $NetBSD: uname.3,v 1.12 2011/03/30 16:41:00 jruoho Exp $
.\"
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)uname.3 8.1 (Berkeley) 1/4/94
.\"
-.Dd April 27, 2010
+.Dd March 30, 2011
.Dt UNAME 3
.Os
.Sh NAME
.Fa name .
.Pp
The
-.Li utsname
+.Em utsname
structure is defined in the
.In sys/utsname.h
header file, and contains the following members:
-/* $NetBSD: uname.c,v 1.10 2007/01/15 22:26:35 cbiere Exp $ */
+/* $NetBSD: uname.c,v 1.11 2012/03/20 16:36:05 matt Exp $ */
/*-
* Copyright (c) 1994
#if 0
static char sccsid[] = "@(#)uname.c 8.1 (Berkeley) 1/4/94";
#else
-__RCSID("$NetBSD: uname.c,v 1.10 2007/01/15 22:26:35 cbiere Exp $");
+__RCSID("$NetBSD: uname.c,v 1.11 2012/03/20 16:36:05 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-uname(name)
- struct utsname *name;
+uname(struct utsname *name)
{
int mib[2];
size_t len;
-.\" $NetBSD: unvis.3,v 1.20 2010/11/28 01:28:21 wiz Exp $
+.\" $NetBSD: unvis.3,v 1.23 2011/03/17 14:06:29 wiz Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
.\"
-.Dd November 27, 2010
+.Dd March 12, 2011
.Dt UNVIS 3
.Os
.Sh NAME
.Ft int
.Fn strunvis "char *dst" "const char *src"
.Ft int
+.Fn strnunvis "char *dst" "size_t dlen" "const char *src"
+.Ft int
.Fn strunvisx "char *dst" "const char *src" "int flag"
+.Ft int
+.Fn strnunvisx "char *dst" "size_t dlen" "const char *src" "int flag"
.Sh DESCRIPTION
The
.Fn unvis ,
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 ,
function
first appeared in
.Bx 4.4 .
+The
+.Fn strnunvis
+and
+.Fn strnunvisx
+functions appeared in
+.Nx 6.0 .
-/* $NetBSD: unvis.c,v 1.32 2010/11/27 21:22:11 christos Exp $ */
+/* $NetBSD: unvis.c,v 1.39 2012/03/13 21:13:37 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.32 2010/11/27 21:22:11 christos Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.39 2012/03/13 21:13:37 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
+#include <stdint.h>
#include <stdio.h>
+#include <errno.h>
#include <vis.h>
#ifdef __weak_alias
-__weak_alias(strunvis,_strunvis)
+__weak_alias(strnunvisx,_strnunvisx)
#endif
#if !HAVE_VIS
#define S_CTRL 4 /* control char started (^) */
#define S_OCTAL2 5 /* octal digit 2 */
#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX1 7 /* http hex digit */
-#define S_HEX2 8 /* http hex digit 2 */
-#define S_MIME1 9 /* mime hex digit 1 */
-#define S_MIME2 10 /* mime hex digit 2 */
-#define S_EATCRNL 11 /* mime eating CRNL */
-#define S_AMP 12 /* seen & */
-#define S_NUMBER 13 /* collecting number */
-#define S_STRING 14 /* collecting string */
+#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))
+#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
+#define XTOD(c) (isdigit(c) ? (c - '0') : ((c - 'A') + 10))
/*
* RFC 1866
*cp = '\033';
*astate = SS(0, S_GROUND);
return UNVIS_VALID;
+ case 'x':
+ *astate = SS(0, S_HEX);
+ return UNVIS_NOCHAR;
case '\n':
/*
* hidden newline
*/
return UNVIS_VALIDPUSH;
+ case S_HEX:
+ if (!isxdigit(uc))
+ goto bad;
+ /*FALLTHROUGH*/
case S_HEX1:
if (isxdigit(uc)) {
*cp = xtod(uc);
break;
}
- if (*cp == __arraycount(nv))
+ if (ia == __arraycount(nv))
goto bad;
if (uc != 0) {
}
/*
- * strunvis - decode src into dst
+ * strnunvisx - decode src into dst
*
* Number of chars decoded into dst is returned, -1 on error.
* Dst is null terminated.
*/
int
-strunvisx(char *dst, const char *src, int flag)
+strnunvisx(char *dst, size_t dlen, const char *src, int flag)
{
char c;
- char *start = dst;
+ 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(dst, c, &state, flag)) {
+ switch (unvis(&t, c, &state, flag)) {
case UNVIS_VALID:
- dst++;
+ CHECKSPACE();
+ *dst++ = t;
break;
case UNVIS_VALIDPUSH:
- dst++;
+ CHECKSPACE();
+ *dst++ = t;
goto again;
case 0:
case UNVIS_NOCHAR:
break;
+ case UNVIS_SYNBAD:
+ errno = EINVAL;
+ return -1;
default:
- return (-1);
+ _DIAGASSERT(/*CONSTCOND*/0);
+ errno = EINVAL;
+ return -1;
}
}
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
+ if (unvis(&t, c, &state, UNVIS_END) == UNVIS_VALID) {
+ CHECKSPACE();
+ *dst++ = t;
+ }
+ CHECKSPACE();
*dst = '\0';
return (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 strunvisx(dst, src, 0);
+ 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
-/* $NetBSD: usleep.c,v 1.19 2008/04/28 20:22:59 martin Exp $ */
+/* $NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: usleep.c,v 1.19 2008/04/28 20:22:59 martin Exp $");
+__RCSID("$NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
int
-usleep(useconds)
- useconds_t useconds;
+usleep(useconds_t useconds)
{
struct timespec ts;
-/* $NetBSD: utime.c,v 1.13 2010/03/23 20:28:59 drochner Exp $ */
+/* $NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: utime.c,v 1.13 2010/03/23 20:28:59 drochner Exp $");
+__RCSID("$NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <utime.h>
int
-utime(path, times)
- const char *path;
- const struct utimbuf *times;
+utime(const char *path, const struct utimbuf *times)
{
struct timeval tv[2], *tvp;
-/* $NetBSD: utmp.c,v 1.9 2009/02/05 23:52:55 lukem Exp $ */
+/* $NetBSD: utmp.c,v 1.10 2011/10/15 23:00:02 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmp.c,v 1.9 2009/02/05 23:52:55 lukem Exp $");
+__RCSID("$NetBSD: utmp.c,v 1.10 2011/10/15 23:00:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
if (ut == NULL) {
struct stat st;
off_t numentries;
- if ((ut = fopen(utfile, "r")) == NULL)
+ if ((ut = fopen(utfile, "re")) == NULL)
return NULL;
if (fstat(fileno(ut), &st) == -1)
goto out;
-/* $NetBSD: utmpx.c,v 1.26 2009/01/11 02:46:27 christos Exp $ */
+/* $NetBSD: utmpx.c,v 1.30 2012/06/24 15:26:03 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmpx.c,v 1.26 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: utmpx.c,v 1.30 2012/06/24 15:26:03 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
struct timeval *tv = &utx->ut_tv;
(void)memcpy(&otv, tv, sizeof(otv));
tv->tv_sec = otv.tv_sec;
- tv->tv_usec = otv.tv_usec;
+ tv->tv_usec = (suseconds_t)otv.tv_usec;
}
static void
}
void
-setutxent()
+setutxent(void)
{
(void)memset(&ut, 0, sizeof(ut));
void
-endutxent()
+endutxent(void)
{
(void)memset(&ut, 0, sizeof(ut));
struct utmpx *
-getutxent()
+getutxent(void)
{
if (fp == NULL) {
struct stat st;
- if ((fp = fopen(utfile, "r+")) == NULL)
+ if ((fp = fopen(utfile, "re+")) == NULL)
if ((fp = fopen(utfile, "w+")) == NULL) {
if ((fp = fopen(utfile, "r")) == NULL)
goto fail;
if (utx == NULL)
return NULL;
- if (strcmp(_PATH_UTMPX, utfile) == 0)
- if ((fp != NULL && readonly) || (fp == NULL && geteuid() != 0))
- return utmp_update(utx);
+ 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));
-/* $NetBSD: valloc.c,v 1.10 2003/08/07 16:42:59 agc Exp $ */
+/* $NetBSD: valloc.c,v 1.11 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: valloc.c,v 1.10 2003/08/07 16:42:59 agc Exp $");
+__RCSID("$NetBSD: valloc.c,v 1.11 2012/06/25 22:32:44 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
void *
-valloc(i)
- size_t i;
+valloc(size_t i)
{
long valsiz = getpagesize(), j;
void *cp = malloc((size_t)(i + (valsiz-1)));
-/* $NetBSD: verr.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */
+/* $NetBSD: verr.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: verr.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $");
+__RCSID("$NetBSD: verr.c,v 1.15 2011/07/17 20:54:34 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if !HAVE_ERR_H
__dead void
-verr(int eval, const char *fmt, _BSD_VA_LIST_ ap)
+verr(int eval, const char *fmt, va_list ap)
{
int sverrno;
-/* $NetBSD: verrx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */
+/* $NetBSD: verrx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: verrx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $");
+__RCSID("$NetBSD: verrx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if !HAVE_ERR_H
__dead void
-verrx(int eval, const char *fmt, _BSD_VA_LIST_ ap)
+verrx(int eval, const char *fmt, va_list ap)
{
(void)fprintf(stderr, "%s: ", getprogname());
if (fmt != NULL)
-.\" $NetBSD: vis.3,v 1.23 2009/02/10 23:06:31 christos Exp $
+.\" $NetBSD: vis.3,v 1.27 2011/05/17 07:10:39 joerg Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd February 10, 2009
+.Dd March 12, 2011
.Dt VIS 3
.Os
.Sh NAME
.Nm vis ,
+.Nm nvis ,
.Nm strvis ,
+.Nm strnvis ,
.Nm strvisx ,
+.Nm strnvisx ,
.Nm svis ,
+.Nm snvis ,
.Nm strsvis ,
+.Nm strsnvis ,
.Nm strsvisx
+.Nm strsnvisx
.Nd visually encode characters
.Sh LIBRARY
.Lb libc
.In vis.h
.Ft char *
.Fn vis "char *dst" "int c" "int flag" "int nextc"
+.Ft char *
+.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc"
.Ft int
.Fn strvis "char *dst" "const char *src" "int flag"
.Ft int
+.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
+.Ft int
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
+.Ft int
+.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
.Ft 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"
.Sh DESCRIPTION
The
.Fn vis
encoding format (explained below).
.Pp
The
-.Fn strvis
+.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
and
-.Fn strvisx
+.Fn strnvisx
functions copy into
.Fa dst
a visual representation of
.Fa src .
The
.Fn strvis
-function encodes characters from
+and
+.Fn strnvis
+functions encode characters from
.Fa src
up to the
first
.Dv NUL .
The
.Fn strvisx
-function encodes exactly
+and
+.Fn strnvisx
+functions encode exactly
.Fa len
characters from
.Fa src
forms return the number of characters in dst (not including
the trailing
.Dv NUL ) .
+The
+.Dq 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 fix the converted string then the
+.Fn strnvis
+and
+.Fn strnvisx
+functions return \-1 and set
+.Va errno
+to
+.Dv ENOSPC .
.Pp
The functions
.Fn svis ,
+.Fn snvis ,
.Fn strsvis ,
+.Fn strsnvis ,
+.Fn strsvisx ,
and
-.Fn strsvisx
+.Fn strsnvisx
correspond to
.Fn vis ,
+.Fn nvis ,
.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
and
-.Fn strvisx
+.Fn strnvisx
but have an additional argument
.Fa extra ,
pointing to a
The encoding is a unique, invertible representation composed entirely of
graphic characters; it can be decoded back into the original form using
the
-.Xr unvis 3
-or
+.Xr unvis 3 ,
.Xr strunvis 3
+or
+.Xr strnunvis 3
functions.
.Pp
There are two parameters that can be controlled: the range of
characters that are encoded (applies only to
.Fn vis ,
+.Fn nvis ,
.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
and
-.Fn strvisx ) ,
+.Fn strnvisx ) ,
and the type of representation used.
By default, all non-graphic characters,
except space, tab, and newline are encoded.
.Pp
(The above flags have no effect for
.Fn svis ,
+.Fn snvis ,
.Fn strsvis ,
+.Fn strsnvis ,
+.Fn strsvisx ,
and
-.Fn strsvisx .
+.Fn strsnvisx .
When using these functions, place all graphic characters to be
encoded in an array pointed to by
.Fa extra .
.Ql M-C ) .
With this flag set, the encoding is
ambiguous and non-invertible.
+.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 length size is not enough to perform the conversion while
+setting
+.Va errno
+to:
+.Bl -tag -width Er
+.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 ,
.Re
.Sh HISTORY
The
-.Fa vis ,
-.Fa strvis ,
+.Fn vis ,
+.Fn strvis ,
and
.Fa strvisx
functions first appeared in
.Bx 4.4 .
The
-.Fa svis ,
-.Fa strsvis ,
+.Fn svis ,
+.Fn strsvis ,
and
-.Fa strsvisx
+.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 .
-/* $NetBSD: vis.c,v 1.41 2009/11/23 10:08:47 plunky Exp $ */
+/* $NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.41 2009/11/23 10:08:47 plunky Exp $");
+__RCSID("$NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <vis.h>
+#include <errno.h>
#include <stdlib.h>
#ifdef __weak_alias
-__weak_alias(strsvis,_strsvis)
-__weak_alias(strsvisx,_strsvisx)
-__weak_alias(strvis,_strvis)
__weak_alias(strvisx,_strvisx)
-__weak_alias(svis,_svis)
-__weak_alias(vis,_vis)
#endif
#if !HAVE_VIS || !HAVE_SVIS
#include <stdio.h>
#include <string.h>
-static char *do_svis(char *, int, int, int, const char *);
+static char *do_svis(char *, size_t *, int, int, int, const char *);
#undef BELL
#define BELL '\a'
* This is do_hvis, for HTTP style (RFC 1808)
*/
static char *
-do_hvis(char *dst, int c, int flag, int nextc, const char *extra)
+do_hvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
if ((isascii(c) && isalnum(c))
/* extra */
|| c == '!' || c == '*' || c == '\'' || c == '(' || c == ')'
|| c == ',') {
- dst = do_svis(dst, c, flag, nextc, extra);
+ dst = do_svis(dst, dlen, c, flag, nextc, extra);
} else {
+ if (dlen) {
+ if (*dlen < 3)
+ return NULL;
+ *dlen -= 3;
+ }
*dst++ = '%';
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
*dst++ = xtoa((unsigned int)c & 0xf);
* NB: No handling of long lines or CRLF.
*/
static char *
-do_mvis(char *dst, int c, int flag, int nextc, const char *extra)
+do_mvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
if ((c != '\n') &&
/* Space at the end of the line */
(!isspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) ||
/* Specific char to be escaped */
strchr("#$@[\\]^`{|}~", c) != NULL)) {
+ if (dlen) {
+ if (*dlen < 3)
+ return NULL;
+ *dlen -= 3;
+ }
*dst++ = '=';
*dst++ = XTOA(((unsigned int)c >> 4) & 0xf);
*dst++ = XTOA((unsigned int)c & 0xf);
} else {
- dst = do_svis(dst, c, flag, nextc, extra);
+ dst = do_svis(dst, dlen, c, flag, nextc, extra);
}
return dst;
}
* backslash-protected.
*/
static char *
-do_svis(char *dst, int c, int flag, int nextc, const char *extra)
+do_svis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
int isextra;
+ size_t odlen = dlen ? *dlen : 0;
+
isextra = strchr(extra, c) != NULL;
+#define HAVE(x) \
+ do { \
+ if (dlen) { \
+ if (*dlen < (x)) \
+ goto out; \
+ *dlen -= (x); \
+ } \
+ } while (/*CONSTCOND*/0)
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) ||
((flag & VIS_SAFE) && issafe(c)))) {
+ HAVE(1);
*dst++ = c;
return dst;
}
if (flag & VIS_CSTYLE) {
+ HAVE(2);
switch (c) {
case '\n':
*dst++ = '\\'; *dst++ = 'n';
case '\0':
*dst++ = '\\'; *dst++ = '0';
if (isoctal(nextc)) {
+ HAVE(2);
*dst++ = '0';
*dst++ = '0';
}
*dst++ = '\\'; *dst++ = c;
return dst;
}
+ if (dlen)
+ *dlen = odlen;
}
}
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
+ HAVE(4);
*dst++ = '\\';
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
*dst++ = (c & 07) + '0';
} else {
- if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\';
+ if ((flag & VIS_NOSLASH) == 0) {
+ HAVE(1);
+ *dst++ = '\\';
+ }
+
if (c & 0200) {
+ HAVE(1);
c &= 0177; *dst++ = 'M';
}
+
if (iscntrl(c)) {
+ HAVE(2);
*dst++ = '^';
if (c == 0177)
*dst++ = '?';
else
*dst++ = c + '@';
} else {
+ HAVE(2);
*dst++ = '-'; *dst++ = c;
}
}
return dst;
+out:
+ *dlen = odlen;
+ return NULL;
}
-typedef char *(*visfun_t)(char *, int, int, int, const char *);
+typedef char *(*visfun_t)(char *, size_t *, int, int, int, const char *);
/*
* Return the appropriate encoding function depending on the flags given.
}
/*
- * svis - visually encode characters, also encoding the characters
+ * isnvis - visually encode characters, also encoding the characters
* pointed to by `extra'
*/
-char *
-svis(char *dst, int c, int flag, int nextc, const char *extra)
+static char *
+isnvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
char *nextra = NULL;
visfun_t f;
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0'; /* can't create nextra, return "" */
return dst;
}
f = getvisfun(flag);
- dst = (*f)(dst, c, flag, nextc, nextra);
+ dst = (*f)(dst, dlen, c, flag, nextc, nextra);
free(nextra);
+ if (dst == NULL || (dlen && *dlen == 0)) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0';
return dst;
}
+char *
+svis(char *dst, int c, int flag, int nextc, const char *extra)
+{
+ return isnvis(dst, NULL, c, flag, nextc, extra);
+}
+
+char *
+snvis(char *dst, size_t dlen, int c, int flag, int nextc, const char *extra)
+{
+ return isnvis(dst, &dlen, c, flag, nextc, extra);
+}
+
/*
* strsvis, strsvisx - visually encode characters from src into dst
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int
-strsvis(char *dst, const char *csrc, int flag, const char *extra)
+static int
+istrsnvis(char *dst, size_t *dlen, const char *csrc, int flag, const char *extra)
{
int c;
char *start;
return 0;
}
f = getvisfun(flag);
- for (start = dst; (c = *src++) != '\0'; /* empty */)
- dst = (*f)(dst, c, flag, *src, nextra);
+ for (start = dst; (c = *src++) != '\0'; /* empty */) {
+ dst = (*f)(dst, dlen, c, flag, *src, nextra);
+ if (dst == NULL) {
+ errno = ENOSPC;
+ return -1;
+ }
+ }
free(nextra);
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0';
return (int)(dst - start);
}
+int
+strsvis(char *dst, const char *csrc, int flag, const char *extra)
+{
+ return istrsnvis(dst, NULL, csrc, flag, extra);
+}
int
-strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+strsnvis(char *dst, size_t dlen, const char *csrc, int flag, const char *extra)
+{
+ return istrsnvis(dst, &dlen, csrc, flag, extra);
+}
+
+static int
+istrsnvisx(char *dst, size_t *dlen, const char *csrc, size_t len, int flag,
+ const char *extra)
{
unsigned char c;
char *start;
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (! nextra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create nextra, return "" */
return 0;
}
f = getvisfun(flag);
for (start = dst; len > 0; len--) {
c = *src++;
- dst = (*f)(dst, c, flag, len > 1 ? *src : '\0', nextra);
+ dst = (*f)(dst, dlen, c, flag, len > 1 ? *src : '\0', nextra);
+ if (dst == NULL) {
+ errno = ENOSPC;
+ return -1;
+ }
}
free(nextra);
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0';
return (int)(dst - start);
}
+
+int
+strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+{
+ return istrsnvisx(dst, NULL, csrc, len, flag, extra);
+}
+
+int
+strsnvisx(char *dst, size_t dlen, const char *csrc, size_t len, int flag,
+ const char *extra)
+{
+ return istrsnvisx(dst, &dlen, csrc, len, flag, extra);
+}
#endif
#if !HAVE_VIS
/*
* vis - visually encode characters
*/
-char *
-vis(char *dst, int c, int flag, int nextc)
+static char *
+invis(char *dst, size_t *dlen, int c, int flag, int nextc)
{
char *extra = NULL;
unsigned char uc = (unsigned char)c;
MAKEEXTRALIST(flag, extra, "");
if (! extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0'; /* can't create extra, return "" */
return dst;
}
f = getvisfun(flag);
- dst = (*f)(dst, uc, flag, nextc, extra);
+ dst = (*f)(dst, dlen, uc, flag, nextc, extra);
free(extra);
+ if (dst == NULL || (dlen && *dlen == 0)) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0';
return dst;
}
+char *
+vis(char *dst, int c, int flag, int nextc)
+{
+ return invis(dst, NULL, c, flag, nextc);
+}
+
+char *
+nvis(char *dst, size_t dlen, int c, int flag, int nextc)
+{
+ return invis(dst, &dlen, c, flag, nextc);
+}
+
/*
* strvis, strvisx - visually encode characters from src into dst
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int
-strvis(char *dst, const char *src, int flag)
+static int
+istrnvis(char *dst, size_t *dlen, const char *src, int flag)
{
char *extra = NULL;
int rv;
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
- rv = strsvis(dst, src, flag, extra);
+ rv = istrsnvis(dst, dlen, src, flag, extra);
free(extra);
return rv;
}
+int
+strvis(char *dst, const char *src, int flag)
+{
+ return istrnvis(dst, NULL, src, flag);
+}
int
-strvisx(char *dst, const char *src, size_t len, int flag)
+strnvis(char *dst, size_t dlen, const char *src, int flag)
+{
+ return istrnvis(dst, &dlen, src, flag);
+}
+
+static int
+istrnvisx(char *dst, size_t *dlen, const char *src, size_t len, int flag)
{
char *extra = NULL;
int rv;
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
- rv = strsvisx(dst, src, len, flag, extra);
+ rv = istrsnvisx(dst, dlen, src, len, flag, extra);
free(extra);
return rv;
}
+
+int
+strvisx(char *dst, const char *src, size_t len, int flag)
+{
+ return istrnvisx(dst, NULL, src, len, flag);
+}
+
+int
+strnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag)
+{
+ return istrnvisx(dst, &dlen, src, len, flag);
+}
+
#endif
-/* $NetBSD: vwarn.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */
+/* $NetBSD: vwarn.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vwarn.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $");
+__RCSID("$NetBSD: vwarn.c,v 1.15 2011/07/17 20:54:34 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if !HAVE_ERR_H
void
-vwarn(const char *fmt, _BSD_VA_LIST_ ap)
+vwarn(const char *fmt, va_list ap)
{
int sverrno;
-/* $NetBSD: vwarnx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */
+/* $NetBSD: vwarnx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vwarnx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $");
+__RCSID("$NetBSD: vwarnx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if !HAVE_ERR_H
void
-vwarnx(const char *fmt, _BSD_VA_LIST_ ap)
+vwarnx(const char *fmt, va_list ap)
{
(void)fprintf(stderr, "%s: ", getprogname());
if (fmt != NULL)
-/* $NetBSD: wait.c,v 1.8 2003/08/07 16:43:00 agc Exp $ */
+/* $NetBSD: wait.c,v 1.9 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wait.c,v 1.8 2003/08/07 16:43:00 agc Exp $");
+__RCSID("$NetBSD: wait.c,v 1.9 2012/03/20 16:36:05 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
pid_t
-wait(istat)
- int *istat;
+wait(int *istat)
{
- return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
+ return (wait4(WAIT_ANY, istat, 0, (struct rusage *)NULL));
}
-/* $NetBSD: wait3.c,v 1.9 2010/03/23 20:28:59 drochner Exp $ */
+/* $NetBSD: wait3.c,v 1.10 2012/03/20 16:36:05 matt Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wait3.c,v 1.9 2010/03/23 20:28:59 drochner Exp $");
+__RCSID("$NetBSD: wait3.c,v 1.10 2012/03/20 16:36:05 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/resource.h>
pid_t
-wait3(istat, options, rup)
- int *istat;
- int options;
- struct rusage *rup;
+wait3(int *istat, int options, struct rusage *rup)
{
return (wait4(WAIT_ANY, istat, options, rup));
}
-/* $NetBSD: gmon.c,v 1.33 2011/01/05 00:03:52 wiz Exp $ */
+/* $NetBSD: gmon.c,v 1.34 2012/03/13 21:13:37 christos Exp $ */
/*
* Copyright (c) 2003, 2004 Wasabi Systems, Inc.
#if 0
static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: gmon.c,v 1.33 2011/01/05 00:03:52 wiz Exp $");
+__RCSID("$NetBSD: gmon.c,v 1.34 2012/03/13 21:13:37 christos Exp $");
#endif
#endif
cp = mmap(NULL,
(size_t)(sizeof (struct gmonparam) +
_gmonparam.fromssize + _gmonparam.tossize),
- PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0LL);
+ PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
p = (void *)cp;
*p = _gmonparam;
p->kcount = NULL;
-# $NetBSD: Makefile.inc,v 1.11 2006/10/27 18:29:21 drochner Exp $
+# $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
.include "${.CURDIR}/hash/sha1/Makefile.inc"
.include "${.CURDIR}/hash/sha2/Makefile.inc"
+.include "${.CURDIR}/hash/murmurhash/Makefile.inc"
-/* $NetBSD: md2.c,v 1.5 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: md2.c,v 1.7 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md2.c,v 1.5 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: md2.c,v 1.7 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
void
-MD2Init(context)
- MD2_CTX *context;
+MD2Init(MD2_CTX *context)
{
_DIAGASSERT(context != 0);
}
void
-MD2Update(context, input, inputLen)
- MD2_CTX *context;
- const unsigned char *input;
- unsigned int inputLen;
+MD2Update(MD2_CTX *context, const unsigned char *input, unsigned int inputLen)
{
unsigned int idx, piece;
}
void
-MD2Final(digest, context)
- unsigned char digest[16]; /* message digest */
- MD2_CTX *context; /* context */
+MD2Final(unsigned char digest[16], MD2_CTX *context)
{
unsigned int padlen;
}
/*static*/ void
-MD2Transform(context)
- MD2_CTX *context;
+MD2Transform(MD2_CTX *context)
{
- u_int32_t l, j, k, t;
+ uint32_t l, j, k, t;
/* set block "3" and update "checksum" */
for (l = context->C[15], j = 0; j < 16; j++) {
--- /dev/null
+# $NetBSD: Makefile.inc,v 1.1 2012/07/08 11:43:47 rmind Exp $
+
+.PATH: ${.CURDIR}/hash/murmurhash
+
+SRCS+= murmurhash.c
-/* $NetBSD: extern.h,v 1.17 2009/10/21 01:07:45 snj Exp $ */
+/* $NetBSD: extern.h,v 1.21 2012/10/11 17:09:56 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef __minix
+#include <sys/types.h>
+#endif
+#include <stdarg.h>
+#include <ucontext.h>
+
__BEGIN_DECLS
extern char *__minbrk;
int __getcwd(char *, size_t);
int __getlogin(char *, size_t);
int __setlogin(const char *);
-void _resumecontext(void);
+void _resumecontext(void) __dead;
const char *__strerror(int , char *, size_t);
const char *__strsignal(int , char *, size_t);
char *__dtoa(double, int, 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 *, ...)
- __attribute__((__format__(__printf__,3,4)));
-void vsyslog_ss(int, struct syslog_data *, const char *, _BSD_VA_LIST_);
-void vsyslog_ss(int, struct syslog_data *, const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,3,0)));
+ __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 *, ...) __attribute__((__format__(__printf__,5,0)));
+ const char *, ...) __RENAME(__syslogp_ss60) __printflike(5, 0);
void vsyslogp_ss(int, struct syslog_data *, const char *, const char *,
- const char *, _BSD_VA_LIST_) __attribute__((__format__(__printf__,5,0)));
+ const char *, va_list) __RENAME(__vsyslogp_ss60) __printflike(5, 0);
+#endif
int snprintf_ss(char * __restrict, size_t, const char * __restrict, ...)
- __attribute__((__format__(__printf__, 3, 4)));
+ __printflike(3, 4);
int vsnprintf_ss(char * __restrict, size_t, const char * __restrict,
- _BSD_VA_LIST_) __attribute__((__format__(__printf__, 3, 0)));
+ va_list) __printflike(3, 0);
void _malloc_prefork(void);
void _malloc_postfork(void);
+int _sys_setcontext(const ucontext_t *);
+
__END_DECLS
-/* $NetBSD: namespace.h,v 1.146 2010/12/16 18:38:06 christos Exp $ */
+/* $NetBSD: namespace.h,v 1.156 2012/08/20 21:38:10 dsl Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
#define catopen _catopen
#define daylight _daylight
#define difftime _difftime
+#define devname_r _devname_r
#define err _err
#define errx _errx
#ifdef _REENTRANT
#define alarm _alarm
#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 atoll _atoll
#define fnmatch _fnmatch
#define fparseln _fparseln
#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 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 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 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 strsignal _strsignal
#define strsuftoll _strsuftoll
#define strsuftollx _strsuftollx
-#define strsvis _strsvis
-#define strsvisx _strsvisx
#define strtok_r _strtok_r
-#define strunvis _strunvis
-#define strvis _strvis
+#define strnunvisx _strnunvisx
#define strvisx _strvisx
#define svc_auth_reg _svc_auth_reg
#define svc_create _svc_create
#define svcudp_bufcreate _svcudp_bufcreate
#define svcudp_create _svcudp_create
#define svcudp_enablecache _svcudp_enablecache
-#define svis _svis
#define sysarch _sys_sysarch
#define sysctl _sysctl
#define sysctlbyname _sysctlbyname
#define ualarm _ualarm
#define uname _uname
#define unsetenv _unsetenv
-#define unvis _unvis
#define user_from_uid _user_from_uid
#define usleep _usleep
#define utime _utime
#define uuid_is_nil _uuid_is_nil
#define valloc _valloc
#define vdprintf _vdprintf
-#define vis _vis
#define vdprintf _vdprintf
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#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 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
-/* $NetBSD: reentrant.h,v 1.14 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: reentrant.h,v 1.15 2012/06/03 21:27:30 joerg Exp $ */
/*-
* Copyright (c) 1997, 1998, 2003 The NetBSD Foundation, Inc.
#define thr_getspecific(k)
#define thr_keydelete(k)
-#define thr_once(o, f)
+#if !defined(__minix)
+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;
+}
+#endif /* defined(__minix) */
#define thr_sigsetmask(f, n, o)
#define thr_self()
#define thr_errno()
-.\" $NetBSD: inet.3,v 1.1 2004/05/20 23:13:02 christos Exp $
+.\" $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.
.\"
.\" @(#)inet.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 30, 2003
+.Dd July 25, 2012
.Dt INET 3
.Os
.Sh NAME
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
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 ,
.Re
.Sh STANDARDS
The
-.Nm inet_ntop
+.Fn inet_ntop
and
-.Nm inet_pton
+.Fn inet_pton
functions conform to
.St -p1003.1-2001 .
Note that
-.Nm inet_pton
-does not accept 1-, 2-, or 3-part dotted addresses; all four parts
+.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
-.Nm inet_aton .
+.Fn inet_aton .
.Sh HISTORY
The
-.Nm inet_addr ,
-.Nm inet_network ,
-.Nm inet_makeaddr ,
-.Nm inet_lnaof
+.Fn inet_addr ,
+.Fn inet_network ,
+.Fn inet_makeaddr ,
+.Fn inet_lnaof
and
-.Nm inet_netof
+.Fn inet_netof
functions appeared in
.Bx 4.2 .
They were changed to use
-.Va in_addr_t
+.Vt in_addr_t
in place of
-.Va unsigned long
+.Vt unsigned long
in
.Nx 2.0 .
The
-.Nm inet_aton
+.Fn inet_aton
and
-.Nm inet_ntoa
+.Fn inet_ntoa
functions appeared in
.Bx 4.3 .
The
-.Nm inet_pton
+.Fn inet_pton
and
-.Nm inet_ntop
+.Fn inet_ntop
functions appeared in BIND 4.9.4 and thence
.Nx 1.3 ;
they were also in
.Fn inet_ntoa
resides in a static memory area.
.Pp
+The function
.Fn inet_addr
should return a
-.Fa "struct in_addr" .
+.Vt struct in_addr .
+.Pp
+The function
+.Fn inet_network
+does not support byte rearrangement for one, two, and three
+part addresses.
-/* $NetBSD: inet_cidr_ntop.c,v 1.7 2009/04/12 17:07:16 christos Exp $ */
+/* $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")
#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.7 2009/04/12 17:07:16 christos Exp $");
+__RCSID("$NetBSD: inet_cidr_ntop.c,v 1.8 2012/03/13 21:13:38 christos Exp $");
#endif
#endif
#include <arpa/nameser.h>
#include <arpa/inet.h>
+#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
}
size -= (size_t)(dst - t);
}
- return (dst - odst);
+ _DIAGASSERT(__type_fit(int, dst - odst));
+ return (int)(dst - odst);
}
/*%
-/* $NetBSD: inet_cidr_pton.c,v 1.6 2009/04/12 17:07:16 christos Exp $ */
+/* $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")
#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.6 2009/04/12 17:07:16 christos Exp $");
+__RCSID("$NetBSD: inet_cidr_pton.c,v 1.8 2012/03/20 17:08:13 matt Exp $");
#endif
#endif
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <stddef.h>
#include <stdlib.h>
#include "port_after.h"
__weak_alias(inet_cidr_pton,_inet_cidr_pton)
#endif
-static int inet_cidr_pton_ipv4 __P((const char *src, u_char *dst,
- int *bits, int ipv6));
-static int inet_cidr_pton_ipv6 __P((const char *src, u_char *dst,
- int *bits));
+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);
static int
inet_cidr_pton_ipv4(const char *src, u_char *dst, int *pbits, int ipv6) {
const u_char *odst = dst;
- int n, ch, tmp, bits;
+ int ch, bits;
+ ptrdiff_t n, tmp;
size_t size = 4;
/* Get the mantissa. */
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
- val |= (pch - xdigits);
+ val |= (int)(pch - xdigits);
if (val > 0xffff)
return (0);
saw_xdigit = 1;
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
- const int n = tp - colonp;
+ const ptrdiff_t n = tp - colonp;
int i;
if (tp == endp)
if (cp == NULL) /*%< syntax */
return (-2);
bits *= 10;
- bits += cp - digits;
+ bits += (int)(cp - digits);
if (bits == 0 && *src != '\0') /*%< no leading zeros */
return (-2);
if (bits > (ipv6 ? 128 : 32)) /*%< range error */
-.\" $NetBSD: inet_net.3,v 1.2 2008/04/30 13:10:50 martin Exp $
+.\" $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.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 8, 2001
+.Dd July 20, 2012
.Dt INET_NET 3
.Os
.Sh NAME
The
.Fn inet_net_ntop
function converts an Internet network number from network format (usually a
-.Ft struct in_addr
+.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
-is the number of bits in
+argument is the number of bits in
.Fa src
that are the network number.
-It returns NULL if a system error occurs (in which case,
+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
.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
-.Ft struct in_addr
+.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
+specified with /CIDR), or \-1 if a failure occurred
(in which case
.Va errno
-will have been set.
-It will be set to
-.Er ENOENT
-if the Internet network number was not valid).
+will have been set).
.Pp
The currently supported values for
.Fa af
.Dv AF_INET
and
.Dv AF_INET6 .
+The
.Fa size
-is the size of the result buffer
+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:
.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
+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
+.Tn Intel 386 , 486 ,
and
.Tn Pentium
processors) the bytes referred to above appear as
.Pp
When a three part number is specified, the last
part is interpreted as a 16-bit quantity and placed
-in the right-most two bytes of the Internet network number.
+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 right most three bytes of the Internet network number.
+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 .
All numbers supplied as
.Dq parts
in a
-.Ql \&.
+.Ql \&.
notation
may be decimal, octal, or hexadecimal, as specified
in the C language (i.e., a leading 0x or 0X implies
.\" .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
-.Nm inet_net_ntop
+.Fn inet_net_ntop
and
-.Nm inet_net_pton
+.Fn inet_net_pton
functions appeared in BIND 4.9.4 and thence
.Nx 1.3 .
Support for
#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.2 2009/02/07 07:25:22 lukem Exp $");
+__RCSID("$NetBSD: inet_net_ntop.c,v 1.3 2012/03/20 17:08:13 matt Exp $");
#endif
#endif
# define SPRINTF(x) sprintf x
#endif
-static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits,
- char *dst, size_t size));
-static char * inet_net_ntop_ipv6 __P((const u_char *src, int bits,
- char *dst, size_t size));
+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 *
* Paul Vixie (ISC), July 1996
*/
char *
-inet_net_ntop(af, src, bits, dst, size)
- int af;
- const void *src;
- int bits;
- char *dst;
- size_t size;
+inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
switch (af) {
case AF_INET:
* Paul Vixie (ISC), July 1996
*/
static char *
-inet_net_ntop_ipv4(src, bits, dst, size)
- const u_char *src;
- int bits;
- char *dst;
- size_t size;
+inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size)
{
char *odst = dst;
char *t;
*/
static char *
-inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
+inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size)
+{
u_int m;
int b;
size_t p;
#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.1 2004/05/20 23:13:02 christos Exp $");
+__RCSID("$NetBSD: inet_net_pton.c,v 1.4 2012/03/20 17:08:13 matt Exp $");
#endif
#endif
#include <arpa/inet.h>
#include <isc/assertions.h>
+#include <stddef.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
* Paul Vixie (ISC), June 1996
*/
static int
-inet_net_pton_ipv4( const char *src, u_char *dst, size_t size) {
+inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
+{
static const char xdigits[] = "0123456789abcdef";
static const char digits[] = "0123456789";
- int n, ch, tmp = 0, dirty, bits;
+ 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]))
n = strchr(digits, ch) - digits;
INSIST(n >= 0 && n <= 9);
bits *= 10;
- bits += n;
+ 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;
- if (bits > 32)
- goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits >= 8 && bits < ((dst - odst) * 8))
- bits = (dst - odst) * 8;
+ bits = (int)(dst - odst) * 8;
}
/* Extend network to cover the actual mask. */
while (bits > ((dst - odst) * 8)) {
}
static int
-getbits(const char *src, int *bitsp) {
+getbits(const char *src, int *bitsp)
+{
static const char digits[] = "0123456789";
int n;
int val;
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
- val += (pch - digits);
+ val += (int)(pch - digits);
if (val > 128) /* range */
return (0);
continue;
}
static int
-getv4(const char *src, u_char *dst, int *bitsp) {
+getv4(const char *src, u_char *dst, int *bitsp)
+{
static const char digits[] = "0123456789";
u_char *odst = dst;
int n;
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
- val += (pch - digits);
+ val += (int)(pch - digits);
if (val > 255) /* range */
return (0);
continue;
}
static int
-inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) {
+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;
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
- val |= (pch - xdigits);
+ val |= (int)(pch - xdigits);
if (++digits > 4)
goto enoent;
saw_xdigit = 1;
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
- const int n = tp - colonp;
+ const ptrdiff_t n = tp - colonp;
int i;
if (tp == endp)
* Paul Vixie (ISC), June 1996
*/
int
-inet_net_pton(int af, const char *src, void *dst, size_t size) {
+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));
-/* $NetBSD: inet_neta.c,v 1.1 2004/05/20 23:13:02 christos Exp $ */
+/* $NetBSD: inet_neta.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
#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.1 2004/05/20 23:13:02 christos Exp $");
+__RCSID("$NetBSD: inet_neta.c,v 1.3 2012/06/25 22:32:44 abs Exp $");
#endif
#endif
* Paul Vixie (ISC), July 1996
*/
char *
-inet_neta(src, dst, size)
- u_long src;
- char *dst;
- size_t size;
+inet_neta(u_long src, char *dst, size_t size)
{
char *odst = dst;
char *ep;
ep = dst + size;
if (ep <= dst)
goto emsgsize;
- while (src & 0xffffffff) {
- u_char b = (u_char)((src & 0xff000000) >> 24);
+ while (src & 0xffffffffUL) {
+ u_char b = (u_char)((src & 0xff000000UL) >> 24);
src <<= 8;
if (b || src) {
-/* $NetBSD: inet_ntoa.c,v 1.1 2004/05/20 23:13:02 christos Exp $ */
+/* $NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: inet_ntoa.c,v 1.1 2004/05/20 23:13:02 christos Exp $");
+__RCSID("$NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
static char ret[18];
strlcpy(ret, "[inet_ntoa error]", sizeof(ret));
- (void) inet_ntop(AF_INET, &in, ret, sizeof ret);
- return (ret);
+ (void) inet_ntop(AF_INET, &in, ret, (socklen_t)sizeof ret);
+ return ret;
}
-/* $NetBSD: inet_ntop.c,v 1.8 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.8 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Paul Vixie, 1996.
*/
const char *
-inet_ntop(af, src, dst, size)
- int af;
- const void *src;
- char *dst;
- socklen_t size;
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
_DIAGASSERT(src != NULL);
* Paul Vixie, 1996.
*/
static const char *
-inet_ntop4(src, dst, size)
- const u_char *src;
- char *dst;
- socklen_t size;
+inet_ntop4(const u_char *src, char *dst, socklen_t size)
{
char tmp[sizeof "255.255.255.255"];
int l;
* Paul Vixie, 1996.
*/
static const char *
-inet_ntop6(src, dst, size)
- const u_char *src;
- char *dst;
- socklen_t size;
+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
-/* $NetBSD: inet_pton.c,v 1.7 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.7 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
+#include <stddef.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
{
u_int32_t val;
u_int digit, base;
- int n;
+ ptrdiff_t n;
unsigned char c;
u_int parts[4];
- register u_int *pp = parts;
+ u_int *pp = parts;
_DIAGASSERT(src != NULL);
_DIAGASSERT(dst != NULL);
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
- val |= (pch - xdigits);
+ val |= (int)(pch - xdigits);
if (++seen_xdigits > 4)
return (0);
continue;
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
- const int n = tp - colonp;
+ const ptrdiff_t n = tp - colonp;
int i;
if (tp == endp)
-/* $NetBSD: assertions.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: assertions.c,v 1.7 2011/09/16 16:05:58 joerg Exp $ */
/*
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
#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.6 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: assertions.c,v 1.7 2011/09/16 16:05:58 joerg Exp $");
#endif
#endif
* Forward.
*/
-static void default_assertion_failed(const char *, int, assertion_type,
+__dead static void default_assertion_failed(const char *, int, assertion_type,
const char *, int);
/*
-/* $NetBSD: ev_timers.c,v 1.8 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.8 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $");
#endif
#endif
}
struct timespec
-evNowTime() {
+evNowTime(void)
+{
struct timeval now;
#ifdef CLOCK_REALTIME
struct timespec tsnow;
return (tsnow);
#endif
if (gettimeofday(&now, NULL) < 0)
- return (evConsTime(0L, 0L));
+ return (evConsTime((time_t)0, 0L));
return (evTimeSpec(now));
}
return (tsnow);
#endif
if (gettimeofday(&now, NULL) < 0)
- return (evConsTime(0L, 0L));
+ return (evConsTime((time_t)0, 0L));
return (evTimeSpec(now));
}
struct timeval tv;
tv.tv_sec = ts.tv_sec;
- tv.tv_usec = ts.tv_nsec / 1000;
+ tv.tv_usec = (suseconds_t)(ts.tv_nsec / 1000);
return (tv);
}
-/* $NetBSD: _wcstol.h,v 1.3 2005/11/29 03:11:59 christos Exp $ */
+/* $NetBSD: _wcstol.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
*/
__INT
-_FUNCNAME(nptr, endptr, base)
- const wchar_t *nptr;
- wchar_t **endptr;
- int base;
+_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s;
__INT acc, cutoff;
-/* $NetBSD: _wcstoul.h,v 1.3 2005/11/29 03:11:59 christos Exp $ */
+/* $NetBSD: _wcstoul.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1990, 1993
*/
__UINT
-_FUNCNAME(nptr, endptr, base)
- const wchar_t *nptr;
- wchar_t **endptr;
- int base;
+_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s;
__UINT acc, cutoff;
+++ /dev/null
-/* $NetBSD: aliasname.c,v 1.4 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.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: aliasname.c,v 1.4 2009/01/11 02:46:28 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "aliasname_local.h"
-
-__inline int __is_ws(char);
-
-__inline int __is_ws(char ch)
-{
-
- return (ch == ' ' || ch == '\t');
-}
-
-const char *
-__unaliasname(const char *dbname, const char *alias, void *buf, size_t bufsize)
-{
- FILE *fp = NULL;
- const char *result = NULL;
- size_t resultlen;
- size_t aliaslen;
- const char *p;
- size_t len;
-
- _DIAGASSERT(dbname != NULL);
- _DIAGASSERT(alias != NULL);
- _DIAGASSERT(buf != NULL);
-
- fp = fopen(dbname, "r");
- if (fp == NULL)
- goto quit;
-
- aliaslen = strlen(alias);
-
- while (/*CONSTCOND*/ 1) {
- p = fgetln(fp, &len);
- if (p == NULL)
- goto quit; /* eof or error */
-
- _DIAGASSERT(len != 0);
-
- /* ignore terminating NL */
- if (p[len - 1] == '\n')
- len--;
-
- /* ignore null line and comment */
- if (len == 0 || p[0] == '#')
- continue;
-
- if (aliaslen > len)
- continue;
-
- if (memcmp(alias, p, aliaslen))
- continue;
-
- p += aliaslen;
- len -= aliaslen;
-
- if (len == 0 || !__is_ws(*p))
- continue;
-
- /* entry was found here */
- break;
-
- /* NOTREACHED */
- }
-
- /* skip white spaces */
- do {
- p++;
- len--;
- } while (len != 0 && __is_ws(*p));
-
- if (len == 0)
- goto quit;
-
- /* count length of result */
- resultlen = 0;
- while (resultlen < len && !__is_ws(*p))
- resultlen++;
-
- /* check if space is enough */
- if (bufsize < resultlen + 1)
- goto quit;
-
- memcpy(buf, p, resultlen);
- ((char *)buf)[resultlen] = 0;
- result = buf;
-
-quit:
- if (fp)
- fclose(fp);
-
- return result;
-}
+++ /dev/null
-/* $NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 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 <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/endian.h>
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "bsdctype_local.h"
-#include "runetype_misc.h"
-
-const _BSDCTypeLocale _DefaultBSDCTypeLocale = {
- _C_ctype_,
- _C_tolower_,
- _C_toupper_
-};
-
-const _BSDCTypeLocale *_CurrentBSDCTypeLocale = &_DefaultBSDCTypeLocale;
-
-typedef struct {
- _BSDCTypeLocale bl;
- unsigned char blp_ctype_tab [_CTYPE_NUM_CHARS + 1];
- short blp_tolower_tab[_CTYPE_NUM_CHARS + 1];
- short blp_toupper_tab[_CTYPE_NUM_CHARS + 1];
-} _BSDCTypeLocalePriv;
-
-static __inline void
-_bsdctype_init_priv(_BSDCTypeLocalePriv *blp)
-{
-#if _CTYPE_CACHE_SIZE != _CTYPE_NUM_CHARS
- int i;
-
- for (i = _CTYPE_CACHE_SIZE; i < _CTYPE_NUM_CHARS; ++i) {
- blp->blp_ctype_tab [i + 1] = 0;
- blp->blp_tolower_tab[i + 1] = i;
- blp->blp_toupper_tab[i + 1] = i;
- }
-#endif
- blp->blp_ctype_tab [0] = 0;
- blp->blp_tolower_tab[0] = EOF;
- blp->blp_toupper_tab[0] = EOF;
- blp->bl.bl_ctype_tab = &blp->blp_ctype_tab [0];
- blp->bl.bl_tolower_tab = &blp->blp_tolower_tab[0];
- blp->bl.bl_toupper_tab = &blp->blp_toupper_tab[0];
-}
-
-static __inline int
-_bsdctype_read_file(const char * __restrict var, size_t lenvar,
- _BSDCTypeLocalePriv * __restrict blp)
-{
- const _FileBSDCTypeLocale *fbl;
- uint32_t value;
- int i;
-
- _DIAGASSERT(blp != NULL);
-
- if (lenvar < sizeof(*fbl))
- return EFTYPE;
- fbl = (const _FileBSDCTypeLocale *)(const void *)var;
- if (memcmp(&fbl->fbl_id[0], _CTYPE_ID, sizeof(fbl->fbl_id)))
- return EFTYPE;
- value = be32toh(fbl->fbl_rev);
- if (value != _CTYPE_REV)
- return EFTYPE;
- value = be32toh(fbl->fbl_num_chars);
- if (value != _CTYPE_CACHE_SIZE)
- return EFTYPE;
- for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
- blp->blp_ctype_tab [i + 1] = fbl->fbl_ctype_tab[i];
- blp->blp_tolower_tab[i + 1] = be16toh(fbl->fbl_tolower_tab[i]);
- blp->blp_toupper_tab[i + 1] = be16toh(fbl->fbl_toupper_tab[i]);
- }
- return 0;
-}
-
-static __inline int
-_bsdctype_read_runetype(const char * __restrict var, size_t lenvar,
- _BSDCTypeLocalePriv * __restrict blp)
-{
- const _FileRuneLocale *frl;
- int i;
-
- _DIAGASSERT(blp != NULL);
-
- 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;
- if (frl->frl_encoding[0] != 'N' || frl->frl_encoding[1] != 'O' ||
- frl->frl_encoding[2] != 'N' || frl->frl_encoding[3] != 'E' ||
- frl->frl_encoding[4] != '\0') /* XXX */
- return EFTYPE;
- if (be32toh(frl->frl_runetype_ext.frr_nranges) != 0 ||
- be32toh(frl->frl_maplower_ext.frr_nranges) != 0 ||
- be32toh(frl->frl_mapupper_ext.frr_nranges) != 0)
- return EFTYPE;
- if (lenvar < be32toh((uint32_t)frl->frl_variable_len))
- return EFTYPE;
- for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
- blp->blp_ctype_tab [i + 1] = (unsigned char)
- _runetype_to_ctype((_RuneType)
- be32toh(frl->frl_runetype[i]));
- blp->blp_tolower_tab[i + 1] = (short)
- be32toh((uint32_t)frl->frl_maplower[i]);
- blp->blp_toupper_tab[i + 1] = (short)
- be32toh((uint32_t)frl->frl_mapupper[i]);
- }
- return 0;
-}
-
-int
-_bsdctype_load(const char * __restrict var, size_t lenvar,
- _BSDCTypeLocale ** __restrict pbl)
-{
- int ret;
- _BSDCTypeLocalePriv *blp;
-
- _DIAGASSERT(var != NULL || lenvar < 1);
- _DIAGASSERT(pbl != NULL);
-
- if (lenvar < 1)
- return EFTYPE;
- blp = malloc(sizeof(*blp));
- if (blp == NULL)
- return errno;
- _bsdctype_init_priv(blp);
- switch (*var) {
- case 'B':
- _bsdctype_read_file(var, lenvar, blp);
- break;
- case 'R':
- _bsdctype_read_runetype(var, lenvar, blp);
- break;
- default:
- ret = EFTYPE;
- }
- if (ret)
- free(blp);
- else
- *pbl = &blp->bl;
- return ret;
-}
+++ /dev/null
-/* $NetBSD: bsdctype_local.h,v 1.2 2010/06/19 13:26:52 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 _BSDCTYPE_LOCAL_H_
-#define _BSDCTYPE_LOCAL_H_
-
-#include "bsdctype_file.h"
-
-typedef struct {
- const unsigned char *bl_ctype_tab;
- const short *bl_tolower_tab;
- const short *bl_toupper_tab;
-} _BSDCTypeLocale;
-
-extern const _BSDCTypeLocale _DefaultBSDCTypeLocale;
-extern const _BSDCTypeLocale *_CurrentBSDCTypeLocale;
-
-__BEGIN_DECLS
-int _bsdctype_load(const char * __restrict, size_t,
- _BSDCTypeLocale ** __restrict);
-__END_DECLS
-
-#endif /*_BSDCTYPE_LOCAL_H_*/
-/* $NetBSD: current_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: current_locale.c,v 1.3 2012/03/20 17:44:18 matt Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: current_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: current_locale.c,v 1.3 2012/03/20 17:44:18 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
static struct _locale_impl_t *__current_locale = &_global_locale;
struct _locale_impl_t **
-_current_locale()
+_current_locale(void)
{
return &__current_locale;
}
-/* $NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#define _CATEGORY_NAME "LC_COLLATE"
#include "dummy_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_dummy_LC_COLLATE_);
-/* $NetBSD: dummy_lc_template.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: dummy_lc_template.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include "generic_lc_template_decl.h"
-static const char *
+const char *
_PREFIX(setlocale)(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
return locale->part_name[(size_t)_CATEGORY_ID];
}
-#include "generic_lc_template.h"
-
#endif /*_DUMMY_LC_TEMPLATE_H_*/
-/* $NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $ */
+/* $NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $ */
/*
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $");
+__RCSID("$NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <limits.h>
#include "fix_grouping.h"
#ifndef NBCHAR_MAX
-#define NBCHAR_MAX CHAR_MAX
+#define NBCHAR_MAX (char)CHAR_MAX
#endif
#ifndef __UNCONST
-/* $NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $ */
+/* $NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $");
+__RCSID("$NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
_generic_LC_ALL_setlocale(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
- _locale_category_t *l;
+ _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;
- l = _find_category(1);
- _DIAGASSERT(l != NULL);
+ sl = _find_category(1);
+ _DIAGASSERT(sl != NULL);
load_locale_success = 0;
if (name != NULL) {
strlcpy(&head[0], name, sizeof(head));
if (tail != NULL)
return NULL;
}
- if ((*l->setlocale)(tokens[1], locale) != NULL)
+ if ((*sl)(tokens[1], locale) != NULL)
load_locale_success = 1;
}
- s = (*l->setlocale)(NULL, locale);
+ s = (*sl)(NULL, locale);
_DIAGASSERT(s != NULL);
strlcpy(&locale->query[0], s, sizeof(locale->query));
for (i = 2, j = 0; i < _LC_LAST; ++i) {
- l = _find_category(i);
- _DIAGASSERT(l != NULL);
+ sl = _find_category(i);
+ _DIAGASSERT(sl != NULL);
if (name != NULL) {
- if ((*l->setlocale)(tokens[i], locale) != NULL)
+ if ((*sl)(tokens[i], locale) != NULL)
load_locale_success = 1;
}
- t = (*l->setlocale)(NULL, locale);
+ t = (*sl)(NULL, locale);
_DIAGASSERT(t != NULL);
if (j == 0) {
if (!strcmp(s, t))
return (const char *)&locale->query[0];
}
-/*
- * macro requrired by generic_lc_template.h
- */
-#define _CATEGORY_ID LC_ALL
-
-#include "generic_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_generic_LC_ALL_);
+++ /dev/null
-/* $NetBSD: generic_lc_template.h,v 1.3 2009/03/09 02:22: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 _GENERIC_LC_TEMPLATE_H_
-#define _GENERIC_LC_TEMPLATE_H_
-
-#define _LOCALE_CATEGORY_ENTRY(name) \
-const _locale_category_t name##desc = { \
- .category = _CATEGORY_ID, \
- .setlocale = &name##setlocale, \
-}
-
-#endif /*_GENERIC_LC_TEMPLATE_H_*/
-/* $NetBSD: generic_lc_template_decl.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: generic_lc_template_decl.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#ifndef _GENERIC_LC_TEMPLATE_DECL_H_
#define _GENERIC_LC_TEMPLATE_DECL_H_
-static const char * _PREFIX(setlocale)(const char * __restrict,
+const char * _PREFIX(setlocale)(const char * __restrict,
struct _locale_impl_t * __restrict);
#endif /*_GENERIC_LC_TEMPLATE_DECL_H_*/
-/* $NetBSD: global_locale.c,v 1.11 2010/06/19 13:26:52 tnozaki Exp $ */
+/* $NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.11 2010/06/19 13:26:52 tnozaki Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdlib.h>
-#ifdef WITH_RUNE
-#include "runetype_local.h"
-#else
-#include "bsdctype_local.h"
-#endif
+#include "runetype_local.h"
#include "setlocale_local.h"
+#ifndef NBCHAR_MAX
+#define NBCHAR_MAX (char)CHAR_MAX
+#endif
+
static struct lconv _global_ldata = {
.decimal_point = __UNCONST("."),
.thousands_sep = __UNCONST(""),
.mon_grouping = __UNCONST(""),
.positive_sign = __UNCONST(""),
.negative_sign = __UNCONST(""),
- .int_frac_digits = CHAR_MAX,
- .frac_digits = CHAR_MAX,
- .p_cs_precedes = CHAR_MAX,
- .p_sep_by_space = CHAR_MAX,
- .n_cs_precedes = CHAR_MAX,
- .n_sep_by_space = CHAR_MAX,
- .p_sign_posn = CHAR_MAX,
- .n_sign_posn = CHAR_MAX,
- .int_p_cs_precedes = CHAR_MAX,
- .int_n_cs_precedes = CHAR_MAX,
- .int_p_sep_by_space = CHAR_MAX,
- .int_n_sep_by_space = CHAR_MAX,
- .int_p_sign_posn = CHAR_MAX,
- .int_n_sign_posn = CHAR_MAX,
+ .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,
};
static const char *_global_items[(size_t)ALT_DIGITS + 1] = {
[(size_t)LC_ALL ] = (_locale_part_t)NULL,
[(size_t)LC_COLLATE ] = (_locale_part_t)NULL,
[(size_t)LC_CTYPE ] = (_locale_part_t)
-#ifdef WITH_RUNE
__UNCONST(&_DefaultRuneLocale),
-#else
- __UNCONST(&_DefaultBSDCTypeLocale),
-#endif
[(size_t)LC_MONETARY] = (_locale_part_t)
__UNCONST(&_DefaultMonetaryLocale),
[(size_t)LC_NUMERIC ] = (_locale_part_t)
+++ /dev/null
-/* $NetBSD: iswctype_sb.c,v 1.11 2010/06/01 18:00:28 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 <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: iswctype_sb.c,v 1.11 2010/06/01 18:00:28 tnozaki Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-#include <assert.h>
-#define _CTYPE_NOINLINE
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#define _ISWCTYPE_FUNC(name) \
-int \
-isw##name(wint_t wc) \
-{ \
- int c; \
- \
- c = (wc == WEOF) ? EOF : (unsigned char)wc; \
- return is##name(c); \
-}
-_ISWCTYPE_FUNC(alnum)
-_ISWCTYPE_FUNC(alpha)
-_ISWCTYPE_FUNC(blank)
-_ISWCTYPE_FUNC(cntrl)
-_ISWCTYPE_FUNC(digit)
-_ISWCTYPE_FUNC(graph)
-_ISWCTYPE_FUNC(lower)
-_ISWCTYPE_FUNC(print)
-_ISWCTYPE_FUNC(punct)
-_ISWCTYPE_FUNC(space)
-_ISWCTYPE_FUNC(upper)
-_ISWCTYPE_FUNC(xdigit)
-
-#define _TOWCTRANS_FUNC(name) \
-wint_t \
-tow##name(wint_t wc) \
-{ \
- int c; \
- c = (wc == WEOF) ? EOF : (unsigned char)wc; \
- return to##name(c); \
-}
-_TOWCTRANS_FUNC(upper)
-_TOWCTRANS_FUNC(lower)
-
-struct _wctype_priv_t {
- const char *name;
- int (*iswctype)(wint_t);
-};
-
-static const struct _wctype_priv_t _wctype_decl[] = {
- { "alnum", &iswalnum },
- { "alpha", &iswalpha },
- { "blank", &iswblank },
- { "cntrl", &iswcntrl },
- { "digit", &iswdigit },
- { "graph", &iswgraph },
- { "lower", &iswlower },
- { "print", &iswprint },
- { "punct", &iswpunct },
- { "space", &iswspace },
- { "upper", &iswupper },
- { "xdigit", &iswxdigit },
-};
-static const size_t _wctype_decl_size =
- sizeof(_wctype_decl) / sizeof(struct _wctype_priv_t);
-
-wctype_t
-wctype(const char *charclass)
-{
- size_t i;
-
- for (i = 0; i < _wctype_decl_size; ++i) {
- if (!strcmp(charclass, _wctype_decl[i].name))
- return (wctype_t)__UNCONST(&_wctype_decl[i]);
- }
- return (wctype_t)NULL;
-}
-
-struct _wctrans_priv_t {
- const char *name;
- wint_t (*towctrans)(wint_t);
-};
-
-static const struct _wctrans_priv_t _wctrans_decl[] = {
- { "upper", &towupper },
- { "lower", &towlower },
-};
-static const size_t _wctrans_decl_size =
- sizeof(_wctrans_decl) / sizeof(struct _wctrans_priv_t);
-
-wctrans_t
-/*ARGSUSED*/
-wctrans(const char *charmap)
-{
- size_t i;
-
- for (i = 0; i < _wctrans_decl_size; ++i) {
- if (!strcmp(charmap, _wctrans_decl[i].name))
- return (wctrans_t)__UNCONST(&_wctrans_decl[i]);
- }
- return (wctrans_t)NULL;
-}
-
-int
-/*ARGSUSED*/
-iswctype(wint_t wc, wctype_t charclass)
-{
- const struct _wctype_priv_t *p;
-
- p = (const struct _wctype_priv_t *)(void *)charclass;
- if (p < &_wctype_decl[0] || p > &_wctype_decl[_wctype_decl_size - 1]) {
- errno = EINVAL;
- return 0;
- }
- return (*p->iswctype)(wc);
-}
-
-wint_t
-/*ARGSUSED*/
-towctrans(wint_t wc, wctrans_t charmap)
-{
- const struct _wctrans_priv_t *p;
-
- p = (const struct _wctrans_priv_t *)(void *)charmap;
- if (p < &_wctrans_decl[0] || p > &_wctrans_decl[_wctrans_decl_size - 1]) {
- errno = EINVAL;
- return wc;
- }
- return (*p->towctrans)(wc);
-}
-
-__weak_alias(wcwidth,_wcwidth)
-
-int
-wcwidth(wchar_t wc)
-{
- int c;
-
- switch (wc) {
- case L'\0':
- return 0;
- case WEOF:
- c = EOF;
- break;
- default:
- c = (unsigned char)wc;
- }
- if (isprint(c))
- return 1;
- return -1;
-}
-
-int
-wcswidth(const wchar_t * __restrict ws, size_t wn)
-{
- const wchar_t *pws;
- int c;
-
- pws = ws;
- while (wn > 0 && *ws != L'\0') {
- c = (*ws == WEOF) ? EOF : (unsigned char)*ws;
- if (!isprint(c))
- return -1;
- ++ws, --wn;
- }
- return (int)(ws - pws);
-}
-/* $NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $ */
+/* $NetBSD: localeconv.c,v 1.19 2012/06/24 15:26:03 christos Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $");
+__RCSID("$NetBSD: localeconv.c,v 1.19 2012/06/24 15:26:03 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include "setlocale_local.h"
struct lconv *
-localeconv()
+localeconv(void)
{
return _current_cache()->ldata;
}
+++ /dev/null
-/* $NetBSD: localeio.c,v 1.5 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.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio.c,v 1.5 2010/06/19 13:26:52 tnozaki Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <locale.h>
-#include <paths.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "localeio.h"
-
-int
-_localeio_map_file(const char * __restrict path,
- void ** __restrict pvar, size_t * __restrict plenvar)
-{
- int fd, ret;
- struct stat st;
- void *var;
- size_t lenvar;
-
- _DIAGASSERT(path != NULL);
- _DIAGASSERT(pvar != NULL);
- _DIAGASSERT(plenvar != NULL);
-
- fd = open(path, O_RDONLY);
- if (fd == -1)
- return errno;
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || fstat(fd, &st) == 1) {
- ret = errno;
- goto error;
- }
- if (!S_ISREG(st.st_mode)) {
- ret = EBADF;
- goto error;
- }
- lenvar = (size_t)st.st_size;
- if (lenvar < 1) {
- ret = EFTYPE;
- goto error;
- }
- var = mmap(NULL, lenvar, PROT_READ,
- MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
- if (var == MAP_FAILED) {
- ret = errno;
- goto error;
- }
- *pvar = var;
- *plenvar = lenvar;
- return 0;
-error:
- return ret;
-}
-
-void
-_localeio_unmap_file(void *var, size_t lenvar)
-{
- munmap(var, lenvar);
-}
-
-int
-__loadlocale(const char *name, size_t nstr, size_t nbytes,
- size_t localesize, void *currentlocale)
-{
- int fd, ret;
- unsigned char **ap, *buf, *bp, *cp, *cbp, *ebp;
- unsigned char ***locale;
- struct stat st;
- size_t i, bufsize;
-
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(localesize != 0);
- _DIAGASSERT(currentlocale != NULL);
-
- if ((fd = open(name, O_RDONLY)) == -1)
- return ENOENT;
-
- if ((fstat(fd, &st) == -1) || !S_ISREG(st.st_mode) ||
- (st.st_size <= 0)) {
- ret = EFTYPE;
- goto error1;
- }
-
- bufsize = localesize + (size_t)st.st_size;
- if ((buf = malloc(bufsize)) == NULL) {
- ret = ENOMEM;
- goto error1;
- }
-
- bp = buf + localesize;
- if (read(fd, bp, (size_t)st.st_size) != st.st_size) {
- ret = EFTYPE;
- goto error2;
- }
-
- ap = (unsigned char **)(void *)buf;
- for (i = (size_t)0, ebp = buf + bufsize; i < nstr; i++) {
- ap[i] = bp;
- while (bp != ebp && *bp != '\n')
- bp++;
- if (bp == ebp) {
- ret = EFTYPE;
- goto error2;
- }
- *bp++ = '\0';
- }
-
- cp = buf + (sizeof(unsigned char *) * nstr);
- for (i = 0, cbp = bp; i < nbytes; i++) {
- int n;
-
- while (bp != ebp && *bp != '\n')
- bp++;
- if (bp == ebp) {
- ret = EFTYPE;
- goto error2;
- }
- /* ignore overflow/underflow and bad characters */
- n = (unsigned char)strtol((char *)cbp, NULL, 0);
- cp[i] = (unsigned char)(n & CHAR_MAX);
- cbp = bp;
- }
-
- locale = currentlocale;
-
- *locale = (unsigned char **)(void *)buf;
- (void)close(fd);
- return 0;
-
-error2:
- free(buf);
-
-error1:
- (void)close(fd);
- return ret;
-}
+++ /dev/null
-/* $NetBSD: localeio_lc_ctype.c,v 1.6 2010/06/19 13:26:52 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 <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio_lc_ctype.c,v 1.6 2010/06/19 13:26:52 tnozaki Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "reentrant.h"
-#include <sys/types.h>
-#include <sys/ctype_bits.h>
-#include <sys/queue.h>
-#include <assert.h>
-#include <errno.h>
-#include <langinfo.h>
-#include <limits.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "bsdctype_local.h"
-#include "aliasname_local.h"
-#include "localeio.h"
-
-#include "setlocale_local.h"
-
-/*
- * macro required by all template headers
- */
-#define _PREFIX(name) __CONCAT(_localeio_LC_CTYPE_, name)
-
-/*
- * macro required by nb_lc_template(_decl).h
- */
-#define _CATEGORY_TYPE _BSDCTypeLocale
-
-#include "nb_lc_template_decl.h"
-
-static int
-/*ARGSUSED*/
-_localeio_LC_CTYPE_create_impl(const char * __restrict root,
- const char * __restrict name, _BSDCTypeLocale ** __restrict pdata)
-{
- char path[PATH_MAX + 1];
- void *var;
- size_t lenvar;
- int ret;
-
- _DIAGASSERT(root != NULL);
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(pdata != NULL);
-
- snprintf(path, sizeof(path),
- "%s/%s/LC_CTYPE", root, name);
- ret = _localeio_map_file(path, &var, &lenvar);
- if (!ret) {
- ret = _bsdctype_load((const char *)var, lenvar, pdata);
- _localeio_unmap_file(var, lenvar);
- }
- return ret;
-}
-
-static __inline void
-_PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
- _BSDCTypeLocale * __restrict data)
-{
- _DIAGASSERT(cache != NULL);
- _DIAGASSERT(data != NULL);
-
- cache->ctype_tab = data->bl_ctype_tab;
- cache->tolower_tab = data->bl_tolower_tab;
- cache->toupper_tab = data->bl_toupper_tab;
- cache->mb_cur_max = (size_t)1;
-}
-
-static __inline void
-_PREFIX(fixup)(_BSDCTypeLocale *data)
-{
- _DIAGASSERT(data != NULL);
-
- _ctype_ = data->bl_ctype_tab;
- _tolower_tab_ = data->bl_tolower_tab;
- _toupper_tab_ = data->bl_toupper_tab;
-}
-
-/*
- * macro required by nb_lc_template.h
- */
-#define _CATEGORY_ID LC_CTYPE
-#define _CATEGORY_NAME "LC_CTYPE"
-#define _CATEGORY_DEFAULT _DefaultBSDCTypeLocale
-
-#include "nb_lc_template.h"
-#include "generic_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_localeio_LC_CTYPE_);
+++ /dev/null
-/* $NetBSD: localeio_lc_monetary.c,v 1.2 2009/01/11 02:46:28 christos 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.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeio_lc_monetary.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "reentrant.h"
-#include <sys/types.h>
-#include <sys/localedef.h>
-#include <sys/queue.h>
-#include <assert.h>
-#include <errno.h>
-#include <langinfo.h>
-#include <limits.h>
-#define __SETLOCALE_SOURCE__
-#include <locale.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "setlocale_local.h"
-
-#include "aliasname_local.h"
-#include "fix_grouping.h"
-#include "localeio.h"
-
-/*
- * macro required by all template headers
- */
-#define _PREFIX(name) __CONCAT(_localeio_LC_MONETARY_, name)
-
-#include "nb_lc_monetary_misc.h"
-#include "nb_lc_template_decl.h"
-
-#define NSTRINGS \
- (offsetof(_MonetaryLocale, int_frac_digits)/sizeof(const char **))
-#define NCHARS \
- (offsetof(_MonetaryLocale, int_n_sign_posn) - \
- offsetof(_MonetaryLocale, int_frac_digits) + 1)
-
-static int
-_localeio_LC_MONETARY_create_impl(const char * __restrict root,
- const char * __restrict name, _MonetaryLocale ** __restrict pdata)
-{
- char path[PATH_MAX + 1];
- int ret;
-
- _DIAGASSERT(root != NULL);
- _DIAGASSERT(name != NULL);
- _DIAGASSERT(pdata != NULL);
-
- snprintf(path, sizeof(path),
- "%s/%s/LC_MONETARY", root, name);
- ret = __loadlocale(path, NSTRINGS, NCHARS, sizeof(_MonetaryLocale),
- (void *)pdata);
- if (!ret) {
- (*pdata)->mon_grouping =
- __fix_locale_grouping_str((*pdata)->mon_grouping);
- }
- return ret;
-}
-
-#include "nb_lc_template.h"
-_LOCALE_CATEGORY_ENTRY(_localeio_LC_MONETARY_);
-.\" $NetBSD: mbstowcs.3,v 1.11 2010/12/16 17:42:27 wiz Exp $
+.\" $NetBSD: mbstowcs.3,v 1.12 2011/03/16 09:32:12 mbalmer Exp $
.\"
.\" Copyright (c)2002 Citrus Project,
.\" All rights reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 3, 2002
+.Dd March 16, 2011
.Dt MBSTOWCS 3
.Os
.\" ----------------------------------------------------------------------
.\" ----------------------------------------------------------------------
.Sh SEE ALSO
.Xr mbtowc 3 ,
-.Xr setlocale 3
+.Xr setlocale 3 ,
+.Xr wcstombs 3
.\" ----------------------------------------------------------------------
.Sh STANDARDS
The
+++ /dev/null
-/* $NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $ */
-
-/*
- * Copyright (c) 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.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char *sccsid = "from: @(#)multibyte.c 5.1 (Berkeley) 2/18/91";
-#else
-__RCSID("$NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <wchar.h>
-
-/*
- * Stub multibyte character functions.
- * This cheezy implementation is fixed to the native single-byte
- * character set.
- */
-
-/*ARGSUSED*/
-int
-mbsinit(ps)
- const mbstate_t *ps;
-{
-
- return 1;
-}
-
-/*ARGSUSED*/
-size_t
-mbrlen(s, n, ps)
- const char *s;
- size_t n;
- mbstate_t *ps;
-{
-
- /* ps appears to be unused */
-
- if (s == NULL || *s == '\0')
- return 0;
- if (n == 0)
- return (size_t)-1;
- return 1;
-}
-
-int
-mblen(s, n)
- const char *s;
- size_t n;
-{
-
- /* s may be NULL */
-
- return mbrlen(s, n, NULL);
-}
-
-/*ARGSUSED*/
-size_t
-mbrtowc(pwc, s, n, ps)
- wchar_t *pwc;
- const char *s;
- size_t n;
- mbstate_t *ps;
-{
-
- /* pwc may be NULL */
- /* s may be NULL */
- /* ps appears to be unused */
-
- if (s == NULL)
- return 0;
- if (n == 0)
- return (size_t)-1;
- if (pwc)
- *pwc = (wchar_t) *s;
- return (*s != '\0');
-}
-
-int
-mbtowc(pwc, s, n)
- wchar_t *pwc;
- const char *s;
- size_t n;
-{
-
- /* pwc may be NULL */
- /* s may be NULL */
-
- return mbrtowc(pwc, s, n, NULL);
-}
-
-/*ARGSUSED*/
-size_t
-wcrtomb(s, wchar, ps)
- char *s;
- wchar_t wchar;
- mbstate_t *ps;
-{
-
- /* s may be NULL */
- /* ps appears to be unused */
-
- if (s == NULL)
- return 0;
-
- *s = (char) wchar;
- return 1;
-}
-
-int
-wctomb(s, wchar)
- char *s;
- wchar_t wchar;
-{
-
- /* s may be NULL */
-
- return wcrtomb(s, wchar, NULL);
-}
-
-/*ARGSUSED*/
-size_t
-mbsrtowcs(pwcs, s, n, ps)
- wchar_t *pwcs;
- const char **s;
- size_t n;
- mbstate_t *ps;
-{
- int count = 0;
-
- /* pwcs may be NULL */
- /* s may be NULL */
- /* ps appears to be unused */
-
- if (!s || !*s)
- return 0;
-
- if (n != 0) {
- if (pwcs != NULL) {
- do {
- if ((*pwcs++ = (wchar_t) *(*s)++) == 0)
- break;
- count++;
- } while (--n != 0);
- } else {
- do {
- if (((wchar_t)*(*s)++) == 0)
- break;
- count++;
- } while (--n != 0);
- }
- }
-
- return count;
-}
-
-size_t
-mbstowcs(pwcs, s, n)
- wchar_t *pwcs;
- const char *s;
- size_t n;
-{
-
- /* pwcs may be NULL */
- /* s may be NULL */
-
- return mbsrtowcs(pwcs, &s, n, NULL);
-}
-
-/*ARGSUSED*/
-size_t
-wcsrtombs(s, pwcs, n, ps)
- char *s;
- const wchar_t **pwcs;
- size_t n;
- mbstate_t *ps;
-{
- int count = 0;
-
- /* s may be NULL */
- /* pwcs may be NULL */
- /* ps appears to be unused */
-
- if (pwcs == NULL || *pwcs == NULL)
- return (0);
-
- if (s == NULL) {
- while (*(*pwcs)++ != 0)
- count++;
- return(count);
- }
-
- if (n != 0) {
- do {
- if ((*s++ = (char) *(*pwcs)++) == 0)
- break;
- count++;
- } while (--n != 0);
- }
-
- return count;
-}
-
-size_t
-wcstombs(s, pwcs, n)
- char *s;
- const wchar_t *pwcs;
- size_t n;
-{
-
- /* s may be NULL */
- /* pwcs may be NULL */
-
- return wcsrtombs(s, &pwcs, n, NULL);
-}
-
-wint_t
-btowc(c)
- int c;
-{
- if (c == EOF || c & ~0xFF)
- return WEOF;
- return (wint_t)c;
-}
-
-int
-wctob(c)
- wint_t c;
-{
- if (c == WEOF || c & ~0xFF)
- return EOF;
- return (int)c;
-}
-/* $NetBSD: nb_lc_template.h,v 1.3 2010/05/22 13:15:59 tnozaki Exp $ */
+/* $NetBSD: nb_lc_template.h,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)1999, 2008 Citrus Project,
return ret;
}
-static const char *
+const char *
_PREFIX(setlocale)(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
return locale->part_name[(size_t)_CATEGORY_ID];
}
-#include "generic_lc_template.h"
-
#endif /*_NB_LC_TEMPLATE_H_*/
-.\" $NetBSD: nl_langinfo.3,v 1.19 2010/03/22 19:30:54 joerg Exp $
+.\" $NetBSD: nl_langinfo.3,v 1.20 2011/04/14 05:50:49 jruoho Exp $
.\"
.\" Written by J.T. Conklin <jtc@NetBSD.org>.
.\" Public domain.
.\"
-.Dd February 12, 2003
+.Dd April 14, 2011
.Dt NL_LANGINFO 3
.Os
.Sh NAME
.\" .Ed
.Sh SEE ALSO
.Xr setlocale 3 ,
+.Xr tm 3 ,
.Xr nls 7
.Sh STANDARDS
The
-/* $NetBSD: rune.c,v 1.41 2010/11/30 15:25:05 tnozaki Exp $ */
-
+/* $NetBSD: rune.c,v 1.45 2012/08/08 20:16:50 wiz Exp $ */
/*-
* Copyright (c)2010 Citrus Project,
* All rights reserved.
#include "citrus_ctype.h"
#include "runetype_local.h"
-#include "bsdctype_local.h"
#include "multibyte.h"
variable_len = be32toh((uint32_t)frl->frl_variable_len);
- n = (len * sizeof(*fre)) + variable_len;
+ n = len * sizeof(*fre);
if (lenvar < n)
return EFTYPE;
lenvar -= n;
READ_RANGE(maplower);
READ_RANGE(mapupper);
- memcpy((void *)rune, (void const *)frune, variable_len);
- rl->rl_variable_len = variable_len;
- rl->rl_variable = (void *)rune;
-
- if (lenvar > 0) {
+ 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);
return ret;
}
-static __inline int
-_rune_read_bsdctype(const char * __restrict var, size_t lenvar,
- _RuneLocale ** __restrict prl)
-{
- const _FileBSDCTypeLocale *fbl;
- uint32_t value;
- int i, bits;
- uint16_t lower, upper;
- _RuneLocalePriv *rlp;
- _RuneLocale *rl;
-
- if (lenvar < sizeof(*fbl))
- return EFTYPE;
- fbl = (const _FileBSDCTypeLocale *)(const void *)var;
- if (memcmp(&fbl->fbl_id[0], _CTYPE_ID, sizeof(fbl->fbl_id)))
- return EFTYPE;
- value = be32toh(fbl->fbl_rev);
- if (value != _CTYPE_REV)
- return EFTYPE;
- value = be32toh(fbl->fbl_num_chars);
- if (value != _CTYPE_CACHE_SIZE)
- return EFTYPE;
- rlp = (_RuneLocalePriv *)malloc(sizeof(*rlp));
- if (rlp == NULL)
- return ENOMEM;
- _rune_init_priv(rlp);
- rlp->rlp_codeset[0] = '\0';
-
- rl = &rlp->rl;
- for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
- bits = fbl->fbl_ctype_tab[i];
- lower = be16toh(fbl->fbl_tolower_tab[i]);
- upper = be16toh(fbl->fbl_toupper_tab[i]);
-
- rlp->rlp_ctype_tab [i + 1] = (unsigned char)bits;
- rlp->rlp_tolower_tab[i + 1] = (short)lower;
- rlp->rlp_toupper_tab[i + 1] = (short)upper;
-
- rl->rl_runetype[i] = _runetype_from_ctype(bits, i);
- rl->rl_maplower[i] = (__nbrune_t)lower;
- rl->rl_mapupper[i] = (__nbrune_t)upper;
- }
- *prl = rl;
- return 0;
-}
-
int
_rune_load(const char * __restrict var, size_t lenvar,
_RuneLocale ** __restrict prl)
case 'R':
ret = _rune_read_file(var, lenvar, prl);
break;
- case 'B':
- ret = _rune_read_bsdctype(var, lenvar, prl);
- break;
default:
ret = EFTYPE;
}
-/* $NetBSD: runetype_misc.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
+/* $NetBSD: runetype_misc.h,v 1.3 2012/01/18 14:22:27 joerg Exp $ */
/*-
* Copyright (c) 1993
return ret;
}
-static __inline _RuneType
-_runetype_from_ctype(int bits, int ch)
-{
- _RuneType ret;
-
- /*
- * TWEAKS!
- * - old locale file declarations do not have proper _B
- * in many cases.
- * - isprint() declaration in ctype.h incorrectly uses _B.
- * _B means "isprint but !isgraph", not "isblank" with the
- * declaration.
- * - _X and _RUNETYPE_X have negligible difference in meaning.
- * - we don't set digit value, fearing that it would be
- * too much of hardcoding. we may need to revisit it.
- */
-
- ret = (_RuneType)0;
- if (bits & _CTYPE_U)
- ret |= _RUNETYPE_U;
- if (bits & _CTYPE_L)
- ret |= _RUNETYPE_L;
- if (bits & _CTYPE_N)
- ret |= _RUNETYPE_D;
- if (bits & _CTYPE_S)
- ret |= _RUNETYPE_S;
- if (bits & _CTYPE_P)
- ret |= _RUNETYPE_P;
- if (bits & _CTYPE_C)
- ret |= _RUNETYPE_C;
- /* derived flag bits, duplicate of ctype.h */
- if (bits & (_CTYPE_U|_CTYPE_L))
- ret |= _RUNETYPE_A;
- if (bits & (_CTYPE_N|_CTYPE_X))
- ret |= _RUNETYPE_X;
- if (bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N))
- ret |= _RUNETYPE_G;
- /* we don't really trust _B in the file. see above. */
- if (bits & _CTYPE_B)
- ret |= _RUNETYPE_B;
- if ((bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)) ||
- ch == ' ')
- ret |= (_RUNETYPE_R | _RUNETYPE_SW1);
- if (ch == ' ' || ch == '\t')
- ret |= _RUNETYPE_B;
- return ret;
-}
-
#endif /* !_RUNETYPE_MISC_H_ */
-/* $NetBSD: setlocale.c,v 1.58 2010/06/07 13:52:30 tnozaki Exp $ */
+/* $NetBSD: setlocale.c,v 1.60 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: setlocale.c,v 1.58 2010/06/07 13:52:30 tnozaki Exp $");
+__RCSID("$NetBSD: setlocale.c,v 1.60 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
const char *_PathLocale = NULL;
-__link_set_decl(all_categories, _locale_category_t);
-
-extern const _locale_category_t _generic_LC_ALL_desc;
-extern const _locale_category_t _dummy_LC_COLLATE_desc;
-#ifdef WITH_RUNE
-extern const _locale_category_t _citrus_LC_CTYPE_desc;
-extern const _locale_category_t _citrus_LC_MONETARY_desc;
-extern const _locale_category_t _citrus_LC_NUMERIC_desc;
-extern const _locale_category_t _citrus_LC_TIME_desc;
-extern const _locale_category_t _citrus_LC_MESSAGES_desc;
-#else
-extern const _locale_category_t _localeio_LC_CTYPE_desc;
-extern const _locale_category_t _localeio_LC_MONETARY_desc;
-extern const _locale_category_t _localeio_LC_NUMERIC_desc;
-extern const _locale_category_t _localeio_LC_TIME_desc;
-extern const _locale_category_t _localeio_LC_MESSAGES_desc;
-#endif
-
-#ifdef __minix
-/* GNU binutils 2.x a.out support is rotten and link sets are not
- supported. Workaround this by explicitely creating the structure
- the linker was supposed to create. */
-
-struct {
- int __ls_length;
- _locale_category_t *__ls_items[7];
-} __link_set_all_categories = {
- .__ls_length = 7,
- .__ls_items = {
- [0] = __UNCONST(&_generic_LC_ALL_desc),
- [1] = __UNCONST(&_dummy_LC_COLLATE_desc),
-#ifdef WITH_RUNE
- [2] = __UNCONST(&_citrus_LC_CTYPE_desc),
- [3] = __UNCONST(&_citrus_LC_MONETARY_desc),
- [4] = __UNCONST(&_citrus_LC_NUMERIC_desc),
- [5] = __UNCONST(&_citrus_LC_TIME_desc),
- [6] = __UNCONST(&_citrus_LC_MESSAGES_desc),
-#else
- [2] = __UNCONST(&_localeio_LC_CTYPE_desc),
- [3] = __UNCONST(&_localeio_LC_MONETARY_desc),
- [4] = __UNCONST(&_localeio_LC_NUMERIC_desc),
- [5] = __UNCONST(&_localeio_LC_TIME_desc),
- [6] = __UNCONST(&_localeio_LC_MESSAGES_desc),
-#endif
- },
+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,
};
-#endif /* __minix */
-
-
-__link_set_add_data(all_categories, _generic_LC_ALL_desc);
-__link_set_add_data(all_categories, _dummy_LC_COLLATE_desc);
-#ifdef WITH_RUNE
-__link_set_add_data(all_categories, _citrus_LC_CTYPE_desc);
-__link_set_add_data(all_categories, _citrus_LC_MONETARY_desc);
-__link_set_add_data(all_categories, _citrus_LC_NUMERIC_desc);
-__link_set_add_data(all_categories, _citrus_LC_TIME_desc);
-__link_set_add_data(all_categories, _citrus_LC_MESSAGES_desc);
-#else
-__link_set_add_data(all_categories, _localeio_LC_CTYPE_desc);
-__link_set_add_data(all_categories, _localeio_LC_MONETARY_desc);
-__link_set_add_data(all_categories, _localeio_LC_NUMERIC_desc);
-__link_set_add_data(all_categories, _localeio_LC_TIME_desc);
-__link_set_add_data(all_categories, _localeio_LC_MESSAGES_desc);
-#endif
-
-_locale_category_t *
+_locale_set_t
_find_category(int category)
{
- _locale_category_t * const *p;
-
- __link_set_foreach(p, all_categories) {
- if ((*p)->category == category)
- return *p;
- }
+ if (category >= LC_ALL && category < _LC_LAST)
+ return all_categories[category];
return NULL;
}
char *
__setlocale(int category, const char *name)
{
- _locale_category_t *l;
+ _locale_set_t sl;
struct _locale_impl_t *impl;
- if (category >= LC_ALL && category < _LC_LAST) {
- l = _find_category(category);
- if (l != NULL) {
- if (issetugid() || ((_PathLocale == NULL &&
- (_PathLocale = getenv("PATH_LOCALE")) == NULL) ||
- *_PathLocale == '\0'))
- _PathLocale = _PATH_LOCALE;
- impl = *_current_locale();
- return __UNCONST((*l->setlocale)(name, impl));
- }
- }
- return NULL;
+ sl = _find_category(category);
+ if (sl == NULL)
+ return NULL;
+ if (issetugid() || ((_PathLocale == NULL &&
+ (_PathLocale = getenv("PATH_LOCALE")) == NULL) ||
+ *_PathLocale == '\0'))
+ _PathLocale = _PATH_LOCALE;
+ impl = *_current_locale();
+ return __UNCONST((*sl)(name, impl));
}
char *
-/* $NetBSD: setlocale_local.h,v 1.7 2010/06/07 13:52:30 tnozaki Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.8 2012/03/04 21:14:57 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
typedef const char *(*_locale_set_t)(const char * __restrict,
struct _locale_impl_t * __restrict);
-typedef struct {
- const char* name;
- int category;
- _locale_set_t setlocale;
-} _locale_category_t;
-
__BEGIN_DECLS
-_locale_category_t *_find_category(int);
+_locale_set_t _find_category(int);
const char *_get_locale_env(const char *);
struct _locale_impl_t **_current_locale(void);
char *__setlocale(int, const char *);
+
+const char *_generic_LC_ALL_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_dummy_LC_COLLATE_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_citrus_LC_CTYPE_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_citrus_LC_MONETARY_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_citrus_LC_NUMERIC_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_citrus_LC_TIME_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
+const char *_citrus_LC_MESSAGES_setlocale(
+ const char * __restrict, struct _locale_impl_t * __restrict);
__END_DECLS
static __inline struct _locale_cache_t *
-/* $NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $ */
+/* $NetBSD: wcscoll.c,v 1.2 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $");
+__RCSID("$NetBSD: wcscoll.c,v 1.2 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
* Compare strings with using collating information.
*/
int
-wcscoll(s1, s2)
- const wchar_t *s1, *s2;
+wcscoll(const wchar_t *s1, const wchar_t *s2)
{
/* XXX: LC_COLLATE should be implemented. */
return (wcscmp(s1, s2));
-.\" $NetBSD: wcsftime.3,v 1.2 2005/04/06 21:39:17 kleink Exp $
+.\" $NetBSD: wcsftime.3,v 1.3 2011/04/14 05:50:49 jruoho Exp $
.\"
.\" Copyright (c) 2002 Tim J. Robbins
.\" All rights reserved.
.\"
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/locale/wcsftime.3,v 1.2 2002/11/29 17:35:09 ru Exp $
.\"
-.Dd September 8, 2002
+.Dd April 14, 2011
.Dt WCSFTIME 3
.Os
.Sh NAME
instead of
.Vt "const wchar_t *" .
.Sh SEE ALSO
-.Xr strftime 3
+.Xr strftime 3 ,
+.Xr tm 3
.Sh STANDARDS
The
.Fn wcsftime
-.\" $NetBSD: wcstombs.3,v 1.12 2010/12/16 17:42:27 wiz Exp $
+.\" $NetBSD: wcstombs.3,v 1.13 2011/03/16 09:32:12 mbalmer Exp $
.\"
.\" Copyright (c)2002 Citrus Project,
.\" All rights reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 8, 2006
+.Dd March 16, 2011
.Dt WCSTOMBS 3
.Os
.\" ----------------------------------------------------------------------
.El
.\" ----------------------------------------------------------------------
.Sh SEE ALSO
+.Xr mbstowcs 3 ,
.Xr setlocale 3 ,
.Xr wctomb 3
.\" ----------------------------------------------------------------------
-/* $NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $ */
+/* $NetBSD: wcsxfrm.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $");
+__RCSID("$NetBSD: wcsxfrm.c,v 1.3 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
* Compare strings with using collating information.
*/
size_t
-wcsxfrm(s1, s2, n)
- wchar_t *s1;
- const wchar_t *s2;
- size_t n;
+wcsxfrm(wchar_t *s1, const wchar_t *s2, size_t n)
{
size_t len;
SRCS+= md4c.c md5c.c md4hl.c md5hl.c
-#MAN+= md4.3 md5.3
+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
+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
-/* $NetBSD: mdXhl.c,v 1.8 2009/03/06 18:15:24 apb Exp $ */
+/* $NetBSD: mdXhl.c,v 1.10 2012/06/25 22:32:44 abs Exp $ */
/*
* ----------------------------------------------------------------------------
char *
-MDNAME(End)(ctx, buf)
- MDNAME(_CTX) *ctx;
- char *buf;
+MDNAME(End)(MDNAME(_CTX) *ctx, char *buf)
{
int i;
unsigned char digest[16];
}
char *
-MDNAME(File)(filename, buf)
- const char *filename;
- char *buf;
+MDNAME(File)(const char *filename, char *buf)
{
unsigned char buffer[BUFSIZ];
MDNAME(_CTX) ctx;
- int f, i, j;
+ int f, j;
+ ssize_t i;
_DIAGASSERT(filename != 0);
/* buf may be NULL */
}
char *
-MDNAME(Data)(data, len, buf)
- const unsigned char *data;
- unsigned int len;
- char *buf;
+MDNAME(Data)(const unsigned char *data, unsigned int len, char *buf)
{
MDNAME(_CTX) ctx;
static u8_t *ptr_min, *ptr_max;
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-
static unsigned long page_round_down(unsigned long x)
{
return x - x % PAGE_SIZE;
-/* $NetBSD: initfini.c,v 1.7 2010/11/14 18:11:42 tron Exp $ */
+/* $NetBSD: initfini.c,v 1.10 2012/02/16 23:00:39 joerg Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: initfini.c,v 1.7 2010/11/14 18:11:42 tron Exp $");
+__RCSID("$NetBSD: initfini.c,v 1.10 2012/02/16 23:00:39 joerg Exp $");
#ifdef _LIBC
#include "namespace.h"
#endif
-void __libc_init(void) __attribute__((__constructor__, __used__));
+#include <sys/param.h>
+#include <sys/exec.h>
+#ifndef __minix
+#include <sys/tls.h>
+#endif
+#include <stdbool.h>
+
+void _libc_init(void) __attribute__((__constructor__, __used__));
void __guard_setup(void);
void __libc_thr_init(void);
void __libc_atexit_init(void);
void __libc_env_init(void);
-/* LINTED used */
+#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
-__libc_init(void)
+_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();
+#ifdef _REENTRANT
/* Atomic operations */
__libc_atomic_init();
+#endif
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ /* Initialize TLS for statically linked programs. */
+ __libc_static_tls_setup();
+#endif
#ifdef _REENTRANT
/* Threads */
-/* $NetBSD: stack_protector.c,v 1.5 2010/12/07 20:10:53 joerg Exp $ */
+/* $NetBSD: stack_protector.c,v 1.8 2012/03/13 21:13:39 christos Exp $ */
/* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */
/*
*
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: stack_protector.c,v 1.5 2010/12/07 20:10:53 joerg Exp $");
+__RCSID("$NetBSD: stack_protector.c,v 1.8 2012/03/13 21:13:39 christos Exp $");
#ifdef _LIBC
#include "namespace.h"
long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static void __fail(const char *) __attribute__((__noreturn__));
-void __stack_chk_fail_local(void);
+__dead void __stack_chk_fail_local(void);
void __guard_setup(void);
void
__guard_setup(void)
{
#ifndef __minix
- int mib[2];
+ static const int mib[2] = { CTL_KERN, KERN_ARND };
size_t len;
#endif
return;
#ifndef __minix
- mib[0] = CTL_KERN;
- mib[1] = KERN_ARND;
-
len = sizeof(__stack_chk_guard);
- if (__sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 ||
- 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
/* If sysctl was unsuccessful, use the "terminator canary". */
((unsigned char *)(void *)__stack_chk_guard)[0] = 0;
{
#ifdef _LIBC
struct syslog_data sdata = SYSLOG_DATA_INIT;
-#endif
struct sigaction sa;
+#endif
sigset_t mask;
/* Immediately block all signal handlers from running code */
xprintf("%s: %s\n", getprogname(), msg);
#endif
+#ifdef _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
_exit(127);
}
-/* $NetBSD: ns_name.c,v 1.8 2009/04/12 19:43:37 christos Exp $ */
+/* $NetBSD: ns_name.c,v 1.9 2012/03/13 21:13:39 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.8 2009/04/12 19:43:37 christos Exp $");
+__RCSID("$NetBSD: ns_name.c,v 1.9 2012/03/13 21:13:39 christos Exp $");
#endif
#endif
#include <netinet/in.h>
#include <arpa/nameser.h>
+#include <assert.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
+# define SPRINTF(x) ((int)strlen(sprintf/**/x))
#else
-# define SPRINTF(x) ((size_t)sprintf x)
+# define SPRINTF(x) (sprintf x)
#endif
#define NS_TYPE_ELT 0x40 /*%< EDNS0 extended label type */
return (-1);
}
*dn++ = '\0';
- return (dn - dst);
+ _DIAGASSERT(__type_fit(int, dn - dst));
+ return (int)(dn - dst);
}
/*%
continue;
}
else if ((cp = strchr(digits, c)) != NULL) {
- n = (cp - digits) * 100;
+ n = (int)(cp - digits) * 100;
if ((c = *src++) == 0 ||
(cp = strchr(digits, c)) == NULL) {
errno = EMSGSIZE;
return (-1);
}
- n += (cp - digits) * 10;
+ n += (int)(cp - digits) * 10;
if ((c = *src++) == 0 ||
(cp = strchr(digits, c)) == NULL) {
errno = EMSGSIZE;
return (-1);
}
- n += (cp - digits);
+ n += (int)(cp - digits);
if (n > 255) {
errno = EMSGSIZE;
return (-1);
escaped = 1;
continue;
} else if (c == '.') {
- c = (bp - label - 1);
+ c = (int)(bp - label - 1);
if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */
errno = EMSGSIZE;
return (-1);
}
*bp++ = (u_char)c;
}
- c = (bp - label - 1);
+ c = (int)(bp - label - 1);
if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */
errno = EMSGSIZE;
return (-1);
}
}
*dn++ = '\0';
- return (dn - dst);
+ _DIAGASSERT(__type_fit(int, dn - dst));
+ return (int)(dn - dst);
}
/*%
errno = EMSGSIZE;
return (-1);
}
- if (len < 0)
- len = srcp - src + 1;
+ if (len < 0) {
+ _DIAGASSERT(__type_fit(int, srcp - src + 1));
+ len = (int)(srcp - src + 1);
+ }
srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
if (srcp < msg || srcp >= eom) { /*%< Out of range. */
errno = EMSGSIZE;
*dstp++ = 0;
if (dstlen != NULL)
*dstlen = dstp - dst;
- if (len < 0)
- len = srcp - src;
- return (len);
+ if (len < 0) {
+ _DIAGASSERT(__type_fit(int, srcp - src));
+ len = (int)(srcp - src);
+ }
+ return len;
}
/*%
}
*dstp++ = ((u_int32_t)l >> 8) | NS_CMPRSFLGS;
*dstp++ = l % 256;
- return (dstp - dst);
+ _DIAGASSERT(__type_fit(int, dstp - dst));
+ return (int)(dstp - dst);
}
/* Not found, save it. */
if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
errno = EMSGSIZE;
return (-1);
}
- return (dstp - dst);
+ _DIAGASSERT(__type_fit(int, dstp - dst));
+ return (int)(dstp - dst);
}
/*%
mklower(*cp++))
goto next;
/* Is next root for both ? */
- if (*dn == '\0' && *cp == '\0')
- return (sp - msg);
+ if (*dn == '\0' && *cp == '\0') {
+ _DIAGASSERT(__type_fit(int,
+ sp - msg));
+ return (int)(sp - msg);
+ }
if (*dn)
continue;
goto next;
if ((blen = (*cp & 0xff)) == 0)
blen = 256;
plen = (blen + 3) / 4;
- plen += sizeof("\\[x/]") + (blen > 99 ? 3 : (blen > 9) ? 2 : 1);
+ plen += (int)sizeof("\\[x/]") + (blen > 99 ? 3 : (blen > 9) ? 2 : 1);
if (dn + plen >= eom)
return (-1);
dn += i;
*cpp = cp;
- return (dn - beg);
+ _DIAGASSERT(__type_fit(int, dn - beg));
+ return (int)(dn - beg);
}
static int
-/* $NetBSD: ns_netint.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: ns_netint.c,v 1.7 2012/03/13 21:13:39 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.6 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: ns_netint.c,v 1.7 2012/03/13 21:13:39 christos Exp $");
#endif
#endif
/* Public. */
-u_int16_t
+uint16_t
ns_get16(const u_char *src) {
- u_int dst;
+ uint16_t dst;
NS_GET16(dst, src);
- return (dst);
+ return dst;
}
-u_int32_t
+uint32_t
ns_get32(const u_char *src) {
- u_long dst;
+ u_int32_t dst;
NS_GET32(dst, src);
- return (dst);
+ return dst;
}
void
-ns_put16(u_int16_t src, u_char *dst) {
+ns_put16(uint16_t src, u_char *dst) {
NS_PUT16(src, dst);
}
void
-ns_put32(u_int32_t src, u_char *dst) {
+ns_put32(uint32_t src, u_char *dst) {
NS_PUT32(src, dst);
}
-/* $NetBSD: ns_parse.c,v 1.8 2009/04/12 19:43:37 christos Exp $ */
+/* $NetBSD: ns_parse.c,v 1.9 2012/03/13 21:13:39 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.8 2009/04/12 19:43:37 christos Exp $");
+__RCSID("$NetBSD: ns_parse.c,v 1.9 2012/03/13 21:13:39 christos Exp $");
#endif
#endif
#include <netinet/in.h>
#include <arpa/nameser.h>
+#include <assert.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
}
if (ptr > eom)
RETERR(EMSGSIZE);
- return (ptr - optr);
+ _DIAGASSERT(__type_fit(int, ptr - optr));
+ return (int)(ptr - optr);
}
int
-/* $NetBSD: ns_print.c,v 1.10 2009/04/12 19:43:37 christos Exp $ */
+/* $NetBSD: ns_print.c,v 1.11 2012/03/13 21:13:39 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.10 2009/04/12 19:43:37 christos Exp $");
+__RCSID("$NetBSD: ns_print.c,v 1.11 2012/03/13 21:13:39 christos Exp $");
#endif
#endif
#include <isc/assertions.h>
#include <isc/dst.h>
+#include <assert.h>
#include <errno.h>
#include <resolv.h>
+#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
+# define SPRINTF(x) ((int)strlen(sprintf/**/x))
#else
-# define SPRINTF(x) ((size_t)sprintf x)
+# define SPRINTF(x) (sprintf x)
#endif
/* Forward. */
if (name_ctx != NULL && ns_samename(name_ctx, name) == 1) {
T(addstr("\t\t\t", (size_t)3, &buf, &buflen));
} else {
- len = prune_origin(name, origin);
+ len = (int)prune_origin(name, origin);
if (*name == '\0') {
goto root;
} else if (len == 0) {
case ns_t_a:
if (rdlen != (size_t)NS_INADDRSZ)
goto formerr;
- (void) inet_ntop(AF_INET, rdata, buf, buflen);
+ (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
addlen(strlen(buf), &buf, &buflen);
break;
case ns_t_aaaa:
if (rdlen != (size_t)NS_IN6ADDRSZ)
goto formerr;
- (void) inet_ntop(AF_INET6, rdata, buf, buflen);
+ (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen);
addlen(strlen(buf), &buf, &buflen);
break;
goto formerr;
/* Address. */
- (void) inet_ntop(AF_INET, rdata, buf, buflen);
+ (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
addlen(strlen(buf), &buf, &buflen);
rdata += NS_INADDRSZ;
}
case ns_t_nxt: {
- int n, c;
+ ptrdiff_t n, c;
/* Next domain name. */
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
n = edata - rdata;
for (c = 0; c < n*8; c++)
if (NS_NXT_BIT_ISSET(c, rdata)) {
- len = SPRINTF((tmp, " %s", p_type(c)));
+ 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;
- unsigned int siz;
+ size_t siz;
char base64_cert[8192], tmp1[40];
const char *leader;
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, buflen);
+ (void) inet_ntop(AF_INET6, &a, buf, (socklen_t)buflen);
addlen(strlen(buf), &buf, &buflen);
rdata += sizeof(a) - pbyte;
}
char base64_dhcid[8192];
const char *leader;
- siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
+ 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));
T(addstr(".", 1, &buf, &buflen));
break;
case 1:
- (void) inet_ntop(AF_INET, rdata, buf, buflen);
+ (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, buflen);
+ (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen);
addlen(strlen(buf), &buf, &buflen);
rdata += 16;
break;
if (rdata >= edata)
break;
- siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
+ 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));
comment = "unknown RR type";
goto hexify;
}
- return (buf - obuf);
+ _DIAGASSERT(__type_fit(int, buf - obuf));
+ return (int)(buf - obuf);
formerr:
comment = "RR format error";
hexify: {
p = tmp;
p += SPRINTF((p, "\n\t"));
spaced = 0;
- n = MIN(16, edata - rdata);
+ 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));
T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen));
rdata += n;
}
- return (buf - obuf);
+ _DIAGASSERT(__type_fit(int, buf - obuf));
+ return (int)(buf - obuf);
}
}
}
if (addstr("\"", (size_t)1, buf, buflen) < 0)
goto enospc;
- return (rdata - odata);
+ _DIAGASSERT(__type_fit(int, rdata - odata));
+ return (int)(rdata - odata);
enospc:
errno = ENOSPC;
*buf = save_buf;
*pp += n;
addlen(newlen, buf, buflen);
**buf = '\0';
- return (newlen);
+ _DIAGASSERT(__type_fit(int, newlen));
+ return (int)newlen;
enospc:
errno = ENOSPC;
*buf = save_buf;
addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen) {
size_t save_buflen = *buflen;
char *save_buf = *buf;
- int t;
+ ptrdiff_t t;
if (spaced || len >= target - 1) {
T(addstr(" ", (size_t)2, buf, buflen));
-/* $NetBSD: ns_ttl.c,v 1.7 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: ns_ttl.c,v 1.8 2012/03/13 21:13:39 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.7 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: ns_ttl.c,v 1.8 2012/03/13 21:13:39 christos Exp $");
#endif
#endif
#include <arpa/nameser.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
int secs, mins, hours, days, weeks, x;
char *p;
- secs = src % 60; src /= 60;
- mins = src % 60; src /= 60;
- hours = src % 24; src /= 24;
- days = src % 7; src /= 7;
- weeks = src; src = 0;
+ 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) {
*p = tolower(ch);
}
- return (dst - odst);
+ _DIAGASSERT(__type_fit(int, dst - odst));
+ return (int)(dst - odst);
}
#ifndef _LIBC
.endif
.PATH: ${ARCHDIR}/net ${.CURDIR}/net
-.if defined(__MINIX)
# Not supported by minix: iso_addr.c link_addr.c sockatmark.c
-SRCS+= __cmsg_alignbytes.c 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 \
- nsdispatch.c nslexer.l nsparser.y nsap_addr.c \
- rcmd.c recv.c send.c sethostent.c
-.else
-SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \
+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
-.endif
+# sockatmark.c
.if (${MKHESIOD} != "no")
SRCS+= hesiod.c
-/* $NetBSD: base64.c,v 1.12 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: base64.c,v 1.14 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
#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.12 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: base64.c,v 1.14 2012/06/25 22:32:44 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if (datalength >= targsize)
return (-1);
target[datalength] = '\0'; /*%< Returned value doesn't count \\0. */
- return (datalength);
+ _DIAGASSERT(__type_fit(int, datalength));
+ return (int)datalength;
}
/* skips all whitespace anywhere.
*/
int
-b64_pton(src, target, targsize)
- char const *src;
- u_char *target;
- size_t targsize;
+b64_pton(char const *src, u_char *target, size_t targsize)
{
size_t tarindex;
int state, ch;
if (target) {
if ((size_t)tarindex >= targsize)
return (-1);
- target[tarindex] = (pos - Base64) << 2;
+ target[tarindex] =
+ (unsigned char)(pos - Base64) << 2;
}
state = 1;
break;
return (-1);
target[tarindex] |=
(u_int32_t)(pos - Base64) >> 4;
- target[tarindex+1] = ((pos - Base64) & 0x0f)
- << 4 ;
+ target[tarindex+1] =
+ (unsigned char)
+ (((pos - Base64) & 0x0f) << 4);
}
tarindex++;
state = 2;
return (-1);
target[tarindex] |=
(u_int32_t)(pos - Base64) >> 2;
- target[tarindex+1] = ((pos - Base64) & 0x03)
- << 6;
+ target[tarindex+1] =
+ (unsigned char)
+ (((pos - Base64) & 0x03) << 6);
}
tarindex++;
state = 3;
if (target) {
if ((size_t)tarindex >= targsize)
return (-1);
- target[tarindex] |= (pos - Base64);
+ target[tarindex] |=
+ (unsigned char)(pos - Base64);
}
tarindex++;
state = 0;
return (-1);
}
- return (tarindex);
+ _DIAGASSERT(__type_fit(int, tarindex));
+ return (int)tarindex;
}
/*! \file */
-.\" $NetBSD: byteorder.3,v 1.14 2006/02/04 22:47:28 uwe Exp $
+.\" $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.
.\"
.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 10, 2004
+.Dd May 3, 2011
.Dt BYTEORDER 3
.Os
.Sh NAME
and
.Xr getservent 3 .
.Sh SEE ALSO
+.Xr bswap 3 ,
.Xr gethostbyname 3 ,
.Xr getservent 3
.Sh STANDARDS
-The
-.Fn htonl ,
-.Fn htons ,
-.Fn ntohl ,
-and
-.Fn ntohs
-functions conform to
+The described functions conform to
.St -p1003.1-2001 .
-Their use of the fixed-width integer types
-.Fa uint16_t
-and
-.Fa uint32_t
-first appeared in
-.St -xns5 .
.Sh HISTORY
The
.Nm byteorder
-/* $NetBSD: ethers.c,v 1.21 2006/10/15 10:55:01 martin Exp $ */
+/* $NetBSD: ethers.c,v 1.23 2012/03/20 17:44:18 matt Exp $ */
/*
* ethers(3N) a la Sun.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ethers.c,v 1.21 2006/10/15 10:55:01 martin Exp $");
+__RCSID("$NetBSD: ethers.c,v 1.23 2012/03/20 17:44:18 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
char *
-ether_ntoa(e)
- const struct ether_addr *e;
+ether_ntoa(const struct ether_addr *e)
{
static char a[18];
}
struct ether_addr *
-ether_aton(s)
- const char *s;
+ether_aton(const char *s)
{
static struct ether_addr n;
u_int i[6];
}
int
-ether_ntohost(hostname, e)
- char *hostname;
- const struct ether_addr *e;
+ether_ntohost(char *hostname, const struct ether_addr *e)
{
FILE *f;
char *p;
}
int
-ether_hostton(hostname, e)
- const char *hostname;
- struct ether_addr *e;
+ether_hostton(const char *hostname, struct ether_addr *e)
{
FILE *f;
char *p;
size_t len;
char try[MAXHOSTNAMELEN + 1];
#ifdef YP
- int hostlen = strlen(hostname);
+ int hostlen = (int)strlen(hostname);
#endif
_DIAGASSERT(hostname != NULL);
}
int
-ether_line(l, e, hostname)
- const char *l;
- struct ether_addr *e;
- char *hostname;
+ether_line(const char *l, struct ether_addr *e, char *hostname)
{
u_int i[6];
-/* $NetBSD: getaddrinfo.c,v 1.95 2009/10/02 07:41:08 wiz Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.101 2012/06/08 07:54:14 martin Exp $ */
/* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */
/*
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.95 2009/10/02 07:41:08 wiz Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.101 2012/06/08 07:54:14 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ifaddrs.h>
#include <syslog.h>
#include <stdarg.h>
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
ep = NULL;
errno = 0;
v = strtoul(p, &ep, 10);
- if (errno == 0 && ep && *ep == '\0' && v <= UINT_MAX)
- return v;
+ if (errno == 0 && ep && *ep == '\0' && v <= INT_MAX)
+ return (int)v;
else
return -1;
}
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 */
}
}
+ 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
}
error = get_portmatch(pai, servname, &svd);
if (error)
- ERR(error);
+ goto bad;
*pai = ai0;
}
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;
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)
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;
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
h_errno = NO_RECOVERY;
return (NULL);
}
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
if ((n < 0) || !(*name_ok)(bp)) {
h_errno = NO_RECOVERY;
return (NULL);
* same as the one we sent; this just gets the expanded name
* (i.e., with the succeeding search-domain tacked on).
*/
- n = strlen(bp) + 1; /* for the \0 */
+ n = (int)strlen(bp) + 1; /* for the \0 */
if (n >= MAXHOSTNAMELEN) {
h_errno = NO_RECOVERY;
return (NULL);
haveanswer = 0;
had_error = 0;
while (ancount-- > 0 && cp < eom && !had_error) {
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
if ((n < 0) || !(*name_ok)(bp)) {
had_error++;
continue;
}
if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) &&
type == T_CNAME) {
- n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
+ 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 = strlen(tbuf) + 1; /* for the \0 */
+ n = (int)strlen(tbuf) + 1; /* for the \0 */
if (n > ep - bp || n >= MAXHOSTNAMELEN) {
had_error++;
continue;
int nn;
canonname = bp;
- nn = strlen(bp) + 1; /* for the \0 */
+ nn = (int)strlen(bp) + 1; /* for the \0 */
bp += nn;
}
{
if (!*hostf)
- *hostf = fopen(_PATH_HOSTS, "r" );
+ *hostf = fopen(_PATH_HOSTS, "re");
else
rewind(*hostf);
}
_DIAGASSERT(name != NULL);
_DIAGASSERT(pai != NULL);
- if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r" )))
+ if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
return (NULL);
again:
- if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))
+ if (!(p = fgets(hostbuf, (int)sizeof hostbuf, *hostf)))
return (NULL);
if (*p == '#')
goto again;
#endif
n = res_nmkquery(res, QUERY, name, class, type, NULL, 0, NULL,
- buf, sizeof(buf));
+ buf, (int)sizeof(buf));
#ifdef RES_USE_EDNS0
if (n > 0 && (res->options & RES_USE_EDNS0) != 0)
- n = res_nopt(res, n, buf, sizeof(buf), anslen);
+ n = res_nopt(res, n, buf, (int)sizeof(buf), anslen);
#endif
if (n <= 0) {
#ifdef DEBUG
-/* $NetBSD: gethnamaddr.c,v 1.76 2010/08/29 15:40:35 christos Exp $ */
+/* $NetBSD: gethnamaddr.c,v 1.79 2012/09/09 16:42:23 christos Exp $ */
/*
* ++Copyright++ 1985, 1988, 1993
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.76 2010/08/29 15:40:35 christos Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.79 2012/09/09 16:42:23 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__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 MAXALIASES 35
#define MAXADDRS 35
h_errno = NO_RECOVERY;
return NULL;
}
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
- if ((n < 0) || !(*name_ok)(bp)) {
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
+ if ((n < 0) || !maybe_ok(res, bp, name_ok)) {
h_errno = NO_RECOVERY;
return NULL;
}
* same as the one we sent; this just gets the expanded name
* (i.e., with the succeeding search-domain tacked on).
*/
- n = strlen(bp) + 1; /* for the \0 */
+ n = (int)strlen(bp) + 1; /* for the \0 */
if (n >= MAXHOSTNAMELEN) {
h_errno = NO_RECOVERY;
return NULL;
haveanswer = 0;
had_error = 0;
while (ancount-- > 0 && cp < eom && !had_error) {
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
- if ((n < 0) || !(*name_ok)(bp)) {
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
+ if ((n < 0) || !maybe_ok(res, bp, name_ok)) {
had_error++;
continue;
}
if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) {
if (ap >= &host_aliases[MAXALIASES-1])
continue;
- n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
- if ((n < 0) || !(*name_ok)(tbuf)) {
+ n = dn_expand(answer->buf, eom, cp, tbuf, (int)sizeof tbuf);
+ if ((n < 0) || !maybe_ok(res, tbuf, name_ok)) {
had_error++;
continue;
}
}
/* Store alias. */
*ap++ = bp;
- n = strlen(bp) + 1; /* for the \0 */
+ n = (int)strlen(bp) + 1; /* for the \0 */
if (n >= MAXHOSTNAMELEN) {
had_error++;
continue;
}
bp += n;
/* Get canonical name. */
- n = strlen(tbuf) + 1; /* for the \0 */
+ n = (int)strlen(tbuf) + 1; /* for the \0 */
if (n > ep - bp || n >= MAXHOSTNAMELEN) {
had_error++;
continue;
continue;
}
if (qtype == T_PTR && type == T_CNAME) {
- n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
- if (n < 0 || !res_dnok(tbuf)) {
+ n = dn_expand(answer->buf, eom, cp, tbuf, (int)sizeof tbuf);
+ if (n < 0 || !maybe_dnok(res, tbuf)) {
had_error++;
continue;
}
return NULL;
}
/* Get canonical name. */
- n = strlen(tbuf) + 1; /* for the \0 */
+ n = (int)strlen(tbuf) + 1; /* for the \0 */
if (n > ep - bp || n >= MAXHOSTNAMELEN) {
had_error++;
continue;
cp += n;
continue; /* XXX - had_error++ ? */
}
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
- if ((n < 0) || !res_hnok(bp)) {
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
+ if ((n < 0) || !maybe_hnok(res, bp)) {
had_error++;
break;
}
else
n = -1;
if (n != -1) {
- n = strlen(bp) + 1; /* for the \0 */
+ n = (int)strlen(bp) + 1; /* for the \0 */
if (n >= MAXHOSTNAMELEN) {
had_error++;
break;
int nn;
host.h_name = bp;
- nn = strlen(bp) + 1; /* for the \0 */
+ nn = (int)strlen(bp) + 1; /* for the \0 */
bp += nn;
}
if (res->nsort && haveanswer > 1 && qtype == T_A)
addrsort(h_addr_ptrs, haveanswer, res);
if (!host.h_name) {
- n = strlen(qname) + 1; /* for the \0 */
+ n = (int)strlen(qname) + 1; /* for the \0 */
if (n > ep - bp || n >= MAXHOSTNAMELEN)
goto no_recovery;
strlcpy(bp, qname, (size_t)(ep - bp));
_sethtent(int f)
{
if (!hostf)
- hostf = fopen(_PATH_HOSTS, "r" );
+ hostf = fopen(_PATH_HOSTS, "re");
else
rewind(hostf);
stayopen = f;
char *cp, **q;
int af, len;
- if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
+ if (!hostf && !(hostf = fopen(_PATH_HOSTS, "re"))) {
h_errno = NETDB_INTERNAL;
return NULL;
}
again:
- if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
+ if (!(p = fgets(hostbuf, (int)sizeof hostbuf, hostf))) {
h_errno = HOST_NOT_FOUND;
return NULL;
}
hp->h_addrtype = AF_INET6;
hp->h_length = IN6ADDRSZ;
for (ap = hp->h_addr_list; *ap; ap++) {
- int i = sizeof(align) - (size_t)((u_long)*bpp % sizeof(align));
+ int i = (int)(sizeof(align) -
+ (size_t)((u_long)*bpp % sizeof(align)));
if (ep - *bpp < (i + IN6ADDRSZ)) {
/* Out of memory. Truncate address list here. XXX */
free(buf);
return NS_NOTFOUND;
}
- n = res_nsearch(res, name, C_IN, type, buf->buf, sizeof(buf->buf));
+ 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);
free(buf);
return NS_NOTFOUND;
}
- n = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
+ 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);
* XXX unfortunately, we cannot support IPv6 extended scoped address
* notation here. gethostbyaddr() is not scope-aware. too bad.
*/
- if (inet_ntop(af, uaddr, name, sizeof(name)) == NULL)
+ if (inet_ntop(af, uaddr, name, (socklen_t)sizeof(name)) == NULL)
return NS_UNAVAIL;
if (__ypcurrent)
free(__ypcurrent);
+++ /dev/null
-/* $NetBSD: getifaddrs.c,v 1.13 2010/11/05 16:23:56 pooka 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 <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getifaddrs.c,v 1.13 2010/11/05 16:23:56 pooka Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef RUMP_ACTION
-#include "namespace.h"
-#endif
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <sys/param.h>
-#include <net/route.h>
-#include <sys/sysctl.h>
-#include <net/if_dl.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <ifaddrs.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(__weak_alias) && !defined(RUMP_ACTION)
-__weak_alias(getifaddrs,_getifaddrs)
-__weak_alias(freeifaddrs,_freeifaddrs)
-#endif
-
-#ifdef RUMP_ACTION
-#include <rump/rump_syscalls.h>
-#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f)
-#endif
-
-#define SALIGN (sizeof(long) - 1)
-#define SA_RLEN(sa) ((sa)->sa_len ? (((sa)->sa_len + SALIGN) & ~SALIGN) : (SALIGN + 1))
-
-int
-getifaddrs(struct ifaddrs **pif)
-{
- int icnt = 1;
- int dcnt = 0;
- int ncnt = 0;
- int mib[6];
- 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);
-
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0; /* protocol */
- mib[3] = 0; /* wildcard address family */
- mib[4] = NET_RT_IFLIST;
- mib[5] = 0; /* no flags */
- if (sysctl(mib, __arraycount(mib), NULL, &needed, NULL, 0) < 0)
- return (-1);
- if ((buf = malloc(needed)) == NULL)
- return (-1);
- if (sysctl(mib, __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);
-}
-.\" $NetBSD: getnameinfo.3,v 1.37 2010/03/22 19:30:54 joerg Exp $
+.\" $NetBSD: getnameinfo.3,v 1.39 2012/09/26 23:13:00 christos 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 $
.\"
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd March 21, 2005
+.Dd September 26, 2012
.Dt GETNAMEINFO 3
.Os
.Sh NAME
.In netdb.h
.Ft int
.Fn getnameinfo "const struct sockaddr * restrict sa" "socklen_t salen" \
- "char * restrict host" "size_t hostlen" "char * restrict serv" \
- "size_t servlen" "int flags"
+ "char * restrict host" "socklen_t hostlen" "char * restrict serv" \
+ "socklen_t servlen" "int flags"
.Sh DESCRIPTION
The
.Fn getnameinfo
.Li sockaddr
structure
.Fa sa
-should point to either a
+should point to a
.Li sockaddr_in
-or
+(for IPv4),
.Li sockaddr_in6
-structure (for IPv4 or IPv6 respectively) that is
+(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
-/* $NetBSD: getnameinfo.c,v 1.50 2010/06/29 14:44:19 seanb Exp $ */
+/* $NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $ */
/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
/*
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.50 2010/06/29 14:44:19 seanb Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <net/if.h>
#ifndef __minix
#include <net/if_dl.h>
u_short si_port;
};
-static int getnameinfo_inet __P((const struct sockaddr *, socklen_t, char *,
- socklen_t, char *, socklen_t, int));
+static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *,
+ socklen_t, char *, socklen_t, int);
#ifdef INET6
-static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
- socklen_t, int));
-static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t,
- int));
+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
#ifndef __minix
-static int getnameinfo_atalk __P((const struct sockaddr *, socklen_t, char *,
- socklen_t, char *, socklen_t, int));
-
-static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
- socklen_t, char *, socklen_t, int));
-static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
+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);
#endif /* __minix */
/*
* appropriate function to call.
*/
int
-getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- socklen_t salen;
- char *host, *serv;
- socklen_t hostlen, servlen;
- int flags;
+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_LINK:
return getnameinfo_link(sa, salen, host, hostlen,
serv, servlen, flags);
+ case AF_LOCAL:
+ return getnameinfo_local(sa, salen, host, hostlen,
+ serv, servlen, flags);
#endif /* !__minix */
default:
return EAI_FAMILY;
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;
+}
#endif /* !__minix */
/*
* Format an IPv4 or IPv6 sockaddr into a printable string.
*/
static int
-getnameinfo_inet(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- socklen_t salen;
- char *host;
- socklen_t hostlen;
- char *serv;
- socklen_t servlen;
- int flags;
+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;
u_short port;
int family, i;
const char *addr;
- u_int32_t v4a;
+ uint32_t v4a;
char numserv[512];
char numaddr[512];
switch (sa->sa_family) {
case AF_INET:
- v4a = (u_int32_t)
+ v4a = (uint32_t)
ntohl(((const struct sockaddr_in *)
(const void *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
}
#endif
default:
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
+ 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 */
#ifdef INET6
static int
-ip6_parsenumeric(sa, addr, host, hostlen, flags)
- const struct sockaddr *sa;
- const char *addr;
- char *host;
- socklen_t hostlen;
- int flags;
+ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host,
+ socklen_t hostlen, int flags)
{
size_t numaddrlen;
char numaddr[512];
_DIAGASSERT(addr != NULL);
_DIAGASSERT(host != NULL);
- if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
+ if (inet_ntop(AF_INET6, addr, numaddr, (socklen_t)sizeof(numaddr))
+ == NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
/* ARGSUSED */
static int
-ip6_sa2str(sa6, buf, bufsiz, flags)
- const struct sockaddr_in6 *sa6;
- char *buf;
- size_t bufsiz;
- int flags;
+ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
{
unsigned int ifindex;
const struct in6_addr *a6;
bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf);
if (p) {
- return(strlen(p));
+ return (int)strlen(p);
}
}
case IFT_HIPPI:
case IFT_ISO88025:
default:
- return hexname((const u_int8_t *)CLLADDR(sdl),
+ return hexname((const uint8_t *)CLLADDR(sdl),
(size_t)sdl->sdl_alen, host, hostlen);
}
}
static int
-hexname(cp, len, host, hostlen)
- const u_int8_t *cp;
- char *host;
- size_t len;
- socklen_t hostlen;
+hexname(const uint8_t *cp, size_t len, char *host, socklen_t hostlen)
{
int n;
size_t i;
-/* $NetBSD: getnetent.c,v 1.18 2007/01/27 22:27:35 christos Exp $ */
+/* $NetBSD: getnetent.c,v 1.21 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1983, 1993
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.18 2007/01/27 22:27:35 christos Exp $");
+__RCSID("$NetBSD: getnetent.c,v 1.21 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
static char *net_aliases[MAXALIASES];
int _net_stayopen;
-static void __setnetent __P((int));
-static void __endnetent __P((void));
+static void __setnetent(int);
+static void __endnetent(void);
void
-setnetent(stayopen)
- int stayopen;
+setnetent(int stayopen)
{
sethostent(stayopen);
}
void
-endnetent()
+endnetent(void)
{
endhostent();
}
static void
-__setnetent(f)
- int f;
+__setnetent(int f)
{
if (netf == NULL)
- netf = fopen(_PATH_NETWORKS, "r" );
+ netf = fopen(_PATH_NETWORKS, "re");
else
rewind(netf);
_net_stayopen |= f;
}
static void
-__endnetent()
+__endnetent(void)
{
if (netf) {
}
struct netent *
-getnetent()
+getnetent(void)
{
char *p;
register char *cp, **q;
- if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL)
+ if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "re")) == NULL)
return (NULL);
#if (defined(__sparc__) && defined(_LP64)) || \
defined(__alpha__) || \
net.__n_pad0 = 0;
#endif
again:
- p = fgets(line, sizeof line, netf);
+ p = fgets(line, (int)sizeof line, netf);
if (p == NULL)
return (NULL);
if (*p == '#')
-/* $NetBSD: getnetnamadr.c,v 1.41 2008/05/18 22:36:15 lukem Exp $ */
+/* $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
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.41 2008/05/18 22:36:15 lukem Exp $");
+__RCSID("$NetBSD: getnetnamadr.c,v 1.42 2012/03/13 21:13:41 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/* build result from octets in reverse */
for (octidx = 3; octidx >= 0; octidx--) {
*result <<= 8;
- *result |= (octet[octidx] & 0xff);
+ *result |= (in_addr_t)(octet[octidx] & 0xff);
}
return 0;
}
haveanswer = 0;
n_name[0] = '\0';
while (--ancount >= 0 && cp < eom) {
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
if ((n < 0) || !res_dnok(bp))
break;
cp += n;
cp += INT32SZ; /* TTL */
GETSHORT(n, cp);
if (class == C_IN && type == T_PTR) {
- n = dn_expand(answer->buf, eom, cp, bp, ep - bp);
+ n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
if ((n < 0) || !res_hnok(bp)) {
cp += n;
return NULL;
free(buf);
return NS_NOTFOUND;
}
- anslen = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
+ anslen = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf,
+ (int)sizeof(buf->buf));
if (anslen < 0) {
free(buf);
#ifdef DEBUG
return NS_NOTFOUND;
}
anslen = res_nsearch(res, qbuf, C_IN, T_PTR, buf->buf,
- sizeof(buf->buf));
+ (int)sizeof(buf->buf));
if (anslen < 0) {
free(buf);
#ifdef DEBUG
-.\" $NetBSD: getprotoent.3,v 1.11 2003/08/07 16:43:09 agc Exp $
+.\" $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.
.\"
.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd July 15, 2011
.Dt GETPROTOENT 3
.Os
.Sh NAME
.Fn getprotobyname "const char *name"
.Ft struct protoent *
.Fn getprotobynumber "int proto"
+.Ft void
.Fn setprotoent "int stayopen"
-.Fn endprotoent
+.Ft void
+.Fn endprotoent "void"
.Sh DESCRIPTION
The
.Fn getprotoent ,
.Ed
.Pp
The members of this structure are:
-.Bl -tag -width p_aliases
+.Bl -tag -width p_aliases -offset indent
.It Fa p_name
The official name of the protocol.
.It Fa p_aliases
The
.Fn setprotoent
function
-opens and rewinds the file. If the
+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
.Dv EOF
is encountered.
.Sh RETURN VALUES
-Null pointer
-(0) returned on
+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
-/* $NetBSD: getprotoent_r.c,v 1.5 2005/04/18 19:39:45 kleink Exp $ */
+/* $NetBSD: getprotoent_r.c,v 1.6 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getprotoent_r.c,v 1.5 2005/04/18 19:39:45 kleink Exp $");
+__RCSID("$NetBSD: getprotoent_r.c,v 1.6 2011/10/15 23:00:02 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
setprotoent_r(int f, struct protoent_data *pd)
{
if (pd->fp == NULL)
- pd->fp = fopen(_PATH_PROTOCOLS, "r");
+ pd->fp = fopen(_PATH_PROTOCOLS, "re");
else
rewind(pd->fp);
pd->stayopen |= f;
size_t i = 0;
int oerrno;
- if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL)
+ if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL)
return NULL;
for (;;) {
-/* $NetBSD: getservbyname_r.c,v 1.7 2010/04/25 00:54:46 joerg Exp $ */
+/* $NetBSD: getservbyname_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)getservbyname.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getservbyname_r.c,v 1.7 2010/04/25 00:54:46 joerg Exp $");
+__RCSID("$NetBSD: getservbyname_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
namelen = strlen(name);
if (namelen == 0 || namelen > 255)
return NULL;
- if (proto != NULL && *proto == '\0')
- return NULL;
- if (proto != NULL)
+ if (proto != NULL) {
protolen = strlen(proto);
- else
+ if (protolen == 0 || protolen > 255)
+ return NULL;
+ } else
protolen = 0;
+ if (namelen + protolen > 255)
+ return NULL;
- buf[0] = namelen;
- buf[1] = protolen;
+ buf[0] = (uint8_t)namelen;
+ buf[1] = (uint8_t)protolen;
memcpy(buf + 2, name, namelen);
memcpy(buf + 2 + namelen, proto, protolen);
-/* $NetBSD: getservbyport_r.c,v 1.7 2010/04/25 00:54:46 joerg Exp $ */
+/* $NetBSD: getservbyport_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)getservbyport.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getservbyport_r.c,v 1.7 2010/04/25 00:54:46 joerg Exp $");
+__RCSID("$NetBSD: getservbyport_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
port = be16toh(port);
- if (proto != NULL && *proto == '\0')
- return NULL;
- if (proto != NULL)
+ if (proto != NULL) {
protolen = strlen(proto);
- else
+ if (protolen == 0 || protolen > 255)
+ return NULL;
+ } else
protolen = 0;
if (port < 0 || port > 65536)
return NULL;
buf[0] = 0;
- buf[1] = protolen;
+ buf[1] = (uint8_t)protolen;
be16enc(buf + 2, port);
memcpy(buf + 4, proto, protolen);
-/* $NetBSD: getservent_r.c,v 1.10 2010/04/25 00:54:46 joerg Exp $ */
+/* $NetBSD: getservent_r.c,v 1.11 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getservent_r.c,v 1.10 2010/04/25 00:54:46 joerg Exp $");
+__RCSID("$NetBSD: getservent_r.c,v 1.11 2011/10/15 23:00:02 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
return 0;
}
- sd->plainfile = fopen(_PATH_SERVICES, "r");
+ sd->plainfile = fopen(_PATH_SERVICES, "re");
if (sd->plainfile != NULL) {
sd->flags |= _SV_PLAINFILE;
return 0;
-/* $NetBSD: hesiod.c,v 1.25 2011/01/05 00:09:43 wiz Exp $ */
+/* $NetBSD: hesiod.c,v 1.27 2012/03/20 17:44:18 matt Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
"#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.25 2011/01/05 00:09:43 wiz Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.27 2012/03/20 17:44:18 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#define MAX_HESRESP 1024
-static int read_config_file __P((struct hesiod_p *, const char *));
-static char **get_txt_records __P((int, const char *));
-static int init_context __P((void));
-static void translate_errors __P((void));
+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);
/*
* initialize a hesiod_p.
*/
int
-hesiod_init(context)
- void **context;
+hesiod_init(void **context)
{
struct hesiod_p *ctx;
const char *p, *configname;
* Deallocates the hesiod_p.
*/
void
-hesiod_end(context)
- void *context;
+hesiod_end(void *context)
{
struct hesiod_p *ctx = (struct hesiod_p *) context;
* by the resolver.
*/
char **
-hesiod_resolve(context, name, type)
- void *context;
- const char *name;
- const char *type;
+hesiod_resolve(void *context, const char *name, const char *type)
{
struct hesiod_p *ctx = (struct hesiod_p *) context;
char *bindname, **retvec;
/*ARGSUSED*/
void
-hesiod_free_list(context, list)
- void *context;
- char **list;
+hesiod_free_list(void *context, char **list)
{
char **p;
* or ctx->rhs which need to be freed by the caller.
*/
static int
-read_config_file(ctx, filename)
- struct hesiod_p *ctx;
- const char *filename;
+read_config_file(struct hesiod_p *ctx, const char *filename)
{
- char *key, *data, *p, **which;
- char buf[MAXDNAME + 7];
+ char *buf, *key, *data, *p, **which;
int n;
FILE *fp;
}
ctx->lhs = NULL;
ctx->rhs = NULL;
- while (fgets(buf, sizeof(buf), fp) != NULL) {
+ for (; (buf = fparseln(fp, NULL, NULL, NULL, FPARSELN_UNESCALL))
+ != NULL; free(buf)) {
p = buf;
- if (*p == '#' || *p == '\n' || *p == '\r')
- continue;
while (*p == ' ' || *p == '\t')
p++;
key = p;
*which = strdup(data);
if (!*which) {
errno = ENOMEM;
+ free(buf);
(void)fclose(fp);
return -1;
}
* return a list of them.
*/
static char **
-get_txt_records(qclass, name)
- int qclass;
- const char *name;
+get_txt_records(int qclass, const char *name)
{
HEADER *hp;
unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP], *p, *eom, *eor;
static int errval = HES_ER_UNINIT;
int
-hes_init()
+hes_init(void)
{
init_context();
return errval;
}
char *
-hes_to_bind(name, type)
- const char *name;
- const char *type;
+hes_to_bind(const char *name, const char *type)
{
static char *bindname;
}
char **
-hes_resolve(name, type)
- const char *name;
- const char *type;
+hes_resolve(const char *name, const char *type)
{
static char **list;
}
int
-hes_error()
+hes_error(void)
{
return errval;
}
void
-hes_free(hp)
- char **hp;
+hes_free(char **hp)
{
hesiod_free_list(context, hp);
}
static int
-init_context()
+init_context(void)
{
if (!inited) {
inited = 1;
}
static void
-translate_errors()
+translate_errors(void)
{
switch (errno) {
case ENOENT:
-/* $NetBSD: if_nameindex.c,v 1.6 2000/12/20 18:47:11 christos Exp $ */
+/* $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 $ */
/*-
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: if_nameindex.c,v 1.6 2000/12/20 18:47:11 christos Exp $");
+__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"
if_nameindex(void)
{
struct ifaddrs *ifaddrs, *ifa;
- unsigned int ni;
- int nbytes;
+ size_t nbytes, ni;
struct if_nameindex *ifni, *ifni2;
char *cp;
-/* $NetBSD: ip6opt.c,v 1.12 2009/01/30 23:43:30 lukem Exp $ */
+/* $NetBSD: ip6opt.c,v 1.14 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ip6opt.c,v 1.12 2009/01/30 23:43:30 lukem Exp $");
+__RCSID("$NetBSD: ip6opt.c,v 1.14 2012/03/20 17:44:18 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <netinet/ip6.h>
#include <assert.h>
+#include <stddef.h>
#include <string.h>
#include <stdio.h>
__weak_alias(inet6_opt_get_val, _inet6_opt_get_val)
#endif
-static int ip6optlen(u_int8_t *opt, u_int8_t *lim);
-static void inet6_insert_padopt(u_char *p, size_t len);
+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
* byte, the length byte, and the option data.
*/
int
-inet6_option_space(nbytes)
- int nbytes;
+inet6_option_space(int nbytes)
{
+ size_t sp;
nbytes += 2; /* we need space for nxt-hdr and length fields */
- return(CMSG_SPACE((nbytes + 7) & ~7));
+ sp = CMSG_SPACE((nbytes + 7) & ~7);
+ _DIAGASSERT(__type_fit(int, sp));
+ return (int)sp;
}
/*
* success or -1 on an error.
*/
int
-inet6_option_init(bp, cmsgp, type)
- void *bp;
- struct cmsghdr **cmsgp;
- int type;
+inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type)
{
register struct cmsghdr *ch;
* earlier. It must have a value between 0 and 7, inclusive.
*/
int
-inet6_option_append(cmsg, typep, multx, plusy)
- struct cmsghdr *cmsg;
- const u_int8_t *typep;
- int multx;
- int plusy;
+inet6_option_append(struct cmsghdr *cmsg, const uint8_t *typep, int multx,
+ int plusy)
{
size_t padlen, optlen, off;
- register u_char *bp;
+ register uint8_t *bp;
struct ip6_ext *eh;
_DIAGASSERT(cmsg != NULL);
_DIAGASSERT(typep != NULL);
- bp = (u_char *)(void *)cmsg + cmsg->cmsg_len;
+ bp = (uint8_t *)(void *)cmsg + cmsg->cmsg_len;
eh = (struct ip6_ext *)(void *)CMSG_DATA(cmsg);
/* argument validation */
* first 2 bytes(for next header and length fields) of
* the option header.
*/
- if (bp == (u_char *)(void *)eh) {
+ if (bp == (uint8_t *)(void *)eh) {
bp += 2;
cmsg->cmsg_len += 2;
}
/* calculate pad length before the option. */
- off = bp - (u_char *)(void *)eh;
+ 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 += padlen;
+ _DIAGASSERT(__type_fit(socklen_t, padlen + cmsg->cmsg_len));
+ cmsg->cmsg_len += (socklen_t)padlen;
bp += padlen;
/* copy the option */
optlen = typep[1] + 2;
memcpy(bp, typep, (size_t)optlen);
bp += optlen;
- cmsg->cmsg_len += 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 - (u_char *)(void *)eh;
+ off = bp - (uint8_t *)(void *)eh;
padlen = ((off + 7) & ~7) - off;
inet6_insert_padopt(bp, padlen);
bp += padlen;
- cmsg->cmsg_len += 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 - (u_char *)(void *)eh;
- eh->ip6e_len = (off >> 3) - 1;
+ off = bp - (uint8_t *)(void *)eh;
+ _DIAGASSERT(__type_fit(uint8_t, (off >> 3) - 1));
+ eh->ip6e_len = (uint8_t)((off >> 3) - 1);
return(0);
}
* then be built by the caller.
*
*/
-u_int8_t *
-inet6_option_alloc(cmsg, datalen, multx, plusy)
- struct cmsghdr *cmsg;
- int datalen;
- int multx;
- int plusy;
+uint8_t *
+inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy)
{
size_t padlen, off;
- register u_int8_t *bp;
- u_int8_t *retval;
+ register uint8_t *bp;
+ uint8_t *retval;
struct ip6_ext *eh;
_DIAGASSERT(cmsg != NULL);
- bp = (u_char *)(void *)cmsg + cmsg->cmsg_len;
+ bp = (uint8_t *)(void *)cmsg + cmsg->cmsg_len;
eh = (struct ip6_ext *)(void *)CMSG_DATA(cmsg);
/* argument validation */
* first 2 bytes(for next header and length fields) of
* the option header.
*/
- if (bp == (u_char *)(void *)eh) {
+ if (bp == (uint8_t *)(void *)eh) {
bp += 2;
cmsg->cmsg_len += 2;
}
/* calculate pad length before the option. */
- off = bp - (u_char *)(void *)eh;
+ 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 += padlen;
+ cmsg->cmsg_len += (socklen_t)padlen;
bp += padlen;
/* keep space to store specified length of data */
cmsg->cmsg_len += datalen;
/* calculate pad length after the option and insert the padding */
- off = bp - (u_char *)(void *)eh;
+ off = bp - (uint8_t *)(void *)eh;
padlen = ((off + 7) & ~7) - off;
inet6_insert_padopt(bp, padlen);
bp += padlen;
- cmsg->cmsg_len += 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 - (u_char *)(void *)eh;
- eh->ip6e_len = (off >> 3) - 1;
+ off = bp - (uint8_t *)(void *)eh;
+ _DIAGASSERT(__type_fit(uint8_t, (off >> 3) - 1));
+ eh->ip6e_len = (uint8_t)((off >> 3) - 1);
return(retval);
}
* (RFC 2292, 6.3.5)
*/
int
-inet6_option_next(cmsg, tptrp)
- const struct cmsghdr *cmsg;
- u_int8_t **tptrp;
+inet6_option_next(const struct cmsghdr *cmsg, uint8_t **tptrp)
{
struct ip6_ext *ip6e;
int hdrlen, optlen;
- u_int8_t *lim;
+ uint8_t *lim;
_DIAGASSERT(cmsg != NULL);
_DIAGASSERT(tptrp != NULL);
* simply return the 1st option.
* Otherwise, search the option list for the next option.
*/
- lim = (u_int8_t *)(void *)ip6e + hdrlen;
+ lim = (uint8_t *)(void *)ip6e + hdrlen;
if (*tptrp == NULL)
- *tptrp = (u_int8_t *)(void *)(ip6e + 1);
+ *tptrp = (uint8_t *)(void *)(ip6e + 1);
else {
if ((optlen = ip6optlen(*tptrp, lim)) == 0)
return(-1);
* 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 u_int8_t *, but we think
- * it's a typo. The variable should be type of u_int8_t **.
+ * 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(cmsg, tptrp, type)
- const struct cmsghdr *cmsg;
- u_int8_t **tptrp;
- int type;
+inet6_option_find(const struct cmsghdr *cmsg, uint8_t **tptrp, int type)
{
struct ip6_ext *ip6e;
int hdrlen, optlen;
- u_int8_t *optp, *lim;
+ uint8_t *optp, *lim;
_DIAGASSERT(cmsg != NULL);
_DIAGASSERT(tptrp != NULL);
* search from the beginning of the option list.
* Otherwise, search from *the next option* of the specified point.
*/
- lim = (u_int8_t *)(void *)ip6e + hdrlen;
+ lim = (uint8_t *)(void *)ip6e + hdrlen;
if (*tptrp == NULL)
- *tptrp = (u_int8_t *)(void *)(ip6e + 1);
+ *tptrp = (uint8_t *)(void *)(ip6e + 1);
else {
if ((optlen = ip6optlen(*tptrp, lim)) == 0)
return(-1);
* calculated length and the limitation of the buffer.
*/
static int
-ip6optlen(opt, lim)
- u_int8_t *opt, *lim;
+ip6optlen(uint8_t *opt, uint8_t *lim)
{
int optlen;
}
static void
-inet6_insert_padopt(u_char *p, size_t len)
+inet6_insert_padopt(uint8_t *p, size_t len)
{
_DIAGASSERT(p != NULL);
return;
default:
p[0] = IP6OPT_PADN;
- p[1] = len - 2;
+ _DIAGASSERT(__type_fit(uint8_t, len - 2));
+ p[1] = (uint8_t)(len - 2);
memset(&p[2], 0, len - 2);
return;
}
}
int
-inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type,
- socklen_t len, u_int8_t align, void **databufp)
+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;
padlen = align - (currentlen % align);
/* The option must fit in the extension header buffer. */
- currentlen += padlen;
+ _DIAGASSERT(__type_fit(int, currentlen + padlen));
+ currentlen += (int)padlen;
if (extlen && /* XXX: right? */
(socklen_t)currentlen > extlen)
return (-1);
if (extbuf) {
- u_int8_t *optp = (u_int8_t *)extbuf + offset;
+ uint8_t *optp = (uint8_t *)extbuf + offset;
if (padlen == 1) {
/* insert a Pad1 option */
} else if (padlen > 0) {
/* insert a PadN option for alignment */
*optp++ = IP6OPT_PADN;
- *optp++ = padlen - 2;
+ _DIAGASSERT(__type_fit(uint8_t, padlen - 2));
+ *optp++ = (uint8_t)(padlen - 2);
memset(optp, 0, padlen - 2);
optp += (padlen - 2);
}
int updatelen = offset > 0 ? (1 + ((offset - 1) | 7)) : 0;
if (extbuf) {
- u_int8_t *padp;
+ uint8_t *padp;
size_t padlen = updatelen - offset;
- if ((socklen_t)updatelen > extlen)
+ if ((socklen_t)updatelen > extlen || padlen >= 256 + 2)
return (-1);
- padp = (u_int8_t *)extbuf + offset;
+ padp = (uint8_t *)extbuf + offset;
if (padlen == 1)
*padp = IP6OPT_PAD1;
else if (padlen > 0) {
*padp++ = IP6OPT_PADN;
- *padp++ = (padlen - 2);
+ *padp++ = (uint8_t)(padlen - 2);
memset(padp, 0, padlen - 2);
}
}
inet6_opt_set_val(void *databuf, int offset, void *val, socklen_t vallen)
{
- memcpy((u_int8_t *)databuf + offset, val, vallen);
+ memcpy((uint8_t *)databuf + offset, val, vallen);
return (offset + vallen);
}
int
-inet6_opt_next(void *extbuf, socklen_t extlen, int offset, u_int8_t *typep,
+inet6_opt_next(void *extbuf, socklen_t extlen, int offset, uint8_t *typep,
socklen_t *lenp, void **databufp)
{
- u_int8_t *optp, *lim;
+ uint8_t *optp, *lim;
int optlen;
/* Validate extlen. XXX: is the variable really necessary?? */
if (extlen == 0 || (extlen % 8))
return (-1);
- lim = (u_int8_t *)extbuf + extlen;
+ lim = (uint8_t *)extbuf + extlen;
/*
* If this is the first time this function called for this options
* Otherwise, search the option list for the next option.
*/
if (offset == 0)
- optp = (u_int8_t *)(void *)((struct ip6_hbh *)extbuf + 1);
+ optp = (uint8_t *)(void *)((struct ip6_hbh *)extbuf + 1);
else
- optp = (u_int8_t *)extbuf + offset;
+ 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++;
*typep = *optp;
*lenp = optlen - 2;
*databufp = optp + 2;
- return (optp + optlen - (u_int8_t *)extbuf);
+ rv = optp + optlen - (uint8_t *)extbuf;
+ _DIAGASSERT(__type_fit(int, rv));
+ return (int)rv;
}
}
}
int
-inet6_opt_find(void *extbuf, socklen_t extlen, int offset, u_int8_t type,
+inet6_opt_find(void *extbuf, socklen_t extlen, int offset, uint8_t type,
socklen_t *lenp, void **databufp)
{
- u_int8_t *optp, *lim;
+ uint8_t *optp, *lim;
int optlen;
/* Validate extlen. XXX: is the variable really necessary?? */
if (extlen == 0 || (extlen % 8))
return (-1);
- lim = (u_int8_t *)extbuf + extlen;
+ lim = (uint8_t *)extbuf + extlen;
/*
* If this is the first time this function called for this options
* Otherwise, search the option list for the next option.
*/
if (offset == 0)
- optp = (u_int8_t *)(void *)((struct ip6_hbh *)extbuf + 1);
+ optp = (uint8_t *)(void *)((struct ip6_hbh *)extbuf + 1);
else
- optp = (u_int8_t *)extbuf + offset;
+ optp = (uint8_t *)extbuf + offset;
/* Find the specified option */
while (optp < lim) {
goto optend;
if (*optp == type) { /* found */
+ ptrdiff_t td;
*lenp = optlen - 2;
*databufp = optp + 2;
- return (optp + optlen - (u_int8_t *)extbuf);
+ td = optp + optlen - (uint8_t *)extbuf;
+ _DIAGASSERT(__type_fit(int, td));
+ return (int)td;
}
optp += optlen;
{
/* we can't assume alignment here */
- memcpy(val, (u_int8_t *)databuf + offset, vallen);
+ memcpy(val, (uint8_t *)databuf + offset, vallen);
return (offset + vallen);
}
-/* $NetBSD: iso_addr.c,v 1.12 2005/11/29 03:11:59 christos Exp $ */
+/* $NetBSD: iso_addr.c,v 1.14 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)iso_addr.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: iso_addr.c,v 1.12 2005/11/29 03:11:59 christos Exp $");
+__RCSID("$NetBSD: iso_addr.c,v 1.14 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define DELIM (4*2)
struct iso_addr *
-iso_addr(addr)
- register const char *addr;
+iso_addr(const char *addr)
{
static struct iso_addr out_addr;
register char *cp = out_addr.isoa_genaddr;
}
break;
} while (cp < cplim);
- out_addr.isoa_len = cp - out_addr.isoa_genaddr;
+ _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(isoa)
- const struct iso_addr *isoa;
+iso_ntoa(const struct iso_addr *isoa)
{
static char obuf[64];
char *out = obuf;
-/* $NetBSD: linkaddr.c,v 1.14 2005/11/29 03:11:59 christos Exp $ */
+/* $NetBSD: linkaddr.c,v 1.16 2012/03/20 17:44:18 matt Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: linkaddr.c,v 1.14 2005/11/29 03:11:59 christos Exp $");
+__RCSID("$NetBSD: linkaddr.c,v 1.16 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define LETTER (4*3)
void
-link_addr(addr, sdl)
- register const char *addr;
- register struct sockaddr_dl *sdl;
+link_addr(const char *addr, struct sockaddr_dl *sdl)
{
register char *cp = sdl->sdl_data;
char *cplim = sdl->sdl_len + (char *)(void *)sdl;
- register int byte = 0, state = NAMING;
- register int newaddr = 0; /* pacify gcc */
+ int byte = 0, state = NAMING;
+ size_t newaddr = 0; /* pacify gcc */
_DIAGASSERT(addr != NULL);
_DIAGASSERT(sdl != NULL);
continue;
case NAMING | DELIM:
state = RESET;
- sdl->sdl_nlen = cp - sdl->sdl_data;
+ _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 = newaddr;
+ byte = (int)newaddr;
continue;
case GOTONE | DIGIT:
state = GOTTWO;
- byte = newaddr + (byte << 4);
+ byte = (int)newaddr + (byte << 4);
continue;
default: /* | DELIM */
state = RESET;
}
break;
} while (cp < cplim);
- sdl->sdl_alen = cp - LLADDR(sdl);
+
+ _DIAGASSERT(__type_fit(uint8_t, cp - LLADDR(sdl)));
+ sdl->sdl_alen = (uint8_t)(cp - LLADDR(sdl));
newaddr = cp - (char *)(void *)sdl;
- if ((size_t) newaddr > sizeof(*sdl))
- sdl->sdl_len = newaddr;
+ 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(sdl)
- register const struct sockaddr_dl *sdl;
+link_ntoa(const struct sockaddr_dl *sdl)
{
static char obuf[64];
register char *out = obuf;
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <net/if.h>
-#include <ifaddrs.h>
+#include <namespace.h>
+
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
-#include <netinet/in.h>
+#include <net/if.h>
#include <net/gen/in.h>
#include <net/gen/ip_io.h>
#include <net/gen/tcp.h>
#include <net/gen/udp.h>
+#include <netinet/in.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ifaddrs.h>
+
int
getifaddrs(struct ifaddrs **ifap)
{
-.\" $NetBSD: nsdispatch.3,v 1.29 2009/10/14 17:24:03 joerg Exp $
+.\" $NetBSD: nsdispatch.3,v 1.31 2011/04/28 16:16:23 wiz Exp $
.\"
.\" Copyright (c) 1997, 1998, 1999, 2004, 2005, 2008
.\" The NetBSD Foundation, Inc.
should be set to a pointer to an internal static
.Ft "struct group"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getgrent 3
returns
should be set to a pointer to an internal static
.Ft "struct group"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getgrgid 3
returns
should be set to a pointer to an internal static
.Ft "struct group"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getgrnam 3
returns
should be set to a pointer to an internal static
.Ft "struct netent"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getnetbyaddr 3
returns
should be set to a pointer to an internal static
.Ft "struct netent"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getnetbyname 3
returns
should be set to a pointer to an internal static
.Ft "struct passwd"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getpwent 3
returns
should be set to a pointer to an internal static
.Ft "struct passwd"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getpwnam 3
returns
should be set to a pointer to an internal static
.Ft "struct passwd"
on success,
-.Dv NULL otherwise.
+.Dv NULL
+otherwise.
.Pp
.Xr getpwuid 3
returns
.Xr errno 2
on failure.
.Pp
-.Xr getpwuid_r
+.Xr getpwuid_r 3
returns 0
if
.Fn nsdispatch
-/* $NetBSD: nsdispatch.c,v 1.34 2009/02/05 13:21:11 lukem Exp $ */
+/* $NetBSD: nsdispatch.c,v 1.37 2012/03/13 21:13:42 christos Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nsdispatch.c,v 1.34 2009/02/05 13:21:11 lukem Exp $");
+__RCSID("$NetBSD: nsdispatch.c,v 1.37 2012/03/13 21:13:42 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
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! */
-#elif __GNUC_PREREQ__(4,2)
-static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
-#define is_dynamic() (&rtld_DYNAMIC != NULL)
#else
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
-#define is_dynamic() (&_DYNAMIC != NULL)
+__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).
/* dbt->srclistsize already incremented */
modkey.name = src->name;
- mod = bsearch(&modkey, _nsmod, _nsmodsize, sizeof(*_nsmod),
- _nsmodcmp);
+ mod = bsearch(&modkey, _nsmod, _nsmodsize, sizeof(*_nsmod), _nsmodcmp);
if (mod == NULL)
return (_nsloadmod(src->name, NULL));
%{
-/* $NetBSD: nslexer.l,v 1.11 2010/12/08 03:19:19 christos Exp $ */
+/* $NetBSD: nslexer.l,v 1.13 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nslexer.l,v 1.11 2010/12/08 03:19:19 christos Exp $");
+__RCSID("$NetBSD: nslexer.l,v 1.13 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#undef _nsyywrap
int
-_nsyywrap()
+_nsyywrap(void)
{
return 1;
} /* _nsyywrap */
void
-_nsyyerror(msg)
- const char *msg;
+_nsyyerror(const char *msg)
{
syslog(LOG_WARNING, "libc nsdispatch: %s line %d: %s at '%s'",
%{
-/* $NetBSD: nsparser.y,v 1.11 2009/02/05 13:21:11 lukem Exp $ */
+/* $NetBSD: nsparser.y,v 1.12 2012/03/20 17:44:18 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nsparser.y,v 1.11 2009/02/05 13:21:11 lukem Exp $");
+__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 <syslog.h>
-static void _nsaddsrctomap __P((const char *));
+static void _nsaddsrctomap(const char *);
static ns_dbt curdbt;
static ns_src cursrc;
%%
static void
-_nsaddsrctomap(elem)
- const char *elem;
+_nsaddsrctomap(const char *elem)
{
unsigned int i;
int lineno;
-/* $NetBSD: rcmd.c,v 1.65 2007/01/03 11:46:22 ws Exp $ */
+/* $NetBSD: rcmd.c,v 1.68 2012/07/14 15:06:26 darrenr Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
#if 0
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#else
-__RCSID("$NetBSD: rcmd.c,v 1.65 2007/01/03 11:46:22 ws Exp $");
+__RCSID("$NetBSD: rcmd.c,v 1.68 2012/07/14 15:06:26 darrenr Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "pathnames.h"
-int orcmd __P((char **, u_int, const char *, const char *, const char *,
- int *));
-int orcmd_af __P((char **, u_int, const char *, const char *, const char *,
- int *, int));
-int __ivaliduser __P((FILE *, u_int32_t, const char *, const char *));
-int __ivaliduser_sa __P((FILE *, const struct sockaddr *, socklen_t,
- const char *, const char *));
-static int rshrcmd __P((char **, u_int32_t, const char *, const char *,
- const char *, int *, const char *));
-static int resrcmd __P((struct addrinfo *, char **, u_int32_t, const char *,
- const char *, const char *, int *));
-static int __icheckhost __P((const struct sockaddr *, socklen_t,
- const char *));
-static char *__gethostloop __P((const struct sockaddr *, socklen_t));
+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(ahost, rport, locuser, remuser, cmd, fd2p)
- char **ahost;
- u_short rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
+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(ahost, rport, locuser, remuser, cmd, fd2p, af)
- char **ahost;
- u_short rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
- int af;
+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];
error = getaddrinfo(*ahost, pbuf, &hints, &res);
if (error) {
warnx("%s: %s", *ahost, gai_strerror(error)); /*XXX*/
- return (-1);
+ return -1;
}
if (res->ai_canonname) {
/*
*/
sp = getservbyname("shell", "tcp");
if (sp != NULL && sp->s_port == rport)
- error = rshrcmd(ahost, (u_int32_t)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);
+ return error;
}
/* this is simply a wrapper around hprcmd() that handles ahost first */
int
-orcmd(ahost, rport, locuser, remuser, cmd, fd2p)
- char **ahost;
- u_int rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
+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(ahost, rport, locuser, remuser, cmd, fd2p, af)
- char **ahost;
- u_int rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
- int af;
+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];
error = getaddrinfo(*ahost, pbuf, &hints, &res);
if (error) {
warnx("%s: %s", *ahost, gai_strerror(error)); /*XXX*/
- return (-1);
+ return -1;
}
if (res->ai_canonname) {
strlcpy(hbuf, res->ai_canonname, sizeof(hbuf));
error = resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p);
freeaddrinfo(res);
- return (error);
+ return error;
}
/*ARGSUSED*/
static int
-resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
- struct addrinfo *res;
- char **ahost;
- u_int32_t rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
+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;
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* !__minix */
- return (-1);
+ return -1;
}
}
#ifndef __minix
hbuf[0] = '\0';
if (getnameinfo(r->ai_addr, r->ai_addrlen,
- hbuf, sizeof(hbuf), NULL, 0, niflags) != 0)
+ 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, sizeof(hbuf), NULL, 0, niflags) != 0)
+ hbuf, (socklen_t)sizeof(hbuf), NULL, 0, niflags) !=
+ 0)
strlcpy(hbuf, "(invalid)", sizeof(hbuf));
(void)fprintf(stderr, "Trying %s...\n", hbuf);
continue;
/* No OOB support in Minix. */
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* !__minix */
- return (-1);
+ return -1;
}
lport--;
if (fd2p == 0) {
if (errno != 0)
warn("poll: setting up stderr");
else
- warnx("poll: protocol failure in circuit setup");
+ warnx(
+ "poll: protocol failure in circuit setup");
(void)close(s2);
goto bad;
}
case AF_INET6:
#endif
if (getnameinfo((struct sockaddr *)(void *)&from, len,
- NULL, 0, num, sizeof(num), NI_NUMERICSERV) != 0 ||
+ 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.");
+ warnx(
+ "rcmd: protocol failure in circuit setup.");
goto bad2;
}
break;
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* __minix */
- return (s);
+ return s;
bad2:
if (lport)
(void)close(*fd2p);
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* __minix */
- return (-1);
+ return -1;
}
/*
*/
/* ARGSUSED */
static int
-rshrcmd(ahost, rport, locuser, remuser, cmd, fd2p, rshcmd)
- char **ahost;
- u_int32_t rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
- const char *rshcmd;
+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];
/* locuser must exist on this host. */
if (getpwnam_r(locuser, &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 ||
pw == NULL) {
- warnx("rshrcmd: unknown user: %s", locuser);
- return(-1);
+ 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("rshrcmd: socketpair");
- return (-1);
+ 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("rshrcmd: socketpair");
- return (-1);
+ warn("%s: socketpair", __func__);
+ return -1;
}
*fd2p = ep[0];
}
pid = fork();
if (pid < 0) {
- warn("rshrcmd: fork");
- return (-1);
+ warn("%s: fork", __func__);
+ return -1;
}
if (pid == 0) {
/*
*/
(void)close(sp[0]);
if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) {
- warn("rshrcmd: dup2");
+ warn("%s: dup2", __func__);
_exit(1);
}
(void)close(sp[1]);
if (fd2p) {
if (dup2(ep[1], 2) < 0) {
- warn("rshrcmd: dup2");
+ warn("%s: dup2", __func__);
_exit(1);
}
(void)close(ep[0]);
(void)close(ep[1]);
} else if (dup2(0, 2) < 0) {
- warn("rshrcmd: dup2");
+ warn("%s: dup2", __func__);
_exit(1);
}
/* fork again to lose parent. */
pid = fork();
if (pid < 0) {
- warn("rshrcmd: second fork");
+ warn("%s: second fork", __func__);
_exit(1);
}
if (pid > 0)
/* Orphan. Become local user for rshprog. */
if (setuid(pw->pw_uid)) {
- warn("rshrcmd: setuid(%lu)", (u_long)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 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) {
p = strrchr(rshcmd, '/');
execlp(rshcmd, p ? p + 1 : rshcmd, "-c", cmd, NULL);
} else {
- p = strrchr(rshcmd, '/');
- execlp(rshcmd, p ? p + 1 : rshcmd, *ahost, "-l",
- remuser, cmd, NULL);
+ const char *program;
+ program = strrchr(rshcmd, '/');
+ program = program ? program + 1 : rshcmd;
+ 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("rshrcmd: exec %s", rshcmd);
+ warn("%s: exec %s", __func__, rshcmd);
_exit(1);
}
/* Parent */
(void)close(ep[1]);
(void)waitpid(pid, NULL, 0);
- return (sp[0]);
+ return sp[0];
}
int
-rresvport(alport)
- int *alport;
+rresvport(int *alport)
{
_DIAGASSERT(alport != NULL);
}
int
-rresvport_af(alport, family)
- int *alport;
- int family;
+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;
- int salen;
+ socklen_t salen;
int s;
u_int16_t *portp;
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
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);
+ return -1;
}
sa->sa_family = family;
s = socket(family, SOCK_STREAM, 0);
if (s < 0)
- return (-1);
+ return -1;
#ifdef BSD4_4
switch (family) {
case AF_INET:
(void)close(s);
errno = sverr;
- return (-1);
+ return -1;
}
*alport = (int)ntohs(*portp);
- return (s);
+ 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, (socklen_t)salen) >= 0)
- return (s);
+ if (bind(s, sa, salen) >= 0)
+ return s;
if (errno != EADDRINUSE) {
(void)close(s);
- return (-1);
+ return -1;
}
(*alport)--;
if (*alport == IPPORT_RESERVED/2) {
(void)close(s);
errno = EAGAIN; /* close */
- return (-1);
+ return -1;
}
}
}
const char *__rcmd_errstr;
int
-ruserok(rhost, superuser, ruser, luser)
- const char *rhost, *ruser, *luser;
- int superuser;
+ruserok(const char *rhost, int superuser, const char *ruser, const char *luser)
{
struct addrinfo hints, *res, *r;
int error;
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
error = getaddrinfo(rhost, "0", &hints, &res);
if (error)
- return (-1);
+ 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);
+ return 0;
}
}
freeaddrinfo(res);
- return (-1);
+ return -1;
}
/*
* Returns 0 if ok, -1 if not ok.
*/
int
-iruserok(raddr, superuser, ruser, luser)
- u_int32_t raddr;
- int superuser;
- const char *ruser, *luser;
+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(struct sockaddr_in);
+ irsin.sin_len = sizeof(irsin);
#endif
memcpy(&irsin.sin_addr, &raddr, sizeof(irsin.sin_addr));
- return iruserok_sa(&irsin, sizeof(struct sockaddr_in), superuser, ruser,
- luser);
+ return iruserok_sa(&irsin, (socklen_t)sizeof(irsin), superuser, ruser,
+ luser);
}
/*
* unistd.h and sys/socket.h. There's no better way.
*/
int
-iruserok_sa(raddr, rlen, superuser, ruser, luser)
- const void *raddr;
- int rlen;
- int superuser;
- const char *ruser, *luser;
+iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser,
+ const char *luser)
{
const struct sockaddr *sa;
struct stat sbuf;
if (__ivaliduser_sa(hostf, sa, (socklen_t)rlen, luser,
ruser) == 0) {
(void)fclose(hostf);
- return (0);
+ return 0;
}
(void)fclose(hostf);
}
if (getpwnam_r(luser, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0
|| pwd == NULL)
- return (-1);
+ return -1;
(void)strlcpy(pbuf, pwd->pw_dir, sizeof(pbuf));
(void)strlcat(pbuf, "/.rhosts", sizeof(pbuf));
(void)setegid(gid);
}
- return (isvaliduser);
+ return isvaliduser;
}
/*
static
#endif
int
-__ivaliduser(hostf, raddr, luser, ruser)
- FILE *hostf;
- u_int32_t raddr;
- const char *luser, *ruser;
+__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(struct sockaddr_in);
+ ivusin.sin_len = sizeof(ivusin);
#endif
memcpy(&ivusin.sin_addr, &raddr, sizeof(ivusin.sin_addr));
return __ivaliduser_sa(hostf, (struct sockaddr *)(void *)&ivusin,
- sizeof(struct sockaddr_in), luser, ruser);
+ (socklen_t)sizeof(ivusin), luser, ruser);
}
#ifdef notdef /*_LIBC*/
static
#endif
int
-__ivaliduser_sa(hostf, raddr, salen, luser, ruser)
- FILE *hostf;
- const struct sockaddr *raddr;
- socklen_t salen;
- const char *luser, *ruser;
+__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen,
+ const char *luser, const char *ruser)
{
- register char *user, *p;
+ char *user, *p;
int ch;
char buf[MAXHOSTNAMELEN + 128]; /* host + login */
const char *auser, *ahost;
_DIAGASSERT(luser != NULL);
_DIAGASSERT(ruser != NULL);
- while (fgets(buf, sizeof(buf), hostf)) {
+ while (fgets(buf, (int)sizeof(buf), hostf)) {
p = buf;
/* Skip lines that are too long. */
if (strchr(p, '\n') == NULL) {
break;
default:
- hostok = -__icheckhost(raddr, salen, &ahost[1]);
+ hostok =
+ -__icheckhost(raddr, salen, &ahost[1]);
break;
}
else
* Returns "true" if match, 0 if no match.
*/
static int
-__icheckhost(raddr, salen, lhost)
- const struct sockaddr *raddr;
- socklen_t salen;
- const char *lhost;
+__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost)
{
struct addrinfo hints, *res, *r;
char h1[NI_MAXHOST], h2[NI_MAXHOST];
_DIAGASSERT(lhost != NULL);
h1[0] = '\0';
- if (getnameinfo(raddr, salen, h1, sizeof(h1), NULL, 0,
+ if (getnameinfo(raddr, salen, h1, (socklen_t)sizeof(h1), NULL, 0,
niflags) != 0)
- return (0);
+ return 0;
/* Resolve laddr into sockaddr */
memset(&hints, 0, sizeof(hints));
res = NULL;
error = getaddrinfo(lhost, "0", &hints, &res);
if (error)
- return (0);
+ 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, sizeof(h2),
- NULL, 0, niflags) != 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);
+ return 1;
}
}
/* No match. */
freeaddrinfo(res);
- return (0);
+ return 0;
}
/*
* be found, pack the numeric IP address into the string.
*/
static char *
-__gethostloop(raddr, salen)
- const struct sockaddr *raddr;
- socklen_t salen;
+__gethostloop(const struct sockaddr *raddr, socklen_t salen)
{
static char remotehost[NI_MAXHOST];
char h1[NI_MAXHOST], h2[NI_MAXHOST];
_DIAGASSERT(raddr != NULL);
h1[0] = remotehost[0] = '\0';
- if (getnameinfo(raddr, salen, remotehost, sizeof(remotehost),
+ if (getnameinfo(raddr, salen, remotehost, (socklen_t)sizeof(remotehost),
NULL, 0, NI_NAMEREQD) != 0)
- return (NULL);
- if (getnameinfo(raddr, salen, h1, sizeof(h1), NULL, 0,
+ return NULL;
+ if (getnameinfo(raddr, salen, h1, (socklen_t)sizeof(h1), NULL, 0,
niflags) != 0)
- return (NULL);
+ return NULL;
/*
* Look up the name and check that the supplied
res = NULL;
error = getaddrinfo(remotehost, "0", &hints, &res);
if (error)
- return (NULL);
+ return NULL;
for (r = res; r; r = r->ai_next) {
h2[0] = '\0';
- if (getnameinfo(r->ai_addr, r->ai_addrlen, h2, sizeof(h2),
- NULL, 0, niflags) != 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);
+ return remotehost;
}
}
syslog(LOG_NOTICE, "rcmd: address %s not listed for host %s",
h1, res->ai_canonname ? res->ai_canonname : remotehost);
freeaddrinfo(res);
- return (NULL);
+ return NULL;
}
-/* $NetBSD: recv.c,v 1.9 2003/10/22 15:40:19 drochner Exp $ */
+/* $NetBSD: recv.c,v 1.10 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: recv.c,v 1.9 2003/10/22 15:40:19 drochner Exp $");
+__RCSID("$NetBSD: recv.c,v 1.10 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stddef.h>
ssize_t
-recv(s, buf, len, flags)
- int s, flags;
- size_t len;
- void *buf;
+recv(int s, void *buf, size_t len, int flags)
{
return (recvfrom(s, buf, len, flags, NULL, NULL));
}
-/* $NetBSD: rthdr.c,v 1.17 2009/02/05 23:22:39 lukem Exp $ */
+/* $NetBSD: rthdr.c,v 1.18 2012/03/13 21:13:42 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rthdr.c,v 1.17 2009/02/05 23:22:39 lukem Exp $");
+__RCSID("$NetBSD: rthdr.c,v 1.18 2012/03/13 21:13:42 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
*/
size_t
-inet6_rthdr_space(type, seg)
- int type, seg;
+inet6_rthdr_space(int type, int seg)
{
switch (type) {
case IPV6_RTHDR_TYPE_0:
}
struct cmsghdr *
-inet6_rthdr_init(bp, type)
- void *bp;
- int type;
+inet6_rthdr_init(void *bp, int type)
{
struct cmsghdr *ch;
struct ip6_rthdr *rthdr;
}
int
-inet6_rthdr_add(cmsg, addr, flags)
- struct cmsghdr *cmsg;
- const struct in6_addr *addr;
- u_int flags;
+inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags)
{
struct ip6_rthdr *rthdr;
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);
(void)memcpy(((caddr_t)(void *)rt0) +
((rt0->ip6r0_len + 1) << 3), addr, sizeof(struct in6_addr));
rt0->ip6r0_len += sizeof(struct in6_addr) >> 3;
- cmsg->cmsg_len = CMSG_LEN((rt0->ip6r0_len + 1) << 3);
+ len = CMSG_LEN((rt0->ip6r0_len + 1) << 3);
+ _DIAGASSERT(__type_fit(socklen_t, len));
+ cmsg->cmsg_len = (socklen_t)len;
break;
}
default:
}
int
-inet6_rthdr_lasthop(cmsg, flags)
- struct cmsghdr *cmsg;
- unsigned int flags;
+inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags)
{
struct ip6_rthdr *rthdr;
#if 0
int
-inet6_rthdr_reverse(in, out)
- const struct cmsghdr *in;
- struct cmsghdr *out;
+inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out)
{
return (-1);
#endif
int
-inet6_rthdr_segments(cmsg)
- const struct cmsghdr *cmsg;
+inet6_rthdr_segments(const struct cmsghdr *cmsg)
{
const struct ip6_rthdr *rthdr;
{
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);
- return (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
+ len = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
+ _DIAGASSERT(__type_fit(int, len));
+ return (int)len;
}
default:
}
struct in6_addr *
-inet6_rthdr_getaddr(cmsg, idx)
- struct cmsghdr *cmsg;
- int idx;
+inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx)
{
struct ip6_rthdr *rthdr;
{
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;
- naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
+ 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
}
int
-inet6_rthdr_getflags(cmsg, idx)
- const struct cmsghdr *cmsg;
- int idx;
+inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx)
{
const struct ip6_rthdr *rthdr;
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);
- naddr = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr);
+ 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;
-/* $NetBSD: send.c,v 1.9 2003/08/07 16:43:15 agc Exp $ */
+/* $NetBSD: send.c,v 1.10 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: send.c,v 1.9 2003/08/07 16:43:15 agc Exp $");
+__RCSID("$NetBSD: send.c,v 1.10 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif /* !__minix */
ssize_t
-send(s, msg, len, flags)
- int s, flags;
- size_t len;
- const void *msg;
+send(int s, const void *msg, size_t len, int flags)
{
+
return (sendto(s, msg, len, flags, NULL, 0));
}
-/* $NetBSD: sethostent.c,v 1.16 2007/01/27 22:27:35 christos Exp $ */
+/* $NetBSD: sethostent.c,v 1.17 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1985, 1993
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.16 2007/01/27 22:27:35 christos Exp $");
+__RCSID("$NetBSD: sethostent.c,v 1.17 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__weak_alias(endhostent,_endhostent)
#endif
-void _endhtent __P((void));
+void _endhtent(void);
#ifndef _REENTRANT
-void res_close __P((void));
+void res_close(void);
#endif
-void _sethtent __P((int));
+void _sethtent(int);
void
/*ARGSUSED*/
-sethostent(stayopen)
- int stayopen;
+sethostent(int stayopen)
{
#ifndef _REENTRANT
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
}
void
-endhostent()
+endhostent(void)
{
#ifndef _REENTRANT
_res.options &= ~(RES_STAYOPEN | RES_USEVC);
-/* $NetBSD: sockatmark.c,v 1.2 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: sockatmark.c,v 1.3 2012/03/20 17:44:18 matt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sockatmark.c,v 1.2 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: sockatmark.c,v 1.3 2012/03/20 17:44:18 matt Exp $");
#endif
#include "namespace.h"
#include <assert.h>
int
-sockatmark(s)
- int s;
+sockatmark(int s)
{
int val;
-# $NetBSD: Makefile.inc,v 1.10 2009/01/11 02:46:29 christos Exp $
+# $NetBSD: Makefile.inc,v 1.11 2012/01/20 16:31:30 joerg Exp $
.PATH: ${.CURDIR}/nls
# indirect reference stubs, to be removed soon.
SRCS+= _catclose.c _catgets.c _catopen.c
-CPPFLAGS.catopen.c+= -DHAVE_CITRUS -I${LIBCDIR}/citrus
+CPPFLAGS.catopen.c+= -I${LIBCDIR}/citrus
-/* $NetBSD: catclose.c,v 1.13 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: catclose.c,v 1.13 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#define _NLS_PRIVATE
#endif
int
-_catclose(catd)
- nl_catd catd;
+_catclose(nl_catd catd)
{
if (catd == (nl_catd) -1) {
errno = EBADF;
-/* $NetBSD: catgets.c,v 1.18 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: catgets.c,v 1.19 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: catgets.c,v 1.18 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: catgets.c,v 1.19 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#define _NLS_PRIVATE
#endif
char *
-_catgets(catd, set_id, msg_id, s)
- nl_catd catd;
- int set_id;
- int msg_id;
- const char *s;
+_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;
-/* $NetBSD: catopen.c,v 1.28 2009/03/10 13:15:40 joerg Exp $ */
+/* $NetBSD: catopen.c,v 1.31 2012/07/30 23:02:41 yamt Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: catopen.c,v 1.28 2009/03/10 13:15:40 joerg Exp $");
+__RCSID("$NetBSD: catopen.c,v 1.31 2012/07/30 23:02:41 yamt Exp $");
#endif /* LIBC_SCCS and not lint */
#define _NLS_PRIVATE
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_CITRUS
#include "citrus_namespace.h"
#include "citrus_bcs.h"
#include "citrus_region.h"
#include "citrus_lookup.h"
#include "citrus_aliasname_local.h"
-#else
-#include "aliasname_local.h"
-#endif
#define NLS_ALIAS_DB "/usr/share/nls/nls.alias"
__weak_alias(catopen, _catopen)
#endif
-static nl_catd load_msgcat __P((const char *));
+static nl_catd load_msgcat(const char *);
nl_catd
-_catopen(name, oflag)
- const char *name;
- int oflag;
+_catopen(const char *name, int oflag)
{
char tmppath[PATH_MAX+1];
const char *nlspath;
if (issetugid() || (nlspath = getenv("NLSPATH")) == NULL)
nlspath = NLS_DEFAULT_PATH;
+ /*
+ * histrical note:
+ * http://www.hauN.org/ml/b-l-j/a/800/828.html (in japanese)
+ */
if (oflag == NL_CAT_LOCALE) {
lang = setlocale(LC_MESSAGES, NULL);
- }
- else {
+ } else {
lang = getenv("LANG");
}
if (lang == NULL || strchr(lang, '/'))
}
static nl_catd
-load_msgcat(path)
- const char *path;
+load_msgcat(const char *path)
{
struct stat st;
nl_catd catd;
-# $NetBSD: Makefile.inc,v 1.11 2009/12/06 05:34:42 uebayasi Exp $
+# $NetBSD: Makefile.inc,v 1.14 2012/08/06 08:17:58 matt Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
# Quad support
SRCS.quad= cmpdi2.c divdi3.c fixdfdi.c fixsfdi.c fixunsdfdi.c \
- fixunssfdi.c floatdidf.c floatdisf.c floatunsdidf.c \
+ fixunssfdi.c floatdidf.c floatdisf.c floatundisf.c floatundidf.c \
moddi3.c muldi3.c negdi2.c qdivrem.c \
ucmpdi2.c udivdi3.c umoddi3.c
SRCS.quad+= ashldi3.S ashrdi3.S lshrdi3.S
.elif (${MACHINE_ARCH} == "m68000")
SRCS.quad+= ashldi3.S lshrdi3.S
+.elif (${MACHINE_ARCH} == "earm" || ${MACHINE_ARCH} == "earmeb")
+SRCS.quad+= ashrdi3.c lshldi3.c lshrdi3.c
.else
SRCS.quad+= ashldi3.c ashrdi3.c lshrdi3.c
.endif
-/* $NetBSD: fixdfdi.c,v 1.4 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: fixdfdi.c,v 1.6 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)fixdfdi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fixdfdi.c,v 1.4 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: fixdfdi.c,v 1.6 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"
/*
* We clamp anything that is out of range.
*/
quad_t
-__fixdfdi(x)
- double x;
+__fixdfdi(double x)
{
if (x < 0)
if (x <= QUAD_MIN)
-/* $NetBSD: fixsfdi.c,v 1.4 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: fixsfdi.c,v 1.5 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992 The Regents of the University of California.
#if 0
static char sccsid[] = "@(#)fixsfdi.c 5.1 (Berkeley) 7/7/92";
#else
-__RCSID("$NetBSD: fixsfdi.c,v 1.4 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: fixsfdi.c,v 1.5 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"
/*
-/* $NetBSD: fixunsdfdi.c,v 1.7 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: fixunsdfdi.c,v 1.10 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)fixunsdfdi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fixunsdfdi.c,v 1.7 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: fixunsdfdi.c,v 1.10 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"
-#define ONE_FOURTH ((int)1 << (INT_BITS - 2))
+#define ONE_FOURTH ((int)1 << (unsigned int)(INT_BITS - 2))
#define ONE_HALF (ONE_FOURTH * 2.0)
#define ONE (ONE_FOURTH * 4.0)
* of range becomes UQUAD_MAX.
*/
u_quad_t
-__fixunsdfdi(x)
- double x;
+__fixunsdfdi(double x)
{
union uu t;
unsigned int tmp;
-/* $NetBSD: fixunssfdi.c,v 1.6 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: fixunssfdi.c,v 1.8 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fixunssfdi.c,v 1.6 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: fixunssfdi.c,v 1.8 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"
-#define ONE_FOURTH ((int)1 << (INT_BITS - 2))
+#define ONE_FOURTH ((int)1 << (unsigned int)(INT_BITS - 2))
#define ONE_HALF (ONE_FOURTH * 2.0)
#define ONE (ONE_FOURTH * 4.0)
-/* $NetBSD: floatdidf.c,v 1.6 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: floatdidf.c,v 1.9 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)floatdidf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: floatdidf.c,v 1.6 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: floatdidf.c,v 1.9 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"
/*
* Convert (signed) quad to double.
*/
double
-__floatdidf(x)
- quad_t x;
+__floatdidf(quad_t x)
{
double d;
union uu u;
* 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 << (INT_BITS - 2)) * 4.0);
+ d = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0);
d += u.ul[L];
return (neg ? -d : d);
-/* $NetBSD: floatdisf.c,v 1.6 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: floatdisf.c,v 1.9 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)floatdisf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: floatdisf.c,v 1.6 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: floatdisf.c,v 1.9 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"
/*
* Convert (signed) quad to float.
*/
float
-__floatdisf(x)
- quad_t x;
+__floatdisf(quad_t x)
{
float f;
union uu u;
*
* Using double here may be excessive paranoia.
*/
- f = (double)u.ul[H] * (((int)1 << (INT_BITS - 2)) * 4.0);
+ f = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0);
f += u.ul[L];
return (neg ? -f : f);
-/* $NetBSD: floatunsdidf.c,v 1.6 2003/08/07 16:43:16 agc Exp $ */
+/* $NetBSD: floatundidf.c,v 1.3 2012/08/05 04:28:58 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)floatunsdidf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: floatunsdidf.c,v 1.6 2003/08/07 16:43:16 agc Exp $");
+__RCSID("$NetBSD: floatundidf.c,v 1.3 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"
/*
* This is exactly like floatdidf.c except that negatives never occur.
*/
double
-__floatunsdidf(x)
- u_quad_t x;
+__floatundidf(u_quad_t x)
{
double d;
union uu u;
u.uq = x;
- d = (double)u.ul[H] * (((int)1 << (INT_BITS - 2)) * 4.0);
+ d = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0);
d += u.ul[L];
return (d);
}
--- /dev/null
+/* $NetBSD: floatundisf.c,v 1.3 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 <sys/cdefs.h>
+#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.3 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"
+
+/*
+ * 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;
+}
--- /dev/null
+/* $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 <sys/cdefs.h>
+#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 <machine/ieee.h>
+
+/*
+ * 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
+}
-/* $NetBSD: engine.c,v 1.22 2009/02/12 05:06:54 lukem Exp $ */
+/* $NetBSD: engine.c,v 1.24 2012/03/13 21:13:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
/* prescreening; this does wonders for this rather slow code */
if (g->must != NULL) {
for (dp = start; dp < stop; dp++)
- if (*dp == g->must[0] && stop - dp >= g->mlen &&
- memcmp(dp, g->must, (size_t)g->mlen) == 0)
+ 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);
int c = (start == m->beginp) ? OUT : *(start-1);
int lastc; /* previous c */
int flagch;
- int i;
+ size_t i;
const char *coldp; /* last p after which no match was underway */
_DIAGASSERT(m != NULL);
int c = (start == m->beginp) ? OUT : *(start-1);
int lastc; /* previous c */
int flagch;
- int i;
+ size_t i;
const char *matchp; /* last p at which a match ended */
_DIAGASSERT(m != NULL);
-/* $NetBSD: regcomp.c,v 1.29 2009/02/12 05:06:54 lukem Exp $ */
+/* $NetBSD: regcomp.c,v 1.33 2012/03/13 21:13:43 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regcomp.c,v 1.29 2009/02/12 05:06:54 lukem Exp $");
+__RCSID("$NetBSD: regcomp.c,v 1.33 2012/03/13 21:13:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
sop *strip; /* malloced strip */
sopno ssize; /* malloced strip size (allocated) */
sopno slen; /* malloced strip length (used) */
- int ncsalloc; /* number of csets allocated */
+ 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) */
#endif
/* === regcomp.c === */
-static void p_ere(struct parse *p, int stop);
-static void p_ere_exp(struct parse *p);
+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);
-static int p_simp_re(struct parse *p, int starordinary);
+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 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);
+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 int freezeset(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);
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 void enlarge(struct parse *p, sopno size);
+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);
#define never 0 /* some <assert.h>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);
if (g == NULL)
return(REG_ESPACE);
p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
- p->strip = (sop *)malloc(p->ssize * sizeof(sop));
+ p->strip = malloc(p->ssize * sizeof(sop));
p->slen = 0;
if (p->strip == NULL) {
free(g);
EMIT(OEND, 0);
g->firststate = THERE();
if (cflags®_EXTENDED)
- p_ere(p, OUT);
+ p_ere(p, OUT, 0);
else if (cflags®_NOSPEC)
p_str(p);
else
- p_bre(p, OUT, OUT);
+ p_bre(p, OUT, OUT, 0);
EMIT(OEND, 0);
g->laststate = THERE();
/*
- p_ere - ERE parser top level, concatenation and alternation
- == static void p_ere(struct parse *p, int stop);
+ == 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 */
+ int stop, /* character this ERE should end at */
+ size_t reclimit)
{
char c;
sopno prevback = 0; /* pacify gcc */
_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);
+ p_ere_exp(p, reclimit);
REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
if (!EAT('|'))
/*
- p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
- == static void p_ere_exp(struct parse *p);
+ == static void p_ere_exp(struct parse *p, size_t reclimit);
*/
static void
p_ere_exp(
- struct parse *p)
+ struct parse *p,
+ size_t reclimit)
{
char c;
sopno pos;
p->pbegin[subno] = HERE();
EMIT(OLPAREN, subno);
if (!SEE(')'))
- p_ere(p, ')');
+ p_ere(p, ')', reclimit);
if (subno < NPAREN) {
p->pend[subno] = HERE();
assert(p->pend[subno] != 0);
count2 = INFINITY;
} else /* just a single number */
count2 = count;
- repeat(p, pos, count, count2);
+ repeat(p, pos, count, count2, 0);
if (!EAT('}')) { /* error heuristics */
while (MORE() && PEEK() != '}')
NEXT();
/*
- p_bre - BRE parser top level, anchoring and concatenation
== static void p_bre(struct parse *p, int end1, \
- == int end2);
+ == 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
p_bre(
struct parse *p,
int end1, /* first terminating character */
- int end2) /* second terminating character */
+ int end2, /* second terminating character */
+ size_t reclimit)
{
sopno start;
int first = 1; /* first subexpression? */
_DIAGASSERT(p != NULL);
+ if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) {
+ p->error = REG_ESPACE;
+ return;
+ }
+
start = HERE();
if (EAT('^')) {
p->g->nbol++;
}
while (MORE() && !SEETWO(end1, end2)) {
- wasdollar = p_simp_re(p, first);
+ wasdollar = p_simp_re(p, first, reclimit);
first = 0;
}
if (wasdollar) { /* oops, that was a trailing anchor */
/*
- p_simp_re - parse a simple RE, an atom possibly followed by a repetition
- == static int p_simp_re(struct parse *p, int starordinary);
+ == 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? */
+ int starordinary, /* is a leading * an ordinary character? */
+ size_t reclimit)
{
int c;
int count;
int count2;
- sopno pos;
- int i;
+ sopno pos, i;
sopno subno;
# define BACKSL (1<<CHAR_BIT)
EMIT(OLPAREN, subno);
/* the MORE here is an error heuristic */
if (MORE() && !SEETWO('\\', ')'))
- p_bre(p, '\\', ')');
+ p_bre(p, '\\', ')', reclimit);
if (subno < NPAREN) {
p->pend[subno] = HERE();
assert(p->pend[subno] != 0);
count2 = INFINITY;
} else /* just a single number */
count2 = count;
- repeat(p, pos, count, count2);
+ repeat(p, pos, count, count2, 0);
if (!EATTWO('\\', '}')) { /* error heuristics */
while (MORE() && !SEETWO('\\', '}'))
NEXT();
{
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, "[:<:]]",
return;
if (p->g->cflags®_ICASE) {
- int i;
+ ssize_t i;
int ci;
for (i = p->g->csetsize - 1; i >= 0; i--)
if (CHIN(cs, i) && isalpha(i)) {
- ci = othercase(i);
+ ci = othercase((int)i);
if (ci != i)
CHadd(cs, ci);
}
mccase(p, cs);
}
if (invert) {
- int i;
+ ssize_t i;
for (i = p->g->csetsize - 1; i >= 0; i--)
if (CHIN(cs, i))
- CHsub(cs, i);
+ CHsub(cs, (int)i);
else
- CHadd(cs, i);
+ CHadd(cs, (int)i);
if (p->g->cflags®_NEWLINE)
CHsub(cs, '\n');
if (cs->multis != NULL)
&& othercase((unsigned char) ch) != (unsigned char) ch)
bothcases(p, (unsigned char) ch);
else {
- EMIT(OCHAR, (unsigned char)ch);
- if (cap[ch] == 0)
- cap[ch] = p->g->ncategories++;
+ EMIT(OCHAR, (sopno)(unsigned char)ch);
+ if (cap[ch] == 0) {
+ _DIAGASSERT(__type_fit(unsigned char,
+ p->g->ncategories + 1));
+ cap[ch] = (unsigned char)p->g->ncategories++;
+ }
}
}
/*
- repeat - generate code for a bounded repetition, recursively if needed
- == static void repeat(struct parse *p, sopno start, int from, int to);
+ == 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) */
+ int to, /* to this number of times (maybe INFINITY) */
+ size_t reclimit)
{
sopno finish;
# define N 2
_DIAGASSERT(p != NULL);
- finish = HERE();
-
- if (p->error != 0) /* head off possible runaway recursion */
+ 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, 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);
+ repeat(p, start+1, 1, to, reclimit);
ASTERN(OOR1, start);
AHEAD(start); /* ... fix it */
EMIT(OOR2, 0);
ASTERN(O_CH, THERETHERE());
copy = dupl(p, start+1, finish+1);
assert(copy == finish+4);
- repeat(p, copy, 1, to-1);
+ repeat(p, copy, 1, to-1, reclimit);
break;
case REP(1, INF): /* as x+ */
INSERT(OPLUS_, start);
break;
case REP(N, N): /* as xx{m-1,n-1} */
copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to-1);
+ 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);
+ repeat(p, copy, from-1, to, reclimit);
break;
default: /* "can't happen" */
SETERROR(REG_ASSERT); /* just in case */
allocset(
struct parse *p)
{
- int no;
+ size_t no;
size_t nc;
size_t nbytes;
cset *cs;
size_t css;
- int i;
+ size_t i;
_DIAGASSERT(p != NULL);
nc = p->ncsalloc;
assert(nc % CHAR_BIT == 0);
nbytes = nc / CHAR_BIT * css;
+ if (MEMSIZE(p) > MEMLIMIT)
+ goto oomem;
if (p->g->sets == NULL)
p->g->sets = malloc(nc * sizeof(cset));
else
(void) memset((char *)p->g->setbits + (nbytes - css),
0, css);
else {
+oomem:
no = 0;
SETERROR(REG_ESPACE);
/* caller's responsibility not to do set ops */
+ return NULL;
}
}
- assert(p->g->sets != NULL); /* xxx */
cs = &p->g->sets[no];
cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
- cs->mask = 1 << ((no) % CHAR_BIT);
+ cs->mask = 1 << (unsigned int)((no) % CHAR_BIT);
cs->hash = 0;
cs->smultis = 0;
cs->multis = NULL;
css = (size_t)p->g->csetsize;
for (i = 0; i < css; i++)
- CHsub(cs, i);
+ CHsub(cs, (int)i);
if (cs == top-1) /* recover only the easy case */
p->g->ncsets--;
}
* is done using addition rather than xor -- all ASCII [aA] sets xor to
* the same value!
*/
-static int /* set number */
+static sopno /* set number */
freezeset(
struct parse *p,
cset *cs)
cs = cs2;
}
- return((int)(cs - p->g->sets));
+ return (sopno)(cs - p->g->sets);
}
/*
int c)
{
uch *col;
- int i;
- int ncols;
+ 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)
int c2)
{
uch *col;
- int i;
- int ncols;
+ size_t i;
+ size_t ncols;
unsigned uc1 = (unsigned char)c1;
unsigned uc2 = (unsigned char)c2;
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++)
assert(finish >= start);
if (len == 0)
return(ret);
- enlarge(p, p->ssize + len); /* this many unexpected additions */
- assert(p->ssize >= p->slen + len);
+ 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;
sop op,
sopno opnd)
{
-
_DIAGASSERT(p != NULL);
/* avoid making error situations worse */
/* deal with undersized strip */
if (p->slen >= p->ssize)
- enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
- assert(p->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(op, opnd);
+ p->strip[p->slen++] = (sop)SOP(op, opnd);
}
/*
return;
assert(value < 1<<OPSHIFT);
- p->strip[pos] = OP(p->strip[pos]) | value;
+ p->strip[pos] = (sop)(OP(p->strip[pos]) | value);
}
/*
- enlarge - enlarge the strip
== static void enlarge(struct parse *p, sopno size);
*/
-static void
+static int
enlarge(
struct parse *p,
sopno size)
{
sop *sp;
+ sopno osize;
_DIAGASSERT(p != NULL);
if (p->ssize >= size)
- return;
+ return 1;
- sp = (sop *)realloc(p->strip, size*sizeof(sop));
+ osize = p->ssize;
+ p->ssize = size;
+ if (MEMSIZE(p) > MEMLIMIT)
+ goto oomem;
+ sp = realloc(p->strip, p->ssize * sizeof(sop));
if (sp == NULL) {
+oomem:
+ p->ssize = osize;
SETERROR(REG_ESPACE);
- return;
+ return 0;
}
p->strip = sp;
- p->ssize = size;
+ return 1;
}
/*
-.\" $NetBSD: regex.3,v 1.21 2010/03/22 19:30:54 joerg Exp $
+.\" $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.
it should have been the result from the most recent
.Fn regcomp
using that
-.Fa regex_t . (
-.Fn regerror
+.Fa regex_t .
+.Po Fn regerror
may be able to supply a more detailed message using information
from the
-.Fa regex_t . )
+.Fa regex_t . Pc
.Fn regerror
places the NUL-terminated message into the buffer pointed to by
.Fa errbuf ,
-/* $NetBSD: regex2.h,v 1.12 2009/02/12 05:06:54 lukem Exp $ */
+/* $NetBSD: regex2.h,v 1.13 2011/10/09 18:23:00 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* immediately *preceding* "execution" of that operator.
*/
typedef u_int32_t sop; /* strip operator */
-typedef int sopno;
+typedef size_t sopno;
#define OPRMASK ((u_int32_t)0xf8000000UL)
#define OPDMASK ((u_int32_t)0x07ffffffUL)
#define OPSHIFT ((unsigned)27)
int magic;
# define MAGIC2 ((('R'^0200)<<8)|'E')
sop *strip; /* malloced area for strip */
- int csetsize; /* number of bits in a cset vector */
- int ncsets; /* number of csets in use */
+ 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 */
# define USEBOL 01 /* used ^ */
# define USEEOL 02 /* used $ */
# define BAD 04 /* something wrong */
- int nbol; /* number of ^ used */
- int neol; /* number of $ used */
- int ncategories; /* how many character categories */
+ 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 */
- int mlen; /* length of must */
+ 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? */
-/* $NetBSD: regexec.c,v 1.21 2009/02/12 05:06:54 lukem Exp $ */
+/* $NetBSD: regexec.c,v 1.22 2012/03/13 21:13:43 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
#if 0
static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regexec.c,v 1.21 2009/02/12 05:06:54 lukem Exp $");
+__RCSID("$NetBSD: regexec.c,v 1.22 2012/03/13 21:13:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#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) = (n))
+#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! */
-/* $NetBSD: herror.c,v 1.8 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: herror.c,v 1.9 2012/03/13 21:13:43 christos Exp $ */
/*
* Copyright (c) 1987, 1993
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.8 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: herror.c,v 1.9 2012/03/13 21:13:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
DE_CONST("\n", t);
v->iov_base = t;
v->iov_len = 1;
- writev(STDERR_FILENO, iov, (v - iov) + 1);
+ (void)writev(STDERR_FILENO, iov, (int)((v - iov) + 1));
}
/*%
-/* $NetBSD: res_comp.c,v 1.10 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: res_comp.c,v 1.12 2012/03/13 21:13:43 christos Exp $ */
/*
* Copyright (c) 1985, 1993
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.10 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: res_comp.c,v 1.12 2012/03/13 21:13:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
+#include <assert.h>
#include <ctype.h>
#include <resolv.h>
#include <stdio.h>
u_char **dnptrs, u_char **lastdnptr)
{
return (ns_name_compress(src, dst, (size_t)dstsiz,
- (const u_char **)dnptrs,
- (const u_char **)lastdnptr));
+ (void *)dnptrs,
+ (void *)lastdnptr));
}
/*%
if (ns_name_skip(&ptr, eom) == -1)
return (-1);
- return (ptr - saveptr);
+ _DIAGASSERT(__type_fit(int, ptr - saveptr));
+ return (int)(ptr - saveptr);
}
/*%
-/* $NetBSD: res_debug.c,v 1.11 2009/04/12 17:07:17 christos Exp $ */
+/* $NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $ */
/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_debug.c,v 1.19 2009/02/26 11:20:20 tbox Exp";
#else
-__RCSID("$NetBSD: res_debug.c,v 1.11 2009/04/12 17:07:17 christos Exp $");
+__RCSID("$NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <arpa/inet.h>
#include <arpa/nameser.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
/*
* Print answer records.
*/
- sflag = (statp->pfcode & pflag);
+ sflag = (int)(statp->pfcode & pflag);
if (statp->pfcode && !sflag)
return;
p_type(ns_rr_type(rr)),
p_class(ns_rr_class(rr)));
else if (section == ns_s_ar && ns_rr_type(rr) == ns_t_opt) {
- u_int16_t optcode, optlen, rdatalen = ns_rr_rdlen(rr);
- u_int32_t ttl = ns_rr_ttl(rr);
+ size_t rdatalen, ttl;
+ uint16_t optcode, optlen;
+
+ rdatalen = ns_rr_rdlen(rr);
+ ttl = ns_rr_ttl(rr);
fprintf(file,
- "; EDNS: version: %u, udp=%u, flags=%04x\n",
+ "; EDNS: version: %zu, udp=%u, flags=%04zx\n",
(ttl>>16)&0xff, ns_rr_class(rr), ttl&0xffff);
while (rdatalen >= 4) {
char name[MAXDNAME];
int n;
- if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0)
+ if ((n = dn_expand(msg, msg + len, cp, name, (int)sizeof name)) < 0)
return (NULL);
if (name[0] == '\0')
putc('.', file);
length supplied). */
const u_char *
-p_fqnname(cp, msg, msglen, name, namelen)
- const u_char *cp, *msg;
- int msglen;
- char *name;
- int namelen;
+p_fqnname(const u_char *cp, const u_char *msg, int msglen, char *name,
+ int namelen)
{
- int n, newlen;
+ int n;
+ size_t newlen;
if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)
return (NULL);
newlen = strlen(name);
if (newlen == 0 || name[newlen - 1] != '.') {
- if (newlen + 1 >= namelen) /*%< Lack space for final dot */
+ if ((int)newlen + 1 >= namelen) /*%< Lack space for final dot */
return (NULL);
else
strcpy(name + newlen, ".");
char name[MAXDNAME];
const u_char *n;
- n = p_fqnname(cp, msg, MAXCDNAME, name, sizeof name);
+ n = p_fqnname(cp, msg, MAXCDNAME, name, (int)sizeof name);
if (n == NULL)
return (NULL);
fputs(name, file);
switch (u.sin.sin_family) {
case AF_INET:
- inet_ntop(AF_INET, &u.sin.sin_addr, ret, sizeof ret);
+ inet_ntop(AF_INET, &u.sin.sin_addr, ret, (socklen_t)sizeof ret);
break;
#ifdef HAS_INET6_STRUCTS
case AF_INET6:
* converts a zone file representation in a string to an RDATA on-the-wire
* representation. */
int
-loc_aton(ascii, binary)
- const char *ascii;
- u_char *binary;
+loc_aton(const char *ascii, u_char *binary)
{
const char *cp, *maxcp;
u_char *bcp;
/*% takes an on-the-wire LOC RR and formats it in a human readable format. */
const char *
-loc_ntoa(binary, ascii)
- const u_char *binary;
- char *ascii;
+loc_ntoa(const u_char *binary, char *ascii)
{
static const char *error = "?";
static char tmpbuf[sizeof
/*% Return the number of DNS hierarchy levels in the name. */
int
dn_count_labels(const char *name) {
- int i, len, count;
+ size_t len, i, count;
len = strlen(name);
for (i = 0, count = 0; i < len; i++) {
/* count to include last label */
if (len > 0 && name[len-1] != '.')
count++;
- return (count);
+ _DIAGASSERT(__type_fit(int, count));
+ return (int)count;
}
/*%
-/* $NetBSD: res_debug.h,v 1.1.1.4 2009/04/12 16:35:47 christos Exp $ */
+/* $NetBSD: res_debug.h,v 1.2 2012/03/13 21:13:43 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
# define Dprint(cond, args) if (cond) {fprintf args;} else {}
# define DprintQ(cond, args, query, size) if (cond) {\
fprintf args;\
- res_pquery(statp, query, size, stdout);\
+ res_pquery(statp, (query), (int)(size), stdout);\
} else {}
#endif
-/* $NetBSD: res_init.c,v 1.22 2009/10/24 17:24:01 christos Exp $ */
+/* $NetBSD: res_init.c,v 1.26 2012/09/09 18:04:26 christos Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static const char rcsid[] = "Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp";
#else
-__RCSID("$NetBSD: res_init.c,v 1.22 2009/10/24 17:24:01 christos Exp $");
+__RCSID("$NetBSD: res_init.c,v 1.26 2012/09/09 18:04:26 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/systeminfo.h>
#endif
-static void res_setoptions __P((res_state, const char *, const char *));
+static void res_setoptions(res_state, const char *, const char *);
#ifdef RESOLVSORT
static const char sort_mask[] = "/&";
#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
-static u_int32_t net_mask __P((struct in_addr));
+static uint32_t net_mask(struct in_addr);
#endif
#if !defined(isascii) /*%< XXX - could be a function */
line[sizeof(name) - 1] == '\t'))
nserv = 0;
- if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+ if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
struct stat st;
#ifndef __minix
struct kevent kc;
#endif /* !__minix */
/* read the config file */
- while (fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, (int)sizeof(buf), fp) != NULL) {
/* skip comments */
if (*buf == ';' || *buf == '#')
continue;
__res_conf_time = statp->_u._ext.ext->res_conf_time =
st.st_mtimespec;
#ifndef __minix
- statp->_u._ext.ext->kq = kqueue();
- (void)fcntl(statp->_u._ext.ext->kq, F_SETFD, FD_CLOEXEC);
- (void)fcntl(statp->_u._ext.ext->resfd, F_SETFD, FD_CLOEXEC);
+ statp->_u._ext.ext->kq = kqueue1(O_CLOEXEC);
EV_SET(&kc, statp->_u._ext.ext->resfd, EVFILT_VNODE,
EV_ADD|EV_ENABLE|EV_CLEAR, NOTE_DELETE|NOTE_WRITE| NOTE_EXTEND|
NOTE_ATTRIB|NOTE_LINK|NOTE_RENAME|NOTE_REVOKE, 0, 0);
{
const char *cp = options;
int i;
+ size_t j;
struct __res_state_ext *ext = statp->_u._ext.ext;
#ifdef DEBUG
} else if (!strncmp(cp, "no-check-names",
sizeof("no-check-names") - 1)) {
statp->options |= RES_NOCHECKNAME;
+ } else if (!strncmp(cp, "check-names",
+ sizeof("check-names") - 1)) {
+ statp->options &= ~RES_NOCHECKNAME;
}
#ifdef RES_USE_EDNS0
else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
if (ext == NULL)
goto skip;
cp += sizeof("nibble:") - 1;
- i = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix) - 1);
- strncpy(ext->nsuffix, cp, (size_t)i);
- ext->nsuffix[i] = '\0';
+ j = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix) - 1);
+ strncpy(ext->nsuffix, cp, j);
+ ext->nsuffix[j] = '\0';
}
else if (!strncmp(cp, "nibble2:", sizeof("nibble2:") - 1)) {
if (ext == NULL)
goto skip;
cp += sizeof("nibble2:") - 1;
- i = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix2) - 1);
- strncpy(ext->nsuffix2, cp, (size_t)i);
- ext->nsuffix2[i] = '\0';
+ j = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix2) - 1);
+ strncpy(ext->nsuffix2, cp, j);
+ ext->nsuffix2[j] = '\0';
}
else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
cp += sizeof("v6revmode:") - 1;
#ifdef RESOLVSORT
/* XXX - should really support CIDR which means explicit masks always. */
-static u_int32_t
-net_mask(in) /*!< XXX - should really use system's version of this */
- struct in_addr in;
+static uint32_t
+net_mask(struct in_addr in) /*!< XXX - should really use system's version of this */
{
- register u_int32_t i = ntohl(in.s_addr);
+ register uint32_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (htonl(IN_CLASSA_NET));
res_rndinit(res_state statp)
{
struct timeval now;
- u_int32_t u32;
- u_int16_t u16;
+ uint32_t u32;
+ uint16_t u16;
u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
gettimeofday(&now, NULL);
- u32 = (u_int32_t)now.tv_sec;
+ u32 = (uint32_t)now.tv_sec;
memcpy(rnd, &u32, 4);
u32 = now.tv_usec;
memcpy(rnd + 4, &u32, 4);
- u32 += (u_int32_t)now.tv_sec;
+ u32 += (uint32_t)now.tv_sec;
memcpy(rnd + 8, &u32, 4);
u16 = getpid();
memcpy(rnd + 12, &u16, 2);
}
u_int
-res_nrandomid(res_state statp) {
+res_nrandomid(res_state statp)
+{
struct timeval now;
- u_int16_t u16;
+ uint16_t u16;
MD5_CTX ctx;
u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
gettimeofday(&now, NULL);
- u16 = (u_int16_t) (now.tv_sec ^ now.tv_usec);
+ u16 = (uint16_t) (now.tv_sec ^ now.tv_usec);
memcpy(rnd + 14, &u16, 2);
#ifndef HAVE_MD5
MD5_Init(&ctx);
* This routine is not expected to be user visible.
*/
void
-res_nclose(res_state statp) {
+res_nclose(res_state statp)
+{
int ns;
if (statp->_vcsock >= 0) {
}
void
-res_ndestroy(res_state statp) {
+res_ndestroy(res_state statp)
+{
res_nclose(statp);
if (statp->_u._ext.ext != NULL) {
if (statp->_u._ext.ext->kq != -1)
}
const char *
-res_get_nibblesuffix(res_state statp) {
+res_get_nibblesuffix(res_state statp)
+{
if (statp->_u._ext.ext)
return (statp->_u._ext.ext->nsuffix);
return ("ip6.arpa");
}
const char *
-res_get_nibblesuffix2(res_state statp) {
+res_get_nibblesuffix2(res_state statp)
+{
if (statp->_u._ext.ext)
return (statp->_u._ext.ext->nsuffix2);
return ("ip6.int");
}
void
-res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
+res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt)
+{
int i, nserv;
size_t size;
}
int
-res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) {
+res_getservers(res_state statp, union res_sockaddr_union *set, int cnt)
+{
int i;
size_t size;
- u_int16_t family;
+ uint16_t family;
for (i = 0; i < statp->nscount && i < cnt; i++) {
if (statp->_u._ext.ext)
-/* $NetBSD: res_mkquery.c,v 1.12 2009/04/12 19:43:37 christos Exp $ */
+/* $NetBSD: res_mkquery.c,v 1.13 2012/03/13 21:13:43 christos Exp $ */
/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp";
#else
-__RCSID("$NetBSD: res_mkquery.c,v 1.12 2009/04/12 19:43:37 christos Exp $");
+__RCSID("$NetBSD: res_mkquery.c,v 1.13 2012/03/13 21:13:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
+#include <assert.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
case NS_NOTIFY_OP:
if (ep - cp < QFIXEDSZ)
return (-1);
- if ((n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs,
+ if ((n = dn_comp(dname, cp, (int)(ep - cp - QFIXEDSZ), dnptrs,
lastdnptr)) < 0)
return (-1);
cp += n;
*/
if ((ep - cp) < RRFIXEDSZ)
return (-1);
- n = dn_comp((const char *)data, cp, ep - cp - RRFIXEDSZ,
+ n = dn_comp((const char *)data, cp, (int)(ep - cp - RRFIXEDSZ),
dnptrs, lastdnptr);
if (n < 0)
return (-1);
default:
return (-1);
}
- return (cp - buf);
+ _DIAGASSERT(__type_fit(int, cp - buf));
+ return (int)(cp - buf);
}
#ifdef RES_USE_EDNS0
hp->arcount = htons(ntohs(hp->arcount) + 1);
- return (cp - buf);
+ _DIAGASSERT(__type_fit(int, cp - buf));
+ return (int)(cp - buf);
}
/*
memcpy(cp, data, (size_t)len);
cp += len;
- len = cp - rdata;
+ _DIAGASSERT(__type_fit(u_short, cp - rdata));
+ len = (u_short)(cp - rdata);
ns_put16(len, rdata - 2); /* Update RDLEN field */
- return (cp - buf);
+ _DIAGASSERT(__type_fit(int, cp - buf));
+ return (int)(cp - buf);
}
#endif
-/* $NetBSD: res_query.c,v 1.13 2009/10/24 21:37:57 christos Exp $ */
+/* $NetBSD: res_query.c,v 1.14 2012/03/13 21:13:44 christos Exp $ */
/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka Exp";
#else
-__RCSID("$NetBSD: res_query.c,v 1.13 2009/10/24 21:37:57 christos Exp $");
+__RCSID("$NetBSD: res_query.c,v 1.14 2012/03/13 21:13:44 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
- buf, sizeof(buf));
+ buf, (int)sizeof(buf));
#ifdef RES_USE_EDNS0
if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
(statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC|RES_NSID)) != 0U) {
- n = res_nopt(statp, n, buf, sizeof(buf), anslen);
+ n = res_nopt(statp, n, buf, (int)sizeof(buf), anslen);
rdata = &buf[n];
if (n > 0 && (statp->options & RES_NSID) != 0U) {
- n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
- NS_OPT_NSID, 0, NULL);
+ n = res_nopt_rdata(statp, n, buf, (int)sizeof(buf),
+ rdata, NS_OPT_NSID, 0, NULL);
}
}
#endif
{
char nbuf[MAXDNAME];
const char *longname = nbuf;
- int n, d;
+ size_t n, d;
#ifdef DEBUG
if (statp->options & RES_DEBUG)
RES_SET_H_ERRNO(statp, NO_RECOVERY);
return (-1);
}
- n--;
- if (n >= 0 && name[n] == '.') {
- strncpy(nbuf, name, (size_t)n);
+ if (n && name[--n] == '.') {
+ strncpy(nbuf, name, n);
nbuf[n] = '\0';
} else
longname = name;
if (file == NULL || (fp = fopen(file, "r")) == NULL)
return (NULL);
buf[sizeof(buf) - 1] = '\0';
- while (fgets(buf, sizeof(buf), fp)) {
+ while (fgets(buf, (int)sizeof(buf), fp)) {
for (cp1 = buf; *cp1 && !isspace((unsigned char)*cp1); ++cp1)
;
if (!*cp1)
-/* $NetBSD: res_send.c,v 1.20 2009/10/24 17:24:01 christos Exp $ */
+/* $NetBSD: res_send.c,v 1.25 2012/03/21 00:34:54 christos Exp $ */
/*
* Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp";
#else
-__RCSID("$NetBSD: res_send.c,v 1.20 2009/10/24 17:24:01 christos Exp $");
+__RCSID("$NetBSD: res_send.c,v 1.25 2012/03/21 00:34:54 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <arpa/nameser.h>
#include <arpa/inet.h>
+#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#ifndef USE_POLL
static const int highestFD = FD_SETSIZE - 1;
-#else
-static int highestFD = 0;
#endif
/* Forward. */
-static int get_salen __P((const struct sockaddr *));
-static struct sockaddr * get_nsaddr __P((res_state, size_t));
+static int get_salen(const struct sockaddr *);
+static struct sockaddr * get_nsaddr(res_state, size_t);
static int send_vc(res_state, const u_char *, int,
u_char *, int, int *, int);
static int send_dg(res_state, const u_char *, int,
char tname[MAXDNAME+1];
int n, ttype, tclass;
- n = dn_expand(buf, eom, cp, tname, sizeof tname);
+ n = dn_expand(buf, eom, cp, tname, (int)sizeof tname);
if (n < 0)
return (-1);
cp += n;
char tname[MAXDNAME+1];
int n, ttype, tclass;
- n = dn_expand(buf1, eom1, cp, tname, sizeof tname);
+ n = dn_expand(buf1, eom1, cp, tname, (int)sizeof tname);
if (n < 0)
return (-1);
cp += n;
int gotsomewhere, terrno, tries, v_circuit, resplen, ns, n;
char abuf[NI_MAXHOST];
-#ifdef USE_POLL
- highestFD = sysconf(_SC_OPEN_MAX) - 1;
-#endif
-
(void)res_check(statp, NULL);
/* No name servers or res_init() failure */
}
Dprint(((statp->options & RES_DEBUG) &&
- getnameinfo(nsap, (socklen_t)nsaplen, abuf, sizeof(abuf),
- NULL, 0, niflags) == 0),
+ getnameinfo(nsap, (socklen_t)nsaplen, abuf,
+ (socklen_t)sizeof(abuf), NULL, 0, niflags) == 0),
(stdout, ";; Querying server (# %d) address = %s\n",
ns + 1, abuf));
/* Private */
static int
-get_salen(sa)
- const struct sockaddr *sa;
+get_salen(const struct sockaddr *sa)
{
#ifdef HAVE_SA_LEN
* pick appropriate nsaddr_list for use. see res_init() for initialization.
*/
static struct sockaddr *
-get_nsaddr(statp, n)
- res_state statp;
- size_t n;
+get_nsaddr(res_state statp, size_t n)
{
if (!statp->nsaddr_list[n].sin_family && EXT(statp).ext) {
HEADER *anhp = (HEADER *)(void *)ans;
struct sockaddr *nsap;
int nsaplen;
- int truncating, connreset, resplen, n;
+ int truncating, connreset, resplen;
+ ssize_t n;
struct iovec iov[2];
u_short len;
u_char *cp;
res_nclose(statp);
statp->_vcsock = socket(nsap->sa_family, SOCK_STREAM, 0);
+#ifndef USE_POLL
if (statp->_vcsock > highestFD) {
res_nclose(statp);
errno = ENOTSOCK;
}
+#endif
if (statp->_vcsock < 0) {
switch (errno) {
case EPROTONOSUPPORT:
* Push on even if setsockopt(SO_NOSIGPIPE) fails.
*/
(void)setsockopt(statp->_vcsock, SOL_SOCKET, SO_NOSIGPIPE, &on,
- sizeof(on));
+ (unsigned int)sizeof(on));
#endif
errno = 0;
if (connect(statp->_vcsock, nsap, (socklen_t)nsaplen) < 0) {
len = INT16SZ;
while ((n = read(statp->_vcsock, (char *)cp, (size_t)len)) > 0) {
cp += n;
- if ((len -= n) == 0)
+ if ((len -= (u_short)n) == 0)
break;
}
if (n <= 0) {
cp = ans;
while (len != 0 && (n = read(statp->_vcsock, (char *)cp, (size_t)len)) > 0){
cp += n;
- len -= n;
+ len -= (u_short)n;
}
if (n <= 0) {
*terrno = errno;
n = read(statp->_vcsock, junk,
(len > sizeof junk) ? sizeof junk : len);
if (n > 0)
- len -= n;
+ len -= (u_short)n;
else
break;
}
struct timespec now, timeout, finish;
struct sockaddr_storage from;
ISC_SOCKLEN_T fromlen;
- int resplen, seconds, n, s;
+ ssize_t resplen;
+ int seconds, n, s;
#ifdef USE_POLL
int polltimeout;
struct pollfd pollfd;
nsaplen = get_salen(nsap);
if (EXT(statp).nssocks[ns] == -1) {
EXT(statp).nssocks[ns] = socket(nsap->sa_family, SOCK_DGRAM, 0);
+#ifndef USE_POLL
if (EXT(statp).nssocks[ns] > highestFD) {
res_nclose(statp);
errno = ENOTSOCK;
}
+#endif
if (EXT(statp).nssocks[ns] < 0) {
switch (errno) {
case EPROTONOSUPPORT:
if (seconds <= 0)
seconds = 1;
now = evNowTime();
- timeout = evConsTime((long)seconds, 0L);
+ timeout = evConsTime((time_t)seconds, 0L);
finish = evAddTime(now, timeout);
goto nonow;
wait:
#else
timeout = evSubTime(finish, now);
if (timeout.tv_sec < 0)
- timeout = evConsTime(0L, 0L);
+ timeout = evConsTime((time_t)0, 0L);
polltimeout = 1000*(int)timeout.tv_sec +
(int)timeout.tv_nsec/1000000;
pollfd.fd = s;
* Undersized message.
*/
Dprint(statp->options & RES_DEBUG,
- (stdout, ";; undersized: %d\n",
+ (stdout, ";; undersized: %zd\n",
resplen));
*terrno = EMSGSIZE;
res_nclose(statp);
DprintQ((statp->options & RES_DEBUG) ||
(statp->pfcode & RES_PRF_REPLY),
(stdout, ";; wrong query name:\n"),
- ans, (resplen > anssiz) ? anssiz : resplen);
+ ans, (int)(resplen > anssiz) ? anssiz : resplen);
goto wait;
}
if (anhp->rcode == SERVFAIL ||
anhp->rcode == REFUSED) {
DprintQ(statp->options & RES_DEBUG,
(stdout, "server rejected query:\n"),
- ans, (resplen > anssiz) ? anssiz : resplen);
+ ans, (int)(resplen > anssiz) ? anssiz : resplen);
res_nclose(statp);
/* don't retry if called from dig */
if (!statp->pfcode)
* All is well, or the error is fatal. Signal that the
* next nameserver ought not be tried.
*/
- return (resplen);
+ _DIAGASSERT(__type_fit(int, resplen));
+ return (int)resplen;
}
static void
char sbuf[NI_MAXSERV];
if ((statp->options & RES_DEBUG) != 0U) {
- if (getnameinfo(address, (socklen_t)alen, hbuf, sizeof(hbuf),
- sbuf, sizeof(sbuf), niflags)) {
+ if (getnameinfo(address, (socklen_t)alen, hbuf,
+ (socklen_t)sizeof(hbuf), sbuf, (socklen_t)sizeof(sbuf),
+ niflags)) {
strncpy(hbuf, "?", sizeof(hbuf) - 1);
hbuf[sizeof(hbuf) - 1] = '\0';
strncpy(sbuf, "?", sizeof(sbuf) - 1);
-# $NetBSD: Makefile.inc,v 1.17 2008/10/25 19:07:26 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.21 2012/08/10 12:20:10 joerg Exp $
# librpc sources
.PATH: ${.CURDIR}/rpc
svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_generic.c svc_raw.c \
svc_run.c svc_simple.c svc_vc.c \
xdr.c xdr_array.c xdr_float.c xdr_mem.c xdr_rec.c xdr_reference.c \
- xdr_stdio.c __rpc_getxid.c
+ xdr_stdio.c xdr_sizeof.c __rpc_getxid.c
CPPFLAGS+= -DPORTMAP
xdr.3 xdr_reference.3 \
xdr.3 xdr_setpos.3 \
xdr.3 xdr_short.3 \
+ xdr.3 xdr_sizeof.3 \
xdr.3 xdrstdio_create.3 \
xdr.3 xdr_string.3 \
xdr.3 xdr_u_char.3 \
xdr.3 xdr_vector.3 \
xdr.3 xdr_void.3 \
xdr.3 xdr_wrapstring.3
+
+# XXX
+.if ${HAVE_GCC:U} == 45 || ${MACHINE} == "vax"
+COPTS.xdr_float.c+= -fno-strict-aliasing
+.endif
-/* $NetBSD: auth_none.c,v 1.14 2001/01/16 15:46:52 lukem Exp $ */
+/* $NetBSD: auth_none.c,v 1.15 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: auth_none.c,v 1.14 2001/01/16 15:46:52 lukem Exp $");
+__RCSID("$NetBSD: auth_none.c,v 1.15 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* Authenticator operations routines
*/
-static bool_t authnone_marshal __P((AUTH *, XDR *));
-static void authnone_verf __P((AUTH *));
-static bool_t authnone_validate __P((AUTH *, struct opaque_auth *));
-static bool_t authnone_refresh __P((AUTH *));
-static void authnone_destroy __P((AUTH *));
+static bool_t authnone_marshal(AUTH *, XDR *);
+static void authnone_verf(AUTH *);
+static bool_t authnone_validate(AUTH *, struct opaque_auth *);
+static bool_t authnone_refresh(AUTH *);
+static void authnone_destroy(AUTH *);
static const struct auth_ops ops = {
authnone_verf,
} *authnone_private;
AUTH *
-authnone_create()
+authnone_create(void)
{
struct authnone_private *ap = authnone_private;
XDR xdr_stream;
/*ARGSUSED*/
static bool_t
-authnone_marshal(client, xdrs)
- AUTH *client;
- XDR *xdrs;
+authnone_marshal(AUTH *client, XDR *xdrs)
{
struct authnone_private *ap = authnone_private;
/*ARGSUSED*/
static void
-authnone_verf(client)
- AUTH *client;
+authnone_verf(AUTH *client)
{
}
/*ARGSUSED*/
static bool_t
-authnone_validate(client, auth)
- AUTH *client;
- struct opaque_auth *auth;
+authnone_validate(AUTH *client, struct opaque_auth *auth)
{
return (TRUE);
/*ARGSUSED*/
static bool_t
-authnone_refresh(client)
- AUTH *client;
+authnone_refresh(AUTH *client)
{
return (FALSE);
/*ARGSUSED*/
static void
-authnone_destroy(client)
- AUTH *client;
+authnone_destroy(AUTH *client)
{
}
-/* $NetBSD: auth_unix.c,v 1.22 2009/01/11 02:46:29 christos Exp $ */
+/* $NetBSD: auth_unix.c,v 1.23 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: auth_unix.c,v 1.22 2009/01/11 02:46:29 christos Exp $");
+__RCSID("$NetBSD: auth_unix.c,v 1.23 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
/* auth_unix.c */
-static void authunix_nextverf __P((AUTH *));
-static bool_t authunix_marshal __P((AUTH *, XDR *));
-static bool_t authunix_validate __P((AUTH *, struct opaque_auth *));
-static bool_t authunix_refresh __P((AUTH *));
-static void authunix_destroy __P((AUTH *));
-static void marshal_new_auth __P((AUTH *));
-static const struct auth_ops *authunix_ops __P((void));
+static void authunix_nextverf(AUTH *);
+static bool_t authunix_marshal(AUTH *, XDR *);
+static bool_t authunix_validate(AUTH *, struct opaque_auth *);
+static bool_t authunix_refresh(AUTH *);
+static void authunix_destroy(AUTH *);
+static void marshal_new_auth(AUTH *);
+static const struct auth_ops *authunix_ops(void);
/*
* This struct is pointed to by the ah_private field of an auth_handle.
* Returns an auth handle with the given stuff in it.
*/
AUTH *
-authunix_create(machname, uid, gid, len, aup_gids)
- char *machname;
- int uid;
- int gid;
- int len;
- int *aup_gids;
+authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
{
struct authunix_parms aup;
char mymem[MAX_AUTH_BYTES];
* syscalls.
*/
AUTH *
-authunix_create_default()
+authunix_create_default(void)
{
int len;
char machname[MAXHOSTNAMELEN + 1];
/* ARGSUSED */
static void
-authunix_nextverf(auth)
- AUTH *auth;
+authunix_nextverf(AUTH *auth)
{
/* no action necessary */
}
static bool_t
-authunix_marshal(auth, xdrs)
- AUTH *auth;
- XDR *xdrs;
+authunix_marshal(AUTH *auth, XDR *xdrs)
{
struct audata *au;
}
static bool_t
-authunix_validate(auth, verf)
- AUTH *auth;
- struct opaque_auth *verf;
+authunix_validate(AUTH *auth, struct opaque_auth *verf)
{
struct audata *au;
XDR xdrs;
}
static bool_t
-authunix_refresh(auth)
- AUTH *auth;
+authunix_refresh(AUTH *auth)
{
struct audata *au = AUTH_PRIVATE(auth);
struct authunix_parms aup;
}
static void
-authunix_destroy(auth)
- AUTH *auth;
+authunix_destroy(AUTH *auth)
{
struct audata *au;
* sets private data, au_marshed and au_mpos
*/
static void
-marshal_new_auth(auth)
- AUTH *auth;
+marshal_new_auth(AUTH *auth)
{
XDR xdr_stream;
XDR *xdrs = &xdr_stream;
}
static const struct auth_ops *
-authunix_ops()
+authunix_ops(void)
{
static struct auth_ops ops;
#ifdef _REENTRANT
-/* $NetBSD: authunix_prot.c,v 1.13 2006/05/11 17:11:57 mrg Exp $ */
+/* $NetBSD: authunix_prot.c,v 1.15 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: authunix_prot.c,v 1.13 2006/05/11 17:11:57 mrg Exp $");
+__RCSID("$NetBSD: authunix_prot.c,v 1.15 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* XDR for unix authentication parameters.
*/
bool_t
-xdr_authunix_parms(xdrs, p)
- XDR *xdrs;
- struct authunix_parms *p;
+xdr_authunix_parms(XDR *xdrs, struct authunix_parms *p)
{
_DIAGASSERT(xdrs != NULL);
&& xdr_int(xdrs, &(p->aup_uid))
&& xdr_int(xdrs, &(p->aup_gid))
&& xdr_array(xdrs, (char **)(void *)&(p->aup_gids),
- &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) {
+ &(p->aup_len), NGRPS, (unsigned int)sizeof(int),
+ (xdrproc_t)xdr_int) ) {
return (TRUE);
}
return (FALSE);
-/* $NetBSD: bindresvport.c,v 1.21 2003/01/18 11:29:03 thorpej Exp $ */
+/* $NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)bindresvport.c 1.8 88/02/08 SMI";
static char *sccsid = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: bindresvport.c,v 1.21 2003/01/18 11:29:03 thorpej Exp $");
+__RCSID("$NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* Bind a socket to a privileged IP port
*/
int
-bindresvport(sd, brsin)
- int sd;
- struct sockaddr_in *brsin;
+bindresvport(int sd, struct sockaddr_in *brsin)
{
return bindresvport_sa(sd, (struct sockaddr *)(void *)brsin);
}
* Bind a socket to a privileged IP port
*/
int
-bindresvport_sa(sd, sa)
- int sd;
- struct sockaddr *sa;
+bindresvport_sa(int sd, struct sockaddr *sa)
{
int error, old;
struct sockaddr_storage myaddr;
if (error < 0)
return (error);
error = setsockopt(sd, proto, portrange, &portlow,
- sizeof(portlow));
+ (socklen_t)sizeof(portlow));
if (error < 0)
return (error);
}
if (error < 0) {
if (setsockopt(sd, proto, portrange, &old,
- sizeof(old)) < 0)
+ (socklen_t)sizeof(old)) < 0)
errno = saved_errno;
return (error);
}
-/* $NetBSD: clnt_bcast.c,v 1.22 2010/03/07 23:49:14 dholland Exp $ */
+/* $NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: clnt_bcast.c,v 1.22 2010/03/07 23:49:14 dholland Exp $");
+__RCSID("$NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
typedef TAILQ_HEAD(, broadif) broadlist_t;
-int __rpc_getbroadifs __P((int, int, int, broadlist_t *));
-void __rpc_freebroadifs __P((broadlist_t *));
-int __rpc_broadenable __P((int, int, struct broadif *));
+int __rpc_getbroadifs(int, int, int, broadlist_t *);
+void __rpc_freebroadifs(broadlist_t *);
+int __rpc_broadenable(int, int, struct broadif *);
int __rpc_lowvers = 0;
return -1;
} else
#endif
- if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o, sizeof o) < 0)
+ if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o,
+ (socklen_t)sizeof(o)) == -1)
return -1;
return 0;
enum clnt_stat
-rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
- eachresult, inittime, waittime, nettype)
- rpcprog_t prog; /* program number */
- rpcvers_t vers; /* version number */
- rpcproc_t proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- const char * argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- resultproc_t eachresult; /* call with each result obtained */
- int inittime; /* how long to wait initially */
- int waittime; /* maximum time to wait */
- const char *nettype; /* transport type */
+rpc_broadcast_exp(
+ rpcprog_t prog, /* program number */
+ rpcvers_t vers, /* version number */
+ rpcproc_t proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ const char * argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ resultproc_t eachresult, /* call with each result obtained */
+ int inittime, /* how long to wait initially */
+ int waittime, /* maximum time to wait */
+ const char * nettype) /* transport type */
{
enum clnt_stat stat = RPC_SUCCESS; /* Return status */
XDR xdr_stream; /* XDR stream */
broadlist_t nal;
} fdlist[MAXBCAST];
struct pollfd pfd[MAXBCAST];
- size_t fdlistno = 0;
+ nfds_t fdlistno = 0;
struct r_rpcb_rmtcallargs barg; /* Remote arguments */
struct r_rpcb_rmtcallres bres; /* Remote results */
size_t outlen;
if (!__rpc_lowvers)
if ((size_t)sendto(fdlist[i].fd, outbuf,
outlen, 0, (struct sockaddr*)addr,
- (size_t)fdlist[i].asize) !=
+ (socklen_t)fdlist[i].asize) !=
outlen) {
warn("clnt_bcast: cannot send"
" broadcast packet");
fdlist[i].proto == IPPROTO_UDP) {
if ((size_t)sendto(fdlist[i].fd,
outbuf_pmap, outlen_pmap, 0, addr,
- (size_t)fdlist[i].asize) !=
+ (socklen_t)fdlist[i].asize) !=
outlen_pmap) {
warnx("clnt_bcast: "
"Cannot send "
enum clnt_stat
-rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
- eachresult, nettype)
- rpcprog_t prog; /* program number */
- rpcvers_t vers; /* version number */
- rpcproc_t proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- const char * argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- resultproc_t eachresult; /* call with each result obtained */
- const char *nettype; /* transport type */
+rpc_broadcast(
+ rpcprog_t prog, /* program number */
+ rpcvers_t vers, /* version number */
+ rpcproc_t proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ const char * argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ resultproc_t eachresult, /* call with each result obtained */
+ const char * nettype) /* transport type */
{
enum clnt_stat dummy;
-/* $NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#define RPC_MAX_BACKOFF 30 /* seconds */
-static struct clnt_ops *clnt_dg_ops __P((void));
-static bool_t time_not_ok __P((struct timeval *));
-static enum clnt_stat clnt_dg_call __P((CLIENT *, rpcproc_t, xdrproc_t,
- const char *, xdrproc_t, caddr_t, struct timeval));
-static void clnt_dg_geterr __P((CLIENT *, struct rpc_err *));
-static bool_t clnt_dg_freeres __P((CLIENT *, xdrproc_t, caddr_t));
-static void clnt_dg_abort __P((CLIENT *));
-static bool_t clnt_dg_control __P((CLIENT *, u_int, char *));
-static void clnt_dg_destroy __P((CLIENT *));
+static struct clnt_ops *clnt_dg_ops(void);
+static bool_t time_not_ok(struct timeval *);
+static enum clnt_stat clnt_dg_call(CLIENT *, rpcproc_t, xdrproc_t,
+ const char *, xdrproc_t, caddr_t, struct timeval);
+static void clnt_dg_geterr(CLIENT *, struct rpc_err *);
+static bool_t clnt_dg_freeres(CLIENT *, xdrproc_t, caddr_t);
+static void clnt_dg_abort(CLIENT *);
+static bool_t clnt_dg_control(CLIENT *, u_int, char *);
+static void clnt_dg_destroy(CLIENT *);
* If svcaddr is NULL, returns NULL.
*/
CLIENT *
-clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
- int fd; /* open file descriptor */
- const struct netbuf *svcaddr; /* servers address */
- rpcprog_t program; /* program number */
- rpcvers_t version; /* version number */
- u_int sendsz; /* buffer recv size */
- u_int recvsz; /* buffer send size */
+clnt_dg_create(
+ int fd, /* open file descriptor */
+ const struct netbuf *svcaddr, /* servers address */
+ rpcprog_t program, /* program number */
+ rpcvers_t version, /* version number */
+ u_int sendsz, /* buffer recv size */
+ u_int recvsz) /* buffer send size */
{
CLIENT *cl = NULL; /* client handle */
struct cu_data *cu = NULL; /* private data */
}
static enum clnt_stat
-clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
- CLIENT *cl; /* client handle */
- rpcproc_t proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- const char * argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- struct timeval utimeout; /* seconds to wait before giving up */
+clnt_dg_call(
+ CLIENT * cl, /* client handle */
+ rpcproc_t proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ const char * argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ struct timeval utimeout) /* seconds to wait before giving up */
{
struct cu_data *cu;
XDR *xdrs;
cu->cu_error.re_status = RPC_CANTRECV;
goto out;
}
- if (recvlen >= (ssize_t)sizeof(uint32_t) &&
- (*((uint32_t *)(void *)(cu->cu_inbuf)) ==
- *((uint32_t *)(void *)(cu->cu_outbuf)))) {
- /* We now assume we have the proper reply. */
- break;
- }
+ if (recvlen >= (ssize_t)sizeof(uint32_t)) {
+ if (memcmp(cu->cu_inbuf, cu->cu_outbuf,
+ sizeof(uint32_t)) == 0)
+ /* Assume we have the proper reply. */
+ break;
+ }
}
if (n == -1) {
cu->cu_error.re_errno = errno;
}
static void
-clnt_dg_geterr(cl, errp)
- CLIENT *cl;
- struct rpc_err *errp;
+clnt_dg_geterr(CLIENT *cl, struct rpc_err *errp)
{
struct cu_data *cu;
}
static bool_t
-clnt_dg_freeres(cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
{
struct cu_data *cu;
XDR *xdrs;
/*ARGSUSED*/
static void
-clnt_dg_abort(h)
- CLIENT *h;
+clnt_dg_abort(CLIENT *h)
{
}
static bool_t
-clnt_dg_control(cl, request, info)
- CLIENT *cl;
- u_int request;
- char *info;
+clnt_dg_control(CLIENT *cl, u_int request, char *info)
{
struct cu_data *cu;
struct netbuf *addr;
}
static void
-clnt_dg_destroy(cl)
- CLIENT *cl;
+clnt_dg_destroy(CLIENT *cl)
{
struct cu_data *cu;
int cu_fd;
}
static struct clnt_ops *
-clnt_dg_ops()
+clnt_dg_ops(void)
{
static struct clnt_ops ops;
#ifdef _REENTRANT
* Make sure that the time is not garbage. -1 value is allowed.
*/
static bool_t
-time_not_ok(t)
- struct timeval *t;
+time_not_ok(struct timeval *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: clnt_generic.c,v 1.27 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: clnt_generic.c,v 1.28 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: clnt_generic.c,v 1.27 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: clnt_generic.c,v 1.28 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* if this can not be done.
*/
CLIENT *
-clnt_create_vers(hostname, prog, vers_out, vers_low, vers_high, nettype)
- const char *hostname;
- rpcprog_t prog;
- rpcvers_t *vers_out;
- rpcvers_t vers_low;
- rpcvers_t vers_high;
- const char *nettype;
+clnt_create_vers(
+ const char * hostname,
+ rpcprog_t prog,
+ rpcvers_t * vers_out,
+ rpcvers_t vers_low,
+ rpcvers_t vers_high,
+ const char * nettype)
{
CLIENT *clnt;
struct timeval to;
* It calls clnt_tp_create();
*/
CLIENT *
-clnt_create(hostname, prog, vers, nettype)
- const char *hostname; /* server name */
- rpcprog_t prog; /* program number */
- rpcvers_t vers; /* version number */
- const char *nettype; /* net type */
+clnt_create(
+ const char * hostname, /* server name */
+ rpcprog_t prog, /* program number */
+ rpcvers_t vers, /* version number */
+ const char * nettype) /* net type */
{
struct netconfig *nconf;
CLIENT *clnt = NULL;
* It finds out the server address from rpcbind and calls clnt_tli_create()
*/
CLIENT *
-clnt_tp_create(hostname, prog, vers, nconf)
- const char *hostname; /* server name */
- rpcprog_t prog; /* program number */
- rpcvers_t vers; /* version number */
- const struct netconfig *nconf; /* net config struct */
+clnt_tp_create(
+ const char * hostname, /* server name */
+ rpcprog_t prog, /* program number */
+ rpcvers_t vers, /* version number */
+ const struct netconfig *nconf) /* net config struct */
{
struct netbuf *svcaddr; /* servers address */
CLIENT *cl = NULL; /* client handle */
* If sizes are 0; appropriate defaults will be chosen.
*/
CLIENT *
-clnt_tli_create(fd, nconf, svcaddr, prog, vers, sendsz, recvsz)
- int fd; /* fd */
- const struct netconfig *nconf; /* netconfig structure */
- const struct netbuf *svcaddr; /* servers address */
- rpcprog_t prog; /* program number */
- rpcvers_t vers; /* version number */
- u_int sendsz; /* send size */
- u_int recvsz; /* recv size */
+clnt_tli_create(
+ int fd, /* fd */
+ const struct netconfig *nconf, /* netconfig structure */
+ const struct netbuf *svcaddr, /* servers address */
+ rpcprog_t prog, /* program number */
+ rpcvers_t vers, /* version number */
+ u_int sendsz, /* send size */
+ u_int recvsz) /* recv size */
{
CLIENT *cl; /* client handle */
bool_t madefd = FALSE; /* whether fd opened here */
-/* $NetBSD: clnt_perror.c,v 1.28 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: clnt_perror.c,v 1.29 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: clnt_perror.c,v 1.28 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: clnt_perror.c,v 1.29 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
static char *buf;
static size_t buflen;
-static char *_buf __P((void));
-static char *auth_errmsg __P((enum auth_stat));
+static char *_buf(void);
+static char *auth_errmsg(enum auth_stat);
static char *
-_buf()
+_buf(void)
{
buflen = 256;
* Print reply error info
*/
char *
-clnt_sperror(rpch, s)
- CLIENT *rpch;
- const char *s;
+clnt_sperror(CLIENT *rpch, const char *s)
{
struct rpc_err e;
char *err;
}
void
-clnt_perror(rpch, s)
- CLIENT *rpch;
- const char *s;
+clnt_perror(CLIENT *rpch, const char *s)
{
_DIAGASSERT(rpch != NULL);
* This interface for use by clntrpc
*/
char *
-clnt_sperrno(stat)
- enum clnt_stat stat;
+clnt_sperrno(enum clnt_stat stat)
{
unsigned int errnum = stat;
const char *msg;
}
void
-clnt_perrno(num)
- enum clnt_stat num;
+clnt_perrno(enum clnt_stat num)
{
(void) fprintf(stderr, "%s\n", clnt_sperrno(num));
}
char *
-clnt_spcreateerror(s)
- const char *s;
+clnt_spcreateerror(const char *s)
{
char *str;
size_t len, i;
}
void
-clnt_pcreateerror(s)
- const char *s;
+clnt_pcreateerror(const char *s)
{
_DIAGASSERT(s != NULL);
};
static char *
-auth_errmsg(stat)
- enum auth_stat stat;
+auth_errmsg(enum auth_stat stat)
{
unsigned int errnum = stat;
- if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0])))
+ if (errnum < __arraycount(auth_errlist))
return __UNCONST(auth_errlist[errnum]);
return(NULL);
-/* $NetBSD: clnt_raw.c,v 1.29 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: clnt_raw.c,v 1.30 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: clnt_raw.c,v 1.29 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: clnt_raw.c,v 1.30 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
u_int mcnt;
} *clntraw_private;
-static enum clnt_stat clnt_raw_call __P((CLIENT *, rpcproc_t, xdrproc_t,
- const char *, xdrproc_t, caddr_t, struct timeval));
-static void clnt_raw_geterr __P((CLIENT *, struct rpc_err *));
-static bool_t clnt_raw_freeres __P((CLIENT *, xdrproc_t, caddr_t));
-static void clnt_raw_abort __P((CLIENT *));
-static bool_t clnt_raw_control __P((CLIENT *, u_int, char *));
-static void clnt_raw_destroy __P((CLIENT *));
-static struct clnt_ops *clnt_raw_ops __P((void));
+static enum clnt_stat clnt_raw_call(CLIENT *, rpcproc_t, xdrproc_t,
+ const char *, xdrproc_t, caddr_t, struct timeval);
+static void clnt_raw_geterr(CLIENT *, struct rpc_err *);
+static bool_t clnt_raw_freeres(CLIENT *, xdrproc_t, caddr_t);
+static void clnt_raw_abort(CLIENT *);
+static bool_t clnt_raw_control(CLIENT *, u_int, char *);
+static void clnt_raw_destroy(CLIENT *);
+static struct clnt_ops *clnt_raw_ops(void);
/*
* Create a client handle for memory based rpc.
*/
CLIENT *
-clnt_raw_create(prog, vers)
- rpcprog_t prog;
- rpcvers_t vers;
+clnt_raw_create(rpcprog_t prog, rpcvers_t vers)
{
struct clntraw_private *clp = clntraw_private;
struct rpc_msg call_msg;
/* ARGSUSED */
static enum clnt_stat
-clnt_raw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
- CLIENT *h;
- rpcproc_t proc;
- xdrproc_t xargs;
- const char *argsp;
- xdrproc_t xresults;
- caddr_t resultsp;
- struct timeval timeout;
+clnt_raw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, const char *argsp,
+ xdrproc_t xresults, caddr_t resultsp, struct timeval timeout)
{
struct clntraw_private *clp = clntraw_private;
XDR *xdrs = &clp->xdr_stream;
/*ARGSUSED*/
static void
-clnt_raw_geterr(cl, error)
- CLIENT *cl;
- struct rpc_err *error;
+clnt_raw_geterr(CLIENT *cl, struct rpc_err *error)
{
}
/* ARGSUSED */
static bool_t
-clnt_raw_freeres(cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+clnt_raw_freeres(CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
{
struct clntraw_private *clp = clntraw_private;
XDR *xdrs = &clp->xdr_stream;
/*ARGSUSED*/
static void
-clnt_raw_abort(cl)
- CLIENT *cl;
+clnt_raw_abort(CLIENT *cl)
{
}
/*ARGSUSED*/
static bool_t
-clnt_raw_control(cl, ui, str)
- CLIENT *cl;
- u_int ui;
- char *str;
+clnt_raw_control(CLIENT *cl, u_int ui, char *str)
{
return (FALSE);
}
/*ARGSUSED*/
static void
-clnt_raw_destroy(cl)
- CLIENT *cl;
+clnt_raw_destroy(CLIENT *cl)
{
}
static struct clnt_ops *
-clnt_raw_ops()
+clnt_raw_ops(void)
{
static struct clnt_ops ops;
#ifdef _REENTRANT
-/* $NetBSD: clnt_simple.c,v 1.30 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: clnt_simple.c,v 1.31 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)clnt_simple.c 1.49 89/01/31 Copyr 1984 Sun Micro";
#else
-__RCSID("$NetBSD: clnt_simple.c,v 1.30 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: clnt_simple.c,v 1.31 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
static struct rpc_call_private *rpc_call_private_main;
#ifdef _REENTRANT
-static void rpc_call_destroy __P((void *));
+static void rpc_call_destroy(void *);
static void
rpc_call_destroy(void *vp)
* The total time available is 25 seconds.
*/
enum clnt_stat
-rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
- const char *host; /* host name */
- rpcprog_t prognum; /* program number */
- rpcvers_t versnum; /* version number */
- rpcproc_t procnum; /* procedure number */
- xdrproc_t inproc, outproc; /* in/out XDR procedures */
- const char *in;
- char *out; /* recv/send data */
- const char *nettype; /* nettype */
+rpc_call(
+ const char * host, /* host name */
+ rpcprog_t prognum, /* program number */
+ rpcvers_t versnum, /* version number */
+ rpcproc_t procnum, /* procedure number */
+ xdrproc_t inproc, /* in XDR procedures */
+ const char * in, /* recv data */
+ xdrproc_t outproc, /* out XDR procedures */
+ char * out, /* send data */
+ const char * nettype) /* nettype */
{
struct rpc_call_private *rcp = (struct rpc_call_private *) 0;
enum clnt_stat clnt_stat;
-/* $NetBSD: clnt_vc.c,v 1.17 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: clnt_vc.c,v 1.18 2012/03/13 21:13:44 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
static char sccsid[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: clnt_vc.c,v 1.17 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: clnt_vc.c,v 1.18 2012/03/13 21:13:44 christos Exp $");
#endif
#endif
#define MCALL_MSG_SIZE 24
-static enum clnt_stat clnt_vc_call __P((CLIENT *, rpcproc_t, xdrproc_t,
- const char *, xdrproc_t, caddr_t, struct timeval));
-static void clnt_vc_geterr __P((CLIENT *, struct rpc_err *));
-static bool_t clnt_vc_freeres __P((CLIENT *, xdrproc_t, caddr_t));
-static void clnt_vc_abort __P((CLIENT *));
-static bool_t clnt_vc_control __P((CLIENT *, u_int, char *));
-static void clnt_vc_destroy __P((CLIENT *));
-static struct clnt_ops *clnt_vc_ops __P((void));
-static bool_t time_not_ok __P((struct timeval *));
-static int read_vc __P((caddr_t, caddr_t, int));
-static int write_vc __P((caddr_t, caddr_t, int));
+static enum clnt_stat clnt_vc_call(CLIENT *, rpcproc_t, xdrproc_t,
+ const char *, xdrproc_t, caddr_t, struct timeval);
+static void clnt_vc_geterr(CLIENT *, struct rpc_err *);
+static bool_t clnt_vc_freeres(CLIENT *, xdrproc_t, caddr_t);
+static void clnt_vc_abort(CLIENT *);
+static bool_t clnt_vc_control(CLIENT *, u_int, char *);
+static void clnt_vc_destroy(CLIENT *);
+static struct clnt_ops *clnt_vc_ops(void);
+static bool_t time_not_ok(struct timeval *);
+static int read_vc(caddr_t, caddr_t, int);
+static int write_vc(caddr_t, caddr_t, int);
struct ct_data {
int ct_fd;
* fd should be an open socket
*/
CLIENT *
-clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
- int fd;
- const struct netbuf *raddr;
- rpcprog_t prog;
- rpcvers_t vers;
- u_int sendsz;
- u_int recvsz;
+clnt_vc_create(
+ int fd,
+ const struct netbuf *raddr,
+ rpcprog_t prog,
+ rpcvers_t vers,
+ u_int sendsz,
+ u_int recvsz
+)
{
CLIENT *h;
struct ct_data *ct = NULL;
}
static enum clnt_stat
-clnt_vc_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
- CLIENT *h;
- rpcproc_t proc;
- xdrproc_t xdr_args;
- const char *args_ptr;
- xdrproc_t xdr_results;
- caddr_t results_ptr;
- struct timeval timeout;
+clnt_vc_call(
+ CLIENT *h,
+ rpcproc_t proc,
+ xdrproc_t xdr_args,
+ const char *args_ptr,
+ xdrproc_t xdr_results,
+ caddr_t results_ptr,
+ struct timeval timeout
+)
{
struct ct_data *ct;
XDR *xdrs;
}
static void
-clnt_vc_geterr(h, errp)
- CLIENT *h;
- struct rpc_err *errp;
+clnt_vc_geterr(
+ CLIENT *h,
+ struct rpc_err *errp
+)
{
struct ct_data *ct;
}
static bool_t
-clnt_vc_freeres(cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+clnt_vc_freeres(
+ CLIENT *cl,
+ xdrproc_t xdr_res,
+ caddr_t res_ptr
+)
{
struct ct_data *ct;
XDR *xdrs;
/*ARGSUSED*/
static void
-clnt_vc_abort(cl)
- CLIENT *cl;
+clnt_vc_abort(CLIENT *cl)
{
}
static bool_t
-clnt_vc_control(cl, request, info)
- CLIENT *cl;
- u_int request;
- char *info;
+clnt_vc_control(
+ CLIENT *cl,
+ u_int request,
+ char *info
+)
{
struct ct_data *ct;
void *infop = info;
static void
-clnt_vc_destroy(cl)
- CLIENT *cl;
+clnt_vc_destroy(CLIENT *cl)
{
struct ct_data *ct;
#ifdef _REENTRANT
* around for the rpc level.
*/
static int
-read_vc(ctp, buf, len)
- caddr_t ctp;
- caddr_t buf;
- int len;
+read_vc(char *ctp, char *buf, int len)
{
struct ct_data *ct = (struct ct_data *)(void *)ctp;
struct pollfd fd;
struct timespec ts;
+ ssize_t nread;
if (len == 0)
return (0);
}
break;
}
- switch (len = read(ct->ct_fd, buf, (size_t)len)) {
+ switch (nread = read(ct->ct_fd, buf, (size_t)len)) {
case 0:
/* premature eof */
ct->ct_error.re_status = RPC_CANTRECV;
break;
}
- return (len);
+ return (int)nread;
}
static int
-write_vc(ctp, buf, len)
- caddr_t ctp;
- caddr_t buf;
- int len;
+write_vc(char *ctp, char *buf, int len)
{
struct ct_data *ct = (struct ct_data *)(void *)ctp;
- int i, cnt;
+ ssize_t i;
+ size_t cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- if ((i = write(ct->ct_fd, buf, (size_t)cnt)) == -1) {
+ if ((i = write(ct->ct_fd, buf, cnt)) == -1) {
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTSEND;
return (-1);
}
}
- return (len);
+ return len;
}
static struct clnt_ops *
-clnt_vc_ops()
+clnt_vc_ops(void)
{
static struct clnt_ops ops;
#ifdef _REENTRANT
* Note this is different from time_not_ok in clnt_dg.c
*/
static bool_t
-time_not_ok(t)
- struct timeval *t;
+time_not_ok(struct timeval *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: getnetconfig.c,v 1.18 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: getnetconfig.c,v 1.20 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)getnetconfig.c 1.12 91/12/19 SMI";
#else
-__RCSID("$NetBSD: getnetconfig.c,v 1.18 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: getnetconfig.c,v 1.20 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#define NC_INVALID 0
-static int *__nc_error __P((void));
-static int parse_ncp __P((char *, struct netconfig *));
-static struct netconfig *dup_ncp __P((struct netconfig *));
+static int *__nc_error(void);
+static int parse_ncp(char *, struct netconfig *);
+static struct netconfig *dup_ncp(struct netconfig *);
static FILE *nc_file; /* for netconfig db */
#endif
static int *
-__nc_error()
+__nc_error(void)
{
#ifdef _REENTRANT
int *nc_addr = NULL;
* the netconfig database is not present).
*/
void *
-setnetconfig()
+setnetconfig(void)
{
struct netconfig_vars *nc_vars;
* handle without reopening the netconfig db.
*/
ni.ref++;
- if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "r")) != NULL) {
+ if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "re")) != NULL) {
nc_vars->valid = NC_VALID;
nc_vars->flag = 0;
nc_vars->nc_configs = ni.head;
*/
struct netconfig *
-getnetconfig(handlep)
- void *handlep;
+getnetconfig(void *handlep)
{
struct netconfig_vars *ncp = (struct netconfig_vars *)handlep;
char *stringp; /* tmp string pointer */
* previously).
*/
int
-endnetconfig(handlep)
- void *handlep;
+endnetconfig(void *handlep)
{
struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep;
*/
struct netconfig *
-getnetconfigent(netid)
- const char *netid;
+getnetconfigent(const char *netid)
{
FILE *file; /* NETCONFIG db's file pointer */
char *linep; /* holds current netconfig line */
*/
void
-freenetconfigent(netconfigp)
- struct netconfig *netconfigp;
+freenetconfigent(struct netconfig *netconfigp)
{
if (netconfigp != NULL) {
/* holds all netconfigp's strings */
*/
static int
-parse_ncp(stringp, ncp)
- char *stringp; /* string to parse */
- struct netconfig *ncp; /* where to put results */
+parse_ncp(
+ char *stringp, /* string to parse */
+ struct netconfig *ncp) /* where to put results */
{
char *tokenp; /* for processing tokens */
char *lasts;
* Returns a string describing the reason for failure.
*/
char *
-nc_sperror()
+nc_sperror(void)
{
const char *message;
* Prints a message onto standard error describing the reason for failure.
*/
void
-nc_perror(s)
- const char *s;
+nc_perror(const char *s)
{
_DIAGASSERT(s != NULL);
* Duplicates the matched netconfig buffer.
*/
static struct netconfig *
- dup_ncp(ncp)
- struct netconfig *ncp;
+dup_ncp(struct netconfig *ncp)
{
struct netconfig *p;
char *tmp;
-/* $NetBSD: getnetpath.c,v 1.14 2008/05/24 16:04:15 christos Exp $ */
+/* $NetBSD: getnetpath.c,v 1.16 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)getnetpath.c 1.11 91/12/19 SMI";
#else
-__RCSID("$NetBSD: getnetpath.c,v 1.14 2008/05/24 16:04:15 christos Exp $");
+__RCSID("$NetBSD: getnetpath.c,v 1.16 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
#define NP_VALID 0xf00d
#define NP_INVALID 0
-char *_get_next_token __P((char *, int));
+char *_get_next_token(char *, int);
/*
*/
void *
-setnetpath()
+setnetpath(void)
{
struct netpath_vars *np_sessionp; /* this session's variables */
char *npp; /* NETPATH env variable */
*/
struct netconfig *
-getnetpath(handlep)
- void *handlep;
+getnetpath(void *handlep)
{
struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep;
struct netconfig *ncp = NULL; /* temp. holds a netconfig session */
* (e.g. if setnetpath() was not called previously.
*/
int
-endnetpath(handlep)
- void *handlep;
+endnetpath(void *handlep)
{
struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep;
struct netpath_chain *chainp, *lastp;
-/* $NetBSD: getrpcent.c,v 1.21 2004/08/16 02:47:54 ginsbach Exp $ */
+/* $NetBSD: getrpcent.c,v 1.22 2011/10/15 23:00:02 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char *sccsid = "@(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";
#else
-__RCSID("$NetBSD: getrpcent.c,v 1.21 2004/08/16 02:47:54 ginsbach Exp $");
+__RCSID("$NetBSD: getrpcent.c,v 1.22 2011/10/15 23:00:02 christos Exp $");
#endif
#endif
if (d == 0)
return;
if (d->rpcf == NULL)
- d->rpcf = fopen(RPCDB, "r");
+ d->rpcf = fopen(RPCDB, "re");
else
rewind(d->rpcf);
d->stayopen |= f;
if (d == 0)
return(NULL);
- if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
+ if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "re")) == NULL)
return (NULL);
if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
return (NULL);
-/* $NetBSD: getrpcport.c,v 1.16 2000/01/22 22:19:18 mycroft Exp $ */
+/* $NetBSD: getrpcport.c,v 1.17 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)getrpcport.c 1.3 87/08/11 SMI";
static char *sccsid = "@(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: getrpcport.c,v 1.16 2000/01/22 22:19:18 mycroft Exp $");
+__RCSID("$NetBSD: getrpcport.c,v 1.17 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#endif
int
-getrpcport(host, prognum, versnum, proto)
- char *host;
- int prognum, versnum, proto;
+getrpcport(char *host, int prognum, int versnum, int proto)
{
struct sockaddr_in addr;
struct hostent *hp;
-/* $NetBSD: mt_misc.c,v 1.8 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: mt_misc.c,v 1.9 2012/03/20 17:14:50 matt Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: mt_misc.c,v 1.8 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: mt_misc.c,v 1.9 2012/03/20 17:14:50 matt Exp $");
#endif
#include "namespace.h"
#endif /* _REENTRANT */
struct rpc_createerr*
-__rpc_createerr()
+__rpc_createerr(void)
{
#ifdef _REENTRANT
struct rpc_createerr *rce_addr = 0;
return &rpc_createerr;
#endif
}
-
-/* $NetBSD: pmap_getmaps.c,v 1.16 2000/07/06 03:10:34 christos Exp $ */
+/* $NetBSD: pmap_getmaps.c,v 1.17 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: pmap_getmaps.c,v 1.16 2000/07/06 03:10:34 christos Exp $");
+__RCSID("$NetBSD: pmap_getmaps.c,v 1.17 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
-pmap_getmaps(address)
- struct sockaddr_in *address;
+pmap_getmaps(struct sockaddr_in *address)
{
struct pmaplist *head = NULL;
int sock = -1;
-/* $NetBSD: pmap_prot.c,v 1.10 2000/01/22 22:19:18 mycroft Exp $ */
+/* $NetBSD: pmap_prot.c,v 1.11 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: pmap_prot.c,v 1.10 2000/01/22 22:19:18 mycroft Exp $");
+__RCSID("$NetBSD: pmap_prot.c,v 1.11 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
bool_t
-xdr_pmap(xdrs, regs)
- XDR *xdrs;
- struct pmap *regs;
+xdr_pmap(XDR *xdrs, struct pmap *regs)
{
_DIAGASSERT(xdrs != NULL);
-/* $NetBSD: pmap_prot2.c,v 1.15 2001/01/04 14:42:20 lukem Exp $ */
+/* $NetBSD: pmap_prot2.c,v 1.16 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: pmap_prot2.c,v 1.15 2001/01/04 14:42:20 lukem Exp $");
+__RCSID("$NetBSD: pmap_prot2.c,v 1.16 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* this sounds like a job for xdr_reference!
*/
bool_t
-xdr_pmaplist(xdrs, rp)
- XDR *xdrs;
- struct pmaplist **rp;
+xdr_pmaplist(XDR *xdrs, struct pmaplist **rp)
{
/*
* more_elements is pre-computed in case the direction is
* functionality to xdr_pmaplist().
*/
bool_t
-xdr_pmaplist_ptr(xdrs, rp)
- XDR *xdrs;
- struct pmaplist *rp;
+xdr_pmaplist_ptr(XDR *xdrs, struct pmaplist *rp)
{
_DIAGASSERT(xdrs != NULL);
-/* $NetBSD: pmap_rmt.c,v 1.30 2010/03/23 20:28:59 drochner Exp $ */
+/* $NetBSD: pmap_rmt.c,v 1.33 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: pmap_rmt.c,v 1.30 2010/03/23 20:28:59 drochner Exp $");
+__RCSID("$NetBSD: pmap_rmt.c,v 1.33 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
* programs to do a lookup and call in one step.
*/
enum clnt_stat
-pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout,
- port_ptr)
- struct sockaddr_in *addr;
- u_long prog, vers, proc;
- xdrproc_t xdrargs, xdrres;
- caddr_t argsp, resp;
- struct timeval tout;
- u_long *port_ptr;
+pmap_rmtcall(struct sockaddr_in *addr, u_long prog, u_long vers, u_long proc,
+ xdrproc_t xdrargs, caddr_t argsp, xdrproc_t xdrres, caddr_t resp,
+ struct timeval tout, u_long *port_ptr)
{
int sock = -1;
CLIENT *client;
* written for XDR_ENCODE direction only
*/
bool_t
-xdr_rmtcall_args(xdrs, cap)
- XDR *xdrs;
- struct rmtcallargs *cap;
+xdr_rmtcall_args(XDR *xdrs, struct rmtcallargs *cap)
{
u_int lenposition, argposition, position;
* written for XDR_DECODE direction only
*/
bool_t
-xdr_rmtcallres(xdrs, crp)
- XDR *xdrs;
- struct rmtcallres *crp;
+xdr_rmtcallres(XDR *xdrs, struct rmtcallres *crp)
{
caddr_t port_ptr;
_DIAGASSERT(crp != NULL);
port_ptr = (caddr_t)(void *)crp->port_ptr;
- if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
+ if (xdr_reference(xdrs, &port_ptr, (u_int)sizeof(u_long),
(xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
crp->port_ptr = (u_long *)(void *)port_ptr;
return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
.\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" $NetBSD: rpc.3,v 1.22 2010/03/22 19:30:54 joerg Exp $
+.\" $NetBSD: rpc.3,v 1.24 2012/05/13 15:47:38 wiz Exp $
.Dd May 7, 1993
.Dt RPC 3
.Os
* structure of the data type to be decoded. If this points to 0,
* then the type routines should allocate dynamic storage of the
* appropriate size and return it.
- * bool_t (*xdrproc_t)(XDR *, caddr_t *);
*/
-typedef bool_t (*xdrproc_t)();
+typedef bool_t (*xdrproc_t)(XDR *, const void *);
/*
* The XDR handle.
.Bl -column "authunix_create_default()" "rpc_clnt_create(3)"
.It Em "RPC Routine" Ta Em "Manual Reference Page"
.Pp
-.It Fn auth_destroy Ta Xr rpc_clnt_auth 3 ,
-.It Fn authdes_create Ta Xr rpc_soc 3 ,
-.It Fn authnone_create Ta Xr rpc_clnt_auth 3 ,
-.It Fn authsys_create Ta Xr rpc_clnt_auth 3 ,
-.It Fn authsys_create_default Ta Xr rpc_clnt_auth 3 ,
-.It Fn authunix_create Ta Xr rpc_soc 3 ,
-.It Fn authunix_create_default Ta Xr rpc_soc 3 ,
-.It Fn callrpc Ta Xr rpc_soc 3 ,
-.It Fn clnt_broadcast Ta Xr rpc_soc 3 ,
-.It Fn clnt_call Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_control Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_destroy Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_dg_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_freeres Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_geterr Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_pcreateerror Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_perrno Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_perror Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_raw_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_spcreateerror Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_sperrno Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_sperror Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_tli_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_tp_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_udpcreate Ta Xr rpc_soc 3 ,
-.It Fn clnt_vc_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clntraw_create Ta Xr rpc_soc 3 ,
-.It Fn clnttcp_create Ta Xr rpc_soc 3 ,
-.It Fn clntudp_bufcreate Ta Xr rpc_soc 3 ,
-.It Fn get_myaddress Ta Xr rpc_soc 3 ,
-.It Fn pmap_getmaps Ta Xr rpc_soc 3 ,
-.It Fn pmap_getport Ta Xr rpc_soc 3 ,
-.It Fn pmap_rmtcall Ta Xr rpc_soc 3 ,
-.It Fn pmap_set Ta Xr rpc_soc 3 ,
-.It Fn pmap_unset Ta Xr rpc_soc 3 ,
-.It Fn registerrpc Ta Xr rpc_soc 3 ,
-.It Fn rpc_broadcast Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_broadcast_exp Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_call Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_reg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_destroy Ta Xr rpc_svc_create 3 ,
-.It Fn svc_dg_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_dg_enablecache Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_fd_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_fds Ta Xr rpc_soc 3 ,
-.It Fn svc_freeargs Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_getargs Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_getcaller Ta Xr rpc_soc 3 ,
-.It Fn svc_getreq Ta Xr rpc_soc 3 ,
-.It Fn svc_getreqset Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_getrpccaller Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_kerb_reg Ta Xr kerberos_rpc 3 ,
-.It Fn svc_raw_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_reg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_register Ta Xr rpc_soc 3 ,
-.It Fn svc_run Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_sendreply Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_tli_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_tp_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_unreg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_unregister Ta Xr rpc_soc 3 ,
-.It Fn svc_vc_create Ta Xr rpc_svc_create 3 ,
-.It Fn svcerr_auth Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_decode Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_noproc Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_noprog Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_progvers Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_systemerr Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_weakauth Ta Xr rpc_svc_err 3 ,
-.It Fn svcfd_create Ta Xr rpc_soc 3 ,
-.It Fn svcraw_create Ta Xr rpc_soc 3 ,
-.It Fn svctcp_create Ta Xr rpc_soc 3 ,
-.It Fn svcudp_bufcreate Ta Xr rpc_soc 3 ,
-.It Fn svcudp_create Ta Xr rpc_soc 3 ,
-.It Fn xdr_accepted_reply Ta Xr rpc_xdr 3 ,
-.It Fn xdr_authsys_parms Ta Xr rpc_xdr 3 ,
-.It Fn xdr_authunix_parms Ta Xr rpc_soc 3 ,
-.It Fn xdr_callhdr Ta Xr rpc_xdr 3 ,
-.It Fn xdr_callmsg Ta Xr rpc_xdr 3 ,
-.It Fn xdr_opaque_auth Ta Xr rpc_xdr 3 ,
-.It Fn xdr_rejected_reply Ta Xr rpc_xdr 3 ,
-.It Fn xdr_replymsg Ta Xr rpc_xdr 3 ,
-.It Fn xprt_register Ta Xr rpc_svc_calls 3 ,
-.It Fn xprt_unregister Ta Xr rpc_svc_calls 3 ,
+.It Fn auth_destroy Ta Xr rpc_clnt_auth 3
+.It Fn authdes_create Ta Xr rpc_soc 3
+.It Fn authnone_create Ta Xr rpc_clnt_auth 3
+.It Fn authsys_create Ta Xr rpc_clnt_auth 3
+.It Fn authsys_create_default Ta Xr rpc_clnt_auth 3
+.It Fn authunix_create Ta Xr rpc_soc 3
+.It Fn authunix_create_default Ta Xr rpc_soc 3
+.It Fn callrpc Ta Xr rpc_soc 3
+.It Fn clnt_broadcast Ta Xr rpc_soc 3
+.It Fn clnt_call Ta Xr rpc_clnt_calls 3
+.It Fn clnt_control Ta Xr rpc_clnt_create 3
+.It Fn clnt_create Ta Xr rpc_clnt_create 3
+.It Fn clnt_destroy Ta Xr rpc_clnt_create 3
+.It Fn clnt_dg_create Ta Xr rpc_clnt_create 3
+.It Fn clnt_freeres Ta Xr rpc_clnt_calls 3
+.It Fn clnt_geterr Ta Xr rpc_clnt_calls 3
+.It Fn clnt_pcreateerror Ta Xr rpc_clnt_create 3
+.It Fn clnt_perrno Ta Xr rpc_clnt_calls 3
+.It Fn clnt_perror Ta Xr rpc_clnt_calls 3
+.It Fn clnt_raw_create Ta Xr rpc_clnt_create 3
+.It Fn clnt_spcreateerror Ta Xr rpc_clnt_create 3
+.It Fn clnt_sperrno Ta Xr rpc_clnt_calls 3
+.It Fn clnt_sperror Ta Xr rpc_clnt_calls 3
+.It Fn clnt_tli_create Ta Xr rpc_clnt_create 3
+.It Fn clnt_tp_create Ta Xr rpc_clnt_create 3
+.It Fn clnt_udpcreate Ta Xr rpc_soc 3
+.It Fn clnt_vc_create Ta Xr rpc_clnt_create 3
+.It Fn clntraw_create Ta Xr rpc_soc 3
+.It Fn clnttcp_create Ta Xr rpc_soc 3
+.It Fn clntudp_bufcreate Ta Xr rpc_soc 3
+.It Fn get_myaddress Ta Xr rpc_soc 3
+.It Fn pmap_getmaps Ta Xr rpc_soc 3
+.It Fn pmap_getport Ta Xr rpc_soc 3
+.It Fn pmap_rmtcall Ta Xr rpc_soc 3
+.It Fn pmap_set Ta Xr rpc_soc 3
+.It Fn pmap_unset Ta Xr rpc_soc 3
+.It Fn registerrpc Ta Xr rpc_soc 3
+.It Fn rpc_broadcast Ta Xr rpc_clnt_calls 3
+.It Fn rpc_broadcast_exp Ta Xr rpc_clnt_calls 3
+.It Fn rpc_call Ta Xr rpc_clnt_calls 3
+.It Fn rpc_reg Ta Xr rpc_svc_calls 3
+.It Fn svc_create Ta Xr rpc_svc_create 3
+.It Fn svc_destroy Ta Xr rpc_svc_create 3
+.It Fn svc_dg_create Ta Xr rpc_svc_create 3
+.It Fn svc_dg_enablecache Ta Xr rpc_svc_calls 3
+.It Fn svc_fd_create Ta Xr rpc_svc_create 3
+.It Fn svc_fds Ta Xr rpc_soc 3
+.It Fn svc_freeargs Ta Xr rpc_svc_reg 3
+.It Fn svc_getargs Ta Xr rpc_svc_reg 3
+.It Fn svc_getcaller Ta Xr rpc_soc 3
+.It Fn svc_getreq Ta Xr rpc_soc 3
+.It Fn svc_getreqset Ta Xr rpc_svc_calls 3
+.It Fn svc_getrpccaller Ta Xr rpc_svc_calls 3
+.It Fn svc_kerb_reg Ta Xr kerberos_rpc 3
+.It Fn svc_raw_create Ta Xr rpc_svc_create 3
+.It Fn svc_reg Ta Xr rpc_svc_calls 3
+.It Fn svc_register Ta Xr rpc_soc 3
+.It Fn svc_run Ta Xr rpc_svc_reg 3
+.It Fn svc_sendreply Ta Xr rpc_svc_reg 3
+.It Fn svc_tli_create Ta Xr rpc_svc_create 3
+.It Fn svc_tp_create Ta Xr rpc_svc_create 3
+.It Fn svc_unreg Ta Xr rpc_svc_calls 3
+.It Fn svc_unregister Ta Xr rpc_soc 3
+.It Fn svc_vc_create Ta Xr rpc_svc_create 3
+.It Fn svcerr_auth Ta Xr rpc_svc_err 3
+.It Fn svcerr_decode Ta Xr rpc_svc_err 3
+.It Fn svcerr_noproc Ta Xr rpc_svc_err 3
+.It Fn svcerr_noprog Ta Xr rpc_svc_err 3
+.It Fn svcerr_progvers Ta Xr rpc_svc_err 3
+.It Fn svcerr_systemerr Ta Xr rpc_svc_err 3
+.It Fn svcerr_weakauth Ta Xr rpc_svc_err 3
+.It Fn svcfd_create Ta Xr rpc_soc 3
+.It Fn svcraw_create Ta Xr rpc_soc 3
+.It Fn svctcp_create Ta Xr rpc_soc 3
+.It Fn svcudp_bufcreate Ta Xr rpc_soc 3
+.It Fn svcudp_create Ta Xr rpc_soc 3
+.It Fn xdr_accepted_reply Ta Xr rpc_xdr 3
+.It Fn xdr_authsys_parms Ta Xr rpc_xdr 3
+.It Fn xdr_authunix_parms Ta Xr rpc_soc 3
+.It Fn xdr_callhdr Ta Xr rpc_xdr 3
+.It Fn xdr_callmsg Ta Xr rpc_xdr 3
+.It Fn xdr_opaque_auth Ta Xr rpc_xdr 3
+.It Fn xdr_rejected_reply Ta Xr rpc_xdr 3
+.It Fn xdr_replymsg Ta Xr rpc_xdr 3
+.It Fn xprt_register Ta Xr rpc_svc_calls 3
+.It Fn xprt_unregister Ta Xr rpc_svc_calls 3
.El
.Sh FILES
.Pa /etc/netconfig
-/* $NetBSD: rpc_callmsg.c,v 1.18 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: rpc_callmsg.c,v 1.19 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: rpc_callmsg.c,v 1.18 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: rpc_callmsg.c,v 1.19 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
* XDR a call message
*/
bool_t
-xdr_callmsg(xdrs, cmsg)
- XDR *xdrs;
- struct rpc_msg *cmsg;
+xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg)
{
int32_t *buf;
struct opaque_auth *oa;
.\" Copyright 1989 AT&T
.\" @(#)rpc_clnt_create 1.5 89/07/24 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
-.\" $NetBSD: rpc_clnt_create.3,v 1.11 2009/05/23 18:57:25 christos Exp $
+.\" $NetBSD: rpc_clnt_create.3,v 1.12 2011/05/17 03:35:39 enami Exp $
.Dd May 23, 2009
.Dt RPC_CLNT_CREATE 3
.Os
Note:
If you set the timeout value to 0
.Fn clnt_control
-immediately returns an error (
-.Dv RPC_TIMEDOUT ) .
+immediately returns an error
+.Pq Dv RPC_TIMEDOUT .
Set the timeout parameter to 0 for batching calls.
.Bl -column CLSET_FD_NCLOSE "struct timeval *" "do not close fd on destroy"
.It Dv CLGET_SVC_ADDR Ta "struct netbuf *" Ta "get servers address"
-/* $NetBSD: rpc_dtablesize.c,v 1.14 1998/11/15 17:32:43 christos Exp $ */
+/* $NetBSD: rpc_dtablesize.c,v 1.15 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
static char *sccsid = "@(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: rpc_dtablesize.c,v 1.14 1998/11/15 17:32:43 christos Exp $");
+__RCSID("$NetBSD: rpc_dtablesize.c,v 1.15 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#include <unistd.h>
-int _rpc_dtablesize __P((void)); /* XXX */
+int _rpc_dtablesize(void); /* XXX */
/*
* Cache the result of sysconf(_SC_OPEN_MAX), so we don't have to do an
* expensive system call every time.
*/
int
-_rpc_dtablesize()
+_rpc_dtablesize(void)
{
static int size;
if (size == 0)
-/* $NetBSD: rpc_generic.c,v 1.24 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: rpc_generic.c,v 1.26 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rpc_generic.c,v 1.24 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: rpc_generic.c,v 1.26 2012/03/20 17:14:50 matt Exp $");
#endif
#include "namespace.h"
};
#if 0
-static char *strlocase __P((char *));
+static char *strlocase(char *);
#endif
-static int getnettype __P((const char *));
+static int getnettype(const char *);
/*
* Cache the result of getrlimit(), so we don't have to do an
* expensive call every time.
*/
int
-__rpc_dtbsize()
+__rpc_dtbsize(void)
{
static int tbsize;
struct rlimit rl;
*/
u_int
/*ARGSUSED*/
-__rpc_get_t_size(af, proto, size)
- int af, proto;
- int size; /* Size requested */
+__rpc_get_t_size(
+ int af,
+ int proto,
+ int size) /* Size requested */
{
int maxsize, defsize;
* Find the appropriate address buffer size
*/
u_int
-__rpc_get_a_size(af)
- int af;
+__rpc_get_a_size(int af)
{
switch (af) {
case AF_INET:
#if 0
static char *
-strlocase(p)
- char *p;
+strlocase(char *p)
{
char *t = p;
* If nettype is NULL, it defaults to NETPATH.
*/
static int
-getnettype(nettype)
- const char *nettype;
+getnettype(const char *nettype)
{
int i;
#endif
struct netconfig *
-__rpc_getconfip(nettype)
- const char *nettype;
+__rpc_getconfip(const char *nettype)
{
char *netid;
char *netid_tcp = NULL;
* __rpc_getconf().
*/
void *
-__rpc_setconf(nettype)
- const char *nettype;
+__rpc_setconf(const char *nettype)
{
struct handle *handle;
* __rpc_setconf() should have been called previously.
*/
struct netconfig *
-__rpc_getconf(vhandle)
- void *vhandle;
+__rpc_getconf(void *vhandle)
{
struct handle *handle;
struct netconfig *nconf;
}
void
-__rpc_endconf(vhandle)
- void * vhandle;
+__rpc_endconf(void *vhandle)
{
struct handle *handle;
* Returns NULL if fails, else a non-NULL pointer.
*/
void *
-rpc_nullproc(clnt)
- CLIENT *clnt;
+rpc_nullproc(CLIENT *clnt)
{
struct timeval TIMEOUT = {25, 0};
* one succeeds in finding the netconf for the given fd.
*/
struct netconfig *
-__rpcgettp(fd)
- int fd;
+__rpcgettp(int fd)
{
const char *netid;
struct __rpc_sockinfo si;
switch (af) {
case AF_INET:
sinp = nbuf->buf;
- if (inet_ntop(af, &sinp->sin_addr, namebuf, sizeof namebuf)
- == NULL)
+ if (inet_ntop(af, &sinp->sin_addr, namebuf,
+ (socklen_t)sizeof namebuf) == NULL)
return NULL;
port = ntohs(sinp->sin_port);
if (asprintf(&ret, "%s.%u.%u", namebuf, ((u_int32_t)port) >> 8,
#ifdef INET6
case AF_INET6:
sin6 = nbuf->buf;
- if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6)
- == NULL)
+ if (inet_ntop(af, &sin6->sin6_addr, namebuf6,
+ (socklen_t)sizeof namebuf6) == NULL)
return NULL;
port = ntohs(sin6->sin6_port);
if (asprintf(&ret, "%s.%u.%u", namebuf6, ((u_int32_t)port) >> 8,
struct netbuf *ret = NULL;
char *addrstr, *p;
unsigned port, portlo, porthi;
+ size_t len;
struct sockaddr_in *sinp;
#ifdef INET6
struct sockaddr_in6 *sin6;
memset(sun, 0, sizeof *sun);
sun->sun_family = AF_LOCAL;
strncpy(sun->sun_path, addrstr, sizeof(sun->sun_path) - 1);
- ret->len = ret->maxlen = sun->sun_len = SUN_LEN(sun);
+ len = SUN_LEN(sun);
+ _DIAGASSERT(__type_fit(uint8_t, len));
+ ret->len = ret->maxlen = sun->sun_len = (uint8_t)len;
ret->buf = sun;
break;
default:
int one = 1;
if (si->si_proto != IPPROTO_TCP)
return 0;
- return setsockopt(fd, si->si_proto, TCP_NODELAY, &one, sizeof(one));
+ return setsockopt(fd, si->si_proto, TCP_NODELAY, &one,
+ (socklen_t)sizeof(one));
}
-/* $NetBSD: rpc_prot.c,v 1.18 2003/05/29 18:15:25 christos Exp $ */
+/* $NetBSD: rpc_prot.c,v 1.20 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: rpc_prot.c,v 1.18 2003/05/29 18:15:25 christos Exp $");
+__RCSID("$NetBSD: rpc_prot.c,v 1.20 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
__weak_alias(xdr_replymsg,_xdr_replymsg)
#endif
-static void accepted __P((enum accept_stat, struct rpc_err *));
-static void rejected __P((enum reject_stat, struct rpc_err *));
+static void accepted(enum accept_stat, struct rpc_err *);
+static void rejected(enum reject_stat, struct rpc_err *);
/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
* (see auth.h)
*/
bool_t
-xdr_opaque_auth(xdrs, ap)
- XDR *xdrs;
- struct opaque_auth *ap;
+xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
{
_DIAGASSERT(xdrs != NULL);
* XDR a DES block
*/
bool_t
-xdr_des_block(xdrs, blkp)
- XDR *xdrs;
- des_block *blkp;
+xdr_des_block(XDR *xdrs, des_block *blkp)
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(blkp != NULL);
- return (xdr_opaque(xdrs, (caddr_t)(void *)blkp, sizeof(des_block)));
+ return (xdr_opaque(xdrs, (caddr_t)(void *)blkp,
+ (u_int)sizeof(des_block)));
}
/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
* XDR the MSG_ACCEPTED part of a reply message union
*/
bool_t
-xdr_accepted_reply(xdrs, ar)
- XDR *xdrs;
- struct accepted_reply *ar;
+xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
{
_DIAGASSERT(xdrs != NULL);
* XDR the MSG_DENIED part of a reply message union
*/
bool_t
-xdr_rejected_reply(xdrs, rr)
- XDR *xdrs;
- struct rejected_reply *rr;
+xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
{
_DIAGASSERT(xdrs != NULL);
* XDR a reply message
*/
bool_t
-xdr_replymsg(xdrs, rmsg)
- XDR *xdrs;
- struct rpc_msg *rmsg;
+xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(rmsg != NULL);
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
bool_t
-xdr_callhdr(xdrs, cmsg)
- XDR *xdrs;
- struct rpc_msg *cmsg;
+xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
{
_DIAGASSERT(xdrs != NULL);
/* ************************** Client utility routine ************* */
static void
-accepted(acpt_stat, error)
- enum accept_stat acpt_stat;
- struct rpc_err *error;
+accepted(enum accept_stat acpt_stat, struct rpc_err *error)
{
_DIAGASSERT(error != NULL);
}
static void
-rejected(rjct_stat, error)
- enum reject_stat rjct_stat;
- struct rpc_err *error;
+rejected(enum reject_stat rjct_stat, struct rpc_err *error)
{
_DIAGASSERT(error != NULL);
* given a reply message, fills in the error
*/
void
-_seterr_reply(msg, error)
- struct rpc_msg *msg;
- struct rpc_err *error;
+_seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
{
_DIAGASSERT(msg != NULL);
-/* $NetBSD: rpc_soc.c,v 1.13 2010/12/08 02:06:38 joerg Exp $ */
+/* $NetBSD: rpc_soc.c,v 1.16 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: rpc_soc.c,v 1.13 2010/12/08 02:06:38 joerg Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.16 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
extern mutex_t rpcsoc_lock;
#endif
-static CLIENT *clnt_com_create __P((struct sockaddr_in *, rpcprog_t, rpcvers_t,
- int *, u_int, u_int, const char *));
-static SVCXPRT *svc_com_create __P((int, u_int, u_int, const char *));
-static bool_t rpc_wrap_bcast __P((char *, struct netbuf *, struct netconfig *));
+static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
+ int *, u_int, u_int, const char *);
+static SVCXPRT *svc_com_create(int, u_int, u_int, const char *);
+static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *);
/*
* A common clnt create routine
*/
static CLIENT *
-clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp)
- struct sockaddr_in *raddr;
- rpcprog_t prog;
- rpcvers_t vers;
- int *sockp;
- u_int sendsz;
- u_int recvsz;
- const char *tp;
+clnt_com_create(struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers,
+ int *sockp, u_int sendsz, u_int recvsz, const char *tp)
{
CLIENT *cl;
int madefd = FALSE;
}
CLIENT *
-clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz)
- struct sockaddr_in *raddr;
- u_long prog;
- u_long vers;
- struct timeval wait;
- int *sockp;
- u_int sendsz;
- u_int recvsz;
+clntudp_bufcreate(struct sockaddr_in *raddr, u_long prog, u_long vers, struct timeval wait, int *sockp, u_int sendsz, u_int recvsz)
{
CLIENT *cl;
}
CLIENT *
-clntudp_create(raddr, program, version, wait, sockp)
- struct sockaddr_in *raddr;
- u_long program;
- u_long version;
- struct timeval wait;
- int *sockp;
+clntudp_create(struct sockaddr_in *raddr, u_long program, u_long version,
+ struct timeval wait, int *sockp)
{
return clntudp_bufcreate(raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE);
}
CLIENT *
-clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
- struct sockaddr_in *raddr;
- u_long prog;
- u_long vers;
- int *sockp;
- u_int sendsz;
- u_int recvsz;
+clnttcp_create(struct sockaddr_in *raddr, u_long prog, u_long vers, int *sockp,
+ u_int sendsz, u_int recvsz)
{
return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
sendsz, recvsz, "tcp");
}
CLIENT *
-clntraw_create(prog, vers)
- u_long prog;
- u_long vers;
+clntraw_create(u_long prog, u_long vers)
{
return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers);
}
* A common server create routine
*/
static SVCXPRT *
-svc_com_create(fd, sendsize, recvsize, netid)
- int fd;
- u_int sendsize;
- u_int recvsize;
- const char *netid;
+svc_com_create(int fd, u_int sendsize, u_int recvsize, const char *netid)
{
struct netconfig *nconf;
SVCXPRT *svc;
}
SVCXPRT *
-svctcp_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+svctcp_create(int fd, u_int sendsize, u_int recvsize)
{
return svc_com_create(fd, sendsize, recvsize, "tcp");
}
SVCXPRT *
-svcudp_bufcreate(fd, sendsz, recvsz)
- int fd;
- u_int sendsz, recvsz;
+svcudp_bufcreate(int fd, u_int sendsz, u_int recvsz)
{
return svc_com_create(fd, sendsz, recvsz, "udp");
}
SVCXPRT *
-svcfd_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+svcfd_create(int fd, u_int sendsize, u_int recvsize)
{
return svc_fd_create(fd, sendsize, recvsize);
}
SVCXPRT *
-svcudp_create(fd)
- int fd;
+svcudp_create(int fd)
{
return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp");
}
SVCXPRT *
-svcraw_create()
+svcraw_create(void)
{
return svc_raw_create();
}
int
-get_myaddress(addr)
- struct sockaddr_in *addr;
+get_myaddress(struct sockaddr_in *addr)
{
_DIAGASSERT(addr != NULL);
* For connectionless "udp" transport. Obsoleted by rpc_call().
*/
int
-callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
- char *host;
- int prognum, versnum, procnum;
- xdrproc_t inproc, outproc;
- char *in, *out;
+callrpc(char *host, int prognum, int versnum, int procnum,
+ xdrproc_t inproc, char *in, xdrproc_t outproc, char *out)
{
return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum,
(rpcproc_t)procnum, inproc, in, outproc, out, "udp");
* For connectionless kind of transport. Obsoleted by rpc_reg()
*/
int
-registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
- int prognum, versnum, procnum;
- char *(*progname) __P((char [UDPMSGSIZE]));
- xdrproc_t inproc, outproc;
+registerrpc(int prognum, int versnum, int procnum,
+ char *(*progname)(char [UDPMSGSIZE]),
+ xdrproc_t inproc, xdrproc_t outproc)
{
return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum,
(rpcproc_t)procnum, progname, inproc, outproc, __UNCONST("udp"));
*/
/* ARGSUSED */
static bool_t
-rpc_wrap_bcast(resultp, addr, nconf)
- char *resultp; /* results of the call */
- struct netbuf *addr; /* address of the guy who responded */
- struct netconfig *nconf; /* Netconf of the transport */
+rpc_wrap_bcast(
+ char *resultp, /* results of the call */
+ struct netbuf *addr, /* address of the guy who responded */
+ struct netconfig *nconf) /* Netconf of the transport */
{
resultproc_t clnt_broadcast_result;
* Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
*/
enum clnt_stat
-clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
- u_long prog; /* program number */
- u_long vers; /* version number */
- u_long proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- caddr_t argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- resultproc_t eachresult; /* call with each result obtained */
+clnt_broadcast(
+ u_long prog, /* program number */
+ u_long vers, /* version number */
+ u_long proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ caddr_t argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ resultproc_t eachresult) /* call with each result obtained */
{
#ifdef _REENTRANT
if (__isthreaded == 0)
-/* $NetBSD: rpcb_clnt.c,v 1.25 2010/03/23 20:28:58 drochner Exp $ */
+/* $NetBSD: rpcb_clnt.c,v 1.27 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: rpcb_clnt.c,v 1.25 2010/03/23 20:28:58 drochner Exp $");
+__RCSID("$NetBSD: rpcb_clnt.c,v 1.27 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
extern int __rpc_lowvers;
-static struct address_cache *check_cache __P((const char *, const char *));
-static void delete_cache __P((struct netbuf *));
-static void add_cache __P((const char *, const char *, struct netbuf *,
- char *));
-static CLIENT *getclnthandle __P((const char *, const struct netconfig *,
- char **));
-static CLIENT *local_rpcb __P((void));
-static struct netbuf *got_entry __P((rpcb_entry_list_ptr,
- const struct netconfig *));
+static struct address_cache *check_cache(const char *, const char *);
+static void delete_cache(struct netbuf *);
+static void add_cache(const char *, const char *, struct netbuf *, char *);
+static CLIENT *getclnthandle(const char *, const struct netconfig *, char **);
+static CLIENT *local_rpcb(void);
+static struct netbuf *got_entry(rpcb_entry_list_ptr, const struct netconfig *);
/*
* This routine adjusts the timeout used for calls to the remote rpcbind.
* These are private routines that may not be provided in future releases.
*/
bool_t
-__rpc_control(request, info)
- int request;
- void *info;
+__rpc_control(int request, void *info)
{
_DIAGASSERT(info != NULL);
*/
static struct address_cache *
-check_cache(host, netid)
- const char *host, *netid;
+check_cache(const char *host, const char *netid)
{
struct address_cache *cptr;
}
static void
-delete_cache(addr)
- struct netbuf *addr;
+delete_cache(struct netbuf *addr)
{
struct address_cache *cptr, *prevptr = NULL;
}
static void
-add_cache(host, netid, taddr, uaddr)
- const char *host, *netid;
- char *uaddr;
- struct netbuf *taddr;
+add_cache(const char *host, const char *netid, struct netbuf *taddr,
+ char *uaddr)
{
struct address_cache *ad_cache, *cptr, *prevptr;
* rpcbind. Returns NULL on error and free's everything.
*/
static CLIENT *
-getclnthandle(host, nconf, targaddr)
- const char *host;
- const struct netconfig *nconf;
- char **targaddr;
+getclnthandle(const char *host, const struct netconfig *nconf, char **targaddr)
{
CLIENT *client;
struct netbuf *addr, taddr;
* rpcbind. Returns NULL on error and free's everything.
*/
static CLIENT *
-local_rpcb()
+local_rpcb(void)
{
CLIENT *client;
static struct netconfig *loopnconf;
goto try_nconf;
sun.sun_family = AF_LOCAL;
strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
- nbuf.len = sun.sun_len = SUN_LEN(&sun);
+ tsize = SUN_LEN(&sun);
+ _DIAGASSERT(__type_fit(uint8_t, tsize));
+ nbuf.len = sun.sun_len = (uint8_t)tsize;
nbuf.maxlen = sizeof (struct sockaddr_un);
nbuf.buf = &sun;
tsize = __rpc_get_t_size(AF_LOCAL, 0, 0);
+ _DIAGASSERT(__type_fit(u_int, tsize));
client = clnt_vc_create(sock, &nbuf, (rpcprog_t)RPCBPROG,
- (rpcvers_t)RPCBVERS, tsize, tsize);
+ (rpcvers_t)RPCBVERS, (u_int)tsize, (u_int)tsize);
if (client != NULL) {
/* XXX - mark the socket to be closed in destructor */
* Calls the rpcbind service to do the mapping.
*/
bool_t
-rpcb_set(program, version, nconf, address)
- rpcprog_t program;
- rpcvers_t version;
- const struct netconfig *nconf; /* Network structure of transport */
- const struct netbuf *address; /* Services netconfig address */
+rpcb_set(rpcprog_t program, rpcvers_t version,
+ const struct netconfig *nconf, /* Network structure of transport */
+ const struct netbuf *address) /* Services netconfig address */
{
CLIENT *client;
bool_t rslt = FALSE;
* only for the given transport.
*/
bool_t
-rpcb_unset(program, version, nconf)
- rpcprog_t program;
- rpcvers_t version;
- const struct netconfig *nconf;
+rpcb_unset(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf)
{
CLIENT *client;
bool_t rslt = FALSE;
* From the merged list, find the appropriate entry
*/
static struct netbuf *
-got_entry(relp, nconf)
- rpcb_entry_list_ptr relp;
- const struct netconfig *nconf;
+got_entry(rpcb_entry_list_ptr relp, const struct netconfig *nconf)
{
struct netbuf *na = NULL;
rpcb_entry_list_ptr sp;
* starts working properly. Also look under clnt_vc.c.
*/
struct netbuf *
-__rpcb_findaddr(program, version, nconf, host, clpp)
- rpcprog_t program;
- rpcvers_t version;
- const struct netconfig *nconf;
- const char *host;
- CLIENT **clpp;
+__rpcb_findaddr(rpcprog_t program, rpcvers_t version,
+ const struct netconfig *nconf, const char *host, CLIENT **clpp)
{
CLIENT *client = NULL;
RPCB parms;
* Assuming that the address is all properly allocated
*/
int
-rpcb_getaddr(program, version, nconf, address, host)
- rpcprog_t program;
- rpcvers_t version;
- const struct netconfig *nconf;
- struct netbuf *address;
- const char *host;
+rpcb_getaddr(rpcprog_t program, rpcvers_t version,
+ const struct netconfig *nconf, struct netbuf *address,
+ const char *host)
{
struct netbuf *na;
* It returns NULL on failure.
*/
rpcblist *
-rpcb_getmaps(nconf, host)
- const struct netconfig *nconf;
- const char *host;
+rpcb_getmaps(const struct netconfig *nconf, const char *host)
{
rpcblist_ptr head = NULL;
CLIENT *client;
* programs to do a lookup and call in one step.
*/
enum clnt_stat
-rpcb_rmtcall(nconf, host, prog, vers, proc, xdrargs, argsp,
- xdrres, resp, tout, addr_ptr)
- const struct netconfig *nconf; /* Netconfig structure */
- const char *host; /* Remote host name */
- rpcprog_t prog;
- rpcvers_t vers;
- rpcproc_t proc; /* Remote proc identifiers */
- xdrproc_t xdrargs, xdrres; /* XDR routines */
- const char *argsp; /* Argument */
- caddr_t resp; /* Result */
- struct timeval tout; /* Timeout value for this call */
- const struct netbuf *addr_ptr; /* Preallocated netbuf address */
+rpcb_rmtcall(
+ const struct netconfig *nconf, /* Netconfig structure */
+ const char *host, /* Remote host name */
+ rpcprog_t prog,
+ rpcvers_t vers,
+ rpcproc_t proc, /* Remote proc identifiers */
+ xdrproc_t xdrargs,
+ const char *argsp, /* Argument */
+ xdrproc_t xdrres, /* XDR routines */
+ caddr_t resp, /* Result */
+ struct timeval tout, /* Timeout value for this call */
+ const struct netbuf *addr_ptr) /* Preallocated netbuf address */
{
CLIENT *client;
enum clnt_stat stat;
* Returns 1 if succeeds else 0.
*/
bool_t
-rpcb_gettime(host, timep)
- const char *host;
- time_t *timep;
+rpcb_gettime(const char *host, time_t *timep)
{
CLIENT *client = NULL;
void *handle;
* really be called because local n2a libraries are always provided.
*/
char *
-rpcb_taddr2uaddr(nconf, taddr)
- struct netconfig *nconf;
- struct netbuf *taddr;
+rpcb_taddr2uaddr(struct netconfig *nconf, struct netbuf *taddr)
{
CLIENT *client;
char *uaddr = NULL;
-
/* parameter checking */
if (nconf == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
* really be called because local n2a libraries are always provided.
*/
struct netbuf *
-rpcb_uaddr2taddr(nconf, uaddr)
- struct netconfig *nconf;
- char *uaddr;
+rpcb_uaddr2taddr(struct netconfig *nconf, char *uaddr)
{
CLIENT *client;
struct netbuf *taddr;
-/* $NetBSD: rpcb_prot.c,v 1.9 2006/05/11 17:11:57 mrg Exp $ */
+/* $NetBSD: rpcb_prot.c,v 1.10 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro";
#else
-__RCSID("$NetBSD: rpcb_prot.c,v 1.9 2006/05/11 17:11:57 mrg Exp $");
+__RCSID("$NetBSD: rpcb_prot.c,v 1.10 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
bool_t
-xdr_rpcb(xdrs, objp)
- XDR *xdrs;
- RPCB *objp;
+xdr_rpcb(XDR *xdrs, RPCB *objp)
{
_DIAGASSERT(objp != NULL);
*/
bool_t
-xdr_rpcblist_ptr(xdrs, rp)
- XDR *xdrs;
- rpcblist_ptr *rp;
+xdr_rpcblist_ptr(XDR *xdrs, rpcblist_ptr *rp)
{
/*
* more_elements is pre-computed in case the direction is
* functionality to xdr_rpcblist_ptr().
*/
bool_t
-xdr_rpcblist(xdrs, rp)
- XDR *xdrs;
- RPCBLIST **rp;
+xdr_rpcblist(XDR *xdrs, RPCBLIST **rp)
{
bool_t dummy;
bool_t
-xdr_rpcb_entry(xdrs, objp)
- XDR *xdrs;
- rpcb_entry *objp;
+xdr_rpcb_entry(XDR *xdrs, rpcb_entry *objp)
{
_DIAGASSERT(objp != NULL);
}
bool_t
-xdr_rpcb_entry_list_ptr(xdrs, rp)
- XDR *xdrs;
- rpcb_entry_list_ptr *rp;
+xdr_rpcb_entry_list_ptr(XDR *xdrs, rpcb_entry_list_ptr *rp)
{
/*
* more_elements is pre-computed in case the direction is
* written for XDR_ENCODE direction only
*/
bool_t
-xdr_rpcb_rmtcallargs(xdrs, p)
- XDR *xdrs;
- struct rpcb_rmtcallargs *p;
+xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *p)
{
struct r_rpcb_rmtcallargs *objp =
(struct r_rpcb_rmtcallargs *)(void *)p;
* written for XDR_DECODE direction only
*/
bool_t
-xdr_rpcb_rmtcallres(xdrs, p)
- XDR *xdrs;
- struct rpcb_rmtcallres *p;
+xdr_rpcb_rmtcallres(XDR *xdrs, struct rpcb_rmtcallres *p)
{
bool_t dummy;
struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p;
}
bool_t
-xdr_netbuf(xdrs, objp)
- XDR *xdrs;
- struct netbuf *objp;
+xdr_netbuf(XDR *xdrs, struct netbuf *objp)
{
bool_t dummy;
-/* $NetBSD: rpcb_st_xdr.c,v 1.7 2006/05/11 17:11:57 mrg Exp $ */
+/* $NetBSD: rpcb_st_xdr.c,v 1.9 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rpcb_st_xdr.c,v 1.7 2006/05/11 17:11:57 mrg Exp $");
+__RCSID("$NetBSD: rpcb_st_xdr.c,v 1.9 2012/06/25 22:32:45 abs Exp $");
#endif
#include "namespace.h"
#endif
bool_t
-xdr_rpcbs_addrlist(xdrs, objp)
- XDR *xdrs;
- rpcbs_addrlist *objp;
+xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
{
_DIAGASSERT(objp != NULL);
}
if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
- sizeof (rpcbs_addrlist),
+ (u_int)sizeof (rpcbs_addrlist),
(xdrproc_t)xdr_rpcbs_addrlist)) {
return (FALSE);
}
/* Link list of all the stats about rmtcall */
bool_t
-xdr_rpcbs_rmtcalllist(xdrs, objp)
- XDR *xdrs;
- rpcbs_rmtcalllist *objp;
+xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
{
int32_t *buf;
return (FALSE);
}
if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
- sizeof (rpcbs_rmtcalllist),
+ (u_int)sizeof (rpcbs_rmtcalllist),
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
return (FALSE);
}
return (FALSE);
}
if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
- sizeof (rpcbs_rmtcalllist),
+ (u_int)sizeof (rpcbs_rmtcalllist),
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
return (FALSE);
}
return (FALSE);
}
if (!xdr_pointer(xdrs, (char **)(void *)&objp->next,
- sizeof (rpcbs_rmtcalllist),
+ (u_int)sizeof (rpcbs_rmtcalllist),
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
return (FALSE);
}
}
bool_t
-xdr_rpcbs_proc(xdrs, objp)
- XDR *xdrs;
- rpcbs_proc objp;
+xdr_rpcbs_proc(XDR *xdrs, rpcbs_proc objp)
{
if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC,
- sizeof (int), (xdrproc_t)xdr_int)) {
+ (u_int)sizeof (int), (xdrproc_t)xdr_int)) {
return (FALSE);
}
return (TRUE);
}
bool_t
-xdr_rpcbs_addrlist_ptr(xdrs, objp)
- XDR *xdrs;
- rpcbs_addrlist_ptr *objp;
+xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp)
{
- if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist),
+ if (!xdr_pointer(xdrs, (char **)objp, (u_int)sizeof (rpcbs_addrlist),
(xdrproc_t)xdr_rpcbs_addrlist)) {
return (FALSE);
}
}
bool_t
-xdr_rpcbs_rmtcalllist_ptr(xdrs, objp)
- XDR *xdrs;
- rpcbs_rmtcalllist_ptr *objp;
+xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp)
{
- if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist),
+ if (!xdr_pointer(xdrs, (char **)objp, (u_int)sizeof (rpcbs_rmtcalllist),
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
return (FALSE);
}
}
bool_t
-xdr_rpcb_stat(xdrs, objp)
- XDR *xdrs;
- rpcb_stat *objp;
+xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp)
{
_DIAGASSERT(objp != NULL);
* being monitored.
*/
bool_t
-xdr_rpcb_stat_byvers(xdrs, objp)
- XDR *xdrs;
- rpcb_stat_byvers objp;
+xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp)
{
if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT,
- sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
+ (u_int)sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) {
return (FALSE);
}
return (TRUE);
-/* $NetBSD: svc.c,v 1.30 2010/07/08 20:12:37 tron Exp $ */
+/* $NetBSD: svc.c,v 1.31 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: svc.c,v 1.30 2010/07/08 20:12:37 tron Exp $");
+__RCSID("$NetBSD: svc.c,v 1.31 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
rpcprog_t sc_prog;
rpcvers_t sc_vers;
char *sc_netid;
- void (*sc_dispatch) __P((struct svc_req *, SVCXPRT *));
+ void (*sc_dispatch)(struct svc_req *, SVCXPRT *);
} *svc_head;
#ifdef _REENTRANT
extern rwlock_t svc_fd_lock;
#endif
-static struct svc_callout *svc_find __P((rpcprog_t, rpcvers_t,
- struct svc_callout **, char *));
-static void __xprt_do_unregister __P((SVCXPRT *xprt, bool_t dolock));
+static struct svc_callout *svc_find(rpcprog_t, rpcvers_t,
+ struct svc_callout **, char *);
+static void __xprt_do_unregister(SVCXPRT *xprt, bool_t dolock);
/* *************** SVCXPRT related stuff **************** */
* Activate a transport handle.
*/
void
-xprt_register(xprt)
- SVCXPRT *xprt;
+xprt_register(SVCXPRT *xprt)
{
int sock;
* De-activate a transport handle.
*/
static void
-__xprt_do_unregister(xprt, dolock)
- SVCXPRT *xprt;
- bool_t dolock;
+__xprt_do_unregister(SVCXPRT *xprt, bool_t dolock)
{
int sock;
* program number comes in.
*/
bool_t
-svc_reg(xprt, prog, vers, dispatch, nconf)
- SVCXPRT *xprt;
- const rpcprog_t prog;
- const rpcvers_t vers;
- void (*dispatch) __P((struct svc_req *, SVCXPRT *));
- const struct netconfig *nconf;
+svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers,
+ void (*dispatch)(struct svc_req *, SVCXPRT *),
+ const struct netconfig *nconf)
{
bool_t dummy;
struct svc_callout *prev;
* Remove a service program from the callout list.
*/
void
-svc_unreg(prog, vers)
- const rpcprog_t prog;
- const rpcvers_t vers;
+svc_unreg(const rpcprog_t prog, const rpcvers_t vers)
{
struct svc_callout *prev;
struct svc_callout *s;
* program number comes in.
*/
bool_t
-svc_register(xprt, prog, vers, dispatch, protocol)
- SVCXPRT *xprt;
- u_long prog;
- u_long vers;
- void (*dispatch) __P((struct svc_req *, SVCXPRT *));
- int protocol;
+svc_register(SVCXPRT *xprt, u_long prog, u_long vers,
+ void (*dispatch)(struct svc_req *, SVCXPRT *), int protocol)
{
struct svc_callout *prev;
struct svc_callout *s;
* Remove a service program from the callout list.
*/
void
-svc_unregister(prog, vers)
- u_long prog;
- u_long vers;
+svc_unregister(u_long prog, u_long vers)
{
struct svc_callout *prev;
struct svc_callout *s;
* struct.
*/
static struct svc_callout *
-svc_find(prog, vers, prev, netid)
- rpcprog_t prog;
- rpcvers_t vers;
- struct svc_callout **prev;
- char *netid;
+svc_find(rpcprog_t prog, rpcvers_t vers, struct svc_callout **prev, char *netid)
{
struct svc_callout *s, *p;
* Send a reply to an rpc request
*/
bool_t
-svc_sendreply(xprt, xdr_results, xdr_location)
- SVCXPRT *xprt;
- xdrproc_t xdr_results;
- const char *xdr_location;
+svc_sendreply(SVCXPRT *xprt, xdrproc_t xdr_results, const char *xdr_location)
{
struct rpc_msg rply;
* No procedure error reply
*/
void
-svcerr_noproc(xprt)
- SVCXPRT *xprt;
+svcerr_noproc(SVCXPRT *xprt)
{
struct rpc_msg rply;
* Can't decode args error reply
*/
void
-svcerr_decode(xprt)
- SVCXPRT *xprt;
+svcerr_decode(SVCXPRT *xprt)
{
struct rpc_msg rply;
* Some system error
*/
void
-svcerr_systemerr(xprt)
- SVCXPRT *xprt;
+svcerr_systemerr(SVCXPRT *xprt)
{
struct rpc_msg rply;
* protocol: the portmapper (or rpc binder).
*/
void
-__svc_versquiet_on(xprt)
- SVCXPRT *xprt;
+__svc_versquiet_on(SVCXPRT *xprt)
{
u_long tmp;
}
void
-__svc_versquiet_off(xprt)
- SVCXPRT *xprt;
+__svc_versquiet_off(SVCXPRT *xprt)
{
u_long tmp;
}
void
-svc_versquiet(xprt)
- SVCXPRT *xprt;
+svc_versquiet(SVCXPRT *xprt)
{
__svc_versquiet_on(xprt);
}
int
-__svc_versquiet_get(xprt)
- SVCXPRT *xprt;
+__svc_versquiet_get(SVCXPRT *xprt)
{
_DIAGASSERT(xprt != NULL);
* Authentication error reply
*/
void
-svcerr_auth(xprt, why)
- SVCXPRT *xprt;
- enum auth_stat why;
+svcerr_auth(SVCXPRT *xprt, enum auth_stat why)
{
struct rpc_msg rply;
* Auth too weak error reply
*/
void
-svcerr_weakauth(xprt)
- SVCXPRT *xprt;
+svcerr_weakauth(SVCXPRT *xprt)
{
_DIAGASSERT(xprt != NULL);
* Program unavailable error reply
*/
void
-svcerr_noprog(xprt)
- SVCXPRT *xprt;
+svcerr_noprog(SVCXPRT *xprt)
{
struct rpc_msg rply;
* Program version mismatch error reply
*/
void
-svcerr_progvers(xprt, low_vers, high_vers)
- SVCXPRT *xprt;
- rpcvers_t low_vers;
- rpcvers_t high_vers;
+svcerr_progvers(SVCXPRT *xprt, rpcvers_t low_vers, rpcvers_t high_vers)
{
struct rpc_msg rply;
*/
void
-svc_getreq(rdfds)
- int rdfds;
+svc_getreq(int rdfds)
{
fd_set readfds;
}
void
-svc_getreqset(readfds)
- fd_set *readfds;
+svc_getreqset(fd_set *readfds)
{
uint32_t mask, *maskp;
int sock, bit, fd;
}
void
-svc_getreq_common(fd)
- int fd;
+svc_getreq_common(int fd)
{
SVCXPRT *xprt;
struct svc_req r;
void
-svc_getreq_poll(pfdp, pollretval)
- struct pollfd *pfdp;
- int pollretval;
+svc_getreq_poll(struct pollfd *pfdp, int pollretval)
{
int i;
int fds_found;
-/* $NetBSD: svc_auth.c,v 1.15 2003/09/09 03:56:40 itojun Exp $ */
+/* $NetBSD: svc_auth.c,v 1.16 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro";
#else
-__RCSID("$NetBSD: svc_auth.c,v 1.15 2003/09/09 03:56:40 itojun Exp $");
+__RCSID("$NetBSD: svc_auth.c,v 1.16 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
/* declarations to allow servers to specify new authentication flavors */
struct authsvc {
int flavor;
- enum auth_stat (*handler) __P((struct svc_req *, struct rpc_msg *));
+ enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *);
struct authsvc *next;
};
static struct authsvc *Auths = NULL;
* invalid.
*/
enum auth_stat
-_authenticate(rqst, msg)
- struct svc_req *rqst;
- struct rpc_msg *msg;
+_authenticate(struct svc_req *rqst, struct rpc_msg *msg)
{
int cred_flavor;
struct authsvc *asp;
/*ARGSUSED*/
enum auth_stat
-_svcauth_null(rqst, msg)
- struct svc_req *rqst;
- struct rpc_msg *msg;
+_svcauth_null(struct svc_req *rqst, struct rpc_msg *msg)
{
return (AUTH_OK);
}
*/
int
-svc_auth_reg(cred_flavor, handler)
- int cred_flavor;
- enum auth_stat (*handler) __P((struct svc_req *, struct rpc_msg *));
+svc_auth_reg(
+ int cred_flavor,
+ enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *))
{
struct authsvc *asp;
#ifdef _REENTRANT
-/* $NetBSD: svc_auth_unix.c,v 1.18 2003/01/18 11:29:06 thorpej Exp $ */
+/* $NetBSD: svc_auth_unix.c,v 1.20 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: svc_auth_unix.c,v 1.18 2003/01/18 11:29:06 thorpej Exp $");
+__RCSID("$NetBSD: svc_auth_unix.c,v 1.20 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
* Unix longhand authenticator
*/
enum auth_stat
-_svcauth_unix(rqst, msg)
- struct svc_req *rqst;
- struct rpc_msg *msg;
+_svcauth_unix(struct svc_req *rqst, struct rpc_msg *msg)
{
enum auth_stat stat;
XDR xdrs;
stat = AUTH_BADCRED;
goto done;
}
- aup->aup_len = gid_len;
+ _DIAGASSERT(__type_fit(u_int, gid_len));
+ aup->aup_len = (u_int)gid_len;
for (i = 0; i < gid_len; i++) {
aup->aup_gids[i] = (int)IXDR_GET_INT32(buf);
}
*/
/*ARGSUSED*/
enum auth_stat
-_svcauth_short(rqst, msg)
- struct svc_req *rqst;
- struct rpc_msg *msg;
+_svcauth_short(struct svc_req *rqst, struct rpc_msg *msg)
{
return (AUTH_REJECTEDCRED);
}
-/* $NetBSD: svc_dg.c,v 1.12 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: svc_dg.c,v 1.14 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: svc_dg.c,v 1.12 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: svc_dg.c,v 1.14 2012/03/20 17:14:50 matt Exp $");
#endif
#include "namespace.h"
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
-static void svc_dg_ops __P((SVCXPRT *));
-static enum xprt_stat svc_dg_stat __P((SVCXPRT *));
-static bool_t svc_dg_recv __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_dg_reply __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_dg_getargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_dg_freeargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static void svc_dg_destroy __P((SVCXPRT *));
-static bool_t svc_dg_control __P((SVCXPRT *, const u_int, void *));
-static int cache_get __P((SVCXPRT *, struct rpc_msg *, char **, size_t *));
-static void cache_set __P((SVCXPRT *, size_t));
+static void svc_dg_ops(SVCXPRT *);
+static enum xprt_stat svc_dg_stat(SVCXPRT *);
+static bool_t svc_dg_recv(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_dg_reply(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_dg_getargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_dg_freeargs(SVCXPRT *, xdrproc_t, caddr_t);
+static void svc_dg_destroy(SVCXPRT *);
+static bool_t svc_dg_control(SVCXPRT *, const u_int, void *);
+static int cache_get(SVCXPRT *, struct rpc_msg *, char **, size_t *);
+static void cache_set(SVCXPRT *, size_t);
/*
* Usage:
static const char __no_mem_str[] = "out of memory";
SVCXPRT *
-svc_dg_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+svc_dg_create(int fd, u_int sendsize, u_int recvsize)
{
SVCXPRT *xprt;
struct svc_dg_data *su = NULL;
su->su_iosz = ((MAX(sendsize, recvsize) + 3) / 4) * 4;
if ((rpc_buffer(xprt) = malloc(su->su_iosz)) == NULL)
goto freedata;
- xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
+ _DIAGASSERT(__type_fit(u_int, su->su_iosz));
+ xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), (u_int)su->su_iosz,
XDR_DECODE);
su->su_cache = NULL;
xprt->xp_fd = fd;
/*ARGSUSED*/
static enum xprt_stat
-svc_dg_stat(xprt)
- SVCXPRT *xprt;
+svc_dg_stat(SVCXPRT *xprt)
{
return (XPRT_IDLE);
}
static bool_t
-svc_dg_recv(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_dg_recv(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svc_dg_data *su;
XDR *xdrs;
}
static bool_t
-svc_dg_reply(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_dg_reply(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svc_dg_data *su;
XDR *xdrs;
}
static bool_t
-svc_dg_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_dg_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
return (*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr);
}
static bool_t
-svc_dg_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_dg_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
XDR *xdrs;
}
static void
-svc_dg_destroy(xprt)
- SVCXPRT *xprt;
+svc_dg_destroy(SVCXPRT *xprt)
{
struct svc_dg_data *su;
static bool_t
/*ARGSUSED*/
-svc_dg_control(xprt, rq, in)
- SVCXPRT *xprt;
- const u_int rq;
- void *in;
+svc_dg_control(SVCXPRT *xprt, const u_int rq, void *in)
{
return (FALSE);
}
static void
-svc_dg_ops(xprt)
- SVCXPRT *xprt;
+svc_dg_ops(SVCXPRT *xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
static const char enable_err[] = "cache already enabled";
int
-svc_dg_enablecache(transp, size)
- SVCXPRT *transp;
- u_int size;
+svc_dg_enablecache(SVCXPRT *transp, u_int size)
{
struct svc_dg_data *su;
struct cl_cache *uc;
static const char cache_set_err3[] = "could not allocate new rpc buffer";
static void
-cache_set(xprt, replylen)
- SVCXPRT *xprt;
- size_t replylen;
+cache_set(SVCXPRT *xprt, size_t replylen)
{
cache_ptr victim;
cache_ptr *vicp;
victim->cache_replylen = replylen;
victim->cache_reply = rpc_buffer(xprt);
rpc_buffer(xprt) = newbuf;
- xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt),
- su->su_iosz, XDR_ENCODE);
+ _DIAGASSERT(__type_fit(u_int, su->su_iosz));
+ xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), (u_int)su->su_iosz,
+ XDR_ENCODE);
victim->cache_xid = su->su_xid;
victim->cache_proc = uc->uc_proc;
victim->cache_vers = uc->uc_vers;
* return 1 if found, 0 if not found and set the stage for cache_set()
*/
static int
-cache_get(xprt, msg, replyp, replylenp)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
- char **replyp;
- size_t *replylenp;
+cache_get(SVCXPRT *xprt, struct rpc_msg *msg, char **replyp, size_t *replylenp)
{
u_int loc;
cache_ptr ent;
-/* $NetBSD: svc_generic.c,v 1.10 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: svc_generic.c,v 1.12 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: svc_generic.c,v 1.10 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: svc_generic.c,v 1.12 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#include <rpc/nettype.h>
#include <stdio.h>
#include <errno.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h>
__weak_alias(svc_tli_create,_svc_tli_create)
#endif
-extern int __svc_vc_setflag __P((SVCXPRT *, int));
+extern int __svc_vc_setflag(SVCXPRT *, int);
/*
* The highest level interface for server creation.
* created earlier instead of creating a new handle every time.
*/
int
-svc_create(dispatch, prognum, versnum, nettype)
- void (*dispatch) __P((struct svc_req *, SVCXPRT *));
- rpcprog_t prognum; /* Program number */
- rpcvers_t versnum; /* Version number */
- const char *nettype; /* Networktype token */
+svc_create(
+ void (*dispatch)(struct svc_req *, SVCXPRT *),
+ rpcprog_t prognum, /* Program number */
+ rpcvers_t versnum, /* Version number */
+ const char *nettype) /* Networktype token */
{
struct xlist {
SVCXPRT *xprt; /* Server handle */
* with the rpcbind. It calls svc_tli_create();
*/
SVCXPRT *
-svc_tp_create(dispatch, prognum, versnum, nconf)
- void (*dispatch) __P((struct svc_req *, SVCXPRT *));
- rpcprog_t prognum; /* Program number */
- rpcvers_t versnum; /* Version number */
- const struct netconfig *nconf; /* Netconfig structure for the network */
+svc_tp_create(
+ void (*dispatch)(struct svc_req *, SVCXPRT *),
+ rpcprog_t prognum, /* Program number */
+ rpcvers_t versnum, /* Version number */
+ const struct netconfig *nconf) /* Netconfig structure for the network */
{
SVCXPRT *xprt;
* If sendsz or recvsz are zero, their default values are chosen.
*/
SVCXPRT *
-svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz)
- int fd; /* Connection end point */
- const struct netconfig *nconf; /* Netconfig struct for nettoken */
- const struct t_bind *bindaddr; /* Local bind address */
- u_int sendsz; /* Max sendsize */
- u_int recvsz; /* Max recvsize */
+svc_tli_create(
+ int fd, /* Connection end point */
+ const struct netconfig *nconf, /* Netconfig struct for nettoken */
+ const struct t_bind *bindaddr, /* Local bind address */
+ u_int sendsz, /* Max sendsize */
+ u_int recvsz) /* Max recvsize */
{
SVCXPRT *xprt = NULL; /* service handle */
bool_t madefd = FALSE; /* whether fd opened here */
-/* $NetBSD: svc_raw.c,v 1.21 2008/05/24 15:59:59 christos Exp $ */
+/* $NetBSD: svc_raw.c,v 1.22 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#if 0
static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro";
#else
-__RCSID("$NetBSD: svc_raw.c,v 1.21 2008/05/24 15:59:59 christos Exp $");
+__RCSID("$NetBSD: svc_raw.c,v 1.22 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
extern mutex_t svcraw_lock;
#endif
-static enum xprt_stat svc_raw_stat __P((SVCXPRT *));
-static bool_t svc_raw_recv __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_raw_reply __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_raw_getargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_raw_freeargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static void svc_raw_destroy __P((SVCXPRT *));
-static void svc_raw_ops __P((SVCXPRT *));
-static bool_t svc_raw_control __P((SVCXPRT *, const u_int, void *));
+static enum xprt_stat svc_raw_stat(SVCXPRT *);
+static bool_t svc_raw_recv(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_raw_reply(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_raw_getargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_raw_freeargs(SVCXPRT *, xdrproc_t, caddr_t);
+static void svc_raw_destroy(SVCXPRT *);
+static void svc_raw_ops(SVCXPRT *);
+static bool_t svc_raw_control(SVCXPRT *, const u_int, void *);
char *__rpc_rawcombuf = NULL;
SVCXPRT *
-svc_raw_create()
+svc_raw_create(void)
{
struct svc_raw_private *srp;
/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */
/*ARGSUSED*/
static enum xprt_stat
-svc_raw_stat(xprt)
-SVCXPRT *xprt; /* args needed to satisfy ANSI-C typechecking */
+svc_raw_stat(SVCXPRT *xprt) /* args needed to satisfy ANSI-C typechecking */
{
return (XPRT_IDLE);
}
/*ARGSUSED*/
static bool_t
-svc_raw_recv(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_raw_recv(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svc_raw_private *srp;
XDR *xdrs;
/*ARGSUSED*/
static bool_t
-svc_raw_reply(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_raw_reply(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svc_raw_private *srp;
XDR *xdrs;
/*ARGSUSED*/
static bool_t
-svc_raw_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_raw_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
struct svc_raw_private *srp;
/*ARGSUSED*/
static bool_t
-svc_raw_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_raw_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
struct svc_raw_private *srp;
XDR *xdrs;
/*ARGSUSED*/
static void
-svc_raw_destroy(xprt)
-SVCXPRT *xprt;
+svc_raw_destroy(SVCXPRT *xprt)
{
}
/*ARGSUSED*/
static bool_t
-svc_raw_control(xprt, rq, in)
- SVCXPRT *xprt;
- const u_int rq;
- void *in;
+svc_raw_control(SVCXPRT *xprt, const u_int rq, void *in)
{
return (FALSE);
}
static void
-svc_raw_ops(xprt)
- SVCXPRT *xprt;
+svc_raw_ops(SVCXPRT *xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
-/* $NetBSD: svc_run.c,v 1.19 2003/01/18 11:29:07 thorpej Exp $ */
+/* $NetBSD: svc_run.c,v 1.20 2012/06/24 15:26:03 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: svc_run.c,v 1.19 2003/01/18 11:29:07 thorpej Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.20 2012/06/24 15:26:03 christos Exp $");
#endif
#endif
#endif
void
-svc_run()
+svc_run(void)
{
fd_set readfds, cleanfds;
struct timeval timeout;
* more work to do.
*/
void
-svc_exit()
+svc_exit(void)
{
#ifdef _REENTRANT
extern rwlock_t svc_fd_lock;
-/* $NetBSD: svc_simple.c,v 1.30 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: svc_simple.c,v 1.31 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: svc_simple.c,v 1.30 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: svc_simple.c,v 1.31 2012/03/20 17:14:50 matt Exp $");
#endif
#include "namespace.h"
__weak_alias(rpc_reg,_rpc_reg)
#endif
-static void universal __P((struct svc_req *, SVCXPRT *));
+static void universal(struct svc_req *, SVCXPRT *);
static struct proglst {
- char *(*p_progname) __P((char *));
+ char *(*p_progname)(char *);
rpcprog_t p_prognum;
rpcvers_t p_versnum;
rpcproc_t p_procnum;
*/
int
-rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
- rpcprog_t prognum; /* program number */
- rpcvers_t versnum; /* version number */
- rpcproc_t procnum; /* procedure number */
- char *(*progname) __P((char *)); /* Server routine */
- xdrproc_t inproc, outproc; /* in/out XDR procedures */
- char *nettype; /* nettype */
+rpc_reg(
+ rpcprog_t prognum, /* program number */
+ rpcvers_t versnum, /* version number */
+ rpcproc_t procnum, /* procedure number */
+ char *(*progname)(char *), /* Server routine */
+ xdrproc_t inproc, /* in XDR procedure */
+ xdrproc_t outproc, /* out XDR procedure */
+ char *nettype) /* nettype */
{
struct netconfig *nconf;
int done = FALSE;
*/
static void
-universal(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
+universal(struct svc_req *rqstp, SVCXPRT *transp)
{
rpcprog_t prog;
rpcvers_t vers;
-/* $NetBSD: svc_vc.c,v 1.22 2009/02/12 04:38:52 lukem Exp $ */
+/* $NetBSD: svc_vc.c,v 1.26 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: svc_vc.c,v 1.22 2009/02/12 04:38:52 lukem Exp $");
+__RCSID("$NetBSD: svc_vc.c,v 1.26 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
extern rwlock_t svc_fd_lock;
#endif
-static SVCXPRT *makefd_xprt __P((int, u_int, u_int));
-static bool_t rendezvous_request __P((SVCXPRT *, struct rpc_msg *));
-static enum xprt_stat rendezvous_stat __P((SVCXPRT *));
-static void svc_vc_destroy __P((SVCXPRT *));
-static void __svc_vc_dodestroy __P((SVCXPRT *));
-static int read_vc __P((caddr_t, caddr_t, int));
-static int write_vc __P((caddr_t, caddr_t, int));
-static enum xprt_stat svc_vc_stat __P((SVCXPRT *));
-static bool_t svc_vc_recv __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_vc_getargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_vc_freeargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_vc_reply __P((SVCXPRT *, struct rpc_msg *));
-static void svc_vc_rendezvous_ops __P((SVCXPRT *));
-static void svc_vc_ops __P((SVCXPRT *));
-static bool_t svc_vc_control __P((SVCXPRT *, const u_int, void *));
-static bool_t svc_vc_rendezvous_control __P((SVCXPRT *, const u_int,
- void *));
+static SVCXPRT *makefd_xprt(int, u_int, u_int);
+static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *);
+static enum xprt_stat rendezvous_stat(SVCXPRT *);
+static void svc_vc_destroy(SVCXPRT *);
+static void __svc_vc_dodestroy(SVCXPRT *);
+static int read_vc(caddr_t, caddr_t, int);
+static int write_vc(caddr_t, caddr_t, int);
+static enum xprt_stat svc_vc_stat(SVCXPRT *);
+static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_vc_getargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_vc_freeargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_vc_reply(SVCXPRT *, struct rpc_msg *);
+static void svc_vc_rendezvous_ops(SVCXPRT *);
+static void svc_vc_ops(SVCXPRT *);
+static bool_t svc_vc_control(SVCXPRT *, const u_int, void *);
+static bool_t svc_vc_rendezvous_control(SVCXPRT *, const u_int, void *);
struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */
u_int sendsize;
* 0 => use the system default.
*/
SVCXPRT *
-svc_vc_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+svc_vc_create(int fd, u_int sendsize, u_int recvsize)
{
SVCXPRT *xprt;
struct cf_rendezvous *r = NULL;
* We want to be able to check credentials on local sockets.
*/
if (sslocal.ss_family == AF_LOCAL)
- if (setsockopt(fd, 0, LOCAL_CREDS, &one, sizeof one) < 0)
+ if (setsockopt(fd, 0, LOCAL_CREDS, &one, (socklen_t)sizeof one)
+ == -1)
goto cleanup_svc_vc_create;
xprt->xp_ltaddr.maxlen = xprt->xp_ltaddr.len = sslocal.ss_len;
xprt->xp_rtaddr.maxlen = sizeof (struct sockaddr_storage);
xprt_register(xprt);
- return (xprt);
+ return xprt;
cleanup_svc_vc_create:
if (xprt)
mem_free(xprt, sizeof(*xprt));
if (r != NULL)
mem_free(r, sizeof(*r));
- return (NULL);
+ return NULL;
}
/*
* descriptor as its first input.
*/
SVCXPRT *
-svc_fd_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+svc_fd_create(int fd, u_int sendsize, u_int recvsize)
{
struct sockaddr_storage ss;
socklen_t slen;
}
static SVCXPRT *
-makefd_xprt(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+makefd_xprt(int fd, u_int sendsize, u_int recvsize)
{
SVCXPRT *xprt;
struct cf_conn *cd;
goto out;
xprt_register(xprt);
- return (xprt);
+ return xprt;
out:
warn("svc_tcp: makefd_xprt");
if (xprt)
/*ARGSUSED*/
static bool_t
-rendezvous_request(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+rendezvous_request(SVCXPRT *xprt, struct rpc_msg *msg)
{
int sock, flags;
struct cf_rendezvous *r;
if (__svc_clean_idle(&cleanfds, 0, FALSE))
goto again;
}
- return (FALSE);
+ return FALSE;
}
/*
* make a new transporter (re-uses xprt)
(void)gettimeofday(&cd->last_recv_time, NULL);
- return (FALSE); /* there is never an rpc msg to be processed */
+ return FALSE; /* there is never an rpc msg to be processed */
out:
(void)close(sock);
- return (FALSE); /* there was an error */
+ return FALSE; /* there was an error */
}
/*ARGSUSED*/
static enum xprt_stat
-rendezvous_stat(xprt)
- SVCXPRT *xprt;
+rendezvous_stat(SVCXPRT *xprt)
{
- return (XPRT_IDLE);
+ return XPRT_IDLE;
}
static void
-svc_vc_destroy(xprt)
- SVCXPRT *xprt;
+svc_vc_destroy(SVCXPRT *xprt)
{
_DIAGASSERT(xprt != NULL);
}
static void
-__svc_vc_dodestroy(xprt)
- SVCXPRT *xprt;
+__svc_vc_dodestroy(SVCXPRT *xprt)
{
struct cf_conn *cd;
struct cf_rendezvous *r;
/*ARGSUSED*/
static bool_t
-svc_vc_control(xprt, rq, in)
- SVCXPRT *xprt;
- const u_int rq;
- void *in;
+svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in)
{
- return (FALSE);
+ return FALSE;
}
/*ARGSUSED*/
static bool_t
-svc_vc_rendezvous_control(xprt, rq, in)
- SVCXPRT *xprt;
- const u_int rq;
- void *in;
+svc_vc_rendezvous_control(SVCXPRT *xprt, const u_int rq, void *in)
{
struct cf_rendezvous *cfp;
cfp = (struct cf_rendezvous *)xprt->xp_p1;
if (cfp == NULL)
- return (FALSE);
+ return FALSE;
switch (rq) {
case SVCGET_CONNMAXREC:
*(int *)in = cfp->maxrec;
cfp->maxrec = *(int *)in;
break;
default:
- return (FALSE);
+ return FALSE;
}
- return (TRUE);
+ return TRUE;
}
/*
* fatal for the connection.
*/
static int
-read_vc(xprtp, buf, len)
- caddr_t xprtp;
- caddr_t buf;
- int len;
+read_vc(caddr_t xprtp, caddr_t buf, int len)
{
SVCXPRT *xprt;
int sock;
cfp = (struct cf_conn *)xprt->xp_p1;
if (cfp->nonblock) {
- len = read(sock, buf, (size_t)len);
+ len = (int)read(sock, buf, (size_t)len);
if (len < 0) {
if (errno == EAGAIN)
len = 0;
}
} while ((pollfd.revents & POLLIN) == 0);
- if ((len = read(sock, buf, (size_t)len)) > 0) {
+ if ((len = (int)read(sock, buf, (size_t)len)) > 0) {
gettimeofday(&cfp->last_recv_time, NULL);
- return (len);
+ return len;
}
fatal_err:
if (crmsg != NULL)
free(crmsg);
((struct cf_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED;
- return (-1);
+ return -1;
}
/*
* Any error is fatal and the connection is closed.
*/
static int
-write_vc(xprtp, buf, len)
- caddr_t xprtp;
- caddr_t buf;
- int len;
+write_vc(caddr_t xprtp, caddr_t buf, int len)
{
SVCXPRT *xprt;
int i, cnt;
gettimeofday(&tv0, NULL);
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- if ((i = write(xprt->xp_fd, buf, (size_t)cnt)) < 0) {
+ if ((i = (int)write(xprt->xp_fd, buf, (size_t)cnt)) < 0) {
if (errno != EAGAIN || !cd->nonblock) {
cd->strm_stat = XPRT_DIED;
- return (-1);
+ return -1;
}
- if (cd->nonblock && i != cnt) {
+ if (cd->nonblock) {
/*
* For non-blocking connections, do not
* take more than 2 seconds writing the
gettimeofday(&tv1, NULL);
if (tv1.tv_sec - tv0.tv_sec >= 2) {
cd->strm_stat = XPRT_DIED;
- return (-1);
+ return -1;
}
}
+ i = 0;
}
}
- return (len);
+ return len;
}
static enum xprt_stat
-svc_vc_stat(xprt)
- SVCXPRT *xprt;
+svc_vc_stat(SVCXPRT *xprt)
{
struct cf_conn *cd;
cd = (struct cf_conn *)(xprt->xp_p1);
if (cd->strm_stat == XPRT_DIED)
- return (XPRT_DIED);
+ return XPRT_DIED;
if (! xdrrec_eof(&(cd->xdrs)))
- return (XPRT_MOREREQS);
- return (XPRT_IDLE);
+ return XPRT_MOREREQS;
+ return XPRT_IDLE;
}
static bool_t
-svc_vc_recv(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct cf_conn *cd;
XDR *xdrs;
if (xdr_callmsg(xdrs, msg)) {
cd->x_id = msg->rm_xid;
- return (TRUE);
+ return TRUE;
}
cd->strm_stat = XPRT_DIED;
- return (FALSE);
+ return FALSE;
}
static bool_t
-svc_vc_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_vc_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
_DIAGASSERT(xprt != NULL);
/* args_ptr may be NULL */
- return ((*xdr_args)(&(((struct cf_conn *)(xprt->xp_p1))->xdrs),
- args_ptr));
+ return (*xdr_args)(&(((struct cf_conn *)(xprt->xp_p1))->xdrs),
+ args_ptr);
}
static bool_t
-svc_vc_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svc_vc_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
XDR *xdrs;
xdrs = &(((struct cf_conn *)(xprt->xp_p1))->xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return (*xdr_args)(xdrs, args_ptr);
}
static bool_t
-svc_vc_reply(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg)
{
struct cf_conn *cd;
XDR *xdrs;
msg->rm_xid = cd->x_id;
rstat = xdr_replymsg(xdrs, msg);
(void)xdrrec_endofrecord(xdrs, TRUE);
- return (rstat);
+ return rstat;
}
static void
-svc_vc_ops(xprt)
- SVCXPRT *xprt;
+svc_vc_ops(SVCXPRT *xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
}
static void
-svc_vc_rendezvous_ops(xprt)
- SVCXPRT *xprt;
+svc_vc_rendezvous_ops(SVCXPRT *xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
#ifdef _REENTRANT
extern mutex_t ops_lock;
#endif
-/* XXXGCC vax compiler unhappy otherwise */
-#ifdef __vax__
-extern void abort(void);
-#endif
-
mutex_lock(&ops_lock);
if (ops.xp_recv == NULL) {
ops.xp_recv = rendezvous_request;
ops.xp_stat = rendezvous_stat;
ops.xp_getargs =
- (bool_t (*) __P((SVCXPRT *, xdrproc_t, caddr_t)))abort;
+ (bool_t (*)(SVCXPRT *, xdrproc_t, caddr_t))abort;
ops.xp_reply =
- (bool_t (*) __P((SVCXPRT *, struct rpc_msg *)))abort;
+ (bool_t (*)(SVCXPRT *, struct rpc_msg *))abort;
ops.xp_freeargs =
- (bool_t (*) __P((SVCXPRT *, xdrproc_t, caddr_t)))abort;
+ (bool_t (*)(SVCXPRT *, xdrproc_t, caddr_t))abort;
ops.xp_destroy = svc_vc_destroy;
ops2.xp_control = svc_vc_rendezvous_control;
}
.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\" $NetBSD: xdr.3,v 1.12 2009/10/13 21:39:55 joerg Exp $
+.\" $NetBSD: xdr.3,v 1.14 2011/07/08 19:28:22 wiz Exp $
.\"
-.Dd April 17, 2003
+.Dd July 4, 2011
.Dt XDR 3
.Os
.Sh NAME
.Nm xdr_reference ,
.Nm xdr_setpos ,
.Nm xdr_short ,
+.Nm xdr_sizeof ,
.Nm xdrstdio_create ,
.Nm xdr_string ,
.Nm xdr_u_char ,
.Fn xdr_setpos "XDR *xdrs" "u_int pos"
.Ft int
.Fn xdr_short "XDR *xdrs" "short *sp"
+.Ft nsigned long
+.Fn xdr_sizeof "xdrproc_t func" "void *data"
.Ft void
.Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
.Ft int
A filter primitive that translates between C short integers
and their external representations.
This routine returns one if it succeeds, zero otherwise.
+.It Fn xdr_sizeof
+This routine returns the amount of memory required to encode
+.Fa data
+using filter
+.Fa func .
.It Fn xdrstdio_create
This routine initializes the XDR stream object pointed to by
.Fa xdrs .
-/* $NetBSD: xdr.c,v 1.28 2006/05/14 02:15:31 christos Exp $ */
+/* $NetBSD: xdr.c,v 1.31 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr.c,v 1.28 2006/05/14 02:15:31 christos Exp $");
+__RCSID("$NetBSD: xdr.c,v 1.31 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
* Not a filter, but a convenient utility nonetheless
*/
void
-xdr_free(proc, objp)
- xdrproc_t proc;
- char *objp;
+xdr_free(xdrproc_t proc, char *objp)
{
XDR x;
* XDR nothing
*/
bool_t
-xdr_void(/* xdrs, addr */)
- /* XDR *xdrs; */
- /* caddr_t addr; */
-{
+xdr_void(void) {
return (TRUE);
}
* XDR integers
*/
bool_t
-xdr_int(xdrs, ip)
- XDR *xdrs;
- int *ip;
+xdr_int(XDR *xdrs, int *ip)
{
long l;
* XDR unsigned integers
*/
bool_t
-xdr_u_int(xdrs, up)
- XDR *xdrs;
- u_int *up;
+xdr_u_int(XDR *xdrs, u_int *up)
{
u_long l;
* same as xdr_u_long - open coded to save a proc call!
*/
bool_t
-xdr_long(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdr_long(XDR *xdrs, long *lp)
{
_DIAGASSERT(xdrs != NULL);
* same as xdr_long - open coded to save a proc call!
*/
bool_t
-xdr_u_long(xdrs, ulp)
- XDR *xdrs;
- u_long *ulp;
+xdr_u_long(XDR *xdrs, u_long *ulp)
{
_DIAGASSERT(xdrs != NULL);
* same as xdr_u_int32_t - open coded to save a proc call!
*/
bool_t
-xdr_int32_t(xdrs, int32_p)
- XDR *xdrs;
- int32_t *int32_p;
+xdr_int32_t(XDR *xdrs, int32_t *int32_p)
{
long l;
* same as xdr_int32_t - open coded to save a proc call!
*/
bool_t
-xdr_u_int32_t(xdrs, u_int32_p)
- XDR *xdrs;
- u_int32_t *u_int32_p;
+xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
{
u_long l;
* XDR short integers
*/
bool_t
-xdr_short(xdrs, sp)
- XDR *xdrs;
- short *sp;
+xdr_short(XDR *xdrs, short *sp)
{
long l;
* XDR unsigned short integers
*/
bool_t
-xdr_u_short(xdrs, usp)
- XDR *xdrs;
- u_short *usp;
+xdr_u_short(XDR *xdrs, u_short *usp)
{
u_long l;
* XDR 16-bit integers
*/
bool_t
-xdr_int16_t(xdrs, int16_p)
- XDR *xdrs;
- int16_t *int16_p;
+xdr_int16_t(XDR *xdrs, int16_t *int16_p)
{
long l;
* XDR unsigned 16-bit integers
*/
bool_t
-xdr_u_int16_t(xdrs, u_int16_p)
- XDR *xdrs;
- u_int16_t *u_int16_p;
+xdr_u_int16_t(XDR *xdrs, u_int16_t *u_int16_p)
{
u_long l;
* XDR a char
*/
bool_t
-xdr_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
+xdr_char(XDR *xdrs, char *cp)
{
int i;
* XDR an unsigned char
*/
bool_t
-xdr_u_char(xdrs, cp)
- XDR *xdrs;
- u_char *cp;
+xdr_u_char(XDR *xdrs, u_char *cp)
{
u_int u;
* XDR booleans
*/
bool_t
-xdr_bool(xdrs, bp)
- XDR *xdrs;
- bool_t *bp;
+xdr_bool(XDR *xdrs, bool_t *bp)
{
long lb;
* XDR enumerations
*/
bool_t
-xdr_enum(xdrs, ep)
- XDR *xdrs;
- enum_t *ep;
+xdr_enum(XDR *xdrs, enum_t *ep)
{
long l;
* cp points to the opaque object and cnt gives the byte length.
*/
bool_t
-xdr_opaque(xdrs, cp, cnt)
- XDR *xdrs;
- caddr_t cp;
- u_int cnt;
+xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
{
u_int rndup;
static int crud[BYTES_PER_XDR_UNIT];
* If *cpp is NULL maxsize bytes are allocated
*/
bool_t
-xdr_bytes(xdrs, cpp, sizep, maxsize)
- XDR *xdrs;
- char **cpp;
- u_int *sizep;
- u_int maxsize;
+xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
{
char *sp; /* sp is the actual string pointer */
u_int nodesize;
* Implemented here due to commonality of the object.
*/
bool_t
-xdr_netobj(xdrs, np)
- XDR *xdrs;
- struct netobj *np;
+xdr_netobj(XDR *xdrs, struct netobj *np)
{
_DIAGASSERT(xdrs != NULL);
* If there is no specific or default routine an error is returned.
*/
bool_t
-xdr_union(xdrs, dscmp, unp, choices, dfault)
- XDR *xdrs;
- enum_t *dscmp; /* enum to decide which arm to work on */
- char *unp; /* the union itself */
- const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
- xdrproc_t dfault; /* default xdr routine */
+xdr_union(
+ XDR *xdrs,
+ enum_t *dscmp, /* enum to decide which arm to work on */
+ char *unp, /* the union itself */
+ const struct xdr_discrim *choices, /* [value, xdr proc] for each arm */
+ xdrproc_t dfault /* default xdr routine */
+)
{
enum_t dscm;
* of the string as specified by a protocol.
*/
bool_t
-xdr_string(xdrs, cpp, maxsize)
- XDR *xdrs;
- char **cpp;
- u_int maxsize;
+xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
{
char *sp; /* sp is the actual string pointer */
u_int size = 0; /* XXX: GCC */
u_int nodesize;
+ size_t len;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(cpp != NULL);
}
/* FALLTHROUGH */
case XDR_ENCODE:
- size = strlen(sp);
+ len = strlen(sp);
+ _DIAGASSERT(__type_fit(u_int, len));
+ size = (u_int)len;
break;
case XDR_DECODE:
break;
* routines like clnt_call
*/
bool_t
-xdr_wrapstring(xdrs, cpp)
- XDR *xdrs;
- char **cpp;
+xdr_wrapstring(XDR *xdrs, char **cpp)
{
_DIAGASSERT(xdrs != NULL);
* XDR 64-bit integers
*/
bool_t
-xdr_int64_t(xdrs, llp)
- XDR *xdrs;
- int64_t *llp;
+xdr_int64_t(XDR *xdrs, int64_t *llp)
{
u_long ul[2];
switch (xdrs->x_op) {
case XDR_ENCODE:
- ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff;
- ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff;
+ ul[0] = (u_long)(((uint64_t)*llp >> 32) &
+ (uint64_t)0xffffffffULL);
+ ul[1] = (u_long)(((uint64_t)*llp) &
+ (uint64_t)0xffffffffULL);
if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
return (FALSE);
return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
* XDR unsigned 64-bit integers
*/
bool_t
-xdr_u_int64_t(xdrs, ullp)
- XDR *xdrs;
- u_int64_t *ullp;
+xdr_u_int64_t(XDR *xdrs, u_int64_t *ullp)
{
u_long ul[2];
switch (xdrs->x_op) {
case XDR_ENCODE:
- ul[0] = (u_long)(*ullp >> 32) & 0xffffffff;
- ul[1] = (u_long)(*ullp) & 0xffffffff;
+ ul[0] = (u_long)(*ullp >> 32) & 0xffffffffUL;
+ ul[1] = (u_long)(*ullp) & 0xffffffffUL;
if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
return (FALSE);
return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
* XDR hypers
*/
bool_t
-xdr_hyper(xdrs, llp)
- XDR *xdrs;
- longlong_t *llp;
+xdr_hyper(XDR *xdrs, longlong_t *llp)
{
_DIAGASSERT(xdrs != NULL);
* XDR unsigned hypers
*/
bool_t
-xdr_u_hyper(xdrs, ullp)
- XDR *xdrs;
- u_longlong_t *ullp;
+xdr_u_hyper(XDR *xdrs, u_longlong_t *ullp)
{
_DIAGASSERT(xdrs != NULL);
* XDR longlong_t's
*/
bool_t
-xdr_longlong_t(xdrs, llp)
- XDR *xdrs;
- longlong_t *llp;
+xdr_longlong_t(XDR *xdrs, longlong_t *llp)
{
_DIAGASSERT(xdrs != NULL);
* XDR u_longlong_t's
*/
bool_t
-xdr_u_longlong_t(xdrs, ullp)
- XDR *xdrs;
- u_longlong_t *ullp;
+xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
{
_DIAGASSERT(xdrs != NULL);
-/* $NetBSD: xdr_array.c,v 1.16 2005/08/05 10:39:05 wiz Exp $ */
+/* $NetBSD: xdr_array.c,v 1.17 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_array.c,v 1.16 2005/08/05 10:39:05 wiz Exp $");
+__RCSID("$NetBSD: xdr_array.c,v 1.17 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
* xdr procedure to call to handle each element of the array.
*/
bool_t
-xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
- XDR *xdrs;
- caddr_t *addrp; /* array pointer */
- u_int *sizep; /* number of elements */
- u_int maxsize; /* max numberof elements */
- u_int elsize; /* size in bytes of each element */
- xdrproc_t elproc; /* xdr routine to handle each element */
+xdr_array(XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize,
+ xdrproc_t elproc)
{
u_int i;
caddr_t target = *addrp;
* > xdr_elem: routine to XDR each element
*/
bool_t
-xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
- XDR *xdrs;
- char *basep;
- u_int nelem;
- u_int elemsize;
- xdrproc_t xdr_elem;
+xdr_vector(XDR *xdrs, char *basep, u_int nelem, u_int elemsize,
+ xdrproc_t xdr_elem)
{
u_int i;
char *elptr;
-/* $NetBSD: xdr_float.c,v 1.35 2009/02/14 06:26:42 lukem Exp $ */
+/* $NetBSD: xdr_float.c,v 1.37 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_float.c,v 1.35 2009/02/14 06:26:42 lukem Exp $");
+__RCSID("$NetBSD: xdr_float.c,v 1.37 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
#endif /* vax */
bool_t
-xdr_float(xdrs, fp)
- XDR *xdrs;
- float *fp;
+xdr_float(XDR *xdrs, float *fp)
{
#ifndef IEEEFP
struct ieee_single is;
#ifdef IEEEFP
return (XDR_PUTINT32(xdrs, (int32_t *)(void *)fp));
#else
- vs = *((struct vax_single *)fp);
+ vs = *((struct vax_single *)(void *)fp);
for (i = 0, lim = sgl_limits;
i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
i++, lim++) {
#ifdef IEEEFP
return (XDR_GETINT32(xdrs, (int32_t *)(void *)fp));
#else
- vsp = (struct vax_single *)fp;
+ vsp = (struct vax_single *)(void *)fp;
if (!XDR_GETINT32(xdrs, (int32_t *)(void *)&is))
return (FALSE);
for (i = 0, lim = sgl_limits;
}
vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
vsp->mantissa2 = is.mantissa;
- vsp->mantissa1 = (is.mantissa >> 16);
+ vsp->mantissa1 = ((unsigned int)is.mantissa >> 16);
doneit:
vsp->sign = is.sign;
return (TRUE);
bool_t
-xdr_double(xdrs, dp)
- XDR *xdrs;
- double *dp;
+xdr_double(XDR *xdrs, double *dp)
{
#ifdef IEEEFP
int32_t *i32p;
#endif
return (rv);
#else
- vd = *((struct vax_double *)dp);
+ vd = *((struct vax_double *)(void *)dp);
for (i = 0, lim = dbl_limits;
i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
i++, lim++) {
}
}
id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
- id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
+ id.mantissa1 = (vd.mantissa1 << 13) |
+ ((unsigned int)vd.mantissa2 >> 3);
id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) |
(vd.mantissa3 << 13) |
- ((vd.mantissa4 >> 3) & MASK(13));
+ (((unsigned int)vd.mantissa4 >> 3) & MASK(13));
shipit:
id.sign = vd.sign;
lp = (int32_t *)(void *)&id;
}
}
vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
- vd.mantissa1 = (id.mantissa1 >> 13);
+ vd.mantissa1 = ((unsigned int)id.mantissa1 >> 13);
vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
- (id.mantissa2 >> 29);
- vd.mantissa3 = (id.mantissa2 >> 13);
+ ((unsigned int)id.mantissa2 >> 29);
+ vd.mantissa3 = ((unsigned int)id.mantissa2 >> 13);
vd.mantissa4 = (id.mantissa2 << 3);
doneit:
vd.sign = id.sign;
-/* $NetBSD: xdr_mem.c,v 1.17 2006/10/15 16:14:46 christos Exp $ */
+/* $NetBSD: xdr_mem.c,v 1.18 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_mem.c,v 1.17 2006/10/15 16:14:46 christos Exp $");
+__RCSID("$NetBSD: xdr_mem.c,v 1.18 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
__weak_alias(xdrmem_create,_xdrmem_create)
#endif
-static void xdrmem_destroy __P((XDR *));
-static bool_t xdrmem_getlong_aligned __P((XDR *, long *));
-static bool_t xdrmem_putlong_aligned __P((XDR *, const long *));
-static bool_t xdrmem_getlong_unaligned __P((XDR *, long *));
-static bool_t xdrmem_putlong_unaligned __P((XDR *, const long *));
-static bool_t xdrmem_getbytes __P((XDR *, char *, u_int));
-static bool_t xdrmem_putbytes __P((XDR *, const char *, u_int));
+static void xdrmem_destroy(XDR *);
+static bool_t xdrmem_getlong_aligned(XDR *, long *);
+static bool_t xdrmem_putlong_aligned(XDR *, const long *);
+static bool_t xdrmem_getlong_unaligned(XDR *, long *);
+static bool_t xdrmem_putlong_unaligned(XDR *, const long *);
+static bool_t xdrmem_getbytes(XDR *, char *, u_int);
+static bool_t xdrmem_putbytes(XDR *, const char *, u_int);
/* XXX: w/64-bit pointers, u_int not enough! */
-static u_int xdrmem_getpos __P((XDR *));
-static bool_t xdrmem_setpos __P((XDR *, u_int));
-static int32_t *xdrmem_inline_aligned __P((XDR *, u_int));
-static int32_t *xdrmem_inline_unaligned __P((XDR *, u_int));
+static u_int xdrmem_getpos(XDR *);
+static bool_t xdrmem_setpos(XDR *, u_int);
+static int32_t *xdrmem_inline_aligned(XDR *, u_int);
+static int32_t *xdrmem_inline_unaligned(XDR *, u_int);
static const struct xdr_ops xdrmem_ops_aligned = {
xdrmem_getlong_aligned,
* memory buffer.
*/
void
-xdrmem_create(xdrs, addr, size, op)
- XDR *xdrs;
- char *addr;
- u_int size;
- enum xdr_op op;
+xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
{
xdrs->x_op = op;
/*ARGSUSED*/
static void
-xdrmem_destroy(xdrs)
- XDR *xdrs;
+xdrmem_destroy(XDR *xdrs)
{
}
static bool_t
-xdrmem_getlong_aligned(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdrmem_getlong_aligned(XDR *xdrs, long *lp)
{
if (xdrs->x_handy < sizeof(int32_t))
}
static bool_t
-xdrmem_putlong_aligned(xdrs, lp)
- XDR *xdrs;
- const long *lp;
+xdrmem_putlong_aligned(XDR *xdrs, const long *lp)
{
if (xdrs->x_handy < sizeof(int32_t))
}
static bool_t
-xdrmem_getlong_unaligned(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdrmem_getlong_unaligned(XDR *xdrs, long *lp)
{
u_int32_t l;
}
static bool_t
-xdrmem_putlong_unaligned(xdrs, lp)
- XDR *xdrs;
- const long *lp;
+xdrmem_putlong_unaligned(XDR *xdrs, const long *lp)
{
u_int32_t l;
}
static bool_t
-xdrmem_getbytes(xdrs, addr, len)
- XDR *xdrs;
- char *addr;
- u_int len;
+xdrmem_getbytes(XDR *xdrs, char *addr, u_int len)
{
if (xdrs->x_handy < len)
}
static bool_t
-xdrmem_putbytes(xdrs, addr, len)
- XDR *xdrs;
- const char *addr;
- u_int len;
+xdrmem_putbytes(XDR *xdrs, const char *addr, u_int len)
{
if (xdrs->x_handy < len)
}
static u_int
-xdrmem_getpos(xdrs)
- XDR *xdrs;
+xdrmem_getpos(XDR *xdrs)
{
/* XXX w/64-bit pointers, u_int not enough! */
}
static bool_t
-xdrmem_setpos(xdrs, pos)
- XDR *xdrs;
- u_int pos;
+xdrmem_setpos(XDR *xdrs, u_int pos)
{
char *newaddr = xdrs->x_base + pos;
char *lastaddr = (char *)xdrs->x_private + xdrs->x_handy;
}
static int32_t *
-xdrmem_inline_aligned(xdrs, len)
- XDR *xdrs;
- u_int len;
+xdrmem_inline_aligned(XDR *xdrs, u_int len)
{
int32_t *buf = 0;
/* ARGSUSED */
static int32_t *
-xdrmem_inline_unaligned(xdrs, len)
- XDR *xdrs;
- u_int len;
+xdrmem_inline_unaligned(XDR *xdrs, u_int len)
{
return (0);
-/* $NetBSD: xdr_rec.c,v 1.31 2010/11/23 14:02:01 christos Exp $ */
+/* $NetBSD: xdr_rec.c,v 1.33 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_rec.c,v 1.31 2010/11/23 14:02:01 christos Exp $");
+__RCSID("$NetBSD: xdr_rec.c,v 1.33 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
#include <netinet/in.h>
+#include <assert.h>
#include <err.h>
#include <stddef.h>
#include <stdio.h>
__weak_alias(xdrrec_skiprecord,_xdrrec_skiprecord)
#endif
-static bool_t xdrrec_getlong __P((XDR *, long *));
-static bool_t xdrrec_putlong __P((XDR *, const long *));
-static bool_t xdrrec_getbytes __P((XDR *, char *, u_int));
+static bool_t xdrrec_getlong(XDR *, long *);
+static bool_t xdrrec_putlong(XDR *, const long *);
+static bool_t xdrrec_getbytes(XDR *, char *, u_int);
-static bool_t xdrrec_putbytes __P((XDR *, const char *, u_int));
-static u_int xdrrec_getpos __P((XDR *));
-static bool_t xdrrec_setpos __P((XDR *, u_int));
-static int32_t *xdrrec_inline __P((XDR *, u_int));
-static void xdrrec_destroy __P((XDR *));
+static bool_t xdrrec_putbytes(XDR *, const char *, u_int);
+static u_int xdrrec_getpos(XDR *);
+static bool_t xdrrec_setpos(XDR *, u_int);
+static int32_t *xdrrec_inline(XDR *, u_int);
+static void xdrrec_destroy(XDR *);
static const struct xdr_ops xdrrec_ops = {
xdrrec_getlong,
* meet the needs of xdr and rpc based on tcp.
*/
-#define LAST_FRAG ((u_int32_t)(1 << 31))
+#define LAST_FRAG ((uint32_t)(1 << 31))
typedef struct rec_strm {
char *tcp_handle;
/*
* out-goung bits
*/
- int (*writeit) __P((char *, char *, int));
+ int (*writeit)(char *, char *, int);
char *out_base; /* output buffer (points to frag header) */
char *out_finger; /* next output position */
char *out_boundry; /* data cannot up to this address */
- u_int32_t *frag_header; /* beginning of curren fragment */
+ uint32_t *frag_header; /* beginning of curren fragment */
bool_t frag_sent; /* true if buffer sent in middle of record */
/*
* in-coming bits
*/
- int (*readit) __P((char *, char *, int));
+ int (*readit)(char *, char *, int);
u_long in_size; /* fixed size of the input buffer */
char *in_base;
char *in_finger; /* location of next byte to be had */
bool_t nonblock;
bool_t in_haveheader;
- u_int32_t in_header;
+ uint32_t in_header;
char *in_hdrp;
int in_hdrlen;
int in_reclen;
int in_maxrec;
} RECSTREAM;
-static u_int fix_buf_size __P((u_int));
-static bool_t flush_out __P((RECSTREAM *, bool_t));
-static bool_t fill_input_buf __P((RECSTREAM *));
-static bool_t get_input_bytes __P((RECSTREAM *, char *, u_int));
-static bool_t set_input_fragment __P((RECSTREAM *));
-static bool_t skip_input_bytes __P((RECSTREAM *, long));
-static bool_t realloc_stream __P((RECSTREAM *, int));
+static u_int fix_buf_size(u_int);
+static bool_t flush_out(RECSTREAM *, bool_t);
+static bool_t fill_input_buf(RECSTREAM *);
+static bool_t get_input_bytes(RECSTREAM *, char *, u_int);
+static bool_t set_input_fragment(RECSTREAM *);
+static bool_t skip_input_bytes(RECSTREAM *, long);
+static bool_t realloc_stream(RECSTREAM *, int);
/*
* calls expect that they take an opaque handle rather than an fd.
*/
void
-xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
- XDR *xdrs;
- u_int sendsize;
- u_int recvsize;
- char *tcp_handle;
+xdrrec_create(
+ XDR *xdrs,
+ u_int sendsize,
+ u_int recvsize,
+ char *tcp_handle,
/* like read, but pass it a tcp_handle, not sock */
- int (*readit) __P((char *, char *, int));
+ int (*readit)(char *, char *, int),
/* like write, but pass it a tcp_handle, not sock */
- int (*writeit) __P((char *, char *, int));
+ int (*writeit)(char *, char *, int))
{
RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM));
rstrm->readit = readit;
rstrm->writeit = writeit;
rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
- rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base;
- rstrm->out_finger += sizeof(u_int32_t);
+ rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base;
+ rstrm->out_finger += sizeof(uint32_t);
rstrm->out_boundry += sendsize;
rstrm->frag_sent = FALSE;
rstrm->in_size = recvsize;
*/
static bool_t
-xdrrec_getlong(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdrrec_getlong(XDR *xdrs, long *lp)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger);
/* first try the inline, fast case */
if ((rstrm->fbtbc >= (long)sizeof(int32_t)) &&
(((uintptr_t)rstrm->in_boundry - (uintptr_t)buflp) >= sizeof(int32_t))) {
- *lp = (long)ntohl((u_int32_t)(*buflp));
+ *lp = (long)ntohl((uint32_t)(*buflp));
rstrm->fbtbc -= sizeof(int32_t);
rstrm->in_finger += sizeof(int32_t);
} else {
if (! xdrrec_getbytes(xdrs, (char *)(void *)&mylong,
- sizeof(int32_t)))
+ (u_int)sizeof(int32_t)))
return (FALSE);
- *lp = (long)ntohl((u_int32_t)mylong);
+ *lp = (long)ntohl((uint32_t)mylong);
}
return (TRUE);
}
static bool_t
-xdrrec_putlong(xdrs, lp)
- XDR *xdrs;
- const long *lp;
+xdrrec_putlong(XDR *xdrs, const long *lp)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger));
dest_lp = ((int32_t *)(void *)(rstrm->out_finger));
rstrm->out_finger += sizeof(int32_t);
}
- *dest_lp = (int32_t)htonl((u_int32_t)(*lp));
+ *dest_lp = (int32_t)htonl((uint32_t)(*lp));
return (TRUE);
}
static bool_t /* must manage buffers, fragments, and records */
-xdrrec_getbytes(xdrs, addr, len)
- XDR *xdrs;
- char *addr;
- u_int len;
+xdrrec_getbytes(XDR *xdrs, char *addr, u_int len)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
u_int current;
}
static bool_t
-xdrrec_putbytes(xdrs, addr, len)
- XDR *xdrs;
- const char *addr;
- u_int len;
+xdrrec_putbytes(XDR *xdrs, const char *addr, u_int len)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
size_t current;
memmove(rstrm->out_finger, addr, current);
rstrm->out_finger += current;
addr += current;
- len -= current;
+ _DIAGASSERT(__type_fit(u_int, current));
+ len -= (u_int)current;
if (rstrm->out_finger == rstrm->out_boundry) {
rstrm->frag_sent = TRUE;
if (! flush_out(rstrm, FALSE))
}
static u_int
-xdrrec_getpos(xdrs)
- XDR *xdrs;
+xdrrec_getpos(XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
off_t pos;
}
static bool_t
-xdrrec_setpos(xdrs, pos)
- XDR *xdrs;
- u_int pos;
+xdrrec_setpos(XDR *xdrs, u_int pos)
{
RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
u_int currpos = xdrrec_getpos(xdrs);
}
static int32_t *
-xdrrec_inline(xdrs, len)
- XDR *xdrs;
- u_int len;
+xdrrec_inline(XDR *xdrs, u_int len)
{
RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
int32_t *buf = NULL;
}
static void
-xdrrec_destroy(xdrs)
- XDR *xdrs;
+xdrrec_destroy(XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
* this procedure to guarantee proper record alignment.
*/
bool_t
-xdrrec_skiprecord(xdrs)
- XDR *xdrs;
+xdrrec_skiprecord(XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
enum xprt_stat xstat;
* after consuming the rest of the current record.
*/
bool_t
-xdrrec_eof(xdrs)
- XDR *xdrs;
+xdrrec_eof(XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
* pipelined procedure calls.) TRUE => immmediate flush to tcp connection.
*/
bool_t
-xdrrec_endofrecord(xdrs, sendnow)
- XDR *xdrs;
- bool_t sendnow;
+xdrrec_endofrecord(XDR *xdrs, bool_t sendnow)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
u_long len; /* fragment length */
if (sendnow || rstrm->frag_sent ||
- ((u_long)rstrm->out_finger + sizeof(u_int32_t) >=
+ ((u_long)rstrm->out_finger + sizeof(uint32_t) >=
(u_long)rstrm->out_boundry)) {
rstrm->frag_sent = FALSE;
return (flush_out(rstrm, TRUE));
}
len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) -
- sizeof(u_int32_t);
- *(rstrm->frag_header) = htonl((u_int32_t)len | LAST_FRAG);
- rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_finger;
- rstrm->out_finger += sizeof(u_int32_t);
+ sizeof(uint32_t);
+ *(rstrm->frag_header) = htonl((uint32_t)len | LAST_FRAG);
+ rstrm->frag_header = (uint32_t *)(void *)rstrm->out_finger;
+ rstrm->out_finger += sizeof(uint32_t);
return (TRUE);
}
* Return true if a record is available in the buffer, false if not.
*/
bool_t
-__xdrrec_getrec(xdrs, statp, expectdata)
- XDR *xdrs;
- enum xprt_stat *statp;
- bool_t expectdata;
+__xdrrec_getrec(XDR *xdrs, enum xprt_stat *statp, bool_t expectdata)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
ssize_t n;
return FALSE;
}
rstrm->in_hdrp += n;
- rstrm->in_hdrlen += n;
+ _DIAGASSERT(__type_fit(int, n));
+ rstrm->in_hdrlen += (int)n;
if (rstrm->in_hdrlen < (int)sizeof(rstrm->in_header)) {
*statp = XPRT_MOREREQS;
return FALSE;
return FALSE;
}
- rstrm->in_received += n;
+ _DIAGASSERT(__type_fit(int, n));
+ rstrm->in_received += (int)n;
if (rstrm->in_received == rstrm->in_reclen) {
rstrm->in_haveheader = FALSE;
}
bool_t
-__xdrrec_setnonblock(xdrs, maxrec)
- XDR *xdrs;
- int maxrec;
+__xdrrec_setnonblock(XDR *xdrs, int maxrec)
{
RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
* Internal useful routines
*/
static bool_t
-flush_out(rstrm, eor)
- RECSTREAM *rstrm;
- bool_t eor;
+flush_out(RECSTREAM *rstrm, bool_t eor)
{
- u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0;
- u_int32_t len = (u_int32_t)((u_long)(rstrm->out_finger) -
- (u_long)(rstrm->frag_header) - sizeof(u_int32_t));
+ uint32_t eormask = (eor == TRUE) ? LAST_FRAG : 0;
+ uint32_t len = (uint32_t)((u_long)(rstrm->out_finger) -
+ (u_long)(rstrm->frag_header) - sizeof(uint32_t));
*(rstrm->frag_header) = htonl(len | eormask);
- len = (u_int32_t)((u_long)(rstrm->out_finger) -
+ len = (uint32_t)((u_long)(rstrm->out_finger) -
(u_long)(rstrm->out_base));
if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len)
!= (int)len)
return (FALSE);
- rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base;
- rstrm->out_finger = (char *)rstrm->out_base + sizeof(u_int32_t);
+ rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base;
+ rstrm->out_finger = (char *)rstrm->out_base + sizeof(uint32_t);
return (TRUE);
}
static bool_t /* knows nothing about records! Only about input buffers */
-fill_input_buf(rstrm)
- RECSTREAM *rstrm;
+fill_input_buf(RECSTREAM *rstrm)
{
char *where;
- u_int32_t i;
+ uint32_t i;
int len;
if (rstrm->nonblock)
return FALSE;
where = rstrm->in_base;
- i = (u_int32_t)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT);
+ i = (uint32_t)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT);
where += i;
- len = (u_int32_t)(rstrm->in_size - i);
+ len = (uint32_t)(rstrm->in_size - i);
if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1)
return (FALSE);
rstrm->in_finger = where;
}
static bool_t /* knows nothing about records! Only about input buffers */
-get_input_bytes(rstrm, addr, len)
- RECSTREAM *rstrm;
- char *addr;
- u_int len;
+get_input_bytes(RECSTREAM *rstrm, char *addr, u_int len)
{
u_int current;
}
while (len > 0) {
- current = ((uintptr_t)rstrm->in_boundry -
+ uintptr_t d = ((uintptr_t)rstrm->in_boundry -
(uintptr_t)rstrm->in_finger);
+ _DIAGASSERT(__type_fit(u_int, d));
+ current = (u_int)d;
if (current == 0) {
if (! fill_input_buf(rstrm))
return (FALSE);
}
static bool_t /* next two bytes of the input stream are treated as a header */
-set_input_fragment(rstrm)
- RECSTREAM *rstrm;
+set_input_fragment(RECSTREAM *rstrm)
{
- u_int32_t header;
+ uint32_t header;
if (rstrm->nonblock)
return FALSE;
- if (! get_input_bytes(rstrm, (char *)(void *)&header, sizeof(header)))
+ if (! get_input_bytes(rstrm, (char *)(void *)&header,
+ (u_int)sizeof(header)))
return (FALSE);
header = ntohl(header);
rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
}
static bool_t /* consumes input bytes; knows nothing about records! */
-skip_input_bytes(rstrm, cnt)
- RECSTREAM *rstrm;
- long cnt;
+skip_input_bytes(RECSTREAM *rstrm, long cnt)
{
- u_int32_t current;
+ uint32_t current;
while (cnt > 0) {
- current = (size_t)((long)rstrm->in_boundry -
+ current = (uint32_t)((long)rstrm->in_boundry -
(long)rstrm->in_finger);
if (current == 0) {
if (! fill_input_buf(rstrm))
return (FALSE);
continue;
}
- current = ((u_int32_t)cnt < current) ? (u_int32_t)cnt : current;
+ current = ((uint32_t)cnt < current) ? (uint32_t)cnt : current;
rstrm->in_finger += current;
cnt -= current;
}
}
static u_int
-fix_buf_size(s)
- u_int s;
+fix_buf_size(u_int s)
{
if (s < 100)
* Reallocate the input buffer for a non-block stream.
*/
static bool_t
-realloc_stream(rstrm, size)
- RECSTREAM *rstrm;
- int size;
+realloc_stream(RECSTREAM *rstrm, int size)
{
ptrdiff_t diff;
char *buf;
-/* $NetBSD: xdr_reference.c,v 1.15 2008/04/25 17:44:44 christos Exp $ */
+/* $NetBSD: xdr_reference.c,v 1.16 2012/06/25 22:32:45 abs Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
static char *sccsid = "@(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_reference.c,v 1.15 2008/04/25 17:44:44 christos Exp $");
+__RCSID("$NetBSD: xdr_reference.c,v 1.16 2012/06/25 22:32:45 abs Exp $");
#endif
#endif
* proc is the routine to handle the referenced structure.
*/
bool_t
-xdr_reference(xdrs, pp, size, proc)
- XDR *xdrs;
- caddr_t *pp; /* the pointer to work on */
- u_int size; /* size of the object pointed to */
- xdrproc_t proc; /* xdr routine to handle the object */
+xdr_reference(XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
{
caddr_t loc = *pp;
bool_t stat;
*
*/
bool_t
-xdr_pointer(xdrs,objpp,obj_size,xdr_obj)
- XDR *xdrs;
- char **objpp;
- u_int obj_size;
- xdrproc_t xdr_obj;
+xdr_pointer(XDR *xdrs, char **objpp, u_int obj_size, xdrproc_t xdr_obj)
{
bool_t more_data;
--- /dev/null
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+/*
+ * xdr_sizeof.c
+ *
+ * Copyright 1990 Sun Microsystems, Inc.
+ *
+ * General purpose routine to see how much space something will use
+ * when serialized using XDR.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+__FBSDID("$FreeBSD: src/lib/libc/xdr/xdr_sizeof.c,v 1.5.38.1 2010/12/21 17:10:29 kensmith Exp $");
+#else
+__RCSID("$NetBSD: xdr_sizeof.c,v 1.4 2012/03/20 17:14:50 matt Exp $");
+#endif
+
+#include "namespace.h"
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#ifdef __weak_alias
+__weak_alias(xdr_sizeof,_xdr_sizeof)
+#endif
+
+static bool_t x_putlong(XDR *, const long *);
+static bool_t x_putbytes(XDR *, const char *, u_int);
+static u_int x_getpostn(XDR *);
+static bool_t x_setpostn(XDR *, u_int);
+static int32_t *x_inline(XDR *, u_int);
+static int harmless(void);
+static void x_destroy(XDR *);
+
+/* ARGSUSED */
+static bool_t
+x_putlong(XDR *xdrs, const long *longp)
+{
+ xdrs->x_handy += BYTES_PER_XDR_UNIT;
+ return (TRUE);
+}
+
+/* ARGSUSED */
+static bool_t
+x_putbytes(XDR *xdrs, const char *bp, u_int len)
+{
+ xdrs->x_handy += len;
+ return (TRUE);
+}
+
+static u_int
+x_getpostn(XDR *xdrs)
+{
+ return (xdrs->x_handy);
+}
+
+/* ARGSUSED */
+static bool_t
+x_setpostn(XDR *xdrs, u_int pos)
+{
+ /* This is not allowed */
+ return (FALSE);
+}
+
+static int32_t *
+x_inline(XDR *xdrs, u_int len)
+{
+ if (len == 0) {
+ return (NULL);
+ }
+ if (xdrs->x_op != XDR_ENCODE) {
+ return (NULL);
+ }
+ if (len < (u_int)(uintptr_t)xdrs->x_base) {
+ /* x_private was already allocated */
+ xdrs->x_handy += len;
+ return ((int32_t *) xdrs->x_private);
+ } else {
+ /* Free the earlier space and allocate new area */
+ if (xdrs->x_private)
+ free(xdrs->x_private);
+ if ((xdrs->x_private = malloc(len)) == NULL) {
+ xdrs->x_base = 0;
+ return (NULL);
+ }
+ xdrs->x_base = (caddr_t)(uintptr_t)len;
+ xdrs->x_handy += len;
+ return ((int32_t *) xdrs->x_private);
+ }
+}
+
+static int
+harmless(void)
+{
+ /* Always return FALSE/NULL, as the case may be */
+ return (0);
+}
+
+static void
+x_destroy(XDR *xdrs)
+{
+ xdrs->x_handy = 0;
+ xdrs->x_base = 0;
+ if (xdrs->x_private) {
+ free(xdrs->x_private);
+ xdrs->x_private = NULL;
+ }
+ return;
+}
+
+unsigned long
+xdr_sizeof(xdrproc_t func, void *data)
+{
+ XDR x;
+ struct xdr_ops ops;
+ bool_t stat;
+ /* to stop ANSI-C compiler from complaining */
+ typedef bool_t (* dummyfunc1)(XDR *, long *);
+ typedef bool_t (* dummyfunc2)(XDR *, caddr_t, u_int);
+
+ ops.x_putlong = x_putlong;
+ ops.x_putbytes = x_putbytes;
+ ops.x_inline = x_inline;
+ ops.x_getpostn = x_getpostn;
+ ops.x_setpostn = x_setpostn;
+ ops.x_destroy = x_destroy;
+
+ /* the other harmless ones */
+ ops.x_getlong = (dummyfunc1) harmless;
+ ops.x_getbytes = (dummyfunc2) harmless;
+
+ x.x_op = XDR_ENCODE;
+ x.x_ops = &ops;
+ x.x_handy = 0;
+ x.x_private = (caddr_t) NULL;
+ x.x_base = (caddr_t) 0;
+
+ stat = func(&x, data);
+ if (x.x_private)
+ free(x.x_private);
+ return (stat == TRUE ? (unsigned) x.x_handy: 0);
+}
-/* $NetBSD: xdr_stdio.c,v 1.17 2006/10/15 16:14:46 christos Exp $ */
+/* $NetBSD: xdr_stdio.c,v 1.18 2012/03/20 17:14:50 matt Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
static char *sccsid = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr_stdio.c,v 1.17 2006/10/15 16:14:46 christos Exp $");
+__RCSID("$NetBSD: xdr_stdio.c,v 1.18 2012/03/20 17:14:50 matt Exp $");
#endif
#endif
__weak_alias(xdrstdio_create,_xdrstdio_create)
#endif
-static void xdrstdio_destroy __P((XDR *));
-static bool_t xdrstdio_getlong __P((XDR *, long *));
-static bool_t xdrstdio_putlong __P((XDR *, const long *));
-static bool_t xdrstdio_getbytes __P((XDR *, char *, u_int));
-static bool_t xdrstdio_putbytes __P((XDR *, const char *, u_int));
-static u_int xdrstdio_getpos __P((XDR *));
-static bool_t xdrstdio_setpos __P((XDR *, u_int));
-static int32_t *xdrstdio_inline __P((XDR *, u_int));
+static void xdrstdio_destroy(XDR *);
+static bool_t xdrstdio_getlong(XDR *, long *);
+static bool_t xdrstdio_putlong(XDR *, const long *);
+static bool_t xdrstdio_getbytes(XDR *, char *, u_int);
+static bool_t xdrstdio_putbytes(XDR *, const char *, u_int);
+static u_int xdrstdio_getpos(XDR *);
+static bool_t xdrstdio_setpos(XDR *, u_int);
+static int32_t *xdrstdio_inline(XDR *, u_int);
/*
* Ops vector for stdio type XDR
* Operation flag is set to op.
*/
void
-xdrstdio_create(xdrs, file, op)
- XDR *xdrs;
- FILE *file;
- enum xdr_op op;
+xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op)
{
xdrs->x_op = op;
* Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
*/
static void
-xdrstdio_destroy(xdrs)
- XDR *xdrs;
+xdrstdio_destroy(XDR *xdrs)
{
(void)fflush((FILE *)xdrs->x_private);
/* XXX: should we close the file ?? */
}
static bool_t
-xdrstdio_getlong(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdrstdio_getlong(XDR *xdrs, long *lp)
{
u_int32_t temp;
}
static bool_t
-xdrstdio_putlong(xdrs, lp)
- XDR *xdrs;
- const long *lp;
+xdrstdio_putlong(XDR *xdrs, const long *lp)
{
int32_t mycopy = htonl((u_int32_t)*lp);
}
static bool_t
-xdrstdio_getbytes(xdrs, addr, len)
- XDR *xdrs;
- char *addr;
- u_int len;
+xdrstdio_getbytes(XDR *xdrs, char *addr, u_int len)
{
if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1))
}
static bool_t
-xdrstdio_putbytes(xdrs, addr, len)
- XDR *xdrs;
- const char *addr;
- u_int len;
+xdrstdio_putbytes(XDR *xdrs, const char *addr, u_int len)
{
if ((len != 0) && (fwrite(addr, (size_t)len, 1,
}
static u_int
-xdrstdio_getpos(xdrs)
- XDR *xdrs;
+xdrstdio_getpos(XDR *xdrs)
{
return ((u_int) ftell((FILE *)xdrs->x_private));
}
static bool_t
-xdrstdio_setpos(xdrs, pos)
- XDR *xdrs;
- u_int pos;
+xdrstdio_setpos(XDR *xdrs, u_int pos)
{
return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
/* ARGSUSED */
static int32_t *
-xdrstdio_inline(xdrs, len)
- XDR *xdrs;
- u_int len;
+xdrstdio_inline(XDR *xdrs, u_int len)
{
/*
+# $NetBSD: shlib_version,v 1.235 2012/08/24 06:12:52 dholland Exp $
+# Remember to update distrib/sets/lists/base/shl.* when changing
+#
+# things we wish to do on next major version bump:
+# - libc/net/rcmd.c: make __ivaliduser() and __ivaliduser_sa() static
+# - libc/net: resolver update to BIND8/9?
+# - md2, md4, md5, rmd160 & sha1 functions should take the same arguments AFAP
+# - Crypto hashes have name overlap with libcrypto, rename them
+# - libc/gen/assert.c: __{diag,}assert13() -> __{diag,}assert()
+# - libc/gen/times.c: remove; __times13() -> times()
+# - libc/gen/timezone.c: remove; __timezone13 -> timezone
+# - libc/net/getaddrinfo.c, netdb.h: remove __ai_pad0
+# - libc/gen/utmpx.c, utmpx.h: remove lastlogxname, __getlastlogx13 -> getlastlogx
+# - libc/gen/utmpx.c, utmpx.h: add expansion space to struct lastlogx
+# - infinity{,f,l}.c, math.h: __infinity -> __huge_val
+# - libc/gen/is{inf,nan}d_ieee754.c: remove is{inf,nan} aliases
+# - libc/arch/vax/gen/is{inf,nan}.c: remove
+# - libc/db/hash/ndbm.c: remove; __ndbm13 -> ndbm
+# - libc/net/getnet{ent,namadr}.c, netdb.h: remove __n_pad0
+# - libc/stdio: make _file an int, hide struct FILE, stdin, stdout, stderr impls
+# - libc/stdio: make fileno() not a macro
+# - libc/stdio: make stdio macro users depend on some library symbol
+# - remove frexp, ldexp, modf: they belong to libm.
+# - make sure we can support thread local [on arm don't use r9 for example,
+# consider other risc architectures: mips, powerpc, sparc, etc]
+# - rename __libc_mutex_lock and similar back to pthread_mutex_lock.
+# the functions are used by third party code without prototypes.
+# for example in assembler code.
+# - kill sigcontext: never request version 0 or 1 signal trampoline.
+# always request version 2 trampoline. (on vax, 3).
+# - change _ctype_ table in ctype.h and gen/ctype_.c 8bit -> 16 or 32bit.
+# it's insufficient bitwidth to implement all ctype class.
+# see isblank's comment in ctype.h.
+# - remove gets(); it is finally dead in c11.
+# - make __cerror (spelled CERROR) hidden again
+# - remove ruserok() and friends to libcompat (or entirely)
major=0
minor=0
-# $NetBSD: Makefile.inc,v 1.7 2011/01/17 10:08:35 matt Exp $
+# $NetBSD: Makefile.inc,v 1.10 2011/07/04 02:53:15 mrg Exp $
SOFTFLOAT_BITS?=64
.PATH: ${ARCHDIR}/softfloat \
nexf2.c gtxf2.c gexf2.c negxf2.c unordsf2.c unorddf2.c
SRCS+= ${SRCS.softfloat}
+
+# XXX
+.if defined(HAVE_GCC) && ${HAVE_GCC} >= 45 && \
+ (${MACHINE_CPU} == "arm" || \
+ ${MACHINE_CPU} == "mips" || \
+ ${MACHINE_CPU} == "sh3")
+COPTS.softfloat.c+= -Wno-enum-compare
+.endif
-/* $NetBSD: softfloat.c,v 1.1 2002/05/21 23:51:07 bjh21 Exp $ */
+/* $NetBSD: softfloat.c,v 1.2 2012/03/21 14:17:54 christos Exp $ */
/*
* This version hacked for use with gcc -msoft-float by bjh21.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: softfloat.c,v 1.1 2002/05/21 23:51:07 bjh21 Exp $");
+__RCSID("$NetBSD: softfloat.c,v 1.2 2012/03/21 14:17:54 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef SOFTFLOAT_FOR_GCC
isTiny =
( float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
- || ( zSig + roundIncrement < 0x80000000 );
+ || ( zSig + roundIncrement < (uint32)0x80000000 );
shift32RightJamming( zSig, - zExp, &zSig );
zExp = 0;
roundBits = zSig & 0x7F;
INLINE bits32 extractFloat64Frac1( float64 a )
{
- return FLOAT64_DEMANGLE(a) & LIT64( 0x00000000FFFFFFFF );
+ return (bits32)(FLOAT64_DEMANGLE(a) & LIT64(0x00000000FFFFFFFF));
}
INLINE bits32 extractFloat64Frac0( float64 a )
{
- return ( FLOAT64_DEMANGLE(a)>>32 ) & 0x000FFFFF;
+ return (bits32)((FLOAT64_DEMANGLE(a) >> 32) & 0x000FFFFF);
}
INLINE int16 extractFloat64Exp( float64 a )
{
- return ( FLOAT64_DEMANGLE(a)>>52 ) & 0x7FF;
+ return (int16)((FLOAT64_DEMANGLE(a) >> 52) & 0x7FF);
}
INLINE flag extractFloat64Sign( float64 a )
{
- return FLOAT64_DEMANGLE(a)>>63;
+ return (flag)(FLOAT64_DEMANGLE(a) >> 63);
}
if ( a == 0 ) return 0;
if ( a == (sbits32) 0x80000000 ) return packFloat32( 1, 0x9E, 0 );
zSign = ( a < 0 );
- return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a );
+ return normalizeRoundAndPackFloat32(zSign, 0x9C, (uint32)(zSign ? - a : a));
}
-/* $NetBSD: softfloat-macros,v 1.2 2009/02/16 10:23:35 tron Exp $ */
+/* $NetBSD: softfloat-macros,v 1.3 2012/03/21 02:32:26 christos Exp $ */
/*
===============================================================================
bits32 aHigh, aLow, bHigh, bLow;
bits64 z0, zMiddleA, zMiddleB, z1;
- aLow = a;
- aHigh = a>>32;
- bLow = b;
- bHigh = b>>32;
+ aLow = (bits32)a;
+ aHigh = (bits32)(a>>32);
+ bLow = (bits32)b;
+ bHigh = (bits32)(b>>32);
z1 = ( (bits64) aLow ) * bLow;
zMiddleA = ( (bits64) aLow ) * bHigh;
zMiddleB = ( (bits64) aHigh ) * bLow;
z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ idx ];
z = a / z + z;
z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 );
- if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 );
+ if ( z <= a ) return (bits32) ( ( (bits32) a )>>1 );
}
return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 );
else {
a >>= 32;
}
- shiftCount += countLeadingZeros32( a );
+ shiftCount += (int8)countLeadingZeros32( (bits32)a );
return shiftCount;
}
-/* $NetBSD: softfloat.c,v 1.5 2007/11/08 21:31:04 martin Exp $ */
+/* $NetBSD: softfloat.c,v 1.11 2012/03/24 00:06:20 matt Exp $ */
/*
* This version hacked for use with gcc -msoft-float by bjh21.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: softfloat.c,v 1.5 2007/11/08 21:31:04 martin Exp $");
+__RCSID("$NetBSD: softfloat.c,v 1.11 2012/03/24 00:06:20 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef SOFTFLOAT_FOR_GCC
}
}
}
- roundBits = absZ & 0x7F;
+ roundBits = (int8)(absZ & 0x7F);
absZ = ( absZ + roundIncrement )>>7;
absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
- z = absZ;
+ z = (int32)absZ;
if ( zSign ) z = - z;
if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
float_raise( float_flag_invalid );
isTiny =
( float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
- || ( zSig + roundIncrement < 0x80000000 );
+ || ( zSig + roundIncrement < 0x80000000U );
shift32RightJamming( zSig, - zExp, &zSig );
zExp = 0;
roundBits = zSig & 0x7F;
INLINE int16 extractFloat64Exp( float64 a )
{
- return ( FLOAT64_DEMANGLE(a)>>52 ) & 0x7FF;
+ return (int16)((FLOAT64_DEMANGLE(a) >> 52) & 0x7FF);
}
INLINE flag extractFloat64Sign( float64 a )
{
- return FLOAT64_DEMANGLE(a)>>63;
+ return (flag)(FLOAT64_DEMANGLE(a) >> 63);
}
}
}
}
- roundBits = zSig & 0x3FF;
+ roundBits = (int16)(zSig & 0x3FF);
if ( 0x7FD <= (bits16) zExp ) {
if ( ( 0x7FD < zExp )
|| ( ( zExp == 0x7FD )
isTiny =
( float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
- || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );
+ || ( zSig + roundIncrement < (bits64)LIT64( 0x8000000000000000 ) );
shift64RightJamming( zSig, - zExp, &zSig );
zExp = 0;
- roundBits = zSig & 0x3FF;
+ roundBits = (int16)(zSig & 0x3FF);
if ( isTiny && roundBits ) float_raise( float_flag_underflow );
}
}
INLINE int32 extractFloat128Exp( float128 a )
{
- return ( a.high>>48 ) & 0x7FFF;
+ return (int32)((a.high >> 48) & 0x7FFF);
}
INLINE flag extractFloat128Sign( float128 a )
{
- return a.high>>63;
+ return (flag)(a.high >> 63);
}
if ( a == 0 ) return 0;
if ( a == (sbits32) 0x80000000 ) return packFloat32( 1, 0x9E, 0 );
zSign = ( a < 0 );
- return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a );
+ return normalizeRoundAndPackFloat32(zSign, 0x9C, (uint32)(zSign ? - a : a));
}
+float32 uint32_to_float32( uint32 a )
+{
+ if ( a == 0 ) return 0;
+ if ( a & (bits32) 0x80000000 )
+ return normalizeRoundAndPackFloat32( 0, 0x9D, a >> 1 );
+ return normalizeRoundAndPackFloat32( 0, 0x9C, a );
+}
+
+
/*
-------------------------------------------------------------------------------
Returns the result of converting the 32-bit two's complement integer `a'
}
+float64 uint32_to_float64( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig = a;
+
+ if ( a == 0 ) return 0;
+ shiftCount = countLeadingZeros32( a ) + 21;
+ return packFloat64( 0, 0x432 - shiftCount, zSig<<shiftCount );
+
+}
+
#ifdef FLOATX80
/*
}
+floatx80 uint32_to_floatx80( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig = a;
+
+ if ( a == 0 ) return packFloatx80( 0, 0, 0 );
+ shiftCount = countLeadingZeros32( a ) + 32;
+ return packFloatx80( 0, 0x403E - shiftCount, zSig<<shiftCount );
+
+}
+
#endif
#ifdef FLOAT128
}
+float128 uint32_to_float128( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig0 = a;
+
+ if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
+ shiftCount = countLeadingZeros32( a ) + 17;
+ return packFloat128( 0, 0x402E - shiftCount, zSig0<<shiftCount, 0 );
+
+}
+
#endif
#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */
aSig = ( aSig | 0x00800000 )<<7;
bSig = ( bSig | 0x00800000 )<<8;
shift64RightJamming( ( (bits64) aSig ) * bSig, 32, &zSig64 );
- zSig = zSig64;
+ zSig = (bits32)zSig64;
if ( 0 <= (sbits32) ( zSig<<1 ) ) {
zSig <<= 1;
--zExp;
aSig >>= 1;
++zExp;
}
- zSig = ( ( (bits64) aSig )<<32 ) / bSig;
+ zSig = (bits32)((((bits64) aSig) << 32) / bSig);
if ( ( zSig & 0x3F ) == 0 ) {
zSig |= ( (bits64) bSig * zSig != ( (bits64) aSig )<<32 );
}
shiftCount = 0x433 - aExp;
savedASig = aSig;
aSig >>= shiftCount;
- z = aSig;
+ z = (int32)aSig;
if ( aSign ) z = - z;
if ( ( z < 0 ) ^ aSign ) {
invalid:
return packFloat32( aSign, 0xFF, 0 );
}
shift64RightJamming( aSig, 22, &aSig );
- zSig = aSig;
+ zSig = (bits32)aSig;
if ( aExp || zSig ) {
zSig |= 0x40000000;
aExp -= 0x381;
shiftCount = 0x402F - aExp;
savedASig = aSig0;
aSig0 >>= shiftCount;
- z = aSig0;
+ z = (int32)aSig0;
if ( aSign ) z = - z;
if ( ( z < 0 ) ^ aSign ) {
invalid:
}
+#if (defined(SOFTFLOATSPARC64_FOR_GCC) || defined(SOFTFLOAT_FOR_GCC)) \
+ && defined(SOFTFLOAT_NEED_FIXUNS)
/*
* just like above - but do not care for overflow of signed results
*/
return z;
}
+#endif /* (SOFTFLOATSPARC64_FOR_GCC || SOFTFLOAT_FOR_GCC) && SOFTFLOAT_NEED_FIXUNS */
/*
-------------------------------------------------------------------------------
}
aSig0 |= ( aSig1 != 0 );
shift64RightJamming( aSig0, 18, &aSig0 );
- zSig = aSig0;
+ zSig = (bits32)aSig0;
if ( aExp || zSig ) {
zSig |= 0x40000000;
aExp -= 0x3F81;
*/
float128 float128_rem( float128 a, float128 b )
{
- flag aSign, bSign, zSign;
+ flag aSign, zSign;
int32 aExp, bExp, expDiff;
bits64 aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2;
bits64 allZero, alternateASig0, alternateASig1, sigMean1;
bSig1 = extractFloat128Frac1( b );
bSig0 = extractFloat128Frac0( b );
bExp = extractFloat128Exp( b );
- bSign = extractFloat128Sign( b );
if ( aExp == 0x7FFF ) {
if ( ( aSig0 | aSig1 )
|| ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) {
if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( 0, 0, 0, 0 );
normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
}
- zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFE;
+ zExp = ( (unsigned int)(aExp - 0x3FFF) >> 1) + 0x3FFE;
aSig0 |= LIT64( 0x0001000000000000 );
- zSig0 = estimateSqrt32( aExp, aSig0>>17 );
+ zSig0 = estimateSqrt32((int16)aExp, (bits32)(aSig0>>17));
shortShift128Left( aSig0, aSig1, 13 - ( aExp & 1 ), &aSig0, &aSig1 );
zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 );
doubleZSig0 = zSig0<<1;
shiftCount = 0x433 - aExp;
savedASig = aSig;
aSig >>= shiftCount;
- z = aSig;
+ z = (uint32)aSig;
if ( ( aSig<<shiftCount ) != savedASig ) {
float_exception_flags |= float_flag_inexact;
}
-/* $NetBSD: softfloat-for-gcc.h,v 1.8 2009/12/14 01:07:42 matt Exp $ */
+/* $NetBSD: softfloat-for-gcc.h,v 1.9 2012/08/05 04:27:42 matt Exp $ */
/*
* Move private identifiers with external linkage into implementation
#define float128_le __letf2
#define float128_gt __gttf2
#endif
+
+#ifdef __ARM_EABI__
+#define __addsf3 __aeabi_fadd
+#define __adddf3 __aeabi_dadd
+
+#define __subsf3 __aeabi_fsub
+#define __subdf3 __aeabi_dsub
+
+#define __mulsf3 __aeabi_fmul
+#define __muldf3 __aeabi_dmul
+
+#define __divsf3 __aeabi_fdiv
+#define __divdf3 __aeabi_ddiv
+
+#define __floatsisf __aeabi_i2f
+#define __floatsidf __aeabi_i2d
+
+#define __floatdisf __aeabi_l2f
+#define __floatdidf __aeabi_l2d
+
+#define __floatunsisf __aeabi_ui2f
+#define __floatunsidf __aeabi_ui2d
+
+#define __floatundisf __aeabi_ul2f
+#define __floatundidf __aeabi_ul2d
+
+#define __fixsfsi __aeabi_f2iz
+#define __fixdfsi __aeabi_d2iz
+
+#define __fixsfdi __aeabi_f2lz
+#define __fixdfdi __aeabi_d2lz
+
+#define __fixunssfsi __aeabi_f2uiz
+#define __fixunsdfsi __aeabi_d2uiz
+
+#define __fixunssfdi __aeabi_f2ulz
+#define __fixunsdfdi __aeabi_d2ulz
+
+#define __extendsfdf2 __aeabi_f2d
+#define __truncdfsf2 __aeabi_d2f
+
+#define __eqsf2 __aeabi_fcmpeq
+#define __eqdf2 __aeabi_dcmpeq
+
+#define __ltsf2 __aeabi_fcmplt
+#define __ltdf2 __aeabi_dcmplt
+
+#define __lesf2 __aeabi_fcmple
+#define __ledf2 __aeabi_dcmple
+
+#define __gtsf2 __aeabi_fcmpgt
+#define __gtdf2 __aeabi_dcmpgt
+
+#define __gesf2 __aeabi_fcmpge
+#define __gedf2 __aeabi_dcmpge
+
+#endif /* __ARM_EABI__ */
-/* $NetBSD: softfloat-specialize,v 1.4 2004/09/26 21:13:27 jmmv Exp $ */
+/* $NetBSD: softfloat-specialize,v 1.7 2012/03/21 02:32:26 christos Exp $ */
/* This is a derivative work. */
*/
#include <signal.h>
+#include <string.h>
+#include <unistd.h>
/*
-------------------------------------------------------------------------------
should be simply `float_exception_flags |= flags;'.
-------------------------------------------------------------------------------
*/
+#ifdef SOFTFLOAT_FOR_GCC
+#define float_exception_mask _softfloat_float_exception_mask
+#endif
fp_except float_exception_mask = 0;
void float_raise( fp_except flags )
{
+ siginfo_t info;
float_exception_flags |= flags;
if ( flags & float_exception_mask ) {
- raise( SIGFPE );
+ memset(&info, 0, sizeof info);
+ info.si_signo = SIGFPE;
+ info.si_pid = getpid();
+ info.si_uid = geteuid();
+ if (flags & float_flag_underflow)
+ info.si_code = FPE_FLTUND;
+ else if (flags & float_flag_overflow)
+ info.si_code = FPE_FLTOVF;
+ else if (flags & float_flag_divbyzero)
+ info.si_code = FPE_FLTDIV;
+ else if (flags & float_flag_invalid)
+ info.si_code = FPE_FLTINV;
+ else if (flags & float_flag_inexact)
+ info.si_code = FPE_FLTRES;
+ sigqueueinfo(getpid(), &info);
}
}
+#undef float_exception_mask
/*
-------------------------------------------------------------------------------
flag float32_is_nan( float32 a )
{
- return ( 0xFF000000 < (bits32) ( a<<1 ) );
+ return ( (bits32)0xFF000000 < (bits32) ( a<<1 ) );
}
static float32 commonNaNToFloat32( commonNaNT a )
{
- return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | ( a.high>>41 );
+ return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | (bits32)( a.high>>41 );
}
flag float64_is_nan( float64 a )
{
- return ( LIT64( 0xFFE0000000000000 ) <
+ return ( (bits64)LIT64( 0xFFE0000000000000 ) <
(bits64) ( FLOAT64_DEMANGLE(a)<<1 ) );
}
commonNaNT z;
if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
- z.sign = FLOAT64_DEMANGLE(a)>>63;
+ z.sign = (flag)(FLOAT64_DEMANGLE(a)>>63);
z.low = 0;
z.high = FLOAT64_DEMANGLE(a)<<12;
return z;
{
return
- ( LIT64( 0xFFFE000000000000 ) <= (bits64) ( a.high<<1 ) )
+ ( (bits64)LIT64( 0xFFFE000000000000 ) <= (bits64) ( a.high<<1 ) )
&& ( a.low || ( a.high & LIT64( 0x0000FFFFFFFFFFFF ) ) );
}
commonNaNT z;
if ( float128_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
- z.sign = a.high>>63;
+ z.sign = (flag)(a.high>>63);
shortShift128Left( a.high, a.low, 16, &z.high, &z.low );
return z;
-.\" $NetBSD: __builtin_object_size.3,v 1.8 2010/12/19 09:33:52 jruoho Exp $
+.\" $NetBSD: __builtin_object_size.3,v 1.10 2012/07/19 06:44:12 wiz Exp $
.\"
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
-.Dd December 19, 2010
+.Dd July 18, 2012
.Dt __BUILTIN_OBJECT_SIZE 3
.Os
.Sh NAME
If the size of the object is not known or it has side effects the
.Fn __builtin_object_size
function returns:
-.Bl -tag -width (size_t)-1 -offset indent
-.It Dv (size_t)-1
+.Bl -tag -width (size_t)\-1 -offset indent
+.It Dv (size_t)\-1
for
.Fa type
.Dv 0
.Tn GCC 4.1 .
.Sh CAVEATS
This is a non-standard, compiler-specific extension.
+.Pp
+Note that currently the object size calculation pass is only done at -O1
+or above, meaning that this function always returns \-1 when the optimizer
+is off.
+.Pp
+There are some discussions about always doing the object size pass, but
+the issue is that without the optimization pass data sizes are not going
+to be correct.
+.Pp
+For that reason currently code fortification (size-checked replacement
+functions) is disabled when optimization is off.
#include <ssp/ssp.h>
#include <string.h>
-#include <ssp/string.h>
-
-#undef memcpy
#if __SSP_FORTIFY_LEVEL > 0
+#undef memcpy
+
void *
__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
size_t slen)
#include <ssp/ssp.h>
#include <string.h>
-#undef memmove
-
#if __SSP_FORTIFY_LEVEL > 0
+#undef memmove
+
void *
__memmove_chk(void *dst, void *src, size_t len,
size_t slen)
#include <ssp/ssp.h>
#include <string.h>
-#undef memset
-
#if __SSP_FORTIFY_LEVEL > 0
+#undef memset
+
void *
__memset_chk(void * __restrict dst, int val, size_t len, size_t slen)
{
-.\" $NetBSD: ssp.3,v 1.5 2010/12/19 08:28:40 jruoho Exp $
+.\" $NetBSD: ssp.3,v 1.6 2011/03/21 04:42:50 jruoho Exp $
.\"
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
-.Dd December 19, 2010
+.Dd March 21, 2011
.Dt SSP 3
.Os
.Sh NAME
.Xr __builtin_object_size 3 ,
.Xr stdio 3 ,
.Xr string 3 ,
-.Xr security 8
+.Xr security 7
.Sh HISTORY
The
.Nm ssp
#include <ssp/ssp.h>
#include <string.h>
-#undef strncpy
-
#if __SSP_FORTIFY_LEVEL > 0
+#undef strncpy
+
char *
__strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
size_t slen)
# from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91
-# $NetBSD: Makefile.inc,v 1.40 2010/12/22 16:59:10 christos Exp $
+# $NetBSD: Makefile.inc,v 1.41 2012/03/27 15:05:42 christos Exp $
# stdio sources
.PATH: ${.CURDIR}/stdio
MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \
fseek.3 ftello.3 fseek.3 rewind.3
MLINKS+=funopen.3 fropen.3 funopen.3 fwopen.3
+MLINKS+=funopen.3 funopen2.3 funopen.3 fropen2.3 funopen.3 fwopen2.3
MLINKS+=getc.3 fgetc.3 getc.3 getc_unlocked.3 getc.3 getchar.3 \
getc.3 getchar_unlocked.3 getc.3 getw.3
MLINKS+=getdelim.3 getline.3
-/* $NetBSD: asprintf.c,v 1.18 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: asprintf.c,v 1.19 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: asprintf.c,v 1.18 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: asprintf.c,v 1.19 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
if (_base == NULL)
goto err;
*str = (char *)_base;
- return (ret);
+ return ret;
err:
if (f._bf._base)
free(f._bf._base);
*str = NULL;
errno = ENOMEM;
- return (-1);
+ return -1;
}
-/* $NetBSD: clrerr.c,v 1.10 2003/08/07 16:43:21 agc Exp $ */
+/* $NetBSD: clrerr.c,v 1.11 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)clrerr.c 8.1 (Berkeley) 6/4/93";
#endif
-__RCSID("$NetBSD: clrerr.c,v 1.10 2003/08/07 16:43:21 agc Exp $");
+__RCSID("$NetBSD: clrerr.c,v 1.11 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#undef clearerr
void
-clearerr(fp)
- FILE *fp;
+clearerr(FILE *fp)
{
_DIAGASSERT(fp != NULL);
-/* $NetBSD: fclose.c,v 1.17 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: fclose.c,v 1.18 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fclose.c 8.1 (Berkeley) 6/4/93";
#endif
-__RCSID("$NetBSD: fclose.c,v 1.17 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: fclose.c,v 1.18 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include "local.h"
int
-fclose(fp)
- FILE *fp;
+fclose(FILE *fp)
{
int r;
if (fp->_flags == 0) { /* not open! */
errno = EBADF;
- return (EOF);
+ return EOF;
}
FLOCKFILE(fp);
WCIO_FREE(fp);
fp->_file = -1;
fp->_flags = 0; /* Release this FILE for reuse. */
fp->_r = fp->_w = 0; /* Mess up if reaccessed. */
- return (r);
+ return r;
}
-/* $NetBSD: fdopen.c,v 1.15 2008/03/13 15:40:00 christos Exp $ */
+/* $NetBSD: fdopen.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fdopen.c,v 1.15 2008/03/13 15:40:00 christos Exp $");
+__RCSID("$NetBSD: fdopen.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
FILE *
-fdopen(fd, mode)
- int fd;
- const char *mode;
+fdopen(int fd, const char *mode)
{
FILE *fp;
int flags, oflags, fdflags, tmp;
}
if ((flags = __sflags(mode, &oflags)) == 0)
- return (NULL);
+ return NULL;
/* Make sure the mode the user wants is a subset of the actual mode. */
if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
- return (NULL);
+ return NULL;
tmp = fdflags & O_ACCMODE;
if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {
errno = EINVAL;
- return (NULL);
+ return NULL;
}
if (oflags & O_NONBLOCK) {
struct stat st;
if (fstat(fd, &st) == -1) {
- return (NULL);
+ return NULL;
}
if (!S_ISREG(st.st_mode)) {
errno = EFTYPE;
- return (NULL);
+ return NULL;
}
}
if ((fp = __sfp()) == NULL)
- return (NULL);
+ return NULL;
fp->_flags = flags;
/*
* If opened for appending, but underlying descriptor does not have
fp->_write = __swrite;
fp->_seek = __sseek;
fp->_close = __sclose;
- return (fp);
+ return fp;
}
-/* $NetBSD: feof.c,v 1.11 2003/08/07 16:43:22 agc Exp $ */
+/* $NetBSD: feof.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)feof.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: feof.c,v 1.11 2003/08/07 16:43:22 agc Exp $");
+__RCSID("$NetBSD: feof.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#undef feof
int
-feof(fp)
- FILE *fp;
+feof(FILE *fp)
{
int r;
-/* $NetBSD: ferror.c,v 1.11 2003/08/07 16:43:22 agc Exp $ */
+/* $NetBSD: ferror.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)ferror.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ferror.c,v 1.11 2003/08/07 16:43:22 agc Exp $");
+__RCSID("$NetBSD: ferror.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#undef ferror
int
-ferror(fp)
- FILE *fp;
+ferror(FILE *fp)
{
int r;
-/* $NetBSD: fflush.c,v 1.15 2003/08/07 16:43:22 agc Exp $ */
+/* $NetBSD: fflush.c,v 1.18 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fflush.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fflush.c,v 1.15 2003/08/07 16:43:22 agc Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.18 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
+#include <stddef.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
/* Flush a single file, or (if fp is NULL) all files. */
int
-fflush(fp)
- FILE *fp;
+fflush(FILE *fp)
{
int r;
}
int
-__sflush(fp)
- FILE *fp;
+__sflush(FILE *fp)
{
unsigned char *p;
- int n, t;
+ size_t n;
+ ssize_t t;
_DIAGASSERT(fp != NULL);
t = fp->_flags;
if ((t & __SWR) == 0)
- return (0);
+ return 0;
if ((p = fp->_bf._base) == NULL)
- return (0);
+ return 0;
- n = fp->_p - p; /* write this much */
+ ptrdiff_t tp = fp->_p - p;
+ _DIAGASSERT(__type_fit(ssize_t, tp));
+ n = (ssize_t)tp; /* write this much */
/*
* Set these immediately to avoid problems with longjmp and to allow
t = (*fp->_write)(fp->_cookie, (char *)p, n);
if (t <= 0) {
fp->_flags |= __SERR;
- return (EOF);
+ return EOF;
}
}
- return (0);
+ if (fp->_flush)
+ return (*fp->_flush)(fp->_cookie);
+ return 0;
}
-/* $NetBSD: fgetc.c,v 1.11 2003/08/07 16:43:22 agc Exp $ */
+/* $NetBSD: fgetc.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fgetc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fgetc.c,v 1.11 2003/08/07 16:43:22 agc Exp $");
+__RCSID("$NetBSD: fgetc.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
int
-fgetc(fp)
- FILE *fp;
+fgetc(FILE *fp)
{
int r;
-/* $NetBSD: fgetpos.c,v 1.11 2003/08/07 16:43:23 agc Exp $ */
+/* $NetBSD: fgetpos.c,v 1.12 2012/01/22 18:36:17 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fgetpos.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fgetpos.c,v 1.11 2003/08/07 16:43:23 agc Exp $");
+__RCSID("$NetBSD: fgetpos.c,v 1.12 2012/01/22 18:36:17 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <stdio.h>
+#include "reentrant.h"
+#include "local.h"
int
-fgetpos(fp, pos)
- FILE *fp;
- fpos_t *pos;
+fgetpos(FILE * __restrict fp, fpos_t * __restrict pos)
{
+ struct wchar_io_data *wcio;
+
_DIAGASSERT(fp != NULL);
_DIAGASSERT(pos != NULL);
- return((*pos = (off_t)ftello(fp)) == (off_t)-1);
+ wcio = WCIO_GET(fp);
+ if (wcio != NULL && wcio->wcio_mode > 0) {
+ if (fp->_write)
+ pos->_mbstate_in = wcio->wcio_mbstate_in;
+ if (fp->_read)
+ pos->_mbstate_out = wcio->wcio_mbstate_out;
+ }
+ return (pos->_pos = ftello(fp)) == (off_t)-1;
}
-/* $NetBSD: fgets.c,v 1.27 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: fgets.c,v 1.28 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93";
#else
-__RCSID("$NetBSD: fgets.c,v 1.27 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: fgets.c,v 1.28 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Return first argument, or NULL if no characters were read.
*/
char *
-fgets(buf, n, fp)
- char *buf;
- int n;
- FILE *fp;
+fgets(char *buf, int n, FILE *fp)
{
int len;
char *s;
(void)memcpy(s, p, (size_t)len);
s[len] = 0;
FUNLOCKFILE(fp);
- return (buf);
+ return buf;
}
fp->_r -= len;
fp->_p += len;
} while (n != 0);
*s = 0;
FUNLOCKFILE(fp);
- return (buf);
+ return buf;
}
-/* $NetBSD: fgetwc.c,v 1.11 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: fgetwc.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c)2001 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fgetwc.c,v 1.11 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: fgetwc.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
nr = 1;
}
fp->_p += nr;
- fp->_r -= nr;
+ _DIAGASSERT(__type_fit(int, fp->_r - nr));
+ fp->_r -= (int)nr;
return wc;
}
r = __fgetwc_unlock(fp);
FUNLOCKFILE(fp);
- return (r);
+ return r;
}
-/* $NetBSD: fgetwln.c,v 1.4 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: fgetwln.c,v 1.5 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002-2004 Tim J. Robbins.
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/fgetwln.c,v 1.2 2004/08/06 17:00:09 tjr Exp $");
#else
-__RCSID("$NetBSD: fgetwln.c,v 1.4 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: fgetwln.c,v 1.5 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
_DIAGASSERT(fp != NULL);
if (_EXT(fp)->_fgetstr_len >= newsize)
- return (0);
+ return 0;
if ((p = realloc(_EXT(fp)->_fgetstr_buf, newsize)) == NULL)
- return (-1);
+ return -1;
_EXT(fp)->_fgetstr_buf = p;
_EXT(fp)->_fgetstr_len = newsize;
- return (0);
+ return 0;
}
wchar_t *
FUNLOCKFILE(fp);
*lenp = len;
- return ((wchar_t *)(void *)_EXT(fp)->_fgetstr_buf);
+ return (wchar_t *)(void *)_EXT(fp)->_fgetstr_buf;
error:
FUNLOCKFILE(fp);
*lenp = 0;
- return (NULL);
+ return NULL;
}
-/* $NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $ */
+/* $NetBSD: fgetws.c,v 1.3 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins.
#include <sys/cdefs.h>
#if defined(LIB_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $");
+__RCSID("$NetBSD: fgetws.c,v 1.3 2012/03/15 18:22:30 christos Exp $");
#endif
#include <assert.h>
#include "local.h"
wchar_t *
-fgetws(ws, n, fp)
- wchar_t * __restrict ws;
- int n;
- FILE * __restrict fp;
+fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
{
wchar_t *wsp;
wint_t wc;
*wsp++ = L'\0';
FUNLOCKFILE(fp);
- return (ws);
+ return ws;
error:
FUNLOCKFILE(fp);
- return (NULL);
+ return NULL;
}
-/* $NetBSD: fileno.c,v 1.12 2004/05/09 17:27:53 kleink Exp $ */
+/* $NetBSD: fileno.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fileno.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fileno.c,v 1.12 2004/05/09 17:27:53 kleink Exp $");
+__RCSID("$NetBSD: fileno.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* A subroutine version of the macro fileno.
*/
#undef fileno
-int _fileno __P((FILE *)); /* XXX */
+int _fileno(FILE *); /* XXX */
__weak_alias(fileno,_fileno)
int
-_fileno(fp)
- FILE *fp;
+_fileno(FILE *fp)
{
int r;
-/* $NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $ */
+/* $NetBSD: findfp.c,v 1.28 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)findfp.c 8.2 (Berkeley) 1/4/94";
#else
-__RCSID("$NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $");
+__RCSID("$NetBSD: findfp.c,v 1.28 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define NDYNAMIC 10 /* add ten more whenever necessary */
-#define std(flags, file) \
-/* p r w flags file bf lfbsize cookie close */ \
- { NULL, 0, 0, flags, file, { NULL, 0 }, 0, __sF + file, __sclose, \
-/* read seek write ext up */ \
- __sread, __sseek, __swrite, { (void *)(__sFext + file), 0 }, NULL, \
-/* ur ubuf, nbuf lb blksize offset */ \
- 0, { '\0', '\0', '\0' }, { '\0' }, { NULL, 0 }, 0, (fpos_t)0 }
+#if !defined(_LIBMINC) && !defined(__kernel__)
+#define std(flags, file) { \
+ ._p = NULL, \
+ ._r = 0, \
+ ._w = 0, \
+ ._flags = (flags), \
+ ._file = (file), \
+ ._bf = { ._base = NULL, ._size = 0 }, \
+ ._lbfsize = 0, \
+ ._cookie = __sF + (file), \
+ ._close = __sclose, \
+ ._read = __sread, \
+ ._seek = __sseek, \
+ ._write = __swrite, \
+ ._ext = { ._base = (void *)(__sFext + (file)), ._size = 0 }, \
+ ._up = NULL, \
+ ._ur = 0, \
+ ._ubuf = { [0] = '\0', [1] = '\0', [2] = '\0' }, \
+ ._nbuf = { [0] = '\0' }, \
+ ._flush = NULL, \
+ ._lb_unused = { '\0' }, \
+ ._blksize = 0, \
+ ._offset = (off_t)0, \
+}
+
+#else
+
+#define std(flags, file) { \
+ ._p = NULL, \
+ ._r = 0, \
+ ._w = 0, \
+ ._flags = (flags), \
+ ._file = (file), \
+ ._bf = { ._base = NULL, ._size = 0 }, \
+ ._lbfsize = 0, \
+ ._cookie = __sF + (file), \
+ ._close = NULL, \
+ ._read = NULL, \
+ ._seek = NULL, \
+ ._write = NULL, \
+ ._ext = { ._base = (void *)(__sFext + (file)), ._size = 0 }, \
+ ._up = NULL, \
+ ._ur = 0, \
+ ._ubuf = { [0] = '\0', [1] = '\0', [2] = '\0' }, \
+ ._nbuf = { [0] = '\0' }, \
+ ._flush = NULL, \
+ ._lb_unused = { '\0' }, \
+ ._blksize = 0, \
+ ._offset = (off_t)0, \
+}
+
+#endif /* !defined(_LIBMINC) && !defined(__kernel__) */
+
+#if !defined(__kernel__)
/* the usual - (stdin + stdout + stderr) */
static FILE usual[FOPEN_MAX - 3];
static struct __sfileext usualext[FOPEN_MAX - 3];
static struct glue uglue = { 0, FOPEN_MAX - 3, usual };
+#endif /* !defined(__kernel__) */
#if defined(_REENTRANT) && !defined(__lint__) /* XXX lint is busted */
#define STDEXT { ._lock = MUTEX_INITIALIZER, ._lockcond = COND_INITIALIZER }
std(__SWR, STDOUT_FILENO), /* stdout */
std(__SWR|__SNBF, STDERR_FILENO) /* stderr */
};
+
+#if !defined(__kernel__)
struct glue __sglue = { &uglue, 3, __sF };
-static struct glue *moreglue __P((int));
-void f_prealloc __P((void));
+void f_prealloc(void);
#ifdef _REENTRANT
rwlock_t __sfp_lock = RWLOCK_INITIALIZER;
#endif
static struct glue *
-moreglue(n)
- int n;
+moreglue(int n)
{
struct glue *g;
FILE *p;
struct __sfileext *pext;
static FILE empty;
- g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)
- + n * sizeof(struct __sfileext));
+ g = malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)
+ + n * sizeof(struct __sfileext));
if (g == NULL)
- return (NULL);
+ return NULL;
p = (FILE *)ALIGN((u_long)(g + 1));
g->next = NULL;
g->niobs = n;
p++;
pext++;
}
- return (g);
+ return g;
}
void
fp->_lbfsize = 0; /* not line buffered */
fp->_file = -1; /* no file */
/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */
+ fp->_flush = NULL; /* default flush */
_UB(fp)._base = NULL; /* no ungetc buffer */
_UB(fp)._size = 0;
memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data));
* Find a free FILE for fopen et al.
*/
FILE *
-__sfp()
+__sfp(void)
{
FILE *fp;
int n;
break;
}
rwlock_unlock(&__sfp_lock);
- return (NULL);
+ return NULL;
found:
__sfpinit(fp);
rwlock_unlock(&__sfp_lock);
- return (fp);
+ return fp;
}
/*
* but documented historically for certain applications. Bad applications.
*/
void
-f_prealloc()
+f_prealloc(void)
{
+#if !defined(_LIBMINC)
struct glue *g;
int n;
n = (int)sysconf(_SC_OPEN_MAX) - FOPEN_MAX + 20; /* 20 for slop. */
for (g = &__sglue; (n -= g->niobs) > 0 && g->next; g = g->next)
- /* void */;
+ continue;
if (n > 0)
g->next = moreglue(n);
+#endif /* !defined(_LIBMINC) */
}
/*
* The name `_cleanup' is, alas, fairly well known outside stdio.
*/
void
-_cleanup()
+_cleanup(void)
{
+#if !defined(_LIBMINC)
/* (void) _fwalk(fclose); */
(void) fflush(NULL); /* `cheating' */
+#endif /* !defined(_LIBMINC) */
}
/*
* __sinit() is called whenever stdio's internal variables must be set up.
*/
void
-__sinit()
+__sinit(void)
{
int i;
__cleanup = _cleanup; /* conservative */
__sdidinit = 1;
}
+#endif /* !defined(__kernel__) */
-/* $NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $ */
+/* $NetBSD: flags.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)flags.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $");
+__RCSID("$NetBSD: flags.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include "local.h"
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
/*
* Return the (stdio) flags for a given mode. Store the flags
* to be passed to an open() syscall through *optr.
* Return 0 on error.
*/
int
-__sflags(mode, optr)
- const char *mode;
- int *optr;
+__sflags(const char *mode, int *optr)
{
int ret, m, o;
default: /* illegal mode */
errno = EINVAL;
- return (0);
+ return 0;
}
/*
* [rwa]\+ or [rwa]b\+ means read and write
- * f means open only plain files.
+ * f means open only plain files,
+ * e means set close on exec.
*/
for (; *mode; mode++)
switch (*mode) {
case 'f':
o |= O_NONBLOCK;
break;
+ case 'e':
+ o |= O_CLOEXEC;
+ break;
case 'b':
break;
default: /* We could produce a warning here */
}
*optr = m | o;
- return (ret);
+ return ret;
}
-.\" $NetBSD: flockfile.3,v 1.4 2008/04/30 13:10:51 martin Exp $
+.\" $NetBSD: flockfile.3,v 1.6 2011/10/15 21:43:19 wiz Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 28, 2003
+.Dd October 15, 2011
.Dt FLOCKFILE 3
.Os
.Sh NAME
function returns 0.
Otherwise, it returns non-zero to indicate that the lock cannot be acquired.
.Sh SEE ALSO
+.Xr flock 2 ,
.Xr getc_unlocked 3 ,
.Xr getchar_unlocked 3 ,
+.Xr lockf 3 ,
.Xr putc_unlocked 3 ,
.Xr putchar_unlocked 3
.Sh STANDARDS
.Fn funlockfile
functions conform to
.St -p1003.1-2001 .
+.Sh HISTORY
+The
+.Fn flockfile
+function first appeared in
+.Fx 2.0 .
.Sh BUGS
The design of these interfaces does not allow for addressing the
problem of priority inversion.
-/* $NetBSD: flockfile.c,v 1.10 2010/12/08 02:07:03 joerg Exp $ */
+/* $NetBSD: flockfile.c,v 1.11 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: flockfile.c,v 1.10 2010/12/08 02:07:03 joerg Exp $");
+__RCSID("$NetBSD: flockfile.c,v 1.11 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
/* LINTED deliberate lack of effect */
(void)fp;
- return (0);
+ return 0;
}
void
-.\" $NetBSD: fmemopen.3,v 1.5 2010/10/07 00:14:14 enami Exp $
+.\" $NetBSD: fmemopen.3,v 1.7 2012/10/08 18:15:09 njoly Exp $
.\"
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" 3. 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.
.\"
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 24, 2010
+.Dd October 15, 2011
.Dt FMEMOPEN 3
.Os
.Sh NAME
.Sh SYNOPSIS
.In stdio.h
.Ft FILE *
-.Fn fmemopen "void *restrict buffer" "size_t size" "const char *restrict mode"
+.Fn fmemopen "void *restrict buffer" "size_t size" "const char *restrict mode"
.Sh DESCRIPTION
The
.Fn fmemopen
.Xr fflush 3 ,
.Xr fopen 3 ,
.Xr malloc 3
+.Sh STANDARDS
+The
+.Fn fmemopen
+function conforms to
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn fmemopen
-/* $NetBSD: fmemopen.c,v 1.5 2010/09/27 17:08:29 tnozaki Exp $ */
+/* $NetBSD: fmemopen.c,v 1.8 2012/03/29 14:27:33 christos Exp $ */
/*-
* Copyright (c)2007, 2010 Takehiko NOZAKI,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmemopen.c,v 1.5 2010/09/27 17:08:29 tnozaki Exp $");
+__RCSID("$NetBSD: fmemopen.c,v 1.8 2012/03/29 14:27:33 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
char *head, *tail, *cur, *eob;
};
-static int
-fmemopen_read(void *cookie, char *buf, int nbytes)
+static ssize_t
+fmemopen_read(void *cookie, void *buf, size_t nbytes)
{
struct fmemopen_cookie *p;
- char *s;
+ char *s, *b = buf;
_DIAGASSERT(cookie != NULL);
_DIAGASSERT(buf != NULL && nbytes > 0);
do {
if (p->cur == p->tail)
break;
- *buf++ = *p->cur++;
+ *b++ = *p->cur++;
} while (--nbytes > 0);
- return (int)(p->cur - s);
+ return (ssize_t)(p->cur - s);
}
-static int
-fmemopen_write(void *cookie, const char *buf, int nbytes)
+static ssize_t
+fmemopen_write(void *cookie, const void *buf, size_t nbytes)
{
struct fmemopen_cookie *p;
char *s;
+ const char *b = buf;
_DIAGASSERT(cookie != NULL);
_DIAGASSERT(buf != NULL && nbytes > 0);
s = p->cur;
do {
if (p->cur == p->tail - 1) {
- if (*buf == '\0') {
+ if (*b == '\0') {
*p->cur++ = '\0';
goto ok;
}
break;
}
- *p->cur++ = *buf++;
+ *p->cur++ = *b++;
} while (--nbytes > 0);
*p->cur = '\0';
ok:
if (p->cur > p->eob)
p->eob = p->cur;
- return (int)(p->cur - s);
+ return (ssize_t)(p->cur - s);
+}
+
+#ifdef notyet
+static int
+fmemopen_flush(void *cookie)
+{
+ struct fmemopen_cookie *p;
+
+ _DIAGASSERT(cookie != NULL);
+
+ p = (struct fmemopen_cookie *)cookie;
+ if (p->cur >= p->tail)
+ return -1;
+ *p->cur = '\0';
+ return 0;
}
+#endif
-static fpos_t
-fmemopen_seek(void *cookie, fpos_t offset, int whence)
+static off_t
+fmemopen_seek(void *cookie, off_t offset, int whence)
{
struct fmemopen_cookie *p;
errno = EINVAL;
goto error;
}
- if (offset >= (fpos_t)0 && offset <= p->tail - p->head) {
+ if (offset >= (off_t)0 && offset <= p->tail - p->head) {
p->cur = p->head + (ptrdiff_t)offset;
- return (fpos_t)(p->cur - p->head);
+ return (off_t)(p->cur - p->head);
}
error:
- return (fpos_t)-1;
+ return (off_t)-1;
}
static int
goto release;
}
*cookie->head = '\0';
- fp->_close = &fmemopen_close1;
+ fp->_close = fmemopen_close1;
} else {
cookie->head = (char *)buf;
if (oflags & O_TRUNC)
*cookie->head = '\0';
- fp->_close = &fmemopen_close0;
+ fp->_close = fmemopen_close0;
}
cookie->tail = cookie->head + size;
cookie->cur = (oflags & O_APPEND) ? cookie->eob : cookie->head;
fp->_flags = flags;
- fp->_write = (flags & __SRD) ? NULL : &fmemopen_write;
- fp->_read = (flags & __SWR) ? NULL : &fmemopen_read;
- fp->_seek = &fmemopen_seek;
+ fp->_write = (flags & __SRD) ? NULL : fmemopen_write;
+ fp->_read = (flags & __SWR) ? NULL : fmemopen_read;
+ fp->_seek = fmemopen_seek;
+#ifdef notyet
+ fp->_flush = fmemopen_flush;
+#endif
fp->_cookie = (void *)cookie;
return fp;
-.\" $NetBSD: fopen.3,v 1.24 2010/04/05 21:34:47 joerg Exp $
+.\" $NetBSD: fopen.3,v 1.28 2012/07/02 20:02:43 wiz Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd July 18, 2011
.Dt FOPEN 3
.Os
.Sh NAME
.Fa mode
points to a string beginning with one of the following
sequences (Additional characters may follow these sequences.):
-.Bl -tag -width indent
+.Bl -tag -width 4n
+.It Dq Li a
+Append; open for writing.
+The file is created if it does not exist.
+.It Dq Li a+
+Append; open for reading and writing.
+The file is created if it does not exist.
.It Dq Li r
Open for reading.
.It Dq Li r+
.It Dq Li w+
Open for reading and writing.
Truncate file to zero length or create file.
-.It Dq Li a
-Append; open for writing.
-The file is created if it does not exist.
-.It Dq Li a+
-Append; open for reading and writing.
-The file is created if it does not exist.
.El
.Pp
-The
+Additionally, the
.Fa mode
-string can also include the letter ``b'' either as a last character or
-as a character between the characters in any of the two-character strings
-described above.
+string can also include one of the following letters:
+.Bl -tag -width 4n
+.It Sq b
+The letter
+.Sq b
+may appear either as a last character or as a character between the
+characters in any of the two-character strings described above.
This is strictly for compatibility with
.St -ansiC
-and has no effect; the ``b'' is ignored.
-.Pp
-The letter ``f'' in the mode string restricts fopen to regular
-files; if the file opened is not a regular file,
+and has no effect; the
+.Sq b
+is ignored.
+.It Sq e
+The letter
+.Sq e
+in the mode string sets the close-on-exec flag in the file descriptors of
+the newly opened file files; if the operation fails,
+.Fn fopen
+will fail.
+This is a non
+.St -ansiC
+extension.
+.It Sq f
+The letter
+.Sq f
+in the mode string restricts
+.Fn fopen
+to regular files; if the file opened is not a regular file,
.Fn fopen
will fail.
This is a non
.St -ansiC
extension.
+.El
.Pp
Any created files will have mode
.Pf \*q Dv S_IRUSR
.Dv S_IWOTH Ns \*q
.Pq Li 0666 ,
as modified by the process'
-umask value (see
-.Xr umask 2 ) .
+.Xr umask 2
+value.
.Pp
Opening a file with append mode causes all subsequent writes to it
to be forced to the then current end of file, regardless of intervening
.Va errno
is set to indicate the error.
.Sh ERRORS
+The functions may fail if:
.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa mode
-provided to
-.Fn fopen ,
-.Fn fdopen ,
-or
-.Fn freopen
-was invalid.
.It Bq Er EFTYPE
The file is not a regular file and the character ``f'' is specified
in the mode.
+.It Bq Er EINVAL
+The specified
+.Fa mode
+was invalid.
.El
.Pp
The
.Fn fopen
and
.Fn freopen
-functions
-conform to
+functions conform to
.St -ansiC .
-The
-.Fn fdopen
-function conforms to
-.St -p1003.1-90 .
+All three functions are specified in
+.St -p1003.1-2008 .
.Sh CAVEATS
Proper code using
.Fn fdopen
-/* $NetBSD: fopen.c,v 1.13 2008/03/13 15:40:00 christos Exp $ */
+/* $NetBSD: fopen.c,v 1.15 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fopen.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fopen.c,v 1.13 2008/03/13 15:40:00 christos Exp $");
+__RCSID("$NetBSD: fopen.c,v 1.15 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
FILE *
-fopen(file, mode)
- const char *file;
- const char *mode;
+fopen(const char *file, const char *mode)
{
FILE *fp;
int f;
_DIAGASSERT(file != NULL);
if ((flags = __sflags(mode, &oflags)) == 0)
- return (NULL);
+ return NULL;
if ((fp = __sfp()) == NULL)
- return (NULL);
+ return NULL;
if ((f = open(file, oflags, DEFFILEMODE)) < 0)
goto release;
if (oflags & O_NONBLOCK) {
* fseek and ftell.)
*/
if (oflags & O_APPEND)
- (void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
- return (fp);
+ (void) __sseek((void *)fp, (off_t)0, SEEK_END);
+ return fp;
release:
fp->_flags = 0; /* release */
- return (NULL);
+ return NULL;
}
-/* $NetBSD: fprintf.c,v 1.11 2003/08/07 16:43:24 agc Exp $ */
+/* $NetBSD: fprintf.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fprintf.c,v 1.11 2003/08/07 16:43:24 agc Exp $");
+__RCSID("$NetBSD: fprintf.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
va_start(ap, fmt);
ret = vfprintf(fp, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: fpurge.c,v 1.13 2003/08/07 16:43:24 agc Exp $ */
+/* $NetBSD: fpurge.c,v 1.14 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fpurge.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fpurge.c,v 1.13 2003/08/07 16:43:24 agc Exp $");
+__RCSID("$NetBSD: fpurge.c,v 1.14 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* given FILE's buffer empty.
*/
int
-fpurge(fp)
- FILE *fp;
+fpurge(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if (fp->_flags == 0) {
errno = EBADF;
- return (EOF);
+ return EOF;
}
FLOCKFILE(fp);
if (HASUB(fp))
fp->_r = 0;
fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
FUNLOCKFILE(fp);
- return (0);
+ return 0;
}
-/* $NetBSD: fputc.c,v 1.12 2003/08/07 16:43:24 agc Exp $ */
+/* $NetBSD: fputc.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fputc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fputc.c,v 1.12 2003/08/07 16:43:24 agc Exp $");
+__RCSID("$NetBSD: fputc.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
int
-fputc(c, fp)
- int c;
- FILE *fp;
+fputc(int c, FILE *fp)
{
int r;
-/* $NetBSD: fputs.c,v 1.14 2005/06/22 19:45:22 christos Exp $ */
+/* $NetBSD: fputs.c,v 1.15 2012/03/13 21:13:46 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fputs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fputs.c,v 1.14 2005/06/22 19:45:22 christos Exp $");
+__RCSID("$NetBSD: fputs.c,v 1.15 2012/03/13 21:13:46 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Write the given string to the given file.
*/
int
-fputs(s, fp)
- const char *s;
- FILE *fp;
+fputs(const char *s, FILE *fp)
{
struct __suio uio;
struct __siov iov;
s = "(null)";
iov.iov_base = __UNCONST(s);
- iov.iov_len = uio.uio_resid = strlen(s);
+ uio.uio_resid = iov.iov_len = strlen(s);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
FLOCKFILE(fp);
-/* $NetBSD: fputwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $ */
+/* $NetBSD: fputwc.c,v 1.5 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c)2001 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fputwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $");
+__RCSID("$NetBSD: fputwc.c,v 1.5 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
r = __fputwc_unlock(wc, fp);
FUNLOCKFILE(fp);
- return (r);
+ return r;
}
-/* $NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */
+/* $NetBSD: fputws.c,v 1.2 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $");
+__RCSID("$NetBSD: fputws.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
#endif
#include <assert.h>
#include "local.h"
int
-fputws(ws, fp)
- const wchar_t * __restrict ws;
- FILE * __restrict fp;
+fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
{
_DIAGASSERT(fp != NULL);
_DIAGASSERT(ws != NULL);
while (*ws != '\0') {
if (__fputwc_unlock(*ws++, fp) == WEOF) {
FUNLOCKFILE(fp);
- return (-1);
+ return -1;
}
}
FUNLOCKFILE(fp);
- return (0);
+ return 0;
}
-.\" $NetBSD: fread.3,v 1.14 2009/01/11 02:46:29 christos Exp $
+.\" $NetBSD: fread.3,v 1.15 2011/09/11 04:55:48 jruoho Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)fread.3 8.2 (Berkeley) 3/8/94
.\"
-.Dd December 19, 2008
+.Dd September 11, 2011
.Dt FREAD 3
.Os
.Sh NAME
and
.Fn fwrite
calls without setting the file position explicitly using
-.Fn fsetpos
+.Xr fsetpos 3
between read and write or write and read operations will lead to unexpected
results because of buffering the file pointer not being set to the
expected position after each operation completes.
-/* $NetBSD: fread.c,v 1.20 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: fread.c,v 1.22 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fread.c 8.2 (Berkeley) 12/11/93";
#else
-__RCSID("$NetBSD: fread.c,v 1.20 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: fread.c,v 1.22 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
size_t
-fread(buf, size, count, fp)
- void *buf;
- size_t size, count;
- FILE *fp;
+fread(void *buf, size_t size, size_t count, FILE *fp)
{
size_t resid;
char *p;
* fwrite, the SUSv2 does.
*/
if ((resid = count * size) == 0)
- return (0);
+ return 0;
_DIAGASSERT(buf != NULL);
if (__srefill(fp)) {
/* no more input: return partial result */
FUNLOCKFILE(fp);
- return ((total - resid) / size);
+ return (total - resid) / size;
}
}
(void)memcpy(p, fp->_p, resid);
- fp->_r -= resid;
+
+ _DIAGASSERT(__type_fit(int, fp->_r - resid));
+ fp->_r -= (int)resid;
fp->_p += resid;
FUNLOCKFILE(fp);
- return (count);
+ return count;
}
-/* $NetBSD: freopen.c,v 1.16 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: freopen.c,v 1.19 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: freopen.c,v 1.16 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: freopen.c,v 1.19 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* all possible, no matter what.
*/
FILE *
-freopen(file, mode, fp)
- const char *file, *mode;
- FILE *fp;
+freopen(const char *file, const char *mode, FILE *fp)
{
int f;
int flags, isopen, oflags, sverrno, wantfd;
if ((flags = __sflags(mode, &oflags)) == 0) {
(void) fclose(fp);
- return (NULL);
+ return NULL;
}
if (!__sdidinit)
} else {
/* flush the stream; ANSI doesn't require this. */
if (fp->_flags & __SWR)
- (void) __sflush(fp);
+ (void)__sflush(fp);
/* if close is NULL, closing is a no-op, hence pointless */
isopen = fp->_close != NULL;
if ((wantfd = __sfileno(fp)) == -1 && isopen) {
if (f < 0) { /* did not get it after all */
fp->_flags = 0; /* set it free */
errno = sverrno; /* restore in case _close clobbered */
- return (NULL);
+ return NULL;
}
if (oflags & O_NONBLOCK) {
sverrno = errno;
(void)close(f);
errno = sverrno;
- return (NULL);
+ return NULL;
}
if (!S_ISREG(st.st_mode)) {
(void)close(f);
errno = EFTYPE;
- return (NULL);
+ return NULL;
}
}
* fseek and ftell.)
*/
if (oflags & O_APPEND)
- (void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
- return (fp);
+ (void) __sseek((void *)fp, (off_t)0, SEEK_END);
+ return fp;
}
-/* $NetBSD: fscanf.c,v 1.12 2003/08/07 16:43:25 agc Exp $ */
+/* $NetBSD: fscanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fscanf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fscanf.c,v 1.12 2003/08/07 16:43:25 agc Exp $");
+__RCSID("$NetBSD: fscanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
va_start(ap, fmt);
ret = __svfscanf(fp, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-.\" $NetBSD: fseek.3,v 1.25 2010/10/22 21:29:31 christos Exp $
+.\" $NetBSD: fseek.3,v 1.27 2012/01/22 19:13:42 wiz Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)fseek.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd October 22, 2010
+.Dd January 21, 2012
.Dt FSEEK 3
.Os
.Sh NAME
(see
.Xr clearerr 3 ) .
.Pp
-In this implementation, the
-.Fn fgetpos
-and
-.Fn fsetpos
-functions
-are alternative interfaces equivalent to
-.Fn ftell ,
-.Fn ftello ,
-.Fn fseek ,
-and
-.Fn fseeko
-(with whence set to
-.Dv SEEK_SET ) ,
-setting and storing the current value of
-the file offset into or from the object referenced by
-.Fa pos .
-In others implementations, an
+In this implementations, an
.Dq Fa fpos_t
-object may be a complex object
-and these routines may be the only way to portably reposition a text stream.
+object is a complex object that represents both the position and the parse
+state of the stream making these routines are the only way to portably
+reposition a text stream.
+The
+.Ar pos
+argument of
+.Fn fsetpos
+must always be initialized by
+a call to
+.Fn fgetpos .
.Sh RETURN VALUES
The
.Fn rewind
-/* $NetBSD: fseeko.c,v 1.8 2009/01/31 00:08:05 lukem Exp $ */
+/* $NetBSD: fseeko.c,v 1.12 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fseeko.c,v 1.8 2009/01/31 00:08:05 lukem Exp $");
+__RCSID("$NetBSD: fseeko.c,v 1.12 2012/03/27 15:05:42 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(fseeko, _fseeko)
#endif
-#define POS_ERR (-(fpos_t)1)
+#define POS_ERR ((off_t)-1)
/*
* Seek the given file to the given offset.
int
fseeko(FILE *fp, off_t offset, int whence)
{
- fpos_t (*seekfn)(void *, fpos_t, int);
- fpos_t target, curoff;
+ off_t (*seekfn)(void *, off_t, int);
+ off_t target, curoff;
size_t n;
struct stat st;
int havepos;
if ((seekfn = fp->_seek) == NULL) {
errno = ESPIPE; /* historic practice */
FUNLOCKFILE(fp);
- return (-1);
+ return -1;
}
/*
* we have to first find the current stream offset a la
* ftell (see ftell for details).
*/
- __sflush(fp); /* may adjust seek offset on append stream */
+ (void)__sflush(fp); /* may adjust seek offset on append stream */
if (fp->_flags & __SOFF)
curoff = fp->_offset;
else {
- curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);
+ curoff = (*seekfn)(fp->_cookie, (off_t)0, SEEK_CUR);
if (curoff == POS_ERR) {
FUNLOCKFILE(fp);
- return (-1);
+ return -1;
}
}
if (fp->_flags & __SRD) {
default:
errno = EINVAL;
FUNLOCKFILE(fp);
- return (-1);
+ return -1;
}
/*
if (fp->_flags & __SOFF)
curoff = fp->_offset;
else {
- curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);
+ curoff = (*seekfn)(fp->_cookie, (off_t)0, SEEK_CUR);
if (curoff == POS_ERR)
goto dumb;
}
* skip this; see fgetln.c.)
*/
if ((fp->_flags & __SMOD) == 0 &&
- target >= curoff && target < (fpos_t)(curoff + n)) {
+ target >= curoff && target < curoff + (off_t)n) {
int o = (int)(target - curoff);
fp->_p = fp->_bf._base + o;
- fp->_r = n - o;
+ _DIAGASSERT(__type_fit(int, n - o));
+ fp->_r = (int)(n - o);
if (HASUB(fp))
FREEUB(fp);
fp->_flags &= ~__SEOF;
FUNLOCKFILE(fp);
- return (0);
+ return 0;
}
/*
if (__srefill(fp) || (size_t)fp->_r < n)
goto dumb;
fp->_p += n;
- fp->_r -= n;
+ _DIAGASSERT(__type_fit(int, fp->_r - n));
+ fp->_r -= (int)n;
}
FUNLOCKFILE(fp);
- return (0);
+ return 0;
/*
* We get here if we cannot optimise the seek ... just
*/
dumb:
if (__sflush(fp) ||
- (*seekfn)(fp->_cookie, (fpos_t)offset, whence) == POS_ERR) {
+ (*seekfn)(fp->_cookie, offset, whence) == POS_ERR) {
FUNLOCKFILE(fp);
- return (-1);
+ return -1;
}
/* success: clear EOF indicator and discard ungetc() data */
if (HASUB(fp))
/* fp->_w = 0; */ /* unnecessary (I think...) */
fp->_flags &= ~__SEOF;
FUNLOCKFILE(fp);
- return (0);
+ return 0;
}
-/* $NetBSD: fsetpos.c,v 1.10 2003/08/07 16:43:25 agc Exp $ */
+/* $NetBSD: fsetpos.c,v 1.11 2012/01/22 18:36:17 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fsetpos.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fsetpos.c,v 1.10 2003/08/07 16:43:25 agc Exp $");
+__RCSID("$NetBSD: fsetpos.c,v 1.11 2012/01/22 18:36:17 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <stdio.h>
+#include "reentrant.h"
+#include "local.h"
/*
* fsetpos: like fseek.
*/
int
-fsetpos(iop, pos)
- FILE *iop;
- const fpos_t *pos;
+fsetpos(FILE * __restrict fp, const fpos_t * __restrict pos)
{
- _DIAGASSERT(iop != NULL);
+ struct wchar_io_data *wcio;
+
+ _DIAGASSERT(fp != NULL);
_DIAGASSERT(pos != NULL);
- return (fseeko(iop, (off_t)*pos, SEEK_SET));
+ wcio = WCIO_GET(fp);
+ if (wcio != NULL && wcio->wcio_mode > 0) {
+ if (fp->_write)
+ wcio->wcio_mbstate_in = pos->_mbstate_in;
+ if (fp->_read)
+ wcio->wcio_mbstate_out = pos->_mbstate_out;
+ }
+ return fseeko(fp, pos->_pos, SEEK_SET) == (off_t)-1;
}
-/* $NetBSD: ftell.c,v 1.17 2010/10/24 17:44:32 tron Exp $ */
+/* $NetBSD: ftell.c,v 1.20 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: ftell.c,v 1.17 2010/10/24 17:44:32 tron Exp $");
+__RCSID("$NetBSD: ftell.c,v 1.20 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* ftell: return current offset.
*/
long
-ftell(fp)
- FILE *fp;
+ftell(FILE *fp)
{
- fpos_t pos;
+ off_t pos;
FLOCKFILE(fp);
* Find offset of underlying I/O object, then
* adjust for buffered bytes.
*/
- __sflush(fp); /* may adjust seek offset on append stream */
+ (void)__sflush(fp); /* may adjust seek offset on append stream */
if (fp->_flags & __SOFF)
pos = fp->_offset;
else {
- pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);
+ pos = (*fp->_seek)(fp->_cookie, (off_t)0, SEEK_CUR);
if (pos == -1L) {
FUNLOCKFILE(fp);
- return (long)(pos);
+ return (long)pos;
}
}
if (fp->_flags & __SRD) {
}
FUNLOCKFILE(fp);
- if (__fpos_overflow(pos)) {
+ if (__long_overflow(pos)) {
errno = EOVERFLOW;
return -1L;
}
- return (long)(pos);
+ return (long)pos;
}
-/* $NetBSD: ftello.c,v 1.4 2003/08/07 16:43:26 agc Exp $ */
+/* $NetBSD: ftello.c,v 1.7 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ftello.c,v 1.4 2003/08/07 16:43:26 agc Exp $");
+__RCSID("$NetBSD: ftello.c,v 1.7 2012/03/27 15:05:42 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
* ftell: return current offset.
*/
off_t
-ftello(fp)
- FILE *fp;
+ftello(FILE *fp)
{
- fpos_t pos;
+ off_t pos;
FLOCKFILE(fp);
if (fp->_seek == NULL) {
FUNLOCKFILE(fp);
errno = ESPIPE; /* historic practice */
- return ((off_t)-1);
+ return (off_t)-1;
}
/*
* Find offset of underlying I/O object, then
* adjust for buffered bytes.
*/
- __sflush(fp); /* may adjust seek offset on append stream */
+ (void)__sflush(fp); /* may adjust seek offset on append stream */
if (fp->_flags & __SOFF)
pos = fp->_offset;
else {
- pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);
- if (pos == (fpos_t)-1) {
+ pos = (*fp->_seek)(fp->_cookie, (off_t)0, SEEK_CUR);
+ if (pos == (off_t)-1) {
FUNLOCKFILE(fp);
- return (pos);
+ return pos;
}
}
if (fp->_flags & __SRD) {
pos += fp->_p - fp->_bf._base;
}
FUNLOCKFILE(fp);
- return (pos);
+ return pos;
}
-.\" $NetBSD: funopen.3,v 1.15 2010/03/22 19:30:54 joerg Exp $
+.\" $NetBSD: funopen.3,v 1.22 2012/10/08 18:15:09 njoly Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)funopen.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd June 9, 1993
+.Dd March 16, 2012
.Dt FUNOPEN 3
.Os
.Sh NAME
.Nm funopen ,
+.Nm funopen2 ,
.Nm fropen ,
-.Nm fwopen
+.Nm fropen2 ,
+.Nm fwopen ,
+.Nm fwopen2
.Nd open a stream
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdio.h
.Ft FILE *
-.Fn funopen "void *cookie" "int (*readfn)(void *, char *, int)" "int (*writefn)(void *, const char *, int)" "fpos_t (*seekfn)(void *, fpos_t, int)" "int (*closefn)(void *)"
+.Fn funopen "void *cookie" "int (*readfn)(void *, char *, int)" "int (*writefn)(void *, const char *, int)" "off_t (*seekfn)(void *, off_t, int)" "int (*closefn)(void *)"
+.Fn funopen2 "void *cookie" "ssize_t (*readfn)(void *, void *, size_t)" "ssize_t (*writefn)(void *, const void *, size_t)" "off_t (*seekfn)(void *, off_t, int)" "int (*flushfn)(void *)" "int (*closefn)(void *)"
.Ft FILE *
-.Fn fropen "void *cookie" "int (*readfn)(void *, char *, int)"
+.Fn fropen "void *cookie" "int (*readfn)(void *, char *, int)"
.Ft FILE *
-.Fn fwopen "void *cookie" "int (*writefn)(void *, const char *, int)"
+.Fn fropen2 "void *cookie" "ssize_t (*readfn)(void *, void *, size_t)"
+.Ft FILE *
+.Fn fwopen "void *cookie" "int (*writefn)(void *, const char *, int)"
+.Ft FILE *
+.Fn fwopen2 "void *cookie" "ssize_t (*writefn)(void *, const void *, size_t)"
.Sh DESCRIPTION
The
.Fn funopen
functions will be used to read, write, seek and
close the new stream.
.Pp
+The
+.Fn funopen2
+function provides sightly different read and write signatures, which match
+better the corresponding system calls, plus the ability to augment the
+streams default flushing function.
+If a flushing function is provided, then it is called after all data has
+been written to the stream.
+.Pp
In general, omitting a function means that any attempt to perform the
associated operation on the resulting stream will fail.
If the close function is omitted, closing the stream will flush
.Fa cookie
argument specified to
.Fn funopen
-in place of the traditional file descriptor argument,
-and
-.Fa seekfn
-uses
-.Li fpos_t
-instead of
-.Li off_t .
+in place of the traditional file descriptor argument.
.Pp
Read and write
.Tn I/O
.Fn funopen
functions first appeared in
.Bx 4.4 .
-.Sh BUGS
The
-.Fn funopen
-function
-may not be portable to systems other than
-.Bx .
+.Fn funopen2
+functions first appeared in
+.Nx 7.0 .
+.Sh CAVEATS
+All three functions are specific to
+.Nx
+and thus unportable.
-/* $NetBSD: funopen.c,v 1.10 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: funopen.c,v 1.14 2012/03/28 15:21:11 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)funopen.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: funopen.c,v 1.10 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: funopen.c,v 1.14 2012/03/28 15:21:11 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
+#include <stddef.h>
#include "reentrant.h"
#include "local.h"
FILE *
-funopen(cookie, readfn, writefn, seekfn, closefn)
- const void *cookie;
- int (*readfn) __P((void *, char *, int));
- int (*writefn) __P((void *, const char *, int));
- fpos_t (*seekfn) __P((void *, fpos_t, int));
- int (*closefn) __P((void *));
+funopen2(const void *cookie,
+ ssize_t (*readfn)(void *, void *, size_t),
+ ssize_t (*writefn)(void *, const void *, size_t),
+ off_t (*seekfn)(void *, off_t, int),
+ int (*flushfn)(void *),
+ int (*closefn)(void *))
{
FILE *fp;
int flags;
if (readfn == NULL) {
if (writefn == NULL) { /* illegal */
errno = EINVAL;
- return (NULL);
+ return NULL;
} else
flags = __SWR; /* write only */
} else {
flags = __SRW; /* read-write */
}
if ((fp = __sfp()) == NULL)
- return (NULL);
+ return NULL;
fp->_flags = flags;
fp->_file = -1;
fp->_cookie = __UNCONST(cookie);
fp->_read = readfn;
fp->_write = writefn;
fp->_seek = seekfn;
+ fp->_flush = flushfn;
fp->_close = closefn;
- return (fp);
+ return fp;
}
+
+typedef struct {
+ void *cookie;
+ int (*readfn)(void *, char *, int);
+ int (*writefn)(void *, const char *, int);
+ off_t (*seekfn)(void *, off_t, int);
+ int (*closefn)(void *);
+} dookie_t;
+
+static ssize_t
+creadfn(void *dookie, void *buf, size_t len)
+{
+ dookie_t *d = dookie;
+ if (len > INT_MAX)
+ len = INT_MAX;
+ return (*d->readfn)(d->cookie, buf, (int)len);
+}
+
+static ssize_t
+cwritefn(void *dookie, const void *buf, size_t len)
+{
+ dookie_t *d = dookie;
+ ssize_t nr;
+ size_t l = len;
+ const char *b = buf;
+
+ while (l) {
+ size_t nw = l > INT_MAX ? INT_MAX : l;
+ nr = (*d->writefn)(d->cookie, buf, (int)nw);
+ if (nr == -1) {
+ if (len == l)
+ return -1;
+ else
+ return len - l;
+ }
+ b += nr;
+ l -= nr;
+ }
+ return len;
+}
+
+static off_t
+cseekfn(void *dookie, off_t off, int whence)
+{
+ dookie_t *d = dookie;
+ return (*d->seekfn)(d->cookie, off, whence);
+}
+
+static int
+cclosefn(void *dookie)
+{
+ dookie_t *d = dookie;
+ void *c = d->cookie;
+ int (*cf)(void *) = d->closefn;
+ free(dookie);
+ return (*cf)(c);
+}
+
+FILE *
+funopen(const void *cookie,
+ int (*readfn)(void *, char *, int),
+ int (*writefn)(void *, const char *, int),
+ off_t (*seekfn)(void *, off_t, int),
+ int (*closefn)(void *))
+{
+ dookie_t *d;
+ FILE *fp;
+
+ if ((d = malloc(sizeof(*d))) == NULL)
+ return NULL;
+
+ d->cookie = __UNCONST(cookie);
+ d->readfn = readfn;
+ d->writefn = writefn;
+ d->seekfn = seekfn;
+ d->closefn = closefn;
+ fp = funopen2(d,
+ d->readfn ? creadfn : NULL,
+ d->writefn ? cwritefn : NULL,
+ d->seekfn ? cseekfn : NULL,
+ NULL,
+ d->closefn ? cclosefn : NULL);
+ if (fp != NULL)
+ return fp;
+ free(d);
+ return NULL;
+ }
-/* $NetBSD: fvwrite.c,v 1.21 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: fvwrite.c,v 1.25 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fvwrite.c,v 1.21 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: fvwrite.c,v 1.25 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
+#include <stddef.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
* to the three different kinds of output buffering is handled here.
*/
int
-__sfvwrite(fp, uio)
- FILE *fp;
- struct __suio *uio;
+__sfvwrite(FILE *fp, struct __suio *uio)
{
- int len;
+ size_t len;
char *p;
struct __siov *iov;
- int w, s;
+ int s;
+ ssize_t w;
char *nl;
- int nlknown, nldist;
+ size_t nlknown, nldist;
_DIAGASSERT(fp != NULL);
_DIAGASSERT(uio != NULL);
- if ((int)uio->uio_resid < 0) {
+ if ((ssize_t)uio->uio_resid < 0) {
errno = EINVAL;
- return (EOF);
+ return EOF;
}
- if ((len = uio->uio_resid) == 0)
- return (0);
+ if (uio->uio_resid == 0)
+ return 0;
/* make sure we can write */
if (cantwrite(fp)) {
errno = EBADF;
- return (EOF);
+ return EOF;
}
#define MIN(a, b) ((a) < (b) ? (a) : (b))
*/
do {
GETIOV(;);
- w = (*fp->_write)(fp->_cookie, p,
- (int)MIN(len, BUFSIZ));
+ w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ));
if (w <= 0)
goto err;
p += w;
do {
GETIOV(;);
if ((fp->_flags & (__SALC | __SSTR)) ==
- (__SALC | __SSTR) && fp->_w < len) {
- int blen = fp->_p - fp->_bf._base;
+ (__SALC | __SSTR) && (size_t)fp->_w < len) {
+ ptrdiff_t blen = fp->_p - fp->_bf._base;
unsigned char *_base;
int _size;
_size = fp->_bf._size;
do {
_size = (_size << 1) + 1;
- } while (_size < blen + len);
+ } while ((size_t)_size < blen + len);
_base = realloc(fp->_bf._base,
(size_t)(_size + 1));
if (_base == NULL)
}
w = fp->_w;
if (fp->_flags & __SSTR) {
- if (len < w)
+ if (len < (size_t)w)
w = len;
COPY(w); /* copy MIN(fp->_w,len), */
- fp->_w -= w;
+ fp->_w -= (int)w;
fp->_p += w;
w = len; /* but pretend copied all */
- } else if (fp->_p > fp->_bf._base && len > w) {
+ } else if (fp->_p > fp->_bf._base && len > (size_t)w) {
/* fill and flush */
COPY(w);
/* fp->_w -= w; */ /* unneeded */
fp->_p += w;
if (fflush(fp))
goto err;
- } else if (len >= (w = fp->_bf._size)) {
+ } else if (len >= (size_t)(w = fp->_bf._size)) {
/* write directly */
- w = (*fp->_write)(fp->_cookie, p, w);
+ w = (*fp->_write)(fp->_cookie, p, (size_t)w);
if (w <= 0)
goto err;
} else {
/* fill and done */
w = len;
COPY(w);
- fp->_w -= w;
+ fp->_w -= (int)w;
fp->_p += w;
}
p += w;
do {
GETIOV(nlknown = 0);
if (!nlknown) {
- nl = memchr(p, '\n', (size_t)len);
- nldist = nl ? nl + 1 - p : len + 1;
+ nl = memchr(p, '\n', len);
+ nldist = nl ? (size_t)(nl + 1 - p) : len + 1;
nlknown = 1;
}
- s = MIN(len, nldist);
+ s = (int)MIN(len, nldist);
w = fp->_w + fp->_bf._size;
if (fp->_p > fp->_bf._base && s > w) {
COPY(w);
if (fflush(fp))
goto err;
} else if (s >= (w = fp->_bf._size)) {
- w = (*fp->_write)(fp->_cookie, p, w);
+ w = (*fp->_write)(fp->_cookie, p, (size_t)w);
if (w <= 0)
goto err;
} else {
w = s;
COPY(w);
- fp->_w -= w;
+ fp->_w -= (int)w;
fp->_p += w;
}
if ((nldist -= w) == 0) {
len -= w;
} while ((uio->uio_resid -= w) != 0);
}
- return (0);
+ return 0;
err:
fp->_flags |= __SERR;
- return (EOF);
+ return EOF;
}
-/* $NetBSD: fvwrite.h,v 1.7 2003/08/07 16:43:26 agc Exp $ */
+/* $NetBSD: fvwrite.h,v 1.8 2012/03/13 21:13:46 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
};
struct __suio {
struct __siov *uio_iov;
- int uio_iovcnt;
- int uio_resid;
+ size_t uio_iovcnt;
+ size_t uio_resid;
};
extern int __sfvwrite(FILE *, struct __suio *);
-/* $NetBSD: fwalk.c,v 1.11 2003/08/07 16:43:26 agc Exp $ */
+/* $NetBSD: fwalk.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fwalk.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fwalk.c,v 1.11 2003/08/07 16:43:26 agc Exp $");
+__RCSID("$NetBSD: fwalk.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "glue.h"
int
-_fwalk(function)
- int (*function) __P((FILE *));
+_fwalk(int (*function)(FILE *))
{
FILE *fp;
int n, ret;
for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
if (fp->_flags != 0)
ret |= (*function)(fp);
- return (ret);
+ return ret;
}
-/* $NetBSD: fwprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: fwprintf.c,v 1.2 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/fwprintf.c,v 1.1 2002/09/21 13:00:30 tjr Exp $");
#else
-__RCSID("$NetBSD: fwprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: fwprintf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
ret = vfwprintf(fp, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: fwrite.c,v 1.16 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: fwrite.c,v 1.17 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)fwrite.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fwrite.c,v 1.16 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: fwrite.c,v 1.17 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Return the number of whole objects written.
*/
size_t
-fwrite(buf, size, count, fp)
- const void *buf;
- size_t size, count;
- FILE *fp;
+fwrite(const void *buf, size_t size, size_t count, FILE *fp)
{
size_t n;
struct __suio uio;
* SUSv2 requires a return value of 0 for a count or a size of 0.
*/
if ((n = count * size) == 0)
- return (0);
+ return 0;
_DIAGASSERT(buf != NULL);
iov.iov_base = __UNCONST(buf);
if (__sfvwrite(fp, &uio) != 0)
count = ((n - uio.uio_resid) / size);
FUNLOCKFILE(fp);
- return (count);
+ return count;
}
-/* $NetBSD: fwscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: fwscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/fwscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
#else
-__RCSID("$NetBSD: fwscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: fwscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
r = vfwscanf(fp, fmt, ap);
va_end(ap);
- return (r);
+ return r;
}
-/* $NetBSD: getc.c,v 1.11 2003/08/07 16:43:26 agc Exp $ */
+/* $NetBSD: getc.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)getc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getc.c,v 1.11 2003/08/07 16:43:26 agc Exp $");
+__RCSID("$NetBSD: getc.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#undef getc_unlocked
int
-getc(fp)
- FILE *fp;
+getc(FILE *fp)
{
int r;
}
int
-getc_unlocked(fp)
- FILE *fp;
+getc_unlocked(FILE *fp)
{
_DIAGASSERT(fp != NULL);
- return (__sgetc(fp));
+ return __sgetc(fp);
}
-/* $NetBSD: getchar.c,v 1.9 2003/08/07 16:43:27 agc Exp $ */
+/* $NetBSD: getchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)getchar.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getchar.c,v 1.9 2003/08/07 16:43:27 agc Exp $");
+__RCSID("$NetBSD: getchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#undef getchar_unlocked
int
-getchar()
+getchar(void)
{
FILE *fp = stdin;
int r;
}
int
-getchar_unlocked()
+getchar_unlocked(void)
{
- return (__sgetc(stdin));
+ return __sgetc(stdin);
}
-.\" $NetBSD: getdelim.3,v 1.8 2010/06/30 13:38:10 jruoho Exp $
+.\" $NetBSD: getdelim.3,v 1.9 2011/04/20 23:37:51 enami Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
char *line = NULL;
size_t linesize = 0;
ssize_t linelen;
+
while ((linelen = getline(\*[Am]line, \*[Am]linesize, fp)) != -1)
fwrite(line, linelen, 1, stdout);
.Sh ERRORS
.Bl -tag -width [EOVERFLOW]
.It Bq Er EINVAL
-.Fa *lineptr
+.Fa lineptr
or
-.Fa *n
+.Fa n
is a
.Dv NULL
pointer.
-/* $NetBSD: getdelim.c,v 1.12 2009/12/07 21:31:43 roy Exp $ */
+/* $NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: getdelim.c,v 1.12 2009/12/07 21:31:43 roy Exp $");
+__RCSID("$NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $");
#include "namespace.h"
if (buf == NULL || buflen == NULL) {
errno = EINVAL;
- return -1;
+ goto error;
}
/* If buf is NULL, we have to assume a size of zero */
-/* $NetBSD: gets.c,v 1.16 2007/06/03 17:39:26 christos Exp $ */
+/* $NetBSD: gets.c,v 1.17 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: gets.c,v 1.16 2007/06/03 17:39:26 christos Exp $");
+__RCSID("$NetBSD: gets.c,v 1.17 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__warn_references(gets, "warning: this program uses gets(), which is unsafe.")
char *
-gets(buf)
- char *buf;
+gets(char *buf)
{
int c;
char *s;
if (c == EOF) {
if (s == buf) {
FUNLOCKFILE(stdin);
- return (NULL);
+ return NULL;
} else {
break;
}
}
*s = 0;
FUNLOCKFILE(stdin);
- return (buf);
+ return buf;
}
-/* $NetBSD: gettemp.c,v 1.14 2008/10/20 10:28:38 apb Exp $ */
+/* $NetBSD: gettemp.c,v 1.15 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: gettemp.c,v 1.14 2008/10/20 10:28:38 apb Exp $");
+__RCSID("$NetBSD: gettemp.c,v 1.15 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-GETTEMP(path, doopen, domkdir)
- char *path;
- int *doopen;
- int domkdir;
+GETTEMP(char *path, int *doopen, int domkdir)
{
char *start, *trv;
struct stat sbuf;
if (*trv == '/') {
*trv = '\0';
if (stat(path, &sbuf))
- return (0);
+ return 0;
if (!S_ISDIR(sbuf.st_mode)) {
errno = ENOTDIR;
- return (0);
+ return 0;
}
*trv = '/';
break;
if (doopen) {
if ((*doopen =
open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
- return (1);
+ return 1;
if (errno != EEXIST)
- return (0);
+ return 0;
} else if (domkdir) {
if (mkdir(path, 0700) >= 0)
- return (1);
+ return 1;
if (errno != EEXIST)
- return (0);
+ return 0;
} else if (lstat(path, &sbuf))
- return (errno == ENOENT ? 1 : 0);
+ return errno == ENOENT ? 1 : 0;
/* tricky little algorithm for backward compatibility */
for (trv = start;;) {
if (!*trv)
- return (0);
+ return 0;
if (*trv == 'z')
*trv++ = 'a';
else {
-/* $NetBSD: getw.c,v 1.9 2003/08/07 16:43:27 agc Exp $ */
+/* $NetBSD: getw.c,v 1.10 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)getw.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getw.c,v 1.9 2003/08/07 16:43:27 agc Exp $");
+__RCSID("$NetBSD: getw.c,v 1.10 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
int
-getw(fp)
- FILE *fp;
+getw(FILE *fp)
{
int x;
_DIAGASSERT(fp != NULL);
- return (fread((void *)&x, sizeof(x), 1, fp) == 1 ? x : EOF);
+ return fread((void *)&x, sizeof(x), 1, fp) == 1 ? x : EOF;
}
-/* $NetBSD: getwchar.c,v 1.3 2005/06/12 05:21:27 lukem Exp $ */
+/* $NetBSD: getwchar.c,v 1.4 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c)2001 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getwchar.c,v 1.3 2005/06/12 05:21:27 lukem Exp $");
+__RCSID("$NetBSD: getwchar.c,v 1.4 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#undef getwchar
wint_t
-getwchar()
+getwchar(void)
{
return fgetwc(stdin);
-/* $NetBSD: local.h,v 1.29 2010/10/24 17:44:32 tron Exp $ */
+/* $NetBSD: local.h,v 1.34 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#include "fileext.h"
#include <limits.h>
+#include <stdarg.h>
#include <stdbool.h>
/*
* in particular, macros and private variables.
*/
-extern int __sflush __P((FILE *));
-extern FILE *__sfp __P((void));
-extern void __sfpinit __P((FILE *));
-extern int __srefill __P((FILE *));
-extern int __sread __P((void *, char *, int));
-extern int __swrite __P((void *, char const *, int));
-extern fpos_t __sseek __P((void *, fpos_t, int));
-extern int __sclose __P((void *));
-extern void __sinit __P((void));
-extern void _cleanup __P((void));
-extern void (*__cleanup) __P((void));
-extern void __smakebuf __P((FILE *));
-extern int __swhatbuf __P((FILE *, size_t *, int *));
-extern int _fwalk __P((int (*)(FILE *)));
-extern char *_mktemp __P((char *));
-extern int __swsetup __P((FILE *));
-extern int __sflags __P((const char *, int *));
-extern int __svfscanf __P((FILE * __restrict, const char * __restrict,
- _BSD_VA_LIST_))
- __attribute__((__format__(__scanf__, 2, 0)));
-extern int __svfscanf_unlocked __P((FILE * __restrict, const char * __restrict,
- _BSD_VA_LIST_))
- __attribute__((__format__(__scanf__, 2, 0)));
-extern int __vfprintf_unlocked __P((FILE * __restrict, const char * __restrict,
- _BSD_VA_LIST_));
+extern int __sflush(FILE *);
+extern FILE *__sfp(void);
+extern void __sfpinit(FILE *);
+extern int __srefill(FILE *);
+extern ssize_t __sread(void *, void *, size_t);
+extern ssize_t __swrite(void *, const void *, size_t);
+extern off_t __sseek(void *, off_t, int);
+extern int __sclose(void *);
+extern void __sinit(void);
+extern void _cleanup(void);
+extern void (*__cleanup)(void);
+extern void __smakebuf(FILE *);
+extern int __swhatbuf(FILE *, size_t *, int *);
+extern int _fwalk(int (*)(FILE *));
+extern char *_mktemp(char *);
+extern int __swsetup(FILE *);
+extern int __sflags(const char *, int *);
+extern int __svfscanf(FILE * __restrict, const char * __restrict,
+ va_list) __scanflike(2, 0);
+extern int __svfscanf_unlocked(FILE * __restrict, const char * __restrict,
+ va_list) __scanflike(2, 0);
+extern int __vfprintf_unlocked(FILE * __restrict, const char * __restrict,
+ va_list) __printflike(2, 0);
extern int __sdidinit;
-extern int __gettemp __P((char *, int *, int));
+extern int __gettemp(char *, int *, int);
-extern wint_t __fgetwc_unlock __P((FILE *));
-extern wint_t __fputwc_unlock __P((wchar_t, FILE *));
+extern wint_t __fgetwc_unlock(FILE *);
+extern wint_t __fputwc_unlock(wchar_t, FILE *);
extern ssize_t __getdelim(char **__restrict, size_t *__restrict, int,
FILE *__restrict);
-extern char *__fgetstr __P((FILE * __restrict, size_t * __restrict, int));
-extern int __vfwprintf_unlocked __P((FILE *, const wchar_t *,
- _BSD_VA_LIST_));
-extern int __vfwscanf_unlocked __P((FILE * __restrict,
- const wchar_t * __restrict, _BSD_VA_LIST_));
+extern char *__fgetstr(FILE * __restrict, size_t * __restrict, int);
+extern int __vfwprintf_unlocked(FILE *, const wchar_t *, va_list);
+extern int __vfwscanf_unlocked(FILE * __restrict,
+ const wchar_t * __restrict, va_list);
/*
* Return true iff the given FILE cannot be written now.
_EXT(fp)->_fgetstr_len = 0; \
}
-extern void __flockfile_internal __P((FILE *, int));
-extern void __funlockfile_internal __P((FILE *, int));
+extern void __flockfile_internal(FILE *, int);
+extern void __funlockfile_internal(FILE *, int);
/*
* Detect if the current file position fits in a long int.
*/
static __inline bool
-__fpos_overflow(fpos_t pos)
+__long_overflow(off_t pos)
{
- return (pos < LONG_MIN) || (pos > LONG_MAX);
+ return (pos < LONG_MIN) || (pos > LONG_MAX);
}
-/* $NetBSD: makebuf.c,v 1.15 2008/03/13 15:40:00 christos Exp $ */
+/* $NetBSD: makebuf.c,v 1.17 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)makebuf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: makebuf.c,v 1.15 2008/03/13 15:40:00 christos Exp $");
+__RCSID("$NetBSD: makebuf.c,v 1.17 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* optimisation) right after the fstat() that finds the buffer size.
*/
void
-__smakebuf(fp)
- FILE *fp;
+__smakebuf(FILE *fp)
{
void *p;
int flags;
__cleanup = _cleanup;
flags |= __SMBF;
fp->_bf._base = fp->_p = p;
- fp->_bf._size = size;
+ _DIAGASSERT(__type_fit(int, size));
+ fp->_bf._size = (int)size;
if (couldbetty && isatty(__sfileno(fp)))
flags |= __SLBF;
fp->_flags |= flags;
* Internal routine to determine `proper' buffering for a file.
*/
int
-__swhatbuf(fp, bufsize, couldbetty)
- FILE *fp;
- size_t *bufsize;
- int *couldbetty;
+__swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty)
{
struct stat st;
if (__sfileno(fp) == -1 || fstat(__sfileno(fp), &st) < 0) {
*couldbetty = 0;
*bufsize = BUFSIZ;
- return (__SNPT);
+ return __SNPT;
}
/* could be a tty iff it is a character device */
*couldbetty = S_ISCHR(st.st_mode);
+ if (st.st_blksize == 0) {
+ *bufsize = BUFSIZ;
+ return __SNPT;
+ }
/*
* Optimise fseek() only if it is a regular file. (The test for
} else
#endif
*bufsize = fp->_blksize = st.st_blksize;
-
- return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ?
- __SOPT : __SNPT);
+ return (st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ?
+ __SOPT : __SNPT;
}
-/* $NetBSD: mkdtemp.c,v 1.10 2008/10/20 10:28:38 apb Exp $ */
+/* $NetBSD: mkdtemp.c,v 1.11 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: mkdtemp.c,v 1.10 2008/10/20 10:28:38 apb Exp $");
+__RCSID("$NetBSD: mkdtemp.c,v 1.11 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
char *
-mkdtemp(path)
- char *path;
+mkdtemp(char *path)
{
_DIAGASSERT(path != NULL);
- return (GETTEMP(path, (int *)NULL, 1) ? path : (char *)NULL);
+ return GETTEMP(path, NULL, 1) ? path : NULL;
}
#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP */
-/* $NetBSD: mkstemp.c,v 1.10 2008/10/20 10:28:38 apb Exp $ */
+/* $NetBSD: mkstemp.c,v 1.11 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: mkstemp.c,v 1.10 2008/10/20 10:28:38 apb Exp $");
+__RCSID("$NetBSD: mkstemp.c,v 1.11 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-mkstemp(path)
- char *path;
+mkstemp(char *path)
{
int fd;
_DIAGASSERT(path != NULL);
- return (GETTEMP(path, &fd, 0) ? fd : -1);
+ return GETTEMP(path, &fd, 0) ? fd : -1;
}
#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP */
-/* $NetBSD: mktemp.c,v 1.19 2003/08/07 16:43:28 agc Exp $ */
+/* $NetBSD: mktemp.c,v 1.20 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: mktemp.c,v 1.19 2003/08/07 16:43:28 agc Exp $");
+__RCSID("$NetBSD: mktemp.c,v 1.20 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
char *
-_mktemp(path)
- char *path;
+_mktemp(char *path)
{
_DIAGASSERT(path != NULL);
- return (__gettemp(path, (int *)NULL, 0) ? path : (char *)NULL);
+ return __gettemp(path, NULL, 0) ? path : NULL;
}
__warn_references(mktemp,
"warning: mktemp() possibly used unsafely, use mkstemp() or mkdtemp()")
char *
-mktemp(path)
- char *path;
+mktemp(char *path)
{
_DIAGASSERT(path != NULL);
- return (__gettemp(path, (int *)NULL, 0) ? path : (char *)NULL);
+ return __gettemp(path, NULL, 0) ? path : NULL;
}
-/* $NetBSD: printf.c,v 1.11 2003/08/07 16:43:29 agc Exp $ */
+/* $NetBSD: printf.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)printf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: printf.c,v 1.11 2003/08/07 16:43:29 agc Exp $");
+__RCSID("$NetBSD: printf.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
va_start(ap, fmt);
ret = vfprintf(stdout, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: putc.c,v 1.11 2003/08/07 16:43:29 agc Exp $ */
+/* $NetBSD: putc.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)putc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: putc.c,v 1.11 2003/08/07 16:43:29 agc Exp $");
+__RCSID("$NetBSD: putc.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#undef putc_unlocked
int
-putc(c, fp)
- int c;
- FILE *fp;
+putc(int c, FILE *fp)
{
int r;
}
int
-putc_unlocked(c, fp)
- int c;
- FILE *fp;
+putc_unlocked(int c, FILE *fp)
{
_DIAGASSERT(fp != NULL);
- return (__sputc(c, fp));
+ return __sputc(c, fp);
}
-/* $NetBSD: putchar.c,v 1.9 2003/08/07 16:43:29 agc Exp $ */
+/* $NetBSD: putchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)putchar.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: putchar.c,v 1.9 2003/08/07 16:43:29 agc Exp $");
+__RCSID("$NetBSD: putchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* A subroutine version of the macro putchar
*/
int
-putchar(c)
- int c;
+putchar(int c)
{
FILE *fp = stdout;
int r;
}
int
-putchar_unlocked(c)
- int c;
+putchar_unlocked(int c)
{
- return (__sputc(c, stdout));
+ return __sputc(c, stdout);
}
-/* $NetBSD: puts.c,v 1.15 2006/03/17 02:25:23 chris Exp $ */
+/* $NetBSD: puts.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)puts.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: puts.c,v 1.15 2006/03/17 02:25:23 chris Exp $");
+__RCSID("$NetBSD: puts.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Write the given string to stdout, appending a newline.
*/
int
-puts(s)
- char const *s;
+puts(char const *s)
{
size_t c;
struct __suio uio;
FLOCKFILE(stdout);
r = __sfvwrite(stdout, &uio);
FUNLOCKFILE(stdout);
- return (r ? EOF : '\n');
+ return r ? EOF : '\n';
}
-/* $NetBSD: putw.c,v 1.11 2003/08/07 16:43:29 agc Exp $ */
+/* $NetBSD: putw.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)putw.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: putw.c,v 1.11 2003/08/07 16:43:29 agc Exp $");
+__RCSID("$NetBSD: putw.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
int
-putw(w, fp)
- int w;
- FILE *fp;
+putw(int w, FILE *fp)
{
struct __suio uio;
struct __siov iov;
-/* $NetBSD: refill.c,v 1.14 2010/09/10 10:29:23 drochner Exp $ */
+/* $NetBSD: refill.c,v 1.16 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)refill.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: refill.c,v 1.14 2010/09/10 10:29:23 drochner Exp $");
+__RCSID("$NetBSD: refill.c,v 1.16 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
extern rwlock_t __sfp_lock;
#endif
-static int lflush __P((FILE *));
-
static int
-lflush(fp)
- FILE *fp;
+lflush(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
- return (__sflush(fp));
- return (0);
+ return __sflush(fp);
+ return 0;
}
/*
* Return EOF on eof or error, 0 otherwise.
*/
int
-__srefill(fp)
- FILE *fp;
+__srefill(FILE *fp)
{
_DIAGASSERT(fp != NULL);
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF)
- return (EOF);
+ return EOF;
/* if not already reading, have to be reading and writing */
if ((fp->_flags & __SRD) == 0) {
if ((fp->_flags & __SRW) == 0) {
errno = EBADF;
fp->_flags |= __SERR;
- return (EOF);
+ return EOF;
}
/* switch to reading */
if (fp->_flags & __SWR) {
if (__sflush(fp))
- return (EOF);
+ return EOF;
fp->_flags &= ~__SWR;
fp->_w = 0;
fp->_lbfsize = 0;
FREEUB(fp);
if ((fp->_r = fp->_ur) != 0) {
fp->_p = fp->_up;
- return (0);
+ return 0;
}
}
}
rwlock_unlock(&__sfp_lock);
}
fp->_p = fp->_bf._base;
- fp->_r = (*fp->_read)(fp->_cookie, (char *)fp->_p, fp->_bf._size);
+ fp->_r = (int)(*fp->_read)(fp->_cookie, (char *)fp->_p,
+ (size_t)fp->_bf._size);
fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
if (fp->_r <= 0) {
if (fp->_r == 0)
fp->_r = 0;
fp->_flags |= __SERR;
}
- return (EOF);
+ return EOF;
}
- return (0);
+ return 0;
}
-/* $NetBSD: remove.c,v 1.13 2003/08/07 16:43:30 agc Exp $ */
+/* $NetBSD: remove.c,v 1.14 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)remove.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: remove.c,v 1.13 2003/08/07 16:43:30 agc Exp $");
+__RCSID("$NetBSD: remove.c,v 1.14 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <unistd.h>
int
-remove(file)
- const char *file;
+remove(const char *file)
{
struct stat sb;
_DIAGASSERT(file != NULL);
if (lstat(file, &sb) < 0)
- return (-1);
+ return -1;
/*
* The file system may prohibit using unlink(2) on directories,
* so always use rmdir(2) in that case.
*/
if (S_ISDIR(sb.st_mode))
- return (rmdir(file));
+ return rmdir(file);
else
- return (unlink(file));
+ return unlink(file);
}
-/* $NetBSD: rewind.c,v 1.13 2003/08/07 16:43:30 agc Exp $ */
+/* $NetBSD: rewind.c,v 1.14 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)rewind.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: rewind.c,v 1.13 2003/08/07 16:43:30 agc Exp $");
+__RCSID("$NetBSD: rewind.c,v 1.14 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
void
-rewind(fp)
- FILE *fp;
+rewind(FILE *fp)
{
_DIAGASSERT(fp != NULL);
-/* $NetBSD: rget.c,v 1.12 2003/08/07 16:43:30 agc Exp $ */
+/* $NetBSD: rget.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)rget.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: rget.c,v 1.12 2003/08/07 16:43:30 agc Exp $");
+__RCSID("$NetBSD: rget.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* in the newly-filled buffer.
*/
int
-__srget(fp)
- FILE *fp;
+__srget(FILE *fp)
{
_DIAGASSERT(fp != NULL);
_SET_ORIENTATION(fp, -1);
if (__srefill(fp) == 0) {
fp->_r--;
- return (*fp->_p++);
+ return *fp->_p++;
}
- return (EOF);
+ return EOF;
}
-/* $NetBSD: scanf.c,v 1.12 2003/08/07 16:43:31 agc Exp $ */
+/* $NetBSD: scanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)scanf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: scanf.c,v 1.12 2003/08/07 16:43:31 agc Exp $");
+__RCSID("$NetBSD: scanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
va_start(ap, fmt);
ret = __svfscanf(stdin, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: setbuf.c,v 1.9 2003/08/07 16:43:31 agc Exp $ */
+/* $NetBSD: setbuf.c,v 1.10 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)setbuf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: setbuf.c,v 1.9 2003/08/07 16:43:31 agc Exp $");
+__RCSID("$NetBSD: setbuf.c,v 1.10 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
void
-setbuf(fp, buf)
- FILE *fp;
- char *buf;
+setbuf(FILE *fp, char *buf)
{
_DIAGASSERT(fp != NULL);
/* buf may be NULL */
- (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
+ (void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
}
-/* $NetBSD: setbuffer.c,v 1.12 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: setbuffer.c,v 1.13 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)setbuffer.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: setbuffer.c,v 1.12 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: setbuffer.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
void
-setbuffer(fp, buf, size)
- FILE *fp;
- char *buf;
- int size;
+setbuffer(FILE *fp, char *buf, int size)
{
_DIAGASSERT(fp != NULL);
* set line buffering
*/
int
-setlinebuf(fp)
- FILE *fp;
+setlinebuf(FILE *fp)
{
_DIAGASSERT(fp != NULL);
- return (setvbuf(fp, NULL, _IOLBF, (size_t)0));
+ return setvbuf(fp, NULL, _IOLBF, (size_t)0);
}
-/* $NetBSD: setvbuf.c,v 1.17 2003/08/07 16:43:31 agc Exp $ */
+/* $NetBSD: setvbuf.c,v 1.19 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)setvbuf.c 8.2 (Berkeley) 11/16/93";
#else
-__RCSID("$NetBSD: setvbuf.c,v 1.17 2003/08/07 16:43:31 agc Exp $");
+__RCSID("$NetBSD: setvbuf.c,v 1.19 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* a buffer.
*/
int
-setvbuf(fp, buf, mode, size)
- FILE *fp;
- char *buf;
- int mode;
- size_t size;
+setvbuf(FILE *fp, char *buf, int mode, size_t size)
{
int ret, flags;
size_t iosize;
*/
if (mode != _IONBF)
if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0)
- return (-1);
+ return -1;
FLOCKFILE(fp);
/*
fp->_bf._base = fp->_p = fp->_nbuf;
fp->_bf._size = 1;
FUNLOCKFILE(fp);
- return (ret);
+ return ret;
}
flags |= __SMBF;
}
flags |= __SLBF;
fp->_flags = flags;
fp->_bf._base = fp->_p = (unsigned char *)buf;
- fp->_bf._size = size;
+ _DIAGASSERT(__type_fit(int, size));
+ fp->_bf._size = (int)size;
/* fp->_lbfsize is still 0 */
if (flags & __SWR) {
/*
if (flags & __SLBF) {
fp->_w = 0;
fp->_lbfsize = -fp->_bf._size;
- } else
- fp->_w = size;
+ } else {
+ _DIAGASSERT(__type_fit(int, size));
+ fp->_w = (int)size;
+ }
} else {
/* begin/continue reading, or stay in intermediate state */
fp->_w = 0;
__cleanup = _cleanup;
FUNLOCKFILE(fp);
- return (ret);
+ return ret;
}
-/* $NetBSD: snprintf.c,v 1.22 2007/10/26 19:48:14 christos Exp $ */
+/* $NetBSD: snprintf.c,v 1.24 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: snprintf.c,v 1.22 2007/10/26 19:48:14 christos Exp $");
+__RCSID("$NetBSD: snprintf.c,v 1.24 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if ((int)n < 0) {
errno = EINVAL;
- return (-1);
+ return -1;
}
va_start(ap, fmt);
_FILEEXT_SETUP(&f, &fext);
f._bf._size = f._w = 0;
} else {
f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = n - 1;
+ _DIAGASSERT(__type_fit(int, n - 1));
+ f._bf._size = f._w = (int)(n - 1);
}
ret = __vfprintf_unlocked(&f, fmt, ap);
*f._p = 0;
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: sprintf.c,v 1.15 2007/06/03 17:39:26 christos Exp $ */
+/* $NetBSD: sprintf.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)sprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sprintf.c,v 1.15 2007/06/03 17:39:26 christos Exp $");
+__RCSID("$NetBSD: sprintf.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
ret = __vfprintf_unlocked(&f, fmt, ap);
va_end(ap);
*f._p = 0;
- return (ret);
+ return ret;
}
-/* $NetBSD: sscanf.c,v 1.17 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: sscanf.c,v 1.20 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)sscanf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sscanf.c,v 1.17 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: sscanf.c,v 1.20 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include "local.h"
-static int eofread __P((void *, char *, int));
-
/* ARGSUSED */
-static int
-eofread(cookie, buf, len)
- void *cookie;
- char *buf;
- int len;
+static ssize_t
+eofread(void *cookie, void *buf, size_t len)
{
- return (0);
+ return 0;
}
int
int ret;
va_list ap;
FILE f;
+ size_t len;
struct __sfileext fext;
_DIAGASSERT(str != NULL);
_FILEEXT_SETUP(&f, &fext);
f._flags = __SRD;
f._bf._base = f._p = __UNCONST(str);
- f._bf._size = f._r = strlen(str);
+ len = strlen(str);
+ _DIAGASSERT(__type_fit(int, len));
+ f._bf._size = f._r = (int)len;
f._read = eofread;
_UB(&f)._base = NULL;
va_start(ap, fmt);
ret = __svfscanf_unlocked(&f, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: stdio.c,v 1.16 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: stdio.c,v 1.21 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)stdio.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: stdio.c,v 1.16 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: stdio.c,v 1.21 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Small standard I/O/seek/close functions.
* These maintain the `known seek offset' for seek optimisation.
*/
-int
-__sread(cookie, buf, n)
- void *cookie;
- char *buf;
- int n;
+ssize_t
+__sread(void *cookie, void *buf, size_t n)
{
FILE *fp = cookie;
- int ret;
+ ssize_t ret;
- _DIAGASSERT(fp != NULL);
+ _DIAGASSERT(cookie != NULL);
+ _DIAGASSERT(cookie == fp->_cookie);
_DIAGASSERT(buf != NULL);
- ret = read(__sfileno(fp), buf, (size_t)n);
+ ret = read(__sfileno(fp), buf, n);
/* if the read succeeded, update the current offset */
if (ret >= 0)
fp->_offset += ret;
else
fp->_flags &= ~__SOFF; /* paranoia */
- return (ret);
+
+ return ret;
}
-int
-__swrite(cookie, buf, n)
- void *cookie;
- char const *buf;
- int n;
+ssize_t
+__swrite(void *cookie, const void *buf, size_t n)
{
FILE *fp = cookie;
_DIAGASSERT(cookie != NULL);
+ _DIAGASSERT(cookie == fp->_cookie);
_DIAGASSERT(buf != NULL);
if (fp->_flags & __SAPP)
- (void) lseek(__sfileno(fp), (off_t)0, SEEK_END);
+ if (lseek(__sfileno(fp), (off_t)0, SEEK_END) == (off_t)-1)
+ return -1;
fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */
- return write(__sfileno(fp), buf, (size_t)n);
+ return write(__sfileno(fp), buf, n);
}
-fpos_t
-__sseek(cookie, offset, whence)
- void *cookie;
- fpos_t offset;
- int whence;
+off_t
+__sseek(void *cookie, off_t offset, int whence)
{
FILE *fp = cookie;
off_t ret;
- _DIAGASSERT(fp != NULL);
+ _DIAGASSERT(cookie != NULL);
+ _DIAGASSERT(cookie == fp->_cookie);
- ret = lseek(__sfileno(fp), (off_t)offset, whence);
- if (ret == -1L)
+ ret = lseek(__sfileno(fp), offset, whence);
+ if (ret == (off_t)-1L)
fp->_flags &= ~__SOFF;
else {
fp->_flags |= __SOFF;
fp->_offset = ret;
}
- return (ret);
+ return ret;
}
int
-__sclose(cookie)
- void *cookie;
+__sclose(void *cookie)
{
+ FILE *fp = cookie;
_DIAGASSERT(cookie != NULL);
+ _DIAGASSERT(cookie == fp->_cookie);
- return close(__sfileno((FILE *)cookie));
+ return close(__sfileno(fp));
}
-/* $NetBSD: swprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: swprintf.c,v 1.2 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/swprintf.c,v 1.1 2002/09/21 13:00:30 tjr Exp $");
#else
-__RCSID("$NetBSD: swprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: swprintf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
ret = vswprintf(s, n, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: swscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: swscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/swscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
#else
-__RCSID("$NetBSD: swscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: swscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
r = vswscanf(str, fmt, ap);
va_end(ap);
- return (r);
+ return r;
}
-/* $NetBSD: tempnam.c,v 1.21 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: tempnam.c,v 1.22 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)tempnam.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tempnam.c,v 1.21 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: tempnam.c,v 1.22 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
sverrno = errno;
free(name);
errno = sverrno;
- return(NULL);
+ return NULL;
}
-/* $NetBSD: tmpfile.c,v 1.11 2003/08/07 16:43:33 agc Exp $ */
+/* $NetBSD: tmpfile.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)tmpfile.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tmpfile.c,v 1.11 2003/08/07 16:43:33 agc Exp $");
+__RCSID("$NetBSD: tmpfile.c,v 1.12 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <paths.h>
FILE *
-tmpfile()
+tmpfile(void)
{
sigset_t set, oset;
FILE *fp;
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
if (fd == -1)
- return (NULL);
+ return NULL;
if ((fp = fdopen(fd, "w+")) == NULL) {
sverrno = errno;
(void)close(fd);
errno = sverrno;
- return (NULL);
+ return NULL;
}
- return (fp);
+ return fp;
}
-/* $NetBSD: tmpnam.c,v 1.14 2003/08/07 16:43:33 agc Exp $ */
+/* $NetBSD: tmpnam.c,v 1.15 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
#if 0
static char sccsid[] = "@(#)tmpnam.c 8.3 (Berkeley) 3/28/94";
#else
-__RCSID("$NetBSD: tmpnam.c,v 1.14 2003/08/07 16:43:33 agc Exp $");
+__RCSID("$NetBSD: tmpnam.c,v 1.15 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
"warning: tmpnam() possibly used unsafely, use mkstemp() or mkdtemp()")
char *
-tmpnam(s)
- char *s;
+tmpnam(char *s)
{
static u_long tmpcount;
static char buf[L_tmpnam];
s = buf;
(void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXXXXXX", P_tmpdir, tmpcount);
++tmpcount;
- return (_mktemp(s));
+ return _mktemp(s);
}
-/* $NetBSD: ungetc.c,v 1.16 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: ungetc.c,v 1.17 2012/03/15 18:22:30 christos Exp $ */
/*-
- * Copyright (c) 1990, 1993
+ * Copyright c 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
#if 0
static char sccsid[] = "@(#)ungetc.c 8.2 (Berkeley) 11/3/93";
#else
-__RCSID("$NetBSD: ungetc.c,v 1.16 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: ungetc.c,v 1.17 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include "local.h"
-static int __submore __P((FILE *));
/*
* Expand the ungetc buffer `in place'. That is, adjust fp->_p when
* the buffer moves, so that it points the same distance from the end,
* are all at the end (stack-style).
*/
static int
-__submore(fp)
- FILE *fp;
+__submore(FILE *fp)
{
int i;
unsigned char *p;
* Get a new buffer (rather than expanding the old one).
*/
if ((p = malloc((size_t)BUFSIZ)) == NULL)
- return (EOF);
+ return EOF;
_UB(fp)._base = p;
_UB(fp)._size = BUFSIZ;
p += BUFSIZ - sizeof(fp->_ubuf);
for (i = sizeof(fp->_ubuf); --i >= 0;)
p[i] = fp->_ubuf[i];
fp->_p = p;
- return (0);
+ return 0;
}
i = _UB(fp)._size;
p = realloc(_UB(fp)._base, (size_t)(i << 1));
if (p == NULL)
- return (EOF);
+ return EOF;
/* no overlap (hence can use memcpy) because we doubled the size */
(void)memcpy((p + i), p, (size_t)i);
fp->_p = p + i;
_UB(fp)._base = p;
_UB(fp)._size = i << 1;
- return (0);
+ return 0;
}
int
-ungetc(c, fp)
- int c;
- FILE *fp;
+ungetc(int c, FILE *fp)
{
_DIAGASSERT(fp != NULL);
if (c == EOF)
- return (EOF);
+ return EOF;
if (!__sdidinit)
__sinit();
FLOCKFILE(fp);
*/
if ((fp->_flags & __SRW) == 0) {
FUNLOCKFILE(fp);
- return (EOF);
+ return EOF;
}
if (fp->_flags & __SWR) {
if (__sflush(fp)) {
FUNLOCKFILE(fp);
- return (EOF);
+ return EOF;
}
fp->_flags &= ~__SWR;
fp->_w = 0;
if (HASUB(fp)) {
if (fp->_r >= _UB(fp)._size && __submore(fp)) {
FUNLOCKFILE(fp);
- return (EOF);
+ return EOF;
}
*--fp->_p = c;
fp->_r++;
FUNLOCKFILE(fp);
- return (c);
+ return c;
}
fp->_flags &= ~__SEOF;
fp->_p--;
fp->_r++;
FUNLOCKFILE(fp);
- return (c);
+ return c;
}
/*
fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];
fp->_r = 1;
FUNLOCKFILE(fp);
- return (c);
+ return c;
}
-/* $NetBSD: vasprintf.c,v 1.12 2009/10/25 20:44:13 christos Exp $ */
+/* $NetBSD: vasprintf.c,v 1.14 2012/03/15 18:22:30 christos Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vasprintf.c,v 1.12 2009/10/25 20:44:13 christos Exp $");
+__RCSID("$NetBSD: vasprintf.c,v 1.14 2012/03/15 18:22:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include "local.h"
int
-vasprintf(str, fmt, ap)
- char **str;
- const char *fmt;
- _BSD_VA_LIST_ ap;
+vasprintf(char **str, const char *fmt, va_list ap)
{
int ret;
FILE f;
if (_base == NULL)
goto err;
*str = (char *)_base;
- return (ret);
+ return ret;
err:
if (f._bf._base)
free(f._bf._base);
*str = NULL;
errno = ENOMEM;
- return (-1);
+ return -1;
}
-/* $NetBSD: vdprintf.c,v 1.1 2010/09/06 14:52:55 christos Exp $ */
+/* $NetBSD: vdprintf.c,v 1.2 2011/07/17 20:54:34 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vdprintf.c,v 1.1 2010/09/06 14:52:55 christos Exp $");
+__RCSID("$NetBSD: vdprintf.c,v 1.2 2011/07/17 20:54:34 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#endif
int
-vdprintf(int fd, const char * __restrict fmt, _BSD_VA_LIST_ ap)
+vdprintf(int fd, const char * __restrict fmt, va_list ap)
{
FILE f;
struct __sfileext fext;
-/* $NetBSD: vfscanf.c,v 1.41 2010/12/16 17:42:27 wiz Exp $ */
+/* $NetBSD: vfscanf.c,v 1.43 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.41 2007/01/09 00:28:07 imp Exp $");
#else
-__RCSID("$NetBSD: vfscanf.c,v 1.41 2010/12/16 17:42:27 wiz Exp $");
+__RCSID("$NetBSD: vfscanf.c,v 1.43 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
static const u_char *__sccl(char *, const u_char *);
#ifndef NO_FLOATING_POINT
-static int parsefloat(FILE *, char *, char *);
+static size_t parsefloat(FILE *, char *, char *);
#endif
int __scanfdebug = 0;
FLOCKFILE(fp);
ret = __svfscanf_unlocked(fp, fmt0, ap);
FUNLOCKFILE(fp);
- return (ret);
+ return ret;
}
#define SCANF_SKIP_SPACE() \
char *p0; /* saves original value of p when necessary */
int nassigned; /* number of fields assigned */
int nconversions; /* number of conversions */
- int nread; /* number of characters consumed from fp */
+ size_t nread; /* number of characters consumed from fp */
int base; /* base argument to conversion function */
char ccltab[256]; /* character class table for %[...] */
char buf[BUF]; /* buffer for numeric and mb conversions */
for (;;) {
c = (unsigned char)*fmt++;
if (c == 0)
- return (nassigned);
+ return nassigned;
if (isspace(c)) {
while ((fp->_r > 0 || __srefill(fp) == 0) &&
isspace(*fp->_p))
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORTSHORT)
- *va_arg(ap, char *) = nread;
+ *va_arg(ap, char *) = (char)nread;
else if (flags & SHORT)
- *va_arg(ap, short *) = nread;
+ *va_arg(ap, short *) = (short)nread;
else if (flags & LONG)
*va_arg(ap, long *) = nread;
else if (flags & LONGLONG)
else if (flags & PTRDIFFT)
*va_arg(ap, ptrdiff_t *) = nread;
else
- *va_arg(ap, int *) = nread;
+ *va_arg(ap, int *) = (int)nread;
continue;
default:
* Disgusting backwards compatibility hack. XXX
*/
case '\0': /* compat */
- return (EOF);
+ return EOF;
}
/*
}
} else {
sum += width;
- fp->_r -= width;
+ _DIAGASSERT(__type_fit(int,
+ fp->_r - width));
+ fp->_r -= (int)width;
fp->_p += width;
break;
}
}
}
input_failure:
- return (nconversions != 0 ? nassigned : EOF);
+ return nconversions != 0 ? nassigned : EOF;
match_failure:
- return (nassigned);
+ return nassigned;
}
/*
* considered part of the scanset.
*/
static const u_char *
-__sccl(tab, fmt)
- char *tab;
- const u_char *fmt;
+__sccl(char *tab, const u_char *fmt)
{
int c, n, v, i;
(void)memset(tab, v, 256);
if (c == 0)
- return (fmt - 1);/* format ended before closing ] */
+ return fmt - 1;/* format ended before closing ] */
/*
* Now set the entries corresponding to the actual scanset
switch (n) {
case 0: /* format ended too soon */
- return (fmt - 1);
+ return fmt - 1;
case '-':
/*
#else
c = *fmt++;
if (c == 0)
- return (fmt - 1);
+ return fmt - 1;
if (c == ']')
- return (fmt);
+ return fmt;
#endif
case ']': /* end of scanset */
- return (fmt);
+ return fmt;
default: /* just another character */
c = n;
}
#ifndef NO_FLOATING_POINT
-static int
+static size_t
parsefloat(FILE *fp, char *buf, char *end)
{
char *commit, *p;
while (commit < --p)
(void)ungetc(*(u_char *)p, fp);
*++commit = '\0';
- return (commit - buf);
+ return commit - buf;
}
#endif
-/* $NetBSD: vfwprintf.c,v 1.23 2010/12/16 17:42:27 wiz Exp $ */
+/* $NetBSD: vfwprintf.c,v 1.30 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $");
#else
-__RCSID("$NetBSD: vfwprintf.c,v 1.23 2010/12/16 17:42:27 wiz Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.30 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Type ids for argument type table.
*/
enum typeid {
- T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT,
+ T_UNUSED = 0, TP_SHORT, T_INT, T_U_INT, TP_INT,
T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
T_PTRDIFFT, TP_PTRDIFFT, T_SSIZET, T_SIZET, TP_SIZET,
T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
static int __sprint(FILE *, struct __suio *);
#endif
static int __find_arguments(const CHAR_T *, va_list, union arg **);
-static int __grow_type_table(int, enum typeid **, int *);
+static int __grow_type_table(size_t, enum typeid **, size_t *);
/*
* Helper function for `fprintf to unbuffered unix file': creates a
fake._file = fp->_file;
fake._cookie = fp->_cookie;
fake._write = fp->_write;
+ fake._flush = fp->_flush;
/* set up the buffer */
fake._bf._base = fake._p = buf;
ret = END_OF_FILE;
if (fake._flags & __SERR)
fp->_flags |= __SERR;
- return (ret);
+ return ret;
}
#ifndef NARROW
size_t len;
if ((fp->_flags & __SSTR) == 0)
- return (__fputwc_unlock(wc, fp));
+ return __fputwc_unlock(wc, fp);
mbs = initial;
if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) {
fp->_flags |= __SERR;
- return (END_OF_FILE);
+ return END_OF_FILE;
}
uio.uio_iov = &iov;
uio.uio_resid = len;
uio.uio_iovcnt = 1;
iov.iov_base = buf;
iov.iov_len = len;
- return (__sfvwrite(fp, &uio) != EOF ? (wint_t)wc : END_OF_FILE);
+ return __sfvwrite(fp, &uio) != EOF ? (wint_t)wc : END_OF_FILE;
}
#else
/*
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
- return (0);
+ return 0;
}
err = __sfvwrite(fp, uio);
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
- return (err);
+ return err;
}
#endif
*/
static CHAR_T *
__ultoa(u_long val, CHAR_T *endp, int base, int octzero, const char *xdigs,
- int needgrp, char thousep, const char *grp)
+ int needgrp, char thousep, const char *grp)
{
CHAR_T *cp = endp;
long sval;
case 10:
if (val < 10) { /* many numbers are 1 digit */
*--cp = to_char(val);
- return (cp);
+ return cp;
}
ndig = 0;
/*
* If (*grp == CHAR_MAX) then no more grouping
* should be performed.
*/
- if (needgrp && ndig == *grp && *grp != CHAR_MAX
- && sval > 9) {
+ if (needgrp && ndig == *grp
+ && (unsigned char)*grp != (unsigned char)CHAR_MAX
+ && sval > 9) {
*--cp = thousep;
ndig = 0;
/*
default: /* oops */
abort();
}
- return (cp);
+ return cp;
}
/* Identical to __ultoa, but for intmax_t. */
static CHAR_T *
__ujtoa(uintmax_t val, CHAR_T *endp, int base, int octzero,
- const char *xdigs, int needgrp, char thousep, const char *grp)
+ const char *xdigs, int needgrp, char thousep, const char *grp)
{
CHAR_T *cp = endp;
intmax_t sval;
/* quick test for small values; __ultoa is typically much faster */
/* (perhaps instead we should run until small, then call __ultoa?) */
if (val <= ULONG_MAX)
- return (__ultoa((u_long)val, endp, base, octzero, xdigs,
- needgrp, thousep, grp));
+ return __ultoa((u_long)val, endp, base, octzero, xdigs,
+ needgrp, thousep, grp);
switch (base) {
case 10:
if (val < 10) {
*--cp = to_char(val % 10);
- return (cp);
+ return cp;
}
ndig = 0;
if (val > INTMAX_MAX) {
* If (*grp == CHAR_MAX) then no more grouping
* should be performed.
*/
- if (needgrp && *grp != CHAR_MAX && ndig == *grp
- && sval > 9) {
+ if (needgrp
+ && (unsigned char)*grp != (unsigned char)CHAR_MAX
+ && ndig == *grp
+ && sval > 9) {
*--cp = thousep;
ndig = 0;
/*
default:
abort();
}
- return (cp);
+ return cp;
}
#ifndef NARROW
size_t insize, nchars, nconv;
if (mbsarg == NULL)
- return (NULL);
+ return NULL;
/*
* Supplied argument is a multibyte string; convert it to wide
insize += nconv;
}
if (nconv == (size_t)-1 || nconv == (size_t)-2)
- return (NULL);
+ return NULL;
} else
insize = strlen(mbsarg);
*/
convbuf = malloc((insize + 1) * sizeof(*convbuf));
if (convbuf == NULL)
- return (NULL);
+ return NULL;
wcp = convbuf;
p = mbsarg;
mbs = initial;
}
if (nconv == (size_t)-1 || nconv == (size_t)-2) {
free(convbuf);
- return (NULL);
+ return NULL;
}
*wcp = L'\0';
- return (convbuf);
+ return convbuf;
}
#else
/*
if (prec < 0) {
p = wcsarg;
mbs = initial;
- nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, &mbs);
+ nbytes = wcsrtombs(NULL, (void *)&p, 0, &mbs);
if (nbytes == (size_t)-1)
- return (NULL);
+ return NULL;
} else {
/*
* Optimisation: if the output precision is small enough,
}
}
if ((convbuf = malloc(nbytes + 1)) == NULL)
- return (NULL);
+ return NULL;
/* Fill the output buffer. */
p = wcsarg;
mbs = initial;
- if ((nbytes = wcsrtombs(convbuf, (const wchar_t **)&p,
+ if ((nbytes = wcsrtombs(convbuf, (void *)&p,
nbytes, &mbs)) == (size_t)-1) {
free(convbuf);
- return (NULL);
+ return NULL;
}
convbuf[nbytes] = '\0';
- return (convbuf);
+ return convbuf;
}
#endif
FLOCKFILE(fp);
ret = WDECL(__vf,printf_unlocked)(fp, fmt0, ap);
FUNLOCKFILE(fp);
- return (ret);
+ return ret;
}
#ifndef NO_FLOATING_POINT
} \
} while (/*CONSTCOND*/0)
#define PRINTANDPAD(p, ep, len, with) do { \
- n2 = (ep) - (p); \
+ ptrdiff_t td = (ep) - (p); \
+ _DIAGASSERT(__type_fit(int, td)); \
+ n2 = (int)td; \
if (n2 > (len)) \
n2 = (len); \
if (n2 > 0) \
/* sorry, f{w,}printf(read_only_file, L"") returns {W,}EOF, not 0 */
if (cantwrite(fp)) {
errno = EBADF;
- return (END_OF_FILE);
+ return END_OF_FILE;
}
/* optimise fprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
__sfileno(fp) != -1)
- return (__sbprintf(fp, fmt0, ap));
+ return __sbprintf(fp, fmt0, ap);
fmt = (CHAR_T *)__UNCONST(fmt0);
argtable = NULL;
for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
continue;
- if ((n = fmt - cp) != 0) {
+ _DIAGASSERT(__type_fit(int, fmt - cp));
+ if ((n = (int)(fmt - cp)) != 0) {
if ((unsigned)ret + n > INT_MAX) {
ret = END_OF_FILE;
goto error;
if (dtoaresult == NULL)
goto oomem;
- if (prec < 0)
- prec = dtoaend - dtoaresult;
+ if (prec < 0) {
+ _DIAGASSERT(__type_fit(int,
+ dtoaend - dtoaresult));
+ prec = (int)(dtoaend - dtoaresult);
+ }
if (expt == INT_MAX)
ox[1] = '\0';
- ndig = dtoaend - dtoaresult;
+ _DIAGASSERT(__type_fit(int, dtoaend - dtoaresult));
+ ndig = (int)(dtoaend - dtoaresult);
if (convbuf != NULL)
free(convbuf);
#ifndef NARROW
}
if (dtoaresult == NULL)
goto oomem;
- ndig = dtoaend - dtoaresult;
+ _DIAGASSERT(__type_fit(int, dtoaend - dtoaresult));
+ ndig = (int)(dtoaend - dtoaresult);
if (convbuf != NULL)
free(convbuf);
#ifndef NARROW
/* space for thousands' grouping */
nseps = nrepeats = 0;
lead = expt;
- while (*grouping != CHAR_MAX) {
+ while ((unsigned char)*grouping
+ != (unsigned char)CHAR_MAX) {
if (lead <= *grouping)
break;
lead -= *grouping;
CHAR_T *p = MEMCHR(result, 0, (size_t)prec);
if (p != NULL) {
- size = p - result;
+ _DIAGASSERT(__type_fit(int,
+ p - result));
+ size = (int)(p - result);
if (size > prec)
size = prec;
} else
size = prec;
- } else
- size = STRLEN(result);
+ } else {
+ size_t rlen = STRLEN(result);
+ _DIAGASSERT(__type_fit(int, rlen));
+ size = (int)rlen;
+ }
sign = '\0';
break;
case 'U':
flags & GROUPING, thousands_sep,
grouping);
}
- size = buf + BUF - result;
+ _DIAGASSERT(__type_fit(int, buf + BUF - result));
+ size = (int)(buf + BUF - result);
if (size > BUF) /* should never happen */
abort();
break;
ret = END_OF_FILE;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
- return (ret);
+ return ret;
/* NOTREACHED */
oomem:
errno = ENOMEM;
{
CHAR_T *fmt; /* format string */
int ch; /* character from fmt */
- int n, n2; /* handy integer (short term usage) */
+ size_t n, n2; /* handy index (short term usage) */
CHAR_T *cp; /* handy char pointer (short term usage) */
int flags; /* flags as above */
enum typeid *typetable; /* table of types */
enum typeid stattypetable [STATIC_ARG_TBL_SIZE];
- int tablesize; /* current size of type table */
- int tablemax; /* largest used index in table */
- int nextarg; /* 1-based argument index */
+ size_t tablesize; /* current size of type table */
+ size_t tablemax; /* largest used index in table */
+ size_t nextarg; /* 1-based argument index */
+ size_t nitems; /* number of items we picked from the stack */
/*
* Add an argument type to the table, expanding if necessary.
+ * Check for overflow.
*/
#define ADDTYPE(type) \
do { \
+ if (nextarg > SIZE_MAX / sizeof(**argtable)) { \
+ if (typetable != stattypetable) \
+ free(typetable); \
+ return -1; \
+ } \
if (nextarg >= tablesize) \
if (__grow_type_table(nextarg, &typetable, \
&tablesize) == -1) \
if (nextarg > tablemax) \
tablemax = nextarg; \
typetable[nextarg++] = type; \
+ nitems++; \
} while (/*CONSTCOND*/0)
#define ADDSARG() \
cp++; \
} \
if (*cp == '$') { \
- int hold = nextarg; \
+ size_t hold = nextarg; \
nextarg = n2; \
ADDTYPE(T_INT); \
nextarg = hold; \
ADDTYPE(T_INT); \
}
fmt = (CHAR_T *)__UNCONST(fmt0);
+ memset(stattypetable, 0, sizeof(stattypetable));
typetable = stattypetable;
tablesize = STATIC_ARG_TBL_SIZE;
tablemax = 0;
nextarg = 1;
- for (n = 0; n < STATIC_ARG_TBL_SIZE; n++)
- typetable[n] = T_UNUSED;
+ nitems = 1;
/*
* Scan the format for conversions (`%' character).
}
}
done:
+ /*
+ * nitems contains the number of arguments we picked from the stack.
+ * If tablemax is larger, this means that some positional argument,
+ * tried to pick an argument the number of arguments possibly supplied.
+ * Since positional arguments are typically used to swap the order of
+ * the printf arguments and not to pick random arguments from strange
+ * positions in the stack, we assume that if the positional argument
+ * is trying to pick beyond the end of arguments, then this is wrong.
+ * Alternatively we could find a way to figure out when va_arg() runs
+ * out, but how to do that?
+ */
+ if (nitems < tablemax) {
+ if (typetable != stattypetable)
+ free(typetable);
+ return -1;
+ }
/*
* Build the argument table.
*/
if (tablemax >= STATIC_ARG_TBL_SIZE) {
- *argtable = (union arg *)
- malloc (sizeof (union arg) * (tablemax + 1));
- if (*argtable == NULL)
+ *argtable = malloc(sizeof(**argtable) * (tablemax + 1));
+ if (*argtable == NULL) {
+ free(typetable);
return -1;
+ }
}
(*argtable) [0].intarg = 0;
}
}
- if ((typetable != NULL) && (typetable != stattypetable))
+ if (typetable != stattypetable)
free (typetable);
return 0;
}
* Increase the size of the type table.
*/
static int
-__grow_type_table (int nextarg, enum typeid **typetable, int *tablesize)
+__grow_type_table (size_t nextarg, enum typeid **typetable, size_t *tablesize)
{
enum typeid *const oldtable = *typetable;
- const int oldsize = *tablesize;
+ const size_t oldsize = *tablesize;
enum typeid *newtable;
- int n, newsize = oldsize * 2;
+ size_t newsize = oldsize * 2;
if (newsize < nextarg + 1)
newsize = nextarg + 1;
if (oldsize == STATIC_ARG_TBL_SIZE) {
- if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
+ if ((newtable = malloc(newsize * sizeof(*newtable))) == NULL)
return -1;
- memcpy(newtable, oldtable, oldsize * sizeof(enum typeid));
+ memcpy(newtable, oldtable, oldsize * sizeof(*newtable));
} else {
- newtable = realloc(oldtable, newsize * sizeof(enum typeid));
+ newtable = realloc(oldtable, newsize * sizeof(*newtable));
if (newtable == NULL) {
free(oldtable);
return -1;
}
}
- for (n = oldsize; n < newsize; n++)
- newtable[n] = T_UNUSED;
+ memset(&newtable[oldsize], 0, (newsize - oldsize) * sizeof(*newtable));
*typetable = newtable;
*tablesize = newsize;
*p++ = '0';
*p++ = to_char(expo);
}
- return (p - p0);
+ _DIAGASSERT(__type_fit(int, p - p0));
+ return (int)(p - p0);
}
#endif /* !NO_FLOATING_POINT */
-/* $NetBSD: vfwscanf.c,v 1.6 2009/02/21 17:20:01 christos Exp $ */
+/* $NetBSD: vfwscanf.c,v 1.8 2012/03/15 18:22:30 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95";
__FBSDID("$FreeBSD: src/lib/libc/stdio/vfwscanf.c,v 1.12 2004/05/02 20:13:29 obrien Exp $");
#else
-__RCSID("$NetBSD: vfwscanf.c,v 1.6 2009/02/21 17:20:01 christos Exp $");
+__RCSID("$NetBSD: vfwscanf.c,v 1.8 2012/03/15 18:22:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <ctype.h>
#include <inttypes.h>
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
_SET_ORIENTATION(fp, 1);
ret = __vfwscanf_unlocked(fp, fmt, ap);
FUNLOCKFILE(fp);
- return (ret);
+ return ret;
}
#define SCANF_SKIP_SPACE() \
wchar_t *p0; /* saves original value of p when necessary */
int nassigned; /* number of fields assigned */
int nconversions; /* number of conversions */
- int nread; /* number of characters consumed from fp */
+ size_t nread; /* number of characters consumed from fp */
int base; /* base argument to conversion function */
wchar_t buf[BUF]; /* buffer for numeric conversions */
const wchar_t *ccls; /* character class start */
for (;;) {
c = *fmt++;
if (c == 0)
- return (nassigned);
+ return nassigned;
if (iswspace(c)) {
while ((c = __fgetwc_unlock(fp)) != WEOF &&
iswspace(c))
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORTSHORT)
- *va_arg(ap, char *) = nread;
+ *va_arg(ap, char *) = (char)nread;
else if (flags & SHORT)
- *va_arg(ap, short *) = nread;
+ *va_arg(ap, short *) = (short)nread;
else if (flags & LONG)
*va_arg(ap, long *) = nread;
else if (flags & LONGLONG)
else if (flags & PTRDIFFT)
*va_arg(ap, ptrdiff_t *) = nread;
else
- *va_arg(ap, int *) = nread;
+ *va_arg(ap, int *) = (int)nread;
continue;
default:
* Disgusting backwards compatibility hack. XXX
*/
case '\0': /* compat */
- return (EOF);
+ return EOF;
}
/*
*p++ = (wchar_t)wi;
if (wi != WEOF)
ungetwc(wi, fp);
- n = p - p0;
+ _DIAGASSERT(__type_fit(int, p - p0));
+ n = (int)(p - p0);
if (n == 0)
goto match_failure;
*p = 0;
*va_arg(ap, int *) = (int)res;
nassigned++;
}
- nread += p - buf;
+ _DIAGASSERT(__type_fit(int, p - buf));
+ nread += (int)(p - buf);
nconversions++;
break;
}
}
input_failure:
- return (nconversions != 0 ? nassigned : EOF);
+ return nconversions != 0 ? nassigned : EOF;
match_failure:
- return (nassigned);
+ return nassigned;
}
#ifndef NO_FLOATING_POINT
while (commit < --p)
ungetwc(*p, fp);
*++commit = '\0';
- return (commit - buf);
+ _DIAGASSERT(__type_fit(int, commit - buf));
+ return (int)(commit - buf);
}
#endif
-/* $NetBSD: vprintf.c,v 1.10 2003/08/07 16:43:34 agc Exp $ */
+/* $NetBSD: vprintf.c,v 1.12 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vprintf.c,v 1.10 2003/08/07 16:43:34 agc Exp $");
+__RCSID("$NetBSD: vprintf.c,v 1.12 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
+#include <stdarg.h>
#include <stdio.h>
int
-vprintf(fmt, ap)
- char const *fmt;
- _BSD_VA_LIST_ ap;
+vprintf(const char *fmt, va_list ap)
{
_DIAGASSERT(fmt != NULL);
- return (vfprintf(stdout, fmt, ap));
+ return vfprintf(stdout, fmt, ap);
}
-/* $NetBSD: vscanf.c,v 1.12 2003/08/07 16:43:35 agc Exp $ */
+/* $NetBSD: vscanf.c,v 1.14 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vscanf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vscanf.c,v 1.12 2003/08/07 16:43:35 agc Exp $");
+__RCSID("$NetBSD: vscanf.c,v 1.14 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "local.h"
int
-vscanf(fmt, ap)
- const char *fmt;
- _BSD_VA_LIST_ ap;
+vscanf(const char *fmt, va_list ap)
{
_DIAGASSERT(fmt != NULL);
- return (__svfscanf(stdin, fmt, ap));
+ return __svfscanf(stdin, fmt, ap);
}
-/* $NetBSD: vsnprintf.c,v 1.22 2007/10/26 19:48:14 christos Exp $ */
+/* $NetBSD: vsnprintf.c,v 1.25 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vsnprintf.c,v 1.22 2007/10/26 19:48:14 christos Exp $");
+__RCSID("$NetBSD: vsnprintf.c,v 1.25 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- const char *fmt;
- _BSD_VA_LIST_ ap;
+vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
int ret;
FILE f;
if ((int)n < 0) {
errno = EINVAL;
- return (-1);
+ return -1;
}
_FILEEXT_SETUP(&f, &fext);
f._bf._size = f._w = 0;
} else {
f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = n - 1;
+ _DIAGASSERT(__type_fit(int, n - 1));
+ f._bf._size = f._w = (int)(n - 1);
}
ret = __vfprintf_unlocked(&f, fmt, ap);
*f._p = 0;
- return (ret);
+ return ret;
}
-/* $NetBSD: vsnprintf_ss.c,v 1.9 2009/12/17 15:19:48 christos Exp $ */
+/* $NetBSD: vsnprintf_ss.c,v 1.12 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vsnprintf_ss.c,v 1.9 2009/12/17 15:19:48 christos Exp $");
+__RCSID("$NetBSD: vsnprintf_ss.c,v 1.12 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
} while (/*CONSTCOND*/0)
int
-vsnprintf_ss(char *sbuf, size_t slen, const char *fmt0, _BSD_VA_LIST_ ap)
+vsnprintf_ss(char *sbuf, size_t slen, const char *fmt0, va_list ap)
{
const char *fmt; /* format string */
int ch; /* character from fmt */
const char *xdigs; /* digits for [xX] conversion */
char bf[128]; /* space for %c, %[diouxX] */
char *tailp; /* tail pointer for snprintf */
+ size_t len;
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
if ((int)slen < 0) {
errno = EINVAL;
- return (-1);
+ return -1;
}
tailp = sbuf + slen;
char *p = memchr(cp, 0, (size_t)prec);
if (p != NULL) {
- size = p - cp;
+ _DIAGASSERT(__type_fit(int, p - cp));
+ size = (int)(p - cp);
if (size > prec)
size = prec;
} else
size = prec;
- } else
- size = strlen(cp);
+ } else {
+ len = strlen(cp);
+ _DIAGASSERT(__type_fit(int, len));
+ size = (int)len;
+ }
sign = '\0';
break;
case 'U':
default:
/*XXXUNCONST*/
cp = __UNCONST("bug bad base");
- size = strlen(cp);
+ len = strlen(cp);
+ _DIAGASSERT(__type_fit(int, len));
+ size = (int)len;
goto skipsize;
}
}
- size = bf + sizeof(bf) - cp;
+ _DIAGASSERT(__type_fit(int, bf + sizeof(bf) - cp));
+ size = (int)(bf + sizeof(bf) - cp);
skipsize:
break;
default: /* "%?" prints ?, unless ? is NUL */
sbuf[-1] = '\0';
else
*sbuf = '\0';
- return (ret);
+ return ret;
/* NOTREACHED */
}
-/* $NetBSD: vsprintf.c,v 1.15 2007/06/03 17:39:27 christos Exp $ */
+/* $NetBSD: vsprintf.c,v 1.17 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vsprintf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vsprintf.c,v 1.15 2007/06/03 17:39:27 christos Exp $");
+__RCSID("$NetBSD: vsprintf.c,v 1.17 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-vsprintf(str, fmt, ap)
- char *str;
- const char *fmt;
- _BSD_VA_LIST_ ap;
+vsprintf(char *str, const char *fmt, va_list ap)
{
int ret;
FILE f;
f._bf._size = f._w = INT_MAX;
ret = __vfprintf_unlocked(&f, fmt, ap);
*f._p = 0;
- return (ret);
+ return ret;
}
-/* $NetBSD: vsscanf.c,v 1.15 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: vsscanf.c,v 1.19 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vsscanf.c,v 1.15 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: vsscanf.c,v 1.19 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include "local.h"
-static int eofread __P((void *, char *, int));
-
/* ARGSUSED */
-static int
-eofread(cookie, buf, len)
- void *cookie;
- char *buf;
- int len;
+static ssize_t
+eofread(void *cookie, void *buf, size_t len)
{
- return (0);
+ return 0;
}
int
-vsscanf(str, fmt, ap)
- const char *str;
- const char *fmt;
- _BSD_VA_LIST_ ap;
+vsscanf(const char *str, const char *fmt, va_list ap)
{
FILE f;
struct __sfileext fext;
+ size_t len;
_DIAGASSERT(str != NULL);
_DIAGASSERT(fmt != NULL);
_FILEEXT_SETUP(&f, &fext);
f._flags = __SRD;
f._bf._base = f._p = __UNCONST(str);
- f._bf._size = f._r = strlen(str);
+ len = strlen(str);
+ _DIAGASSERT(__type_fit(int, len));
+ f._bf._size = f._r = (int)len;
f._read = eofread;
_UB(&f)._base = NULL;
- return (__svfscanf_unlocked(&f, fmt, ap));
+ return __svfscanf_unlocked(&f, fmt, ap);
}
-/* $NetBSD: vswprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: vswprintf.c,v 1.3 2012/03/15 18:22:31 christos Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/vswprintf.c,v 1.6 2005/02/21 19:41:44 fjoe Exp $");
#else
-__RCSID("$NetBSD: vswprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: vswprintf.c,v 1.3 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
if (n == 0) {
errno = EINVAL;
- return (-1);
+ return -1;
}
_FILEEXT_SETUP(&f, &fext);
f._bf._base = f._p = (unsigned char *)malloc(128);
if (f._bf._base == NULL) {
errno = ENOMEM;
- return (-1);
+ return -1;
}
f._bf._size = f._w = 127; /* Leave room for the NUL */
ret = __vfwprintf_unlocked(&f, fmt, ap);
sverrno = errno;
free(f._bf._base);
errno = sverrno;
- return (-1);
+ return -1;
}
*f._p = '\0';
mbp = (char *)f._bf._base;
* fputwc() did in __vfwprintf().
*/
mbs = initial;
- nwc = mbsrtowcs(s, (const char **)&mbp, n, &mbs);
+ nwc = mbsrtowcs(s, (void *)&mbp, n, &mbs);
free(f._bf._base);
if (nwc == (size_t)-1) {
errno = EILSEQ;
- return (-1);
+ return -1;
}
if (nwc == n) {
s[n - 1] = L'\0';
errno = EOVERFLOW;
- return (-1);
+ return -1;
}
- return (ret);
+ return ret;
}
-/* $NetBSD: vswscanf.c,v 1.6 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: vswscanf.c,v 1.9 2012/03/27 15:05:42 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.3 2004/04/07 09:55:05 tjr Exp $");
#else
-__RCSID("$NetBSD: vswscanf.c,v 1.6 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: vswscanf.c,v 1.9 2012/03/27 15:05:42 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
+#include <assert.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include "reentrant.h"
#include "local.h"
-static int eofread(void *, char *, int);
-
-static int
+static ssize_t
/*ARGSUSED*/
-eofread(void *cookie, char *buf, int len)
+eofread(void *cookie, void *buf, size_t len)
{
- return (0);
+ return 0;
}
int
* __vfwscanf() will convert back to wide characters.
*/
if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
- return (EOF);
+ return EOF;
mbs = initial;
if ((mlen = wcsrtombs(mbstr, &rstr, SIZE_T_MAX, &mbs)) == (size_t)-1) {
free(mbstr);
- return (EOF);
+ return EOF;
}
_FILEEXT_SETUP(&f, &fext);
(void)memset(WCIO_GET(&f), 0, sizeof(struct wchar_io_data));
f._file = -1;
f._flags = __SRD;
f._bf._base = f._p = (unsigned char *)mbstr;
- f._bf._size = f._r = mlen;
+ _DIAGASSERT(__type_fit(int, mlen));
+ f._bf._size = f._r = (int)mlen;
f._read = eofread;
_UB(&f)._base = NULL;
r = __vfwscanf_unlocked(&f, fmt, ap);
free(mbstr);
- return (r);
+ return r;
}
-/* $NetBSD: vwprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: vwprintf.c,v 1.2 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/vwprintf.c,v 1.1 2002/09/21 13:00:30 tjr Exp $");
#else
-__RCSID("$NetBSD: vwprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: vwprintf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
vwprintf(const wchar_t * __restrict fmt, va_list ap)
{
- return (vfwprintf(stdout, fmt, ap));
+ return vfwprintf(stdout, fmt, ap);
}
-/* $NetBSD: vwscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: vwscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/vwscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
#else
-__RCSID("$NetBSD: vwscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: vwscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
vwscanf(const wchar_t * __restrict fmt, va_list ap)
{
- return (vfwscanf(stdin, fmt, ap));
+ return vfwscanf(stdin, fmt, ap);
}
-/* $NetBSD: wbuf.c,v 1.13 2003/08/07 16:43:35 agc Exp $ */
+/* $NetBSD: wbuf.c,v 1.15 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wbuf.c,v 1.13 2003/08/07 16:43:35 agc Exp $");
+__RCSID("$NetBSD: wbuf.c,v 1.15 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* or if c=='\n' and the file is line buffered.
*/
int
-__swbuf(c, fp)
- int c;
- FILE *fp;
+__swbuf(int c, FILE *fp)
{
int n;
fp->_w = fp->_lbfsize;
if (cantwrite(fp)) {
errno = EBADF;
- return (EOF);
+ return EOF;
}
c = (unsigned char)c;
* guarantees that putc() will always call wbuf() by setting _w
* to 0, so we need not do anything else.
*/
- n = fp->_p - fp->_bf._base;
+ _DIAGASSERT(__type_fit(int, fp->_p - fp->_bf._base));
+ n = (int)(fp->_p - fp->_bf._base);
if (n >= fp->_bf._size) {
if (fflush(fp))
- return (EOF);
+ return EOF;
n = 0;
}
fp->_w--;
*fp->_p++ = c;
if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n'))
if (fflush(fp))
- return (EOF);
- return (c);
+ return EOF;
+ return c;
}
-/* $NetBSD: wprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: wprintf.c,v 1.2 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/wprintf.c,v 1.1 2002/09/21 13:00:30 tjr Exp $");
#else
-__RCSID("$NetBSD: wprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: wprintf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
ret = vfwprintf(stdout, fmt, ap);
va_end(ap);
- return (ret);
+ return ret;
}
-/* $NetBSD: wscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
+/* $NetBSD: wscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdio/wscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
#else
-__RCSID("$NetBSD: wscanf.c,v 1.1 2005/05/14 23:51:02 christos Exp $");
+__RCSID("$NetBSD: wscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
r = vfwscanf(stdin, fmt, ap);
va_end(ap);
- return (r);
+ return r;
}
-/* $NetBSD: wsetup.c,v 1.11 2003/08/07 16:43:35 agc Exp $ */
+/* $NetBSD: wsetup.c,v 1.12 2012/03/15 18:22:31 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)wsetup.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wsetup.c,v 1.11 2003/08/07 16:43:35 agc Exp $");
+__RCSID("$NetBSD: wsetup.c,v 1.12 2012/03/15 18:22:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* _wsetup returns 0 if OK to write, nonzero otherwise.
*/
int
-__swsetup(fp)
- FILE *fp;
+__swsetup(FILE *fp)
{
_DIAGASSERT(fp != NULL);
*/
if ((fp->_flags & __SWR) == 0) {
if ((fp->_flags & __SRW) == 0)
- return (EOF);
+ return EOF;
if (fp->_flags & __SRD) {
/* clobber any ungetc data */
if (HASUB(fp))
fp->_lbfsize = -fp->_bf._size;
} else
fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size;
- return (0);
+ return 0;
}
-# $NetBSD: Makefile.inc,v 1.75 2010/11/14 18:11:43 tron Exp $
+# $NetBSD: Makefile.inc,v 1.78 2011/09/14 23:33:51 christos Exp $
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
# stdlib sources
.PATH: ${ARCHDIR}/stdlib ${.CURDIR}/stdlib
-.if defined(__MINIX)
-# pty.c not compiled
+#LSC: MINIX: pty.c not compiled
SRCS+= _env.c _rand48.c \
a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \
bsearch.c drand48.c exit.c \
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
unsetenv.c strfmon.c
-.else
-SRCS+= _env.c _rand48.c \
- a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \
- bsearch.c drand48.c exit.c \
- getenv.c getopt.c getopt_long.c getsubopt.c \
- hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
- lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \
- nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \
- radixsort.c rand.c rand_r.c random.c remque.c \
- seed48.c setenv.c srand48.c strsuftoll.c \
- strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
- strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
- unsetenv.c strfmon.c
-.endif
# These are often replaced by MD .S versions
SRCS+= abs.c labs.c llabs.c imaxabs.c
.if (${USE_JEMALLOC} != "no")
SRCS+= jemalloc.c
-.elif (${USE_MINIXMALLOC} != "no")
+.elif (${USE_MINIXMALLOC:Uno} != "no")
.include "../minix/Makefile.inc"
.else
SRCS+= malloc.c
exit.3 \
getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \
hcreate.3 \
- imaxabs.3 imaxdiv.3 insque.3 \
+ insque.3 \
jemalloc.3 \
- labs.3 ldiv.3 llabs.3 lldiv.3 lsearch.3 \
+ lsearch.3 \
malloc.3 memory.3 mi_vector_hash.3 \
posix_memalign.3 posix_openpt.3 ptsname.3 \
qabs.3 qdiv.3 qsort.3 \
MLINKS+=a64l.3 l64a.3
MLINKS+=a64l.3 l64a_r.3
+MLINKS+=abs.3 labs.3 \
+ abs.3 llabs.3 \
+ abs.3 imaxabs.3
+MLINKS+=div.3 ldiv.3 \
+ div.3 lldiv.3 \
+ div.3 imaxdiv.3
MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
MLINKS+=getenv.3 getenv_r.3
MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3
+MLINKS+=hcreate.3 hcreate_r.3 hcreate.3 hdestroy_r.3 hcreate.3 hsearch_r.3
MLINKS+=insque.3 remque.3
MLINKS+=lsearch.3 lfind.3
MLINKS+=malloc.3 calloc.3 malloc.3 realloc.3 malloc.3 free.3
-/* $NetBSD: _env.c,v 1.5 2010/11/17 13:25:53 tron Exp $ */
+/* $NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
-static int inited = 0;
-
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _env.c,v 1.5 2010/11/17 13:25:53 tron Exp $");
+__RCSID("$NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
/* Our initialization function. */
void __libc_env_init(void);
+char **environ;
+
/*ARGSUSED*/
static signed int
env_tree_compare_nodes(void *ctx, const void *node_a, const void *node_b)
env_node_t *node;
_DIAGASSERT(envvar != NULL);
- assert(inited);
node = rb_tree_find_node(&env_tree, envvar);
if (node != NULL) {
rb_tree_remove_node(&env_tree, node);
{
env_node_t *node;
- assert(inited);
node = malloc(sizeof(*node) + length);
if (node != NULL) {
node->length = length;
{
env_node_t *node;
- assert(inited);
-
_DIAGASSERT(envvar != NULL);
node = rb_tree_find_node(&env_tree, envvar);
size_t num_entries;
env_node_t *node, *next;
- assert(inited);
while (++marker == 0);
/* Mark all nodes which are currently used. */
void
__libc_env_init(void)
{
- assert(!inited);
rb_tree_init(&env_tree, &env_tree_ops);
- inited = 1;
}
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: a64l.c,v 1.9 2003/07/26 19:24:53 salo Exp $");
+__RCSID("$NetBSD: a64l.c,v 1.10 2012/06/08 11:15:26 abs Exp $");
#endif
#include "namespace.h"
#endif
long
-a64l(s)
- const char *s;
+a64l(const char *s)
{
long value, digit, shift;
int i;
-.\" $NetBSD: abort.3,v 1.12 2003/08/07 16:43:37 agc Exp $
+.\" $NetBSD: abort.3,v 1.13 2012/06/12 21:16:17 jdf Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
Any open streams are flushed and closed.
.Sh RETURN VALUES
The
-.Nm abort
+.Fn abort
function
never returns.
.Sh SEE ALSO
-/* $NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $ */
+/* $NetBSD: abort.c,v 1.15 2012/06/08 11:15:26 abs Exp $ */
/*
* Copyright (c) 1985, 1993
#if 0
static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $");
+__RCSID("$NetBSD: abort.c,v 1.15 2012/06/08 11:15:26 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <unistd.h>
-extern void (*__cleanup) __P((void));
+extern void (*__cleanup)(void);
static int aborting = 0;
void
-abort()
+abort(void)
{
sigset_t mask;
-.\" $NetBSD: abs.3,v 1.13 2008/08/04 21:29:27 matt Exp $
+.\" $NetBSD: abs.3,v 1.14 2011/04/13 06:56:50 jruoho Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)abs.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd April 13, 2011
.Dt ABS 3
.Os
.Sh NAME
-.Nm abs
-.Nd integer absolute value function
+.Nm abs ,
+.Nm labs ,
+.Nm llabs ,
+.Nm imaxabs
+.Nd functions for integer absolute value
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft int
-.Fn abs "int j"
+.Fn abs "int x"
+.Ft long int
+.Fn labs "long int x"
+.Ft long long int
+.Fn llabs "long long int x"
+.In inttypes.h
+.Ft intmax_t
+.Fn imaxabs "intmax_t x"
.Sh DESCRIPTION
-The
-.Fn abs
-function
-computes
-the absolute value of the integer
-.Ar j .
-.Sh RETURN VALUES
-The
-.Fn abs
-function
-returns
-the absolute value.
+These functions return the absolute value of the integer
+.Fa x .
+The listed functions differ only with respect
+to the type of the return value and
+.Fa x .
.Sh SEE ALSO
.Xr cabs 3 ,
.Xr fabs 3 ,
.Xr floor 3 ,
-.Xr hypot 3 ,
-.Xr imaxabs 3 ,
-.Xr labs 3 ,
-.Xr llabs 3 ,
.Xr math 3
.Sh STANDARDS
-The
-.Fn abs
-function conforms to
-.St -ansiC .
+The described functions conform to
+.St -isoC-99 .
.Sh BUGS
The absolute value of the most negative integer remains negative.
-/* $NetBSD: abs.c,v 1.7 2003/08/07 16:43:37 agc Exp $ */
+/* $NetBSD: abs.c,v 1.8 2012/06/08 11:15:26 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)abs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: abs.c,v 1.7 2003/08/07 16:43:37 agc Exp $");
+__RCSID("$NetBSD: abs.c,v 1.8 2012/06/08 11:15:26 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
int
-abs(j)
- int j;
+abs(int j)
{
return(j < 0 ? -j : j);
}
-.\" $NetBSD: alloca.3,v 1.13 2010/05/03 06:11:38 jruoho Exp $
+.\" $NetBSD: alloca.3,v 1.14 2011/03/21 04:42:50 jruoho Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)alloca.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd May 3, 2010
+.Dd March 21, 2011
.Dt ALLOCA 3
.Os
.Sh NAME
modifies the stack at runtime,
it causes problems to certain security features.
See
-.Xr security 8
+.Xr security 7
for a discussion.
.El
.\" .Sh HISTORY
-/* $NetBSD: atof.c,v 1.12 2003/08/07 16:43:38 agc Exp $ */
+/* $NetBSD: atof.c,v 1.13 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)atof.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: atof.c,v 1.12 2003/08/07 16:43:38 agc Exp $");
+__RCSID("$NetBSD: atof.c,v 1.13 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
double
-atof(ascii)
- const char *ascii;
+atof(const char *ascii)
{
_DIAGASSERT(ascii != NULL);
-/* $NetBSD: atoi.c,v 1.11 2003/08/07 16:43:38 agc Exp $ */
+/* $NetBSD: atoi.c,v 1.12 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: atoi.c,v 1.11 2003/08/07 16:43:38 agc Exp $");
+__RCSID("$NetBSD: atoi.c,v 1.12 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
int
-atoi(str)
- const char *str;
+atoi(const char *str)
{
_DIAGASSERT(str != NULL);
-/* $NetBSD: atol.c,v 1.10 2003/08/07 16:43:38 agc Exp $ */
+/* $NetBSD: atol.c,v 1.11 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)atol.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: atol.c,v 1.10 2003/08/07 16:43:38 agc Exp $");
+__RCSID("$NetBSD: atol.c,v 1.11 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
long
-atol(str)
- const char *str;
+atol(const char *str)
{
_DIAGASSERT(str != NULL);
-/* $NetBSD: atoll.c,v 1.5 2003/10/27 00:12:42 lukem Exp $ */
+/* $NetBSD: atoll.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "from: @(#)atol.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: atoll.c,v 1.5 2003/10/27 00:12:42 lukem Exp $");
+__RCSID("$NetBSD: atoll.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if !HAVE_ATOLL
/* LONGLONG */
long long int
-atoll(str)
- const char *str;
+atoll(const char *str)
{
return (strtoll(str, (char **)NULL, 10));
}
-/* $NetBSD: bsearch.c,v 1.14 2010/11/27 18:33:54 christos Exp $ */
+/* $NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $ */
/*
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: bsearch.c,v 1.14 2010/11/27 18:33:54 christos Exp $");
+__RCSID("$NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
const void *p;
_DIAGASSERT(key != NULL);
- _DIAGASSERT(base0 != NULL);
+ _DIAGASSERT(base0 != NULL || nmemb == 0);
_DIAGASSERT(compar != NULL);
for (lim = nmemb; lim != 0; lim >>= 1) {
-.\" $NetBSD: div.3,v 1.12 2008/08/04 21:29:27 matt Exp $
+.\" $NetBSD: div.3,v 1.14 2011/05/03 09:36:24 wiz Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)div.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd April 13, 2011
.Dt DIV 3
.Os
.Sh NAME
-.Nm div
-.Nd return quotient and remainder from division
+.Nm div ,
+.Nm ldiv ,
+.Nm lldiv ,
+.Nm imaxdiv
+.Nd quotient and remainder from division
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft div_t
.Fn div "int num" "int denom"
+.Ft ldiv_t
+.Fn ldiv "long int num" "long int denom"
+.Ft lldiv_t
+.Fn lldiv "long long int num" "long long int denom"
+.In inttypes.h
+.Ft imaxdiv_t
+.Fn imaxdiv "intmax_t num" "intmax_t denom"
.Sh DESCRIPTION
-The
-.Fn div
-function
-computes the value
-.Fa num/denom
-and returns the quotient and remainder in a structure named
-.Fa div_t
-that contains two
-.Em int
-members named
-.Fa quot
+These functions compute the value of
+.Fa num / denom
+and return the quotient and remainder in a specific divison structure.
+The functions differ only with respect to the type of the return value and
+the parameters.
+.Pp
+The returned structure always contains two members named
+.Vt quot
and
-.Fa rem .
+.Vt rem ,
+denoting the quotient and the remainder.
+The type of these correspond with the underlying type of the function.
+.Sh EXAMPLES
+The following example demonstrate the basic usage of the functions.
+.Bd -literal -offset indent
+div_t d;
+
+int a = 4321;
+int b = 1234;
+
+d = div(a, b);
+
+(void)printf("%d %d\en", d.quot, d.rem);
+.Ed
.Sh SEE ALSO
-.Xr imaxdiv 3 ,
-.Xr ldiv 3 ,
-.Xr lldiv 3 ,
+.Xr fast_divide32 3 ,
.Xr math 3 ,
.Xr qdiv 3
.Sh STANDARDS
-The
-.Fn div
-function
-conforms to
-.St -ansiC .
+All described functions conform to
+.St -isoC-99 .
-/* $NetBSD: div.c,v 1.7 2003/08/07 16:43:39 agc Exp $ */
+/* $NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)div.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: div.c,v 1.7 2003/08/07 16:43:39 agc Exp $");
+__RCSID("$NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h> /* div_t */
div_t
-div(num, denom)
- int num, denom;
+div(int num, int denom)
{
div_t r;
-.\" $NetBSD: exit.3,v 1.14 2003/08/07 16:43:39 agc Exp $
+.\" $NetBSD: exit.3,v 1.15 2012/01/02 15:55:29 dholland Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)exit.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd August 11, 2002
+.Dd January 2, 2012
.Dt EXIT 3
.Os
.Sh NAME
.Fn exit
calls
.Xr _exit 2 .
-Note that typically
-.Xr _exit 2
-only passes the lower 8 bits of
+.Sh RESTRICTIONS
+Standard C guarantees only that the values zero,
+.Dv EXIT_SUCCESS ,
+and
+.Dv EXIT_FAILURE
+produce meaningful results.
+POSIX extends this to guarantee that the
+least significant 8 bits of
.Fa status
-on to the parent, thus negative values have less meaning.
+are preserved and returned to the parent via
+.Xr wait 2 .
+Values outside the supported range 0-255 are bitwise-truncated; therefore,
+negative values should not be used.
.Sh RETURN VALUES
The
.Fn exit
-/* $NetBSD: exit.c,v 1.13 2010/09/09 10:19:31 skrll Exp $ */
+/* $NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)exit.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: exit.c,v 1.13 2010/09/09 10:19:31 skrll Exp $");
+__RCSID("$NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "atexit.h"
#endif
-#ifdef _LIBC
-extern void __libc_init(void);
-#ifndef __lint
-static void (*force_ref)(void) __used = __libc_init;
-#endif
-#endif
-
-void (*__cleanup) __P((void));
+void (*__cleanup)(void);
/*
* Exit, flushing stdio buffers if necessary.
-/* $NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $ */
+/* $NetBSD: getsubopt.c,v 1.9 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $");
+__RCSID("$NetBSD: getsubopt.c,v 1.9 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
char *suboptarg;
int
-getsubopt(optionp, tokens, valuep)
- char **optionp, **valuep;
- char * const *tokens;
+getsubopt(char **optionp, char * const *tokens, char **valuep)
{
int cnt;
char *p;
-.\" $NetBSD: hcreate.3,v 1.8 2010/05/01 06:18:03 jruoho Exp $
+.\" $NetBSD: hcreate.3,v 1.10 2011/09/15 09:14:54 wiz Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 1, 2010
+.Dd September 14, 2011
.Dt HCREATE 3
.Os
.Sh NAME
.Nm hcreate ,
+.Nm hcreate_r ,
.Nm hdestroy ,
-.Nm hsearch
+.Nm hdestroy_r ,
+.Nm hsearch ,
+.Nm hsearch_r
.Nd manage hash search table
.Sh LIBRARY
.Lb libc
.In search.h
.Ft int
.Fn hcreate "size_t nel"
+.Ft int
+.Fn hcreate_r "size_t nel" "struct hsearch_data *table"
.Ft void
.Fn hdestroy "void"
+.Ft void
+.Fn hdestroy_r "struct hsearch_data *table"
.Ft ENTRY *
.Fn hsearch "ENTRY item" "ACTION action"
+.Ft int
+.Fn hsearch_r "ENTRY item" "ACTION action" "ENTRY ** itemp" "struct hsearch_data *table"
.Sh DESCRIPTION
The
.Fn hcreate ,
-.Fn hdestroy
+.Fn hcreate_r ,
+.Fn hdestroy ,
+.Fn hdestroy_r
+.Fn hsearch ,
and
-.Fn hsearch
+.Fn hsearch_r
functions manage hash search tables.
.Pp
The
.Fa key
is allocated by using
.Xr strdup 3 .
+.Pp
+The
+.Fn hcreate_r ,
+.Fn hdestroy_r ,
+and
+.Fn hsearch_r
+functions are re-entrant versions of the above functions that can
+operate on a table supplied by the user.
+The
+.Fn hsearch_r
+function returns
+.Dv 0
+if the action is
+.Dv ENTER
+and the element cannot be created,
+.Dv 1
+otherwise.
+If the element exists or can be created, it will be placed in
+.Fa itemp ,
+otherwise
+.Fa itemp
+will be set to
+.Dv NULL .
.Sh RETURN VALUES
If successful, the
.Fn hcreate
-function returns a non-zero value.
-Otherwise, a value of 0 is returned and
+and
+.Fn hcreate_r
+functions return a non-zero value.
+Otherwise, a value of
+.Dv 0
+is returned and
.Va errno
is set to indicate the error.
.Pp
The
.Fn hdestroy
-functions
-returns no value.
+and
+.Fn hdestroy_r
+functions return no value.
.Pp
If successful, the
.Fn hsearch
.Dv ENTER
and an entry already existed in the table matching the given
key, the existing entry is returned and is not replaced.
+.Pp
+The
+.Fn hsearch_r
+function returns
+.Dv 1
+unless the table is full, when it returns
+.Dv 0 .
+If
+.Fn hsearch
+returns
+.Dv 0
+or the element is not found,
+.Va errno
+is set to indicate the error.
.Sh ERRORS
The
-.Fn hcreate
-and
+.Fn hcreate ,
+.Fn hcreate_r ,
.Fn hsearch
+and
+.Fn hsearch_r
functions will fail if:
.Bl -tag -width Er
.It Bq Er ENOMEM
Insufficient memory is available.
.El
+.Pp
+The
+.Fn hsearch
+and
+.Fn hsearch_r
+functions will also fail if the action is
+.Dv SEARCH
+and the element is not found:
+.Bl -tag -width Er
+.It Bq Er ESRCH
+The
+.Fa item
+given is not found.
+.El
.Sh SEE ALSO
.Xr bsearch 3 ,
.Xr lsearch 3 ,
.Fn hsearch
functions first appeared in
.At V .
+The
+.Fn hcreate_r ,
+.Fn hdestroy_r
+and
+.Fn hsearch_r
+functions are
+.Tn GNU
+extensions.
.Sh CAVEATS
At least the following limitations can be mentioned:
.Bl -bullet
.It
-The interface permits the use of only one hash table at a time.
+The original,
+.Pf non- Tn GNU
+interface permits the use of only one hash table at a time.
.It
Individual hash table entries can be added, but not deleted.
.It
-/* $NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $ */
+/* $NetBSD: hcreate.c,v 1.8 2011/09/17 16:54:39 christos Exp $ */
/*
* Copyright (c) 2001 Christopher G. Demetriou
* 2. Redistributions in binary form must reproduce 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
+ * 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
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $");
+__RCSID("$NetBSD: hcreate.c,v 1.8 2011/09/17 16:54:39 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#if !defined(lint)
/* Default hash function, from db/hash/hash_func.c */
extern u_int32_t (*__default_hash)(const void *, size_t);
-static struct internal_head *htable;
-static size_t htablesize;
+static struct hsearch_data htable;
int
hcreate(size_t nel)
{
- size_t idx;
- unsigned int p2;
+ _DIAGASSERT(htable.table == NULL);
/* Make sure this isn't called when a table already exists. */
- _DIAGASSERT(htable == NULL);
- if (htable != NULL) {
+ if (htable.table != NULL) {
errno = EINVAL;
return 0;
}
+ return hcreate_r(nel, &htable);
+}
+
+int
+hcreate_r(size_t nel, struct hsearch_data *head)
+{
+ struct internal_head *table;
+ size_t idx;
+ unsigned int p2;
+ void *p;
/* If nel is too small, make it min sized. */
if (nel < MIN_BUCKETS)
}
/* Allocate the table. */
- htablesize = nel;
- htable = malloc(htablesize * sizeof htable[0]);
- if (htable == NULL) {
+ head->size = nel;
+ head->filled = 0;
+ p = malloc(nel * sizeof table[0]);
+ if (p == NULL) {
errno = ENOMEM;
return 0;
}
+ head->table = p;
+ table = p;
/* Initialize it. */
- for (idx = 0; idx < htablesize; idx++)
- SLIST_INIT(&htable[idx]);
+ for (idx = 0; idx < nel; idx++)
+ SLIST_INIT(&table[idx]);
return 1;
}
void
hdestroy(void)
+{
+ _DIAGASSERT(htable.table != NULL);
+ hdestroy_r(&htable);
+}
+
+void
+hdestroy_r(struct hsearch_data *head)
{
struct internal_entry *ie;
size_t idx;
+ void *p;
+ struct internal_head *table;
- _DIAGASSERT(htable != NULL);
- if (htable == NULL)
+ if (head == NULL)
return;
- for (idx = 0; idx < htablesize; idx++) {
- while (!SLIST_EMPTY(&htable[idx])) {
- ie = SLIST_FIRST(&htable[idx]);
- SLIST_REMOVE_HEAD(&htable[idx], link);
+ p = head->table;
+ head->table = NULL;
+ table = p;
+
+ for (idx = 0; idx < head->size; idx++) {
+ while (!SLIST_EMPTY(&table[idx])) {
+ ie = SLIST_FIRST(&table[idx]);
+ SLIST_REMOVE_HEAD(&table[idx], link);
free(ie->ent.key);
free(ie);
}
}
- free(htable);
- htable = NULL;
+ free(table);
}
ENTRY *
hsearch(ENTRY item, ACTION action)
{
- struct internal_head *head;
+ ENTRY *ep;
+ _DIAGASSERT(htable.table != NULL);
+ (void)hsearch_r(item, action, &ep, &htable);
+ return ep;
+}
+
+int
+hsearch_r(ENTRY item, ACTION action, ENTRY **itemp, struct hsearch_data *head)
+{
+ struct internal_head *table, *chain;
struct internal_entry *ie;
uint32_t hashval;
size_t len;
+ void *p;
- _DIAGASSERT(htable != NULL);
_DIAGASSERT(item.key != NULL);
_DIAGASSERT(action == ENTER || action == FIND);
+ p = head->table;
+ table = p;
+
len = strlen(item.key);
hashval = (*__default_hash)(item.key, len);
- head = &htable[hashval & (htablesize - 1)];
- ie = SLIST_FIRST(head);
+ chain = &table[hashval & (head->size - 1)];
+ ie = SLIST_FIRST(chain);
while (ie != NULL) {
if (strcmp(ie->ent.key, item.key) == 0)
break;
ie = SLIST_NEXT(ie, link);
}
- if (ie != NULL)
- return &ie->ent;
- else if (action == FIND)
- return NULL;
+ if (ie != NULL) {
+ *itemp = &ie->ent;
+ return 1;
+ } else if (action == FIND) {
+ *itemp = NULL;
+ errno = ESRCH;
+ return 1;
+ }
ie = malloc(sizeof *ie);
if (ie == NULL)
- return NULL;
+ return 0;
ie->ent.key = item.key;
ie->ent.data = item.data;
- SLIST_INSERT_HEAD(head, ie, link);
- return &ie->ent;
+ SLIST_INSERT_HEAD(chain, ie, link);
+ *itemp = &ie->ent;
+ head->filled++;
+ return 1;
}
+++ /dev/null
-.\" $NetBSD: imaxabs.3,v 1.2 2010/03/21 13:39:51 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.
-.\"
-.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 6, 2000
-.Dt IMAXABS 3
-.Os
-.Sh NAME
-.Nm imaxabs
-.Nd return the absolute value of a imaxint_t
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In inttypes.h
-.Ft intmax_t
-.Fn imaxabs "intmax_t i"
-.Sh DESCRIPTION
-The
-.Fn imaxabs
-function
-returns the absolute value of the
-.Vt imaxint_t
-integer
-.Ar j .
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr cabs 3 ,
-.Xr floor 3 ,
-.Xr labs 3 ,
-.Xr llabs 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn imaxabs
-function
-conforms to
-.St -isoC-99 .
-.Sh BUGS
-The absolute value of the most negative integer remains negative.
+++ /dev/null
-.\" $NetBSD: imaxdiv.3,v 1.1 2008/08/04 21:29:27 matt 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. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (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: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 6, 2000
-.Dt IMAXDIV 3
-.Os
-.Sh NAME
-.Nm imaxdiv
-.Nd return quotient and remainder from division
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In inttypes.h
-.Ft imaxdiv_t
-.Fn imaxdiv "intmax_t num" "intmax_t denom"
-.Sh DESCRIPTION
-The
-.Fn imaxdiv
-function
-divides
-.Ar num
-by
-.Ar denom
-and returns the resulting quotient and remainder in a structure named
-.Ar imaxdiv_t
-that contains two
-.Em imaxint_t
-members named
-.Ar quot
-and
-.Ar rem .
-.Sh SEE ALSO
-.Xr div 3 ,
-.Xr ldiv 3 ,
-.Xr lldiv 3 ,
-.Xr math 3 ,
-.Xr qdiv 3
-.Sh STANDARDS
-The
-.Fn imaxdiv
-function
-conforms to
-.St -isoC-99 .
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: insque.c,v 1.2 2005/07/06 17:17:15 drochner Exp $");
+__RCSID("$NetBSD: insque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
};
void
-insque(entry, pred)
- void *entry;
- void *pred;
+insque(void *entry, void *pred)
{
struct qelem *e = (struct qelem *) entry;
struct qelem *p = (struct qelem *) pred;
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.73 2007/06/15 22:32:33 jasone Exp $
.\"
-.Dd May 14, 2010
-.Os
+.Dd June 21, 2011
.Dt JEMALLOC 3
+.Os
.Sh NAME
.Nm jemalloc
.Nd the default system allocator
This is intended for debugging and will impact performance negatively.
.El
.Pp
+Extra care should be taken when enabling
+any of the options in production environments.
The
-.Em J
+.Em A ,
+.Em J ,
and
.Em Z
options are intended for testing and debugging.
There are a number of allocator implementations available on the Internet
which focus on detecting and pinpointing problems by trading performance for
extra sanity checks and detailed diagnostics.
+.Sh ENVIRONMENT
+The following environment variables affect the execution of the allocation
+functions:
+.Bl -tag -width ".Ev MALLOC_OPTIONS"
+.It Ev MALLOC_OPTIONS
+If the environment variable
+.Ev MALLOC_OPTIONS
+is set, the characters it contains will be interpreted as flags to the
+allocation functions.
+.El
+.Sh EXAMPLES
+To dump core whenever a problem occurs:
+.Pp
+.Bd -literal -offset indent
+ln -s 'A' /etc/malloc.conf
+.Ed
+.Pp
+To specify in the source that a program does no return value checking
+on calls to these functions:
+.Bd -literal -offset indent
+_malloc_options = "X";
+.Ed
.Sh DIAGNOSTICS
If any of the memory allocation/deallocation functions detect an error or
warning condition, a message will be printed to file descriptor
.Pp
All messages are prefixed by
.Dq Ao Ar progname Ac Ns Li \&: Pq malloc .
-.Sh ENVIRONMENT
-The following environment variables affect the execution of the allocation
-functions:
-.Bl -tag -width ".Ev MALLOC_OPTIONS"
-.It Ev MALLOC_OPTIONS
-If the environment variable
-.Ev MALLOC_OPTIONS
-is set, the characters it contains will be interpreted as flags to the
-allocation functions.
-.El
-.Sh EXAMPLES
-To dump core whenever a problem occurs:
-.Pp
-.Bd -literal -offset indent
-ln -s 'A' /etc/malloc.conf
-.Ed
-.Pp
-To specify in the source that a program does no return value checking
-on calls to these functions:
-.Bd -literal -offset indent
-_malloc_options = "X";
-.Ed
.Sh SEE ALSO
.Xr emalloc 3 ,
.Xr malloc 3 ,
-/* $NetBSD: jemalloc.c,v 1.21 2010/03/04 22:48:31 enami Exp $ */
+/* $NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos Exp $ */
/*-
* Copyright (C) 2006,2007 Jason Evans <jasone@FreeBSD.org>.
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $"); */
-__RCSID("$NetBSD: jemalloc.c,v 1.21 2010/03/04 22:48:31 enami Exp $");
+__RCSID("$NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos Exp $");
#ifdef __FreeBSD__
#include "libc_private.h"
#define SMALL_MAX_DEFAULT (1 << SMALL_MAX_2POW_DEFAULT)
/*
- * Maximum desired run header overhead. Runs are sized as small as possible
- * such that this setting is still honored, without violating other constraints.
- * The goal is to make runs as small as possible without exceeding a per run
- * external fragmentation threshold.
+ * RUN_MAX_OVRHD indicates maximum desired run header overhead. Runs are sized
+ * as small as possible such that this setting is still honored, without
+ * violating other constraints. The goal is to make runs as small as possible
+ * without exceeding a per run external fragmentation threshold.
*
- * Note that it is possible to set this low enough that it cannot be honored
- * for some/all object sizes, since there is one bit of header overhead per
- * object (plus a constant). In such cases, this constraint is relaxed.
+ * We use binary fixed point math for overhead computations, where the binary
+ * point is implicitly RUN_BFP bits to the left.
*
- * RUN_MAX_OVRHD_RELAX specifies the maximum number of bits per region of
- * overhead for which RUN_MAX_OVRHD is relaxed.
+ * Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be
+ * honored for some/all object sizes, since there is one bit of header overhead
+ * per object (plus a constant). This constraint is relaxed (ignored) for runs
+ * that are so small that the per-region overhead is greater than:
+ *
+ * (RUN_MAX_OVRHD / (reg_size << (3+RUN_BFP))
*/
-#define RUN_MAX_OVRHD 0.015
-#define RUN_MAX_OVRHD_RELAX 1.5
+#define RUN_BFP 12
+/* \/ Implicit binary fixed point. */
+#define RUN_MAX_OVRHD 0x0000003dU
+#define RUN_MAX_OVRHD_RELAX 0x00001800U
/* Put a cap on small object run size. This overrides RUN_MAX_OVRHD. */
#define RUN_MAX_SMALL_2POW 15
#ifdef MALLOC_STATS
static void malloc_printf(const char *format, ...);
#endif
-static char *umax2s(uintmax_t x, char *s);
+static char *size_t2s(size_t x, char *s);
static bool base_pages_alloc(size_t minsize);
static void *base_alloc(size_t size);
static chunk_node_t *base_chunk_node_alloc(void);
/*
* We don't want to depend on vsnprintf() for production builds, since that can
- * cause unnecessary bloat for static binaries. umax2s() provides minimal
+ * cause unnecessary bloat for static binaries. size_t2s() provides minimal
* integer printing functionality, so that malloc_printf() use can be limited to
* MALLOC_STATS code.
*/
#define UMAX2S_BUFSIZE 21
static char *
-umax2s(uintmax_t x, char *s)
+size_t2s(size_t x, char *s)
{
unsigned i;
/* Make sure UMAX2S_BUFSIZE is large enough. */
/* LINTED */
- assert(sizeof(uintmax_t) <= 8);
+ assert(sizeof(size_t) <= 8);
i = UMAX2S_BUFSIZE - 1;
s[i] = '\0';
size_t try_run_size, good_run_size;
unsigned good_nregs, good_mask_nelms, good_reg0_offset;
unsigned try_nregs, try_mask_nelms, try_reg0_offset;
- float max_ovrhd = RUN_MAX_OVRHD;
assert(min_run_size >= pagesize);
assert(min_run_size <= arena_maxclass);
*/
try_run_size = min_run_size;
try_nregs = (unsigned)(((try_run_size - sizeof(arena_run_t)) /
- bin->reg_size) + 1); /* Counter-act the first line of the loop. */
+ bin->reg_size) + 1); /* Counter-act try_nregs-- in loop. */
do {
try_nregs--;
try_mask_nelms = (try_nregs >> (SIZEOF_INT_2POW + 3)) +
} while (sizeof(arena_run_t) + (sizeof(unsigned) *
(try_mask_nelms - 1)) > try_reg0_offset);
} while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL
- && max_ovrhd > RUN_MAX_OVRHD_RELAX / ((float)(bin->reg_size << 3))
- && ((float)(try_reg0_offset)) / ((float)(try_run_size)) >
- max_ovrhd);
+ && RUN_MAX_OVRHD * (bin->reg_size << 3) > RUN_MAX_OVRHD_RELAX
+ && (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size);
assert(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1))
<= good_reg0_offset);
opt_xmalloc ? "X" : "x",
opt_zero ? "Z\n" : "z\n");
- _malloc_message("CPUs: ", umax2s(ncpus, s), "\n", "");
- _malloc_message("Max arenas: ", umax2s(narenas, s), "\n", "");
- _malloc_message("Pointer size: ", umax2s(sizeof(void *), s),
+ _malloc_message("CPUs: ", size_t2s(ncpus, s), "\n", "");
+ _malloc_message("Max arenas: ", size_t2s(narenas, s), "\n", "");
+ _malloc_message("Pointer size: ", size_t2s(sizeof(void *), s),
"\n", "");
- _malloc_message("Quantum size: ", umax2s(quantum, s), "\n", "");
- _malloc_message("Max small size: ", umax2s(small_max, s), "\n",
+ _malloc_message("Quantum size: ", size_t2s(quantum, s), "\n", "");
+ _malloc_message("Max small size: ", size_t2s(small_max, s), "\n",
"");
- _malloc_message("Chunk size: ", umax2s(chunksize, s), "", "");
- _malloc_message(" (2^", umax2s(opt_chunk_2pow, s), ")\n", "");
+ _malloc_message("Chunk size: ", size_t2s(chunksize, s), "", "");
+ _malloc_message(" (2^", size_t2s((size_t)opt_chunk_2pow, s),
+ ")\n", "");
#ifdef MALLOC_STATS
{
ssize_t linklen;
char buf[PATH_MAX + 1];
const char *opts = "";
+ int serrno;
malloc_mutex_lock(&init_lock);
if (malloc_initialized) {
return (false);
}
+ serrno = errno;
/* Get number of CPUs. */
{
int mib[2];
}
}
}
+ errno = serrno;
/* Take care to call atexit() only once. */
if (opt_print_stats) {
-/* $NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $ */
+/* $NetBSD: l64a.c,v 1.14 2012/03/13 21:13:48 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $");
+__RCSID("$NetBSD: l64a.c,v 1.14 2012/03/13 21:13:48 christos Exp $");
#endif
#include "namespace.h"
#endif
char *
-l64a (value)
- long value;
+l64a(long value)
{
static char buf[8];
- (void)l64a_r(value, buf, sizeof (buf));
+ (void)l64a_r(value, buf, (int)sizeof (buf));
return buf;
}
int
-l64a_r (value, buffer, buflen)
- long value;
- char *buffer;
- int buflen;
+l64a_r(long value, char *buffer, int buflen)
{
char *s = buffer;
int digit;
+++ /dev/null
-.\" $NetBSD: labs.3,v 1.11 2008/08/04 21:29:27 matt 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.
-.\"
-.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt LABS 3
-.Os
-.Sh NAME
-.Nm labs
-.Nd return the absolute value of a long integer
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft long int
-.Fn labs "long int j"
-.Sh DESCRIPTION
-The
-.Fn labs
-function
-returns the absolute value of the long integer
-.Ar j .
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr cabs 3 ,
-.Xr floor 3 ,
-.Xr imaxabs 3 ,
-.Xr llabs 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn labs
-function
-conforms to
-.St -ansiC .
-.Sh BUGS
-The absolute value of the most negative integer remains negative.
-/* $NetBSD: labs.c,v 1.7 2003/08/07 16:43:41 agc Exp $ */
+/* $NetBSD: labs.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)labs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: labs.c,v 1.7 2003/08/07 16:43:41 agc Exp $");
+__RCSID("$NetBSD: labs.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
long
-labs(j)
- long j;
+labs(long j)
{
return(j < 0 ? -j : j);
}
+++ /dev/null
-.\" $NetBSD: ldiv.3,v 1.13 2008/08/04 21:29:27 matt 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. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (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: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt LDIV 3
-.Os
-.Sh NAME
-.Nm ldiv
-.Nd return quotient and remainder from division
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft ldiv_t
-.Fn ldiv "long int num" "long int denom"
-.Sh DESCRIPTION
-The
-.Fn ldiv
-function
-computes the value
-.Ar num/denom
-and returns the quotient and remainder in a structure named
-.Ar ldiv_t
-that contains two
-.Em long integer
-members named
-.Ar quot
-and
-.Ar rem .
-.Sh SEE ALSO
-.Xr div 3 ,
-.Xr imaxdiv 3 ,
-.Xr lldiv 3 ,
-.Xr math 3 ,
-.Xr qdiv 3
-.Sh STANDARDS
-The
-.Fn ldiv
-function
-conforms to
-.St -ansiC .
-/* $NetBSD: ldiv.c,v 1.7 2003/08/07 16:43:41 agc Exp $ */
+/* $NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)ldiv.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: ldiv.c,v 1.7 2003/08/07 16:43:41 agc Exp $");
+__RCSID("$NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h> /* ldiv_t */
ldiv_t
-ldiv(num, denom)
- long num, denom;
+ldiv(long num, long denom)
{
ldiv_t r;
+++ /dev/null
-.\" $NetBSD: llabs.3,v 1.7 2008/08/04 21:29:27 matt 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.
-.\"
-.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 6, 2000
-.Dt LLABS 3
-.Os
-.Sh NAME
-.Nm llabs
-.Nd return the absolute value of a long long integer
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft long long int
-.Fn llabs "long long int j"
-.Sh DESCRIPTION
-The
-.Fn llabs
-function
-returns the absolute value of the long long integer
-.Ar j .
-.Sh SEE ALSO
-.Xr abs 3 ,
-.Xr cabs 3 ,
-.Xr floor 3 ,
-.Xr imaxabs 3 ,
-.Xr labs 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn llabs
-function
-conforms to
-.St -isoC-99 .
-.Sh BUGS
-The absolute value of the most negative integer remains negative.
-/* $NetBSD: llabs.c,v 1.3 2003/08/07 16:43:41 agc Exp $ */
+/* $NetBSD: llabs.c,v 1.4 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "from: @(#)labs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: llabs.c,v 1.3 2003/08/07 16:43:41 agc Exp $");
+__RCSID("$NetBSD: llabs.c,v 1.4 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/* LONGLONG */
long long int
-llabs(j)
- long long int j;
+llabs(long long int j)
{
return (j < 0 ? -j : j);
}
+++ /dev/null
-.\" $NetBSD: lldiv.3,v 1.7 2008/08/04 21:29:27 matt 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. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (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: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 6, 2000
-.Dt LLDIV 3
-.Os
-.Sh NAME
-.Nm lldiv
-.Nd return quotient and remainder from division
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft lldiv_t
-.Fn lldiv "long long int num" "long long int denom"
-.Sh DESCRIPTION
-The
-.Fn lldiv
-function
-computes the value
-.Ar num/denom
-and returns the quotient and remainder in a structure named
-.Ar lldiv_t
-that contains two
-.Em long long integer
-members named
-.Ar quot
-and
-.Ar rem .
-.Sh SEE ALSO
-.Xr div 3 ,
-.Xr imaxdiv 3 ,
-.Xr ldiv 3 ,
-.Xr math 3 ,
-.Xr qdiv 3
-.Sh STANDARDS
-The
-.Fn lldiv
-function
-conforms to
-.St -isoC-99 .
-/* $NetBSD: lldiv.c,v 1.3 2003/08/07 16:43:41 agc Exp $ */
+/* $NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "from: @(#)ldiv.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: lldiv.c,v 1.3 2003/08/07 16:43:41 agc Exp $");
+__RCSID("$NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/* LONGLONG */
lldiv_t
-lldiv(num, denom)
- long long int num, denom;
+lldiv(long long int num, long long int denom)
{
lldiv_t r;
#if 0
static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: lsearch.c,v 1.4 2005/07/16 17:32:09 christos Exp $");
+__RCSID("$NetBSD: lsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include <search.h>
-typedef int (*cmp_fn_t) __P((const void *, const void *));
-static void *linear_base __P((const void *, void *, size_t *, size_t,
- cmp_fn_t, int));
+typedef int (*cmp_fn_t)(const void *, const void *);
+static void *linear_base(const void *, void *, size_t *, size_t,
+ cmp_fn_t, int);
void *
-lsearch(key, base, nelp, width, compar)
- const void *key;
- void *base;
- size_t *nelp, width;
- cmp_fn_t compar;
+lsearch(const void *key, void *base, size_t *nelp, size_t width,
+ cmp_fn_t compar)
{
_DIAGASSERT(key != NULL);
}
void *
-lfind(key, base, nelp, width, compar)
- const void *key, *base;
- size_t *nelp, width;
- cmp_fn_t compar;
+lfind(const void *key, const void *base, size_t *nelp, size_t width,
+ cmp_fn_t compar)
{
_DIAGASSERT(key != NULL);
}
static void *
-linear_base(key, base, nelp, width, compar, add_flag)
- const void *key;
- void *base;
- size_t *nelp, width;
- cmp_fn_t compar;
- int add_flag;
+linear_base(const void *key, void *base, size_t *nelp, size_t width,
+ cmp_fn_t compar, int add_flag)
{
char *element, *end;
-/* $NetBSD: malloc.c,v 1.52 2008/02/03 22:56:53 christos Exp $ */
+/* $NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $ */
/*
* ----------------------------------------------------------------------------
# define malloc_pageshift 12U
# define malloc_minsize 16U
# endif
-#ifndef __minix
# define HAS_UTRACE
# define UTRACE_LABEL
-#endif /* __minix */
#include <sys/cdefs.h>
void utrace(struct ut *, int);
#undef minix_mmap
#undef minix_munmap
-#include <assert.h>
-
#include <sys/types.h>
#if defined(__NetBSD__)
# define malloc_minsize 16U
#include <sys/cdefs.h>
#include "extern.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: malloc.c,v 1.52 2008/02/03 22:56:53 christos Exp $");
+__RCSID("$NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $");
#endif /* LIBC_SCCS and not lint */
int utrace(const char *, void *, size_t);
static void
malloc_init(void)
{
- int save_errno = errno;
#ifndef MALLOC_NO_SYSCALLS
const char *p;
char b[64];
size_t i;
ssize_t j;
+#endif
+ int serrno = errno;
+#ifndef MALLOC_NO_SYSCALLS
/*
* Compute page-size related variables.
for (i = 0; i < 3; i++) {
if (i == 0) {
j = readlink("/etc/malloc.conf", b, sizeof b - 1);
- if (j <= 0)
+ if (j == -1)
continue;
b[j] = '\0';
p = b;
*/
px = imalloc(sizeof *px);
- errno = save_errno;
+ errno = serrno;
}
/*
pf->size > malloc_cache && /* ..and the cache is full, */
pf->end == malloc_brk && /* ..and none behind us, */
malloc_brk == sbrk((intptr_t)0)) { /* ..and it's OK to do... */
- int r;
+
/*
* Keep the cache intact. Notice that the '>' above guarantees that
* the pf will always have at least one page afterwards.
pf->end = (char *)pf->page + malloc_cache;
pf->size = malloc_cache;
- r = brk(pf->end);
- assert(r >= 0);
+ brk(pf->end);
malloc_brk = pf->end;
idx = ptr2idx(pf->end);
-.\" $NetBSD: memory.3,v 1.10 2003/08/07 16:43:42 agc Exp $
+.\" $NetBSD: memory.3,v 1.11 2011/09/11 10:05:23 jruoho Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)memory.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd September 11, 2011
.Dt MEMORY 3
.Os
.Sh NAME
These functions allocate and free memory for the calling process.
They are described in the
individual manual pages.
+The memory allocators used in the kernel are described in
+.Xr memoryallocators 9 .
.Sh SEE ALSO
.Xr alloca 3 ,
.Xr calloc 3 ,
-/* $NetBSD: merge.c,v 1.12 2009/02/12 03:12:36 lukem Exp $ */
+/* $NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "from: @(#)merge.c 8.2 (Berkeley) 2/14/94";
#else
-__RCSID("$NetBSD: merge.c,v 1.12 2009/02/12 03:12:36 lukem Exp $");
+__RCSID("$NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__weak_alias(mergesort,_mergesort)
#endif
-static void setup __P((u_char *, u_char *, size_t, size_t,
- int (*)(const void *, const void *)));
-static void insertionsort __P((u_char *, size_t, size_t,
- int (*)(const void *, const void *)));
+static void setup(u_char *, u_char *, size_t, size_t,
+ int (*)(const void *, const void *));
+static void insertionsort(u_char *, size_t, size_t,
+ int (*)(const void *, const void *));
#define ISIZE sizeof(int)
#define PSIZE sizeof(u_char *)
* Arguments are as for qsort.
*/
int
-mergesort(base, nmemb, size, cmp)
- void *base;
- size_t nmemb;
- size_t size;
- int (*cmp) __P((const void *, const void *));
+mergesort(void *base, size_t nmemb, size_t size,
+ int (*cmp)(const void *, const void *))
{
size_t i;
int sense;
/* XXX: shouldn't this function be static? - lukem 990810 */
void
-setup(list1, list2, n, size, cmp)
- size_t n, size;
- int (*cmp) __P((const void *, const void *));
- u_char *list1, *list2;
+setup(u_char *list1, u_char *list2, size_t n, size_t size,
+ int (*cmp)(const void *, const void *))
{
- int i, length, size2, tmp, sense;
+ int length, tmp, sense;
u_char *f1, *f2, *s, *l2, *last, *p2;
+ size_t size2, i;
_DIAGASSERT(cmp != NULL);
_DIAGASSERT(list1 != NULL);
* for simplicity.
*/
i = 4 + (n & 1);
- insertionsort(list1 + (n - i) * size, (size_t)i, size, cmp);
+ insertionsort(list1 + (n - i) * size, i, size, cmp);
last = list1 + size * (n - i);
*EVAL(list2 + (last - list1)) = list2 + n * size;
if ((cmp(f2-size, f2) > 0) != sense) {
p2 = *EVAL(p2) = f2 - list1 + list2;
if (sense > 0)
- reverse(f1, f2-size);
+ reverse(f1, f2 - size);
f1 = f2;
}
}
if (sense > 0)
- reverse (f1, f2-size);
+ reverse(f1, f2 - size);
f1 = f2;
if (f2 < last || cmp(f2 - size, f2) > 0)
p2 = *EVAL(p2) = f2 - list1 + list2;
* last 4 elements.
*/
static void
-insertionsort(a, n, size, cmp)
- u_char *a;
- size_t n, size;
- int (*cmp) __P((const void *, const void *));
+insertionsort(u_char *a, size_t n, size_t size,
+ int (*cmp)(const void *, const void *))
{
u_char *ai, *s, *t, *u, tmp;
- int i;
+ size_t i;
_DIAGASSERT(a != NULL);
_DIAGASSERT(cmp != NULL);
-/* $NetBSD: mi_vector_hash.c,v 1.3 2010/03/19 18:11:30 joerg Exp $ */
+/* $NetBSD: mi_vector_hash.c,v 1.4 2011/10/21 23:45:56 joerg Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mi_vector_hash.c,v 1.3 2010/03/19 18:11:30 joerg Exp $");
+__RCSID("$NetBSD: mi_vector_hash.c,v 1.4 2011/10/21 23:45:56 joerg Exp $");
#include "namespace.h"
+#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
+#endif
#include <stdint.h>
#include <stdlib.h>
-.\" $NetBSD: posix_openpt.3,v 1.4 2008/04/30 13:10:51 martin Exp $
+.\" $NetBSD: posix_openpt.3,v 1.6 2011/05/05 07:36:44 wiz Exp $
.\"
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
.\" All rights reserved.
.Ft int
.Fn posix_openpt "int oflag"
.Sh DESCRIPTION
+The
.Fn posix_openpt
-Searches for an unused master pseudo-terminal device, opens it, and returns
-a file descriptor associated the now used pseudo-terminal device.
+function searches for an unused master pseudo-terminal device,
+opens it, and returns a file descriptor associated with the now
+used pseudo-terminal device.
The
.Fa oflag
argument has the same meaning as in the
#ifdef __weak_alias
__weak_alias(putenv,_putenv)
+#if defined(__minix)
+__weak_alias(__putenv50,_putenv)
+#endif /* defined(__minix) */
#endif
int
-/* $NetBSD: qabs.c,v 1.6 2003/08/07 16:43:42 agc Exp $ */
+/* $NetBSD: qabs.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#if 0
static char *sccsid = "from: @(#)labs.c 5.2 (Berkeley) 5/17/90";
#else
-__RCSID("$NetBSD: qabs.c,v 1.6 2003/08/07 16:43:42 agc Exp $");
+__RCSID("$NetBSD: qabs.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
quad_t
-qabs(j)
- quad_t j;
+qabs(quad_t j)
{
return(j < 0 ? -j : j);
}
-/* $NetBSD: qdiv.c,v 1.6 2003/08/07 16:43:42 agc Exp $ */
+/* $NetBSD: qdiv.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1990 Regents of the University of California.
#if 0
static char *sccsid = "from: @(#)ldiv.c 5.2 (Berkeley) 4/16/91";
#else
-__RCSID("$NetBSD: qdiv.c,v 1.6 2003/08/07 16:43:42 agc Exp $");
+__RCSID("$NetBSD: qdiv.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
qdiv_t
-qdiv(num, denom)
- quad_t num, denom;
+qdiv(quad_t num, quad_t denom)
{
qdiv_t r;
-/* $NetBSD: qsort.c,v 1.20 2009/06/01 06:37:40 yamt Exp $ */
+/* $NetBSD: qsort.c,v 1.22 2012/05/26 21:47:05 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: qsort.c,v 1.20 2009/06/01 06:37:40 yamt Exp $");
+__RCSID("$NetBSD: qsort.c,v 1.22 2012/05/26 21:47:05 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <errno.h>
#include <stdlib.h>
-static inline char *med3 __P((char *, char *, char *,
- int (*)(const void *, const void *)));
-static inline void swapfunc __P((char *, char *, size_t, int));
+static inline char *med3(char *, char *, char *,
+ int (*)(const void *, const void *));
+static inline void swapfunc(char *, char *, size_t, int);
#define min(a, b) (a) < (b) ? a : b
static inline char *
med3(char *a, char *b, char *c,
- int (*cmp) __P((const void *, const void *)))
+ int (*cmp)(const void *, const void *))
{
return cmp(a, b) < 0 ?
void
qsort(void *a, size_t n, size_t es,
- int (*cmp) __P((const void *, const void *)))
+ int (*cmp)(const void *, const void *))
{
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
size_t d, r;
int swaptype, cmp_result;
- _DIAGASSERT(a != NULL);
+ _DIAGASSERT(a != NULL || n == 0 || es == 0);
_DIAGASSERT(cmp != NULL);
loop: SWAPINIT(a, es);
-/* $NetBSD: rand.c,v 1.10 2003/08/07 16:43:43 agc Exp $ */
+/* $NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
#else
-__RCSID("$NetBSD: rand.c,v 1.10 2003/08/07 16:43:43 agc Exp $");
+__RCSID("$NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
static u_long next = 1;
int
-rand()
+rand(void)
{
/* LINTED integer overflow */
return (int)((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
}
void
-srand(seed)
- u_int seed;
+srand(u_int seed)
{
next = seed;
}
-/* $NetBSD: rand48.h,v 1.5 2006/03/22 20:52:16 drochner Exp $ */
+/* $NetBSD: rand48.h,v 1.6 2011/05/18 19:36:36 dsl Exp $ */
/*
* Copyright (c) 1993 Martin Birgmeier
#include <stdlib.h>
-extern void __dorand48 __P((unsigned short[3]));
+extern void __dorand48(unsigned short[3]);
extern unsigned short __rand48_seed[3];
extern unsigned short __rand48_mult[3];
extern unsigned short __rand48_add;
-/* $NetBSD: rand_r.c,v 1.5 2003/08/07 16:43:43 agc Exp $ */
+/* $NetBSD: rand_r.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#if 0
static char *sccsid = "from: @(#)rand.c 5.6 (Berkeley) 6/24/91";
#else
-__RCSID("$NetBSD: rand_r.c,v 1.5 2003/08/07 16:43:43 agc Exp $");
+__RCSID("$NetBSD: rand_r.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
int
-rand_r(seed)
- unsigned int *seed;
+rand_r(unsigned int *seed)
{
_DIAGASSERT(seed != NULL);
-.\" $NetBSD: random.3,v 1.19 2008/02/28 16:16:35 christos Exp $
+.\" $NetBSD: random.3,v 1.20 2011/10/15 21:35:49 rmind Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)random.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd February 28, 2008
+.Dd October 15, 2011
.Dt RANDOM 3
.Os
.Sh NAME
.Xr srand 3 ,
.Xr rnd 4 ,
.Xr rnd 9
+.Sh STANDARDS
+The
+.Fn random ,
+.Fn srandom ,
+.Fn initstate
+and
+.Fn setstate
+functions conform to
+.St -p1003.1-2008 .
.Sh HISTORY
These
functions appeared in
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: remque.c,v 1.2 2005/07/06 17:17:15 drochner Exp $");
+__RCSID("$NetBSD: remque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
};
void
-remque(element)
- void *element;
+remque(void *element)
{
struct qelem *e = (struct qelem *) element;
-/* $NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $ */
+/* $NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $ */
/*-
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.14 2003/03/20 08:18:55 ache Exp $");
#else
-__RCSID("$NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $");
+__RCSID("$NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
#include <sys/types.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#define USE_INTL_CURRENCY 0x40 /* use international currency symbol */
#define IS_NEGATIVE 0x80 /* is argument value negative ? */
+#ifndef NBCHAR_MAX
+#define NBCHAR_MAX ((unsigned char)CHAR_MAX)
+#endif
+
/* internal macros */
#define PRINT(CH) do { \
if (dst >= s + maxsize) \
while (dst - tmpptr < width)
PRINT(' ');
} else {
- pad_size = dst-tmpptr;
+ _DIAGASSERT(__type_fit(int, dst - tmpptr));
+ pad_size = dst - tmpptr;
memmove(tmpptr + width-pad_size, tmpptr,
(size_t) pad_size);
memset(tmpptr, ' ', (size_t) width-pad_size);
/* Set defult values for unspecified information. */
if (*cs_precedes != 0)
*cs_precedes = 1;
- if (*sep_by_space == CHAR_MAX)
+ if ((unsigned char)*sep_by_space == NBCHAR_MAX)
*sep_by_space = 0;
- if (*sign_posn == CHAR_MAX)
+ if ((unsigned char)*sign_posn == NBCHAR_MAX)
*sign_posn = 0;
}
char cs_precedes, sep_by_space, sign_posn;
const char *signstr;
- int left_chars = 0;
+ size_t left_chars = 0;
__setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn, &signstr);
if (cs_precedes != 0)
left_chars += strlen(signstr);
}
- return (left_chars);
+ _DIAGASSERT(__type_fit(int, left_chars));
+ return (int)left_chars;
}
static int
int chars = 0;
- if (*grouping == CHAR_MAX || *grouping <= 0) /* no grouping ? */
+ if ((unsigned char)*grouping == NBCHAR_MAX || *grouping <= 0) /* no grouping ? */
return (0);
while (size > (int)*grouping) {
chars++;
size -= (int)*grouping++;
/* no more grouping ? */
- if (*grouping == CHAR_MAX)
+ if ((unsigned char)*grouping == NBCHAR_MAX)
break;
/* rest grouping with same value ? */
if (*grouping == 0) {
char *rslt;
char *avalue;
int avalue_size;
- char fmt[32];
size_t bufsize;
char *bufend;
left_prec += get_groups(left_prec, grouping);
/* convert to string */
- snprintf(fmt, sizeof(fmt), "%%%d.%df", left_prec + right_prec + 1,
- right_prec);
- avalue_size = asprintf(&avalue, fmt, value);
+ avalue_size = asprintf(&avalue, "%*.*f", left_prec + right_prec + 1,
+ right_prec, value);
if (avalue_size < 0)
return (NULL);
/* make sure that we've enough space for result string */
- bufsize = strlen(avalue)*2+1;
+ bufsize = avalue_size * 2 + 1;
rslt = malloc(bufsize);
if (rslt == NULL) {
free(avalue);
avalue_size -= (right_prec + 1);
}
+ /* XXX: Why not use %' instead? */
if ((*flags & NEED_GROUPING) &&
thousands_sep != '\0' && /* XXX: need investigation */
- *grouping != CHAR_MAX &&
+ (unsigned char)*grouping != NBCHAR_MAX &&
*grouping > 0) {
while (avalue_size > (int)*grouping) {
GRPCPY(*grouping);
grouping++;
/* no more grouping ? */
- if (*grouping == CHAR_MAX)
+ if ((unsigned char)*grouping == NBCHAR_MAX)
break;
/* rest grouping with same value ? */
-/* $NetBSD: strsuftoll.c,v 1.8 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $ */
/*-
* Copyright (c) 2001-2002,2004 The NetBSD Foundation, Inc.
* All rights reserved.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strsuftoll.c,v 1.8 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef _LIBC
result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf));
if (*errbuf != '\0')
- errx(1, "%s", errbuf);
- return (result);
+ errx(EXIT_FAILURE, "%s", errbuf);
+ return result;
}
/*
* rather than exiting with it.
*/
/* LONGLONG */
-long long
-strsuftollx(const char *desc, const char *val,
- long long min, long long max, char *ebuf, size_t ebuflen)
+static long long
+__strsuftollx(const char *desc, const char *val,
+ long long min, long long max, char *ebuf, size_t ebuflen, size_t depth)
{
long long num, t;
char *expr;
_DIAGASSERT(val != NULL);
_DIAGASSERT(ebuf != NULL);
- errno = 0;
- ebuf[0] = '\0';
+ if (depth > 16) {
+ snprintf(ebuf, ebuflen, "%s: Recursion limit exceeded", desc);
+ return 0;
+ }
while (isspace((unsigned char)*val)) /* Skip leading space */
val++;
+ errno = 0;
num = strtoll(val, &expr, 10);
if (errno == ERANGE)
goto erange; /* Overflow */
case '*': /* Backward compatible */
case 'x':
t = num;
- num *= strsuftollx(desc, expr + 1, min, max, ebuf, ebuflen);
+ num *= __strsuftollx(desc, expr + 1, min, max, ebuf, ebuflen,
+ depth + 1);
if (*ebuf != '\0')
- return (0);
+ return 0;
if (t > num) {
erange:
- snprintf(ebuf, ebuflen,
- "%s: %s", desc, strerror(ERANGE));
- return (0);
+ errno = ERANGE;
+ snprintf(ebuf, ebuflen, "%s: %s", desc, strerror(errno));
+ return 0;
}
break;
default:
- badnum: snprintf(ebuf, ebuflen,
- "%s `%s': illegal number", desc, val);
- return (0);
+ badnum:
+ snprintf(ebuf, ebuflen, "%s `%s': illegal number", desc, val);
+ return 0;
}
if (num < min) {
- /* LONGLONG */
+ /* LONGLONG */
snprintf(ebuf, ebuflen, "%s %lld is less than %lld.",
desc, (long long)num, (long long)min);
- return (0);
+ return 0;
}
if (num > max) {
- /* LONGLONG */
- snprintf(ebuf, ebuflen,
- "%s %lld is greater than %lld.",
+ /* LONGLONG */
+ snprintf(ebuf, ebuflen, "%s %lld is greater than %lld.",
desc, (long long)num, (long long)max);
- return (0);
+ return 0;
}
*ebuf = '\0';
- return (num);
+ return num;
}
+long long
+strsuftollx(const char *desc, const char *val,
+ long long min, long long max, char *ebuf, size_t ebuflen)
+{
+ return __strsuftollx(desc, val, min, max, ebuf, ebuflen, 0);
+}
#endif /* !HAVE_STRSUFTOLL */
-/* $NetBSD: system.c,v 1.23 2010/11/14 18:11:43 tron Exp $ */
+/* $NetBSD: system.c,v 1.24 2012/06/25 22:32:45 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: system.c,v 1.23 2010/11/14 18:11:43 tron Exp $");
+__RCSID("$NetBSD: system.c,v 1.24 2012/06/25 22:32:45 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
int
-system(command)
- const char *command;
+system(const char *command)
{
pid_t pid;
struct sigaction intsa, quitsa, sa;
-/* $NetBSD: tdelete.c,v 1.4 2006/03/19 01:12:08 christos Exp $ */
+/* $NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tdelete.c,v 1.4 2006/03/19 01:12:08 christos Exp $");
+__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <stdlib.h>
-/* delete node with given key */
+/* find a node with key "vkey" in tree "vrootp" */
void *
-tdelete(vkey, vrootp, compar)
- const void *vkey; /* key to be deleted */
- void **vrootp; /* address of the root of tree */
- int (*compar) __P((const void *, const void *));
+tdelete(const void *vkey, void **vrootp,
+ int (*compar)(const void *, const void *))
{
node_t **rootp = (node_t **)vrootp;
node_t *p, *q, *r;
-/* $NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $ */
+/* $NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $");
+__RCSID("$NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <stdlib.h>
#include <search.h>
-/* find a node, or return 0 */
+/* find a node by key "vkey" in tree "vrootp", or return 0 */
void *
-tfind(vkey, vrootp, compar)
- const void *vkey; /* key to be found */
- void * const *vrootp; /* address of the tree root */
- int (*compar) __P((const void *, const void *));
+tfind(const void *vkey, void * const *vrootp,
+ int (*compar)(const void *, const void *))
{
node_t * const *rootp = (node_t * const*)vrootp;
-/* $NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
/* find or insert datum into search tree */
void *
-tsearch(vkey, vrootp, compar)
- const void *vkey; /* key to be located */
- void **vrootp; /* address of tree root */
- int (*compar) __P((const void *, const void *));
+tsearch(const void *vkey, void **vrootp,
+ int (*compar)(const void *, const void *))
{
node_t *q;
node_t **rootp = (node_t **)vrootp;
-/* $NetBSD: twalk.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
+/* $NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: twalk.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+__RCSID("$NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <search.h>
#include <stdlib.h>
-static void trecurse __P((const node_t *,
- void (*action)(const void *, VISIT, int), int level));
+typedef void (*cmp_fn_t)(const void *, VISIT, int);
/* Walk the nodes of a tree */
static void
-trecurse(root, action, level)
- const node_t *root; /* Root of the tree to be walked */
- void (*action) __P((const void *, VISIT, int));
- int level;
+trecurse(const node_t *root, /* Root of the tree to be walked */
+ cmp_fn_t action, int level)
{
_DIAGASSERT(root != NULL);
_DIAGASSERT(action != NULL);
/* Walk the nodes of a tree */
void
-twalk(vroot, action)
- const void *vroot; /* Root of the tree to be walked */
- void (*action) __P((const void *, VISIT, int));
+twalk(const void *vroot, cmp_fn_t action) /* Root of the tree to be walked */
{
if (vroot != NULL && action != NULL)
trecurse(vroot, action, 0);
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $NetBSD: Makefile.inc,v 1.75 2009/07/30 20:57:15 dsl Exp $
+# $NetBSD: Makefile.inc,v 1.76 2012/08/30 12:16:48 drochner Exp $
# string sources
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
SRCS+= strcat.c strcmp.c strcpy.c strcspn.c strlen.c
SRCS+= strncat.c strncmp.c strncpy.c strpbrk.c strsep.c
SRCS+= strspn.c strstr.c swab.c
+SRCS+= explicit_bzero.c consttime_bcmp.c
SRCS+= memccpy.c memcpy.c memmem.c memmove.c
SRCS+= strchr.c strrchr.c
-/* $NetBSD: __strsignal.c,v 1.24 2003/08/07 16:43:46 agc Exp $ */
+/* $NetBSD: __strsignal.c,v 1.25 2012/03/20 17:44:18 matt Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
#if 0
static char *sccsid = "@(#)strerror.c 5.6 (Berkeley) 5/4/91";
#else
-__RCSID("$NetBSD: __strsignal.c,v 1.24 2003/08/07 16:43:46 agc Exp $");
+__RCSID("$NetBSD: __strsignal.c,v 1.25 2012/03/20 17:44:18 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/* ARGSUSED */
const char *
-__strsignal(num, buf, buflen)
- int num;
- char *buf;
- size_t buflen;
+__strsignal(int num, char *buf, size_t buflen)
{
#define UPREFIX "Unknown signal: %u"
#define RPREFIX "Real time signal %u"
.\" SUCH DAMAGE.
.\"
.\" from: @(#)bcmp.3 8.1 (Berkeley) 6/4/93
-.\" $NetBSD: bcmp.3,v 1.13 2010/04/29 06:54:26 jruoho Exp $
+.\" $NetBSD: bcmp.3,v 1.14 2012/05/05 21:24:19 dholland Exp $
.\"
-.Dd April 29, 2010
+.Dd May 5, 2012
.Dt BCMP 3
.Os
.Sh NAME
Zero-length strings are always identical.
.Pp
The strings may overlap.
+.Pp
+This function is obsolete.
+The equivalent function
+.Xr memcmp 3
+should be used instead.
.Sh SEE ALSO
.Xr memcmp 3 ,
.Xr strcasecmp 3 ,
.\" SUCH DAMAGE.
.\"
.\" from: @(#)bcopy.3 8.1 (Berkeley) 6/4/93
-.\" $NetBSD: bcopy.3,v 1.13 2010/04/29 07:27:30 wiz Exp $
+.\" $NetBSD: bcopy.3,v 1.14 2012/05/05 21:24:19 dholland Exp $
.\"
-.Dd April 29, 2010
+.Dd May 5, 2012
.Dt BCOPY 3
.Os
.Sh NAME
If
.Fa len
is zero, no bytes are copied.
+.Pp
+This function is obsolete.
+The functions
+.Xr memcpy 3
+and/or
+.Xr memmove 3
+should be used instead.
+Note that
+.Fn bcopy
+takes its
+.Fa src
+and
+.Fa dst
+arguments in the opposite order from these.
.Sh SEE ALSO
.Xr memccpy 3 ,
.Xr memcpy 3 ,
-/* $NetBSD: bm.c,v 1.11 2003/08/07 16:43:47 agc Exp $ */
+/* $NetBSD: bm.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1994
#if 0
static char sccsid[] = "@(#)bm.c 8.7 (Berkeley) 6/21/94";
#else
-__RCSID("$NetBSD: bm.c,v 1.11 2003/08/07 16:43:47 agc Exp $");
+__RCSID("$NetBSD: bm.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS && not lint */
};
bm_pat *
-bm_comp(pb, len, freq)
- u_char const *pb;
- size_t len;
- u_char const *freq;
+bm_comp(u_char const *pb, size_t len, u_char const *freq)
{
u_char const *pe, *p;
size_t *d, r;
}
void
-bm_free(pat)
- bm_pat *pat;
+bm_free(bm_pat *pat)
{
_DIAGASSERT(pat != NULL);
}
u_char *
-bm_exec(pat, base, n)
- bm_pat *pat;
- u_char *base;
- size_t n;
+bm_exec(bm_pat *pat, u_char *base, size_t n)
{
u_char *e, *ep, *p, *q, *s;
size_t *d0, k, md2, n1, ro;
.\" SUCH DAMAGE.
.\"
.\" from: @(#)index.3 8.1 (Berkeley) 6/4/93
-.\" $NetBSD: index.3,v 1.13 2010/04/29 06:54:26 jruoho Exp $
+.\" $NetBSD: index.3,v 1.15 2012/05/05 21:18:43 dholland Exp $
.\"
-.Dd April 29, 2010
+.Dd May 5, 2012
.Dt INDEX 3
.Os
.Sh NAME
.Em char )
in the nul-terminated string
.Fa s .
+.Pp
+This function is obsolete.
+The equivalent function
+.Xr strchr 3
+should be used instead.
.Sh RETURN VALUES
A pointer to the character is returned if it is found; otherwise
.Dv NULL
-/* $NetBSD: memccpy.c,v 1.12 2003/08/07 16:43:48 agc Exp $ */
+/* $NetBSD: memccpy.c,v 1.13 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)memccpy.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: memccpy.c,v 1.12 2003/08/07 16:43:48 agc Exp $");
+__RCSID("$NetBSD: memccpy.c,v 1.13 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <string.h>
void *
-memccpy(t, f, c, n)
- void *t;
- const void *f;
- int c;
- size_t n;
+memccpy(void *t, const void *f, int c, size_t n)
{
_DIAGASSERT(t != 0);
-.\" $NetBSD: popcount.3,v 1.4 2009/07/22 07:07:27 wiz Exp $
+.\" $NetBSD: popcount.3,v 1.5 2011/08/22 01:36:04 dholland Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 13, 2009
+.Dd August 22, 2011
.Dt POPCOUNT 3
.Os
.Sh NAME
.Fn popcountl "unsigned long value"
.Ft unsigned int
.Fn popcountll "unsigned long long value"
+.In stdint.h
.Ft unsigned int
.Fn popcount32 "uint32_t value"
.Ft unsigned int
.\" SUCH DAMAGE.
.\"
.\" from: @(#)rindex.3 8.1 (Berkeley) 6/4/93
-.\" $NetBSD: rindex.3,v 1.12 2010/04/29 06:54:26 jruoho Exp $
+.\" $NetBSD: rindex.3,v 1.14 2012/05/05 21:18:43 dholland Exp $
.\"
-.Dd April 29, 2010
+.Dd May 5, 2012
.Dt RINDEX 3
.Os
.Sh NAME
.Em char )
in the nul-terminated string
.Fa s .
+.Pp
+This function is obsolete.
+The equivalent function
+.Xr strrchr 3
+should be used instead.
.Sh RETURN VALUES
A pointer to the character is returned if it is found; otherwise
.Dv NULL
-/* $NetBSD: strcoll.c,v 1.9 2003/08/07 16:43:50 agc Exp $ */
+/* $NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)strcoll.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strcoll.c,v 1.9 2003/08/07 16:43:50 agc Exp $");
+__RCSID("$NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Compare strings according to LC_COLLATE category of current locale.
*/
int
-strcoll(s1, s2)
- const char *s1, *s2;
+strcoll(const char *s1, const char *s2)
{
_DIAGASSERT(s1 != NULL);
-/* $NetBSD: strcspn.c,v 1.17 2009/07/30 21:42:06 dsl Exp $ */
+/* $NetBSD: strcspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strcspn.c,v 1.17 2009/07/30 21:42:06 dsl Exp $");
+__RCSID("$NetBSD: strcspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $");
#include <assert.h>
#include <inttypes.h>
size_t
strcspn(const char *s, const char *charset)
{
- static const size_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+ static const uint8_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
const char *t;
uint8_t set[32];
#define UC(a) ((unsigned int)(unsigned char)(a))
-/* $NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp $ */
+/* $NetBSD: strdup.c,v 1.14 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp $");
+__RCSID("$NetBSD: strdup.c,v 1.14 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
char *
-strdup(str)
- const char *str;
+strdup(const char *str)
{
size_t len;
char *copy;
-/* $NetBSD: strmode.c,v 1.18 2006/10/07 22:04:18 apb Exp $ */
+/* $NetBSD: strmode.c,v 1.19 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)strmode.c 8.3 (Berkeley) 8/15/94";
#else
-__RCSID("$NetBSD: strmode.c,v 1.18 2006/10/07 22:04:18 apb Exp $");
+__RCSID("$NetBSD: strmode.c,v 1.19 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* $NetBSD: strncat.c,v 1.11 2007/06/03 17:39:27 christos Exp $ */
+/* $NetBSD: strncat.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)strncat.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strncat.c,v 1.11 2007/06/03 17:39:27 christos Exp $");
+__RCSID("$NetBSD: strncat.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* are written at dst (at most n+1 bytes being appended). Return dst.
*/
char *
-strncat(dst, src, n)
- char *dst;
- const char *src;
- size_t n;
+strncat(char *dst, const char *src, size_t n)
{
_DIAGASSERT(dst != NULL);
-/* $NetBSD: strpbrk.c,v 1.19 2008/09/24 16:58:53 christos Exp $ */
+/* $NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strpbrk.c,v 1.19 2008/09/24 16:58:53 christos Exp $");
+__RCSID("$NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $");
#include <assert.h>
#include <inttypes.h>
_DIAGASSERT(s != NULL);
_DIAGASSERT(charset != NULL);
+ if (charset[0] == '\0')
+ return NULL;
+ if (charset[1] == '\0')
+ return strchr(s, charset[0]);
+
for (; *charset != '\0'; ++charset)
ADD_TO_SET(UC(*charset));
-/* $NetBSD: strsignal.c,v 1.14 2009/07/22 19:48:27 kleink Exp $ */
+/* $NetBSD: strsignal.c,v 1.15 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
#if 0
static char *sccsid = "@(#)strerror.c 5.6 (Berkeley) 5/4/91";
#else
-__RCSID("$NetBSD: strsignal.c,v 1.14 2009/07/22 19:48:27 kleink Exp $");
+__RCSID("$NetBSD: strsignal.c,v 1.15 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
__aconst char *
-strsignal(sig)
- int sig;
+strsignal(int sig)
{
static char buf[NL_TEXTMAX];
-/* $NetBSD: strspn.c,v 1.17 2009/07/30 21:42:06 dsl Exp $ */
+/* $NetBSD: strspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strspn.c,v 1.17 2009/07/30 21:42:06 dsl Exp $");
+__RCSID("$NetBSD: strspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $");
#include <assert.h>
#include <inttypes.h>
size_t
strspn(const char *s, const char *charset)
{
- static const size_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+ static const uint8_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
uint8_t set[32];
const char *t;
#define UC(a) ((unsigned int)(unsigned char)(a))
-/* $NetBSD: strtok_r.c,v 1.9 2003/08/07 16:43:53 agc Exp $ */
+/* $NetBSD: strtok_r.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
#if 0
static char *sccsid = "@(#)strtok.c 5.8 (Berkeley) 2/24/91";
#else
-__RCSID("$NetBSD: strtok_r.c,v 1.9 2003/08/07 16:43:53 agc Exp $");
+__RCSID("$NetBSD: strtok_r.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
char *
-strtok_r(s, delim, lasts)
- char *s;
- const char *delim;
- char **lasts;
+strtok_r(char *s, const char *delim, char **lasts)
{
const char *spanp;
int c, sc;
-/* $NetBSD: strxfrm.c,v 1.11 2003/08/07 16:43:53 agc Exp $ */
+/* $NetBSD: strxfrm.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)strxfrm.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: strxfrm.c,v 1.11 2003/08/07 16:43:53 agc Exp $");
+__RCSID("$NetBSD: strxfrm.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* on the original untransformed strings would return.
*/
size_t
-strxfrm(dst, src, n)
- char *dst;
- const char *src;
- size_t n;
+strxfrm(char *dst, const char *src, size_t n)
{
size_t srclen, copysize;
-/* $NetBSD: wcscat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
+/* $NetBSD: wcscat.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcscat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $");
+__RCSID("$NetBSD: wcscat.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcscat(s1, s2)
- wchar_t *s1;
- const wchar_t *s2;
+wcscat(wchar_t *s1, const wchar_t *s2)
{
wchar_t *p;
wchar_t *q;
-/* $NetBSD: wcscmp.c,v 1.8 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: wcscmp.c,v 1.9 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
#if 0
static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wcscmp.c,v 1.8 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: wcscmp.c,v 1.9 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* Compare strings.
*/
int
-wcscmp(s1, s2)
- const wchar_t *s1, *s2;
+wcscmp(const wchar_t *s1, const wchar_t *s2)
{
_DIAGASSERT(s1 != NULL);
-/* $NetBSD: wcscpy.c,v 1.3 2005/10/13 21:13:05 tnozaki Exp $ */
+/* $NetBSD: wcscpy.c,v 1.4 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcscpy.c,v 1.3 2005/10/13 21:13:05 tnozaki Exp $");
+__RCSID("$NetBSD: wcscpy.c,v 1.4 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcscpy(s1, s2)
- wchar_t *s1;
- const wchar_t *s2;
+wcscpy(wchar_t *s1, const wchar_t *s2)
{
wchar_t *p;
-/* $NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
+/* $NetBSD: wcscspn.c,v 1.4 2011/11/24 18:44:25 joerg Exp $ */
/*-
- * Copyright (c)1999 Citrus Project,
+ * Copyright (c) 1999 Citrus Project,
+ * Copyright (c) 2011 Joerg Sonnenberger,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $");
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: wcscspn.c,v 1.4 2011/11/24 18:44:25 joerg Exp $");
#include <assert.h>
+#include <inttypes.h>
+#include <string.h>
#include <wchar.h>
+#include "wcscspn_bloom.h"
+
size_t
-wcscspn(s, set)
- const wchar_t *s;
- const wchar_t *set;
+wcscspn(const wchar_t *s, const wchar_t *set)
{
+ size_t bloom[BLOOM_ARRAY_SIZE];
const wchar_t *p;
const wchar_t *q;
_DIAGASSERT(s != NULL);
_DIAGASSERT(set != NULL);
- p = s;
- while (*p) {
+ if (set[0] == '\0')
+ return wcslen(s);
+ if (set[1] == '\0') {
+ for (p = s; *p; ++p)
+ if (*p == set[0])
+ break;
+ return p - s;
+ }
+
+ wcsspn_bloom_init(bloom, set);
+
+ for (p = s; *p; ++p) {
+ if (!wcsspn_in_bloom(bloom, *p))
+ continue;
+
q = set;
- while (*q) {
+ do {
if (*p == *q)
goto done;
- q++;
- }
- p++;
+ } while (*++q);
}
done:
--- /dev/null
+/* $NetBSD: wcscspn_bloom.h,v 1.4 2011/11/25 17:48:22 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 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.
+ */
+
+/*
+ * Bloom filter for fast test if a given character is part of the reject set.
+ * The test may have false positives, but doesn't have false negatives.
+ * The first hash function is designed to be very fast to evaluate.
+ * It is collision free if the input is part of the same European language
+ * and shouldn't be too bad even other input. The second hash function
+ * tries to provide a much better mixing, but involves the slower
+ * multiplication.
+ */
+
+#include <limits.h>
+
+#define BLOOM_SIZE 64
+#define BLOOM_ARRAY_SIZE (BLOOM_SIZE / sizeof(size_t))
+#define BLOOM_BITS (BLOOM_SIZE * CHAR_BIT)
+#define BLOOM_DIV (sizeof(size_t) * CHAR_BIT)
+
+static inline size_t
+wcscspn_bloom1(size_t x)
+{
+ return x % BLOOM_BITS;
+}
+
+static inline size_t
+wcscspn_bloom2(size_t x)
+{
+ return (size_t)((uint32_t)(x * 2654435761U) /
+ (0x100000000ULL / BLOOM_BITS));
+}
+
+static inline void
+wcsspn_bloom_init(size_t *bloom, const wchar_t *charset)
+{
+ size_t val;
+
+ memset(bloom, 0, BLOOM_SIZE);
+ do {
+ val = wcscspn_bloom1((size_t)*charset);
+ bloom[val / BLOOM_DIV] |= (size_t)1 << (val % BLOOM_DIV);
+ val = wcscspn_bloom2((size_t)*charset);
+ bloom[val / BLOOM_DIV] |= (size_t)1 << (val % BLOOM_DIV);
+ }
+ while (*++charset);
+}
+
+static inline int
+wcsspn_in_bloom(const size_t *bloom, wchar_t ch)
+{
+ size_t val;
+
+ val = wcscspn_bloom1((size_t)ch);
+ if (bloom[val / BLOOM_DIV] & ((size_t)1 << (val % BLOOM_DIV)))
+ return 1;
+ val = wcscspn_bloom2((size_t)ch);
+ if (bloom[val / BLOOM_DIV] & ((size_t)1 << (val % BLOOM_DIV)))
+ return 1;
+ return 0;
+}
-/* $NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
+/* $NetBSD: wcslcat.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */
/*
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $");
+__RCSID("$NetBSD: wcslcat.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
* truncation occurred.
*/
size_t
-wcslcat(dst, src, siz)
- wchar_t *dst;
- const wchar_t *src;
- size_t siz;
+wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
{
wchar_t *d = dst;
const wchar_t *s = src;
-/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
+/* $NetBSD: wcslcpy.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/*
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $");
+__RCSID("$NetBSD: wcslcpy.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
* Returns wcslen(src); if retval >= siz, truncation occurred.
*/
size_t
-wcslcpy(dst, src, siz)
- wchar_t *dst;
- const wchar_t *src;
- size_t siz;
+wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
{
wchar_t *d = dst;
const wchar_t *s = src;
-/* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
+/* $NetBSD: wcslen.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $");
+__RCSID("$NetBSD: wcslen.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
size_t
-wcslen(s)
- const wchar_t *s;
+wcslen(const wchar_t *s)
{
const wchar_t *p;
-/* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
+/* $NetBSD: wcsncat.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $");
+__RCSID("$NetBSD: wcsncat.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcsncat(s1, s2, n)
- wchar_t *s1;
- const wchar_t *s2;
- size_t n;
+wcsncat(wchar_t *s1, const wchar_t *s2, size_t n)
{
wchar_t *p;
wchar_t *q;
-/* $NetBSD: wcsncmp.c,v 1.8 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: wcsncmp.c,v 1.9 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: wcsncmp.c,v 1.8 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: wcsncmp.c,v 1.9 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "runetype_local.h"
int
-wcsncmp(s1, s2, n)
- const wchar_t *s1, *s2;
- size_t n;
+wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
{
_DIAGASSERT(s1 != NULL);
-/* $NetBSD: wcsncpy.c,v 1.3 2005/10/13 21:13:05 tnozaki Exp $ */
+/* $NetBSD: wcsncpy.c,v 1.4 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsncpy.c,v 1.3 2005/10/13 21:13:05 tnozaki Exp $");
+__RCSID("$NetBSD: wcsncpy.c,v 1.4 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcsncpy(s1, s2, n)
- wchar_t *s1;
- const wchar_t *s2;
- size_t n;
+wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n)
{
wchar_t *p;
-/* $NetBSD: wcspbrk.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: wcspbrk.c,v 1.5 2011/11/24 18:44:25 joerg Exp $ */
/*-
- * Copyright (c)1999 Citrus Project,
+ * Copyright (c) 1999 Citrus Project,
+ * Copyright (c) 2011 Joerg Sonnenberger,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcspbrk.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: wcspbrk.c,v 1.5 2011/11/24 18:44:25 joerg Exp $");
#include <assert.h>
+#include <inttypes.h>
+#include <string.h>
#include <wchar.h>
+#include "wcscspn_bloom.h"
+
wchar_t *
-wcspbrk(s, set)
- const wchar_t *s;
- const wchar_t *set;
+wcspbrk(const wchar_t *s, const wchar_t *set)
{
+ size_t bloom[BLOOM_ARRAY_SIZE];
const wchar_t *p;
const wchar_t *q;
_DIAGASSERT(s != NULL);
_DIAGASSERT(set != NULL);
- p = s;
- while (*p) {
+ if (set[0] == '\0')
+ return NULL;
+ if (set[1] == '\0')
+ return wcschr(s, set[0]);
+
+ wcsspn_bloom_init(bloom, set);
+
+ for (p = s; *p; ++p) {
+ if (!wcsspn_in_bloom(bloom, *p))
+ continue;
+
q = set;
- while (*q) {
+ do {
if (*p == *q)
return __UNCONST(p);
- q++;
- }
- p++;
+ } while (*++q);
}
return NULL;
}
-/* $NetBSD: wcsrchr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: wcsrchr.c,v 1.4 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsrchr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: wcsrchr.c,v 1.4 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcsrchr(s, c)
- const wchar_t *s;
- wchar_t c;
+wcsrchr(const wchar_t *s, wchar_t c)
{
const wchar_t *p;
-/* $NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $ */
+/* $NetBSD: wcsspn.c,v 1.4 2011/11/21 15:02:48 joerg Exp $ */
/*-
* Copyright (c)1999,2001 Citrus Project,
*/
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $");
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: wcsspn.c,v 1.4 2011/11/21 15:02:48 joerg Exp $");
#include <assert.h>
#include <wchar.h>
size_t
-wcsspn(s, set)
- const wchar_t *s;
- const wchar_t *set;
+wcsspn(const wchar_t *s, const wchar_t *set)
{
const wchar_t *p;
const wchar_t *q;
_DIAGASSERT(s != NULL);
_DIAGASSERT(set != NULL);
- p = s;
- while (*p) {
- q = set;
- while (*q) {
+ for (p = s; *p; ++p) {
+ for (q = set; *q; ++q) {
if (*p == *q)
break;
- q++;
}
if (!*q)
- goto done;
- p++;
+ break;
}
-done:
return (p - s);
}
-/* $NetBSD: wcsstr.c,v 1.4 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: wcsstr.c,v 1.5 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsstr.c,v 1.4 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: wcsstr.c,v 1.5 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
wchar_t *
#ifdef WCSWCS
-wcswcs(big, little)
+wcswcs(const wchar_t *big, const wchar_t *little)
#else
-wcsstr(big, little)
+wcsstr(const wchar_t *big, const wchar_t *little)
#endif
- const wchar_t *big;
- const wchar_t *little;
{
const wchar_t *p;
const wchar_t *q;
-/* $NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $ */
+/* $NetBSD: wcstok.c,v 1.4 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1998 Softweyr LLC. All rights reserved.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $");
+__RCSID("$NetBSD: wcstok.c,v 1.4 2012/06/25 22:32:46 abs Exp $");
#endif
#include <assert.h>
#include <wchar.h>
wchar_t *
-wcstok(s, delim, last)
- wchar_t * __restrict s;
- const wchar_t * __restrict delim;
- wchar_t ** __restrict last;
+wcstok(wchar_t * __restrict s, const wchar_t * __restrict delim,
+ wchar_t ** __restrict last)
{
const wchar_t *spanp;
wchar_t c, sc;
-/* $NetBSD: wmemchr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: wmemchr.c,v 1.4 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemchr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: wmemchr.c,v 1.4 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wmemchr(s, c, n)
- const wchar_t *s;
- wchar_t c;
- size_t n;
+wmemchr(const wchar_t *s, wchar_t c, size_t n)
{
size_t i;
-/* $NetBSD: wmemcmp.c,v 1.6 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: wmemcmp.c,v 1.7 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemcmp.c,v 1.6 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: wmemcmp.c,v 1.7 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include "runetype_local.h"
int
-wmemcmp(s1, s2, n)
- const wchar_t *s1;
- const wchar_t *s2;
- size_t n;
+wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
{
size_t i;
-/* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
+/* $NetBSD: wmemcpy.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $");
+__RCSID("$NetBSD: wmemcpy.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wmemcpy(d, s, n)
- wchar_t *d;
- const wchar_t *s;
- size_t n;
+wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
{
_DIAGASSERT(d != NULL);
-/* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
+/* $NetBSD: wmemmove.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $");
+__RCSID("$NetBSD: wmemmove.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wmemmove(d, s, n)
- wchar_t *d;
- const wchar_t *s;
- size_t n;
+wmemmove(wchar_t *d, const wchar_t *s, size_t n)
{
_DIAGASSERT(d != NULL);
-/* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
+/* $NetBSD: wmemset.c,v 1.3 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $");
+__RCSID("$NetBSD: wmemset.c,v 1.3 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <wchar.h>
wchar_t *
-wmemset(s, c, n)
- wchar_t *s;
- wchar_t c;
- size_t n;
+wmemset(wchar_t *s, wchar_t c, size_t n)
{
size_t i;
wchar_t *p;
*/
rslabel = find_rslabel(args);
if (rslabel != NULL){
- snprintf(label,16,rslabel);
+ snprintf(label,16,"%s",rslabel);
free(rslabel);
} else {
if (stat(name, &statbuf) < 0) return -1;
return r;
}
-char *find_rslabel(args_line)
-char *args_line;
+char *find_rslabel(char *args_line)
{
/**
* Find and return the rslabel as given as optional
new->st_ctimespec.tv_sec = prev->st_ctime;
}
+int _stat(const char *name, struct stat *buffer);
+int _lstat(const char *name, struct stat *buffer);
+int _fstat(int fd, struct stat *buffer);
+
__weak_alias(_stat, __stat50);
__weak_alias(_lstat, __lstat50);
__weak_alias(_fstat, __fstat50);
__weak_alias(stime, _stime)
#endif
-int stime(long *top)
+int stime(time_t *top)
{
message m;
- m.m2_l1 = *top;
+ m.m2_l1 = (long)*top;
return(_syscall(PM_PROC_NR, STIME, &m));
}
-/* $NetBSD: Lint___vfork14.c,v 1.2 2000/06/14 06:49:10 cgd Exp $ */
+/* $NetBSD: Lint___vfork14.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */
/*
* This file placed in the public domain.
/*ARGSUSED*/
pid_t
-__vfork14()
+__vfork14(void)
{
return (0);
}
-# $NetBSD: Makefile.inc,v 1.204 2011/01/10 04:41:27 christos Exp $
+# $NetBSD: Makefile.inc,v 1.217 2012/10/02 01:46:40 christos Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
# sys sources
# modules with default implementations on all architectures:
ASM= access.S acct.S \
bind.S \
- chdir.S chflags.S chmod.S chown.S chroot.S __clock_getres50.S \
- __clock_gettime50.S \
- dup.S dup2.S \
+ chdir.S chflags.S chmod.S chown.S chroot.S clock_nanosleep.S \
+ __clock_getres50.S __clock_gettime50.S \
+ dup.S dup2.S dup3.S \
extattrctl.S \
extattr_delete_fd.S extattr_delete_file.S \
extattr_delete_link.S extattr_get_fd.S extattr_get_file.S \
extattr_get_link.S extattr_list_fd.S extattr_list_file.S \
extattr_list_link.S extattr_set_fd.S extattr_set_file.S \
extattr_set_link.S \
- fchdir.S fchflags.S fchmod.S fchown.S fchroot.S \
- __fhopen40.S __fhstat50.S __fhstatvfs140.S fktrace.S \
- flock.S fpathconf.S __fstat50.S fstatvfs1.S __futimes50.S \
+ setxattr.S getxattr.S listxattr.S removexattr.S \
+ lsetxattr.S lgetxattr.S llistxattr.S lremovexattr.S \
+ fsetxattr.S fgetxattr.S flistxattr.S fremovexattr.S \
+ faccessat.S fchdir.S fchflags.S fchmod.S fchmodat.S fchown.S \
+ fchownat.S fchroot.S fexecve.S __fhopen40.S __fhstat50.S \
+ __fhstatvfs140.S fktrace.S flock.S fpathconf.S __fstat50.S \
+ fstatvfs1.S fstatat.S __futimes50.S futimens.S \
__getcwd.S __getdents30.S __getfh30.S getvfsstat.S getgroups.S\
__getitimer50.S __getlogin.S getpeername.S getpgid.S getpgrp.S \
getpriority.S getrlimit.S __getrusage50.S getsid.S \
getsockname.S getsockopt.S __gettimeofday50.S \
ioctl.S \
- kqueue.S ktrace.S \
+ kqueue.S kqueue1.S ktrace.S \
_ksem_close.S _ksem_destroy.S _ksem_getvalue.S _ksem_init.S \
- _ksem_post.S _ksem_trywait.S _ksem_unlink.S _ksem_wait.S \
- _ksem_open.S \
+ _ksem_post.S _ksem_timedwait.S _ksem_trywait.S _ksem_unlink.S \
+ _ksem_wait.S _ksem_open.S \
lchflags.S lchmod.S lchown.S lfs_bmapv.S lfs_markv.S lfs_segclean.S \
- __lfs_segwait50.S link.S listen.S __lstat50.S __lutimes50.S \
- _lwp_create.S _lwp_exit.S _lwp_kill.S ___lwp_park50.S \
- _lwp_self.S _lwp_wait.S _lwp_unpark.S _lwp_unpark_all.S \
- _lwp_suspend.S _lwp_continue.S _lwp_wakeup.S _lwp_detach.S \
- _lwp_setprivate.S \
+ __lfs_segwait50.S link.S linkat.S listen.S __lstat50.S \
+ __lutimes50.S _lwp_create.S _lwp_exit.S _lwp_kill.S \
+ ___lwp_park50.S _lwp_self.S _lwp_wait.S _lwp_unpark.S \
+ _lwp_unpark_all.S _lwp_suspend.S _lwp_continue.S \
+ _lwp_wakeup.S _lwp_detach.S _lwp_setprivate.S \
_lwp_setname.S _lwp_getname.S _lwp_ctl.S \
- madvise.S mincore.S minherit.S mkdir.S mkfifo.S __mknod50.S \
- mlock.S mlockall.S modctl.S __mount50.S mprotect.S \
- __msgctl50.S msgget.S munlock.S munlockall.S munmap.S \
+ madvise.S mincore.S minherit.S mkdir.S mkdirat.S mkfifo.S mkfifoat.S \
+ __mknod50.S mknodat.S mlock.S mlockall.S modctl.S __mount50.S \
+ mprotect.S __msgctl50.S msgget.S munlock.S munlockall.S \
+ munmap.S \
nfssvc.S __ntp_gettime50.S \
- pathconf.S pmc_get_info.S pmc_control.S __posix_chown.S \
- __posix_fchown.S __posix_lchown.S __posix_rename.S profil.S \
- quotactl.S \
- rasctl.S reboot.S recvfrom.S recvmsg.S rename.S revoke.S \
- rmdir.S \
- sa_register.S sa_stacks.S sa_enable.S sa_setconcurrency.S sa_yield.S \
- sa_preempt.S semconfig.S semget.S semop.S \
- sendmsg.S sendto.S setegid.S setcontext.S seteuid.S setgid.S \
- setgroups.S __setitimer50.S __setlogin.S setpgid.S \
+ openat.S \
+ paccept.S pathconf.S pipe2.S pmc_get_info.S pmc_control.S \
+ __posix_chown.S __posix_fchown.S __posix_lchown.S \
+ __posix_rename.S profil.S \
+ __quotactl.S \
+ rasctl.S readlinkat.S reboot.S recvfrom.S recvmmsg.S recvmsg.S rename.S \
+ renameat.S revoke.S rmdir.S \
+ semconfig.S semget.S semop.S \
+ sendmmsg.S sendmsg.S sendto.S setegid.S seteuid.S \
+ setgid.S setgroups.S __setitimer50.S __setlogin.S setpgid.S \
setpriority.S \
setregid.S setreuid.S setrlimit.S setsid.S setsockopt.S \
setuid.S __shmctl50.S shmdt.S shmget.S shutdown.S \
sigqueueinfo.S \
__sigaltstack14.S __sigpending14.S __sigaction_sigtramp.S \
____sigtimedwait50.S __socket30.S socketpair.S __stat50.S \
- statvfs1.S swapctl.S symlink.S __sysctl.S \
+ statvfs1.S swapctl.S symlink.S symlinkat.S __sysctl.S \
timer_create.S timer_delete.S __timer_gettime50.S timer_getoverrun.S \
____semctl50.S __timer_settime50.S \
- umask.S undelete.S unlink.S unmount.S __utimes50.S utrace.S uuidgen.S \
- vadvise.S
+ umask.S undelete.S unlink.S unlinkat.S unmount.S __utimes50.S \
+ utimensat.S utrace.S uuidgen.S vadvise.S
+
+# sa compat syscalls
+SAASM+= sa_register.S sa_stacks.S sa_enable.S sa_setconcurrency.S sa_yield.S \
+ sa_preempt.S
# modules with potentially non default implementations
ASM_MD= _lwp_getprivate.S mremap.S
__pollts50.S __pselect50.S read.S readlink.S \
readv.S _sched_setparam.S _sched_getparam.S _sched_setaffinity.S \
_sched_getaffinity.S sched_yield.S \
- __select50.S __sigprocmask14.S __sigsuspend14.S sysarch.S \
+ __select50.S setcontext.S __sigprocmask14.S __sigsuspend14.S sysarch.S \
__wait450.S write.S writev.S
NOERR= getegid.S geteuid.S getgid.S getpid.S getppid.S getuid.S \
- issetugid.S sync.S __posix_fadvise50.S
+ issetugid.S posix_spawn.S sync.S __posix_fadvise50.S
PSEUDONOERR= _exit.S
${_MKTARGET_CREATE}
printf '#include "SYS.h"\nWSYSCALL(${.PREFIX},_sys_${.PREFIX})\nWEAK_ALIAS(_${.PREFIX},_sys_${.PREFIX})\n' >${.TARGET}
+${SAASM}: ${ASMDEPS}
+ ${_MKTARGET_CREATE}
+ printf '#include "SYS.h"\n_SYSCALL(${.PREFIX:S/tmp_//},${.PREFIX:S/tmp_//:S/sa_/compat_60_sa_/})\n' >${.TARGET}
+
${NOERR}: ${ASMDEPS}
${_MKTARGET_CREATE}
printf '#include "SYS.h"\nRSYSCALL_NOERROR(${.PREFIX})\n' >${.TARGET}
mount.2 \
mprotect.2 mremap.2 msgctl.2 msgget.2 msgrcv.2 msgsnd.2 msync.2 \
munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 pathconf.2 pipe.2 \
- pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 quotactl.2 \
+ pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 __quotactl.2 \
rasctl.2 read.2 readlink.2 \
reboot.2 recv.2 rename.2 revoke.2 rmdir.2 \
select.2 semctl.2 \
MLINKS+=brk.2 sbrk.2
MLINKS+=clone.2 __clone.2
MLINKS+=dup.2 dup2.2
+MLINKS+=dup.2 dup3.2
MLINKS+=chdir.2 fchdir.2
MLINKS+=chflags.2 fchflags.2 chflags.2 lchflags.2
MLINKS+=chmod.2 fchmod.2 chmod.2 lchmod.2
MLINKS+=kqueue.2 kevent.2
MLINKS+=ktrace.2 fktrace.2
MLINKS+=lseek.2 seek.2
+MLINKS+=link.2 linkat.2
MLINKS+=_lwp_suspend.2 _lwp_continue.2
MLINKS+=_lwp_getprivate.2 _lwp_setprivate.2
MLINKS+=madvise.2 posix_madvise.2
MLINKS+=pmc_control.2 pmc_get_info.2
MLINKS+=poll.2 pollts.2
MLINKS+=read.2 readv.2 read.2 pread.2 read.2 preadv.2
-MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2
+MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2 recv.2 recvmmsg.2
MLINKS+=select.2 pselect.2
-MLINKS+=send.2 sendmsg.2 send.2 sendto.2
+MLINKS+=send.2 sendmsg.2 send.2 sendto.2 send.2 sendmmsg.2
MLINKS+=setpgid.2 setpgrp.2
MLINKS+=setuid.2 setegid.2 setuid.2 seteuid.2 setuid.2 setgid.2
MLINKS+=shmat.2 shmdt.2
MLINKS+=syscall.2 __syscall.2
MLINKS+=truncate.2 ftruncate.2
MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2
+MLINKS+=utimes.2 futimens.2 utimes.2 utimensat.2
MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2
MLINKS+=write.2 writev.2 write.2 pwrite.2 write.2 pwritev.2
+MLINKS+=pipe.2 pipe2.2
+MLINKS+=accept.2 paccept.2
+MLINKS+=nanosleep.2 clock_nanosleep.2
--- /dev/null
+.\" $NetBSD: __quotactl.2,v 1.3 2012/02/13 19:50:15 dholland Exp $
+.\"
+.\" Copyright (c) 1983, 1990, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Robert Elz at The University of Melbourne.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)quotactl.2 8.2 (Berkeley) 3/10/95
+.\"
+.Dd February 11, 2012
+.Dt __QUOTACTL 2
+.Os
+.Sh NAME
+.Nm __quotactl
+.Nd manipulate file system quotas
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/quota.h
+.In sys/quotactl.h
+.Ft int
+.Fn __quotactl "const char *path" "struct quotactl_args *args"
+.Sh DESCRIPTION
+The
+.Fn __quotactl
+call manipulates file system quotas.
+This is an internal interface and is documented for reference purposes
+only.
+All application and utility code should use the
+.Xr libquota 3
+interface.
+.Pp
+The
+.Fn __quotactl
+function performs one of several quota-related operations on the file
+system named by
+.Fa path .
+The operation and arguments to that operation are passed in the
+.Fa args
+argument.
+The operation is stored in the
+.Fa qc_op
+member of
+.Fa args .
+The arguments are placed in a union such that the first and second
+arguments of the operation
+.Dv QUOTACTL_EXAMPLE
+are found as the members
+.Fa u.example.qc_arg1
+and
+.Fa u.example.qc_arg2 .
+The descriptions below will refer to the operations as functions of
+the form
+.Fn QUOTACTL_EXAMPLE "int arg1" "int arg2"
+and elide the encoding of these arguments into the
+.Fa args
+structure.
+Explicit mention of the
+.Fa path
+argument is also omitted.
+.Pp
+There are fourteen quota control operations.
+These are:
+.Bl -tag -width abcdef
+.\" ************************************************************
+.It Fn QUOTACTL_STAT "struct quotastat *info"
+Information about the quota implementation on the selected volume is
+returned in
+.Fa info .
+The
+.Dv quotastat
+structure contains the following members:
+.Bl -tag -width qs_restrictions
+.It qs_implname
+A human-readable string describing the underlying implementation of
+quotas.
+This is suitable for display to users
+.Pq and system administrators
+but should not be interpreted by software.
+See
+.Xr quota_getimplname 3 .
+.It qs_numidtypes
+The number of ID types supported by this implementation.
+See
+.Xr quota_getnumidtypes 3 .
+.It qs_numobjtypes
+The number of object types supported by this implementation.
+See
+.Xr quota_getnumobjtypes 3 .
+.It qs_restrictions
+Flags identifying specific semantic limitations of the implementation.
+See
+.Xr quota_getrestrictions 3 .
+.El
+.\" ************************************************************
+.It Fn QUOTACTL_IDTYPESTAT "int idtype" "struct quotaidtypestat *info"
+Information about a particular ID type on the selected volume is
+returned in
+.Fa info .
+The
+.Dv quotaidtypestat
+structure contains the following members:
+.Bl -tag -width qs_restrictions
+.It qis_name
+The name of the ID type.
+See
+.Xr quota_idtype_getname 3 .
+.El
+.\" ************************************************************
+.It Fn QUOTACTL_OBJYPESTAT "int objtype" "struct quotaobjtypestat *info"
+Information about a particular object type on the selected volume is
+returned in
+.Fa info .
+The
+.Dv quotaobjtypestat
+structure contains the following members:
+.Bl -tag -width qs_restrictions
+.It qos_name
+The name of the object type.
+See
+.Xr quota_objtype_getname 3 .
+.It qos_isbytes
+A flag that is nonzero if the object type is something measured in
+bytes.
+See
+.Xr quota_objtype_isbytes 3 .
+.El
+.\" ************************************************************
+.It Fn QUOTACTL_GET "const struct quotakey *key" "struct quotaval *val"
+Return in
+.Fa val
+the quota information selected by
+.Fa key .
+See
+.Xr quota_get 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_PUT "const struct quotakey *key" "const struct quotaval *val"
+The quota information selected by
+.Fa key
+is updated to the values provided in
+.Fa val .
+Note that the current usage information, which is file system
+meta-data, cannot be updated via this interface.
+If the usage information is incorrect a tool such as
+.Xr fsck 8
+or
+.Xr quotacheck 8
+with file-system-specific knowledge must be used to repair the
+on-disk information.
+See
+.Xr quota_put 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_DELETE "const struct quotakey *key"
+The quota information selected by
+.Fa key
+is removed.
+See
+.Xr quota_delete 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSOROPEN "struct quotakcursor *cursor"
+A cursor for iterating the quota information is created.
+The
+.Dv quotakcursor
+structure is a semi-opaque type holding the iteration state used by
+the quota implementation.
+The caller is responsible for allocating and maintaining storage for
+the cursor.
+Every cursor that is opened should be closed.
+It is not specified whether a cursor remains valid if
+.Xr memcpy 3
+is used to move it to a different location in user memory.
+It is not specified whether or how a cursor may be duplicated.
+Passing an uninitialized, corrupted, or closed cursor to operations
+other than
+.Fn QUOTACTL_CURSOROPEN
+will produce unspecified behavior.
+As per general standards for system calls such actions must not
+produce undefined or materially adverse behavior in the kernel;
+however, the effect on a user process may be arbitrary.
+The
+.Xr libquota 3
+interface wraps the system call level quota cursors in a friendlier
+interface.
+See
+.Xr quota_opencursor 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSORCLOSE "struct quotakcursor *cursor"
+The cursor passed in is closed.
+See
+.Xr quotacursor_close 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSORSKIPIDTYPE "struct quotakcursor *cursor" "int idtype"
+This operation provides a hint that iteration can skip over a
+particular ID type.
+The implementation is not obliged to honor the hint.
+See
+.Xr quotacursor_skipidtype 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSORGET "struct quotakcursor *cursor" "struct quotakey *keys" "struct quotaval *vals" "unsigned maxnum" "unsigned *ret"
+This operation retrieves data at the current cursor position and
+advances it.
+Up to
+.Fa maxnum
+quota records are retrieved and stored into the arrays named by
+.Fa keys
+and
+.Fa vals .
+The number of records retrieved is stored into the variable pointed to
+by
+.Fa ret .
+See
+.Xr quotacursor_get 3
+and
+.Xr quotacursor_getn 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSORATEND "struct quotakcursor *cursor" "int *ret"
+This operation generates a nonzero value if the cursor has reached the
+end of the available quota information and zero otherwise.
+The generated value is stored into the variable pointed to by
+.Fa ret .
+See
+.Xr quotacursor_atend 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_CURSORREWIND "struct quotakcursor *cursor"
+This operation updates the cursor state so that further calls to
+.Fn QUOTACTL_CURSORGET
+will begin again at the start of the iteration.
+See
+.Xr quotacursor_rewind 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_QUOTAON "int idtype" "const char *quotafile"
+This operation is accepted only by old-style
+.Pq Dq quota1
+quota implementations.
+Quotas for the ID type named by
+.Fa idtype
+are switched on, and the file
+.Fa quotafile
+is used to hold the quota information.
+This operation can also be used when quotas are already switched on
+to change the file used to hold the quota information.
+Note however that as the current usage information in the file must be
+consistent with the current state of the file system, in general it is
+not safe to call
+.Fn QUOTACTL_QUOTAON
+except in single-user mode.
+See
+.Xr quotaon 8
+for more information.
+Normally
+quotaon 8
+is run during the boot sequence after
+quotacheck 8 .
+Also see
+.Xr quota_quotaon 3 .
+.\" ************************************************************
+.It Fn QUOTACTL_QUOTAOFF "int idtype"
+This operation is accepted only by old-style
+.Pq Dq quota1
+quota implementations.
+Quotas for the ID type named by
+.Fa idtype
+are switched off.
+Once quotas are switched off the file system behaves as if no quotas
+are present.
+Normally
+quotaoff 8
+is run during the shutdown sequence.
+Also see
+.Xr quota_quotaoff 3 .
+.\" ************************************************************
+.El
+.Sh RETURN VALUES
+On success,
+.Fn __quotactl
+returns 0.
+Otherwise the value \-1 is returned and an error code reflecting the
+reason for the failure is placed in
+.Va errno .
+.Sh ERRORS
+.Fn __quotactl
+failures include:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+A pointer points outside the process's allocated address space.
+.It Bq Er EINVAL
+The operation code was out of range; or
+a requested ID or object type was out of range; or
+a corrupted or invalid cursor was passed in.
+.It Bq Er ENODEV
+The requested action was inappropriate for
+.Pq or not supported by
+the selected volume.
+.It Bq Er ENOENT
+No quota information exists for the requested key.
+.It Bq Er ENOMEM
+Memory could not be allocated within the kernel.
+.It Bq Er ENXIO
+The target file system type is capable of supporting quotas, but
+quotas are not enabled on the selected volume.
+.It Bq Er EOPNOTSUPP
+The target file system does not support quotas.
+.El
+.Sh SEE ALSO
+.Xr quota 1 ,
+.Xr libquota 3 ,
+.Xr fstab 5 ,
+.Xr edquota 8 ,
+.Xr quotacheck 8 ,
+.Xr quotaon 8 ,
+.Xr quotarestore 8 ,
+.Xr repquota 8
+.Sh HISTORY
+The original
+.Fn quotactl
+function call appeared in
+.Bx 4.3 Reno .
+The current
+.Fn __quotactl
+interface appeared in
+.Nx 6.0 .
+.Sh BUGS
+As of this writing the error returns that occur in practice are not
+always completely consistent with the intent documented above.
+.Pp
+There should be some way to integrate this call with the resource
+limit interface provided by
+.Xr setrlimit 2
+and
+.Xr getrlimit 2 .
-.\" $NetBSD: _lwp_create.2,v 1.4 2008/04/30 13:10:51 martin Exp $
+.\" $NetBSD: _lwp_create.2,v 1.5 2012/05/21 14:15:16 martin Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.Fa context
argument specifies the initial execution context for the new LWP including
signal mask, stack, and machine registers.
+If this context specifies invalid register values (for example priviledge
+escalation by setting machine dependend bits forbidden for user processes),
+or does not specify cpu register values (uc_flags does not have the
+_UC_CPU bit set), the call will fail and errno will be set to EINVAL.
.Pp
The following flags affect the creation of the new LWP:
.Bl -tag -width LWP_SUSPENDED
Upon successful completion,
.Fn _lwp_create
returns a value of 0.
-Otherwise, an error code is returned to indicate the error.
+Otherwise, a value of -1 is returned and errno is set to one of the values
+documented below.
.Sh ERRORS
.Fn _lwp_create
will fail and no LWP will be created if:
or
.Fa new_lwp
is outside the process's allocated address space.
+.It Bq Er EINVAL
+The ucontext_t passed is invalid.
.El
.Sh SEE ALSO
.Xr _lwp_continue 2 ,
-.\" $NetBSD: _lwp_ctl.2,v 1.3 2009/02/17 18:51:56 njoly Exp $
+.\" $NetBSD: _lwp_ctl.2,v 1.5 2012/04/13 15:14:58 yamt Exp $
.\"
.\" Copyright (c)2007 YAMAMOTO Takashi,
.\" All rights reserved.
.\" SUCH DAMAGE.
.\"
.\" ------------------------------------------------------------
-.Dd May 5, 2008
+.Dd April 13, 2012
.Dt _LWP_CTL 2
.Os
.Sh NAME
.Lb libc
.\" ------------------------------------------------------------
.Sh SYNOPSIS
+.In sys/lwpctl.h
.In lwp.h
.Ft int
.Fn _lwp_ctl "int features" "struct lwpctl **address"
The bitwise-OR of the following flags.
.Bl -tag -width LWPCTL_FEATURE_CURCPU
.It Dv LWPCTL_FEATURE_CURCPU
-Request lc_curcpu.
+Request
+.Vt lc_curcpu .
.It Dv LWPCTL_FEATURE_PCTR
-Request lc_pctr.
+Request
+.Vt lc_pctr .
.El
.It Fa address
-The address to store a pointer to lwpctl structure for the calling LWP.
+The address to store a pointer to
+.Vt lwpctl
+structure for the calling LWP.
.El
.Pp
-The per-LWP communication area is described by an lwpctl structure.
+The per-LWP communication area is described by an
+.Vt lwpctl
+structure.
It has following members, depending on
.Fa features .
.Bl -tag -width int_lc_curcpu
-.It int lc_curcpu
+.It Vt int lc_curcpu
The integral identifier of the CPU on which the LWP is running,
or
.Dv LWPCTL_CPU_NONE
It's available only if requested with the
.Dv LWPCTL_FEATURE_CURCPU
flag.
-.It int lc_pctr
+.It Vt int lc_pctr
The integer which is incremented on every context switches to the LWP.
It can be used to detect preemption of the LWP.
(thus its name "preemption counter".)
-.\" $NetBSD: accept.2,v 1.25 2006/11/17 23:59:33 rillig Exp $
+.\" $NetBSD: accept.2,v 1.29 2012/03/19 09:34:36 plunky Exp $
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)accept.2 8.2 (Berkeley) 12/11/93
.\"
-.Dd November 18, 2006
+.Dd March 19, 2012
.Dt ACCEPT 2
.Os
.Sh NAME
-.Nm accept
+.Nm accept ,
+.Nm paccept
.Nd accept a connection on a socket
.Sh LIBRARY
.Lb libc
.In sys/socket.h
.Ft int
.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
+.Ft int
+.Fn paccept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "const sigset_t * restrict sigmask" "int flags"
.Sh DESCRIPTION
The argument
.Fa s
call with providing only the control information,
or by calling
.Xr setsockopt 2 .
+.Pp
+The
+.Fn paccept
+function behaves exactly like
+.Fn accept ,
+but it also allows to set the following
+.Fa flags
+on the returned file descriptor:
+.Bl -column SOCK_NONBLOCK -offset indent
+.It Dv SOCK_CLOEXEC
+Set the close on exec property.
+.It Dv SOCK_NONBLOCK
+Sets non-blocking I/O.
+.El
+.Pp
+It can also temporarily replace the signal mask of the calling thread if
+.Fa sigmask
+is a
+.Pf non- Dv NULL
+pointer, then the
+.Fn paccept
+function shall replace the signal mask of the caller by the set of
+signals pointed to by
+.Fa sigmask
+before waiting for a connection, and shall restore the signal mask
+of the calling thread before returning.
.Sh RETURN VALUES
-The call returns \-1 on error.
-If it succeeds, it returns a non-negative
+The
+.Fn accept
+and
+.Fn paccept
+calls return \-1 on error.
+If they succeed, they return a non-negative
integer that is a descriptor for the accepted socket.
+.Sh COMPATIBILITY
+The
+.Fn accept
+implementation makes the new file descriptor inherit file flags
+(like
+.Dv O_NONBLOCK )
+from the listening socket.
+It's a traditional behaviour for BSD derivative systems.
+On the other hand, there are implementations which don't do so.
+Linux is an example of such implementations.
+Portable programs should not rely on either of the behaviours.
.Sh ERRORS
The
.Fn accept
.Fn accept
function appeared in
.Bx 4.2 .
+The
+.Fn paccept
+function is inspired from Linux and appeared in
+.Nx 6.0 .
-/* $NetBSD: adjtime.c,v 1.11 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: adjtime.c,v 1.12 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: adjtime.c,v 1.11 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: adjtime.c,v 1.12 2011/10/15 23:00:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/clockctl.h>
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
extern int __clockctl_fd;
int ____adjtime50(const struct timeval *, struct timeval *);
* If this fails, it means that we are not root
* and we cannot open clockctl. This is a failure.
*/
- __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY, 0);
+ __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY | O_CLOEXEC, 0);
if (__clockctl_fd == -1) {
/* original error was EPERM - don't leak open errors */
errno = EPERM;
return -1;
}
-
- (void) fcntl(__clockctl_fd, F_SETFD, FD_CLOEXEC);
}
/*
-.\" $NetBSD: chflags.2,v 1.26 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: chflags.2,v 1.27 2011/08/06 11:28:24 jruoho Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)chflags.2 8.3 (Berkeley) 5/2/95
.\"
-.Dd May 2, 1995
+.Dd August 6, 2011
.Dt CHFLAGS 2
.Os
.Sh NAME
.Sh SEE ALSO
.Xr chflags 1 ,
.Xr stat 2 ,
+.Xr stat_flags 3 ,
.Xr init 8 ,
.Xr mount_union 8
.Sh HISTORY
-.\" $NetBSD: chmod.2,v 1.37 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: chmod.2,v 1.40 2012/03/04 11:58:31 wiz Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)chmod.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd January 4, 2009
+.Dd March 3, 2012
.Dt CHMOD 2
.Os
.Sh NAME
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
-#define S_ISVTX 0001000 /* save swapped text even after use */
+#define S_ISVTX 0001000 /* sticky bit */
.Ed
.Pp
-If mode
+The mode
.Dv ISVTX
(the
.Sq sticky bit )
-is set on a regular file, it historically meant that the system should
-save a shareable copy of the program text in the swap area.
-When applied to commonly used programs like the shell or editor, this
-would decrease memory usage and startup time.
-In
-.Nx ,
-the sticky bit may still be set on regular files by the super-user,
-but has no effect.
-The historical meaning became obsolete in the 1980s with the advent of
-memory-mapped executables, and is only documented as a matter of
-historical interest.
+can be set on regular files, but has no effect.
+For historical reasons this can be done only by the super-user.
.Pp
If mode
.Dv ISVTX
The sticky bit may be set by any user on a directory which the user
owns or has appropriate permissions.
.Pp
-For more information about the properties of the sticky bit, see
+For more information about the history and properties of the sticky bit, see
.Xr sticky 7 .
.Pp
Changing the owner of a file
.Fn lchmod
will fail and the file mode will be unchanged if:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EFAULT
+.Fa path
+points outside the process's allocated address space.
+.It Bq Er EFTYPE
+The effective user ID is not the super-user, the
+.Fa mode
+includes the sticky bit
+.Pq Dv S_ISVTX ,
+and
+.Fa path
+does not refer to a directory.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.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.
.It Bq Er ENOENT
The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
.It Bq Er EPERM
The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
-.It Bq Er EPERM
-The mode includes the setgid bit
+the effective user ID is not the super-user; or
+the mode includes the setgid bit
.Pq Dv S_ISGID
but the file's group is neither the effective group ID nor is it in the
group access list.
.It Bq Er EROFS
The named file resides on a read-only file system.
-.It Bq Er EFAULT
-.Fa path
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EFTYPE
-The effective user ID is not the super-user, the
-.Fa mode
-includes the sticky bit
-.Pq Dv S_ISVTX ,
-and
-.Fa path
-does not refer to a directory.
.El
.Pp
.Fn fchmod
.Bl -tag -width Er
.It Bq Er EBADF
The descriptor is not valid.
+.It Bq Er EFTYPE
+The effective user ID is not the super-user, the
+.Fa mode
+includes the sticky bit
+.Pq Dv S_ISVTX ,
+and
+.Fa fd
+does not refer to a directory.
.It Bq Er EINVAL
.Fa fd
refers to a socket, not to a file.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
.It Bq Er EPERM
The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
-.It Bq Er EPERM
-The mode includes the setgid bit
+the effective user ID is not the super-user; or
+the mode includes the setgid bit
.Pq Dv S_ISGID
but the file's group is neither the effective group ID nor is it in the
group access list.
.It Bq Er EROFS
The file resides on a read-only file system.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EFTYPE
-The effective user ID is not the super-user, the
-.Fa mode
-includes the sticky bit
-.Pq Dv S_ISVTX ,
-and
-.Fa fd
-does not refer to a directory.
.El
.Sh SEE ALSO
.Xr chmod 1 ,
-/* $NetBSD: clock_settime.c,v 1.11 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: clock_settime.c,v 1.12 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: clock_settime.c,v 1.11 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: clock_settime.c,v 1.12 2011/10/15 23:00:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/clockctl.h>
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
extern int __clockctl_fd;
int ____clock_settime50(clockid_t, const struct timespec *);
* If this fails, it means that we are not root
* and we cannot open clockctl. This is a failure.
*/
- __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY, 0);
+ __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY | O_CLOEXEC, 0);
if (__clockctl_fd == -1) {
/* original error was EPERM - don't leak open errors */
errno = EPERM;
return -1;
}
-
- (void) fcntl(__clockctl_fd, F_SETFD, FD_CLOEXEC);
}
/*
-.\" $NetBSD: clone.2,v 1.12 2010/05/04 06:13:43 jruoho Exp $
+.\" $NetBSD: clone.2,v 1.13 2012/01/29 11:44:54 wiz Exp $
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
.Dt CLONE 2
.Os
.Sh NAME
-.Nm clone
+.Nm clone ,
+.Nm __clone
.Nd spawn new process with options
.Sh LIBRARY
.Lb libc
-.\" $NetBSD: dup.2,v 1.21 2009/01/11 02:46:30 christos Exp $
+.\" $NetBSD: dup.2,v 1.28 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)dup.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd December 2, 2008
+.Dd January 23, 2012
.Dt DUP 2
.Os
.Sh NAME
.Nm dup ,
-.Nm dup2
+.Nm dup2 ,
+.Nm dup3
.Nd duplicate an existing file descriptor
.Sh LIBRARY
.Lb libc
.Fn dup "int oldd"
.Ft int
.Fn dup2 "int oldd" "int newd"
+.Ft int
+.Fn dup3 "int oldd" "int newd" "int flags"
.Sh DESCRIPTION
.Fn dup
duplicates an existing object descriptor and returns its value to
and
.Fa oldd
are the same, the call has no effect.
+.Pp
+.Fn dup3
+behaves exactly like
+.Fn dup2
+only it allows extra
+.Fa flags
+to be set on the returned file descriptor.
+The following flags are valid:
+.Bl -tag -width O_NONBLOCK -offset indent
+.It Dv O_CLOEXEC
+Set the
+.Dq close-on-exec
+property.
+.It Dv O_NONBLOCK
+Sets non-blocking I/O.
+.It Dv O_NOSIGPIPE
+Return
+.Er EPIPE
+instead of raising
+.Dv SIGPIPE .
+.El
.Sh RETURN VALUES
The value \-1 is returned if an error occurs in either call.
The external variable
.Va errno
indicates the cause of the error.
.Sh ERRORS
-.Fn dup
-and
-.Fn dup2
-fail if:
+All three functions may fail if:
.Bl -tag -width Er
.It Bq Er EBADF
.Fa oldd
or
.Fa newd
is not in the range of valid file descriptors.
+.El
+.Pp
+The
+.Fn dup
+function may also fail if:
+.Bl -tag -width Er
.It Bq Er EMFILE
Too many descriptors are active.
.El
+.Pp
+The
+.Fn dup3
+function will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa flags
+is other than
+.Dv O_NONBLOCK
+or
+.Dv O_CLOEXEC .
+.El
.Sh SEE ALSO
.Xr accept 2 ,
.Xr close 2 ,
.Fn dup2
functions conform to
.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn dup3
+function is inspired from Linux and appeared in
+.Nx 6.0 .
-.\" $NetBSD: extattr_get_file.2,v 1.3 2005/01/02 18:28:48 wiz Exp $
+.\" $NetBSD: extattr_get_file.2,v 1.5 2011/08/03 09:48:12 wiz Exp $
.\"
.\" Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org>
.\" Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org>
.\"
.\" FreeBSD: src/lib/libc/sys/extattr_get_file.2,v 1.14 2004/07/05 17:12:52 ru Exp
.\"
-.Dd January 2, 2004
+.Dd August 3, 2011
.Dt EXTATTR_GET_FILE 2
.Os
.Sh NAME
system call deletes the extended attribute specified.
The
.Fn extattr_list_file
-returns a list of attributes present in the requested namespace, separated
-by ASCII 0 (nul) characters.
+returns a list of attributes present in the requested namespace.
+Each list entry consists of a single byte containing the length
+of the attribute name, followed by the attribute name.
+The attribute name is not terminated by ASCII 0 (nul).
The
.Fn extattr_get_file
and
.Fn extattr_delete_file
calls may also fail due to the following errors:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
.It Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
.It Bq Er ENOENT
A component of the path name that must exist does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
.\" XXX are any missing?
.El
.Sh SEE ALSO
This interface is under active development, and as such is subject to
change as applications are adapted to use it.
Developers are discouraged from relying on its stability.
+.Pp
+Note that previous versions of this man page incorrectly stated that
+.Fn extattr_list_file
+returned a list of attribute names separated by ASCII 0 (nul).
-.\" $NetBSD: fcntl.2,v 1.37 2010/05/17 12:16:43 jruoho Exp $
+.\" $NetBSD: fcntl.2,v 1.40 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\"
-.Dd May 17, 2010
+.Dd January 23, 2012
.Dt FCNTL 2
.Os
.Sh NAME
interpreted as an int by some commands and ignored by others.
.Pp
Commands are:
-.Bl -tag -width F_GETOWNX
+.Bl -tag -width F_DUPFD_CLOEXEC
.It Dv F_DUPFD
Return a new descriptor as follows:
.Pp
.Xr execve 2
system calls.
.El
+.It Dv F_DUPFD_CLOEXEC
+Same as
+.Dv F_DUPFD ,
+but sets the close-on-exec property on the file descriptor created.
.It Dv F_GETFD
Get the close-on-exec flag associated with the file descriptor
.Fa fd
.Ar fd .
.It Dv F_MAXFD
Return the maximum file descriptor number currently open by the process.
+.It Dv F_GETNOSIGPIPE
+Return if the
+.Dv O_NOSIGPIPE
+flag is set in the file descriptor.
+.It Dv F_SETNOSIGPIPE
+Set or clear the
+.Dv O_NOSIGPIPE
+in the file descriptor.
.El
.Pp
-The flags for the
+The set of valid flags for the
.Dv F_GETFL
and
.Dv F_SETFL
flags are as follows:
-.Bl -tag -width O_NONBLOCKX
-.It Dv O_NONBLOCK
-Non-blocking I/O; if no data is available to a
-.Xr read 2
-call, or if a
-.Xr write 2
-operation would block,
-the read or write call returns \-1 with the error
-.Er EAGAIN .
-.It Dv O_APPEND
-Force each write to append at the end of file;
-corresponds to the
-.Dv O_APPEND
-flag of
+.Dv O_APPEND ,
+.Dv O_ASYNC ,
+.Dv O_FSYNC ,
+.Dv O_NONBLOCK ,
+.Dv O_DSYNC ,
+.Dv O_RSYNC ,
+.Dv O_ALT_IO ,
+.Dv O_DIRECT ,
+.Dv O_NOSIGPIPE .
+These flags are described in
.Xr open 2 .
-.It Dv O_ASYNC
-Enable the
-.Dv SIGIO
-signal to be sent to the process group
-when I/O is possible, e.g.,
-upon availability of data to be read.
-.El
.Pp
Several commands are available for doing advisory file locking;
they all operate on the following structure:
request fails or blocks respectively when another process has existing
locks on bytes in the specified region and the type of any of those
locks conflicts with the type specified in the request.
+.Sh RETURN VALUES
+Upon successful completion, the value returned depends on
+.Fa cmd
+as follows:
+.Bl -tag -width F_GETOWNX -offset indent
+.It Dv F_DUPFD
+A new file descriptor.
+.It Dv F_GETFD
+Value of flag (only the low-order bit is defined).
+.It Dv F_GETFL
+Value of flags.
+.It Dv F_GETOWN
+Value of file descriptor owner.
+.It Dv F_MAXFD
+Value of the highest file descriptor open by the process.
+.It other
+Value other than \-1.
+.El
+.Pp
+Otherwise, a value of \-1 is returned and
+.Va errno
+is set to indicate the error.
.Sh COMPATIBILITY
This interface follows the completely stupid semantics of
.At V
would cause a deadlock and fails with an
.Er EDEADLK
error.
-.Sh RETURN VALUES
-Upon successful completion, the value returned depends on
-.Fa cmd
-as follows:
-.Bl -tag -width F_GETOWNX -offset indent
-.It Dv F_DUPFD
-A new file descriptor.
-.It Dv F_GETFD
-Value of flag (only the low-order bit is defined).
-.It Dv F_GETFL
-Value of flags.
-.It Dv F_GETOWN
-Value of file descriptor owner.
-.It Dv F_MAXFD
-Value of the highest file descriptor open by the process.
-.It other
-Value other than \-1.
-.El
-.Pp
-Otherwise, a value of \-1 is returned and
-.Va errno
-is set to indicate the error.
.Sh ERRORS
.Fn fcntl
will fail if:
-.\" $NetBSD: flock.2,v 1.21 2009/10/29 01:52:01 wiz Exp $
+.\" $NetBSD: flock.2,v 1.22 2011/10/15 21:35:50 rmind Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)flock.2 8.2 (Berkeley) 12/11/93
.\"
-.Dd October 26, 2009
+.Dd October 15, 2011
.Dt FLOCK 2
.Os
.Sh NAME
.Xr dup 2 ,
.Xr execve 2 ,
.Xr fork 2 ,
-.Xr open 2
+.Xr open 2 ,
+.Xr flockfile 3 ,
+.Xr lockf 3
.Sh HISTORY
The
.Fn flock
-/* $NetBSD: ftruncate.c,v 1.13 2007/11/23 12:39:15 uebayasi Exp $ */
+/* $NetBSD: ftruncate.c,v 1.14 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93";
#else
-__RCSID("$NetBSD: ftruncate.c,v 1.13 2007/11/23 12:39:15 uebayasi Exp $");
+__RCSID("$NetBSD: ftruncate.c,v 1.14 2012/03/20 16:26:12 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
int
-ftruncate(fd, length)
- int fd;
- off_t length;
+ftruncate(int fd, off_t length)
{
return __ftruncate(fd, 0, length);
-.\" $NetBSD: getdents.2,v 1.22 2010/06/04 05:42:24 jruoho Exp $
+.\" $NetBSD: getdents.2,v 1.23 2011/07/20 17:51:25 njoly Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.Fa fd
is not a valid file descriptor open for reading.
.It Bq Er EFAULT
-Either
.Fa buf
points outside the allocated address space.
.It Bq Er EINVAL
-.\" $NetBSD: getitimer.2,v 1.24 2010/04/30 04:17:45 jruoho Exp $
+.\" $NetBSD: getitimer.2,v 1.28 2011/10/27 16:10:37 christos Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getitimer.2 8.3 (Berkeley) 5/16/95
.\"
-.Dd April 30, 2010
+.Dd October 27, 2011
.Dt GETITIMER 2
.Os
.Sh NAME
.Lb libc
.Sh SYNOPSIS
.In sys/time.h
-.Fd #define ITIMER_REAL 0
-.Fd #define ITIMER_VIRTUAL 1
-.Fd #define ITIMER_PROF 2
.Ft int
.Fn getitimer "int which" "struct itimerval *value"
.Ft int
The
.Fn setitimer
call sets a timer to the specified
-.Fa value
-(returning the previous value of the timer if
+.Fa value ,
+returning the previous value of the timer if
.Fa ovalue
-is non-nil).
+is not
+.Dv NULL .
.Pp
A timer value is defined by the
.Fa itimerval
.Fa it_value
is non-zero).
.Pp
-Time values smaller than the resolution of the
-system clock are rounded up to this resolution
-(typically 10 milliseconds).
-.Pp
The
-.Dv ITIMER_REAL
+.Fa which
+parameter specifies the type of the timer:
+.Bl -tag -width "ITIMER_MONOTONIC " -offset indent
+.It Dv ITIMER_REAL
timer decrements in real time.
+This timer is affected by
+.Xr adjtime 2
+and
+.Xr settimeofday 2 .
A
.Dv SIGALRM
signal is
delivered when this timer expires.
-.Pp
-The
-.Dv ITIMER_VIRTUAL
+.It Dv ITIMER_VIRTUAL
timer decrements in process virtual time.
It runs only when the process is executing.
A
.Dv SIGVTALRM
signal
is delivered when it expires.
-.Pp
-The
-.Dv ITIMER_PROF
+.It Dv ITIMER_PROF
timer decrements both in process virtual time and
when the system is running on behalf of the process.
It is designed to be used by interpreters in statistically profiling
Because this signal may interrupt in-progress
system calls, programs using this timer must be prepared to
restart interrupted system calls.
-.Sh NOTES
-Macros for manipulating time values are defined in the
-.In sys/time.h
-header;
-.Fn timerclear
-sets a time value to zero,
-.Fn timerisset
-tests if a time value is non-zero,
-.Fn timercmp
-compares two time values,
-.Fn timeradd
-adds a time value to another time value,
-.Fn timersub
-computes the time difference between two time values.
-For additional details, see
-.Xr timeradd 3 .
+.It Dv ITIMER_MONOTONIC
+timer decrements in monotonic time.
+This timer is not affected by
+.Xr adjtime 2
+and
+.Xr settimeofday 2 .
+A
+.Dv SIGALRM
+signal is
+delivered when this timer expires.
+.El
+Note that:
+.Bl -bullet -offset indent
+.It
+Time values smaller than the resolution of the
+system clock are rounded up to this resolution
+(typically 10 milliseconds).
+.It
+The interaction between
+.Fn setitimer
+and
+.Xr alarm 3
+or
+.Xr sleep 3
+is unspecified by the specification.
+.El
.Sh RETURN VALUES
If the calls succeed, a value of 0 is returned.
If an error occurs, the value \-1 is returned, and a more precise error
code is placed in the global variable
.Va errno .
.Sh ERRORS
-.Fn getitimer
-and
-.Fn setitimer
-will fail if:
+Both functions may fail if:
.Bl -tag -width Er
.It Bq Er EFAULT
The
.Fa value
parameter specified a bad address.
.It Bq Er EINVAL
-A
+The
+.Fa which
+parameter was not a known timer type, or the
.Fa value
parameter specified a time that was too large
to be handled.
.El
.Sh SEE ALSO
.Xr gettimeofday 2 ,
-.Xr poll 2 ,
.Xr select 2 ,
-.Xr sigaction 2
+.Xr sigaction 2 ,
+.Xr itimerval 3 ,
+.Xr timeradd 3
.Sh STANDARDS
-The
-.Fn getitimer
-and
-.Fn setitimer
-functions conform to
+The functions conform to
.St -p1003.1-2001 .
The later
.St -p1003.1-2008
-revision however marked both functions as obsolescent,
+revision however marked both as obsolescent,
recommending the use of
.Xr timer_gettime 2
and
.Fn getitimer
function call appeared in
.Bx 4.2 .
+The
+.Dv ITIMER_MONOTONIC
+functionality appeared in
+.Nx 6.0 .
-.\" $NetBSD: getpeername.2,v 1.19 2006/03/05 22:06:08 agc Exp $
+.\" $NetBSD: getpeername.2,v 1.21 2011/06/03 08:07:48 wiz Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getpeername.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd March 5, 2006
+.Dd June 3, 2011
.Dt GETPEERNAME 2
.Os
.Sh NAME
.Sh SYNOPSIS
.In sys/socket.h
.Ft int
-.Fn getpeername "int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
+.Fn getpeername \
+"int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
.Sh DESCRIPTION
+The
.Fn getpeername
-returns the name of the peer connected to
-socket
+function returns the name of the peer connected to the socket
.Fa s .
One common use occurs when a process inherits an open socket, such as
TCP servers forked from
.Fn getpeername
is used to determine the connecting client's IP address.
.Pp
-.Fn getpeername
-takes three parameters:
-.Pp
-.Fa s
+The function takes three parameters:
+.Bl -tag -width namelen -offset indent
+.It Fa s
contains the file descriptor of the socket whose peer should be looked up.
-.Pp
-.Fa name
+.It Fa name
points to a
.Li sockaddr
structure that will hold the address information for the connected peer.
is large enough to hold any of the other sockaddr_* variants.
On return, it can be cast to the correct sockaddr type,
based on the protocol family contained in its ss_family field.
-.Pp
-.Fa namelen
+.It Fa namelen
indicates the amount of space pointed to by
.Fa name ,
in bytes.
+.El
.Pp
If address information for the local end of the socket is required, the
.Xr getsockname 2
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 socket is not connected.
-.It Bq Er ENOBUFS
-Insufficient resources were available in the system
-to perform the operation.
.It Bq Er EFAULT
The
.Fa name
parameter points to memory not in a valid part of the
process address space.
+.It Bq Er ENOBUFS
+Insufficient resources were available in the system
+to perform the operation.
+.It Bq Er ENOTCONN
+The socket is not connected.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is a file, not a socket.
.El
.Sh SEE ALSO
.Xr accept 2 ,
.Xr bind 2 ,
.Xr getsockname 2 ,
.Xr socket 2
+.Sh STANDARDS
+The function conforms to
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn getpeername
-.\" $NetBSD: getpriority.2,v 1.18 2009/03/11 13:39:14 joerg Exp $
+.\" $NetBSD: getpriority.2,v 1.20 2012/04/13 16:32:15 wiz Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getpriority.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd April 25, 2004
+.Dd April 13, 2012
.Dt GETPRIORITY 2
.Os
.Sh NAME
call and set with the
.Fn setpriority
call.
+.Pp
+The priority is maintained in a per-process basis and
+affects scheduling of LWPs which belong to the process and use the
+.Dv SCHED_OTHER
+scheduling class.
+.Pp
.Fa which
is one of
.Dv PRIO_PROCESS ,
.Fa prio
is a value in the range -20 to 20.
The default priority is 0;
-lower priorities cause more favorable scheduling.
+numerically lower priority values cause more favorable scheduling.
A value of 19 or 20
will schedule a process only when nothing at priority \*(Le 0 is runnable.
.Pp
.Fn setpriority
call sets the priorities of all of the specified processes
to the specified value.
-Only the super-user may lower priorities.
+Only the super-user may lower priority values.
.Sh RETURN VALUES
Since
.Fn getpriority
.Fn setpriority
will fail if:
.Bl -tag -width Er
-.It Bq Er ESRCH
-No process was located using the
-.Fa which
-and
-.Fa who
-values specified.
.It Bq Er EINVAL
.Fa which
was not one of
.Dv PRIO_PGRP ,
or
.Dv PRIO_USER .
+.It Bq Er ESRCH
+No process was located using the
+.Fa which
+and
+.Fa who
+values specified.
.El
.Pp
In addition to the errors indicated above,
.Fn setpriority
will fail if:
.Bl -tag -width Er
+.It Bq Er EACCES
+A non super-user attempted to lower a process priority value.
.It Bq Er EPERM
A process was located, but neither its effective nor real user
ID matched the effective user ID of the caller.
-.It Bq Er EACCES
-A non super-user attempted to lower a process priority.
.El
.Sh SEE ALSO
.Xr nice 1 ,
.Xr fork 2 ,
+.Xr sched 3 ,
.Xr renice 8
.Sh HISTORY
The
-.\" $NetBSD: getrlimit.2,v 1.32 2009/07/01 11:25:50 wiz Exp $
+.\" $NetBSD: getrlimit.2,v 1.36 2012/06/09 02:36:25 christos Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getrlimit.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd July 1, 2009
+.Dd June 8, 2012
.Dt GETRLIMIT 2
.Os
.Sh NAME
The maximum number of open files for this process.
.It Li RLIMIT_NPROC
The maximum number of simultaneous processes for this user id.
+.It Li RLIMIT_NTHR
+The maximum number of simultaneous threads (Lightweight Processes) for this
+user id.
+Kernel threads and the first thread of each process are not counted against
+this limit.
.It Li RLIMIT_RSS
The maximum size (in bytes) to which a process's resident set size may
grow.
.It Bq Er EINVAL
Specified
.Fa resource
-was invalid.
-.It Bq Er EINVAL
-In the
+was invalid; or, in the
.Fn setrlimit
call, the specified
.Fa rlim_cur
.Xr csh 1 ,
.Xr sh 1 ,
.Xr mlock 2 ,
-.Xr quotactl 2 ,
.Xr setsockopt 2 ,
.Xr sigaction 2 ,
.Xr sigaltstack 2 ,
+.Xr libquota 3 ,
.Xr sysctl 3
.\" Sh STANDARDS
.\" With exception of
.Fn getrlimit
function call appeared in
.Bx 4.2 .
+.Sh BUGS
+The resource limit
+.Dv RLIMIT_RSS
+is not implemented in
+.Xr uvm 9
+which means that process memory size limits are not enforced.
-.\" $NetBSD: getsid.2,v 1.10 2006/10/07 21:03:51 elad Exp $
+.\" $NetBSD: getsid.2,v 1.11 2011/04/04 08:00:53 jruoho Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getpgrp.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd October 7, 2006
+.Dd April 4, 2011
.Dt GETSID 2
.Os
.Sh NAME
.Fn getsid "pid_t pid"
.Sh DESCRIPTION
The
-.Nm
+.Fn getsid
function returns the session ID of the process specified by
.Ar pid .
If
process that is the session leader.
.Sh ERRORS
If an error occurs,
-.Nm
+.Fn getsid
returns \-1 and the global variable
.Va errno
is set to indicate the error, as follows:
-.\" $NetBSD: getsockname.2,v 1.23 2003/08/07 16:43:59 agc Exp $
+.\" $NetBSD: getsockname.2,v 1.24 2012/07/09 21:22:21 jdf Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getsockname.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd August 11, 2002
+.Dd July 9, 2012
.Dt GETSOCKNAME 2
.Os
.Sh NAME
The socket has been shut down.
.It Bq Er ENOBUFS
Insufficient resources were available in the system to perform the operation.
+.It Bq Er ENOTCONN
+The socket is not connected.
.It Bq Er EFAULT
The
.Fa name
-.\" $NetBSD: getsockopt.2,v 1.34 2009/06/29 08:38:07 wiz Exp $
+.\" $NetBSD: getsockopt.2,v 1.35 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95
.\"
-.Dd June 28, 2009
+.Dd January 23, 2012
.Dt GETSOCKOPT 2
.Os
.Sh NAME
.It Dv SO_RCVTIMEO Ta "set timeout value for input"
.It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams"
.It Dv SO_ACCEPTFILTER Ta "set accept filter on listening socket"
+.It Dv SO_NOSIGPIPE Ta
+controls generation of
+.Dv SIGPIPE
+for the socket
.It Dv SO_TYPE Ta "get the type of the socket (get only)"
.It Dv SO_ERROR Ta "get and clear error on the socket (get only)"
.El
-.\" $NetBSD: issetugid.2,v 1.11 2003/08/07 16:44:00 agc Exp $
+.\" $NetBSD: issetugid.2,v 1.12 2012/04/21 12:27:27 roy Exp $
.\" OpenBSD: issetugid.2,v 1.7 1997/02/18 00:16:09 deraadt Exp
.\" FreeBSD: src/lib/libc/sys/issetugid.2,v 1.5.2.2 1999/09/18 16:18:59 phantom Exp
.\"
.\"
.\" FreeBSD: src/lib/libc/sys/issetugid.2,v 1.5.2.2 1999/09/18 16:18:59 phantom Exp
.\"
-.Dd April 22, 2000
+.Dd April 5, 2012
.Dt ISSETUGID 2
.Os
.Sh NAME
privileges were given as a result) or if it has changed any of its real,
effective or saved user or group ID's since it began execution.
.Pp
-This system call exists so that library routines (e.g., libc, libtermcap)
+This system call exists so that library routines (e.g., libc)
can reliably determine if it is safe to use information
that was obtained from the user, in particular the results from
.Xr getenv 3
-.\" $NetBSD: kqueue.2,v 1.29 2010/04/13 10:45:46 wiz Exp $
+.\" $NetBSD: kqueue.2,v 1.32 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 2000 Jonathan Lemon
.\" All rights reserved.
.\"
.\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $
.\"
-.Dd April 13, 2010
+.Dd January 23, 2012
.Dt KQUEUE 2
.Os
.Sh NAME
.Nm kqueue ,
+.Nm kqueue1 ,
.Nm kevent
.Nd kernel event notification mechanism
.Sh LIBRARY
.Ft int
.Fn kqueue "void"
.Ft int
+.Fn kqueue1 "int flags"
+.Ft int
.Fn kevent "int kq" "const struct kevent *changelist" "size_t nchanges" "struct kevent *eventlist" "size_t nevents" "const struct timespec *timeout"
.Fn EV_SET "\*[Am]kev" ident filter flags fflags data udata
.Sh DESCRIPTION
.Pp
.Fn kqueue
creates a new kernel event queue and returns a descriptor.
+.Pp
+The
+.Fn kqueue1
+also allows to set the following
+.Fa flags
+on the returned file descriptor:
+.Bl -column O_NONBLOCK -offset indent
+.It Dv O_CLOEXEC
+Set the close on exec property.
+.It Dv O_NONBLOCK
+Sets non-blocking I/O.
+.It Dv O_NOSIGPIPE
+Return
+.Er EPIPE
+instead of raising
+.Dv SIGPIPE .
+.El
The queue is not inherited by a child created with
.Xr fork 2 .
.\" However, if
EV_SET(\*[Am]ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK|
NOTE_RENAME|NOTE_REVOKE, 0, 0);
- if (kevent(kq, \*[Am]ch, 1, NULL, 0, \*[Am]tout) == -1)
- err(1, "kevent");
+ if (kevent(kq, \*[Am]ev, 1, NULL, 0, \*[Am]tout) == -1)
+ err(1, "kevent");
for (;;) {
nev = kevent(kq, NULL, 0, \*[Am]ev, 1, \*[Am]tout);
if (nev == -1)
.Fx 4.1 ,
and then in
.Nx 2.0 .
+The
+.Fn kqueue1
+function first appeared in
+.Nx 6.0 .
-.\" $NetBSD: link.2,v 1.24 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: link.2,v 1.26 2011/08/08 19:50:17 wiz Exp $
.\"
-.\" Copyright (c) 1980, 1991, 1993
+.\" Copyright (c) 1980, 1991, 1993, 2011
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.In unistd.h
.Ft int
.Fn link "const char *name1" "const char *name2"
+.Ft int
+.Fn linkat "int fd1" "const char *name1" "int fd2" "const char *name2" "int flags"
.Sh DESCRIPTION
The
.Fn link
.Fa name1
may not be a directory unless the caller is the super-user
and the file system containing it supports linking to directories.
+.Pp
+When operating on a symlink,
+.Fn link
+resolves the symlink and creates a hard link on the target.
+.Fn linkat
+will do the same if
+.Dv AT_SYMLINK_FOLLOW
+is set in
+.Fa flags ,
+but it will link on the symlink itself if the flag is clear.
+.Pp
+At the moment,
+.Fn linkat
+is partially implemented.
+It will return
+.Er ENOSYS
+for
+.Fa fd1
+and
+.Fa fd2
+values different than
+.Dv AT_FDCWD .
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
.Fn link
will fail and no link will be created if:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of either path prefix is not a directory.
-.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
-A component of either path prefix does not exist.
.It Bq Er EACCES
A component of either path prefix denies search permission, or
the requested link requires writing in a directory with a mode
that denies write permission.
+.It Bq Er EDQUOT
+The directory in which the entry for the new link
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EEXIST
+The link named by
+.Fa name2
+does exist.
+.It Bq Er EFAULT
+One of the pathnames specified
+is outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to
+the file system to make the directory entry.
.It Bq Er ELOOP
Too many symbolic links were encountered in translating one of the pathnames.
+.It Bq Er EMLINK
+The link count of the file named by
+.Fa name1
+would exceed
+.Dv {LINK_MAX} .
+.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 file named by
+A component of either path prefix does not exist, or the file named
+by
.Fa name1
does not exist.
+.It Bq Er ENOSPC
+The directory in which the entry for the new link is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er ENOTDIR
+A component of either path prefix is not a directory.
.It Bq Er EOPNOTSUPP
The file system containing the file named by
.Fa name1
does not support links.
-.It Bq Er EMLINK
-The link count of the file named by
-.Fa name1
-would exceed
-.Dv {LINK_MAX} .
-.It Bq Er EEXIST
-The link named by
-.Fa name2
-does exist.
.It Bq Er EPERM
The file named by
.Fa name1
or the file system containing the file does not permit the use of
.Fn link
on a directory.
+.It Bq Er EROFS
+The requested link requires writing in a directory on a read-only file
+system.
.It Bq Er EXDEV
The link named by
.Fa name2
and the file named by
.Fa name1
are on different file systems.
-.It Bq Er ENOSPC
-The directory in which the entry for the new link is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er EDQUOT
-The directory in which the entry for the new link
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to
-the file system to make the directory entry.
-.It Bq Er EROFS
-The requested link requires writing in a directory on a read-only file
-system.
-.It Bq Er EFAULT
-One of the pathnames specified
-is outside the process's allocated address space.
.El
.Sh SEE ALSO
.Xr symlink 2 ,
.Fn link
function conforms to
.St -p1003.1-90 .
+.Sh BUGS
+.Fn linkat
+is partially implemented.
-/* $NetBSD: lseek.c,v 1.10 2007/11/23 12:39:15 uebayasi Exp $ */
+/* $NetBSD: lseek.c,v 1.11 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)lseek.c 8.1 (Berkeley) 6/17/93";
#else
-__RCSID("$NetBSD: lseek.c,v 1.10 2007/11/23 12:39:15 uebayasi Exp $");
+__RCSID("$NetBSD: lseek.c,v 1.11 2012/03/20 16:26:12 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
off_t
-lseek(fd, offset, whence)
- int fd;
- off_t offset;
- int whence;
+lseek(int fd, off_t offset, int whence)
{
return __lseek(fd, 0, offset, whence);
-.\" $NetBSD: madvise.2,v 1.26 2009/06/03 09:04:18 wiz Exp $
+.\" $NetBSD: madvise.2,v 1.27 2011/03/29 18:54:54 jruoho Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\"
-.Dd June 2, 2009
+.Dd March 29, 2011
.Dt MADVISE 2
.Os
.Sh NAME
interface is identical and is provided for standards conformance.
.Pp
The known behaviors are:
-.Bl -tag -width MADV_NORMAL
+.Bl -tag -width MADV_SEQUENTIAL
.It Dv MADV_NORMAL
Tells the system to revert to the default paging
behavior.
#!/bin/sh -
-# $NetBSD: makelintstub,v 1.23 2008/08/05 02:08:13 lukem Exp $
+# $NetBSD: makelintstub,v 1.25 2012/02/12 01:46:05 martin Exp $
#
# Copyright (c) 1996, 1997 Christopher G. Demetriou
# All rights reserved.
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>
+ #include <sys/spawn.h>
#include <sys/sched.h>
#include <sys/timex.h>
#include <sys/socket.h>
#include <sys/event.h>
#include <sys/uuid.h>
+ #include <sys/quotactl.h>
#ifdef __STDC__
#include <stdarg.h>
#else
-.\" $NetBSD: mknod.2,v 1.20 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: mknod.2,v 1.22 2011/07/08 19:25:51 wiz Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)mknod.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd January 18, 2007
+.Dd July 3, 2011
.Dt MKNOD 2
.Os
.Sh NAME
.Fn mknod
will fail and the file will be not created if:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EDQUOT
+The directory in which the entry for the new node
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted; or
+the user's quota of inodes on the file system on
+which the node is being created has been exhausted.
+.It Bq Er EEXIST
+The named file exists.
+.It Bq Er EFAULT
+.Fa path
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The supplied
+.Fa mode
+or
+.Fa dev
+is invalid.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry or allocating the 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.
.It Bq Er ENOENT
A component of the path prefix does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The process's effective user ID is not super-user.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry or allocating the inode.
.It Bq Er ENOSPC
The directory in which the entry for the new node is being placed
cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er ENOSPC
-There are no free inodes on the file system on which the
+system containing the directory; or
+there are no free inodes on the file system on which the
node is being created.
-.It Bq Er EDQUOT
-The directory in which the entry for the new node
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EDQUOT
-The user's quota of inodes on the file system on
-which the node is being created has been exhausted.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er EPERM
+The process's effective user ID is not super-user.
.It Bq Er EROFS
The named file resides on a read-only file system.
-.It Bq Er EEXIST
-The named file exists.
-.It Bq Er EFAULT
-.Fa path
-points outside the process's allocated address space.
.El
.Sh SEE ALSO
.Xr chmod 2 ,
-.\" $NetBSD: mlock.2,v 1.18 2004/05/13 10:20:58 wiz Exp $
+.\" $NetBSD: mlock.2,v 1.20 2011/02/28 07:17:02 wiz Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)mlock.2 8.2 (Berkeley) 12/11/93
.\"
-.Dd June 2, 1993
+.Dd February 28, 2011
.Dt MLOCK 2
.Os
.Sh NAME
call unlocks pages previously locked by one or more
.Nm mlock
calls.
-For both, the
-.Fa addr
-parameter should be aligned to a multiple of the page size.
-If the
-.Fa len
-parameter is not a multiple of the page size, it will be rounded up
-to be so.
-The entire range must be allocated.
+The entire range of memory must be allocated.
.Pp
After an
.Nm mlock
the per-process
.Li RLIMIT_MEMLOCK
resource limit.
+.Pp
+Portable code should ensure that the
+.Fa addr
+and
+.Fa len
+parameters are aligned to a multiple of the page size, even though the
+.Nx
+implementation will round as necessary.
.Sh RETURN VALUES
A return value of 0 indicates that the call
succeeded and all pages in the range have either been locked or unlocked.
.Fn mlock
will fail if:
.Bl -tag -width Er
-.It Bq Er EINVAL
-The address given is not page aligned or the length is negative.
.It Bq Er EAGAIN
Locking the indicated range would exceed either the system or per-process
limit for locked memory.
+.It Bq Er EINVAL
+The length is negative; or the address or length given is not page
+aligned and the implementation does not round.
.It Bq Er ENOMEM
Some portion of the indicated address range is not allocated.
There was an error faulting/mapping a page.
will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
-The address given is not page aligned or the length is negative.
+The length is negative; or the address or length given is not page
+aligned and the implementation does not round.
.It Bq Er ENOMEM
Some portion of the indicated address range is not allocated.
Some portion of the indicated address range is not locked.
-.\" $NetBSD: mmap.2,v 1.41 2009/02/27 16:48:02 wiz Exp $
+.\" $NetBSD: mmap.2,v 1.47 2012/01/05 15:19:52 reinoud Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\"
-.Dd February 27, 2009
+.Dd December 20, 2011
.Dt MMAP 2
.Os
.Sh NAME
.Em OR Ns 'ing
the following values:
.Pp
-.Bl -tag -width PROT_WRITEXX
+.Bl -tag -width PROT_WRITEXX -offset indent
.It Dv PROT_EXEC
Pages may be executed.
.It Dv PROT_READ
.Em OR Ns 'ing
the following values:
.Pp
-.Bl -tag -width MAP_HASSEMAPHOREXX
+.Bl -tag -width MAP_HASSEMAPHOREXX -offset indent
.It Dv MAP_ALIGNED(n)
Request that the allocation be aligned to the given boundary.
The parameter
.Xr munmap 2 ,
.Xr getpagesize 3 ,
.Xr sysconf 3
+.Sh STANDARDS
+The
+.Fn mmap
+function conforms to
+.St -p1003.1b-93 .
+.Sh HISTORY
+The
+.Fn mmap
+interface was first designed in
+.Bx 4.2 .
-/* $NetBSD: mmap.c,v 1.14 2007/11/23 12:39:15 uebayasi Exp $ */
+/* $NetBSD: mmap.c,v 1.15 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93";
#else
-__RCSID("$NetBSD: mmap.c,v 1.14 2007/11/23 12:39:15 uebayasi Exp $");
+__RCSID("$NetBSD: mmap.c,v 1.15 2012/03/20 16:26:12 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
void *
-mmap(addr, len, prot, flags, fd, offset)
- void *addr;
- size_t len;
- int prot;
- int flags;
- int fd;
- off_t offset;
+mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
return __mmap(addr, len, prot, flags, fd, 0, offset);
-.\" $NetBSD: modctl.2,v 1.8 2010/12/14 16:23:59 jruoho Exp $
+.\" $NetBSD: modctl.2,v 1.9 2012/08/07 01:19:05 jnemeth Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 14, 2010
+.Dd August 3, 2012
.Dt MODCTL 2
.Os
.Sh NAME
is one of
.Dv MODCTL_LOAD ,
.Dv MODCTL_UNLOAD ,
+.Dv MODCTL_STAT ,
or
-.Dv MODCTL_STAT .
+.Dv MODCTL_EXISTS .
The argument
.Fa argp
depends on the
.Em iovec
to reflect the size of the complete report, regardless of whether this
is larger or smaller than the size passed in.
+.It Dv MODCTL_EXISTS
+Test to see if the kernel was compiled with
+.Dq options MODULAR
+and whether or
+not modules may be loaded at the moment.
+In this case,
+.Fa argp
+should be an integer.
+It should be
+.Dq 0
+to test if a user can load a module via
+.Dv MODCTL_LOAD ,
+or it should be
+.Dq 1
+to test if the system can autoload modules.
+Note that this
+test does not consider the sysctl
+.Li kern.module.autoload .
.El
.Ss Data Types
The
Zero or more of the following flag values:
.Bl -tag -compact -width "MODCTL_LOAD_FORCE"
.It Dv MODCTL_NO_PROP
-Don't load \*[Lt]module\*[Gt].plist.
+Don't load
+.Ao module Ac Ns Pa .plist .
.It Dv MODCTL_LOAD_FORCE
Ignore kernel version mismatch.
.El
.El
.Sh SEE ALSO
.Xr module 7 ,
+.Xr sysctl 7 ,
.Xr module 9
.Sh HISTORY
The
-.\" $NetBSD: mount.2,v 1.45 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: mount.2,v 1.49 2011/11/18 21:04:21 christos Exp $
.\"
.\" Copyright (c) 1980, 1989, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)mount.2 8.3 (Berkeley) 5/24/95
.\"
-.Dd April 10, 2009
+.Dd November 18, 2011
.Dt MOUNT 2
.Os
.Sh NAME
Do not allow programs to dump core files on the file system.
.It Dv MNT_NOATIME
Never update access time in the file system.
+.It Dv MNT_RELATIME
+Update access time on write and change.
+This helps programs that verify that the file has been read after written
+to work.
.It Dv MNT_NODEVMTIME
Never update modification time of device files.
.It Dv MNT_SYMPERM
filesystem, creating a record of meta-data writes to be
performed, allowing the actual writes to be deferred.
This improves performance in most cases.
+.It MNT_EXTATTR
+Enable extended attributes, if the filesystem supports them and
+does not enable them by default.
+Currently this is only the case for UFS1.
.El
.Pp
The
-.\" $NetBSD: mprotect.2,v 1.22 2009/01/11 02:46:30 christos Exp $
+.\" $NetBSD: mprotect.2,v 1.24 2011/04/03 06:54:30 jruoho Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)mprotect.2 8.1 (Berkeley) 6/9/93
.\"
-.Dd January 6, 2009
+.Dd April 3, 2011
.Dt MPROTECT 2
.Os
.Sh NAME
.Tn OR Ns 'ing
the following values:
.Pp
-.Bl -tag -width MAP_FIXEDX
+.Bl -tag -width MAP_FIXEDX -offset indent
.It Dv PROT_EXEC
Pages may be executed.
.It Dv PROT_READ
An invalid memory range, or invalid parameters were provided.
.It Bq Er ENOMEM
A resource shortage occurred while internally calling
-.Fn uvm_map_protect .
+.Xr uvm_map_protect 9 .
.El
.Sh SEE ALSO
.Xr madvise 2 ,
-.\" $NetBSD: mremap.2,v 1.3 2008/02/16 17:45:39 tnn Exp $
+.\" $NetBSD: mremap.2,v 1.4 2011/04/28 12:00:55 wiz Exp $
.\"
.\" Copyright (c) 2007 Thomas Klausner and Joerg Sonnenberger
.\" All rights reserved.
returns the new address or
.Dv MAP_FAILED ,
if the remap failed.
-.Sh HISTORY
-The
-.Fn mremap
-system call appeared in
-.Nx 5.0 .
-It was based on the code that supports
-.Fn mremap
-compatibility for Linux binaries.
.Sh COMPATIBILITY
The semantics of
.Fn mremap
.Sh SEE ALSO
.Xr mmap 2 ,
.Xr munmap 2
+.Sh HISTORY
+The
+.Fn mremap
+system call appeared in
+.Nx 5.0 .
+It was based on the code that supports
+.Fn mremap
+compatibility for Linux binaries.
-.\" $NetBSD: msgrcv.2,v 1.19 2009/01/28 08:57:02 wiz Exp $
+.\" $NetBSD: msgrcv.2,v 1.20 2012/05/15 11:37:01 reinoud Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
.Sh RETURN VALUES
Upon successful completion,
.Fn msgrcv
-returns the number of bytes received into the
+returns the number of bytes received and placed into the
.Va mtext
field of the structure pointed to by
.Fa msgp .
-.\" $NetBSD: msync.2,v 1.23 2005/10/18 03:18:16 chs Exp $
+.\" $NetBSD: msync.2,v 1.24 2011/10/15 21:35:50 rmind Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.Xr mlock 2 ,
.Xr mmap 2 ,
.Xr munlock 2
+.Sh STANDARDS
+The
+.Fn msync
+function conforms to
+.St -p1003.1b-93
.Sh HISTORY
The
.Fn msync
-.\" $NetBSD: munmap.2,v 1.19 2004/05/13 10:20:58 wiz Exp $
+.\" $NetBSD: munmap.2,v 1.20 2011/10/15 21:35:50 rmind Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.Xr mprotect 2 ,
.Xr msync 2 ,
.Xr getpagesize 3
+.Sh STANDARDS
+The
+.Fn munmap
+function conforms to
+.St -p1003.1b-93 .
.Sh HISTORY
The
.Fn munmap
-.\" $NetBSD: nanosleep.2,v 1.11 2010/05/17 07:22:03 jruoho Exp $
+.\" $NetBSD: nanosleep.2,v 1.13 2012/10/08 18:08:40 njoly Exp $
.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd May 17, 2010
+.Dd October 1, 2012
.Dt NANOSLEEP 2
.Os
.Sh NAME
.Sh SYNOPSIS
.In time.h
.Ft int
+.Fn clock_nanosleep "clockid_t clock_id" "int flags" "const struct timespec *rqtp" "struct timespec *rmtp"
+.Ft int
.Fn nanosleep "const struct timespec *rqtp" "struct timespec *rmtp"
.Sh DESCRIPTION
-The
-.Fn nanosleep
-suspends execution of the calling process until either the number of
-seconds and nanoseconds specified by
+If the
+.Dv TIMER_ABSTIME
+flag is not set in the
+.Fa flags
+argument, then
+.Fn clock_nanosleep
+suspends execution of the calling thread until either the number of
+seconds and nanoseconds specified in the
+.Fa rqtp
+argument have elapsed using the clock in the
+.Fa clock_id
+argument, or a signal is delivered to the calling process and its
+action is to invoke a signal catching function or to terminate the
+process.
+.Pp
+If the
+.Dv TIMER_ABSTIME
+flag is set in the
+.Fa flags
+argument, then
+.Fn clock_nanosleep
+suspends execution of the calling thread until either the value
+of the clock specified in the
+.Fa clock_id
+argument reaches the value of the
.Fa rqtp
-have elapsed or a signal is delivered to the calling process and its
+argument in seconds and nanoseconds,
+or a signal is delivered to the calling process and its
action is to invoke a signal catching function or to terminate the
process.
+.Pp
The suspension time may be longer than requested due to the
scheduling of other activity by the system.
+.Pp
+The
+.Fn nanosleep
+function behaves like
+.Fn clock_nanosleep
+with the
+.Fa clock_id
+argument equal to
+.Dv CLOCK_MONOTONIC
+and the
+.Fa flags
+argument having
+.Dv TIMER_ABSTIME
+not set.
+.Pp
The
.Em struct timespec
is described in
.Xr timespec 3 .
+The
+.Fa clock_id
+specified is the time source.
.Sh RETURN VALUES
If the
+.Fn clock_nanosleep
+or the
.Fn nanosleep
-function returns because the requested time has elapsed, the value
+functions return because the requested time has elapsed, the value
returned will be zero.
.Pp
If the
+.Fn clock_nanosleep
+or the
.Fn nanosleep
-function returns due to the delivery of a signal, the value returned
+functions return due to the delivery of a signal, the value returned
will be the \-1, and the global variable
.Va errno
will be set to indicate the interruption.
.It Bq Er ENOSYS
.Nm
is not supported by this implementation.
+.It Bq Er ENOTSUP
+for
+.Fn clock_nanosleep ,
+the clock specified in the
+.Fa clock_id
+argument is not supported.
.El
.Sh SEE ALSO
.Xr sleep 3 ,
.Fn nanosleep
function conforms to
.St -p1003.1b-93 .
+The
+.Fn clock_nanosleep
+function conforms to
+.St -p1003.1j-2000 .
-/* $NetBSD: ntp_adjtime.c,v 1.11 2007/11/23 12:39:15 uebayasi Exp $ */
+/* $NetBSD: ntp_adjtime.c,v 1.13 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ntp_adjtime.c,v 1.11 2007/11/23 12:39:15 uebayasi Exp $");
+__RCSID("$NetBSD: ntp_adjtime.c,v 1.13 2012/03/20 16:26:12 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(ntp_adjtime,_ntp_adjtime)
#endif
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
extern int __clockctl_fd;
int __ntp_adjtime(struct timex *);
int
-ntp_adjtime(tp)
- struct timex *tp;
+ntp_adjtime(struct timex *tp)
{
struct clockctl_ntp_adjtime args;
int error;
* and we cannot open clockctl. This is a true
* failure.
*/
- __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY, 0);
+ __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY | O_CLOEXEC, 0);
if (__clockctl_fd == -1) {
/* original error was EPERM - don't leak open errors */
errno = EPERM;
return -1;
}
-
- (void) fcntl(__clockctl_fd, F_SETFD, FD_CLOEXEC);
}
/*
-.\" $NetBSD: open.2,v 1.47 2010/09/22 17:58:09 wiz Exp $
+.\" $NetBSD: open.2,v 1.51 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
.\"
-.Dd September 22, 2010
+.Dd January 23, 2012
.Dt OPEN 2
.Os
.Sh NAME
.Sh SYNOPSIS
.In fcntl.h
.Ft int
-.Fn open "const char *path" "int flags" "mode_t mode"
+.Fn open "const char *path" "int flags" "..."
.Sh DESCRIPTION
The file name specified by
.Fa path
the values listed below.
Applications must specify exactly one of the first three values
(file access methods):
-.Bl -tag -offset indent -width O_NONBLOCK
+.Bl -tag -offset indent -width O_DIRECTORY
.It Dv O_RDONLY
Open for reading only.
.It Dv O_WRONLY
.El
.Pp
Any combination of the following may be used:
-.Bl -tag -offset indent -width O_NONBLOCK
+.Bl -tag -offset indent -width O_DIRECTORY
.It Dv O_NONBLOCK
Do not block on open or for data to become available.
.It Dv O_APPEND
Append to the file on each write.
.It Dv O_CREAT
-Create the file if it does not exist, in which case the file is
-created with mode
-.Ar mode
-as described in
+Create the file if it does not exist.
+The third argument of type
+.Ft mode_t
+is used to compute the mode bits of the file as described in
.Xr chmod 2
and modified by the process' umask value (see
.Xr umask 2 ) .
If last path element is a symlink, don't follow it.
This option is provided for compatibility with other operating
systems, but its security value is questionable.
+.It Dv O_CLOEXEC
+Set the
+.Xr close 2
+on
+.Xr exec 3
+flag.
+.It Dv O_NOSIGPIPE
+Return
+.Er EPIPE
+instead of raising
+.Dv SIGPIPE .
.It Dv O_DSYNC
If set, write operations will be performed according to synchronized
I/O data integrity completion:
element of the request must meet the above alignment constraints.
.It Dv O_DIRECTORY
Fail if the file is not a directory.
+.It Dv O_ASYNC
+Enable the
+.Dv SIGIO
+signal to be sent to the process group
+when I/O is possible, e.g.,
+upon availability of data to be read.
.El
.Pp
Opening a file with
-.\" $NetBSD: pipe.2,v 1.22 2004/05/13 10:20:58 wiz Exp $
+.\" $NetBSD: pipe.2,v 1.28 2012/01/25 00:28:35 christos Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)pipe.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd July 17, 1994
+.Dd January 23, 2012
.Dt PIPE 2
.Os
.Sh NAME
.In unistd.h
.Ft int
.Fn pipe "int fildes[2]"
+.Ft int
+.Fn pipe2 "int fildes[2]" "int flags"
.Sh DESCRIPTION
The
.Fn pipe
Widowing a pipe is the only way to deliver end-of-file to a reader:
after the reader consumes any buffered data, reading a widowed pipe
returns a zero count.
+.Pp
+The
+.Fn pipe2
+function
+behaves exactly like
+.Fn pipe
+only it allows extra
+.Fa flags
+to be set on the returned file descriptor.
+The following flags are valid:
+.Bl -tag -width O_NONBLOCK -offset indent
+.It Dv O_CLOEXEC
+Set the
+.Dq close-on-exec
+property.
+.It Dv O_NONBLOCK
+Sets non-blocking I/O.
+.It Dv O_NOSIGPIPE
+Return
+.Er EPIPE
+instead of raising
+.Dv SIGPIPE .
+.El
.Sh RETURN VALUES
On successful creation of the pipe, zero is returned.
Otherwise, a value of \-1 is returned and the variable
.Sh ERRORS
The
.Fn pipe
-call will fail if:
+and
+.Fn pipe2
+calls will fail if:
.Bl -tag -width Er
-.It Bq Er EMFILE
-Too many descriptors are active.
-.It Bq Er ENFILE
-The system file table is full.
.It Bq Er EFAULT
The
.Fa fildes
The reliable detection of this error cannot be guaranteed; when not
detected, a signal may be delivered to the process, indicating an
address violation.
+.It Bq Er EMFILE
+Too many descriptors are active.
+.It Bq Er ENFILE
+The system file table is full.
+.El
+.Pp
+.Fn pipe2
+will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa flags
+is other than
+.Dv O_NONBLOCK
+or
+.Dv O_CLOEXEC .
.El
.Sh SEE ALSO
.Xr sh 1 ,
.Fn pipe
function call appeared in
.At v6 .
+The
+.Fn pipe2
+function is inspired from Linux and appeared in
+.Nx 6.0 .
-/* $NetBSD: preadv.c,v 1.6 2007/11/23 12:39:15 uebayasi Exp $ */
+/* $NetBSD: preadv.c,v 1.7 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: preadv.c,v 1.6 2007/11/23 12:39:15 uebayasi Exp $");
+__RCSID("$NetBSD: preadv.c,v 1.7 2012/03/20 16:26:12 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-preadv(fd, iovp, iovcnt, offset)
- int fd;
- const struct iovec *iovp;
- int iovcnt;
- off_t offset;
+preadv(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
{
return __preadv(fd, iovp, iovcnt, 0, offset);
-.\" $NetBSD: ptrace.2,v 1.34 2010/04/14 08:57:21 jruoho Exp $
+.\" $NetBSD: ptrace.2,v 1.35 2011/08/31 23:04:33 jmcneill Exp $
.\"
.\" This file is in the public domain.
-.Dd April 14, 2010
+.Dd August 31, 2011
.Dt PTRACE 2
.Os
.Sh NAME
.Dq Li "sizeof(struct ptrace_lwpinfo)" .
.It Dv PT_SYSCALL
Stops a process before and after executing each system call.
+.It Dv PT_SYSCALLEMU
+Intercept and ignore a system call before it has been executed, for use with
+.Dv PT_SYSCALL .
.El
.Pp
Additionally, the following requests exist but are
-/* $NetBSD: pwritev.c,v 1.6 2007/11/23 12:39:16 uebayasi Exp $ */
+/* $NetBSD: pwritev.c,v 1.7 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pwritev.c,v 1.6 2007/11/23 12:39:16 uebayasi Exp $");
+__RCSID("$NetBSD: pwritev.c,v 1.7 2012/03/20 16:26:12 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-pwritev(fd, iovp, iovcnt, offset)
- int fd;
- const struct iovec *iovp;
- int iovcnt;
- off_t offset;
+pwritev(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
{
return __pwritev(fd, iovp, iovcnt, 0, offset);
+++ /dev/null
-.\" $NetBSD: quotactl.2,v 1.26 2010/05/31 12:16:20 njoly Exp $
-.\"
-.\" Copyright (c) 1983, 1990, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Robert Elz at The University of Melbourne.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)quotactl.2 8.2 (Berkeley) 3/10/95
-.\"
-.Dd October 9, 2008
-.Dt QUOTACTL 2
-.Os
-.Sh NAME
-.Nm quotactl
-.Nd manipulate filesystem quotas
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In ufs/ufs/quota.h
-.Ft int
-.Fn quotactl "const char *path" "int cmd" "int id" "void *addr"
-.Sh DESCRIPTION
-The
-.Fn quotactl
-call enables, disables and
-manipulates filesystem quotas.
-A quota control command
-given by
-.Fa cmd
-operates on the given filename
-.Fa path
-for the given user
-.Fa id .
-The address of an optional command specific data structure,
-.Fa addr ,
-may be given; its interpretation
-is discussed below with each command.
-.Pp
-Currently quotas are supported only for the ``ffs''
-and ``lfs'' filesystem.
-For both of them,
-a command is composed of a primary command (see below)
-and a command type used to interpret the
-.Fa id .
-Types are supported for interpretation of user identifiers
-and group identifiers.
-The ``ffs'' and ``lfs'' specific commands are:
-.Bl -tag -width Q_QUOTAON
-.It Dv Q_QUOTAON
-Enable disk quotas for the filesystem specified by
-.Fa path .
-The command type specifies the type of the quotas being enabled.
-The
-.Fa addr
-argument specifies a file from which to take the quotas.
-The quota file must exist;
-it is normally created with the
-.Xr quotacheck 8
-program.
-The
-.Fa id
-argument is unused.
-Only the super-user may turn quotas on.
-.It Dv Q_QUOTAOFF
-Disable disk quotas for the filesystem specified by
-.Fa path .
-The command type specifies the type of the quotas being disabled.
-The
-.Fa addr
-and
-.Fa id
-arguments are unused.
-Only the super-user may turn quotas off.
-.It Dv Q_GETQUOTA
-Get disk quota limits and current usage for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-.Fa addr
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-.It Dv Q_SETQUOTA
-Set disk quota limits for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-.Fa addr
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-The usage fields of the
-.Fa dqblk
-structure are ignored.
-This call is restricted to the super-user.
-.It Dv Q_SETUSE
-Set disk usage for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-.Fa addr
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-Only the usage fields are used.
-This call is restricted to the super-user.
-.It Dv Q_SYNC
-Update the on-disk copy of quota usages.
-The command type specifies which type of quotas are to be updated.
-The
-.Fa id
-and
-.Fa addr
-parameters are ignored.
-.El
-.Sh RETURN VALUES
-A successful call returns 0,
-otherwise the value \-1 is returned and the global variable
-.Va errno
-indicates the reason for the failure.
-.Sh ERRORS
-A
-.Fn quotactl
-call will fail if:
-.Bl -tag -width Er
-.It Bq Er EOPNOTSUPP
-The kernel has not been compiled with the
-.Dv QUOTA
-option.
-.It Bq Er EUSERS
-The quota table cannot be expanded.
-.It Bq Er EINVAL
-.Fa cmd
-or the command type is invalid.
-.It Bq Er EACCES
-In
-.Dv Q_QUOTAON ,
-the quota file is not a plain file, or
-search permission is denied for a component of a path prefix.
-.It Bq Er ENOTDIR
-A component of a path prefix was not a directory.
-.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
-A filename does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating a pathname.
-.It Bq Er EROFS
-In
-.Dv Q_QUOTAON ,
-the quota file resides on a read-only filesystem.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing
-to a file containing quotas.
-.It Bq Er EFAULT
-.Fa path
-points outside the process's allocated address space, or
-an invalid
-.Fa addr
-was supplied; the associated structure could not be copied in or out
-of the kernel.
-.It Bq Er EPERM
-The call was privileged and the caller was not the super-user.
-.El
-.Sh SEE ALSO
-.Xr quota 1 ,
-.Xr fstab 5 ,
-.Xr edquota 8 ,
-.Xr quotacheck 8 ,
-.Xr quotaon 8 ,
-.Xr repquota 8
-.Sh HISTORY
-The
-.Fn quotactl
-function call appeared in
-.Bx 4.3 Reno .
-.Sh BUGS
-There should be some way to integrate this call with the resource
-limit interface provided by
-.Xr setrlimit 2
-and
-.Xr getrlimit 2 .
-.\" $NetBSD: read.2,v 1.33 2010/04/05 07:53:47 wiz Exp $
+.\" $NetBSD: read.2,v 1.34 2011/12/12 19:11:21 njoly Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)read.2 8.4 (Berkeley) 2/26/94
.\"
-.Dd April 3, 2010
+.Dd December 12, 2011
.Dt READ 2
.Os
.Sh NAME
return value.
.It Bq Er EIO
An I/O error occurred while reading from the file system.
+.It Bq Er EISDIR
+.Fa d
+refers to a directory and the implementation does not allow the directory
+to be read using
+.Fn read
+or
+.Fn pread .
+The
+.Fn readdir
+function should be used instead.
.El
.Pp
In addition,
-.\" $NetBSD: recv.2,v 1.27 2006/04/23 19:06:59 wiz Exp $
+.\" $NetBSD: recv.2,v 1.35 2012/06/23 05:47:50 dholland Exp $
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)recv.2 8.3 (Berkeley) 2/21/94
.\"
-.Dd April 23, 2006
+.Dd June 22, 2012
.Dt RECV 2
.Os
.Sh NAME
.Nm recv ,
.Nm recvfrom ,
-.Nm recvmsg
+.Nm recvmsg ,
+.Nm recvmmsg
.Nd receive a message from a socket
.Sh LIBRARY
.Lb libc
.Fn recvfrom "int s" "void * restrict buf" "size_t len" "int flags" "struct sockaddr * restrict from" "socklen_t * restrict fromlen"
.Ft ssize_t
.Fn recvmsg "int s" "struct msghdr *msg" "int flags"
+.Ft int
+.Fn recvmmsg "int s" "struct mmsghdr *mmsg" "unsigned int vlen" "unsigned int flags" "struct timespec *timeout"
.Sh DESCRIPTION
-.Fn recvfrom
-and
+.Fn recvfrom ,
.Fn recvmsg
+and
+.Fn recvmmsg
are used to receive messages from a socket,
and may be used to receive data on a socket whether or not
it is connection-oriented.
address stored there.
.Pp
The
+.Fn recvmmsg
+call be used to receive multiple messages in the same call using an array of
+.Fa mmsghdr
+elements with the following form, as defined in
+.Ao Pa sys/socket.h Ac :
+.Pp
+.Bd -literal
+struct mmsghdr {
+ struct msghdr msg_hdr; /* the message to be sent */
+ unsigned int msg_len; /* number of bytes received */
+};
+.Ed
+.Pp
+The
+.Fa msg_len
+member contains the number of bytes received for each
+.Fa msg_hdr
+member.
+The array has
+.Fa vlen
+elements, which is limited to
+.Dv 1024 .
+If there is an error, a number fewer than
+.Fa vlen
+may be returned, and the error may be retrieved using
+.Xr getsockopt 2
+with
+.Dv SO_ERROR .
+If the flag
+.Dv MSG_WAITFORONE
+is set in
+.Fa flags
+then the
+.Fn recvmmsg
+call will wait for one message, and set
+.Dv MSG_DONTWAIT
+for the rest.
+If the
+.Fa timeout
+parameter is not
+.Dv NULL ,
+then
+.Fn recvmmsg
+will return if that time is exceeded.
+.Pp
+The
.Fn recv
call is normally used only on a
.Em connected
parameter.
As it is redundant, it may not be supported in future releases.
.Pp
-All three routines return the length of the message on successful
+.Fn recv ,
+.Fn recvfrom
+and
+.Fn recvmsg
+routines return the length of the message on successful
completion.
+.Fn recvmmsg
+returns the number of messages received.
If a message is too long to fit in the supplied buffer,
excess bytes may be discarded depending on the type of socket
the message is received from (see
.Va errno
set to
.Er EAGAIN .
+If no data is available and the remote peer was shut down,
+0 is returned.
The receive calls normally return any data available,
up to the requested amount,
rather than waiting for receipt of the full amount requested;
argument to a recv call is formed by
.Em or Ap ing
one or more of the values:
-.Bl -column MSG_WAITALL -offset indent
+.Bl -column MSG_CMSG_CLOEXEC -offset indent
+.It Dv MSG_CMSG_CLOEXEC Ta set the close on exec property for passed file descriptors
.It Dv MSG_OOB Ta process out-of-band data
.It Dv MSG_PEEK Ta peek at incoming message
.It Dv MSG_WAITALL Ta wait for full request or error
.Dv MSG_OOB
is returned to indicate that expedited or out-of-band data were received.
.Sh RETURN VALUES
-These calls return the number of bytes received, or \-1
+The
+.Fn recv ,
+.Fn recvfrom
+and
+.Fn recvmsg
+calls return the number of bytes received, or \-1
+if an error occurred.
+For connected sockets whose remote peer was shut down,
+0 is returned when no more data is available.
+The
+.Fn recvmmsg
+calls return the number of messages received, or \-1
if an error occurred.
.Sh ERRORS
The calls fail if:
.Bl -tag -width Er
+.It Bq Er EAGAIN
+The socket is marked non-blocking, and the receive operation
+would block, or
+a receive timeout had been set,
+and the timeout expired before data were received.
.It Bq Er EBADF
The argument
.Fa s
is an invalid descriptor.
+.It Bq Er EFAULT
+The receive buffer pointer(s) point outside the process's
+address space.
+.It Bq Er EINTR
+The receive was interrupted by delivery of a signal before
+any data were available.
+.It Bq Er EINVAL
+The total length of the I/O is more than can be expressed by the ssize_t
+return value.
.It Bq Er ENOTCONN
The socket is associated with a connection-oriented protocol
and has not been connected (see
The argument
.Fa s
does not refer to a socket.
-.It Bq Er EAGAIN
-The socket is marked non-blocking, and the receive operation
-would block, or
-a receive timeout had been set,
-and the timeout expired before data were received.
-.It Bq Er EINTR
-The receive was interrupted by delivery of a signal before
-any data were available.
-.It Bq Er EFAULT
-The receive buffer pointer(s) point outside the process's
-address space.
-.It Bq Er EINVAL
-The total length of the I/O is more than can be expressed by the ssize_t
-return value.
.El
.Pp
.Fn recvmsg
.Fn recv
function call appeared in
.Bx 4.2 .
+The
+.Fn recvmmsg
+function call appeared in
+.Tn Linux 2.6.32
+and
+.Nx 7.0 .
-.\" $NetBSD: revoke.2,v 1.12 2003/08/07 16:44:05 agc Exp $
+.\" $NetBSD: revoke.2,v 1.15 2011/07/08 19:26:19 wiz Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)revoke.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd March 22, 1999
+.Dd July 3, 2011
.Dt REVOKE 2
.Os
.Sh NAME
.Fn revoke "const char *path"
.Sh DESCRIPTION
The
-.Nm revoke
+.Fn revoke
function invalidates all current open file descriptors in the system
for the file named by
.Fa path .
Subsequent operations on any such descriptors
fail, with the exceptions that a
-.Fn read
+.Xr read 2
from a character device file which has been revoked
returns a count of zero (end of file),
and a
-.Fn close
+.Xr close 2
call will succeed.
If the file is a special file for a device which is open,
the device close function
.Pp
Access to a file may be revoked only by its owner or the super user.
.Pp
-.Nm revoke
-is normally used to prepare a terminal device for a new login session,
+The
+.Fn revoke
+function is normally used to prepare a terminal device for a new login session,
preventing any access by a previous user of the terminal.
.Sh RETURN VALUES
A 0 value indicates that the call succeeded.
.Sh ERRORS
Access to the named file is revoked unless one of the following:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1024 characters.
-.It Bq Er ENOENT
-The named file or a component of the path name does not exist.
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
.It Bq Er EFAULT
.Fa path
points outside the process's allocated address space.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1024 characters.
+.It Bq Er ENOENT
+The named file or a component of the path name does not exist.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
.It Bq Er EPERM
The caller is neither the owner of the file nor the super user.
.El
.Xr write 2
.Sh HISTORY
The
-.Nm revoke
+.Fn revoke
function was introduced in
.Bx 4.3 Reno .
-/* $NetBSD: sched.c,v 1.2 2008/10/31 00:29:19 rmind Exp $ */
+/* $NetBSD: sched.c,v 1.4 2012/03/18 02:04:39 christos Exp $ */
/*
* Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: sched.c,v 1.2 2008/10/31 00:29:19 rmind Exp $");
+__RCSID("$NetBSD: sched.c,v 1.4 2012/03/18 02:04:39 christos Exp $");
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sched.h>
+#include <signal.h>
#include <sys/param.h>
#include <sys/types.h>
errno = EINVAL;
return -1;
}
- return sysconf(_SC_SCHED_PRI_MAX);
+ return (int)sysconf(_SC_SCHED_PRI_MAX);
}
int
errno = EINVAL;
return -1;
}
- return sysconf(_SC_SCHED_PRI_MIN);
+ return (int)sysconf(_SC_SCHED_PRI_MIN);
}
int
sched_rr_get_interval(pid_t pid, struct timespec *interval)
{
+ if (pid && kill(pid, 0) == -1)
+ return -1;
interval->tv_sec = 0;
interval->tv_nsec = sysconf(_SC_SCHED_RT_TS) * 1000;
return 0;
-.\" $NetBSD: send.2,v 1.27 2008/05/09 15:52:50 christos Exp $
+.\" $NetBSD: send.2,v 1.30 2012/06/22 22:54:26 wiz Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)send.2 8.2 (Berkeley) 2/21/94
.\"
-.Dd May 9, 2008
+.Dd June 22, 2012
.Dt SEND 2
.Os
.Sh NAME
.Nm send ,
.Nm sendto ,
-.Nm sendmsg
+.Nm sendmsg ,
+.Nm sendmmsg
.Nd send a message from a socket
.Sh LIBRARY
.Lb libc
.Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
.Ft ssize_t
.Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
+.Ft int
+.Fn sendmmsg "int s" "struct mmsghdr *mmsg" "unsigned int vlen" "unsigned int flags"
.Sh DESCRIPTION
.Fn send ,
.Fn sendto ,
+.Fn sendmsg ,
and
-.Fn sendmsg
+.Fn sendmmsg
are used to transmit a message to another socket.
.Fn send
may be used only when the socket is in a
.Em connected
state, while
-.Fn sendto
-and
+.Fn sendto ,
.Fn sendmsg
+and
+.Fn sendmmsg
may be used at any time.
.Pp
+The
+.Fn sendmmsg
+call be used to send multiple messages in the same call using an array of
+.Fa mmsghdr
+elements with the following form, as defined in
+.Ao Pa sys/socket.h Ac :
+.Pp
+.Bd -literal
+struct mmsghdr {
+ struct msghdr msg_hdr; /* the message to be sent */
+ unsigned int msg_len; /* number of bytes transmitted */
+};
+.Ed
+.Pp
+The
+.Fa msg_len
+member contains the number of bytes sent for each
+.Fa msg_hdr
+member.
+The array has
+.Fa vlen
+elements, which is limited to
+.Dv 1024 .
+If there is an error, a number fewer than
+.Fa vlen
+may be returned, and the error may be retrieved using
+.Xr getsockopt 2
+with
+.Dv SO_ERROR .
+.Pp
The address of the target is given by
.Fa to
with
.Xr poll 2
call may be used to determine when it is possible to
send more data.
+Unfortunately this does not work when the interface queue which is used to
+send the message is full, and the call returns
+.Er ENOBUFS .
.Pp
The
.Fa flags
generation when writing a socket that
may be closed.
.Sh RETURN VALUES
-The call returns the number of characters sent, or \-1
+The
+.Fn send ,
+.Fn sendto ,
+and
+.Fn sendmsg
+calls return the number of characters sent, or \-1
if an error occurred.
+The
+.Fn sendmmsg
+call returns the number of messages sent, or \-1
+if an error occured.
.Sh ERRORS
.Fn send ,
.Fn sendto ,
+.Fn sendmsg ,
and
-.Fn sendmsg
+.Fn sendmmsg
fail if:
.Bl -tag -width Er
+.It Bq Er EACCES
+The SO_BROADCAST option is not set on the socket, and a broadcast address
+was given as the destination.
+.It Bq Er EAFNOSUPPORT
+Addresses in the specified address family cannot be used with this socket.
+.It Bq Er EAGAIN|EWOULDBLOCK
+The socket is marked non-blocking and the requested operation
+would block.
.It Bq Er EBADF
An invalid descriptor was specified.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is not a socket.
+.It Bq Er EDSTADDRREQ
+In a non-connected socket a destination address has not been specified.
.It Bq Er EFAULT
An invalid user space address was specified for a parameter.
+.It Bq Er EHOSTDOWN
+The destination is a host on the local subnet and does not respond to
+.Xr arp 4 .
+.It Bq Er EHOSTUNREACH
+The destination for the message is unreachable.
+.It Bq Er EINVAL
+The total length of the I/O is more than can be expressed by the ssize_t
+return value.
.It Bq Er EMSGSIZE
The socket requires that message be sent atomically,
and the size of the message to be sent made this impossible.
-.It Bq Er EPIPE
-In a connected socket the connection has been broken.
-.It Bq Er EDSTADDRREQ
-In a non-connected socket a destination address has not been specified.
-.It Bq Er EAGAIN|EWOULDBLOCK
-The socket is marked non-blocking and the requested operation
-would block.
.It Bq Er ENOBUFS
The system was unable to allocate an internal buffer.
The operation may succeed when buffers become available.
-.It Bq Er ENOBUFS
-The output queue for a network interface was full.
+.Pp
+An alternative reason: the output queue for a network interface was full.
This generally indicates that the interface has stopped sending,
but may be caused by transient congestion.
-.It Bq Er EACCES
-The SO_BROADCAST option is not set on the socket, and a broadcast address
-was given as the destination.
-.It Bq Er EHOSTUNREACH
-The destination for the message is unreachable.
-.It Bq Er EHOSTDOWN
-The destination is a host on the local subnet and does not respond to
-.Xr arp 4 .
-.It Bq Er EINVAL
-The total length of the I/O is more than can be expressed by the ssize_t
-return value.
-.It Bq Er EAFNOSUPPORT
-Addresses in the specified address family cannot be used with this socket.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is not a socket.
+.It Bq Er EPIPE
+In a connected socket the connection has been broken.
.El
.Pp
.Fn sendto
.El
.Pp
.Fn sendmsg
+and
+.Fn sendmmsg
will also fail if:
.Bl -tag -width Er
.It Bq Er EMSGSIZE
.Fn send
function call appeared in
.Bx 4.2 .
+The
+.Fn sendmmsg
+function call appeared in
+.Tn Linux 3.0
+and
+.Nx 7.0 .
-.\" $NetBSD: setsid.2,v 1.14 2006/10/07 21:03:51 elad Exp $
+.\" $NetBSD: setsid.2,v 1.15 2011/04/04 08:00:53 jruoho Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)setsid.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd October 7, 2006
+.Dd April 4, 2011
.Dt SETSID 2
.Os
.Sh NAME
.Fn setsid "void"
.Sh DESCRIPTION
The
-.Nm setsid
+.Fn setsid
function creates a new session.
The calling process is the session leader of the new session, is the
process group leader of a new process group and has no controlling
process group.
.Pp
Upon successful completion, the
-.Nm setsid
+.Fn setsid
function returns the value of the process group ID of the new process
group, which is the same as the process ID of the calling process.
.Sh ERRORS
If an error occurs,
-.Nm setsid
+.Fn setsid
returns \-1 and the global variable
.Va errno
is set to indicate the error, as follows:
.Xr tcsetpgrp 3
.Sh STANDARDS
The
-.Nm setsid
+.Fn setsid
function conforms to
.St -p1003.1-90 .
-/* $NetBSD: settimeofday.c,v 1.13 2009/01/11 02:46:30 christos Exp $ */
+/* $NetBSD: settimeofday.c,v 1.14 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: settimeofday.c,v 1.13 2009/01/11 02:46:30 christos Exp $");
+__RCSID("$NetBSD: settimeofday.c,v 1.14 2011/10/15 23:00:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <time.h>
#include <unistd.h>
+#if defined(__minix) && !defined(O_CLOEXEC)
+#define O_CLOEXEC 0
+#endif
+
int __clockctl_fd = -1;
int ____settimeofday50(const struct timeval *, const void *);
if (rv != -1 || errno != EPERM)
return rv;
- __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY, 0);
+ __clockctl_fd = open(_PATH_CLOCKCTL, O_WRONLY | O_CLOEXEC, 0);
if (__clockctl_fd == -1) {
/* original error was EPERM - don't leak open errors */
errno = EPERM;
return -1;
}
-
- (void) fcntl(__clockctl_fd, F_SETFD, FD_CLOEXEC);
}
/*
-.\" $NetBSD: sigaction.2,v 1.43 2006/06/03 18:23:52 christos Exp $
+.\" $NetBSD: sigaction.2,v 1.44 2012/10/14 08:49:28 dholland Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.El
.Pp
Only functions that are async-signal-safe can safely be used in signal
-handlers, see
+handlers; see
.Xr signal 7
for a complete list.
.Sh NOTES
-.\" $NetBSD: sigaltstack.2,v 1.22 2009/04/16 18:37:29 wiz Exp $
+.\" $NetBSD: sigaltstack.2,v 1.23 2012/03/02 18:07:17 joerg Exp $
.\"
.\" Copyright (c) 1983, 1991, 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)sigaltstack.2 8.2 (Berkeley) 5/1/95
.\"
-.Dd April 16, 2009
+.Dd March 2, 2012
.Dt SIGALTSTACK 2
.Os
.Sh NAME
.Fn sigstack
system call, appeared in
.Bx 4.2 .
-.Sh CAVEATS
-Due to limitations in the current pthread implementation,
-.Nm
-should not be used in programs which link against the
-.Xr pthread 3
-library (whether threads are used or not).
-.\" $NetBSD: sigtimedwait.2,v 1.7 2010/05/31 11:02:24 drochner Exp $
+.\" $NetBSD: sigtimedwait.2,v 1.8 2012/04/02 22:06:47 agc Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 30, 2010
+.Dd April 2, 2012
.Dt SIGTIMEDWAIT 2
.Os
.Sh NAME
Upon successful completion of
.Fn sigwait
.Fa sig
-is updated with ihe signal number, and the function returns 0.
-Otherwise, a non-zero error code is returned,
+is updated with the signal number, and the function returns 0.
+Otherwise, a non-zero error code is returned.
.Sh ERRORS
.Fn sigwaitinfo
and
-/* $NetBSD: sigwait.c,v 1.4 2010/05/31 11:02:24 drochner Exp $ */
+/* $NetBSD: sigwait.c,v 1.5 2012/03/20 16:26:12 matt Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sigwait.c,v 1.4 2010/05/31 11:02:24 drochner Exp $");
+__RCSID("$NetBSD: sigwait.c,v 1.5 2012/03/20 16:26:12 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(sigwait,_sigwait)
#endif
-int _sigwait __P((const sigset_t * __restrict, int * __restrict));
+int _sigwait(const sigset_t * __restrict, int * __restrict);
/*
* This is wrapper around sigtimedwait(2), providing sigwait()
-/* $NetBSD: sigwaitinfo.c,v 1.2 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: sigwaitinfo.c,v 1.3 2012/03/20 16:26:12 matt Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sigwaitinfo.c,v 1.2 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: sigwaitinfo.c,v 1.3 2012/03/20 16:26:12 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
__weak_alias(sigwaitinfo,_sigwaitinfo)
#endif
-int _sigwaitinfo __P((const sigset_t * __restrict,
- siginfo_t * __restrict info));
+int _sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict info);
/*
* This is wrapper around sigtimedwait(2), providing sigwaitinfo()
-.\" $NetBSD: socket.2,v 1.36 2007/09/06 09:32:52 jnemeth Exp $
+.\" $NetBSD: socket.2,v 1.39 2012/01/25 09:18:52 wiz Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)socket.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd September 6, 2007
+.Dd January 23, 2012
.Dt SOCKET 2
.Os
.Sh NAME
SOCK_RDM
.Ed
.Pp
+The following flags can be or'ed to the type to condition the returned
+file descriptor:
+The following flags are valid:
+.Bl -column SOCK_NONBLOCK -offset indent
+.It Dv SOCK_CLOEXEC
+Set the close on exec property.
+.It Dv SOCK_NONBLOCK
+Sets non-blocking I/O.
+.It Dv SOCK_NOSIGPIPE
+Return
+.Er EPIPE
+instead of raising
+.Dv SIGPIPE .
+.El
+.Pp
A
.Dv SOCK_STREAM
type provides sequenced, reliable,
-.\" $NetBSD: socketpair.2,v 1.21 2009/12/20 02:16:40 wiz Exp $
+.\" $NetBSD: socketpair.2,v 1.23 2011/06/27 08:21:08 wiz Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd December 20, 2009
+.Dd June 24, 2011
.Dt SOCKETPAIR 2
.Os
.Sh NAME
.Fa protocol .
The descriptors used in referencing the new sockets
are returned in
-.Fa sv Ns [0]
+.Fa sv[0]
and
-.Fa sv Ns [1] .
+.Fa sv[1] .
The two sockets are indistinguishable.
+.Pp
+The
+.Fa type
+and
+.Fa protocol
+argument values are described in
+.Xr socket 2 .
.Sh RETURN VALUES
A 0 is returned if the call succeeds, \-1 if it fails.
.Sh ERRORS
.Sh SEE ALSO
.Xr pipe 2 ,
.Xr read 2 ,
+.Xr socket 2 ,
.Xr write 2
.Sh HISTORY
The
-.\" $NetBSD: stat.2,v 1.47 2010/11/25 20:53:23 dholland Exp $
+.\" $NetBSD: stat.2,v 1.50 2012/01/04 10:53:39 wiz Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)stat.2 8.4 (Berkeley) 5/1/95
.\"
-.Dd November 25, 2010
+.Dd September 14, 2011
.Dt STAT 2
.Os
.Sh NAME
.It Vt time_t Ta st_mtime Ta time of last data modification
.It Vt time_t Ta st_ctime Ta time of last file status change
.It Vt blksize_t Ta st_blksize Ta preferred I/O block size (fs-specific)
-.It Vt blkcnt_t Ta st_block Ta blocks allocated for the file
+.It Vt blkcnt_t Ta st_blocks Ta blocks allocated for the file
.El
.Pp
These are specified in the
.Va st_ino
and
.Va st_dev
-fields taken together to uniquely identify the file within the system.
+fields taken together uniquely identify the file within the system.
Most of the types are defined in
.Xr types 3 .
.Pp
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
.It Bq Er EBADF
-A badly formed v-node was encountered.
+A badly formed vnode was encountered.
This can happen if a file system information node is incorrect.
.It Bq Er EFAULT
.Fa sb
-.\" $NetBSD: swapctl.2,v 1.37 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: swapctl.2,v 1.38 2011/04/28 11:58:50 wiz Exp $
.\"
.\" Copyright (c) 1997 Matthew R. Green
.\" All rights reserved.
.Fn swapctl
succeeds unless:
.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.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 device does not exist.
-For the
-.Dv SWAP_CTL
-command, the named device is not currently enabled for swapping.
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The caller is not the super-user.
.It Bq Er EBUSY
The device specified by
.Fa arg
has already been made available for swapping.
+.It Bq Er EFAULT
+.Fa arg
+points outside the process' allocated address space.
.It Bq Er EINVAL
The device configured by
.Fa arg
has no associated size, or the
.Fa cmd
was unknown.
+.It Bq Er EIO
+An I/O error occurred while opening the swap device.
+.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 device does not exist.
+For the
+.Dv SWAP_CTL
+command, the named device is not currently enabled for swapping.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
.It Bq Er ENXIO
The major device number of
.Fa arg
is out of range (this indicates no device driver exists
-for the associated hardware).
-.It Bq Er ENXIO
-The block device specified by
+for the associated hardware); or
+the block device specified by
.Fa arg
is not marked as a swap partition in the disklabel.
-.It Bq Er EIO
-An I/O error occurred while opening the swap device.
-.It Bq Er EFAULT
-.Fa arg
-points outside the process' allocated address space.
+.It Bq Er EPERM
+The caller is not the super-user.
.El
.Sh SEE ALSO
.Xr swapctl 8
-/* $NetBSD: swapon.c,v 1.10 2008/05/29 14:51:25 mrg Exp $ */
+/* $NetBSD: swapon.c,v 1.11 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1997 Matthew R. Green
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: swapon.c,v 1.10 2008/05/29 14:51:25 mrg Exp $");
+__RCSID("$NetBSD: swapon.c,v 1.11 2012/06/25 22:32:46 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <unistd.h>
int
-swapon(name)
- const char *name;
+swapon(const char *name)
{
return (swapctl(SWAP_ON, __UNCONST(name), 0));
-/* $NetBSD: truncate.c,v 1.12 2007/11/23 12:39:16 uebayasi Exp $ */
+/* $NetBSD: truncate.c,v 1.13 2012/03/20 16:26:12 matt Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)truncate.c 8.1 (Berkeley) 6/17/93";
#else
-__RCSID("$NetBSD: truncate.c,v 1.12 2007/11/23 12:39:16 uebayasi Exp $");
+__RCSID("$NetBSD: truncate.c,v 1.13 2012/03/20 16:26:12 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
int
-truncate(path, length)
- const char *path;
- off_t length;
+truncate(const char *path, off_t length)
{
return __truncate(path, 0, length);
-.\" $NetBSD: utimes.2,v 1.26 2010/04/29 17:02:38 jruoho Exp $
+.\" $NetBSD: utimes.2,v 1.30 2011/10/25 09:26:53 wiz Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)utimes.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd April 29, 2010
+.Dd August 17, 2011
.Dt UTIMES 2
.Os
.Sh NAME
.Nm utimes ,
.Nm lutimes ,
-.Nm futimes
+.Nm futimes ,
+.Nm futimens ,
+.Nm utimensat
.Nd set file access and modification times
.Sh LIBRARY
.Lb libc
.Fn lutimes "const char *path" "const struct timeval times[2]"
.Ft int
.Fn futimes "int fd" "const struct timeval times[2]"
+.Ft int
+.Fn futimens "int fd" "const struct timespec times[2]"
+.Ft int
+.Fn utimensat "int fd" "const char *path" "const struct timespec times[2]" "int flag"
.Sh DESCRIPTION
The access and modification times of the file named by
.Fa path
while
.Fn utimes
changes the times of the file the link references.
+.Pp
+.Fn futimens
+is like
+.Fn futimes
+except that time is specified with nanosecond instead of microseconds.
+.Pp
+.Fn utimensat
+also allows time to be specifed with nanoseconds.
+When it operates on a symbolic link, it will change the target's time if
+.Ar follow
+is unset.
+If
+.Ar follow
+is set to
+.Dv AT_SYMLINK_NOFOLLOW ,
+the symbolic link's dates are changed.
+.Pp
+The nanosecond fields for
+.Fn futimens
+and
+.Fn utimensat
+can be set to the special value
+.Dv UTIME_NOW
+to set the current time, or to
+.Dv UTIME_OMIT
+to let the time unchanged (this allows changing access time but not
+modification time, and vice-versa).
+.Pp
+.Fn utimensat
+is partially implemented.
+It will return
+.Er ENOSYS
+for
+.Fa fd
+values different than
+.Dv AT_FDCWD .
.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 utimes
+.Fn utimes ,
+.Fn lutimes ,
and
-.Fn lutimes
+.Fn utimensat
will fail if:
.Bl -tag -width Er
.It Bq Er EACCES
.El
.Pp
.Fn futimes
+and
+.Fn futimens
will fail if:
.Bl -tag -width Er
.It Bq Er EACCES
It was however marked as legacy in the
.St -p1003.1-2004
revision.
+.Fn futimens
+and
+.Fn utimensat
+functions conform to
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn utimes
.Nx 1.3 .
Birthtime setting support was added in
.Nx 5.0 .
+.Fn futimens
+and
+.Fn utimensat
+functions calls appreared in
+.Nx 6.0 .
+.Sh BUGS
+.Fn utimensat
+is partially implemented.
SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c
-.endif
-
-
+.endif # defined(__MINIX)
MAN+= tcgetpgrp.3 tcgetsid.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3
-/* $NetBSD: cfgetispeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $ */
+/* $NetBSD: cfgetispeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfgetispeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $");
+__RCSID("$NetBSD: cfgetispeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
speed_t
-cfgetispeed(t)
- const struct termios *t;
+cfgetispeed(const struct termios *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: cfgetospeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $ */
+/* $NetBSD: cfgetospeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfgetospeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $");
+__RCSID("$NetBSD: cfgetospeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
speed_t
-cfgetospeed(t)
- const struct termios *t;
+cfgetospeed(const struct termios *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: cfmakeraw.c,v 1.9 2003/08/07 16:44:12 agc Exp $ */
+/* $NetBSD: cfmakeraw.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfmakeraw.c,v 1.9 2003/08/07 16:44:12 agc Exp $");
+__RCSID("$NetBSD: cfmakeraw.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
* mode with no characters interpreted, 8-bit data path.
*/
void
-cfmakeraw(t)
- struct termios *t;
+cfmakeraw(struct termios *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: cfsetispeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $ */
+/* $NetBSD: cfsetispeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfsetispeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $");
+__RCSID("$NetBSD: cfsetispeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-cfsetispeed(t, speed)
- struct termios *t;
- speed_t speed;
+cfsetispeed(struct termios *t, speed_t speed)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: cfsetospeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $ */
+/* $NetBSD: cfsetospeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfsetospeed.c,v 1.7 2003/08/07 16:44:12 agc Exp $");
+__RCSID("$NetBSD: cfsetospeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-cfsetospeed(t, speed)
- struct termios *t;
- speed_t speed;
+cfsetospeed(struct termios *t, speed_t speed)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: cfsetspeed.c,v 1.7 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: cfsetspeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: cfsetspeed.c,v 1.7 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: cfsetspeed.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-cfsetspeed(t, speed)
- struct termios *t;
- speed_t speed;
+cfsetspeed(struct termios *t, speed_t speed)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: tcdrain.c,v 1.8 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: tcdrain.c,v 1.9 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcdrain.c,v 1.8 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: tcdrain.c,v 1.9 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-tcdrain(fd)
- int fd;
+tcdrain(int fd)
{
_DIAGASSERT(fd != -1);
-/* $NetBSD: tcflow.c,v 1.8 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: tcflow.c,v 1.9 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcflow.c,v 1.8 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: tcflow.c,v 1.9 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-tcflow(fd, action)
- int fd, action;
+tcflow(int fd, int action)
{
#ifdef __minix
_DIAGASSERT(fd != -1);
-/* $NetBSD: tcflush.c,v 1.9 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: tcflush.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcflush.c,v 1.9 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: tcflush.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-tcflush(fd, which)
- int fd, which;
+tcflush(int fd, int which)
{
#ifdef __minix
_DIAGASSERT(fd != -1);
-/* $NetBSD: tcgetattr.c,v 1.9 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: tcgetattr.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcgetattr.c,v 1.9 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: tcgetattr.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-tcgetattr(fd, t)
- int fd;
- struct termios *t;
+tcgetattr(int fd, struct termios *t)
{
_DIAGASSERT(t != NULL);
-/* $NetBSD: tcgetpgrp.c,v 1.9 2004/12/01 21:37:15 dsl Exp $ */
+/* $NetBSD: tcgetpgrp.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcgetpgrp.c,v 1.9 2004/12/01 21:37:15 dsl Exp $");
+__RCSID("$NetBSD: tcgetpgrp.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
pid_t
-tcgetpgrp(fd)
- int fd;
+tcgetpgrp(int fd)
{
int s;
-/* $NetBSD: tcgetsid.c,v 1.6 2003/08/07 16:44:13 agc Exp $ */
+/* $NetBSD: tcgetsid.c,v 1.7 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcgetsid.c,v 1.6 2003/08/07 16:44:13 agc Exp $");
+__RCSID("$NetBSD: tcgetsid.c,v 1.7 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
pid_t
-tcgetsid(fd)
- int fd;
+tcgetsid(int fd)
{
int s;
-/* $NetBSD: tcsendbreak.c,v 1.9 2003/08/07 16:44:14 agc Exp $ */
+/* $NetBSD: tcsendbreak.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcsendbreak.c,v 1.9 2003/08/07 16:44:14 agc Exp $");
+__RCSID("$NetBSD: tcsendbreak.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/*ARGSUSED*/
int
-tcsendbreak(fd, len)
- int fd, len;
+tcsendbreak(int fd, int len)
{
#ifdef __minix
_DIAGASSERT(fd != -1);
-/* $NetBSD: tcsetattr.c,v 1.8 2003/08/07 16:44:14 agc Exp $ */
+/* $NetBSD: tcsetattr.c,v 1.9 2012/06/25 22:32:46 abs Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: tcsetattr.c,v 1.8 2003/08/07 16:44:14 agc Exp $");
+__RCSID("$NetBSD: tcsetattr.c,v 1.9 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif
int
-tcsetattr(fd, opt, t)
- int fd, opt;
- const struct termios *t;
+tcsetattr(int fd, int opt, const struct termios *t)
{
#ifndef __minix
struct termios localterm;
-/* $NetBSD: thread-stub.c,v 1.21 2009/01/30 23:21:03 ad Exp $ */
+/* $NetBSD: thread-stub.c,v 1.22 2011/09/16 16:05:59 joerg Exp $ */
/*-
* Copyright (c) 2003, 2009 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: thread-stub.c,v 1.21 2009/01/30 23:21:03 ad Exp $");
+__RCSID("$NetBSD: thread-stub.c,v 1.22 2011/09/16 16:05:59 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
/*
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 void __libc_thr_exit_stub(void *);
int *__libc_thr_errno_stub(void);
int __libc_thr_setcancelstate_stub(int, int *);
int __libc_thr_equal_stub(pthread_t, pthread_t);
# <pre>
-# @(#)Makefile 8.8
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
+# Version numbers of the code and data distributions.
+VERSION = 2012e
+
# Change the line below for your time zone (after finding the zone you want in
# the time zone files, or adding it to a time zone file).
# Alternately, if you discover you've got the wrong time zone, you can just
# make zonenames
# to get a list of the values you can use for LOCALTIME.
-LOCALTIME= Factory
+LOCALTIME= GMT
# If you want something other than Eastern United States time as a template
# for handling POSIX-style time zone environment variables,
# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
# if you do not want run time warnings about formats that may cause
# year 2000 grief
+# -DNO_ERROR_IN_DST_GAP=1
+# if you want mktime() not to return an error in the DST gap.
# -DZIC_MAX_ABBR_LEN_WO_WARN=3
# (or some other number) to set the maximum time zone abbreviation length
# that zic will accept without a warning (the default is 6)
-GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
+GCC_DEBUG_FLAGS = -Dlint -g -O3 -fno-common \
-Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
-Wnested-externs -Wpointer-arith -Wshadow \
-Wtraditional # -Wstrict-prototypes -Wwrite-strings
AWK= nawk
# The path where SGML DTDs are kept.
-SGML_SEARCH_PATH= $(TOPDIR)/share/doc/sgml-lib/REC-html401-19991224/
+# The default is appropriate for Ubuntu.
+SGML_TOPDIR= /usr
+SGML_SEARCH_PATH= $(SGML_TOPDIR)/share/xml/xhtml/schema/dtd/REC-html401-19991224
# The catalog file(s) to use when validating.
SGML_CATALOG_FILES= HTML4.cat
SP_CHARSET_FIXED=YES \
SP_ENCODING=UTF-8
+# Flags to give 'tar' when making a distribution.
+# Try to use flags appropriate for GNU tar.
+GNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w
+TARFLAGS= `if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
+ then echo $(GNUTARFLAGS); \
+ else :; \
+ fi`
+
+# Flags to give 'gzip' when making a distribution.
+GZIPFLAGS= -9n
+
###############################################################################
cc= cc
DOCS= README Theory $(MANS) date.1 Makefile
PRIMARY_YDATA= africa antarctica asia australasia \
europe northamerica southamerica
-YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
-NDATA= systemv
+YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward
+NDATA= systemv factory
SDATA= solar87 solar88 solar89
TDATA= $(YDATA) $(NDATA) $(SDATA)
TABDATA= iso3166.tab zone.tab
DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
WEB_PAGES= tz-art.htm tz-link.htm
MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
- itca.jpg $(WEB_PAGES) checktab.awk workman.sh \
+ $(WEB_PAGES) checktab.awk workman.sh \
zoneinfo2tdf.pl
ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
-rm -f $(MANDIR)/man1/date.1
cp date.1 $(MANDIR)/man1/.
+version.h:
+ echo >$@ \
+ 'static char const TZVERSION[]="tz$(VERSION)";'
+
zdump: $(TZDOBJS)
$(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
sed \
-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
+ -e 's|\(TZVERSION\)=.*|\1=tz$(VERSION)|' \
<$? >$@
chmod +x $@
$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
clean:
- rm -f core *.o *.out tzselect zdump zic yearistype date
+ rm -f core *.o *.out \
+ date tzselect version.h zdump zic yearistype
maintainer-clean: clean
@echo 'This command is intended for maintainers to use; it'
@echo 'deletes files that may need special tools to rebuild.'
- rm -f *.[1-8].txt tzcode.tar.gz tzdata.tar.gz
+ rm -f *.[1-8].txt tzcode*.tar.gz tzdata*.tar.gz
names:
@echo $(ENCHILADA)
+# Set the time stamps to those of the git repository, if available,
+# and if the files have not changed since then.
+# This uses GNU 'touch' syntax 'touch -d@N FILE',
+# where N is the number of seconds since 1970.
+# If git or GNU 'touch' is absent, do nothing.
+set-timestamps:
+ -TZ=UTC0 && export TZ && files=`git ls-files` && \
+ touch -d @1 test.out && rm -f test.out && \
+ for file in $$files; do \
+ test -z "`git diff --name-only $$file`" || continue; \
+ cmd="touch -d @`git log -1 --format='format:%ct' $$file \
+ ` $$file" && \
+ echo "$$cmd" && \
+ $$cmd || exit; \
+ done
+
# The zics below ensure that each data file can stand on its own.
# We also do an all-files run to catch links to links.
-public: $(ENCHILADA)
+public: $(ENCHILADA) set-timestamps
make maintainer-clean
make "CFLAGS=$(GCC_DEBUG_FLAGS)"
- -mkdir /tmp/,tzpublic
+ mkdir -m go-rwx /tmp/,tzpublic
-for i in $(TDATA) ; do zic -v -d /tmp/,tzpublic $$i 2>&1 | grep -v "starting year" ; done
for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i || exit; done
zic -v -d /tmp/,tzpublic $(TDATA) || exit
rm -f -r /tmp/,tzpublic
- for i in *.[1-8] ; do sh workman.sh $$i > $$i.txt || exit; done
+ for i in *.[1-8] ; do \
+ LC_ALL=C sh workman.sh $$i > $$i.txt && \
+ touch -r $$i $$i.txt || exit; \
+ done
$(AWK) -f checktab.awk $(PRIMARY_YDATA)
- tar cf - $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | gzip -9 > tzcode.tar.gz
- tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
+ LC_ALL=C && export LC_ALL && \
+ tar $(TARFLAGS) -cf - $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | \
+ gzip $(GZIPFLAGS) > tzcode$(VERSION).tar.gz
+ LC_ALL=C && export LC_ALL && \
+ tar $(TARFLAGS) -cf - $(DATA) | \
+ gzip $(GZIPFLAGS) > tzdata$(VERSION).tar.gz
typecheck:
make clean
localtime.o: private.h tzfile.h
scheck.o: private.h
strftime.o: tzfile.h
-zic.o: private.h tzfile.h
+zdump.o: version.h
+zic.o: private.h tzfile.h version.h
.KEEP_STATE:
-# $NetBSD: Makefile.inc,v 1.16 2010/12/16 22:18:37 christos Exp $
+# $NetBSD: Makefile.inc,v 1.17 2011/08/14 09:07:37 christos Exp $
.PATH: ${.CURDIR}/time
tzset.3 daylight.3 \
tzset.3 tzsetwall.3 \
strftime.3 strftime_z.3
+
+COPTS.strftime.c = -Wno-format-nonliteral
-@(#)README 8.3
+README for the tz distribution
+
This file is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
mkdir tz
cd tz
- wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
- gzip -dc tzcode*.tar.gz | tar -xf -
- gzip -dc tzdata*.tar.gz | tar -xf -
+ wget --retr-symlinks 'ftp://ftp.iana.org/tz/tz*-latest.tar.gz'
+ gzip -dc tzcode-latest.tar.gz | tar -xf -
+ gzip -dc tzdata-latest.tar.gz | tar -xf -
Be sure to read the comments in "Makefile" and make any changes needed
to make things right for your system, especially if you are using some
1970, and there are undoubtedly errors even for time stamps since 1970.
If you know that the rules are different from those in a file, by all means
feel free to change file (and please send the changed version to
-tz@elsie.nci.nih.gov for use in the future). Europeans take note!
+tz@iana.org for use in the future). Europeans take note!
Thanks to these Timezone Caballeros who've made major contributions to the
time conversion package: Keith Bostic; Bob Devine; Paul Eggert; Robert Elz;
for testing work, and to Gwillim Law for checking local mean time data.
None of them are responsible for remaining errors.
-Look in the ~ftp/pub directory of elsie.nci.nih.gov
+Look in <ftp://ftp.iana.org/tz/releases/>
for updated versions of these files.
-Please send comments or information to tz@elsie.nci.nih.gov.
+Please send comments or information to tz@iana.org.
+
+Postscript: The README above is largely unmodified (aside from details
+of mailing list and ftp archive addresses) from that prepared many years
+ago by Arthur David Olson, to whom the timezone community owes the
+greatest debt of all. Arthur is not currently maintaining this data or
+code (though he remains involved).
-# $NetBSD: Theory,v 1.9 2009/12/31 22:49:15 mlelstv Exp $
-@(#)Theory 8.3
This file is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
----- Outline -----
Time and date functions
- Names of time zone regions
+ Scope of the tz database
+ Names of time zone rule files
Time zone abbreviations
Calendrical issues
Time and time zones on Mars
better.
+----- Scope of the tz database -----
+
+The tz database attempts to record the history and predicted future of
+all computer-based clocks that track civil time. To represent this
+data, the world is partitioned into regions whose clocks all agree
+about time stamps that occur after the somewhat-arbitrary cutoff point
+of the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region,
+the database records all known clock transitions, and labels the region
+with a notable location.
+
+Clock transitions before 1970 are recorded for each such location,
+because most POSIX-compatible systems support negative time stamps and
+could misbehave if data were omitted for pre-1970 transitions.
+However, the database is not designed for and does not suffice for
+applications requiring accurate handling of all past times everywhere,
+as it would take far too much effort and guesswork to record all
+details of pre-1970 civil timekeeping.
+
+As noted in the README file, the tz database is not authoritative
+(particularly not for pre-1970 time stamps), and it surely has errors.
+Corrections are welcome and encouraged. Users requiring authoritative
+data should consult national standards bodies and the references cited
+in the database's comments.
+
+
----- Names of time zone rule files -----
The time zone rule file naming conventions attempt to strike a balance
See the file `backward' for most of these older names
(e.g. `US/Eastern' instead of `America/New_York').
The other old-fashioned names still supported are
-`WET', `CET', `MET', `EET' (see the file `europe'),
-and `Factory' (see the file `factory').
+`WET', `CET', `MET', and `EET' (see the file `europe').
----- Time zone abbreviations -----
Calendrical issues are a bit out of scope for a time zone database,
but they indicate the sort of problems that we would run into if we
extended the time zone database further into the past. An excellent
-resource in this area is Edward M. Reingold and Nachum Dershowitz,
-<a href="http://emr.cs.uiuc.edu/home/reingold/calendar-book/second-edition/">
-Calendrical Calculations: The Millennium Edition
-</a>, Cambridge University Press (2001). Other information and
+resource in this area is Nachum Dershowitz and Edward M. Reingold,
+<a href="http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/">
+Calendrical Calculations: Third Edition
+</a>, Cambridge University Press (2008). Other information and
sources are given below. They sometimes disagree.
-/* $NetBSD: asctime.c,v 1.13 2009/12/31 22:49:16 mlelstv Exp $ */
+/* $NetBSD: asctime.c,v 1.15 2012/06/25 22:32:46 abs Exp $ */
/*
** This file is in the public domain, so clarified as of
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static char elsieid[] = "@(#)asctime.c 8.2";
+static char elsieid[] = "@(#)asctime.c 8.5";
#else
-__RCSID("$NetBSD: asctime.c,v 1.13 2009/12/31 22:49:16 mlelstv Exp $");
+__RCSID("$NetBSD: asctime.c,v 1.15 2012/06/25 22:32:46 abs Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define ASCTIME_BUFLEN (3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)
char *
-asctime_r(timeptr, buf)
-register const struct tm * timeptr;
-char * buf;
+asctime_r(const struct tm * timeptr, char * buf)
{
static const char *wday_name[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
char year[INT_STRLEN_MAXIMUM(int) + 2];
char result[MAX_ASCTIME_BUF_SIZE];
+ if (timeptr == NULL) {
+ errno = EINVAL;
+ return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
+ }
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
else wn = wday_name[timeptr->tm_wday];
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
year);
- if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
- (void) strcpy(buf, result);
- return buf;
- } else {
+ if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
+ return strcpy(buf, result);
+ else {
#ifdef EOVERFLOW
errno = EOVERFLOW;
#else /* !defined EOVERFLOW */
*/
char *
-asctime(timeptr)
-register const struct tm * timeptr;
+asctime(const struct tm *timeptr)
{
return asctime_r(timeptr, buf_asctime);
}
-# $NetBSD: checktab.awk,v 1.4 2009/12/31 22:49:16 mlelstv Exp $
+# $NetBSD: checktab.awk,v 1.5 2012/08/09 12:38:25 christos Exp $
# Check tz tables for consistency.
-# @(#)checktab.awk 8.1
-
# Contributed by Paul Eggert.
BEGIN {
-.\" $NetBSD: ctime.3,v 1.37 2010/12/17 01:30:50 wiz Exp $
-.Dd December 14, 2010
+.\" $NetBSD: ctime.3,v 1.46 2011/11/02 23:06:08 christos Exp $
+.\"
+.\" XXX: License missing?
+.\"
+.Dd November 2, 2011
.Dt CTIME 3
.Os
.Sh NAME
.Lb libc
.Sh SYNOPSIS
.In time.h
-.Dv extern char *tzname[2];
+.Vt extern char *tzname[2];
+.Ft char *
+.Fn asctime "const struct tm *tm"
+.Ft char *
+.Fn asctime_r "const struct tm restrict tm" "char * restrict buf"
.Ft char *
.Fn ctime "const time_t *clock"
.Ft char *
.Fn ctime_rz "const timezone_t tz" "const time_t *clock" "char *buf"
.Ft double
.Fn difftime "time_t time1" "time_t time0"
-.Ft char *
-.Fn asctime "const struct tm *tm"
-.Ft char *
-.Fn asctime_r "const struct tm restrict tm" "char * restrict buf"
+.Ft struct tm *
+.Fn gmtime "const time_t *clock"
+.Ft struct tm *
+.Fn gmtime_r "const time_t * restrict clock" "struct tm * restrict result"
.Ft struct tm *
.Fn localtime "const time_t *clock"
.Ft struct tm *
.Fn localtime_r "const time_t * restrict clock" "struct tm * restrict result"
.Ft struct tm *
.Fn localtime_rz "const timezone_t tz" "const time_t * restrict clock" "struct tm * restrict result"
-.Ft struct tm *
-.Fn gmtime "const time_t *clock"
-.Ft struct tm *
-.Fn gmtime_r "const time_t * restrict clock" "struct tm * restrict result"
.Ft time_t
.Fn mktime "struct tm *tm"
.Ft time_t
.Fn mktime_z "const timezone_t tz" "struct tm *tm"
.Ft timezone_t
.Fn tzalloc "const char *zone"
-.Ft const char *
-.Fn tzgetname "const timezone_t tz" "int isdst"
.Ft void
.Fn tzfree "const timezone_t tz"
+.Ft const char *
+.Fn tzgetname "const timezone_t tz" "int isdst"
.Sh DESCRIPTION
+The
+.Nm
+family of functions provide various standard library routines
+to operate with time and conversions related to time.
+.Sh FUNCTIONS
+.Bl -tag -width abcd
+.It Fn asctime "tm"
+The
+.Fn asctime
+function converts a time value contained in the
+.Fa tm
+structure to a string with the following general format:
+.Bd -literal -offset indent
+.D1 Thu Nov 24 18:22:48 1986\en\e0
+.Ed
+.Pp
+The
+.Fa tm
+structure is described in
+.Xr tm 3 .
+.It Fn asctime_r "tm" "buf"
+The
+.Fn asctime_r
+has the same behavior as
+.Fn asctime ,
+but the result is stored to
+.Fa buf ,
+which should have a size of at least 26 bytes.
+.It Fn ctime "clock"
+The
.Fn ctime
-converts a
-.Tp time_t ,
+function converts a
+.Vt time_t ,
pointed to by
.Fa clock ,
-representing the time in seconds since
-00:00:00 UTC, 1970-01-01,
-and returns a pointer to a
-string of the form
-.D1 Thu Nov 24 18:22:48 1986\en\e0
+representing the time in seconds since 00:00:00 UTC, 1970-01-01,
+and returns a pointer to a string with the format described above.
Years requiring fewer than four characters are padded with leading zeroes.
For years longer than four characters, the string is of the form
-.D1 Thu Nov 24 18:22:48 81986\en\e0
+.Bd -literal -offset indent
+.D1 "Thu Nov 24 18:22:48 81986\en\e0"
+.Ed
+.Pp
with five spaces before the year.
These unusual formats are designed to make it less likely that older
software that expects exactly 26 bytes of output will mistakenly output
misleading values for out-of-range years.
-.Pp
+.It Fn ctime_r "clock" "buf"
+The
.Fn ctime_r
is similar to
.Fn ctime ,
except it places the result of the conversion on the
.Fa buf
-argument which should be 26 or more bytes long, instead of using a global
-static buffer.
-.Pp
+argument, which should be 26 or more bytes long,
+instead of using a global static buffer.
+.It Fn ctime_rz "tz" "clock" "buf"
+The
.Fn ctime_rz
-is similar to
+function is similar to
.Fn ctime_r ,
but it also takes a
.Ft "const timezone_t"
-argument, returned by a previous call to
+argument, as returned by a previous call to
.Fn tzalloc .
-.Pp
-.Fn localtime
-and
+.It Fn difftime "time1" "time2"
+The
+.Fn difftime
+function returns the difference between two calendar times,
+.Fa ( time1 No - Fa time0 ) ,
+expressed in seconds.
+.It Fn gmtime "clock"
+The
.Fn gmtime
-return pointers to
+function converts to Coordinated Universal Time
+.Pq Tn UTC
+and returns a pointer to the
.Va tm
-structures, described below.
+structure described in
+.Xr tm 3 .
+.It Fn gmtime_r "clock" "result"
+The
+.Fn gmtime_r
+provides the same functionality as
+.Fn gmtime ,
+differing in that the caller must supply a buffer area
+.Fa result
+to which the result is stored.
+.It Fn localtime "clock"
+Also
+.Fn localtime
+is comparable to
+.Fn gmtime .
+However,
.Fn localtime
corrects for the time zone and any time zone adjustments
(such as Daylight Saving Time in the U.S.A.).
After filling in the
.Va tm
-structure,
-.Fn localtime
-sets the
+structure, the function sets the
.Fa tm_isdst Ns 'th
element of
.Fa tzname
to a pointer to an
-ASCII string that's the time zone abbreviation to be used with
+ASCII string that is the time zone abbreviation to be used with
.Fn localtime Ns 's
return value.
-.Pp
-.Fn gmtime
-converts to Coordinated Universal Time.
-.Pp
-The
-.Fn gmtime_r
-and
+.It Fn localtime_r "clock" "result"
+As
+.Fn gmtime_r ,
+the
.Fn localtime_r
-functions provide the same functionality as
-.Fn gmtime
-and
-.Fn localtime
-differing in that the caller must supply a buffer area
+takes an additional buffer
.Fa result
-in which the result is stored; also,
+as a parameter and stores the result to it.
+Note however that
.Fn localtime_r
does not imply initialization of the local time conversion information;
the application may need to do so by calling
.Xr tzset 3 .
-.Pp
+.It Fn localtime_rz "tz" "clock" "result"
+The
.Fn localtime_rz
-is similar to
+function is similar to
.Fn localtime_r ,
but it also takes a
.Ft "const timezone_t"
argument, returned by a previous call to
.Fn tzalloc .
-.Pp
-.Fn asctime
-converts a time value contained in a
-.Dq tm
-structure to a string,
-as shown in the above example,
-and returns a pointer to the string.
-.Pp
+.It Fn mktime "tm"
+The
.Fn mktime
-converts the broken-down time,
-expressed as local time,
-in the structure pointed to by
-.Fa tm
-into a calendar time value with the same encoding as that of the values
-returned by the
+function converts the broken-down time,
+expressed as local time in the
+.Xr tm 3
+structure, into a calendar time value with
+the same encoding as that of the values returned by the
.Xr time 3
function.
+The following remarks should be taken into account.
+.Bl -bullet
+.It
The original values of the
.Fa tm_wday
and
to presume initially that summer time (for example, Daylight Saving Time
in the U.S.A.) respectively,
is or is not in effect for the specified time.
+.It
A negative value for
.Fa tm_isdst
causes the
function to attempt to divine whether summer time is in effect
for the specified time; in this case it does not use a consistent
rule and may give a different answer when later
-presented with the same argument.)
+presented with the same argument.
+.It
On successful completion, the values of the
.Fa tm_wday
and
and
.Fa tm_year
are determined.
-.Fn mktime
-returns the specified calendar time; if the calendar time cannot be
-represented, it returns
-.Va "(time_t)-1" .
+.El
.Pp
+The function returns the specified calendar time;
+if the calendar time cannot be represented, it returns
+.Va "(time_t)-1" .
+This can happen either because the resulting conversion would not fit
+in a
+.Vt time_t
+variable, or because the time specified happens to be in the daylight
+savings gap and
+.Fa tm_isdst
+was set to
+.Dv \-1 .
+Other
+.Fn mktime
+implementations do not return an error in the second case and return
+the appropriate time offset after the daylight savings gap.
+There is code to mimick this behavior, but it is not enabled by default.
+.It Fn mktime_z "tz" "tm"
+The
.Fn mktime_z
-is similar to
+function is similar to
.Fn mktime
but it also takes a
.Ft "const timezone_t"
argument, returned by a previous call to
.Fn tzalloc .
-.Pp
-.Fn difftime
-returns the difference between two calendar times,
-.Fa ( time1 No - Fa time0 ) ,
-expressed in seconds.
-.Pp
+.It Fn tzalloc "zone"
+The
.Fn tzalloc
-takes as an argument a timezone name and returns a
+function takes as an argument a timezone name and returns a
.Ft timezone_t
-object suitable to be used in
+object suitable to be used in the
.Fn ctime_rz ,
.Fn localtime_rz ,
and
-.Fn mktime_z .
-Instead of setting the environment variable
+.Fn mktime_z
+functions.
+.Pp
+Note that instead of setting the environment variable
.Va TZ ,
and globally changing the behavior of the calling program, one can use
multiple timezones at the same time by using separate
and calling the
.Dq z
variants of the functions.
-.Pp
+.It Fn tzfree "tz"
+The
+.Fn tzfree
+function deallocates
+.Fa tz ,
+which was previously allocated by
+.Fn tzalloc .
+.It Fn "tzgetname"
+Finally,
.Fn tzgetname
returns the name for the given
.Fa tz .
.Va 1
the call is equivalent to
.Va tzname[1] .
-.Pp
-.Fn tzfree
-frees the
-.Fa tz
-argument previously returned by
-.Fa tzalloc .
-.Pp
-The structure (of type)
-.Va "struct tm"
-includes the following fields:
-.Bd -literal -offset indent
-int tm_sec; /* seconds after the minute [0,61] */
-int tm_min; /* minutes after the hour [0,59] */
-int tm_hour; /* hours since midnight [0,23] */
-int tm_mday; /* day of the month [1,31] */
-int tm_mon; /* months since January [0,11] */
-int tm_year; /* years since 1900 */
-int tm_wday; /* day of week [0,6] (Sunday = 0) */
-int tm_yday; /* day of year [0,365] (Jan 1 = 0) */
-int tm_isdst; /* daylight savings flag */
-long tm_gmtoff; /* offset from UTC in seconds */
-char *tm_zone; /* abbreviation of timezone name */
-.Ed
-.Pp
-The
-.Fa tm_zone
-and
-.Fa tm_gmtoff
-fields exist, and are filled in, only if arrangements to do
-so were made when the library containing these functions was
-created.
-There is no guarantee that these fields will continue to exist
-in this form in future releases of this code.
-The
-.Fa tm_zone
-field will become invalid and point to freed storage if the corresponding
-.Va "struct tm"
-was returned by
-.Fn localtime_rz
-and the
-.Ft "const timezone_t"
-.Fa tz
-argument has been freed by
-.Fn tzfree .
-.Pp
-.Fa tm_isdst
-is non-zero if summer time is in effect.
-.Pp
-.Fa tm_gmtoff
-is the offset (in seconds) of the time represented
-from UTC, with positive values indicating east
-of the Prime Meridian.
+.El
.Sh RETURN VALUES
+.Bl -bullet
+.It
On success the
.Fn asctime
and
On failure they all return
.Dv NULL
and no errors are defined for them.
+.It
On success the
.Fn gmtime ,
and
and the global variable
.Va errno
is set to indicate the error.
+.It
The
.Fn mktime
and
.Fn mktime_z
function returns the specified time since the Epoch as a
-.Va time_t
+.Vt time_t
type value.
If the time cannot be represented, then
.Fn mktime
setting the global variable
.Va errno
to indicate the error.
+.It
The
.Fn tzalloc
function returns a pointer to a
on failure, setting
.Va errno
to indicate the error.
+.It
.Fn tzgetzone
function returns string containing the name of the timezone given in
.Fa tz .
+.El
.Sh FILES
.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
.It Pa /etc/localtime
is absent, UTC leap seconds are loaded from
.Pa /usr/share/zoneinfo/posixrules .
.Sh ERRORS
-The
-.Fn gmtime_r ,
-.Fn localtime_r ,
-.Fn localtime_rz ,
-.Fn gmtime ,
-.Fn localtime ,
-and
-.Fn mktime ,
-and
-.Fn mktime_z
-will fail when:
+The described functions may fail with
.Bl -tag -width Er
.It Bq Er EINVAL
-The result cannot be represented.
+The result cannot be represented because a parameter is incorrect, or
+the conversion failed because no such time exists (for example a time
+in the DST gap).
.It Bq Er EOVERFLOW
-The result cannot be represented.
+The result cannot be represented because the time requested is out of bounds
+and the time calculation resulted in overflow.
.El
.Pp
-All functions that return values except their
+All functions that return values, except their
.Dq z
variants, can also return the same errors as
.Xr open 2
.Xr getenv 3 ,
.Xr strftime 3 ,
.Xr time 3 ,
+.Xr tm 3 ,
.Xr tzset 3 ,
.Xr tzfile 5
.Sh STANDARDS
and
.Fn mktime
functions conform to
-.St -ansiC
-The
-.Fn ctime_r ,
-.Fn asctime_r ,
-.Fn localtime_r
-and
-.Fn gmtime_r
-functions conform to
-.St -p1003.1c-95 .
-.Sh NOTES
-The return values point to static data; the data is overwritten by
+.St -ansiC .
+Rest of the functions conform to
+.St -p1003.1-2008 .
+.Sh CAVEATS
+The functions that do not take an explicit
+.Ft timezone_t
+argument return values point to static data; the data is overwritten by
each call.
-The
+For the above functions the
.Fa tm_zone
field of a returned
.Va "struct tm"
will also be overwritten at the next call
(and by calls to
.Xr tzset 3 ) .
+The functions that do take an explicit
+.Ft timezone_t
+argument and set the fields of a supplied
+.Va "struct tm"
+should not call
+.Fn tzfree
+since the
+.Fa tm_zone
+field of the
+.Va "struct tm"
+points to data allocated by
+.Fn tzalloc .
.Pp
+The
.Fn asctime
and
.Fn ctime
-behave strangely for years before 1000 or after 9999.
+functions behave strangely for years before 1000 or after 9999.
The 1989 and 1999 editions of the C Standard say
that years from \-99 through 999 are converted without
extra spaces, but this conflicts with longstanding
-/* $NetBSD: difftime.c,v 1.10 2009/12/31 22:49:16 mlelstv Exp $ */
+/* $NetBSD: difftime.c,v 1.11 2012/03/20 16:39:08 matt Exp $ */
/*
** This file is in the public domain, so clarified as of
#if 0
static char elsieid[] = "@(#)difftime.c 8.1";
#else
-__RCSID("$NetBSD: difftime.c,v 1.10 2009/12/31 22:49:16 mlelstv Exp $");
+__RCSID("$NetBSD: difftime.c,v 1.11 2012/03/20 16:39:08 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
double
-difftime(time1, time0)
-const time_t time1;
-const time_t time0;
+difftime(const time_t time1, const time_t time0)
{
/*
** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
-.\" $NetBSD: getdate.3,v 1.1 2009/05/14 02:37:36 ginsbach Exp $
+.\" $NetBSD: getdate.3,v 1.2 2011/04/14 05:50:49 jruoho Exp $
.\"
.\" Copyright (c) 2009, The NetBSD Foundation.
.\" All Rights Reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 8, 2009
+.Dd April 14, 2011
.Dt GETDATE 3
.Os
.Sh NAME
.Fa str
into a static
.Va tm
-structure.
+structure described in
+.Xr tm 3 .
.Pp
The input string is parsed and interpreted using templates.
A text file containing templates is specified by the
-/* $NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.67 2012/03/20 16:39:08 matt Exp $ */
/*
** This file is in the public domain, so clarified as of
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static char elsieid[] = "@(#)localtime.c 8.9";
+static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.67 2012/03/20 16:39:08 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#if defined(__weak_alias)
-__weak_alias(ctime_r,__ctime_r50)
-__weak_alias(ctime_rz,__ctime_rz50)
__weak_alias(daylight,_daylight)
-__weak_alias(mktime_z,__mktime_z50)
-__weak_alias(localtime_r,__localtime_r50)
-__weak_alias(localtime_rz,__localtime_rz50)
-__weak_alias(posix2time,__posix2time50)
-__weak_alias(posix2time_z,__posix2time_z50)
__weak_alias(tzname,_tzname)
#endif
tzname[0] = tzname[1] = (__aconst char *)__UNCONST(gmt);
return;
}
+ /*
+ ** And to get the latest zone names into tzname. . .
+ */
for (i = 0; i < sp->typecnt; ++i) {
const struct ttinfo * const ttisp = &sp->ttis[i];
#ifdef USG_COMPAT
if (ttisp->tt_isdst)
daylight = 1;
- if (i == 0 || !ttisp->tt_isdst)
+ if (!ttisp->tt_isdst)
timezone = -(ttisp->tt_gmtoff);
#endif /* defined USG_COMPAT */
#ifdef ALTZONE
altzone = -(ttisp->tt_gmtoff);
#endif /* defined ALTZONE */
}
- /*
- ** And to get the latest zone names into tzname. . .
- */
- for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * const ttisp =
- &sp->ttis[
- sp->types[i]];
-
- tzname[ttisp->tt_isdst] =
- &sp->chars[ttisp->tt_abbrind];
- }
settzname_z(sp);
}
int i;
int fid;
int stored;
- int nread;
- union {
+ ssize_t nread;
+ typedef union {
struct tzhead tzhead;
char buf[2 * sizeof(struct tzhead) +
2 * sizeof *sp +
4 * TZ_MAX_TIMES];
- } u;
+ } u_t;
+ u_t * up;
+
+ up = calloc(1, sizeof *up);
+ if (up == NULL)
+ return -1;
sp->goback = sp->goahead = FALSE;
if (name == NULL && (name = TZDEFAULT) == NULL)
- return -1;
+ goto oops;
{
int doaccess;
/*
doaccess = name[0] == '/';
if (!doaccess) {
if ((p = TZDIR) == NULL)
- return -1;
+ goto oops;
if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
- return -1;
+ goto oops;
(void) strcpy(fullname, p); /* XXX strcpy is safe */
(void) strcat(fullname, "/"); /* XXX strcat is safe */
(void) strcat(fullname, name); /* XXX strcat is safe */
name = fullname;
}
if (doaccess && access(name, R_OK) != 0)
- return -1;
+ goto oops;
/*
* XXX potential security problem here if user of a set-id
* program has set TZ (which is passed in as name) here,
* above.
*/
if ((fid = open(name, OPEN_MODE)) == -1)
- return -1;
+ goto oops;
}
- nread = read(fid, u.buf, sizeof u.buf);
+ nread = read(fid, up->buf, sizeof up->buf);
if (close(fid) < 0 || nread <= 0)
- return -1;
+ goto oops;
for (stored = 4; stored <= 8; stored *= 2) {
int ttisstdcnt;
int ttisgmtcnt;
- ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
- ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
- sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
- sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt);
- sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt);
- sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt);
- p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt;
+ ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt);
+ ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt);
+ sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt);
+ sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt);
+ sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt);
+ sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt);
+ p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt;
if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
(ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
(ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
- return -1;
- if (nread - (p - u.buf) <
+ goto oops;
+ if (nread - (p - up->buf) <
sp->timecnt * stored + /* ats */
sp->timecnt + /* types */
sp->typecnt * 6 + /* ttinfos */
sp->leapcnt * (stored + 4) + /* lsinfos */
ttisstdcnt + /* ttisstds */
ttisgmtcnt) /* ttisgmts */
- return -1;
+ goto oops;
for (i = 0; i < sp->timecnt; ++i) {
- sp->ats[i] = (stored == 4) ?
- detzcode(p) : detzcode64(p);
+ sp->ats[i] = (time_t)((stored == 4) ?
+ detzcode(p) : detzcode64(p));
p += stored;
}
for (i = 0; i < sp->timecnt; ++i) {
sp->types[i] = (unsigned char) *p++;
if (sp->types[i] >= sp->typecnt)
- return -1;
+ goto oops;
}
for (i = 0; i < sp->typecnt; ++i) {
struct ttinfo * ttisp;
p += 4;
ttisp->tt_isdst = (unsigned char) *p++;
if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
- return -1;
+ goto oops;
ttisp->tt_abbrind = (unsigned char) *p++;
if (ttisp->tt_abbrind < 0 ||
ttisp->tt_abbrind > sp->charcnt)
- return -1;
+ goto oops;
}
for (i = 0; i < sp->charcnt; ++i)
sp->chars[i] = *p++;
struct lsinfo * lsisp;
lsisp = &sp->lsis[i];
- lsisp->ls_trans = (stored == 4) ?
- detzcode(p) : detzcode64(p);
+ lsisp->ls_trans = (time_t)((stored == 4) ?
+ detzcode(p) : detzcode64(p));
p += stored;
lsisp->ls_corr = detzcode(p);
p += 4;
ttisp->tt_ttisstd = *p++;
if (ttisp->tt_ttisstd != TRUE &&
ttisp->tt_ttisstd != FALSE)
- return -1;
+ goto oops;
}
}
for (i = 0; i < sp->typecnt; ++i) {
ttisp->tt_ttisgmt = *p++;
if (ttisp->tt_ttisgmt != TRUE &&
ttisp->tt_ttisgmt != FALSE)
- return -1;
+ goto oops;
}
}
/*
/*
** If this is an old file, we're done.
*/
- if (u.tzhead.tzh_version[0] == '\0')
+ if (up->tzhead.tzh_version[0] == '\0')
break;
- nread -= p - u.buf;
+ nread -= p - up->buf;
for (i = 0; i < nread; ++i)
- u.buf[i] = p[i];
+ up->buf[i] = p[i];
/*
** If this is a narrow integer time_t system, we're done.
*/
break;
}
if (doextend && nread > 2 &&
- u.buf[0] == '\n' && u.buf[nread - 1] == '\n' &&
+ up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
sp->typecnt + 2 <= TZ_MAX_TYPES) {
struct __state ts;
int result;
- u.buf[nread - 1] = '\0';
- result = tzparse(&ts, &u.buf[1], FALSE);
+ up->buf[nread - 1] = '\0';
+ result = tzparse(&ts, &up->buf[1], FALSE);
if (result == 0 && ts.typecnt == 2 &&
sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
for (i = 0; i < 2; ++i)
break;
}
}
+ free(up);
return 0;
+oops:
+ free(up);
+ return -1;
}
static int
*/
static const char *
-getzname(strp)
-const char * strp;
+getzname(const char *strp)
{
char c;
*/
static const char *
-getnum(strp, nump, min, max)
-const char * strp;
-int * const nump;
-const int min;
-const int max;
+getnum(const char *strp, int * const nump, const int min, const int max)
{
char c;
int num;
** add SECSPERDAY times the day number-1 to the time of
** January 1, midnight, to get the day.
*/
- value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
+ value = (time_t)(janfirst + (rulep->r_day - 1) * SECSPERDAY);
if (leapyear && rulep->r_day >= 60)
value += SECSPERDAY;
break;
** Just add SECSPERDAY times the day number to the time of
** January 1, midnight, to get the day.
*/
- value = janfirst + rulep->r_day * SECSPERDAY;
+ value = (time_t)(janfirst + rulep->r_day * SECSPERDAY);
break;
case MONTH_NTH_DAY_OF_WEEK:
*/
value = janfirst;
for (i = 0; i < rulep->r_mon - 1; ++i)
- value += mon_lengths[leapyear][i] * SECSPERDAY;
+ value += (time_t)(mon_lengths[leapyear][i] * SECSPERDAY);
/*
** Use Zeller's Congruence to get day-of-week of first day of
/*
** "d" is the day-of-month (zero-origin) of the day we want.
*/
- value += d * SECSPERDAY;
+ value += (time_t)(d * SECSPERDAY);
break;
}
** time on that day, add the transition time and the current offset
** from UTC.
*/
- return value + rulep->r_time + offset;
+ return (time_t)(value + rulep->r_time + offset);
}
/*
/*
** Two transitions per year, from EPOCH_YEAR forward.
*/
+ memset(sp->ttis, 0, sizeof(sp->ttis));
sp->ttis[0].tt_gmtoff = -dstoffset;
sp->ttis[0].tt_isdst = 1;
- sp->ttis[0].tt_abbrind = stdlen + 1;
+ sp->ttis[0].tt_abbrind = (int)(stdlen + 1);
sp->ttis[1].tt_gmtoff = -stdoffset;
sp->ttis[1].tt_isdst = 0;
sp->ttis[1].tt_abbrind = 0;
}
sp->timecnt += 2;
newfirst = janfirst;
- newfirst += year_lengths[isleap(year)] *
- SECSPERDAY;
+ newfirst += (time_t)
+ (year_lengths[isleap(year)] * SECSPERDAY);
if (newfirst <= janfirst)
break;
janfirst = newfirst;
** offset.
*/
if (isdst && !sp->ttis[j].tt_ttisstd) {
- sp->ats[i] += dstoffset -
- theirdstoffset;
+ sp->ats[i] += (time_t)
+ (dstoffset - theirdstoffset);
} else {
- sp->ats[i] += stdoffset -
- theirstdoffset;
+ sp->ats[i] += (time_t)
+ (stdoffset - theirstdoffset);
}
}
theiroffset = -sp->ttis[j].tt_gmtoff;
}
/*
** Finally, fill in ttis.
- ** ttisstd and ttisgmt need not be handled.
*/
+ memset(sp->ttis, 0, sizeof(sp->ttis));
sp->ttis[0].tt_gmtoff = -stdoffset;
sp->ttis[0].tt_isdst = FALSE;
sp->ttis[0].tt_abbrind = 0;
sp->ttis[1].tt_gmtoff = -dstoffset;
sp->ttis[1].tt_isdst = TRUE;
- sp->ttis[1].tt_abbrind = stdlen + 1;
+ sp->ttis[1].tt_abbrind = (int)(stdlen + 1);
sp->typecnt = 2;
}
} else {
dstlen = 0;
sp->typecnt = 1; /* only standard time */
sp->timecnt = 0;
+ memset(sp->ttis, 0, sizeof(sp->ttis));
sp->ttis[0].tt_gmtoff = -stdoffset;
sp->ttis[0].tt_isdst = 0;
sp->ttis[0].tt_abbrind = 0;
}
- sp->charcnt = stdlen + 1;
+ sp->charcnt = (int)(stdlen + 1);
if (dstlen != 0)
- sp->charcnt += dstlen + 1;
+ sp->charcnt += (int)(dstlen + 1);
if ((size_t) sp->charcnt > sizeof sp->chars)
return -1;
cp = sp->chars;
seconds = sp->ats[0] - t;
else seconds = t - sp->ats[sp->timecnt - 1];
--seconds;
- tcycles = seconds / YEARSPERREPEAT / AVGSECSPERYEAR;
+ tcycles = (time_t)
+ (seconds / YEARSPERREPEAT / AVGSECSPERYEAR);
++tcycles;
icycles = tcycles;
if (tcycles - icycles >= 1 || icycles - tcycles >= 1)
*/
result = timesub(sp, &t, ttisp->tt_gmtoff, tmp);
tmp->tm_isdst = ttisp->tt_isdst;
- tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
+ if (sp == lclptr)
+ tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
#ifdef TM_ZONE
tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
#endif /* defined TM_ZONE */
struct tm *
gmtime(const time_t *const timep)
{
- return gmtsub(NULL, timep, 0L, &tm);
+ struct tm *tmp = gmtsub(NULL, timep, 0L, &tm);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
/*
struct tm *
gmtime_r(const time_t * const timep, struct tm *tmp)
{
- return gmtsub(NULL, timep, 0L, tmp);
+ tmp = gmtsub(NULL, timep, 0L, tmp);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
#ifdef STD_INSPIRED
struct tm *
offtime(const time_t *const timep, long offset)
{
- return gmtsub(NULL, timep, offset, &tm);
+ struct tm *tmp = gmtsub(NULL, timep, offset, &tm);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
struct tm *
offtime_r(const time_t *timep, long offset, struct tm *tmp)
{
- return gmtsub(NULL, timep, offset, tmp);
+ tmp = gmtsub(NULL, timep, offset, tmp);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
#endif /* defined STD_INSPIRED */
}
}
y = EPOCH_YEAR;
- tdays = *timep / SECSPERDAY;
+ tdays = (time_t)(*timep / SECSPERDAY);
rem = (long) (*timep - tdays * SECSPERDAY);
while (tdays < 0 || tdays >= year_lengths[isleap(y)]) {
int newy;
long seconds;
seconds = tdays * SECSPERDAY + 0.5;
- tdays = seconds / SECSPERDAY;
+ tdays = (time_t)(seconds / SECSPERDAY);
rem += (long) (seconds - tdays * SECSPERDAY);
}
/*
*/
static int
-increment_overflow(int *number, int delta)
+increment_overflow(int *ip, int j)
{
- int number0;
+ int i = *ip;
- number0 = *number;
- if (delta < 0 ? number0 < INT_MIN - delta : INT_MAX - delta < number0)
- return 1;
- *number += delta;
- return 0;
+ /*
+ ** If i >= 0 there can only be overflow if i + j > INT_MAX
+ ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow.
+ ** If i < 0 there can only be overflow if i + j < INT_MIN
+ ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
+ */
+ if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
+ return TRUE;
+ *ip += j;
+ return FALSE;
}
static int
-long_increment_overflow(long *number, int delta)
+long_increment_overflow(long *lp, int m)
{
- long number0;
+ long l = *lp;
- number0 = *number;
- if (delta < 0 ? number0 < LONG_MIN - delta : LONG_MAX - delta < number0)
- return 1;
- *number += delta;
- return 0;
+ if ((l >= 0) ? (m > LONG_MAX - l) : (m < LONG_MIN - l))
+ return TRUE;
+ *lp += m;
+ return FALSE;
}
static int
long li;
time_t lo;
time_t hi;
+#ifdef NO_ERROR_IN_DST_GAP
+ time_t ilo;
+#endif
long y;
time_t newt;
time_t t;
*okayp = FALSE;
yourtm = *tmp;
+#ifdef NO_ERROR_IN_DST_GAP
+again:
+#endif
if (do_norm_secs) {
if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
- SECSPERMIN))
- return WRONG;
+ SECSPERMIN))
+ goto overflow;
}
if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR))
- return WRONG;
+ goto overflow;
if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
- return WRONG;
+ goto overflow;
y = yourtm.tm_year;
if (long_normalize_overflow(&y, &yourtm.tm_mon, MONSPERYEAR))
- return WRONG;
+ goto overflow;
/*
** Turn y into an actual year number for now.
** It is converted back to an offset from TM_YEAR_BASE later.
*/
if (long_increment_overflow(&y, TM_YEAR_BASE))
- return WRONG;
+ goto overflow;
while (yourtm.tm_mday <= 0) {
if (long_increment_overflow(&y, -1))
- return WRONG;
+ goto overflow;
li = y + (1 < yourtm.tm_mon);
yourtm.tm_mday += year_lengths[isleap(li)];
}
li = y + (1 < yourtm.tm_mon);
yourtm.tm_mday -= year_lengths[isleap(li)];
if (long_increment_overflow(&y, 1))
- return WRONG;
+ goto overflow;
}
for ( ; ; ) {
i = mon_lengths[isleap(y)][yourtm.tm_mon];
if (++yourtm.tm_mon >= MONSPERYEAR) {
yourtm.tm_mon = 0;
if (long_increment_overflow(&y, 1))
- return WRONG;
+ goto overflow;
}
}
if (long_increment_overflow(&y, -TM_YEAR_BASE))
- return WRONG;
- yourtm.tm_year = y;
+ goto overflow;
+ yourtm.tm_year = (int)y;
if (yourtm.tm_year != y)
- return WRONG;
+ goto overflow;
if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN)
saved_seconds = 0;
else if (y + TM_YEAR_BASE < EPOCH_YEAR) {
** which is a safer assumption than using 58 would be.
*/
if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
- return WRONG;
+ goto overflow;
saved_seconds = yourtm.tm_sec;
yourtm.tm_sec = SECSPERMIN - 1;
} else {
lo *= 2;
hi = -(lo + 1);
}
+#ifdef NO_ERROR_IN_DST_GAP
+ ilo = lo;
+#endif
for ( ; ; ) {
t = lo / 2 + hi / 2;
if (t < lo)
if (t == lo) {
++t;
if (t <= lo)
- return WRONG;
+ goto overflow;
++lo;
} else if (t == hi) {
--t;
if (t >= hi)
- return WRONG;
+ goto overflow;
--hi;
}
+#ifdef NO_ERROR_IN_DST_GAP
+ if (ilo != lo && lo - 1 == hi && yourtm.tm_isdst < 0 &&
+ do_norm_secs) {
+ for (i = sp->typecnt - 1; i >= 0; --i) {
+ for (j = sp->typecnt - 1; j >= 0; --j) {
+ time_t off;
+ if (sp->ttis[j].tt_isdst ==
+ sp->ttis[i].tt_isdst)
+ continue;
+ off = sp->ttis[j].tt_gmtoff -
+ sp->ttis[i].tt_gmtoff;
+ yourtm.tm_sec += off < 0 ?
+ -off : off;
+ goto again;
+ }
+ }
+ }
+#endif
if (lo > hi)
- return WRONG;
+ goto invalid;
if (dir > 0)
hi = t;
else lo = t;
** gets checked.
*/
if (sp == NULL)
- return WRONG;
+ goto invalid;
for (i = sp->typecnt - 1; i >= 0; --i) {
if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
continue;
for (j = sp->typecnt - 1; j >= 0; --j) {
if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
continue;
- newt = t + sp->ttis[j].tt_gmtoff -
- sp->ttis[i].tt_gmtoff;
+ newt = (time_t)(t + sp->ttis[j].tt_gmtoff -
+ sp->ttis[i].tt_gmtoff);
if ((*funcp)(sp, &newt, offset, &mytm) == NULL)
continue;
if (tmcomp(&mytm, &yourtm) != 0)
goto label;
}
}
- return WRONG;
+ goto invalid;
}
label:
newt = t + saved_seconds;
if ((newt < t) != (saved_seconds < 0))
- return WRONG;
+ goto overflow;
t = newt;
if ((*funcp)(sp, &t, offset, tmp)) {
*okayp = TRUE;
return t;
- } else
- return WRONG;
+ }
+overflow:
+ errno = EOVERFLOW;
+ return WRONG;
+invalid:
+ errno = EINVAL;
+ return WRONG;
}
static time_t
int types[TZ_MAX_TYPES];
int okay;
+ if (tmp == NULL) {
+ errno = EINVAL;
+ return WRONG;
+ }
if (tmp->tm_isdst > 1)
tmp->tm_isdst = 1;
t = time2(sp, tmp, funcp, offset, &okay);
** We try to divine the type they started from and adjust to the
** type they need.
*/
- if (sp == NULL)
+ if (sp == NULL) {
+ errno = EINVAL;
return WRONG;
+ }
for (i = 0; i < sp->typecnt; ++i)
seen[i] = FALSE;
nseen = 0;
tmp->tm_isdst = !tmp->tm_isdst;
}
}
+ errno = EOVERFLOW;
return WRONG;
}
t = time1(NULL, tmp, gmtsub, 0L);
else
t = time1(sp, tmp, localsub, 0L);
- if (t == WRONG)
- errno = EOVERFLOW;
return t;
}
time_t
timelocal(struct tm *const tmp)
{
- tmp->tm_isdst = -1; /* in case it wasn't initialized */
+ if (tmp != NULL)
+ tmp->tm_isdst = -1; /* in case it wasn't initialized */
return mktime(tmp);
}
{
time_t t;
- tmp->tm_isdst = 0;
+ if (tmp != NULL)
+ tmp->tm_isdst = 0;
t = time1(gmtptr, tmp, gmtsub, 0L);
- if (t == WRONG)
- errno = EOVERFLOW;
return t;
}
{
time_t t;
- tmp->tm_isdst = 0;
+ if (tmp != NULL)
+ tmp->tm_isdst = 0;
t = time1(gmtptr, tmp, gmtsub, offset);
- if (t == WRONG)
- errno = EOVERFLOW;
return t;
}
time_t
time2posix_z(const timezone_t sp, time_t t)
{
- return t - leapcorr(sp, &t);
+ return (time_t)(t - leapcorr(sp, &t));
}
time_t
time_t result;
rwlock_wrlock(&lcl_lock);
tzset_unlocked();
- result = t - leapcorr(lclptr, &t);
+ result = (time_t)(t - leapcorr(lclptr, &t));
rwlock_unlock(&lcl_lock);
return (result);
}
** hit, the corresponding time doesn't exist,
** so we return an adjacent second.
*/
- x = t + leapcorr(sp, &t);
- y = x - leapcorr(sp, &x);
+ x = (time_t)(t + leapcorr(sp, &t));
+ y = (time_t)(x - leapcorr(sp, &x));
if (y < t) {
do {
x++;
- y = x - leapcorr(sp, &x);
+ y = (time_t)(x - leapcorr(sp, &x));
} while (y < t);
if (t != y) {
return x - 1;
} else if (y > t) {
do {
--x;
- y = x - leapcorr(sp, &x);
+ y = (time_t)(x - leapcorr(sp, &x));
} while (y > t);
if (t != y) {
return x + 1;
-.\" $NetBSD: offtime.3,v 1.2 2010/12/16 18:38:07 christos Exp $
+.\" $NetBSD: offtime.3,v 1.3 2011/04/14 05:50:50 jruoho Exp $
.\" Written by Klaus Klein, May 10, 2004.
.\" Public domain.
-.Dd December 14, 2010
+.Dd April 14, 2011
.Dt OFFTIME 3
.Os
.Sh NAME
and is provided for symmetry only.
.Sh SEE ALSO
.Xr ctime 3 ,
+.Xr tm 3 ,
.Xr tzset 3
-/* $NetBSD: private.h,v 1.25 2009/12/31 22:49:16 mlelstv Exp $ */
+/* $NetBSD: private.h,v 1.26 2012/08/09 12:38:25 christos Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
** Thank you!
*/
-/*
-** ID
-*/
-
-#ifndef lint
-#ifndef NOID
-#if 0
-static char privatehid[] = "@(#)private.h 8.6";
-#endif
-#endif /* !defined NOID */
-#endif /* !defined lint */
-
#define GRANDPARENTED "Local time zone must be set--see zic manual page"
/*
.\" SUCH DAMAGE.
.\"
.\" from: @(#)strftime.3 5.12 (Berkeley) 6/29/91
-.\" $NetBSD: strftime.3,v 1.27 2010/12/16 18:38:07 christos Exp $
+.\" $NetBSD: strftime.3,v 1.29 2012/04/06 11:35:39 wiz Exp $
.\"
-.Dd December 14, 2010
+.Dd April 14, 2011
.Dt STRFTIME 3
.Os
.Sh NAME
.It Cm \&%Z
is replaced by the time zone name.
.It Cm \&%z
-is replaced by the offset from ITC in the ISO 8601 format
+is replaced by the offset from UTC in the ISO 8601 format
.Dq Li [-]hhmm .
.It Cm %%
is replaced by
.Xr printf 1 ,
.Xr ctime 3 ,
.Xr printf 3 ,
-.Xr strptime 3
+.Xr strptime 3 ,
+.Xr tm 3
.Sh STANDARDS
The
.Fn strftime
-/* $NetBSD: strftime.c,v 1.21 2010/12/16 18:38:07 christos Exp $ */
+/* $NetBSD: strftime.c,v 1.22 2012/03/20 16:39:08 matt Exp $ */
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
static char elsieid[] = "@(#)strftime.c 7.64";
static char elsieid[] = "@(#)strftime.c 8.3";
#else
-__RCSID("$NetBSD: strftime.c,v 1.21 2010/12/16 18:38:07 christos Exp $");
+__RCSID("$NetBSD: strftime.c,v 1.22 2012/03/20 16:39:08 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
}
static char *
-_conv(n, format, pt, ptlim)
-const int n;
-const char * const format;
-char * const pt;
-const char * const ptlim;
+_conv(const int n, const char * const format, char * const pt,
+ const char * const ptlim)
{
char buf[INT_STRLEN_MAXIMUM(int) + 1];
}
static char *
-_add(str, pt, ptlim)
-const char * str;
-char * pt;
-const char * const ptlim;
+_add(const char *str, char *pt, const char * const ptlim)
{
while (pt < ptlim && (*pt = *str++) != '\0')
++pt;
*/
static char *
-_yconv(a, b, convert_top, convert_yy, pt, ptlim)
-const int a;
-const int b;
-const int convert_top;
-const int convert_yy;
-char * pt;
-const char * const ptlim;
+_yconv(const int a, const int b, const int convert_top, const int convert_yy,
+ char *pt, const char * const ptlim)
{
register int lead;
register int trail;
-.\" $NetBSD: strptime.3,v 1.27 2009/05/24 02:30:17 ginsbach Exp $
+.\" $NetBSD: strptime.3,v 1.29 2011/04/12 08:40:34 jruoho Exp $
.\"
.\" Copyright (c) 1997, 1998, 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 24, 2009
+.Dd April 12, 2011
.Dt STRPTIME 3
.Os
.Sh NAME
.Fn strptime
function returns a pointer to the character following the last character
parsed.
-Otherwise, a null pointer is returned.
+Otherwise, a
+.Dv NULL
+pointer is returned.
.Sh SEE ALSO
.Xr ctime 3 ,
.Xr isspace 3 ,
.Xr localtime 3 ,
-.Xr strftime 3
+.Xr strftime 3 ,
+.Xr tm 3
.Sh STANDARDS
The
.Fn strptime
-/* $NetBSD: strptime.c,v 1.35 2009/12/14 20:45:02 matt Exp $ */
+/* $NetBSD: strptime.c,v 1.36 2012/03/13 21:13:48 christos Exp $ */
/*-
* Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strptime.c,v 1.35 2009/12/14 20:45:02 matt Exp $");
+__RCSID("$NetBSD: strptime.c,v 1.36 2012/03/13 21:13:48 christos Exp $");
#endif
#include "namespace.h"
const char * const *n2, int c)
{
int i;
- unsigned int len;
+ size_t len;
/* check full name - then abbreviated ones */
for (; n1 != NULL; n1 = n2, n2 = NULL) {
</head>
<body>
<h1>Time and the Arts</h1>
-<address>
-@(#)tz-art.htm 8.13
-</address>
<p>
This file is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
</p>
<p>
Please send corrections to this web page to the
-<a href="mailto:tz@elsie.nci.nih.gov">time zone mailing list</a>.</p>
+<a href="mailto:tz@iana.org">time zone mailing list</a>.</p>
<p>
See also <a href="tz-link.htm">Sources for Time Zone and Daylight Saving Time Data</a>.</p>
<hr>
<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&sql=10:gifqxqt5ld0e">AMG Rating</a></td><td>4.5 stars</td></tr>
<tr><td>ADO Rating</td><td>1.5 stars</td></tr>
<tr><td>Notes<td>The title song is also available on "Bob Dylan's Greatest Hits" and "The Essential Bob Dylan."</td></tr>
-
+<tr><td> </td></tr>
+
+<tr><td>Artist</td><td>Luciana Souza</td></tr>
+<tr><td>CD</td><td>Tide</td></tr>
+<tr><td>Copyright Date</td><td>2009</td></tr>
+<tr><td>Label</td><td>Universal Jazz France</td></tr>
+<tr><td>ID</td><td>B0012688-02</td></tr>
+<tr><td>Total Time</td><td>42:31</td></tr>
+<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&sql=10:3bftxzw0ldhe"</a>AMG Rating</a></td><td>3.5 stars</td></tr>
+<tr><td>ADO Rating</td><td>2.5 stars</td></tr>
+<tr><td>Notes<td>Includes the song "Fire and Wood" with the lyric
+"The clocks were turned back you remeber/Think it's still November."
+</td></tr>
+<tr><td> </td></tr>
+<tr><td>Artist</td><td>Ken Nordine</td></tr>
+<tr><td>CD</td><td>You're Getting Better: The Word Jazz Dot Masters</td></tr>
+<tr><td>Copyright Date</td><td>2005</td></tr>
+<tr><td>Label</td><td>Geffen</td></tr>
+<tr><td>ID</td><td>B0005171-02</td></tr>
+<tr><td>Total Time</td><td>156:22</td></tr>
+<tr><td>ADO Rating</td><td>1 star</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/youre-getting-better-the-word-jazz-dot-masters+r105931">AMG Rating</a></td><td>4.5 stars</td></tr>
+<tr><td>Notes</td><td>Includes the piece "What Time Is It"
+("He knew what time it was everywhere...that counted").</td></tr>
<tr><td> </td></tr>
<tr><td>TV episode title</td><td>The Lost Hour</td>
(originally aired 2007-02-28).
</li>
<li>
-In the 1946 "A Matter of Life and Death,"
+In the "30 Rock" episode "Anna Howard Shaw Day" (first broadcast 2010-02-11),
+Jack Donaghy's date realizes that a Geneva-to-New-York business phone call
+received in the evening must be fake given the difference in local times.
+</li>
+<li>
+In the 1946 movie "A Matter of Life and Death"
+(U.S. title "Stairway to Heaven")
there is a reference to British Double Summer Time.
The time does not play a large part in the plot;
it's just a passing reference to the time when one of the
<a href="http://us.imdb.com/title/tt0038733/">
http://us.imdb.com/title/tt0038733/
</a>. (Dave Cantor)
+<li>
+The 1953 railway comedy movie "The Titfield Thunderbolt" includes a
+play on words on British Double Summer Time. Valentine's wife wants
+him to leave the pub and asks him, "Do you know what time it is?"
+And he, happy where he is, replies: "Yes, my love. Summer double time."
+IMDB page:
+<a href="http://us.imdb.com/title/tt0046436/">
+http://us.imdb.com/title/tt0046436/
+</a>. (Mark Brader, 2009-10-02)
+</li>
+<li>
+The premise of the 1999 caper movie "Entrapment" involves computers
+in an international banking network being shut down briefly at
+midnight in each time zone to avoid any problems at the transition
+from the year 1999 to 2000 in that zone. (Hmmmm.) If this shutdown
+is extended by 10 seconds, it will create a one-time opportunity for
+a gigantic computerized theft. To achieve this, at one location the
+crooks interfere with the microwave system supplying time signals to
+the computer, advancing the time by 0.1 second each minute over the
+last hour of 1999. (So this movie teaches us that 0.1 x 60 = 10.)
+IMDB page:
+<a href="http://us.imdb.com/title/tt0137494/">
+http://us.imdb.com/title/tt0137494/
+</a>. (Mark Brader, 2009-10-02)
+</li>
+<li>
+In "The Todd Couple" episode of "Outsourced" (first aired 2011-02-10),
+Manmeet sets up teledates for 6:00 and 9:00;
+since one is with a New Yorker and the other with a San Franciscan,
+hilarity ensues.
</li>
</ul>
<hr>
as noted by Will Fitzerald)
</li>
<li>
+Brady: "...[Bishop Usher] determined that the Lord began the Creation
+on the 23rd of October in the Year 4004 B.C. at -- uh, at 9 A.M.!"
+<br>
+Drummond: "That Eastern Standard Time? (Laughter) Or Rocky Mountain
+Time? (More laughter) It wasn't daylight-saving time, was it? Because
+the Lord didn't make the sun until the fourth day!"
+<br>
+(From the play "Inherit the Wind" by Jerome Lawrence and Robert E. Lee,
+filmed in 1960 with Spencer Tracy as Drummond and Fredric March as
+Brady, and several other times. Thanks to Mark Brader.)
+</li>
+<li>
"Good news."
"What did they do? Extend Daylight Saving Time year round?"
(Professional tanner George Hamilton, in dialog from a
It is already tomorrow in Australia."
(Charles M. Schulz, provided by Steve Summit)
</li>
+<li>
+"I put myself and my staff through this crazy, huge ordeal, all because
+I refused to go on at midnight, okay? And so I work, you know, and
+then I get this job at eleven, supposed to be a big deal. Then
+yesterday daylight [saving] time ended. Right now it's basically
+midnight." (Conan O'Brien on the 2010-11-08 premier of "Conan.")
+</li>
</ul>
</body>
</html>
<meta http-equiv="Content-type" content='text/html; charset="US-ASCII"'>
<meta name="DC.Creator" content="Eggert, Paul">
<meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2007-12-26">
+<meta name="DC.Date" content="2012-07-19">
<meta name="DC.Description"
content="Sources of information about time zones and daylight saving time">
<meta name="DC.Identifier" content="http://www.twinsun.com/tz/tz-link.htm">
</head>
<body>
<h1>Sources for Time Zone and Daylight Saving Time Data</h1>
-<address>
-@(#)tz-link.htm 8.22
-</address>
<p>
This file is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
</p>
<p>
Please send corrections to this web page to the
-<a href="mailto:tz@elsie.nci.nih.gov">time zone mailing list</a>.</p>
+<a href="mailto:tz@iana.org">time zone mailing list</a>.</p>
<h2>The <code>tz</code> database</h2>
<p>
The <a href="http://en.wikipedia.org/wiki/Public_domain">public-domain</a>
title="Coordinated Universal Time">UTC</abbr></a> offsets, and
<a href="http://en.wikipedia.org/wiki/Daylight_saving">daylight-saving</a>
rules.
-This database (often called <code>tz</code> or <a
-href="http://en.wikipedia.org/wiki/Zoneinfo"><code>zoneinfo</code></a>)
+This database (often called <code>zoneinfo</code> or <a
+href="http://en.wikipedia.org/wiki/TZ_database"><code>tz</code></a>)
is used by several implementations,
including
<a href="http://www.gnu.org/software/libc/">the
the location's full name, e.g., <code>TZ="America/New_York"</code>.</p>
<p>
In the <code>tz</code> database's
-<a href="ftp://elsie.nci.nih.gov/pub"><abbr
-title="File Transfer Protocol">FTP</abbr> distribution</a>
+<a href="ftp://ftp.iana.org/tz/releases/"><abbr
+title="File Transfer Protocol">FTP</abbr> releases</a>
the code is in the file <code>tzcode<var>C</var>.tar.gz</code>,
where <code><var>C</var></code> is the code's version;
similarly, the data are in <code>tzdata<var>D</var>.tar.gz</code>,
where <code><var>D</var></code> is the data's version.
+Each version is a four-digit year followed by lower-case letters
+(a through z, then za through zz, then zza through zzz, and so on).
+Convenience links to
+the <a href="ftp://ftp.iana.org/tz/tzcode-latest.tar.gz">latest
+code</a> and
+<a href="ftp://ftp.iana.org/tz/tzdata-latest.tar.gz">latest data</a> revisions
The following <a
href="http://en.wikipedia.org/wiki/Unix_shell">shell</a> commands download
these files to a <abbr>GNU</abbr>/Linux or similar host;
see the downloaded
<code>README</code> file for what to do next.</p>
-<pre style="margin-left: 2em"><code><a href="http://www.gnu.org/software/wget/">wget</a> 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
-<a href="http://www.gnu.org/software/gzip/">gzip</a> -dc tzcode*.tar.gz | <a href="http://www.gnu.org/software/tar/">tar</a> -xf -
-gzip -dc tzdata*.tar.gz | tar -xf -
+<pre style="margin-left: 2em"><code>mkdir tz
+cd tz
+<a href="http://www.gnu.org/software/wget/">wget</a> --retr-symlinks 'ftp://ftp.iana.org/tz/tz*-latest.tar.gz'
+<a href="http://www.gnu.org/software/gzip/">gzip</a> -dc tzcode-latest.tar.gz | <a href="http://www.gnu.org/software/tar/">tar</a> -xf -
+gzip -dc tzdata-latest.tar.gz | tar -xf -
</code></pre>
<p>
+The code and data files can also be obtained from the
+<a href="http://www.iana.org">IANA</a>
+<a href="http://www.iana.org/time-zones">timezone web page</a>.
+<p>
The code lets you compile the <code>tz</code> source files into
machine-readable binary files, one for each location. It also lets
you read a <code>tz</code> binary file and interpret time stamps for that
location.</p>
<p>
The data are by no means authoritative. If you find errors, please
-send changes to the <a href="mailto:tz@elsie.nci.nih.gov">time zone
+send changes to the <a href="mailto:tz@iana.org">time zone
mailing list</a>. You can also <a
href="http://news.gmane.org/gmane.comp.time.tz">browse recent
messages</a> sent to the mailing list, <a
-href="mailto:tz-request@elsie.nci.nih.gov">subscribe</a> to it,
-retrieve the <a
-href="ftp://elsie.nci.nih.gov/pub/tzarchive.gz">full archive of old
-messages</a> (in gzip compressed format), or retrieve <a
-href="ftp://munnari.oz.au/pub/oldtz">archived older versions of code
+href="https://mm.icann.org/mailman/listinfo/tz">subscribe</a> to it.
+browse the <a
+href="http://mm.icann.org/pipermail/tz/">archive of old
+messages</a> (message by message or in gzip compressed format),
+or retrieve <a
+href="ftp://ftp.iana.org/tz/releases/">archived older versions of code
and data</a>.</p>
<p>
The Web has several other sources for time zone and daylight saving time data.
These are listed roughly in ascending order of complexity and fanciness.
</p>
<ul>
+<li>
+<a href="http://permatime.com">
+Permatime</a>
+is a service for generating and viewing links that refer to a
+particular point in time and can be displayed in multiple timezones.
+It uses the ruby tzinfo gem.
+(From Tim Diggins, 2009-11-03.)
+</li>
<li><a href="http://twiki.org/cgi-bin/xtra/tzdatepick.html">Date and Time Gateway</a>
lets you see the <code>TZ</code> values directly.</li>
<li><a
<li>The <a href="http://worldtimeengine.com/">World Time Engine</a>
also contains data about time zone boundaries; it supports queries via place
names and shows location maps.</li>
+<li><a href="http://simpletimerclocks.mozdev.org/">Simple Timer + Clocks</a>
+is a Firefox add-on which uses a timezone data file generated from the
+tz data files.</li>
</ul>
<h2>Other time zone database formats</h2>
<ul>
license.</li>
</ul>
<h2>Other <code>tz</code> binary file readers</h2>
+<li><a href="http://search.cpan.org/perldoc?DateTime::TimeZone::Tzfile">
+DateTime::TimeZone::Tzfile</a>
+is a <code>tz</code> binary file reader written in Perl.
+It is freely available under the same terms as Perl
+(dual <abbr>GPL</abbr> and Artistic license).</li>
<ul>
<li>The <a
href="http://www.gnu.org/software/libc/"><abbr>GNU</abbr> C
<li><a
href="http://worldtimeexplorer.com/">World Time Explorer</a> is a
Microsoft Windows program.</li>
+<li>
+<a href="http://www.toriasoft.com">
+WorldClock for Windows and Windows Mobile</a>
+lets users "see the time in up to 25 locations in the world at once."
+(From Hans Nieuwenhuis, 2009-11-02.)
+</li>
+<li>
+<a href="http://www.relativedata.com/time-zone-master">
+Time Zone Master Basic
+</a> "allows people to display multiple desktop clocks, and to
+research current and historical time information, as well as times of
+astronomical events (sunrise/transit/set, moonrise/transit/set, phases,
+season starts) for user-selected dates in the past and future. It can
+automatically download, compile and use the tzdata**.gz database files
+as they are released to keep the data up to date. The software is
+free." (Davie Patte)
+</li>
</ul>
<h2>Other time zone databases</h2>
<ul>
→ Tzid table</a> maintained by the <abbr
title="Common Locale Data Repository">CLDR</abbr> data mentioned
below.</li>
+<li>
+<a href="http://code.google.com/p/tzdata/">
+http://code.google.com/p/tzdata/
+</a>
+provides programming-language-specific representations of timezone
+data. Currently this includes XML, PHP, Ruby, Javascript, JSON and CSV
+formatted data. The repository is updated as soon as the FTP
+distribution is updated. All data can be downloaded as a zip and/or it
+can be obtained/synced via anonymous SVN. Data is made available under
+the MIT license. (From Rich Tibbett.)
+</li>
</ul>
<h2>Maps</h2>
<ul>
-.\" $NetBSD: tzfile.5,v 1.15 2010/01/08 23:14:13 joerg Exp $
+.\" $NetBSD: tzfile.5,v 1.18 2012/08/09 12:38:25 christos Exp $
.\"
-.\" @(#)tzfile.5 7.11
.\" This file is in the public domain, so clarified as of
.\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
.Dd September 16, 2001
.Sh SEE ALSO
.Xr ctime 3 ,
.Xr localtime 3 ,
-.Xr time 3
-.\" @(#)tzfile.5 8.2
+.Xr time 3 ,
+.Xr zdump 8
+.\" @(#)tzfile.5 8.3
.\" This file is in the public domain, so clarified as of
.\" 1996-06-05 by Arthur David Olson.
-/* $NetBSD: tzfile.h,v 1.9 2009/12/31 22:49:16 mlelstv Exp $ */
+/* $NetBSD: tzfile.h,v 1.10 2012/08/09 12:38:25 christos Exp $ */
#ifndef TZFILE_H
#define TZFILE_H
** Thank you!
*/
-/*
-** ID
-*/
-
-#ifndef lint
-#ifndef NOID
-#if 0
-static char tzfilehid[] = "@(#)tzfile.h 8.1";
-#endif
-#endif /* !defined NOID */
-#endif /* !defined lint */
-
/*
** Information about time zone files.
*/
#! /bin/ksh
#
-# $NetBSD: tzselect.ksh,v 1.6 2009/12/31 22:49:16 mlelstv Exp $
+# $NetBSD: tzselect.ksh,v 1.7 2012/08/09 12:38:26 christos Exp $
#
-VERSION='@(#)tzselect.ksh 8.2'
+VERSION=see_Makefile
# Ask the user about the time zone, and output the resulting TZ value to stdout.
# Interact with the user via stderr and stdin.
exit 0
elif [ "$1" = "--version" ]; then
cat <<EOF
-tzselect $VERSION
+tzselect $TZVERSION
EOF
exit 0
fi
--- /dev/null
+static char const TZVERSION[]="tz2012e";
-.\" $NetBSD: zdump.8,v 1.8 2010/01/08 23:14:13 joerg Exp $
-.\" @(#)zdump.8 7.4
+.\" $NetBSD: zdump.8,v 1.9 2012/08/09 12:38:26 christos Exp $
.Dd October 29, 2003
.Dt ZDUMP 8
.Os
-/* $NetBSD: zdump.c,v 1.19 2011/01/15 12:31:57 martin Exp $ */
+/* $NetBSD: zdump.c,v 1.25 2012/08/09 12:38:26 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2009-05-17 by Arthur David Olson.
#include <sys/cdefs.h>
#ifndef lint
-#ifndef NOID
-__RCSID("$NetBSD: zdump.c,v 1.19 2011/01/15 12:31:57 martin Exp $");
-#endif /* !defined NOID */
+__RCSID("$NetBSD: zdump.c,v 1.25 2012/08/09 12:38:26 christos Exp $");
#endif /* !defined lint */
-static char elsieid[] = "@(#)zdump.c 8.9";
-
+#include "version.h"
/*
** This code has been made independent of the rest of the time
** conversion package to increase confidence in the verification it provides.
#if HAVE_GETTEXT
#define _(msgid) gettext(msgid)
#else /* !HAVE_GETTEXT */
-#define _(msgid) __UNCONST(msgid)
+#define _(msgid) msgid
#endif /* !HAVE_GETTEXT */
#endif /* !defined _ */
const char * const zone;
{
register const char * cp;
- register char * wp;
+ register const char * wp;
if (warned)
return;
warned = TRUE;
}
-static void
-usage(const char *xprogname, FILE *stream, int status)
+__dead static void
+usage(FILE *stream, int status)
{
(void) fprintf(stream,
_("%s: usage is %s [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] zonename ...\n\
\n\
Report bugs to tz@elsie.nci.nih.gov.\n"),
- xprogname, xprogname);
+ progname, progname);
exit(status);
}
progname = argv[0];
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", elsieid);
+ (void) printf("%s\n", TZVERSION);
exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "--help") == 0) {
- usage(progname, stdout, EXIT_SUCCESS);
+ usage(stdout, EXIT_SUCCESS);
}
vflag = 0;
cutarg = NULL;
else cutarg = optarg;
if ((c != EOF && c != -1) ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
- usage(progname, stderr, EXIT_FAILURE);
+ usage(stderr, EXIT_FAILURE);
}
if (vflag) {
if (cutarg != NULL) {
return EXIT_FAILURE;
}
+static time_t
+ovfl_check(time_t t)
+{
+ if (t < 0 && t - 1 >= 0)
+ return t;
+ else
+ return t - 1;
+}
+
static void
setabsolutes(void)
{
absolute_max_time = t;
t = -t;
- absolute_min_time = t - 1;
- if (t < absolute_min_time)
- absolute_min_time = t;
+ absolute_min_time = ovfl_check(t);
} else {
/*
** time_t is unsigned.
-.\" $NetBSD: zic.8,v 1.18 2010/05/30 07:57:08 wiz Exp $
-.\" @(#)zic.8 7.22
+.\" $NetBSD: zic.8,v 1.20 2012/08/09 12:38:26 christos Exp $
.Dd December 20, 2003
.Dt ZIC 8
.Os
Non-blank lines are expected to be of one of three types:
rule lines, zone lines, and link lines.
.Pp
+Names (such as month names) must be in English and are case insensitive.
+Abbreviations, if used, must be unambiguous in context.
+.Pp
A rule line has the form
.Dl Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
For example:
.Xr ctime 3 ,
.Xr tzfile 5 ,
.Xr zdump 8
-.\" @(#)zic.8 8.5
+.\" @(#)zic.8 8.6
.\" This file is in the public domain, so clarified as of
.\" 2009-05-17 by Arthur David Olson.
-/* $NetBSD: zic.c,v 1.28 2011/01/15 12:31:57 martin Exp $ */
+/* $NetBSD: zic.c,v 1.30 2012/08/09 12:38:26 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.28 2011/01/15 12:31:57 martin Exp $");
+__RCSID("$NetBSD: zic.c,v 1.30 2012/08/09 12:38:26 christos Exp $");
#endif /* !defined lint */
-static char elsieid[] = "@(#)zic.c 8.20";
-
+#include "version.h"
#include "private.h"
#include "locale.h"
#include "tzfile.h"
}
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", elsieid);
+ (void) printf("%s\n", TZVERSION);
exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
if (thistimei == 0)
writetype[0] = TRUE;
}
+#ifndef LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH
+ /*
+ ** For some pre-2011 systems: if the last-to-be-written
+ ** standard (or daylight) type has an offset different from the
+ ** most recently used offset,
+ ** append an (unused) copy of the most recently used type
+ ** (to help get global "altzone" and "timezone" variables
+ ** set correctly).
+ */
+ {
+ register int mrudst, mrustd, hidst, histd, type;
+
+ hidst = histd = mrudst = mrustd = -1;
+ for (i = thistimei; i < thistimelim; ++i)
+ if (isdsts[types[i]])
+ mrudst = types[i];
+ else mrustd = types[i];
+ for (i = 0; i < typecnt; ++i)
+ if (writetype[i]) {
+ if (isdsts[i])
+ hidst = i;
+ else histd = i;
+ }
+ if (hidst >= 0 && mrudst >= 0 && hidst != mrudst &&
+ gmtoffs[hidst] != gmtoffs[mrudst]) {
+ isdsts[mrudst] = -1;
+ type = addtype(gmtoffs[mrudst],
+ &chars[abbrinds[mrudst]],
+ TRUE,
+ ttisstds[mrudst],
+ ttisgmts[mrudst]);
+ isdsts[mrudst] = TRUE;
+ writetype[type] = TRUE;
+ }
+ if (histd >= 0 && mrustd >= 0 && histd != mrustd &&
+ gmtoffs[histd] != gmtoffs[mrustd]) {
+ isdsts[mrustd] = -1;
+ type = addtype(gmtoffs[mrustd],
+ &chars[abbrinds[mrustd]],
+ FALSE,
+ ttisstds[mrustd],
+ ttisgmts[mrustd]);
+ isdsts[mrustd] = FALSE;
+ writetype[type] = TRUE;
+ }
+ }
+#endif /* !defined LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH */
thistypecnt = 0;
for (i = 0; i < typecnt; ++i)
typemap[i] = writetype[i] ? thistypecnt++ : -1;
register int week;
if (rp->r_dycode == DC_DOWGEQ) {
- week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
- if ((week - 1) * DAYSPERWEEK + 1 != rp->r_dayofmonth)
+ if ((rp->r_dayofmonth % DAYSPERWEEK) != 1)
return -1;
+ week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
} else if (rp->r_dycode == DC_DOWLEQ) {
if (rp->r_dayofmonth == len_months[1][rp->r_month])
week = 5;
else {
- week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
- if (week * DAYSPERWEEK - 1 != rp->r_dayofmonth)
+ if ((rp->r_dayofmonth % DAYSPERWEEK) != 0)
return -1;
+ week = rp->r_dayofmonth / DAYSPERWEEK;
}
} else return -1; /* "cannot happen" */
(void) sprintf(result, "M%d.%d.%d",
register char * envvar;
register int max_abbr_len;
register int max_envvar_len;
+ register int prodstic; /* all rules are min to max */
max_abbr_len = 2 + max_format_len + max_abbrvar_len;
max_envvar_len = 2 * max_abbr_len + 5 * 9;
timecnt = 0;
typecnt = 0;
charcnt = 0;
+ prodstic = zonecount == 1;
/*
** Thanks to Earl Chew
** for noting the need to unconditionally initialize startttisstd.
if (max_year <= INT_MAX - YEARSPERREPEAT)
max_year += YEARSPERREPEAT;
else max_year = INT_MAX;
+ /*
+ ** Regardless of any of the above,
+ ** for a "proDSTic" zone which specifies that its rules
+ ** always have and always will be in effect,
+ ** we only need one cycle to define the zone.
+ */
+ if (prodstic) {
+ min_year = 1900;
+ max_year = min_year + YEARSPERREPEAT;
+ }
}
/*
** For the benefit of older systems,
--- /dev/null
+# $NetBSD: Makefile.inc,v 1.2 2011/03/12 07:55:09 matt Exp $
+
+.include <bsd.own.mk>
+
+# Our sources
+.PATH: ${.PARSEDIR} ${ARCHDIR}/tls
+
+SRCS+= tls.c
+CPPFLAGS.tls.c+= -D_LIBC_SOURCE
--- /dev/null
+/* $NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $ */
+
+/*-
+ * Copyright (c) 2011 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 <sys/cdefs.h>
+__RCSID("$NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $");
+
+#include "namespace.h"
+
+#define _rtld_tls_allocate __libc_rtld_tls_allocate
+#define _rtld_tls_free __libc_rtld_tls_free
+
+#include <sys/tls.h>
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <link_elf.h>
+#include <lwp.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+__dso_hidden void __libc_static_tls_setup(void);
+
+static const void *tls_initaddr;
+static size_t tls_initsize;
+static size_t tls_size;
+static size_t tls_allocation;
+static void *initial_thread_tcb;
+
+void * __libc_tls_get_addr(void);
+
+__weak_alias(__tls_get_addr, __libc_tls_get_addr)
+#ifdef __i386__
+__weak_alias(___tls_get_addr, __libc_tls_get_addr)
+#endif
+
+void *
+__libc_tls_get_addr(void)
+{
+
+ abort();
+ /* NOTREACHED */
+}
+
+__weak_alias(_rtld_tls_allocate, __libc_rtld_tls_allocate)
+
+struct tls_tcb *
+_rtld_tls_allocate(void)
+{
+ struct tls_tcb *tcb;
+ uint8_t *p;
+
+ if (initial_thread_tcb == NULL) {
+#ifdef __HAVE_TLS_VARIANT_II
+ tls_size = roundup2(tls_size, sizeof(void *));
+#endif
+ tls_allocation = tls_size + sizeof(*tcb);
+
+ initial_thread_tcb = p = mmap(NULL, tls_allocation,
+ PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+ } else {
+ p = calloc(1, tls_allocation);
+ }
+ if (p == NULL) {
+ static const char msg[] = "TLS allocation failed, terminating\n";
+ write(STDERR_FILENO, msg, sizeof(msg));
+ _exit(127);
+ }
+#ifdef __HAVE_TLS_VARIANT_I
+ /* LINTED */
+ tcb = (struct tls_tcb *)p;
+ p += sizeof(struct tls_tcb);
+#else
+ /* LINTED tls_size is rounded above */
+ tcb = (struct tls_tcb *)(p + tls_size);
+ tcb->tcb_self = tcb;
+#endif
+ memcpy(p, tls_initaddr, tls_initsize);
+
+ return tcb;
+}
+
+__weak_alias(_rtld_tls_free, __libc_rtld_tls_free)
+
+void
+_rtld_tls_free(struct tls_tcb *tcb)
+{
+ uint8_t *p;
+
+#ifdef __HAVE_TLS_VARIANT_I
+ /* LINTED */
+ p = (uint8_t *)tcb;
+#else
+ /* LINTED */
+ p = (uint8_t *)tcb - tls_size;
+#endif
+ if (p == initial_thread_tcb)
+ munmap(p, tls_allocation);
+ else
+ free(p);
+}
+
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
+
+static int
+__libc_static_tls_setup_cb(struct dl_phdr_info *data, size_t len, void *cookie)
+{
+ const Elf_Phdr *phdr = data->dlpi_phdr;
+ const Elf_Phdr *phlimit = data->dlpi_phdr + data->dlpi_phnum;
+
+ for (; phdr < phlimit; ++phdr) {
+ if (phdr->p_type != PT_TLS)
+ continue;
+ tls_initaddr = (void *)(phdr->p_vaddr + data->dlpi_addr);
+ tls_initsize = phdr->p_filesz;
+ tls_size = phdr->p_memsz;
+ }
+ return 0;
+}
+
+void
+__libc_static_tls_setup(void)
+{
+ struct tls_tcb *tcb;
+
+ if (&rtld_DYNAMIC != NULL) {
+#ifdef __powerpc__
+ /*
+ * Old powerpc crt0's are going to overwrite r2 so we need to
+ * restore it but only do so if the saved value isn't NULL (if
+ * it is NULL, ld.elf_so doesn't have the matching change).
+ */
+ if ((tcb = _lwp_getprivate()) != NULL)
+ __lwp_settcb(tcb);
+#endif
+ return;
+ }
+
+ dl_iterate_phdr(__libc_static_tls_setup_cb, NULL);
+
+ tcb = _rtld_tls_allocate();
+#ifdef __HAVE___LWP_SETTCB
+ __lwp_settcb(tcb);
+#else
+ _lwp_setprivate(tcb);
+#endif
+}
+
+#endif /* __HAVE_TLS_VARIANT_I || __HAVE_TLS_VARIANT_II */
#ifdef __minix
#include <paths.h>
#include <fcntl.h>
+#include <unistd.h>
+
/* Fake a uuidgen() syscall */
int uuidgen(struct uuid *store, int count)
{
-# $NetBSD: Makefile.inc,v 1.14 1999/02/24 15:05:21 drochner Exp $
+# $NetBSD: Makefile.inc,v 1.15 2012/03/02 17:27:49 christos Exp $
# yp sources
.PATH: ${ARCHDIR}/yp ${.CURDIR}/yp
MLINKS+=ypclnt.3 yp_all.3 ypclnt.3 yp_bind.3 ypclnt.3 yp_first.3 \
ypclnt.3 yp_get_default_domain.3 ypclnt.3 yp_master.3 \
ypclnt.3 yp_match.3 ypclnt.3 yp_next.3 ypclnt.3 yp_order.3 \
- ypclnt.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypclnt.3 ypprot_err.3
+ ypclnt.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypclnt.3 ypprot_err.3 \
+ ypclnt.3 yp_setbindtries.3
-/* $NetBSD: local.h,v 1.3 2009/10/21 01:07:46 snj Exp $ */
+/* $NetBSD: local.h,v 1.4 2012/03/20 16:30:26 matt Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
*/
__BEGIN_DECLS
-void __yp_unbind __P((struct dom_binding *));
-int _yp_invalid_domain __P((const char *));
+void __yp_unbind(struct dom_binding *);
+int _yp_invalid_domain(const char *);
__END_DECLS
-/* $NetBSD: xdryp.c,v 1.30 2006/05/11 17:11:57 mrg Exp $ */
+/* $NetBSD: xdryp.c,v 1.32 2012/03/20 16:30:26 matt Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <thorpej@NetBSD.org>.
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: xdryp.c,v 1.30 2006/05/11 17:11:57 mrg Exp $");
+__RCSID("$NetBSD: xdryp.c,v 1.32 2012/03/20 16:30:26 matt Exp $");
#endif
/*
/*
* Functions used only within this file.
*/
-static bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
-static bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
-static bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
-static bool_t xdr_ypmaplist_str __P((XDR *, char *));
+static bool_t xdr_ypbind_binding(XDR *, struct ypbind_binding *);
+static bool_t xdr_ypbind_resptype(XDR *, enum ypbind_resptype *);
+static bool_t xdr_ypstat(XDR *, enum ypbind_resptype *);
+static bool_t xdr_ypmaplist_str(XDR *, char *);
__warn_references(xdr_domainname,
"warning: this program uses xdr_domainname(), which is deprecated and buggy.")
bool_t
-xdr_domainname(xdrs, objp)
- XDR *xdrs;
- char *objp;
+xdr_domainname(XDR *xdrs, char *objp)
{
_DIAGASSERT(xdrs != NULL);
"warning: this program uses xdr_peername(), which is deprecated and buggy.")
bool_t
-xdr_peername(xdrs, objp)
- XDR *xdrs;
- char *objp;
+xdr_peername(XDR *xdrs, char *objp)
{
_DIAGASSERT(xdrs != NULL);
"warning: this program uses xdr_mapname(), which is deprecated and buggy.")
bool_t
-xdr_mapname(xdrs, objp)
- XDR *xdrs;
- char *objp;
+xdr_mapname(XDR *xdrs, char *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypdomain_wrap_string(xdrs, objp)
- XDR *xdrs;
- char **objp;
+xdr_ypdomain_wrap_string(XDR *xdrs, char **objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypmap_wrap_string(xdrs, objp)
- XDR *xdrs;
- char **objp;
+xdr_ypmap_wrap_string(XDR *xdrs, char **objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypowner_wrap_string(xdrs, objp)
- XDR *xdrs;
- char **objp;
+xdr_ypowner_wrap_string(XDR *xdrs, char **objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_datum(xdrs, objp)
- XDR *xdrs;
- datum *objp;
+xdr_datum(XDR *xdrs, datum *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypreq_key(xdrs, objp)
- XDR *xdrs;
- struct ypreq_key *objp;
+xdr_ypreq_key(XDR *xdrs, struct ypreq_key *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypreq_nokey(xdrs, objp)
- XDR *xdrs;
- struct ypreq_nokey *objp;
+xdr_ypreq_nokey(XDR *xdrs, struct ypreq_nokey *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_yp_inaddr(xdrs, objp)
- XDR *xdrs;
- struct in_addr *objp;
+xdr_yp_inaddr(XDR *xdrs, struct in_addr *objp)
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(objp != NULL);
return xdr_opaque(xdrs, (caddr_t)(void *)&objp->s_addr,
- sizeof objp->s_addr);
+ (u_int)sizeof objp->s_addr);
}
static bool_t
-xdr_ypbind_binding(xdrs, objp)
- XDR *xdrs;
- struct ypbind_binding *objp;
+xdr_ypbind_binding(XDR *xdrs, struct ypbind_binding *objp)
{
_DIAGASSERT(xdrs != NULL);
return FALSE;
if (!xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
- sizeof objp->ypbind_binding_port))
+ (u_int)sizeof objp->ypbind_binding_port))
return FALSE;
return TRUE;
}
static bool_t
-xdr_ypbind_resptype(xdrs, objp)
- XDR *xdrs;
- enum ypbind_resptype *objp;
+xdr_ypbind_resptype(XDR *xdrs, enum ypbind_resptype *objp)
{
_DIAGASSERT(xdrs != NULL);
}
static bool_t
-xdr_ypstat(xdrs, objp)
- XDR *xdrs;
- enum ypbind_resptype *objp;
+xdr_ypstat(XDR *xdrs, enum ypbind_resptype *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypbind_resp(xdrs, objp)
- XDR *xdrs;
- struct ypbind_resp *objp;
+xdr_ypbind_resp(XDR *xdrs, struct ypbind_resp *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypresp_val(xdrs, objp)
- XDR *xdrs;
- struct ypresp_val *objp;
+xdr_ypresp_val(XDR *xdrs, struct ypresp_val *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypbind_setdom(xdrs, objp)
- XDR *xdrs;
- struct ypbind_setdom *objp;
+xdr_ypbind_setdom(XDR *xdrs, struct ypbind_setdom *objp)
{
char *cp;
}
bool_t
-xdr_ypresp_key_val(xdrs, objp)
- XDR *xdrs;
- struct ypresp_key_val *objp;
+xdr_ypresp_key_val(XDR *xdrs, struct ypresp_key_val *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypall(xdrs, incallback)
- XDR *xdrs;
- struct ypall_callback *incallback;
+xdr_ypall(XDR *xdrs, struct ypall_callback *incallback)
{
struct ypresp_key_val out;
char key[YPMAXRECORD], val[YPMAXRECORD];
}
bool_t
-xdr_ypresp_master(xdrs, objp)
- XDR *xdrs;
- struct ypresp_master *objp;
+xdr_ypresp_master(XDR *xdrs, struct ypresp_master *objp)
{
_DIAGASSERT(xdrs != NULL);
}
static bool_t
-xdr_ypmaplist_str(xdrs, objp)
- XDR *xdrs;
- char *objp;
+xdr_ypmaplist_str(XDR *xdrs, char *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypmaplist(xdrs, objp)
- XDR *xdrs;
- struct ypmaplist *objp;
+xdr_ypmaplist(XDR *xdrs, struct ypmaplist *objp)
{
_DIAGASSERT(xdrs != NULL);
return FALSE;
if (!xdr_pointer(xdrs, (char **)(void *)&objp->ypml_next,
- sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
+ (u_int)sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
return FALSE;
return TRUE;
}
bool_t
-xdr_ypresp_maplist(xdrs, objp)
- XDR *xdrs;
- struct ypresp_maplist *objp;
+xdr_ypresp_maplist(XDR *xdrs, struct ypresp_maplist *objp)
{
_DIAGASSERT(xdrs != NULL);
return FALSE;
if (!xdr_pointer(xdrs, (char **)(void *)&objp->list,
- sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
+ (u_int)sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
return FALSE;
return TRUE;
}
bool_t
-xdr_ypresp_order(xdrs, objp)
- XDR *xdrs;
- struct ypresp_order *objp;
+xdr_ypresp_order(XDR *xdrs, struct ypresp_order *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypreq_xfr(xdrs, objp)
- XDR *xdrs;
- struct ypreq_xfr *objp;
+xdr_ypreq_xfr(XDR *xdrs, struct ypreq_xfr *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_ypmap_parms(xdrs, objp)
- XDR *xdrs;
- struct ypmap_parms *objp;
+xdr_ypmap_parms(XDR *xdrs, struct ypmap_parms *objp)
{
_DIAGASSERT(xdrs != NULL);
}
bool_t
-xdr_yppushresp_xfr(xdrs, objp)
- XDR *xdrs;
- struct yppushresp_xfr *objp;
+xdr_yppushresp_xfr(XDR *xdrs, struct yppushresp_xfr *objp)
{
_DIAGASSERT(xdrs != NULL);
-/* $NetBSD: yp_all.c,v 1.12 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: yp_all.c,v 1.13 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_all.c,v 1.12 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: yp_all.c,v 1.13 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
#endif
int
-yp_all(indomain, inmap, incallback)
- const char *indomain;
- const char *inmap;
- struct ypall_callback *incallback;
+yp_all(const char *indomain, const char *inmap,
+ struct ypall_callback *incallback)
{
struct ypreq_nokey yprnk;
struct dom_binding *ysd;
-/* $NetBSD: yp_first.c,v 1.14 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: yp_first.c,v 1.16 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_first.c,v 1.14 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: yp_first.c,v 1.16 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
+extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_first,_yp_first)
#endif
int
-yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- char **outkey;
- int *outkeylen;
- char **outval;
- int *outvallen;
+yp_first(const char *indomain, const char *inmap, char **outkey,
+ int *outkeylen, char **outval, int *outvallen)
{
struct ypresp_key_val yprkv;
struct ypreq_nokey yprnk;
(xdrproc_t)xdr_ypreq_nokey,
&yprnk, (xdrproc_t)xdr_ypresp_key_val, &yprkv, _yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_first: clnt_call");
nerrs = 0;
- }
+ } else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
+ return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}
}
int
-yp_next(indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- const char *inkey;
- int inkeylen;
- char **outkey;
- int *outkeylen;
- char **outval;
- int *outvallen;
+yp_next(const char *indomain, const char *inmap, const char *inkey,
+ int inkeylen, char **outkey, int *outkeylen, char **outval, int *outvallen)
{
struct ypresp_key_val yprkv;
struct ypreq_key yprk;
(xdrproc_t)xdr_ypreq_key,
&yprk, (xdrproc_t)xdr_ypresp_key_val, &yprkv, _yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_next: clnt_call");
nerrs = 0;
- }
+ } else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
+ return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}
-/* $NetBSD: yp_maplist.c,v 1.11 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: yp_maplist.c,v 1.13 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_maplist.c,v 1.11 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: yp_maplist.c,v 1.13 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
+extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_maplist,_yp_maplist)
#endif
int
-yp_maplist(indomain, outmaplist)
- const char *indomain;
- struct ypmaplist **outmaplist;
+yp_maplist( const char *indomain, struct ypmaplist **outmaplist)
{
struct dom_binding *ysd;
struct ypresp_maplist ypml;
(xdrproc_t)xdr_ypdomain_wrap_string, &indomain,
(xdrproc_t)xdr_ypresp_maplist, &ypml, _yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_maplist: clnt_call");
nerrs = 0;
- }
+ } else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
+ return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}
-/* $NetBSD: yp_master.c,v 1.13 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: yp_master.c,v 1.15 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_master.c,v 1.13 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: yp_master.c,v 1.15 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
+extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_master,_yp_master)
#endif
int
-yp_master(indomain, inmap, outname)
- const char *indomain;
- const char *inmap;
- char **outname;
+yp_master(const char *indomain, const char *inmap, char **outname)
{
struct dom_binding *ysd;
struct ypresp_master yprm;
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_master, &yprm, _yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
nerrs = 0;
- }
+ } else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
+ return YPERR_YPSERV;
ysd->dom_vers = -1;
goto again;
}
-/* $NetBSD: yp_match.c,v 1.17 2005/11/29 03:12:01 christos Exp $ */
+/* $NetBSD: yp_match.c,v 1.19 2012/03/20 16:30:26 matt Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_match.c,v 1.17 2005/11/29 03:12:01 christos Exp $");
+__RCSID("$NetBSD: yp_match.c,v 1.19 2012/03/20 16:30:26 matt Exp $");
#endif
#include "namespace.h"
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
+extern int _yplib_bindtries;
extern char _yp_domain[];
#ifdef __weak_alias
time_t expire_t;
} *ypmc;
-static bool_t ypmatch_add __P((const char *, const char *, int, char *, int));
-static bool_t ypmatch_find __P((const char *, const char *, int, const char **,
- int *));
+static bool_t ypmatch_add(const char *, const char *, int, char *, int);
+static bool_t ypmatch_find(const char *, const char *, int, const char **,
+ int *);
static bool_t
-ypmatch_add(map, key, keylen, val, vallen)
- const char *map;
- const char *key;
- int keylen;
- char *val;
- int vallen;
+ypmatch_add(const char *map, const char *key, int keylen, char *val, int vallen)
{
struct ypmatch_ent *ep;
time_t t;
}
static bool_t
-ypmatch_find(map, key, keylen, val, vallen)
- const char *map;
- const char *key;
- int keylen;
- const char **val;
- int *vallen;
+ypmatch_find(const char *map, const char *key, int keylen, const char **val,
+ int *vallen)
{
struct ypmatch_ent *ep;
time_t t;
#endif
int
-yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
- const char *indomain;
- const char *inmap;
- const char *inkey;
- int inkeylen;
- char **outval;
- int *outvallen;
+yp_match(const char *indomain, const char *inmap, const char *inkey,
+ int inkeylen, char **outval, int *outvallen)
{
struct dom_binding *ysd;
struct ypresp_val yprv;
(xdrproc_t)xdr_ypresp_val, &yprv,
_yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_match: clnt_call");
nerrs = 0;
}
+ else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries) {
+ return YPERR_YPSERV;
+ }
ysd->dom_vers = -1;
goto again;
}
-/* $NetBSD: yp_order.c,v 1.12 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: yp_order.c,v 1.14 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yp_order.c,v 1.12 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: yp_order.c,v 1.14 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
extern struct timeval _yplib_timeout;
extern int _yplib_nerrs;
+extern int _yplib_bindtries;
#ifdef __weak_alias
__weak_alias(yp_order,_yp_order)
#endif
int
-yp_order(indomain, inmap, outorder)
- const char *indomain;
- const char *inmap;
- int *outorder;
+yp_order(const char *indomain, const char *inmap, int *outorder)
{
struct dom_binding *ysd;
struct ypresp_order ypro;
(xdrproc_t)xdr_ypresp_order, &ypro,
_yplib_timeout);
if (r != RPC_SUCCESS) {
- if (++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && ++nerrs == _yplib_nerrs) {
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
nerrs = 0;
- }
+ } else if (_yplib_bindtries > 0 && ++nerrs == _yplib_bindtries)
+ return YPERR_YPSERV;
if (r == RPC_PROCUNAVAIL) {
/* Case of NIS+ server in NIS compat mode */
r = YPERR_YPERR;
-.\" $NetBSD: ypclnt.3,v 1.24 2010/03/22 19:30:55 joerg Exp $
+.\" $NetBSD: ypclnt.3,v 1.26 2012/03/04 11:52:32 wiz Exp $
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 21, 1997
+.Dd March 2, 2012
.Dt YPCLNT 3
.Os
.Sh NAME
.Nm yp_unbind ,
.Nm yperr_string ,
.Nm ypprot_err
+.Nm yp_setbindtries
.Nd Interface to the YP subsystem
.Sh LIBRARY
.Lb libc
.Fn yperr_string "int incode"
.Ft int
.Fn ypprot_err "unsigned int incode"
+.Ft int
+.Fn yp_setbindtries "int ntries"
.Sh DESCRIPTION
The
.Nm ypclnt
The
.Nm ypclnt
suite provides the following functionality:
-.Bl -tag -width yp_match()xx
+.Bl -tag -width yp_matchxxxx
.It Fn yp_match
Provides the value associated with the given key.
.It Fn yp_first
.Nm ypclnt
error code suitable for
.Fn yperr_string .
+.It Fn yp_setbindtries
+Set the number of tries to attempt to bind to the domain before returning
+an error.
+The default is
+.Dv 0
+which means wait forever if no ypserver is not found of if the RPC
+communication with the yp server fails.
+If the number passed is negative, the current number of tries is not modified.
+.Pp
+This function is an extention to the client library that allows application
+to catch communication problems with the ypserver without blocking forever.
.El
.Sh RETURN VALUES
All functions in the
-/* $NetBSD: yperr_string.c,v 1.7 2005/11/29 03:12:01 christos Exp $ */
+/* $NetBSD: yperr_string.c,v 1.8 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yperr_string.c,v 1.7 2005/11/29 03:12:01 christos Exp $");
+__RCSID("$NetBSD: yperr_string.c,v 1.8 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
#endif
char *
-yperr_string(incode)
- int incode;
+yperr_string(int incode)
{
static char err[80];
-/* $NetBSD: yplib.c,v 1.43 2006/11/03 20:18:49 christos Exp $ */
+/* $NetBSD: yplib.c,v 1.45 2012/03/20 16:30:26 matt Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: yplib.c,v 1.43 2006/11/03 20:18:49 christos Exp $");
+__RCSID("$NetBSD: yplib.c,v 1.45 2012/03/20 16:30:26 matt Exp $");
#endif
#include "namespace.h"
struct timeval _yplib_rpc_timeout = { YPLIB_TIMEOUT / YPLIB_RPC_RETRIES,
1000000 * (YPLIB_TIMEOUT % YPLIB_RPC_RETRIES) / YPLIB_RPC_RETRIES };
int _yplib_nerrs = 5;
+int _yplib_bindtries = 0;
#ifdef __weak_alias
__weak_alias(yp_bind, _yp_bind)
__weak_alias(yp_unbind, _yp_unbind)
__weak_alias(yp_get_default_domain, _yp_get_default_domain)
+__weak_alias(yp_setbindtries, _yp_setbindtries)
#endif
#ifdef _REENTRANT
#endif
int
-_yp_dobind(dom, ypdb)
- const char *dom;
- struct dom_binding **ypdb;
+yp_setbindtries(int ntries)
+{
+ int old_val = _yplib_bindtries;
+
+ if (ntries >= 0)
+ _yplib_bindtries = ntries;
+ return old_val;
+}
+
+int
+_yp_dobind(const char *dom, struct dom_binding **ypdb)
{
static int pid = -1;
char path[MAXPATHLEN];
(xdrproc_t)xdr_ypdomain_wrap_string, &dom,
(xdrproc_t)xdr_ypbind_resp, &ypbr, _yplib_timeout);
if (r != RPC_SUCCESS) {
- if (new == 0 && ++nerrs == _yplib_nerrs) {
+ if (_yplib_bindtries <= 0 && new == 0 &&
+ ++nerrs == _yplib_nerrs) {
nerrs = 0;
fprintf(stderr,
"YP server for domain %s not responding, still trying\n",
dom);
}
+ else if (_yplib_bindtries > 0 &&
+ ++nerrs == _yplib_bindtries) {
+ free(ysd);
+ return YPERR_YPBIND;
+ }
clnt_destroy(client);
ysd->dom_vers = -1;
goto again;
}
void
-__yp_unbind(ypb)
- struct dom_binding *ypb;
+__yp_unbind(struct dom_binding *ypb)
{
_DIAGASSERT(ypb != NULL);
}
int
-yp_bind(dom)
- const char *dom;
+yp_bind(const char *dom)
{
if (_yp_invalid_domain(dom))
return YPERR_BADARGS;
}
void
-yp_unbind(dom)
- const char *dom;
+yp_unbind(const char *dom)
{
struct dom_binding *ypb, *ypbp;
}
int
-yp_get_default_domain(domp)
- char **domp;
+yp_get_default_domain(char **domp)
{
if (domp == NULL)
return YPERR_BADARGS;
}
int
-_yp_check(dom)
- char **dom;
+_yp_check(char **dom)
{
char *unused;
int good;
* returns non-zero if invalid
*/
int
-_yp_invalid_domain(dom)
- const char *dom;
+_yp_invalid_domain(const char *dom)
{
if (dom == NULL || *dom == '\0')
return 1;
-/* $NetBSD: ypprot_err.c,v 1.5 2003/12/10 12:06:25 agc Exp $ */
+/* $NetBSD: ypprot_err.c,v 1.6 2012/06/25 22:32:46 abs Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ypprot_err.c,v 1.5 2003/12/10 12:06:25 agc Exp $");
+__RCSID("$NetBSD: ypprot_err.c,v 1.6 2012/06/25 22:32:46 abs Exp $");
#endif
#include "namespace.h"
#endif
int
-ypprot_err(incode)
- unsigned int incode;
+ypprot_err(unsigned int incode)
{
switch (incode) {
case YP_TRUE:
Elf_Phdr *phdr = NULL;
int e, i = 0;
int first = 1;
- vir_bytes startv, stacklow;
+ vir_bytes startv = 0, stacklow;
assert(execi != NULL);
assert(execi->hdr != NULL);
#define _GNU_SOURCE
#endif
+#ifndef __minix
/* Needed for gmtime_r on Interix */
#define _REENTRANT
+#endif
#if HAVE_CONFIG_H
#include "config.h"
CPPFLAGS.sched_start.c+= -I${NETBSDSRCDIR}
-LIBCSRCDIR=${NETBSDSRCDIR}/lib/libc
+LIBCSRCDIR= ${NETBSDSRCDIR}/lib/libc
+CPPFLAGS+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}
+CPPFLAGS+= -D_LIBMINC
+
+#
+# Customized versions of libc functions.
+#
+SRCS+= fputs.c
#
# Shared libc with userspace (/common/lib/libc)
#
.include "${NETBSDSRCDIR}/common/lib/libc/Makefile.inc"
.include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.libc.inc"
+
.if empty(SRCS:Mbyte_swap_8.*)
SRCS+= bswap64.c
.endif
+.if empty(SRCS:Mmemset2.*)
+SRCS+= memset.c
+.endif
+
+# Quad support
.if (${MACHINE_ARCH} != "alpha") && \
(${MACHINE_ARCH} != "mips64eb") && \
(${MACHINE_ARCH} != "mips64el") && \
(${MACHINE_ARCH} != "powerpc64") && \
(${MACHINE_ARCH} != "sparc64") && \
(${MACHINE_ARCH} != "x86_64")
-# Quad support
SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c \
iordi3.c lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c \
notdi2.c qdivrem.c subdi3.c ucmpdi2.c udivdi3.c umoddi3.c \
xordi3.c
.endif
+
.for i in \
random.c strtoll.c strtoul.c strtoull.c strtoumax.c \
memchr.c memcmp.c memcpy.c memmove.c popcount32.c popcount64.c \
strlcpy.c strlen.c strncasecmp.c strncmp.c strncpy.c strnlen.c \
strrchr.c strsep.c strstr.c ptree.c rb.c sha1.c sha2.c
SRCS+= ${i}
-CPPFLAGS.${i}+= -D_LIBC -I${LIBCSRCDIR}/include
.endfor
-.if empty(SRCS:Mmemset2.*)
-SRCS+= memset.c
-.endif
-
-#
-# Customized versions of libc functions.
-#
-SRCS+= fputs.c _stdfile.c
-CPPFLAGS.fputs.c+= -I${LIBCSRCDIR}/include
-
+CPPFLAGS.sha2.c+= -D_LIBC
+CPPFLAGS.rb.c+= -D_LIBC
+CPPFLAGS.strlcpy.c+= -D_LIBC
#
# Functions imported directly from the libc.
#
+# Import from misc (_libc_init symbols)
+.for i in initfini.c stack_protector.c
+.PATH.c: ${LIBCSRCDIR}/misc
+SRCS+= ${i}
+CPPFLAGS.${i}+= -Dxprintf=printf
+.endfor
+
# Import from stdio
-.for i in sprintf.c fprintf.c perror.c vsnprintf.c snprintf.c \
+.for i in findfp.c sprintf.c fprintf.c perror.c vsnprintf.c snprintf.c \
_rand48.c lrand48.c srand48.c
.PATH.c: ${LIBCSRCDIR}/stdio
-CPPFLAGS.${i}= -I${LIBCSRCDIR}/stdio -I${LIBCSRCDIR}/include
+CPPFLAGS.${i}= -I${LIBCSRCDIR}/stdio
SRCS+= ${i}
.endfor
+
# Import from stdlib
.for i in abort.c atexit.c atoi.c exit.c getenv.c \
getopt.c ldiv.c malloc.c
.PATH.c: ${LIBCSRCDIR}/stdlib
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/stdlib -I${LIBCSRCDIR}/include
+CPPFLAGS.${i}+= -I${LIBCSRCDIR}/stdlib
.endfor
-# Import from gen
+# Import from gen
errlist.c: ${LIBCSRCDIR}/gen/errlist.awk \
- ${NETBSDSRCDIR}/include/sys/errno.h
- cat ${NETBSDSRCDIR}/include/sys/errno.h | ${TOOL_SED} 's/(_SIGN//' | ${TOOL_AWK} -f ${LIBCSRCDIR}/gen/errlist.awk > ${.TARGET}
+ ${NETBSDSRCDIR}/sys/sys/errno.h
+ ${TOOL_CAT} ${NETBSDSRCDIR}/sys/sys/errno.h | ${TOOL_SED} 's/(_SIGN//' | ${TOOL_AWK} -f ${LIBCSRCDIR}/gen/errlist.awk > ${.TARGET}
CLEANFILES+= errlist.c
.for i in assert.c _errno.c errno.c _env.c errlist.c \
isfinitef_ieee754.c isfinited_ieee754.c \
signbitf_ieee754.c signbitd_ieee754.c \
nanf.c
-.PATH.c: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/gen ${LIBCSRCDIR}/gen/minix \
+.PATH.c .PATH.S: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/gen ${LIBCSRCDIR}/gen/minix \
${LIBCSRCDIR}/gen ${LIBCSRCDIR}
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include
.endfor
CPPFLAGS.ctype_.c+= -I${LIBCSRCDIR}/locale
CPPFLAGS.isctype.c+= -I${LIBCSRCDIR}/locale
CPPFLAGS.tolower_.c+= -I${LIBCSRCDIR}/locale
CPPFLAGS.toupper_.c+= -I${LIBCSRCDIR}/locale
+
# Import from regex
.for i in regcomp.c regerror.c regexec.c regfree.c
.PATH.c: ${LIBCSRCDIR}/regex
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include
.endfor
+
# Import from string
.for i in strcspn.c strerror.c strerror_r.c strtol.c \
bcopy.S bzero.S
.PATH.S: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/string
.PATH.c: ${LIBCSRCDIR}/string
SRCS+= ${i}
-CPPFLAGS.${i}+= -D_LIBC -I${LIBCSRCDIR}/include
+CPPFLAGS.${i}+= -D_LIBC
.endfor
CPPFLAGS.strtol.c+= -I${LIBCSRCDIR}/../../common/lib/libc/stdlib
+
# Import from time
.for i in asctime.c localtime.c strftime.c
.PATH.c: ${LIBCSRCDIR}/time
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include
.endfor
+
# Import from locale
.for i in _def_time.c
.PATH.c: ${LIBCSRCDIR}/locale
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/locale
+CPPFLAGS.${i}+= -I${LIBCSRCDIR}/locale
.endfor
+
# Import from sys-minix
.for i in access.c brk.c close.c environ.c execve.c fork.c \
getgid.c getpid.c getuid.c gettimeofday.c loadname.c \
.PATH.c: ${LIBCSRCDIR}/sys-minix
.PATH.S: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/sys-minix
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include
.endfor
CPPFLAGS+= -D_LIBSYS
+++ /dev/null
-#include <stdlib.h>
-#include <minix/sysutil.h>
-
-void abort()
-{
- panic("Abort.");
-}
.for i in infinityl.c
.PATH.c: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/gen
SRCS+= ${i}
-CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include
.endfor
# Import from string
.for i in bcmp.S
.PATH.S: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/string
SRCS+= ${i}
-CPPFLAGS.${i}+= -D_LIBC -I${LIBCSRCDIR}/include
+CPPFLAGS.${i}+= -D_LIBC
.endfor
SRCS= rmtlib.c
MAN= rmtops.3
+.ifndef __MINIX
CPPFLAGS+= -D_REENTRANT
+.endif
.include <bsd.lib.mk>
# Makefile for libsys
.include <bsd.own.mk>
-# LSC For now
-NOGCCERROR:= yes
-
LIB= sys
SRCS= \
.endif
CPPFLAGS.sched_start.c+= -I${NETBSDSRCDIR}
-CPPFLAGS.vprintf.c+= -D__NBSD_LIBC
.if (${CC} == "gcc") || (${CC} == "clang")
LDADD+= -lminc
/* Try exit */
_exit(1);
-#ifndef __NBSD_LIBC
/* Try to signal ourself */
abort();
-#endif
/* If exiting nicely through PM fails for some reason, try to
* commit suicide. E.g., message to PM might fail due to deadlock.
/*===========================================================================*
* tickdelay *
*===========================================================================*/
-int tickdelay(ticks)
-long ticks; /* number of ticks to wait */
+int tickdelay(clock_t ticks)
{
/* This function uses the synchronous alarm to delay for a while. This works
* even if a previous synchronous alarm was scheduled, because the remaining
/* vprintf() uses kputc() to print characters. */
void kputc(int c);
-#ifdef __NBSD_LIBC
#define count_kputc(c) do { charcount++; putf((c), farg); } while(0)
int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *farg)
-#else /* !NBSD_LIBC */
-#define count_kputc(c) do { charcount++; kputc(c); } while(0)
-
-int vprintf(const char *fmt, va_list argp)
-#endif /* NBSD_LIBC */
{
int c, charcount = 0;
enum { LEFT, RIGHT } adjust;
}
/* Mark the end with a null (should be something else, like -1). */
-#ifdef __NBDS_LIBC
- putf(0, farg);
-#else
kputc(0);
-#endif
+
return charcount;
}
-#ifdef __NBSD_LIBC
#include <sys/cdefs.h>
#include <assert.h>
#include <unistd.h>
{
return __fvprintf(__xfputc, fmt, argp, fp);
}
-#endif
/*
* $PchId: kprintf.c,v 1.5 1996/04/11 06:59:05 philip Exp $
.include "${NETBSDSRCDIR}/common/lib/libutil/Makefile.inc"
WARNS?= 5
-# LSC MINIX Does not compile with -Werror
-NOGCCERROR=yes
LIB= util
CPPFLAGS+=-DLIBC_SCCS -I${.CURDIR}
LINTFLAGS+=-w
ttymsg.3 util.3
.else
-SRCS+= efun.c getbootfile.c \
- getmntopts.c sockaddr_snprintf.c\
+SRCS+= efun.c \
+ getmntopts.c sockaddr_snprintf.c\
login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \
logwtmp.c logwtmpx.c opendisk.c \
passwd.c pw_scan.c pidfile.c pidlock.c pty.c \
secure_path.c stat_flags.c \
ttyaction.c \
-MAN= efun.3 getbootfile.3 \
+MAN= efun.3 \
getmntopts.3 \
login.3 login_cap.3 loginx.3 \
opendisk.3 openpty.3 pidfile.3 pidlock.3 \
__opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
int (*ofn)(const char *, int, ...))
{
+#ifndef __minix
int f, rawpart;
+#else
+ int f;
+#endif
if (buf == NULL) {
errno = EFAULT;
const struct sockaddr * const sa)
{
const void *a = NULL;
+#ifndef __minix
char abuf[1024], nbuf[1024], *addr = NULL, *w = NULL;
+#else
+ char abuf[1024], nbuf[1024], *addr = NULL;
+#endif
char Abuf[1024], pbuf[32], *name = NULL, *port = NULL;
char *ebuf = &sbuf[len - 1], *buf = sbuf;
const char *ptr, *s;
int p = -1;
- const struct sockaddr_in *sin4 = NULL;
#ifndef __minix
const struct sockaddr_at *sat = NULL;
+#endif
+ const struct sockaddr_in *sin4 = NULL;
+#ifndef __minix
const struct sockaddr_in6 *sin6 = NULL;
const struct sockaddr_un *sun = NULL;
const struct sockaddr_dl *sdl = NULL;
-#ifndef __NBSD_LIBC
#define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */
-#endif
#define _MINIX 1 /* tell headers to include MINIX stuff */
#define _SYSTEM 1 /* tell headers that this is the kernel */
-# $NetBSD: Makefile,v 1.112 2012/08/04 15:17:16 matt Exp $
+# $NetBSD: Makefile,v 1.114 2012/08/23 21:21:15 joerg Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
WARNS?=4
-#LSC MINIX until warnings get fixed...
-NOGCCERROR:=yes
-
-# This executable needs to be linked dynamically
-LDSTATIC= -dynamic
-
-# And the minix gcc currently references /libexec/ld-elf.so.1
-SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld-elf.so.1
# Minix Clang binaries references /libexec/ld.elf_so
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld.elf_so
+# And the minix gcc currently references /libexec/ld-elf.so.1
+SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld-elf.so.1
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
- map_object.c load.c search.c headers.c paths.c expand.c
+ map_object.c load.c search.c headers.c paths.c expand.c \
+ tls.c symver.c diagassert.c
.if ${USE_FORT} == "yes"
.PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
.PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
SRCS+= exit.c
-errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/include/sys/errno.h
+errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
mv -f ${.TARGET}.tmp ${.TARGET}
#CPPFLAGS+= -DDEBUG
#CPPFLAGS+= -DRTLD_DEBUG
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
-DBG= -g
-#COPTS= -O3 -fomit-frame-pointer
+#DBG= -g
+COPTS= -O3 -fomit-frame-pointer
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
--- /dev/null
+Steps for adding TLS support for a new platform:
+
+(1) Declare TLS variant in machine/types.h by defining either
+__HAVE_TLS_VARIANT_I or __HAVE_TLS_VARIANT_II.
+
+(2) _lwp_makecontext has to set the reserved register or kernel transfer
+variable in uc_mcontext to the provided value of 'private'. See
+src/lib/libc/arch/$PLATFORM/gen/_lwp.c.
+
+This is not possible on the VAX as there is no free space in ucontext_t.
+This requires either a special version of _lwp_create or versioning
+everything using ucontext_t. Debug support depends on getting the data from
+ucontext_t, so the second option is possibly required.
+
+(3) _lwp_setprivate(2) has to update the same register as
+_lwp_makecontext uses for the private area pointer. Normally
+cpu_lwp_setprivate is provided by MD to reflect the kernel view and
+enabled by defining __HAVE_CPU_LWP_SETPRIVATE in machine/types.h.
+cpu_setmcontext is responsible for keeping the MI l_private field
+synchronised by calling lwp_setprivate as needed.
+
+cpu_switchto has to update the mapping.
+
+_lwp_setprivate is used for the initial thread, all other threads
+created by libpthread use _lwp_makecontext for this purpose.
+
+(4) Provide __tls_get_addr and possible other MD functions for dynamic
+TLS offset computation. If such alternative entry points exist (currently
+only i386), also add a weak reference to 0 in src/lib/libc/tls/tls.c.
+
+The generic implementation can be found in tls.c and is used with
+__HAVE_COMMON___TLS_GET_ADDR. It depends on ___lwp_getprivate_fast
+(see below).
+
+(5) Implement the necessary relocation records in mdreloc.c. There are
+typically three relocation types found in dynamic binaries:
+
+(a) R_TYPE(TLS_DTPOFF): Offset inside the module. The common TLS code
+ensures that the DTV vector points to offset 0 inside the module TLS block.
+This is normally def->st_value + rela->r_addend.
+
+(b) R_TYPE(TLS_DTPMOD): Module index.
+
+(c) R_TYPE(TLS_TPOFF): Static TLS offset. The code has to check whether
+the static TLS offset for this module has been allocated
+(defobj->tls_done) and otherwise call _rtld_tls_offset_allocate(). This
+may fail if no static space is available and the object has been pulled
+in via dlopen(3).
+
+For TLS Variant I, this is typically:
+
+def->st_value + rela->r_addend + defobj->tlsoffset + sizeof(struct tls_tcb)
+
+e.g. the relocation doesn't include the fixed TCB.
+
+For TLS Variant II, this is typically:
+
+def->st_value - defobj->tlsoffset + rela->r_addend
+
+e.g. starting offset is counting down from the TCB.
+
+(6) Implement _lwp_getprivate_fast() in machine/mcontext.h and set
+__HAVE___LWP_GETPRIVATE_FAST in machine/types.h.
+
+(7) Test using src/tests/lib/libc/tls. Make sure with "objdump -R" that
+t_tls_dynamic has two TPOFF relocations and h_tls_dlopen.so.1 and
+libh_tls_dynamic.so.1 have both two DTPMOD and DTPOFF relocations.
rtld:
* resolve MIPS binding lossage
+TLS:
+* implement proper allocator for static TLS and support for actively
+ freeing DTV entries.
+
binutils/gcc:
* alpha: why are there GLOB_DAT relocs in ld.elf_so?
* alpha: bogus textrels in rtti info
-/* $NetBSD: alpha_reloc.c,v 1.38 2010/09/30 09:11:18 skrll Exp $ */
+/* $NetBSD: alpha_reloc.c,v 1.40 2011/03/31 15:30:31 skrll Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: alpha_reloc.c,v 1.38 2010/09/30 09:11:18 skrll Exp $");
+__RCSID("$NetBSD: alpha_reloc.c,v 1.40 2011/03/31 15:30:31 skrll Exp $");
#endif /* not lint */
#include <sys/types.h>
+#include <sys/tls.h>
#include <string.h>
#include "rtld.h"
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TPREL64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ tmp = (Elf64_Addr)(def->st_value +
+ sizeof(struct tls_tcb) + defobj->tlsoffset +
+ rela->r_addend);
+
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+
+ rdbg(("TPREL64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(DTPMOD64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ tmp = (Elf64_Addr)defobj->tlsindex;
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+
+ rdbg(("DTPMOD64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(DTPREL64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ tmp = (Elf64_Addr)(def->st_value + rela->r_addend);
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+
+ rdbg(("DTPREL64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
Elf_Addr result = 0; /* XXX gcc */
int err;
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &result);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)result;
}
-/* $NetBSD: mdreloc.c,v 1.34 2010/08/06 16:33:17 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.37 2011/11/18 16:10:03 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.34 2010/08/06 16:33:17 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.37 2011/11/18 16:10:03 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TLS_DTPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ tmp = (Elf_Addr)(def->st_value);
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+
+ rdbg(("TLS_DTPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)tmp));
+
+ break;
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ tmp = (Elf_Addr)(defobj->tlsindex);
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+
+ rdbg(("TLS_DTPMOD32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)tmp));
+
+ break;
+
+ case R_TYPE(TLS_TPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ tmp = (Elf_Addr)def->st_value + defobj->tlsoffset +
+ sizeof(struct tls_tcb);
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *where = tmp;
+ else
+ store_ptr(where, tmp);
+ rdbg(("TLS_TPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)tmp));
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"contents = %p, symbol = %s",
Elf_Addr new_value = 0; /* XXX gcc */
int err;
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rel, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: rtld_start.S,v 1.10 2009/11/11 14:15:41 skrll Exp $ */
+/* $NetBSD: rtld_start.S,v 1.11 2012/08/13 02:53:25 matt Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
#include <machine/asm.h>
-RCSID("$NetBSD: rtld_start.S,v 1.10 2009/11/11 14:15:41 skrll Exp $")
+RCSID("$NetBSD: rtld_start.S,v 1.11 2012/08/13 02:53:25 matt Exp $")
.text
.align 0
bl _rtld /* call the shared loader */
mov r3, r0 /* save entry point */
- ldr r2, [sp, #0] /* r2 = cleanup */
- ldr r1, [sp, #4] /* r1 = obj_main */
- add sp, sp, #8 /* restore stack */
+ ldr r2, [sp], #4 /* pop r2 = cleanup */
+ ldr r1, [sp], #4 /* pop r1 = obj_main */
mov r0, r4 /* restore ps_strings */
#ifdef _ARM_ARCH_4T
bx r3 /* jump to the entry point */
* lr = &GOT[2]
*/
_rtld_bind_start:
- stmdb sp!,{r0-r4,sl,fp}
+ stmdb sp!,{r0-r4,sl,fp} /* 8 byte aligned (lr already saved) */
sub r1, ip, lr /* r1 = 4 * (n + 1) */
sub r1, r1, #4 /* r1 = 4 * n */
-/* $NetBSD: hppa_reloc.c,v 1.34 2010/09/24 11:41:46 skrll Exp $ */
+/* $NetBSD: hppa_reloc.c,v 1.42 2012/01/06 10:38:57 skrll Exp $ */
/*-
* Copyright (c) 2002, 2004 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hppa_reloc.c,v 1.34 2010/09/24 11:41:46 skrll Exp $");
+__RCSID("$NetBSD: hppa_reloc.c,v 1.42 2012/01/06 10:38:57 skrll Exp $");
#endif /* not lint */
#include <stdlib.h>
(void)memcpy(where, &val, sizeof(val));
}
+static __inline void
+fdc(void *addr)
+{
+ __asm volatile("fdc %%r0(%%sr0, %0)" : : "r" (addr));
+}
+
+static __inline void
+fic(void *addr)
+{
+ __asm volatile("fic %%r0(%%sr0,%0)" : : "r" (addr));
+}
+
+static __inline void
+sync(void)
+{
+ __asm volatile("sync" : : : "memory");
+}
+
+#define PLT_STUB_MAGIC1 0x00c0ffee
+#define PLT_STUB_MAGIC2 0xdeadbeef
+
+#define PLT_STUB_INSN1 0x0e801081 /* ldw 0(%r20), %r1 */
+#define PLT_STUB_INSN2 0xe820c000 /* bv %r0(%r1) */
+
/*
* In the runtime architecture (ABI), PLABEL function pointers are
* distinguished from normal function pointers by having the next-least-
* Because I'm hesitant to use NEW while relocating self,
* this is a small pool of preallocated PLABELs.
*/
-#define HPPA_PLABEL_PRE (14)
+#define HPPA_PLABEL_PRE (32)
static hppa_plabel hppa_plabel_pre[HPPA_PLABEL_PRE];
static int hppa_plabel_pre_next = 0;
case DT_PLTGOT:
pltgot = (Elf_Addr *)
(relocbase + dynp->d_un.d_ptr);
- break;
+ break;
}
}
relalim = (const Elf_Rela *)((const char *)relafirst + relasz);
plabel = &hppa_plabel_pre[hppa_plabel_pre_next++];
- plabel->hppa_plabel_pc = (Elf_Addr)
+ plabel->hppa_plabel_pc = (Elf_Addr)
(relocbase + sym->st_value + rela->r_addend);
- plabel->hppa_plabel_sl = (Elf_Addr)pltgot;
+ plabel->hppa_plabel_sl = (Elf_Addr)pltgot;
- SLIST_INSERT_HEAD(&hppa_plabel_list, plabel, hppa_plabel_next);
+ SLIST_INSERT_HEAD(&hppa_plabel_list, plabel, hppa_plabel_next);
*((Elf_Addr *)where) = (Elf_Addr)(RTLD_MAKE_PLABEL(plabel));
}
void
_rtld_setup_pltgot(const Obj_Entry *obj)
{
- __rtld_setup_hppa_pltgot(obj, obj->pltgot);
+ Elf_Word *got = obj->pltgot;
+
+ assert(got[-2] == PLT_STUB_MAGIC1);
+ assert(got[-1] == PLT_STUB_MAGIC2);
+
+ __rtld_setup_hppa_pltgot(obj, got);
+
+ fdc(&got[-2]);
+ fdc(&got[-1]);
+ fdc(&got[1]);
+ sync();
+ fic(&got[-2]);
+ fic(&got[-1]);
+ fic(&got[1]);
+ sync();
+
+ /*
+ * libc makes use of %t1 (%r22) to pass errno values to __cerror. Fixup
+ * the PLT stub to not use %r22.
+ */
+ got[-7] = PLT_STUB_INSN1;
+ got[-6] = PLT_STUB_INSN2;
+ fdc(&got[-7]);
+ fdc(&got[-6]);
+ sync();
+ fic(&got[-7]);
+ fic(&got[-6]);
+ sync();
}
int
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TLS_TPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(defobj->tlsoffset + def->st_value +
+ rela->r_addend + sizeof(struct tls_tcb));
+
+ rdbg(("TPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(defobj->tlsindex);
+
+ rdbg(("TLS_DTPMOD32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_DTPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value);
+
+ rdbg(("TLS_DTPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
assert(ELF_R_SYM(rela->r_info) != 0);
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: rtld_start.S,v 1.9 2010/09/30 19:32:40 skrll Exp $ */
+/* $NetBSD: rtld_start.S,v 1.12 2012/01/06 10:38:57 skrll Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* twice later: once to call _rtld, and again to transfer to the
* program's entry point.
*/
- stw %arg0, HPPA_FRAME_ARG(0)(%r3)
+ stw %arg0, HPPA_FRAME_ARG(0)(%r3)
/*
* We can't move to C until we relocate at least the
stw %arg0, -8(%arg1)
bv %r0(%rp)
stw %r19, -4(%arg1)
-EXIT(__rtld_hppa_setup_pltgot)
+EXIT(__rtld_setup_hppa_pltgot)
/*
* In order to support lazy binding, this implementation of _rtld_bind_start is
/* 0(%r3) is filled with the saved %r3 above */
stw %ret0, 4(%r3)
stw %ret1, 8(%r3)
+ stw %t1, 12(%r3) /* %r22 */
/*
* The linker PLT stub loads %r20 with (GOT - 8) for the object that
ldw HPPA_FRAME_ARG(3)(%r3), %arg3
ldw 4(%r3), %ret0
ldw 8(%r3), %ret1
+ ldw 12(%r3), %t1 /* %r22 */
/* End stack calling convention. */
ldo HPPA_FRAME_SIZE(%r3), %sp
-/* $NetBSD: mdreloc.c,v 1.32 2010/08/06 16:33:18 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.34 2011/03/25 18:07:05 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.32 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.34 2011/03/25 18:07:05 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
+#include <sys/ucontext.h>
#include "debug.h"
#include "rtld.h"
rdbg(("COPY (avoid in main)"));
break;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ case R_TYPE(TLS_TPOFF):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value - defobj->tlsoffset);
+
+ rdbg(("TLS_TPOFF %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+ break;
+
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(defobj->tlsindex);
+
+ rdbg(("TLS_DTPMOD32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+ break;
+
+ case R_TYPE(TLS_DTPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value);
+
+ rdbg(("TLS_DTPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+#endif
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"contents = %p, symbol = %s",
new_value = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rel, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
}
return err;
}
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+/*
+ * i386 specific GNU variant of __tls_get_addr using register based
+ * argument passing.
+ */
+#define DTV_MAX_INDEX(dtv) ((size_t)((dtv)[-1]))
+
+__dso_public __attribute__((__regparm__(1))) void *
+___tls_get_addr(void *arg_)
+{
+ size_t *arg = (size_t *)arg_;
+ void **dtv;
+ struct tls_tcb *tcb = __lwp_getprivate_fast();
+ size_t idx = arg[0], offset = arg[1];
+
+ dtv = tcb->tcb_dtv;
+
+ if (__predict_true(idx < DTV_MAX_INDEX(dtv) && dtv[idx] != NULL))
+ return (uint8_t *)dtv[idx] + offset;
+
+ return _rtld_tls_get_addr(tcb, idx, offset);
+}
+#endif
-/* $NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:18 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)defobj->tlsindex;
+ rdbg(("DTPMOD32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TLS_DTPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ - TLS_DTV_OFFSET);
+ rdbg(("DTPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TLS_TPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ + defobj->tlsoffset - TLS_TP_OFFSET);
+ rdbg(("TPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
result = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &result);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)result;
}
-/* $NetBSD: mips_reloc.c,v 1.60 2010/09/24 15:20:52 matt Exp $ */
+/* $NetBSD: mips_reloc.c,v 1.62 2011/03/25 18:07:05 joerg Exp $ */
/*
* Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mips_reloc.c,v 1.60 2010/09/24 15:20:52 matt Exp $");
+__RCSID("$NetBSD: mips_reloc.c,v 1.62 2011/03/25 18:07:05 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/endian.h>
+#include <sys/tls.h>
#include <stdlib.h>
#include <string.h>
break;
}
+#if ELFSIZE == 64
+ case R_TYPE(TLS_DTPMOD64):
+#else
+ case R_TYPE(TLS_DTPMOD32):
+#endif
+ {
+ Elf_Addr old = load_ptr(where, ELFSIZE / 8);
+ Elf_Addr val = old;
+
+ def = _rtld_find_symdef(r_symndx, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ val += (Elf_Addr)defobj->tlsindex;
+
+ store_ptr(where, val, ELFSIZE / 8);
+ rdbg(("DTPMOD %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[r_symndx].st_name,
+ obj->path, (void *)old, defobj->path));
+ break;
+ }
+
+#if ELFSIZE == 64
+ case R_TYPE(TLS_DTPREL64):
+#else
+ case R_TYPE(TLS_DTPREL32):
+#endif
+ {
+ Elf_Addr old = load_ptr(where, ELFSIZE / 8);
+ Elf_Addr val = old;
+
+ def = _rtld_find_symdef(r_symndx, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ val += (Elf_Addr)def->st_value - TLS_DTV_OFFSET;
+ store_ptr(where, val, ELFSIZE / 8);
+
+ rdbg(("DTPREL %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[r_symndx].st_name,
+ obj->path, (void *)old, defobj->path));
+ break;
+ }
+
+#if ELFSIZE == 64
+ case R_TYPE(TLS_TPREL64):
+#else
+ case R_TYPE(TLS_TPREL32):
+#endif
+ {
+ Elf_Addr old = load_ptr(where, ELFSIZE / 8);
+ Elf_Addr val = old;
+
+ def = _rtld_find_symdef(r_symndx, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ val += (Elf_Addr)(def->st_value + defobj->tlsoffset
+ - TLS_TP_OFFSET);
+ store_ptr(where, val, ELFSIZE / 8);
+
+ rdbg(("TPREL %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[r_symndx].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+ }
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"contents = %p, symbol = %s",
Elf_Addr new_value = 0; /* XXX gcc */
int err;
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, a0, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: ppc_reloc.c,v 1.46 2011/01/16 01:22:29 matt Exp $ */
+/* $NetBSD: ppc_reloc.c,v 1.49 2011/03/25 18:07:06 joerg Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ppc_reloc.c,v 1.46 2011/01/16 01:22:29 matt Exp $");
+__RCSID("$NetBSD: ppc_reloc.c,v 1.49 2011/03/25 18:07:06 joerg Exp $");
#endif /* not lint */
#include <stdarg.h>
if (obj->gotptr != NULL) {
obj->gotptr[1] = (Elf_Addr) _rtld_bind_secureplt_start;
obj->gotptr[2] = (Elf_Addr) obj;
+ dbg(("obj %s secure-plt gotptr=%p start=%p obj=%p",
+ obj->path, obj->gotptr,
+ (void *) obj->gotptr[1], (void *) obj->gotptr[2]));
} else {
Elf_Word *pltcall, *pltresolve;
Elf_Word *jmptab;
if (N > 8192)
N += N-8192;
+ dbg(("obj %s bss-plt pltgot=%p jmptab=%u start=%p obj=%p",
+ obj->path, obj->pltgot, 18 + N * 2,
+ _rtld_bind_bssplt_start, obj));
+
pltcall = obj->pltgot;
jmptab = pltcall + 18 + N * 2;
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)defobj->tlsindex;
+ rdbg(("DTPMOD32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(DTPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ - TLS_DTV_OFFSET);
+ rdbg(("DTPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ + defobj->tlsoffset - TLS_TP_OFFSET);
+ rdbg(("TPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
caddr_t
_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
{
- const Elf_Rela *rela = (const void *)((const char *)obj->pltrela + reloff);
+ const Elf_Rela *rela = obj->pltrela + reloff;
Elf_Addr new_value;
int err;
new_value = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, reloff, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: rtld_start.S,v 1.14 2011/01/16 01:22:29 matt Exp $ */
+/* $NetBSD: rtld_start.S,v 1.17 2011/09/26 01:52:22 mrg Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
* bss-plt expects %r11 to be index of the rela entry.
* So for bss-plt, we multiply the index by 12 to get the offset.
*/
-ENTRY_NOPROFILE(_rtld_bind_bssplt_start)
- slwi %r11,%r11,2
- add %r0,%r11,%r11
- add %r11,%r11,%r0
ENTRY_NOPROFILE(_rtld_bind_secureplt_start)
stwu %r1,-160(%r1)
+ stw %r0,20(%r1)
+
+ /*
+ * Instead of division which is costly we will use multiplicative
+ * inverse. a / n = ((a * inv(n)) >> 32)
+ * where inv(n) = (0x100000000 + n - 1) / n
+ */
+ mr %r0,%r11
+ lis %r11,0x15555556@h # load multiplicative inverse of 12
+ ori %r11,%r11,0x15555556@l
+ mulhwu %r11,%r11,%r0 # get high half of multiplication
+
+ b 1f
+ENTRY_NOPROFILE(_rtld_bind_bssplt_start)
+ stwu %r1,-160(%r1)
stw %r0,20(%r1)
+1:
mflr %r0
stw %r0,16(%r1) # save lr
mfcr %r0
addi %r1,%r1,160
bctr
-END(_rtld_bind_start)
+END(_rtld_bind_secureplt_start)
.globl _rtld_powerpc_pltcall
.globl _rtld_powerpc_pltresolve
-/* $NetBSD: mdreloc.c,v 1.28 2010/08/06 16:33:18 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.30 2011/03/25 18:07:06 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.28 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.30 2011/03/25 18:07:06 joerg Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.28 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.30 2011/03/25 18:07:06 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
+#include <sys/tls.h>
#include "debug.h"
#include "rtld.h"
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TLS_DTPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value);
+
+ rdbg(("TLS_DTPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(defobj->tlsindex);
+
+ rdbg(("TLS_DTPMOD32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_TPOFF32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)def->st_value +
+ rela->r_addend + defobj->tlsoffset +
+ sizeof(struct tls_tcb);
+
+ rdbg(("TLS_TPOFF32 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
new_value = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &new_value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: mdreloc.c,v 1.44 2010/08/06 16:33:18 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.47 2011/03/31 12:47:01 nakayama Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.44 2010/08/06 16:33:18 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.47 2011/03/31 12:47:01 nakayama Exp $");
#endif /* not lint */
#include <errno.h>
#define _RF_U 0x04000000 /* Unaligned */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ( (s) & 0xff) /* right shift */
-static const int reloc_target_flags[] = {
+static const int reloc_target_flags[R_TYPE(TLS_TPOFF64)+1] = {
0, /* NONE */
_RF_S|_RF_A| _RF_SZ(8) | _RF_RS(0), /* RELOC_8 */
_RF_S|_RF_A| _RF_SZ(16) | _RF_RS(0), /* RELOC_16 */
_RF_SZ(32) | _RF_RS(0), /* JMP_SLOT */
_RF_A| _RF_B| _RF_SZ(32) | _RF_RS(0), /* RELATIVE */
_RF_S|_RF_A| _RF_U| _RF_SZ(32) | _RF_RS(0), /* UA_32 */
+
+ /* TLS and 64 bit relocs not listed here... */
};
#ifdef RTLD_DEBUG_RELOC
"DISP_16", "DISP_32", "WDISP_30", "WDISP_22", "HI22",
"22", "13", "LO10", "GOT10", "GOT13",
"GOT22", "PC10", "PC22", "WPLT30", "COPY",
- "GLOB_DAT", "JMP_SLOT", "RELATIVE", "UA_32"
+ "GLOB_DAT", "JMP_SLOT", "RELATIVE", "UA_32",
+
+ /* not used with 32bit userland, besides a few of the TLS ones */
+ "PLT32",
+ "HIPLT22", "LOPLT10", "LOPLT10", "PCPLT22", "PCPLT32",
+ "10", "11", "64", "OLO10", "HH22",
+ "HM10", "LM22", "PC_HH22", "PC_HM10", "PC_LM22",
+ "WDISP16", "WDISP19", "GLOB_JMP", "7", "5", "6",
+ "DISP64", "PLT64", "HIX22", "LOX10", "H44", "M44",
+ "L44", "REGISTER", "UA64", "UA16",
+ "TLS_GD_HI22", "TLS_GD_LO10", "TLS_GD_ADD", "TLS_GD_CALL",
+ "TLS_LDM_HI22", "TLS_LDM_LO10", "TLS_LDM_ADD", "TLS_LDM_CALL",
+ "TLS_LDO_HIX22", "TLS_LDO_LOX10", "TLS_LDO_ADD", "TLS_IE_HI22",
+ "TLS_IE_LO10", "TLS_IE_LD", "TLS_IE_LDX", "TLS_IE_ADD", "TLS_LE_HIX22",
+ "TLS_LE_LOX10", "TLS_DTPMOD32", "TLS_DTPMOD64", "TLS_DTPOFF32",
+ "TLS_DTPOFF64", "TLS_TPOFF32", "TLS_TPOFF64",
};
#endif
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
+#define RELOC_TLS(t) (t >= R_TYPE(TLS_GD_HI22))
static const int reloc_target_bitmask[] = {
#define _BM(x) (~(-(1ULL << (x))))
/*
* We use the fact that relocation types are an `enum'
- * Note: R_SPARC_6 is currently numerically largest.
+ * Note: R_SPARC_TLS_TPOFF64 is currently numerically largest.
*/
- if (type > R_TYPE(6))
+ if (type > R_TYPE(TLS_TPOFF64))
return (-1);
value = rela->r_addend;
+ /*
+ * Handle TLS relocations here, they are different.
+ */
+ if (RELOC_TLS(type)) {
+ switch (type) {
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)defobj->tlsindex;
+
+ rdbg(("TLS_DTPMOD32 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_DTPOFF32):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value
+ + rela->r_addend);
+
+ rdbg(("TLS_DTPOFF32 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_TPOFF32):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value -
+ defobj->tlsoffset +
+ rela->r_addend);
+
+ rdbg(("TLS_TPOFF32 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+ }
+ continue;
+ }
+
+ /*
+ * If it is no TLS relocation (handled above), we can not
+ * deal with it if it is beyound R_SPARC_6.
+ */
+ if (type > R_TYPE(6))
+ return (-1);
+
/*
* Handle relative relocs here, as an optimization.
*/
value = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &value);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)value;
}
-/* $NetBSD: mdreloc.c,v 1.50 2010/09/24 12:00:10 skrll Exp $ */
+/* $NetBSD: mdreloc.c,v 1.53 2012/07/22 09:21:03 martin Exp $ */
/*-
* Copyright (c) 2000 Eduardo Horvath.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.50 2010/09/24 12:00:10 skrll Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.53 2012/07/22 09:21:03 martin Exp $");
#endif /* not lint */
#include <errno.h>
#define _RF_U 0x04000000 /* Unaligned */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ( (s) & 0xff) /* right shift */
-static const int reloc_target_flags[] = {
+static const int reloc_target_flags[R_TYPE(TLS_TPOFF64)+1] = {
0, /* NONE */
_RF_S|_RF_A| _RF_SZ(8) | _RF_RS(0), /* RELOC_8 */
_RF_S|_RF_A| _RF_SZ(16) | _RF_RS(0), /* RELOC_16 */
_RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* REGISTER */
_RF_S|_RF_A| _RF_U| _RF_SZ(64) | _RF_RS(0), /* UA64 */
_RF_S|_RF_A| _RF_U| _RF_SZ(16) | _RF_RS(0), /* UA16 */
+/* TLS relocs not represented here! */
};
#ifdef RTLD_DEBUG_RELOC
"HM10", "LM22", "PC_HH22", "PC_HM10", "PC_LM22",
"WDISP16", "WDISP19", "GLOB_JMP", "7", "5", "6",
"DISP64", "PLT64", "HIX22", "LOX10", "H44", "M44",
- "L44", "REGISTER", "UA64", "UA16"
+ "L44", "REGISTER", "UA64", "UA16",
+ "TLS_GD_HI22", "TLS_GD_LO10", "TLS_GD_ADD", "TLS_GD_CALL",
+ "TLS_LDM_HI22", "TLS_LDM_LO10", "TLS_LDM_ADD", "TLS_LDM_CALL",
+ "TLS_LDO_HIX22", "TLS_LDO_LOX10", "TLS_LDO_ADD", "TLS_IE_HI22",
+ "TLS_IE_LO10", "TLS_IE_LD", "TLS_IE_LDX", "TLS_IE_ADD", "TLS_LE_HIX22",
+ "TLS_LE_LOX10", "TLS_DTPMOD32", "TLS_DTPMOD64", "TLS_DTPOFF32",
+ "TLS_DTPOFF64", "TLS_TPOFF32", "TLS_TPOFF64",
};
#endif
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
+#define RELOC_TLS(t) (t >= R_TYPE(TLS_GD_HI22))
static const long reloc_target_bitmask[] = {
#define _BM(x) (~(-(1ULL << (x))))
if (type == R_TYPE(NONE))
continue;
+ /* OLO10 relocations have extra info */
+ if ((type & 0x00ff) == R_SPARC_OLO10)
+ type = R_SPARC_OLO10;
+
/* We do JMP_SLOTs in _rtld_bind() below */
if (type == R_TYPE(JMP_SLOT))
continue;
/*
* We use the fact that relocation types are an `enum'
- * Note: R_SPARC_UA16 is currently numerically largest.
+ * Note: R_SPARC_TLS_TPOFF64 is currently numerically largest.
*/
- if (type > R_TYPE(UA16))
- return (-1);
+ if (type > R_TYPE(TLS_TPOFF64)) {
+ dbg(("unknown relocation type %x at %p", type, rela));
+ return -1;
+ }
value = rela->r_addend;
+ /*
+ * Handle TLS relocations here, they are different.
+ */
+ if (RELOC_TLS(type)) {
+ switch (type) {
+ case R_TYPE(TLS_DTPMOD64):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf64_Addr)defobj->tlsindex;
+
+ rdbg(("TLS_DTPMOD64 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_DTPOFF64):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf64_Addr)(def->st_value
+ + rela->r_addend);
+
+ rdbg(("DTPOFF64 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+
+ case R_TYPE(TLS_TPOFF64):
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf64_Addr)(def->st_value -
+ defobj->tlsoffset +
+ rela->r_addend);
+
+ rdbg(("TLS_TPOFF64 %s in %s --> %p",
+ obj->strtab +
+ obj->symtab[symnum].st_name,
+ obj->path, (void *)*where));
+
+ break;
+ }
+ continue;
+ }
+
/*
* Handle relative relocs here, as an optimization.
*/
value += (Elf_Addr)(defobj->relocbase + def->st_value);
}
+ if (type == R_SPARC_OLO10) {
+ value = (value & 0x3ff)
+ + (((Elf64_Xword)rela->r_info<<32)>>40);
+ }
+
if (RELOC_PC_RELATIVE(type)) {
value -= (Elf_Addr)where;
}
rela -= 4;
}
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &result);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)result;
}
-/* $NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:19 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:07 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:19 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:07 joerg Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.27 2010/08/06 16:33:19 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:07 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
result = 0; /* XXX gcc */
+ _rtld_shared_enter();
err = _rtld_relocate_plt_object(obj, rela, &result);
if (err)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)result;
}
-/* $NetBSD: mdreloc.c,v 1.38 2010/08/06 16:33:19 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.40 2011/03/25 18:07:07 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.38 2010/08/06 16:33:19 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.40 2011/03/25 18:07:07 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
*where32 = tmp32;
rdbg(("32/32S %s in %s --> %p in %s",
obj->strtab + obj->symtab[symnum].st_name,
- obj->path, (void *)(unsigned long)*where32,
+ obj->path, (void *)(uintptr_t)*where32,
defobj->path));
break;
case R_TYPE(64): /* word64 S + A */
(void *)*where64));
break;
+ case R_TYPE(TPOFF64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done &&
+ _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where64 = (Elf64_Addr)(def->st_value -
+ defobj->tlsoffset + rela->r_addend);
+
+ rdbg(("TPOFF64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where64));
+
+ break;
+
+ case R_TYPE(DTPMOD64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where64 = (Elf64_Addr)defobj->tlsindex;
+
+ rdbg(("DTPMOD64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where64));
+
+ break;
+
+ case R_TYPE(DTPOFF64):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where64 = (Elf64_Addr)(def->st_value + rela->r_addend);
+
+ rdbg(("DTPOFF64 %s in %s --> %p",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where64));
+
+ break;
+
case R_TYPE(COPY):
rdbg(("COPY"));
break;
new_value = 0; /* XXX GCC4 */
+ _rtld_shared_enter();
error = _rtld_relocate_plt_object(obj, rela, &new_value);
if (error)
_rtld_die();
+ _rtld_shared_exit();
return (caddr_t)new_value;
}
-/* $NetBSD: rtld_start.S,v 1.8 2010/12/05 00:56:07 joerg Exp $ */
+/* $NetBSD: rtld_start.S,v 1.9 2011/12/11 22:07:26 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
movq %rsp,%r12 # stack pointer arg to _rtld
pushq %rbx # save ps_strings
+ andq $~15,%rsp # align rsp, to be restored from r12
+
leaq _GLOBAL_OFFSET_TABLE_(%rip),%rax
leaq _DYNAMIC(%rip),%rdi # &_DYNAMIC
movq %rdi,%rbx
movq %rbx,%rsi
call _rtld # _rtld(sp, relocbase)
+ leaq -8(%r12),%rsp # restore saved rsp, including %rbx
popq %rbx # %rbx = ps_strings
popq %rdx # %rdx = cleanup
popq %rcx # %rcx = obj_main
--- /dev/null
+#include <assert.h>
+#include <stdlib.h>
+
+__dead void
+/*ARGSUSED*/
+__diagassert13(const char *fn, int fl, const char *fu, const char *m)
+{
+ abort();
+}
{
const char *p, *ep;
char *bp = buf;
+#if !defined(__minix)
size_t len;
char name[32];
+#endif /* !defined(__minix) */
switch (what) {
case 0: /* HWCAP XXX: Not yet */
-/* $NetBSD: headers.c,v 1.39 2011/01/16 01:22:29 matt Exp $ */
+/* $NetBSD: headers.c,v 1.43 2012/08/15 03:46:06 matt Exp $ */
/*
* Copyright 1996 John D. Polstra.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.39 2011/01/16 01:22:29 matt Exp $");
+__RCSID("$NetBSD: headers.c,v 1.43 2012/08/15 03:46:06 matt Exp $");
#endif /* not lint */
#include <err.h>
obj->strsize = dynp->d_un.d_val;
break;
+ case DT_VERNEED:
+ obj->verneed = (const Elf_Verneed *)
+ (obj->relocbase + dynp->d_un.d_ptr);
+ break;
+
+ case DT_VERNEEDNUM:
+ obj->verneednum = dynp->d_un.d_val;
+ break;
+
+ case DT_VERDEF:
+ obj->verdef = (const Elf_Verdef *)
+ (obj->relocbase + dynp->d_un.d_ptr);
+ break;
+
+ case DT_VERDEFNUM:
+ obj->verdefnum = dynp->d_un.d_val;
+ break;
+
+ case DT_VERSYM:
+ obj->versyms = (const Elf_Versym *)
+ (obj->relocbase + dynp->d_un.d_ptr);
+ break;
+
case DT_HASH:
{
const Elf_Symindx *hashtab = (const Elf_Symindx *)
init = dynp->d_un.d_ptr;
break;
+#ifdef HAVE_INITFINI_ARRAY
+ case DT_INIT_ARRAY:
+ obj->init_array =
+ (fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
+ break;
+
+ case DT_INIT_ARRAYSZ:
+ obj->init_arraysz = dynp->d_un.d_val / sizeof(fptr_t);
+ break;
+#endif
+
case DT_FINI:
fini = dynp->d_un.d_ptr;
break;
+#ifdef HAVE_INITFINI_ARRAY
+ case DT_FINI_ARRAY:
+ obj->fini_array =
+ (fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
+ break;
+
+ case DT_FINI_ARRAYSZ:
+ obj->fini_arraysz = dynp->d_un.d_val / sizeof(fptr_t);
+ break;
+#endif
+
/*
* Don't process DT_DEBUG on MIPS as the dynamic section
* is mapped read-only. DT_MIPS_RLD_MAP is used instead.
obj->phsize, (long)obj->relocbase));
break;
}
- assert(obj->phdr == phdr);
for (ph = phdr; ph < phlimit; ++ph) {
vaddr = (Elf_Addr)(uintptr_t)(obj->relocbase + ph->p_vaddr);
case PT_DYNAMIC:
obj->dynamic = (Elf_Dyn *)(uintptr_t)vaddr;
break;
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ case PT_TLS:
+ obj->tlsindex = 1;
+ obj->tlssize = ph->p_memsz;
+ obj->tlsalign = ph->p_align;
+ obj->tlsinitsize = ph->p_filesz;
+ obj->tlsinit = (void *)(uintptr_t)ph->p_vaddr;
+ break;
+#endif
}
}
assert(nsegs == 2);
_rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
int flags)
{
+#if !defined(__minix)
Library_Xform *x = _rtld_xforms;
Obj_Entry *o = NULL;
size_t j;
ssize_t i;
+#endif /* !defined(__minix) */
bool got = false;
+#if !defined(__minix)
union {
int i;
u_quad_t q;
char s[16];
} val;
+#endif /* !defined(__minix) */
+#if !defined(__minix)
dbg(("load by name %s %p", name, x));
for (; x; x = x->next) {
-#ifdef __minix
- continue;
-#else
if (strcmp(x->name, name) != 0)
continue;
}
-#endif
}
+#endif /* !defined(__minix) */
if (got)
return true;
-/* $NetBSD: map_object.c,v 1.41 2010/10/16 10:27:07 skrll Exp $ */
+/* $NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $ */
/*
* Copyright 1996 John D. Polstra.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: map_object.c,v 1.41 2010/10/16 10:27:07 skrll Exp $");
+__RCSID("$NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $");
#endif /* not lint */
#include <errno.h>
-#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#define MINIXVERBOSE 0
+#if MINIXVERBOSE
+#include <stdio.h>
+#endif
+
static int protflags(int); /* Elf flags -> mmap protection */
#define EA_UNDEF (~(Elf_Addr)0)
Obj_Entry *obj;
Elf_Ehdr *ehdr;
Elf_Phdr *phdr;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ Elf_Phdr *phtls;
+#endif
size_t phsize;
Elf_Phdr *phlimit;
Elf_Phdr *segs[2];
int nsegs;
caddr_t mapbase = MAP_FAILED;
size_t mapsize = 0;
- size_t bsssize = 0;
int mapflags;
Elf_Off base_offset;
#ifdef MAP_ALIGNED
Elf_Addr data_vlimit;
int data_flags;
caddr_t data_addr;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ Elf_Addr tls_vaddr = 0; /* Noise GCC */
+#endif
Elf_Addr phdr_vaddr;
size_t phdr_memsz;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
caddr_t gap_addr;
size_t gap_size;
+#endif
int i;
#ifdef RTLD_LOADER
Elf_Addr clear_vaddr;
#endif
if (sb != NULL && sb->st_size < (off_t)sizeof (Elf_Ehdr)) {
- _rtld_error("%s: unrecognized file format1", path);
+ _rtld_error("%s: not ELF file (too short)", path);
return NULL;
}
goto bad;
}
/* Make sure the file is valid */
- if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 ||
- ehdr->e_ident[EI_CLASS] != ELFCLASS) {
- _rtld_error("%s: unrecognized file format2 [%x != %x]", path,
+ if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0) {
+ _rtld_error("%s: not ELF file (magic number bad)", path);
+ goto bad;
+ }
+ if (ehdr->e_ident[EI_CLASS] != ELFCLASS) {
+ _rtld_error("%s: invalid ELF class %x; expected %x", path,
ehdr->e_ident[EI_CLASS], ELFCLASS);
goto bad;
}
* in that order.
*/
phdr = (Elf_Phdr *) ((caddr_t)ehdr + ehdr->e_phoff);
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ phtls = NULL;
+#endif
phsize = ehdr->e_phnum * sizeof(phdr[0]);
obj->phdr = NULL;
phdr_vaddr = EA_UNDEF;
if (nsegs < 2)
segs[nsegs] = phdr;
++nsegs;
- dbg(("%s: PT_LOAD %p", obj->path, phdr));
+
+#if ELFSIZE == 64
+#define PRImemsz PRIu64
+#else
+#define PRImemsz PRIu32
+#endif
+ dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_LOAD",
+ (void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
break;
case PT_PHDR:
phdr_vaddr = phdr->p_vaddr;
phdr_memsz = phdr->p_memsz;
- dbg(("%s: PT_PHDR %p phsize %zu", obj->path,
- (void *)(uintptr_t)phdr_vaddr, phdr_memsz));
+ dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_PHDR",
+ (void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
break;
case PT_DYNAMIC:
obj->dynamic = (void *)(uintptr_t)phdr->p_vaddr;
- dbg(("%s: PT_DYNAMIC %p", obj->path, obj->dynamic));
+ dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_DYNAMIC",
+ (void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
+ break;
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ case PT_TLS:
+ phtls = phdr;
+ dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_TLS",
+ (void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
break;
+#endif
}
++phdr;
obj->vaddrbase = base_vaddr;
obj->isdynamic = ehdr->e_type == ET_DYN;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ if (phtls != NULL) {
+ ++_rtld_tls_dtv_generation;
+ obj->tlsindex = ++_rtld_tls_max_index;
+ obj->tlssize = phtls->p_memsz;
+ obj->tlsalign = phtls->p_align;
+ obj->tlsinitsize = phtls->p_filesz;
+ tls_vaddr = phtls->p_vaddr;
+ }
+#endif
+
obj->phdr_loaded = false;
for (i = 0; i < nsegs; i++) {
if (phdr_vaddr != EA_UNDEF &&
_rtld_error("mmap of data failed: %s", xstrerror(errno));
goto bad;
}
-#endif
-#ifndef __minix
- bsssize= base_vlimit - data_vlimit;
- if(bsssize > 0) {
/* Overlay the bss segment onto the proper region. */
- if (mmap(mapbase + data_vlimit - base_vaddr, bsssize,
+ if (mmap(mapbase + data_vlimit - base_vaddr, base_vlimit - data_vlimit,
data_flags, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) ==
MAP_FAILED) {
- _rtld_error("mmap of bss (at 0x%lx, 0x%lx bytes) failed: %s",
- mapbase + data_vlimit - base_vaddr, bsssize, xstrerror(errno));
+ _rtld_error("mmap of bss failed: %s", xstrerror(errno));
goto bad;
}
- }
/* Unmap the gap between the text and data. */
gap_addr = mapbase + round_up(text_vlimit - base_vaddr);
gap_size = data_addr - gap_addr;
-
if (gap_size != 0 && mprotect(gap_addr, gap_size, PROT_NONE) == -1) {
_rtld_error("mprotect of text -> data gap failed: %s",
xstrerror(errno));
/* Non-file portion of BSS mapped above. */
#endif
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ if (phtls != NULL)
+ obj->tlsinit = mapbase + tls_vaddr;
+#endif
+
obj->mapbase = mapbase;
obj->mapsize = mapsize;
obj->relocbase = mapbase - base_vaddr;
{
Objlist_Entry *elm;
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ if (obj->tls_done)
+ _rtld_tls_offset_free(obj);
+#endif
xfree(obj->path);
while (obj->needed != NULL) {
Needed_Entry *needed = obj->needed;
static Search_Path *_rtld_find_path(Search_Path *, const char *, size_t);
static Search_Path **_rtld_append_path(Search_Path **, Search_Path **,
const char *, const char *, const char *);
+#if !defined(__minix)
static void _rtld_process_mapping(Library_Xform **, const char *,
const char *);
+#endif /* !defined(__minix) */
static char *exstrdup(const char *, const char *);
+#if !defined(__minix)
static const char *getstr(const char **, const char *, const char *);
static const char *getcstr(const char **, const char *, const char *);
static const char *getword(const char **, const char *, const char *);
static int matchstr(const char *, const char *, const char *);
+#endif /* !defined(__minix) */
static const char WS[] = " \t\n";
return (cp);
}
+#if !defined(__minix)
/*
* Like strsep(), but takes end of string and doesn't put any NUL. To
* detect empty string, compare `*p' and return value.
return (*p == 0);
}
+#endif /* !defined(__minix) */
static Search_Path *
_rtld_find_path(Search_Path *path, const char *pathstr, size_t pathlen)
}
}
+#if !defined(__minix)
/*
* Process library mappings of the form:
* <library_name> <machdep_variable> <value,...:library_name,...> ...
xfree(hwptr->name);
xfree(hwptr);
}
+#endif /* !defined(__minix) */
void
_rtld_process_hints(const char *execname, Search_Path **path_p,
struct stat st;
ssize_t sz;
Search_Path **head_p = path_p;
+
if ((fd = open(fname, O_RDONLY)) == -1) {
/* Don't complain */
return;
-/* $NetBSD: reloc.c,v 1.103 2010/12/24 12:41:43 skrll Exp $ */
+/* $NetBSD: reloc.c,v 1.106 2012/01/06 10:38:56 skrll Exp $ */
/*
* Copyright 1996 John D. Polstra.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: reloc.c,v 1.103 2010/12/24 12:41:43 skrll Exp $");
+__RCSID("$NetBSD: reloc.c,v 1.106 2012/01/06 10:38:56 skrll Exp $");
#endif /* not lint */
#include <err.h>
const Elf_Sym *srcsym = NULL;
Obj_Entry *srcobj;
- for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next)
- if ((srcsym = _rtld_symlook_obj(name, hash, srcobj, false)) != NULL)
+ for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) {
+ srcsym = _rtld_symlook_obj(name, hash, srcobj, 0,
+ _rtld_fetch_ventry(dstobj, ELF_R_SYM(rela->r_info)));
+ if (srcsym != NULL)
break;
+ }
if (srcobj == NULL) {
_rtld_error("Undefined symbol \"%s\" referenced from COPY"
dbg(("doing lazy PLT binding"));
if (_rtld_relocate_plt_lazy(obj) < 0)
ok = 0;
-#if defined(__hppa__)
- bind_now = 1;
-#endif
if (obj->z_now || bind_now) {
dbg(("doing immediate PLT binding"));
if (_rtld_relocate_plt_objects(obj) < 0)
obj->magic = RTLD_MAGIC;
obj->version = RTLD_VERSION;
- /* Fill in the dynamic linker entry points. */
+ /*
+ * Fill in the backwards compatibility dynamic linker entry points.
+ *
+ * DO NOT ADD TO THIS LIST
+ */
obj->dlopen = dlopen;
obj->dlsym = dlsym;
obj->dlerror = dlerror;
-/* $NetBSD: rtld.c,v 1.137 2010/12/24 12:41:43 skrll Exp $ */
+/* $NetBSD: rtld.c,v 1.159 2012/10/01 03:03:46 riastradh Exp $ */
/*
* Copyright 1996 John D. Polstra.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.137 2010/12/24 12:41:43 skrll Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.159 2012/10/01 03:03:46 riastradh Exp $");
#endif /* not lint */
+#include <sys/param.h>
+#include <sys/atomic.h>
+#include <sys/mman.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#if !defined(__minix)
+#include <lwp.h>
+#endif /* !defined(__minix) */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/param.h>
-#include <sys/mman.h>
#include <dirent.h>
#include <ctype.h>
Obj_Entry _rtld_objself; /* The dynamic linker shared object */
u_int _rtld_objcount; /* Number of objects in _rtld_objlist */
u_int _rtld_objloads; /* Number of objects loaded in _rtld_objlist */
+u_int _rtld_objgen; /* Generation count for _rtld_objlist */
const char _rtld_path[] = _PATH_RTLD;
/* Initialize a fake symbol for resolving undefined weak references. */
Search_Path *_rtld_paths;
Library_Xform *_rtld_xforms;
+static void *auxinfo;
/*
* Global declarations normally provided by crt0.
char *__progname;
char **environ;
+#if !defined(__minix)
+static volatile bool _rtld_mutex_may_recurse;
+#endif /* !defined(__minix) */
+
#if defined(RTLD_DEBUG)
#ifndef __sh__
extern Elf_Addr _GLOBAL_OFFSET_TABLE_[];
#endif /* RTLD_DEBUG */
extern Elf_Dyn _DYNAMIC;
-static void _rtld_call_fini_functions(int);
-static void _rtld_call_init_functions(void);
+static void _rtld_call_fini_functions(sigset_t *, int);
+static void _rtld_call_init_functions(sigset_t *);
static void _rtld_initlist_visit(Objlist *, Obj_Entry *, int);
static void _rtld_initlist_tsort(Objlist *, int);
static Obj_Entry *_rtld_dlcheck(void *);
static void _rtld_init_dag1(Obj_Entry *, Obj_Entry *);
static void _rtld_objlist_remove(Objlist *, Obj_Entry *);
static void _rtld_objlist_clear(Objlist *);
-static void _rtld_unload_object(Obj_Entry *, bool);
+static void _rtld_unload_object(sigset_t *, Obj_Entry *, bool);
static void _rtld_unref_dag(Obj_Entry *);
static Obj_Entry *_rtld_obj_from_addr(const void *);
+static inline void
+_rtld_call_initfini_function(fptr_t func, sigset_t *mask)
+{
+ _rtld_exclusive_exit(mask);
+ (*func)();
+ _rtld_exclusive_enter(mask);
+}
+
+static void
+_rtld_call_fini_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
+{
+ if (obj->fini_arraysz == 0 && (obj->fini == NULL || obj->fini_called)) {
+ return;
+ }
+ if (obj->fini != NULL && !obj->fini_called) {
+ dbg (("calling fini function %s at %p%s", obj->path,
+ (void *)obj->fini,
+ obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
+ obj->fini_called = 1;
+ _rtld_call_initfini_function(obj->fini, mask);
+ }
+#ifdef HAVE_INITFINI_ARRAY
+ /*
+ * Now process the fini_array if it exists. Simply go from
+ * start to end. We need to make restartable so just advance
+ * the array pointer and decrement the size each time through
+ * the loop.
+ */
+ while (obj->fini_arraysz > 0 && _rtld_objgen == cur_objgen) {
+ fptr_t fini = *obj->fini_array++;
+ obj->fini_arraysz--;
+ dbg (("calling fini array function %s at %p%s", obj->path,
+ (void *)fini,
+ obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
+ _rtld_call_initfini_function(fini, mask);
+ }
+#endif /* HAVE_INITFINI_ARRAY */
+}
+
static void
-_rtld_call_fini_functions(int force)
+_rtld_call_fini_functions(sigset_t *mask, int force)
{
Objlist_Entry *elm;
Objlist finilist;
- Obj_Entry *obj;
+ u_int cur_objgen;
dbg(("_rtld_call_fini_functions(%d)", force));
+restart:
+ cur_objgen = ++_rtld_objgen;
SIMPLEQ_INIT(&finilist);
_rtld_initlist_tsort(&finilist, 1);
/* First pass: objects _not_ marked with DF_1_INITFIRST. */
SIMPLEQ_FOREACH(elm, &finilist, link) {
- obj = elm->obj;
- if (obj->refcount > 0 && !force) {
- continue;
+ Obj_Entry * const obj = elm->obj;
+ if (!obj->z_initfirst) {
+ if (obj->refcount > 0 && !force) {
+ continue;
+ }
+ /*
+ * XXX This can race against a concurrent dlclose().
+ * XXX In that case, the object could be unmapped before
+ * XXX the fini() call or the fini_array has completed.
+ */
+ _rtld_call_fini_function(obj, mask, cur_objgen);
+ if (_rtld_objgen != cur_objgen) {
+ dbg(("restarting fini iteration"));
+ _rtld_objlist_clear(&finilist);
+ goto restart;
}
- if (obj->fini == NULL || obj->fini_called || obj->z_initfirst) {
- continue;
}
- dbg (("calling fini function %s at %p", obj->path,
- (void *)obj->fini));
- obj->fini_called = 1;
- (*obj->fini)();
}
/* Second pass: objects marked with DF_1_INITFIRST. */
SIMPLEQ_FOREACH(elm, &finilist, link) {
- obj = elm->obj;
+ Obj_Entry * const obj = elm->obj;
if (obj->refcount > 0 && !force) {
continue;
}
- if (obj->fini == NULL || obj->fini_called) {
- continue;
+ /* XXX See above for the race condition here */
+ _rtld_call_fini_function(obj, mask, cur_objgen);
+ if (_rtld_objgen != cur_objgen) {
+ dbg(("restarting fini iteration"));
+ _rtld_objlist_clear(&finilist);
+ goto restart;
}
- dbg (("calling fini function %s at %p (DF_1_INITFIRST)",
- obj->path, (void *)obj->fini));
- obj->fini_called = 1;
- (*obj->fini)();
}
_rtld_objlist_clear(&finilist);
}
static void
-_rtld_call_init_functions()
+_rtld_call_init_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
+{
+ if (obj->init_arraysz == 0 && (obj->init_called || obj->init == NULL)) {
+ return;
+ }
+ if (!obj->init_called && obj->init != NULL) {
+ dbg (("calling init function %s at %p%s",
+ obj->path, (void *)obj->init,
+ obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
+ obj->init_called = 1;
+ _rtld_call_initfini_function(obj->init, mask);
+ }
+
+#ifdef HAVE_INITFINI_ARRAY
+ /*
+ * Now process the init_array if it exists. Simply go from
+ * start to end. We need to make restartable so just advance
+ * the array pointer and decrement the size each time through
+ * the loop.
+ */
+ while (obj->init_arraysz > 0 && _rtld_objgen == cur_objgen) {
+ fptr_t init = *obj->init_array++;
+ obj->init_arraysz--;
+ dbg (("calling init_array function %s at %p%s",
+ obj->path, (void *)init,
+ obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
+ _rtld_call_initfini_function(init, mask);
+ }
+#endif /* HAVE_INITFINI_ARRAY */
+}
+
+static void
+_rtld_call_init_functions(sigset_t *mask)
{
Objlist_Entry *elm;
Objlist initlist;
- Obj_Entry *obj;
+ u_int cur_objgen;
dbg(("_rtld_call_init_functions()"));
+
+restart:
+ cur_objgen = ++_rtld_objgen;
SIMPLEQ_INIT(&initlist);
_rtld_initlist_tsort(&initlist, 0);
/* First pass: objects marked with DF_1_INITFIRST. */
SIMPLEQ_FOREACH(elm, &initlist, link) {
- obj = elm->obj;
- if (obj->init == NULL || obj->init_called || !obj->z_initfirst) {
- continue;
+ Obj_Entry * const obj = elm->obj;
+ if (obj->z_initfirst) {
+ _rtld_call_init_function(obj, mask, cur_objgen);
+ if (_rtld_objgen != cur_objgen) {
+ dbg(("restarting init iteration"));
+ _rtld_objlist_clear(&initlist);
+ goto restart;
+ }
}
- dbg (("calling init function %s at %p (DF_1_INITFIRST)",
- obj->path, (void *)obj->init));
- obj->init_called = 1;
- (*obj->init)();
}
/* Second pass: all other objects. */
SIMPLEQ_FOREACH(elm, &initlist, link) {
- obj = elm->obj;
- if (obj->init == NULL || obj->init_called) {
- continue;
+ _rtld_call_init_function(elm->obj, mask, cur_objgen);
+ if (_rtld_objgen != cur_objgen) {
+ dbg(("restarting init iteration"));
+ _rtld_objlist_clear(&initlist);
+ goto restart;
}
- dbg (("calling init function %s at %p", obj->path,
- (void *)obj->init));
- obj->init_called = 1;
- (*obj->init)();
}
_rtld_objlist_clear(&initlist);
static void
_rtld_exit(void)
{
+ sigset_t mask;
+
dbg(("rtld_exit()"));
- _rtld_call_fini_functions(1);
+ _rtld_exclusive_enter(&mask);
+
+ _rtld_call_fini_functions(&mask, 1);
+
+ _rtld_exclusive_exit(&mask);
+}
+
+__dso_public void *
+_dlauxinfo(void)
+{
+ return auxinfo;
}
/*
*pAUX_ruid, *pAUX_rgid;
const AuxInfo *pAUX_pagesz;
char **env, **oenvp;
- const AuxInfo *aux;
const AuxInfo *auxp;
+ Obj_Entry *obj;
Elf_Addr *const osp = sp;
bool bind_now = 0;
const char *ld_bind_now, *ld_preload, *ld_library_path;
const char **real___progname;
const Obj_Entry **real___mainprog_obj;
char ***real_environ;
+ sigset_t mask;
#ifdef DEBUG
- int i = 0;
const char *ld_debug;
#endif
+#ifdef RTLD_DEBUG
+ int i = 0;
+#endif
/*
* On entry, the dynamic linker itself has not been relocated yet.
debug = 1;
dbg(("sp = %p, argc = %ld, argv = %p <%s> relocbase %p", sp,
(long)sp[2], &sp[3], (char *) sp[3], (void *)relocbase));
+#if 0
dbg(("got is at %p, dynamic is at %p", _GLOBAL_OFFSET_TABLE_,
&_DYNAMIC));
+#endif
dbg(("_ctype_ is %p", _ctype_));
#endif
dbg(("env[%d] = %p %s", i++, (void *)sp[-1], (char *)sp[-1]));
#endif
}
- aux = (const AuxInfo *) sp;
+ auxinfo = (AuxInfo *) sp;
pAUX_base = pAUX_entry = pAUX_execfd = NULL;
pAUX_phdr = pAUX_phent = pAUX_phnum = NULL;
execname = NULL;
/* Digest the auxiliary vector. */
- for (auxp = aux; auxp->a_type != AT_NULL; ++auxp) {
+ for (auxp = auxinfo; auxp->a_type != AT_NULL; ++auxp) {
switch (auxp->a_type) {
case AT_BASE:
pAUX_base = auxp;
if (_rtld_load_needed_objects(_rtld_objmain, _RTLD_MAIN) == -1)
_rtld_die();
+ dbg(("checking for required versions"));
+ for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
+ if (_rtld_verify_object_versions(obj) == -1)
+ _rtld_die();
+ }
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ dbg(("initializing initial Thread Local Storage offsets"));
+ /*
+ * All initial objects get the TLS space from the static block.
+ */
+ for (obj = _rtld_objlist; obj != NULL; obj = obj->next)
+ _rtld_tls_offset_allocate(obj);
+#endif
+
dbg(("relocating objects"));
if (_rtld_relocate_objects(_rtld_objmain, bind_now) == -1)
_rtld_die();
if (_rtld_do_copy_relocations(_rtld_objmain) == -1)
_rtld_die();
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ dbg(("initializing Thread Local Storage for main thread"));
+ /*
+ * Set up TLS area for the main thread.
+ * This has to be done after all relocations are processed,
+ * since .tdata may contain relocations.
+ */
+ _rtld_tls_initial_allocation();
+#endif
+
/*
* Set the __progname, environ and, __mainprog_obj before
* calling anything that might use them.
if (real___mainprog_obj)
*real___mainprog_obj = _rtld_objmain;
+ _rtld_exclusive_enter(&mask);
+
dbg(("calling _init functions"));
- _rtld_call_init_functions();
+ _rtld_call_init_functions(&mask);
dbg(("control at program entry point = %p, obj = %p, exit = %p",
_rtld_objmain->entry, _rtld_objmain, _rtld_exit));
+ _rtld_exclusive_exit(&mask);
+
/*
* Return with the entry point and the exit procedure in at the top
* of stack.
break;
if (obj == NULL || obj->dl_refcount == 0) {
- xwarnx("Invalid shared object handle %p", handle);
+ _rtld_error("Invalid shared object handle %p", handle);
return NULL;
}
return obj;
* Note, this is called only for objects loaded by dlopen().
*/
static void
-_rtld_unload_object(Obj_Entry *root, bool do_fini_funcs)
+_rtld_unload_object(sigset_t *mask, Obj_Entry *root, bool do_fini_funcs)
{
_rtld_unref_dag(root);
/* Finalize objects that are about to be unmapped. */
if (do_fini_funcs)
- _rtld_call_fini_functions(0);
+ _rtld_call_fini_functions(mask, 0);
/* Remove the DAG from all objects' DAG lists. */
SIMPLEQ_FOREACH(elm, &root->dagmembers, link)
int
dlclose(void *handle)
{
- Obj_Entry *root = _rtld_dlcheck(handle);
+ Obj_Entry *root;
+ sigset_t mask;
+
+ dbg(("dlclose of %p", handle));
+
+ _rtld_exclusive_enter(&mask);
- if (root == NULL)
+ root = _rtld_dlcheck(handle);
+
+ if (root == NULL) {
+ _rtld_exclusive_exit(&mask);
return -1;
+ }
_rtld_debug.r_state = RT_DELETE;
_rtld_debug_state();
--root->dl_refcount;
- _rtld_unload_object(root, true);
+ _rtld_unload_object(&mask, root, true);
_rtld_debug.r_state = RT_CONSISTENT;
_rtld_debug_state();
+ _rtld_exclusive_exit(&mask);
+
return 0;
}
int flags = _RTLD_DLOPEN;
bool nodelete;
bool now;
+ sigset_t mask;
+ int result;
+
+ dbg(("dlopen of %s %d", name, mode));
+
+ _rtld_exclusive_enter(&mask);
flags |= (mode & RTLD_GLOBAL) ? _RTLD_GLOBAL : 0;
flags |= (mode & RTLD_NOLOAD) ? _RTLD_NOLOAD : 0;
if (*old_obj_tail != NULL) { /* We loaded something new. */
assert(*old_obj_tail == obj);
- if (_rtld_load_needed_objects(obj, flags) == -1 ||
- (_rtld_init_dag(obj),
- _rtld_relocate_objects(obj,
- (now || obj->z_now))) == -1) {
- _rtld_unload_object(obj, false);
+ result = _rtld_load_needed_objects(obj, flags);
+ if (result != -1) {
+ Objlist_Entry *entry;
+ _rtld_init_dag(obj);
+ SIMPLEQ_FOREACH(entry, &obj->dagmembers, link) {
+ result = _rtld_verify_object_versions(entry->obj);
+ if (result == -1)
+ break;
+ }
+ }
+ if (result == -1 || _rtld_relocate_objects(obj,
+ (now || obj->z_now)) == -1) {
+ _rtld_unload_object(&mask, obj, false);
obj->dl_refcount--;
obj = NULL;
} else {
- _rtld_call_init_functions();
+ _rtld_call_init_functions(&mask);
}
}
if (obj != NULL) {
_rtld_debug.r_state = RT_CONSISTENT;
_rtld_debug_state();
+ _rtld_exclusive_exit(&mask);
+
return obj;
}
obj = _rtld_objmain;
_rtld_donelist_init(&donelist);
- def = _rtld_symlook_list(name, hash, &_rtld_list_main, &obj, false,
- &donelist);
+ def = _rtld_symlook_list(name, hash, &_rtld_list_main, &obj, 0,
+ NULL, &donelist);
if (def != NULL)
return obj->relocbase + def->st_value;
}
#endif
-__strong_alias(__dlsym,dlsym)
-void *
-dlsym(void *handle, const char *name)
+#ifdef __HAVE_FUNCTION_DESCRIPTORS
+#define lookup_mutex_enter() _rtld_exclusive_enter(&mask)
+#define lookup_mutex_exit() _rtld_exclusive_exit(&mask)
+#else
+#define lookup_mutex_enter() _rtld_shared_enter()
+#define lookup_mutex_exit() _rtld_shared_exit()
+#endif
+
+static void *
+do_dlsym(void *handle, const char *name, const Ver_Entry *ventry, void *retaddr)
{
const Obj_Entry *obj;
unsigned long hash;
const Elf_Sym *def;
const Obj_Entry *defobj;
- void *retaddr;
- DoneList donelist;
-
+ DoneList donelist;
+ const u_int flags = SYMLOOK_DLSYM | SYMLOOK_IN_PLT;
+#ifdef __HAVE_FUNCTION_DESCRIPTORS
+ sigset_t mask;
+#endif
+
+ lookup_mutex_enter();
+
hash = _rtld_elf_hash(name);
def = NULL;
defobj = NULL;
case (intptr_t)RTLD_NEXT:
case (intptr_t)RTLD_DEFAULT:
case (intptr_t)RTLD_SELF:
-#ifdef __powerpc__
- retaddr = hackish_return_address();
-#else
- retaddr = __builtin_return_address(0);
-#endif
if ((obj = _rtld_obj_from_addr(retaddr)) == NULL) {
_rtld_error("Cannot determine caller's shared object");
+ lookup_mutex_exit();
return NULL;
}
switch ((intptr_t)handle) {
case (intptr_t)NULL: /* Just the caller's shared object. */
- def = _rtld_symlook_obj(name, hash, obj, false);
+ def = _rtld_symlook_obj(name, hash, obj, flags, ventry);
defobj = obj;
break;
case (intptr_t)RTLD_SELF: /* Caller included */
for (; obj; obj = obj->next) {
if ((def = _rtld_symlook_obj(name, hash, obj,
- false)) != NULL) {
+ flags, ventry)) != NULL) {
defobj = obj;
break;
}
case (intptr_t)RTLD_DEFAULT:
def = _rtld_symlook_default(name, hash, obj, &defobj,
- false);
+ flags, ventry);
break;
default:
break;
default:
- if ((obj = _rtld_dlcheck(handle)) == NULL)
+ if ((obj = _rtld_dlcheck(handle)) == NULL) {
+ lookup_mutex_exit();
return NULL;
-
+ }
+
_rtld_donelist_init(&donelist);
if (obj->mainprog) {
/* Search main program and all libraries loaded by it */
def = _rtld_symlook_list(name, hash, &_rtld_list_main,
- &defobj, false, &donelist);
+ &defobj, flags, ventry, &donelist);
} else {
Needed_Entry fake;
DoneList depth;
_rtld_donelist_init(&depth);
def = _rtld_symlook_needed(name, hash, &fake, &defobj,
- false, &donelist, &depth);
+ flags, ventry, &donelist, &depth);
}
break;
}
if (def != NULL) {
+ void *p;
#ifdef __HAVE_FUNCTION_DESCRIPTORS
- if (ELF_ST_TYPE(def->st_info) == STT_FUNC)
- return (void *)_rtld_function_descriptor_alloc(defobj,
+ if (ELF_ST_TYPE(def->st_info) == STT_FUNC) {
+ p = (void *)_rtld_function_descriptor_alloc(defobj,
def, 0);
+ lookup_mutex_exit();
+ return p;
+ }
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
- return defobj->relocbase + def->st_value;
+ p = defobj->relocbase + def->st_value;
+ lookup_mutex_exit();
+ return p;
}
_rtld_error("Undefined symbol \"%s\"", name);
+ lookup_mutex_exit();
return NULL;
}
+__strong_alias(__dlsym,dlsym)
+void *
+dlsym(void *handle, const char *name)
+{
+ void *retaddr;
+
+ dbg(("dlsym of %s in %p", name, handle));
+
+#ifdef __powerpc__
+ retaddr = hackish_return_address();
+#else
+ retaddr = __builtin_return_address(0);
+#endif
+ return do_dlsym(handle, name, NULL, retaddr);
+}
+
+__strong_alias(__dlvsym,dlvsym)
+void *
+dlvsym(void *handle, const char *name, const char *version)
+{
+ Ver_Entry *ventry = NULL;
+ Ver_Entry ver_entry;
+ void *retaddr;
+
+ dbg(("dlvsym of %s@%s in %p", name, version ? version : NULL, handle));
+
+ if (version != NULL) {
+ ver_entry.name = version;
+ ver_entry.file = NULL;
+ ver_entry.hash = _rtld_elf_hash(version);
+ ver_entry.flags = 0;
+ ventry = &ver_entry;
+ }
+#ifdef __powerpc__
+ retaddr = hackish_return_address();
+#else
+ retaddr = __builtin_return_address(0);
+#endif
+ return do_dlsym(handle, name, ventry, retaddr);
+}
+
__strong_alias(__dladdr,dladdr)
int
dladdr(const void *addr, Dl_info *info)
const Elf_Sym *def, *best_def;
void *symbol_addr;
unsigned long symoffset;
-
+#ifdef __HAVE_FUNCTION_DESCRIPTORS
+ sigset_t mask;
+#endif
+
+ dbg(("dladdr of %p", addr));
+
+ lookup_mutex_enter();
+
#ifdef __HAVE_FUNCTION_DESCRIPTORS
addr = _rtld_function_descriptor_function(addr);
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
obj = _rtld_obj_from_addr(addr);
if (obj == NULL) {
_rtld_error("No shared object contains address");
+ lookup_mutex_enter();
return 0;
}
info->dli_fname = obj->path;
best_def, 0);
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
+ lookup_mutex_exit();
return 1;
}
const Obj_Entry *obj;
void *retaddr;
+ dbg(("dlinfo for %p %d", handle, req));
+
+ _rtld_shared_enter();
+
if (handle == RTLD_SELF) {
#ifdef __powerpc__
retaddr = hackish_return_address();
#endif
if ((obj = _rtld_obj_from_addr(retaddr)) == NULL) {
_rtld_error("Cannot determine caller's shared object");
+ _rtld_shared_exit();
return -1;
}
} else {
if ((obj = _rtld_dlcheck(handle)) == NULL) {
- _rtld_error("Invalid handle");
+ _rtld_shared_exit();
return -1;
}
}
default:
_rtld_error("Invalid request");
+ _rtld_shared_exit();
return -1;
}
+ _rtld_shared_exit();
return 0;
}
const Obj_Entry *obj;
int error = 0;
+ dbg(("dl_iterate_phdr"));
+
+ _rtld_shared_enter();
+
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
phdr_info.dlpi_addr = (Elf_Addr)obj->relocbase;
phdr_info.dlpi_name = STAILQ_FIRST(&obj->names) ?
STAILQ_FIRST(&obj->names)->name : obj->path;
phdr_info.dlpi_phdr = obj->phdr;
phdr_info.dlpi_phnum = obj->phsize / sizeof(obj->phdr[0]);
-#if 1
- phdr_info.dlpi_tls_modid = 0;
- phdr_info.dlpi_tls_data = 0;
-#else
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
phdr_info.dlpi_tls_modid = obj->tlsindex;
phdr_info.dlpi_tls_data = obj->tlsinit;
+#else
+ phdr_info.dlpi_tls_modid = 0;
+ phdr_info.dlpi_tls_data = 0;
#endif
phdr_info.dlpi_adds = _rtld_objloads;
phdr_info.dlpi_subs = _rtld_objloads - _rtld_objcount;
+ /* XXXlocking: exit point */
error = callback(&phdr_info, sizeof(phdr_info), param);
if (error)
break;
}
+ _rtld_shared_exit();
return error;
}
_rtld_debug_state(void)
{
- /* do nothing */
+ /* Prevent optimizer from removing calls to this function */
+ __insn_barrier();
}
void
xfree(elm);
}
}
+
+#if defined(__minix)
+void _rtld_shared_enter(void) {}
+void _rtld_shared_exit(void) {}
+void _rtld_exclusive_enter(sigset_t *mask) {}
+void _rtld_exclusive_exit(sigset_t *mask) {}
+#else
+#define RTLD_EXCLUSIVE_MASK 0x80000000U
+static volatile unsigned int _rtld_mutex;
+static volatile unsigned int _rtld_waiter_exclusive;
+static volatile unsigned int _rtld_waiter_shared;
+
+void
+_rtld_shared_enter(void)
+{
+ unsigned int cur;
+ lwpid_t waiter, self = 0;
+
+ membar_enter();
+
+ for (;;) {
+ cur = _rtld_mutex;
+ /*
+ * First check if we are currently not exclusively locked.
+ */
+ if ((cur & RTLD_EXCLUSIVE_MASK) == 0) {
+ /* Yes, so increment use counter */
+ if (atomic_cas_uint(&_rtld_mutex, cur, cur + 1) != cur)
+ continue;
+ return;
+ }
+ /*
+ * Someone has an exclusive lock. Puts us on the waiter list.
+ */
+ if (!self)
+ self = _lwp_self();
+ if (cur == (self | RTLD_EXCLUSIVE_MASK)) {
+ if (_rtld_mutex_may_recurse)
+ return;
+ _rtld_error("dead lock detected");
+ _rtld_die();
+ }
+ waiter = atomic_swap_uint(&_rtld_waiter_shared, self);
+ /*
+ * Check for race against _rtld_exclusive_exit before sleeping.
+ */
+ if ((_rtld_mutex & RTLD_EXCLUSIVE_MASK) ||
+ _rtld_waiter_exclusive)
+ _lwp_park(NULL, -1, __UNVOLATILE(&_rtld_mutex), NULL);
+ /* Try to remove us from the waiter list. */
+ atomic_cas_uint(&_rtld_waiter_shared, self, 0);
+ if (waiter)
+ _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
+ }
+}
+
+void
+_rtld_shared_exit(void)
+{
+ lwpid_t waiter;
+
+ /*
+ * Shared lock taken after an exclusive lock.
+ * Just assume this is a partial recursion.
+ */
+ if (_rtld_mutex & RTLD_EXCLUSIVE_MASK)
+ return;
+
+ /*
+ * Wakeup LWPs waiting for an exclusive lock if this is the last
+ * LWP on the shared lock.
+ */
+ if (atomic_dec_uint_nv(&_rtld_mutex))
+ return;
+ if ((waiter = _rtld_waiter_exclusive) != 0)
+ _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
+
+ membar_exit();
+}
+
+void
+_rtld_exclusive_enter(sigset_t *mask)
+{
+ lwpid_t waiter, self = _lwp_self();
+ unsigned int locked_value = (unsigned int)self | RTLD_EXCLUSIVE_MASK;
+ unsigned int cur;
+ sigset_t blockmask;
+
+ sigfillset(&blockmask);
+ sigdelset(&blockmask, SIGTRAP); /* Allow the debugger */
+ sigprocmask(SIG_BLOCK, &blockmask, mask);
+
+ membar_enter();
+
+ for (;;) {
+ if (atomic_cas_uint(&_rtld_mutex, 0, locked_value) == 0)
+ break;
+ waiter = atomic_swap_uint(&_rtld_waiter_exclusive, self);
+ cur = _rtld_mutex;
+ if (cur == locked_value) {
+ _rtld_error("dead lock detected");
+ _rtld_die();
+ }
+ if (cur)
+ _lwp_park(NULL, -1, __UNVOLATILE(&_rtld_mutex), NULL);
+ atomic_cas_uint(&_rtld_waiter_exclusive, self, 0);
+ if (waiter)
+ _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
+ }
+}
+
+void
+_rtld_exclusive_exit(sigset_t *mask)
+{
+ lwpid_t waiter;
+
+ _rtld_mutex = 0;
+ if ((waiter = _rtld_waiter_exclusive) != 0)
+ _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
+
+ if ((waiter = _rtld_waiter_shared) != 0)
+ _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
+
+ membar_exit();
+ sigprocmask(SIG_SETMASK, mask, NULL);
+}
+#endif /* !defined(__minix) */
-/* $NetBSD: rtld.h,v 1.99 2011/01/16 15:56:37 matt Exp $ */
+/* $NetBSD: rtld.h,v 1.110 2012/08/15 03:46:06 matt Exp $ */
/*
* Copyright 1996 John D. Polstra.
#define RTLD_H
#include <dlfcn.h>
+#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/exec_elf.h>
+#include <sys/tls.h>
#include "rtldenv.h"
#include "link.h"
size_t sp_pathlen;
} Search_Path;
+typedef struct Struct_Ver_Entry {
+ Elf_Word hash;
+ u_int flags;
+ const char *name;
+ const char *file;
+} Ver_Entry;
+
+/* Ver_Entry.flags */
+#define VER_INFO_HIDDEN 0x01
#define RTLD_MAX_ENTRY 10
#define RTLD_MAX_LIBRARY 4
#define RTLD_MAGIC 0xd550b87a
#define RTLD_VERSION 1
+typedef void (*fptr_t)(void);
+
typedef struct Struct_Obj_Entry {
Elf32_Word magic; /* Magic number (sanity check) */
Elf32_Word version; /* Version number of struct format */
Search_Path *rpaths; /* Search path specified in object */
Needed_Entry *needed; /* Shared objects needed by this (%) */
- void (*init)(void); /* Initialization function to call */
- void (*fini)(void); /* Termination function to call */
+ fptr_t init; /* Initialization function to call */
+ fptr_t fini; /* Termination function to call */
- /* Entry points for dlopen() and friends. */
+ /*
+ * BACKWARDS COMPAT Entry points for dlopen() and friends.
+ *
+ * DO NOT MOVE OR ADD TO THE LIST
+ *
+ */
void *(*dlopen)(const char *, int);
void *(*dlsym)(void *, const char *);
char *(*dlerror)(void);
dlopen'ed */
phdr_loaded:1, /* Phdr is loaded and doesn't need to
* be freed. */
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ tls_done:1, /* True if static TLS offset
+ * has been allocated */
+#endif
ref_nodel:1; /* Refcount increased to prevent dlclose */
struct link_map linkmap; /* for GDB */
size_t pathlen; /* Pathname length */
STAILQ_HEAD(, Struct_Name_Entry) names; /* List of names for this object we
know about. */
+
#ifdef __powerpc__
Elf_Addr *gotptr; /* GOT table (secure-plt only) */
#endif
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ /* Thread Local Storage support for this module */
+ size_t tlsindex; /* Index in DTV */
+ void *tlsinit; /* Base address of TLS init block */
+ size_t tlsinitsize; /* Size of TLS init block */
+ size_t tlssize; /* Size of TLS block */
+ size_t tlsoffset; /* Offset in the static TLS block */
+ size_t tlsalign; /* Needed alignment for static TLS */
+#endif
+
+ /* symbol versioning */
+ const Elf_Verneed *verneed; /* Required versions. */
+ Elf_Word verneednum; /* Number of entries in verneed table */
+ const Elf_Verdef *verdef; /* Provided versions. */
+ Elf_Word verdefnum; /* Number of entries in verdef table */
+ const Elf_Versym *versyms; /* Symbol versions table */
+
+ Ver_Entry *vertab; /* Versions required/defined by this
+ * object */
+ int vertabnum; /* Number of entries in vertab */
+
+ /* init_array/fini_array */
+ fptr_t *init_array; /* start of init array */
+ size_t init_arraysz; /* # of entries in it */
+ fptr_t *fini_array; /* start of fini array */
+ size_t fini_arraysz; /* # of entries in it */
} Obj_Entry;
typedef struct Struct_DoneList {
#define RTLD_MODEMASK 0x3
+/* Flags to be passed into _rtld_symlook_ family of functions. */
+#define SYMLOOK_IN_PLT 0x01 /* Lookup for PLT symbol */
+#define SYMLOOK_DLSYM 0x02 /* Return newes versioned symbol.
+ Used by dlsym. */
+
/* Flags for _rtld_load_object() and friends. */
#define _RTLD_GLOBAL 0x01 /* Add object to global DAG. */
#define _RTLD_MAIN 0x02
#define _RTLD_NOLOAD 0x04 /* dlopen() specified RTLD_NOLOAD. */
#define _RTLD_DLOPEN 0x08 /* Load_object() called from dlopen(). */
+/* Preallocation for static TLS model */
+#define RTLD_STATIC_TLS_RESERVATION 64
+
/* rtld.c */
/* We export these symbols using _rtld_symbol_lookup and is_exported. */
__dso_public int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
void *);
+__dso_public void *_dlauxinfo(void) __pure;
+
/* These aren't exported */
void _rtld_error(const char *, ...)
__attribute__((__format__(__printf__,1,2)));
void _rtld_die(void) __attribute__((__noreturn__));
void *_rtld_objmain_sym(const char *);
-void _rtld_debug_state(void);
+__dso_public void _rtld_debug_state(void) __noinline;
void _rtld_linkmap_add(Obj_Entry *);
void _rtld_linkmap_delete(Obj_Entry *);
void _rtld_objlist_push_head(Objlist *, Obj_Entry *);
Objlist_Entry *_rtld_objlist_find(Objlist *, const Obj_Entry *);
void _rtld_ref_dag(Obj_Entry *);
+void _rtld_shared_enter(void);
+void _rtld_shared_exit(void);
+void _rtld_exclusive_enter(sigset_t *);
+void _rtld_exclusive_exit(sigset_t *);
+
/* expand.c */
size_t _rtld_expand_path(char *, size_t, const char *, const char *,\
const char *);
/* symbol.c */
unsigned long _rtld_elf_hash(const char *);
const Elf_Sym *_rtld_symlook_obj(const char *, unsigned long,
- const Obj_Entry *, bool);
+ const Obj_Entry *, u_int, const Ver_Entry *);
const Elf_Sym *_rtld_find_symdef(unsigned long, const Obj_Entry *,
- const Obj_Entry **, bool);
+ const Obj_Entry **, u_int);
const Elf_Sym *_rtld_find_plt_symdef(unsigned long, const Obj_Entry *,
const Obj_Entry **, bool);
const Elf_Sym *_rtld_symlook_list(const char *, unsigned long,
- const Objlist *, const Obj_Entry **, bool, DoneList *);
+ const Objlist *, const Obj_Entry **, u_int, const Ver_Entry *, DoneList *);
const Elf_Sym *_rtld_symlook_default(const char *, unsigned long,
- const Obj_Entry *, const Obj_Entry **, bool);
+ const Obj_Entry *, const Obj_Entry **, u_int, const Ver_Entry *);
const Elf_Sym *_rtld_symlook_needed(const char *, unsigned long,
- const Needed_Entry *, const Obj_Entry **, bool,
+ const Needed_Entry *, const Obj_Entry **, u_int, const Ver_Entry *,
DoneList *, DoneList *);
#ifdef COMBRELOC
void _rtld_combreloc_reset(const Obj_Entry *);
#endif
+/* symver.c */
+int _rtld_object_match_name(const Obj_Entry *, const char *);
+int _rtld_verify_object_versions(Obj_Entry *);
+
+static __inline const Ver_Entry *
+_rtld_fetch_ventry(const Obj_Entry *obj, unsigned long symnum)
+{
+ Elf_Half vernum;
+
+ if (obj->vertab) {
+ vernum = VER_NDX(obj->versyms[symnum].vs_vers);
+ if (vernum >= obj->vertabnum) {
+ _rtld_error("%s: symbol %s has wrong verneed value %d",
+ obj->path, &obj->strtab[symnum], vernum);
+ } else if (obj->vertab[vernum].hash) {
+ return &obj->vertab[vernum];
+ }
+ }
+ return NULL;
+}
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+/* tls.c */
+void *_rtld_tls_get_addr(void *, size_t, size_t);
+void _rtld_tls_initial_allocation(void);
+void *_rtld_tls_module_allocate(size_t index);
+int _rtld_tls_offset_allocate(Obj_Entry *);
+void _rtld_tls_offset_free(Obj_Entry *);
+
+extern size_t _rtld_tls_dtv_generation;
+extern size_t _rtld_tls_max_index;
+
+__dso_public extern void *__tls_get_addr(void *);
+#ifdef __i386__
+__dso_public extern void *___tls_get_addr(void *)
+ __attribute__((__regparm__(1)));
+#endif
+#endif
+
/* map_object.c */
struct stat;
Obj_Entry *_rtld_map_object(const char *, int, const struct stat *);
-/* $NetBSD: rtldenv.h,v 1.10 2010/10/29 15:08:17 christos Exp $ */
+/* $NetBSD: rtldenv.h,v 1.11 2011/12/11 11:05:11 joerg Exp $ */
/*
* Copyright 1996 Matt Thomas <matt@3am-software.com>
void xerrx(int, const char *, ...)
__attribute__((__noreturn__, __format__(__printf__, 2, 3)));
-void xassert(const char *, int, const char *);
+void xassert(const char *, int, const char *) __dead;
const char *xstrerror(int);
int xunsetenv(const char *);
-/* $NetBSD: symbol.c,v 1.54 2010/10/16 10:27:07 skrll Exp $ */
+/* $NetBSD: symbol.c,v 1.61 2012/08/15 03:46:07 matt Exp $ */
/*
* Copyright 1996 John D. Polstra.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: symbol.c,v 1.54 2010/10/16 10:27:07 skrll Exp $");
+__RCSID("$NetBSD: symbol.c,v 1.61 2012/08/15 03:46:07 matt Exp $");
#endif /* not lint */
#include <err.h>
#include "debug.h"
#include "rtld.h"
-typedef void (*fptr_t)(void);
-
/*
* If the given object is already in the donelist, return true. Otherwise
* add the object to the list and return false.
(fptr_t)dlopen,
(fptr_t)dlclose,
(fptr_t)dlsym,
+ (fptr_t)dlvsym,
(fptr_t)dlerror,
(fptr_t)dladdr,
(fptr_t)dlinfo,
(fptr_t)dl_iterate_phdr,
+ (fptr_t)_dlauxinfo,
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+ (fptr_t)_rtld_tls_allocate,
+ (fptr_t)_rtld_tls_free,
+ (fptr_t)__tls_get_addr,
+#ifdef __i386__
+ (fptr_t)___tls_get_addr,
+#endif
+#endif
NULL
};
int i;
const Elf_Sym *
_rtld_symlook_list(const char *name, unsigned long hash, const Objlist *objlist,
- const Obj_Entry **defobj_out, bool in_plt, DoneList *dlp)
+ const Obj_Entry **defobj_out, u_int flags, const Ver_Entry *ventry,
+ DoneList *dlp)
{
const Elf_Sym *symp;
const Elf_Sym *def;
continue;
rdbg(("search object %p (%s) for %s", elm->obj, elm->obj->path,
name));
- if ((symp = _rtld_symlook_obj(name, hash, elm->obj, in_plt))
- != NULL) {
+ symp = _rtld_symlook_obj(name, hash, elm->obj, flags, ventry);
+ if (symp != NULL) {
if ((def == NULL) ||
(ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
def = symp;
*/
const Elf_Sym *
_rtld_symlook_needed(const char *name, unsigned long hash,
- const Needed_Entry *needed, const Obj_Entry **defobj_out, bool inplt,
- DoneList *breadth, DoneList *depth)
+ const Needed_Entry *needed, const Obj_Entry **defobj_out, u_int flags,
+ const Ver_Entry *ventry, DoneList *breadth, DoneList *depth)
{
const Elf_Sym *def, *def_w;
const Needed_Entry *n;
continue;
if (_rtld_donelist_check(breadth, obj))
continue;
- if ((def = _rtld_symlook_obj(name, hash, obj, inplt)) == NULL)
+ def = _rtld_symlook_obj(name, hash, obj, flags, ventry);
+ if (def == NULL)
continue;
defobj = obj;
if (ELF_ST_BIND(def->st_info) != STB_WEAK) {
if (_rtld_donelist_check(depth, obj))
continue;
def_w = _rtld_symlook_needed(name, hash, obj->needed, &defobj1,
- inplt, breadth, depth);
+ flags, ventry, breadth, depth);
if (def_w == NULL)
continue;
if (def == NULL || ELF_ST_BIND(def_w->st_info) != STB_WEAK) {
*/
const Elf_Sym *
_rtld_symlook_obj(const char *name, unsigned long hash,
- const Obj_Entry *obj, bool in_plt)
+ const Obj_Entry *obj, u_int flags, const Ver_Entry *ventry)
{
unsigned long symnum;
+ const Elf_Sym *vsymp = NULL;
+ Elf_Half verndx;
+ int vcount = 0;
for (symnum = obj->buckets[fast_remainder32(hash, obj->nbuckets,
obj->nbuckets_m, obj->nbuckets_s1, obj->nbuckets_s2)];
assert(symnum < obj->nchains);
symp = obj->symtab + symnum;
strp = obj->strtab + symp->st_name;
- rdbg(("check \"%s\" vs \"%s\" in %p", name, strp, obj));
- if (name[1] == strp[1] && !strcmp(name, strp)) {
- if (symp->st_shndx != SHN_UNDEF)
- return symp;
-#ifndef __mips__
- /*
- * XXX DANGER WILL ROBINSON!
- * If we have a function pointer in the executable's
- * data section, it points to the executable's PLT
- * slot, and there is NO relocation emitted. To make
- * the function pointer comparable to function pointers
- * in shared libraries, we must resolve data references
- * in the libraries to point to PLT slots in the
- * executable, if they exist.
- */
- else if (!in_plt && symp->st_value != 0 &&
- ELF_ST_TYPE(symp->st_info) == STT_FUNC)
- return symp;
+ rdbg(("check \"%s\" vs \"%s\" in %s", name, strp, obj->path));
+ if (name[1] != strp[1] || strcmp(name, strp))
+ continue;
+#ifdef __mips__
+ if (symp->st_shndx == SHN_UNDEF)
+ continue;
+#else
+ /*
+ * XXX DANGER WILL ROBINSON!
+ * If we have a function pointer in the executable's
+ * data section, it points to the executable's PLT
+ * slot, and there is NO relocation emitted. To make
+ * the function pointer comparable to function pointers
+ * in shared libraries, we must resolve data references
+ * in the libraries to point to PLT slots in the
+ * executable, if they exist.
+ */
+ if (symp->st_shndx == SHN_UNDEF &&
+ ((flags & SYMLOOK_IN_PLT) ||
+ symp->st_value == 0 ||
+ ELF_ST_TYPE(symp->st_info) != STT_FUNC))
+ continue;
#endif
- else
- return NULL;
+
+ if (ventry == NULL) {
+ if (obj->versyms != NULL) {
+ verndx = VER_NDX(obj->versyms[symnum].vs_vers);
+ if (verndx > obj->vertabnum) {
+ _rtld_error("%s: symbol %s references "
+ "wrong version %d", obj->path,
+ &obj->strtab[symnum], verndx);
+ continue;
+ }
+
+ /*
+ * If we are not called from dlsym (i.e. this
+ * is a normal relocation from unversioned
+ * binary), accept the symbol immediately
+ * if it happens to have first version after
+ * this shared object became versioned.
+ * Otherwise, if symbol is versioned and not
+ * hidden, remember it. If it is the only
+ * symbol with this name exported by the shared
+ * object, it will be returned as a match at the
+ * end of the function. If symbol is global
+ * (verndx < 2) accept it unconditionally.
+ */
+ if (!(flags & SYMLOOK_DLSYM) &&
+ verndx == VER_NDX_GIVEN) {
+ return symp;
+ } else if (verndx >= VER_NDX_GIVEN) {
+ if (!(obj->versyms[symnum].vs_vers & VER_NDX_HIDDEN)) {
+ if (vsymp == NULL)
+ vsymp = symp;
+ vcount++;
+ }
+ continue;
+ }
+ }
+ return symp;
+ } else {
+ if (obj->versyms == NULL) {
+ if (_rtld_object_match_name(obj, ventry->name)){
+ _rtld_error("%s: object %s should "
+ "provide version %s for symbol %s",
+ _rtld_objself.path, obj->path,
+ ventry->name, &obj->strtab[symnum]);
+ continue;
+ }
+ } else {
+ verndx = VER_NDX(obj->versyms[symnum].vs_vers);
+ if (verndx > obj->vertabnum) {
+ _rtld_error("%s: symbol %s references "
+ "wrong version %d", obj->path,
+ &obj->strtab[symnum], verndx);
+ continue;
+ }
+ if (obj->vertab[verndx].hash != ventry->hash ||
+ strcmp(obj->vertab[verndx].name, ventry->name)) {
+ /*
+ * Version does not match. Look if this
+ * is a global symbol and if it is not
+ * hidden. If global symbol (verndx < 2)
+ * is available, use it. Do not return
+ * symbol if we are called by dlvsym,
+ * because dlvsym looks for a specific
+ * version and default one is not what
+ * dlvsym wants.
+ */
+ if ((flags & SYMLOOK_DLSYM) ||
+ (obj->versyms[symnum].vs_vers & VER_NDX_HIDDEN) ||
+ (verndx >= VER_NDX_GIVEN))
+ continue;
+ }
+ }
+ return symp;
}
}
-
+ if (vcount == 1)
+ return vsymp;
return NULL;
}
*/
const Elf_Sym *
_rtld_find_symdef(unsigned long symnum, const Obj_Entry *refobj,
- const Obj_Entry **defobj_out, bool in_plt)
+ const Obj_Entry **defobj_out, u_int flags)
{
const Elf_Sym *ref;
const Elf_Sym *def;
static const Elf_Sym *last_def;
if (symnum == last_symnum && refobj == _rtld_last_refobj
- && in_plt == false) {
+ && !(flags & SYMLOOK_IN_PLT)) {
*defobj_out = last_defobj;
return last_def;
}
hash = _rtld_elf_hash(name);
defobj = NULL;
- def = _rtld_symlook_default(name, hash, refobj, &defobj, in_plt);
+ def = _rtld_symlook_default(name, hash, refobj, &defobj, flags,
+ _rtld_fetch_ventry(refobj, symnum));
} else {
rdbg(("STB_LOCAL symbol %s in %s", name, refobj->path));
def = ref;
if (def != NULL) {
*defobj_out = defobj;
#ifdef COMBRELOC
- if (in_plt == false) {
+ if (!(flags & SYMLOOK_IN_PLT)) {
/*
* Cache the lookup arguments and results if this was
* non-PLT lookup.
} else {
rdbg(("lookup failed"));
_rtld_error("%s: Undefined %ssymbol \"%s\" (symnum = %ld)",
- refobj->path, in_plt ? "PLT " : "", name, symnum);
+ refobj->path, (flags & SYMLOOK_IN_PLT) ? "PLT " : "",
+ name, symnum);
}
return def;
}
_rtld_find_plt_symdef(unsigned long symnum, const Obj_Entry *obj,
const Obj_Entry **defobj, bool imm)
{
- const Elf_Sym *def = _rtld_find_symdef(symnum, obj, defobj, true);
+ const Elf_Sym *def = _rtld_find_symdef(symnum, obj, defobj,
+ SYMLOOK_IN_PLT);
if (__predict_false(def == NULL))
return NULL;
*/
const Elf_Sym *
_rtld_symlook_default(const char *name, unsigned long hash,
- const Obj_Entry *refobj, const Obj_Entry **defobj_out, bool in_plt)
+ const Obj_Entry *refobj, const Obj_Entry **defobj_out, u_int flags,
+ const Ver_Entry *ventry)
{
const Elf_Sym *def;
const Elf_Sym *symp;
/* Look first in the referencing object if linked symbolically. */
if (refobj->symbolic && !_rtld_donelist_check(&donelist, refobj)) {
rdbg(("search referencing object for %s", name));
- symp = _rtld_symlook_obj(name, hash, refobj, in_plt);
+ symp = _rtld_symlook_obj(name, hash, refobj, flags, ventry);
if (symp != NULL) {
def = symp;
defobj = refobj;
if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
rdbg(("search _rtld_list_main for %s", name));
symp = _rtld_symlook_list(name, hash, &_rtld_list_main, &obj,
- in_plt, &donelist);
+ flags, ventry, &donelist);
if (symp != NULL &&
(def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
def = symp;
if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
rdbg(("search _rtld_list_global for %s", name));
symp = _rtld_symlook_list(name, hash, &_rtld_list_global,
- &obj, in_plt, &donelist);
+ &obj, flags, ventry, &donelist);
if (symp != NULL &&
(def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
def = symp;
rdbg(("search DAG with root %p (%s) for %s", elm->obj,
elm->obj->path, name));
symp = _rtld_symlook_list(name, hash, &elm->obj->dagmembers,
- &obj, in_plt, &donelist);
+ &obj, flags, ventry, &donelist);
if (symp != NULL &&
(def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
def = symp;
*/
if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
rdbg(("Search the dynamic linker itself."));
- symp = _rtld_symlook_obj(name, hash, &_rtld_objself, in_plt);
+ symp = _rtld_symlook_obj(name, hash, &_rtld_objself, flags,
+ ventry);
if (symp != NULL && _rtld_is_exported(symp)) {
def = symp;
defobj = &_rtld_objself;
--- /dev/null
+/* $NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $ */
+
+/*-
+ * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
+ * Copyright 2003 Alexander Kabaev <kan@FreeBSD.ORG>.
+ * Copyright 2009, 2010, 2011 Konstantin Belousov <kib@FreeBSD.ORG>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, 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: head/libexec/rtld-elf/rtld.c 220004 2011-03-25 18:23:10Z avg $
+ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by NONAKA Kimihiro.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $");
+
+#include <sys/param.h>
+#include <sys/exec_elf.h>
+#include <string.h>
+
+#include "debug.h"
+#include "rtld.h"
+
+
+int
+_rtld_object_match_name(const Obj_Entry *obj, const char *name)
+{
+ Name_Entry *entry;
+
+ STAILQ_FOREACH(entry, &obj->names, link) {
+ dbg(("name: %s, entry->name: %s", name, entry->name));
+ if (strcmp(name, entry->name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+static Obj_Entry *
+locate_dependency(const Obj_Entry *obj, const char *name)
+{
+ const Objlist_Entry *entry;
+ const Needed_Entry *needed;
+
+ SIMPLEQ_FOREACH(entry, &_rtld_list_main, link) {
+ if (_rtld_object_match_name(entry->obj, name))
+ return entry->obj;
+ }
+
+ for (needed = obj->needed; needed != NULL; needed = needed->next) {
+ dbg(("needed: name: %s, str: %s", name,
+ &obj->strtab[needed->name]));
+ if (strcmp(name, &obj->strtab[needed->name]) == 0 ||
+ (needed->obj != NULL && _rtld_object_match_name(needed->obj, name))) {
+ /*
+ * If there is DT_NEEDED for the name we are looking
+ * for, we are all set. Note that object might not be
+ * found if dependency was not loaded yet, so the
+ * function can return NULL here. This is expected
+ * and handled properly by the caller.
+ */
+ return needed->obj;
+ }
+ }
+
+ _rtld_error("%s: Unexpected inconsistency: dependency %s not found",
+ obj->path, name);
+ return NULL;
+}
+
+static int
+check_object_provided_version(Obj_Entry *refobj, const Obj_Entry *depobj,
+ const Elf_Vernaux *vna)
+{
+ const char *vername = &refobj->strtab[vna->vna_name];
+ const char *depstrtab = depobj->strtab;
+ const Elf_Verdef *vd = depobj->verdef;
+ const Elf_Word hash = vna->vna_hash;
+
+ if (vd == NULL) {
+ _rtld_error("%s: version %s required by %s not defined",
+ depobj->path, vername, refobj->path);
+ return -1;
+ }
+
+ for (;; vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next)) {
+ if (vd->vd_version != VER_DEF_CURRENT) {
+ _rtld_error(
+ "%s: Unsupported version %d of Elf_Verdef entry",
+ depobj->path, vd->vd_version);
+ return -1;
+ }
+ dbg(("hash: 0x%x, vd_hash: 0x%x", hash, vd->vd_hash));
+ if (hash == vd->vd_hash) {
+ const Elf_Verdaux *vda = (const Elf_Verdaux *)
+ ((const char *)vd + vd->vd_aux);
+ dbg(("vername: %s, str: %s", vername,
+ &depstrtab[vda->vda_name]));
+ if (strcmp(vername, &depstrtab[vda->vda_name]) == 0)
+ return 0;
+ }
+ if (vd->vd_next == 0)
+ break;
+ }
+ if (vna->vna_flags & VER_FLG_WEAK)
+ return 0;
+
+ _rtld_error("%s: version %s required by %s not found", depobj->path,
+ vername, refobj->path);
+ return -1;
+}
+
+int
+_rtld_verify_object_versions(Obj_Entry *obj)
+{
+ const char *strtab = obj->strtab;
+ const Elf_Verneed *vn;
+ const Elf_Vernaux *vna;
+ const Elf_Verdef *vd;
+ const Elf_Verdaux *vda;
+ const Obj_Entry *depobj;
+ int maxvertab, vernum;
+
+ dbg(("obj->path: %s", obj->path));
+
+ /*
+ * If we don't have string table or objects that have their version
+ * requirements already checked, we must be ok.
+ */
+ if (strtab == NULL || obj->vertab != NULL)
+ return 0;
+
+ maxvertab = 0;
+
+ /*
+ * Walk over defined and required version records and figure out
+ * max index used by any of them. Do very basic sanity checking
+ * while there.
+ */
+ for (vn = obj->verneed;
+ vn != NULL;
+ vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next)) {
+
+ if (vn->vn_version != VER_NEED_CURRENT) {
+ _rtld_error(
+ "%s: Unsupported version %d of Elf_Verneed entry",
+ obj->path, vn->vn_version);
+ return -1;
+ }
+
+ dbg(("verneed: vn_file: %d, str: %s",
+ vn->vn_file, &strtab[vn->vn_file]));
+ depobj = locate_dependency(obj, &strtab[vn->vn_file]);
+ assert(depobj != NULL);
+
+ for (vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
+ /*CONSTCOND*/1;
+ vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next)) {
+
+ if (check_object_provided_version(obj, depobj, vna) == -1)
+ return -1;
+
+ vernum = VER_NEED_IDX(vna->vna_other);
+ if (vernum > maxvertab)
+ maxvertab = vernum;
+
+ if (vna->vna_next == 0) {
+ /* No more symbols. */
+ break;
+ }
+ }
+
+ if (vn->vn_next == 0) {
+ /* No more dependencies. */
+ break;
+ }
+ }
+
+ for (vd = obj->verdef;
+ vd != NULL;
+ vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next)) {
+
+ if (vd->vd_version != VER_DEF_CURRENT) {
+ _rtld_error(
+ "%s: Unsupported version %d of Elf_Verdef entry",
+ obj->path, vd->vd_version);
+ return -1;
+ }
+
+ dbg(("verdef: vn_ndx: 0x%x", vd->vd_ndx));
+ vernum = VER_DEF_IDX(vd->vd_ndx);
+ if (vernum > maxvertab)
+ maxvertab = vernum;
+
+ if (vd->vd_next == 0) {
+ /* No more definitions. */
+ break;
+ }
+ }
+
+ dbg(("maxvertab: %d", maxvertab));
+ if (maxvertab == 0)
+ return 0;
+
+ /*
+ * Store version information in array indexable by version index.
+ * Verify that object version requirements are satisfied along the
+ * way.
+ */
+ obj->vertabnum = maxvertab + 1;
+ obj->vertab = (Ver_Entry *)xcalloc(obj->vertabnum * sizeof(Ver_Entry));
+
+ for (vn = obj->verneed;
+ vn != NULL;
+ vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next)) {
+
+ for (vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
+ /*CONSTCOND*/1;
+ vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next)) {
+
+ vernum = VER_NEED_IDX(vna->vna_other);
+ assert(vernum <= maxvertab);
+ obj->vertab[vernum].hash = vna->vna_hash;
+ obj->vertab[vernum].name = &strtab[vna->vna_name];
+ obj->vertab[vernum].file = &strtab[vn->vn_file];
+ obj->vertab[vernum].flags =
+ (vna->vna_other & VER_NEED_HIDDEN)
+ ? VER_INFO_HIDDEN : 0;
+ dbg(("verneed: vernum: %d, hash: 0x%x, name: %s, "
+ "file: %s, flags: 0x%x", vernum,
+ obj->vertab[vernum].hash, obj->vertab[vernum].name,
+ obj->vertab[vernum].file,
+ obj->vertab[vernum].flags));
+
+ if (vna->vna_next == 0) {
+ /* No more symbols. */
+ break;
+ }
+ }
+ if (vn->vn_next == 0) {
+ /* No more dependencies. */
+ break;
+ }
+ }
+
+ for (vd = obj->verdef;
+ vd != NULL;
+ vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next)) {
+
+ if ((vd->vd_flags & VER_FLG_BASE) == 0) {
+ vernum = VER_DEF_IDX(vd->vd_ndx);
+ assert(vernum <= maxvertab);
+ vda = (const Elf_Verdaux *)
+ ((const char *)vd + vd->vd_aux);
+ obj->vertab[vernum].hash = vd->vd_hash;
+ obj->vertab[vernum].name = &strtab[vda->vda_name];
+ obj->vertab[vernum].file = NULL;
+ obj->vertab[vernum].flags = 0;
+ dbg(("verdef: vernum: %d, hash: 0x%x, name: %s",
+ vernum, obj->vertab[vernum].hash,
+ obj->vertab[vernum].name));
+ }
+
+ if (vd->vd_next == 0) {
+ /* No more definitions. */
+ break;
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+/* $NetBSD: tls.c,v 1.7 2011/04/23 16:40:08 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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 <sys/cdefs.h>
+__RCSID("$NetBSD: tls.c,v 1.7 2011/04/23 16:40:08 joerg Exp $");
+
+#include <sys/param.h>
+#include <sys/ucontext.h>
+#include <lwp.h>
+#include <string.h>
+#include "rtld.h"
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+
+static struct tls_tcb *_rtld_tls_allocate_locked(void);
+
+#ifndef TLS_DTV_OFFSET
+#define TLS_DTV_OFFSET 0
+#endif
+
+static size_t _rtld_tls_static_space; /* Static TLS space allocated */
+static size_t _rtld_tls_static_offset; /* Next offset for static TLS to use */
+size_t _rtld_tls_dtv_generation = 1;
+size_t _rtld_tls_max_index = 1;
+
+#define DTV_GENERATION(dtv) ((size_t)((dtv)[0]))
+#define DTV_MAX_INDEX(dtv) ((size_t)((dtv)[-1]))
+#define SET_DTV_GENERATION(dtv, val) (dtv)[0] = (void *)(size_t)(val)
+#define SET_DTV_MAX_INDEX(dtv, val) (dtv)[-1] = (void *)(size_t)(val)
+
+void *
+_rtld_tls_get_addr(void *tls, size_t idx, size_t offset)
+{
+ struct tls_tcb *tcb = tls;
+ void **dtv, **new_dtv;
+ sigset_t mask;
+
+ _rtld_exclusive_enter(&mask);
+
+ dtv = tcb->tcb_dtv;
+
+ if (__predict_false(DTV_GENERATION(dtv) != _rtld_tls_dtv_generation)) {
+ size_t to_copy = DTV_MAX_INDEX(dtv);
+
+ new_dtv = xcalloc((2 + _rtld_tls_max_index) * sizeof(*dtv));
+ ++new_dtv;
+ if (to_copy > _rtld_tls_max_index)
+ to_copy = _rtld_tls_max_index;
+ memcpy(new_dtv + 1, dtv + 1, to_copy * sizeof(*dtv));
+ xfree(dtv - 1);
+ dtv = tcb->tcb_dtv = new_dtv;
+ SET_DTV_MAX_INDEX(dtv, _rtld_tls_max_index);
+ SET_DTV_GENERATION(dtv, _rtld_tls_dtv_generation);
+ }
+
+ if (__predict_false(dtv[idx] == NULL))
+ dtv[idx] = _rtld_tls_module_allocate(idx);
+
+ _rtld_exclusive_exit(&mask);
+
+ return (uint8_t *)dtv[idx] + offset;
+}
+
+void
+_rtld_tls_initial_allocation(void)
+{
+ struct tls_tcb *tcb;
+
+ _rtld_tls_static_space = _rtld_tls_static_offset +
+ RTLD_STATIC_TLS_RESERVATION;
+
+#ifndef __HAVE_TLS_VARIANT_I
+ _rtld_tls_static_space = roundup2(_rtld_tls_static_space,
+ sizeof(void *));
+#endif
+
+ tcb = _rtld_tls_allocate_locked();
+#ifdef __HAVE___LWP_SETTCB
+ __lwp_settcb(tcb);
+#ifdef __powerpc__
+ /*
+ * Save the tcb pointer so that libc can retrieve it. Older
+ * crt0 will obliterate r2 so there is code in libc to restore it.
+ */
+ _lwp_setprivate(tcb);
+#endif
+#else
+ _lwp_setprivate(tcb);
+#endif
+}
+
+static struct tls_tcb *
+_rtld_tls_allocate_locked(void)
+{
+ Obj_Entry *obj;
+ struct tls_tcb *tcb;
+ uint8_t *p, *q;
+
+ p = xcalloc(_rtld_tls_static_space + sizeof(struct tls_tcb));
+#ifdef __HAVE_TLS_VARIANT_I
+ tcb = (struct tls_tcb *)p;
+ p += sizeof(struct tls_tcb);
+#else
+ p += _rtld_tls_static_space;
+ tcb = (struct tls_tcb *)p;
+ tcb->tcb_self = tcb;
+#endif
+ tcb->tcb_dtv = xcalloc(sizeof(*tcb->tcb_dtv) * (2 + _rtld_tls_max_index));
+ ++tcb->tcb_dtv;
+ SET_DTV_MAX_INDEX(tcb->tcb_dtv, _rtld_tls_max_index);
+ SET_DTV_GENERATION(tcb->tcb_dtv, _rtld_tls_dtv_generation);
+
+ for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
+ if (obj->tlssize) {
+#ifdef __HAVE_TLS_VARIANT_I
+ q = p + obj->tlsoffset;
+#else
+ q = p - obj->tlsoffset;
+#endif
+ memcpy(q, obj->tlsinit, obj->tlsinitsize);
+ tcb->tcb_dtv[obj->tlsindex] = q;
+ }
+ }
+
+ return tcb;
+}
+
+struct tls_tcb *
+_rtld_tls_allocate(void)
+{
+ struct tls_tcb *tcb;
+ sigset_t mask;
+
+ _rtld_exclusive_enter(&mask);
+ tcb = _rtld_tls_allocate_locked();
+ _rtld_exclusive_exit(&mask);
+
+ return tcb;
+}
+
+void
+_rtld_tls_free(struct tls_tcb *tcb)
+{
+ size_t i, max_index;
+ uint8_t *p;
+ sigset_t mask;
+
+ _rtld_exclusive_enter(&mask);
+
+ max_index = DTV_MAX_INDEX(tcb->tcb_dtv);
+ for (i = 1; i <= max_index; ++i)
+ xfree(tcb->tcb_dtv[i]);
+ xfree(tcb->tcb_dtv - 1);
+
+#ifdef __HAVE_TLS_VARIANT_I
+ p = (uint8_t *)tcb;
+#else
+ p = (uint8_t *)tcb - _rtld_tls_static_space;
+#endif
+ xfree(p);
+
+ _rtld_exclusive_exit(&mask);
+}
+
+void *
+_rtld_tls_module_allocate(size_t idx)
+{
+ Obj_Entry *obj;
+ uint8_t *p;
+
+ for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
+ if (obj->tlsindex == idx)
+ break;
+ }
+ if (obj == NULL) {
+ _rtld_error("Module for TLS index %zu missing", idx);
+ _rtld_die();
+ }
+
+ p = xmalloc(obj->tlssize);
+ memcpy(p, obj->tlsinit, obj->tlsinitsize);
+ memset(p + obj->tlsinitsize, 0, obj->tlssize - obj->tlsinitsize);
+
+ return p;
+}
+
+int
+_rtld_tls_offset_allocate(Obj_Entry *obj)
+{
+ size_t offset, next_offset;
+
+ if (obj->tls_done)
+ return 0;
+ if (obj->tlssize == 0) {
+ obj->tlsoffset = 0;
+ obj->tls_done = 1;
+ return 0;
+ }
+
+#ifdef __HAVE_TLS_VARIANT_I
+ offset = roundup2(_rtld_tls_static_offset, obj->tlsalign);
+ next_offset = offset + obj->tlssize;
+#else
+ offset = roundup2(_rtld_tls_static_offset + obj->tlssize,
+ obj->tlsalign);
+ next_offset = offset;
+#endif
+
+ /*
+ * Check if the static allocation was already done.
+ * This happens if dynamically loaded modules want to use
+ * static TLS space.
+ *
+ * XXX Keep an actual free list and callbacks for initialisation.
+ */
+ if (_rtld_tls_static_space) {
+ if (obj->tlsinitsize) {
+ _rtld_error("%s: Use of initialized "
+ "Thread Local Storage with model initial-exec "
+ "and dlopen is not supported",
+ obj->path);
+ return -1;
+ }
+ if (next_offset > _rtld_tls_static_space) {
+ _rtld_error("%s: No space available "
+ "for static Thread Local Storage",
+ obj->path);
+ return -1;
+ }
+ }
+ obj->tlsoffset = offset;
+ _rtld_tls_static_offset = next_offset;
+ obj->tls_done = 1;
+
+ return 0;
+}
+
+void
+_rtld_tls_offset_free(Obj_Entry *obj)
+{
+
+ /*
+ * XXX See above.
+ */
+ obj->tls_done = 0;
+ return;
+}
+
+#ifdef __HAVE_COMMON___TLS_GET_ADDR
+/*
+ * The fast path is access to an already allocated DTV entry.
+ * This checks the current limit and the entry without needing any
+ * locking. Entries are only freed on dlclose() and it is an application
+ * bug if code of the module is still running at that point.
+ */
+void *
+__tls_get_addr(void *arg_)
+{
+ size_t *arg = (size_t *)arg_;
+ void **dtv;
+#ifdef __HAVE___LWP_GETTCB_FAST
+ struct tls_tcb * const tcb = __lwp_gettcb_fast();
+#else
+ struct tls_tcb * const tcb = __lwp_getprivate_fast();
+#endif
+ size_t idx = arg[0], offset = arg[1] + TLS_DTV_OFFSET;
+
+ dtv = tcb->tcb_dtv;
+
+ if (__predict_true(idx < DTV_MAX_INDEX(dtv) && dtv[idx] != NULL))
+ return (uint8_t *)dtv[idx] + offset;
+
+ return _rtld_tls_get_addr(tcb, idx, offset);
+}
+#endif
+
+#endif /* __HAVE_TLS_VARIANT_I || __HAVE_TLS_VARIANT_II */
-/* $NetBSD: xmalloc.c,v 1.10 2010/12/03 23:07:49 joerg Exp $ */
+/* $NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
*/
#ifdef __minix
+/* Minix mmap can do this. */
+#define mmap minix_mmap
#define munmap minix_munmap
#endif
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: xmalloc.c,v 1.10 2010/12/03 23:07:49 joerg Exp $");
+__RCSID("$NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $");
#endif /* not lint */
#include <stdlib.h>
static size_t pagesz; /* page size */
static size_t pagebucket; /* page size bucket */
+static size_t pageshift; /* page size shift */
#ifdef MSTATS
/*
bucket++;
}
pagebucket = bucket;
+ pageshift = ffs(pagesz) - 1;
}
/*
* Convert amount of memory requested into closest block size
#endif
if (sz < pagesz) {
amt = pagesz;
- nblks = amt / sz;
+ nblks = amt >> (bucket + 3);
} else {
amt = sz + pagesz;
nblks = 1;
}
if (amt > PAGEPOOL_SIZE)
- if (morepages(amt/pagesz + NPOOLPAGES) == 0)
+ if (morepages((amt >> pageshift) + NPOOLPAGES) == 0)
return;
op = (union overhead *)pagepool_start;
pagepool_start += amt;
}
#endif
-/* Minix mmap can do this. */
-#ifdef __minix
-#define mmap minix_mmap
-#endif
static int
morepages(int n)
static size_t off, left, used;
static off_t skip;
-#define MIN(x,y) (x<y?x:y)
-
/*===========================================================================*
* buf_init *
*===========================================================================*/
rip = find_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR);
if (!rip) {
- printf("%s:%d put_inode: inode #%lu dev: %d not found\n", __FILE__,
+ printf("%s:%d put_inode: inode #%u dev: %d not found\n", __FILE__,
__LINE__, (ino_t) fs_m_in.REQ_INODE_NR, fs_dev);
panic("fs_putnode failed");
}
* the double/triple indirect block.
* It's the only function which should take care about rip->i_blocks counter.
*/
- int index1, index2, index3; /* indexes in single..triple indirect blocks */
+ int index1 = 0, index2 = 0, index3 = 0; /* indexes in single..triple indirect blocks */
long excess, block_pos;
char new_ind = 0, new_dbl = 0, new_triple = 0;
int single = 0, triple = 0;
}
else if (!curr_time)
{
- DBLOCK(0x20, printf("set_time: new time %ld < prev_time %ld\n",
+ DBLOCK(0x20, printf("set_time: new time %i < prev_time %i\n",
tim, prev_time));
}
}
rtt= TCP_RTT_MAX;
}
DBLOCK(0x10, printf(
- "tcp_release_retrans, conn[%d]: retrans_time= %ld ms, rtt = %ld ms\n",
+ "tcp_release_retrans, conn[%i]: retrans_time= %i ms, rtt = %i ms\n",
tcp_conn-tcp_conn_table,
retrans_time*1000/HZ,
rtt*1000/HZ));
DBLOCK(0x10, printf(
- "tcp_release_retrans: artt= %ld -> %ld, drtt= %ld -> %ld\n",
+ "tcp_release_retrans: artt= %i -> %i, drtt= %i -> %i\n",
tcp_conn->tc_artt, artt,
tcp_conn->tc_drtt, drtt));
tcp_conn->tc_ka_snd= tcp_conn->tc_SND_NXT;
tcp_conn->tc_ka_rcv= tcp_conn->tc_RCV_NXT;
DBLOCK(0x20, printf(
-"tcp_send_timeout: conn[%d] setting keepalive timer (+%ld ms)\n",
+"tcp_send_timeout: conn[%i] setting keepalive timer (+%i ms)\n",
tcp_conn-tcp_conn_table,
tcp_conn->tc_ka_time*1000/HZ));
clck_timer(&tcp_conn->tc_transmit_timer,
tcp_conn->tc_0wnd_to= 0;
DBLOCK(0x20, printf(
- "tcp_send_timeout: conn[%d] setting timer to %ld ms (+%ld ms)\n",
+ "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n",
tcp_conn-tcp_conn_table,
(curr_time+rtt)*1000/HZ, rtt*1000/HZ));
tcp_conn->tc_rt_seq= 0;
DBLOCK(0x10, printf(
- "tcp_send_timeout: conn[%d] setting timer to %ld ms (+%ld ms)\n",
+ "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n",
tcp_conn-tcp_conn_table,
(curr_time+tcp_conn->tc_0wnd_to)*1000/HZ,
tcp_conn->tc_0wnd_to*1000/HZ));
* probe, which is almost the same.
*/
- DBLOCK(0x20, printf("tcp_send_timeout: conn[%d] una= %lu, rtt= %ldms\n",
+ DBLOCK(0x20, printf("tcp_send_timeout: conn[%i] una= %lu, rtt= %ims\n",
tcp_conn-tcp_conn_table,
(unsigned long)tcp_conn->tc_SND_UNA, rtt*1000/HZ));
timeout += curr_time;
DBLOCK(0x20, printf(
- "tcp_send_timeout: conn[%d] setting timer to %ld ms (+%ld ms)\n",
+ "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n",
tcp_conn-tcp_conn_table, timeout*1000/HZ,
(timeout-curr_time)*1000/HZ));
rtt= tcp_conn->tc_rtt;
DBLOCK(0x20, printf(
- "tcp_set_send_timer: conn[%d] setting timer to %ld ms (+%ld ms)\n",
+ "tcp_set_send_timer: conn[%i] setting timer to %i ms (+%i ms)\n",
tcp_conn-tcp_conn_table,
(curr_time+rtt)*1000/HZ, rtt*1000/HZ));
int do_semctl(message *m)
{
int r, i;
- long opt;
+ long opt = 0;
uid_t uid;
int id, num, cmd, val;
unsigned short *buf;
PROCLOOP(rp, oldrp)
printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint);
- printf("%-8.8s %5u %5u %6lu %6lu ",
+ printf("%-8.8s %5u %5u %6u %6u ",
rp->p_name,
rp->p_priority,
rp->p_quantum_size_ms,
printf(" %08lx %08lx %08lx ",
mp->mp_ignore, mp->mp_catch, mp->mp_sigmask);
printf("%08lx ", mp->mp_sigpending);
- if (mp->mp_flags & ALARM_ON) printf("%8ld", mp->mp_timer.tmr_exp_time-uptime);
+ if (mp->mp_flags & ALARM_ON) printf("%8d", mp->mp_timer.tmr_exp_time-uptime);
else printf(" -");
printf("\n");
}
rpub = &rprocpub[i];
if (! (rp->r_flags & RS_IN_USE)) continue;
if (++n > 22) break;
- printf("%13s %9d %5d %6s %3d/%1d %3ld %8ld %5dx %s",
+ printf("%13s %9d %5d %6s %3d/%1d %3ld %8d %5dx %s",
rpub->label, rpub->endpoint, rp->r_pid,
s_flags_str(rp->r_flags, rpub->sys_flags), rpub->dev_nr,
rpub->dev_style, rp->r_period, rp->r_alive_tm, rp->r_restarts,
/* Find starting inode inode according to the request message */
if ((start_dir = get_dir_record(dir_ino)) == NULL) {
- printf("ISOFS: couldn't find starting inode %lu\n", dir_ino);
+ printf("ISOFS: couldn't find starting inode %u\n", dir_ino);
return(ENOENT);
}
rip = find_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR);
if(!rip) {
- printf("%s:%d put_inode: inode #%lu dev: %d not found\n", __FILE__,
+ printf("%s:%d put_inode: inode #%u dev: %d not found\n", __FILE__,
__LINE__, (ino_t) fs_m_in.REQ_INODE_NR, fs_dev);
panic("fs_putnode failed");
}
if (off+seg_bytes > execi->hdr_len) return ENOEXEC;
if((r= sys_vircopy(SELF, ((vir_bytes)execi->hdr)+off,
execi->proc_e, seg_addr, seg_bytes)) != OK) {
- printf("RS: exec read_seg: copy 0x%x bytes into %d at 0x%lx failed: %d\n",
+ printf("RS: exec read_seg: copy 0x%x bytes into %i at 0x%08x failed: %i\n",
seg_bytes, execi->proc_e, seg_addr, r);
}
return r;
*/
/* Device number of the new device. */
- dev = (dev & ~(BYTE << MINOR)) | (dev_mess.REP_STATUS << MINOR);
+ dev = makedev(major(dev), minor(dev_mess.REP_STATUS));
/* Issue request */
r = req_newnode(PFS_PROC_NR, fp->fp_effuid, fp->fp_effgid,
# MINIX-specific boot program options
.include <bsd.own.mk>
-.include <minix.service.mk>
+# LSC Static linking, order matters!
+# 1. No default libs
+LDADD+= -nodefaultlibs
+
+# 2. Compiler-specific libs
+.if !empty(CC:M*gcc)
+LDADD+= -lgcc -lsys -lgcc
+.elif !empty(CC:M*clang)
+LDADD+= -L/usr/pkg/compiler-rt/lib -lCompilerRT-Generic -lsys -lCompilerRT-Generic
+.endif
+
+# 3. Minimal C library
+LDADD+= -lminc
+
+# Some define still needed, hopefully will go away soon
+CPPFLAGS+= -D__NBSD_LIBC
+
+.include <bsd.prog.mk>
# MINIX-specific servers/drivers options
.include <bsd.own.mk>
-CPPFLAGS+= -D__NBSD_LIBC
-
-.if !empty(CC:M*gcc)
-LDADD+= -nodefaultlibs -lgcc -lsys -lgcc -lminc
-.elif !empty(CC:M*clang)
-LDADD+= -nodefaultlibs -L/usr/pkg/compiler-rt/lib -lCompilerRT-Generic -lsys -lCompilerRT-Generic -lminc
-.endif
-
-.include <bsd.prog.mk>
+.include <minix.bootprog.mk>
-/* $NetBSD: ansi.h,v 1.24 2010/03/27 22:14:09 tnozaki Exp $ */
+/* $NetBSD: ansi.h,v 1.25 2011/07/17 20:54:41 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
* #undef _BSD_SIZE_T_
* #endif
*/
-
-#define _BSD_CLOCK_T_ long
-
-#define _BSD_PTRDIFF_T_ int
-
-#define _BSD_SIZE_T_ unsigned int
-#define _BSD_SSIZE_T_ int
-#define _BSD_TIME_T_ long /* time() */
-#if __GNUC_PREREQ__(2, 96)
-#define _BSD_VA_LIST_ __builtin_va_list /* GCC built-in type */
-#else
-#define _BSD_VA_LIST_ char * /* va_list */
-#endif
+#define _BSD_CLOCK_T_ int /* clock() */
+#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
+#define _BSD_SIZE_T_ unsigned int /* sizeof() */
+#define _BSD_SSIZE_T_ int /* byte count or error */
+#define _BSD_TIME_T_ int /* time() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
#define _BSD_TIMER_T_ int /* timer_t */
-#define _BSD_SUSECONDS_T_ long /* suseconds_t */
-#define _BSD_USECONDS_T_ long /* useconds_t */
+#define _BSD_SUSECONDS_T_ int /* suseconds_t */
+#define _BSD_USECONDS_T_ int /* useconds_t */
#define _BSD_WCHAR_T_ int /* wchar_t */
#define _BSD_WINT_T_ int /* wint_t */
-/* $NetBSD: cdefs.h,v 1.8 2011/06/16 13:27:59 joerg Exp $ */
+/* $NetBSD: cdefs.h,v 1.9 2012/01/20 14:08:06 joerg Exp $ */
#ifndef _I386_CDEFS_H_
#define _I386_CDEFS_H_
#if defined(_STANDALONE)
-#ifdef __PCC__
-#define __compactcall
-#else
#define __compactcall __attribute__((__regparm__(3)))
#endif
-#endif
-#ifdef __minix
+#define __ALIGNBYTES (sizeof(int) - 1)
+
+#if defined(__minix)
#ifndef __ELF__
#define __LEADING_UNDERSCORE
#endif
-#else /* !__minix */
-/* No arch-specific cdefs. */
-#endif
-
+#endif /* defined(__minix) */
#endif /* !_I386_CDEFS_H_ */
#define X86_FLAGS_USER (X86_FLAG_C | X86_FLAG_P | X86_FLAG_A | X86_FLAG_Z | \
X86_FLAG_S | X86_FLAG_D | X86_FLAG_O)
+#include <x86/cpu.h>
+
#endif
-/* $NetBSD: limits.h,v 1.22 2010/06/07 13:52:30 tnozaki Exp $ */
+/* $NetBSD: limits.h,v 1.23 2012/03/28 17:03:29 christos Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
#define CHAR_BIT 8 /* number of bits in a char */
+#define UCHAR_MAX 0xff /* max value for an unsigned char */
#define SCHAR_MAX 0x7f /* max value for a signed char */
#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-#define UCHAR_MAX 0xff /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
#define USHRT_MAX 0xffff /* max value for an unsigned short */
#define SHRT_MAX 0x7fff /* max value for a short */
#define SHRT_MIN (-0x7fff-1) /* min value for a short */
+/* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka 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.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (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 __MULTIBOOT_H__
#define __MULTIBOOT_H__
+#if !defined(_KERNEL) && defined(_STANDALONE)
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Multiboot header structure.
+ */
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
+#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
+#define MULTIBOOT_HEADER_HAS_VBE 0x00000004
+#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000
+
+#if !defined(_LOCORE)
+struct multiboot_header {
+ uint32_t mh_magic;
+ uint32_t mh_flags;
+ uint32_t mh_checksum;
+
+ /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
+ paddr_t mh_header_addr;
+ paddr_t mh_load_addr;
+ paddr_t mh_load_end_addr;
+ paddr_t mh_bss_end_addr;
+ paddr_t mh_entry_addr;
+
+ /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */
+ uint32_t mh_mode_type;
+ uint32_t mh_width;
+ uint32_t mh_height;
+ uint32_t mh_depth;
+};
+#endif /* !defined(_LOCORE) */
+
+/*
+ * Symbols defined in locore.S.
+ */
+#if !defined(_LOCORE) && defined(_KERNEL)
+extern struct multiboot_header *Multiboot_Header;
+#endif /* !defined(_LOCORE) && defined(_KERNEL) */
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Multiboot information structure.
+ */
+#define MULTIBOOT_INFO_MAGIC 0x2BADB002
+#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001
+#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
+#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
+#define MULTIBOOT_INFO_HAS_MODS 0x00000008
+#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010
+#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020
+#define MULTIBOOT_INFO_HAS_MMAP 0x00000040
+#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080
+#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100
+#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
+#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400
+#define MULTIBOOT_INFO_HAS_VBE 0x00000800
+
+#if !defined(_LOCORE)
+struct multiboot_info {
+ uint32_t mi_flags;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
+ uint32_t mi_mem_lower;
+ uint32_t mi_mem_upper;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */
+ uint8_t mi_boot_device_part3;
+ uint8_t mi_boot_device_part2;
+ uint8_t mi_boot_device_part1;
+ uint8_t mi_boot_device_drive;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
+ char * mi_cmdline;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
+ uint32_t mi_mods_count;
+ vaddr_t mi_mods_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */
+ uint32_t mi_elfshdr_num;
+ uint32_t mi_elfshdr_size;
+ vaddr_t mi_elfshdr_addr;
+ uint32_t mi_elfshdr_shndx;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
+ uint32_t mi_mmap_length;
+ vaddr_t mi_mmap_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
+ uint32_t mi_drives_length;
+ vaddr_t mi_drives_addr;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
+ void * unused_mi_config_table;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
+ char * mi_loader_name;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
+ void * unused_mi_apm_table;
+
+ /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
+ void * unused_mi_vbe_control_info;
+ void * unused_mi_vbe_mode_info;
+ paddr_t unused_mi_vbe_interface_seg;
+ paddr_t unused_mi_vbe_interface_off;
+ uint32_t unused_mi_vbe_interface_len;
+};
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Drive information. This describes an entry in the drives table as
+ * pointed to by mi_drives_addr.
+ */
+struct multiboot_drive {
+ uint32_t md_length;
+ uint8_t md_number;
+ uint8_t md_mode;
+ uint16_t md_cylinders;
+ uint8_t md_heads;
+ uint8_t md_sectors;
+
+ /* The variable-sized 'ports' field comes here, so this structure
+ * can be longer. */
+};
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Memory mapping. This describes an entry in the memory mappings table
+ * as pointed to by mi_mmap_addr.
+ *
+ * Be aware that mm_size specifies the size of all other fields *except*
+ * for mm_size. In order to jump between two different entries, you
+ * have to count mm_size + 4 bytes.
+ */
+struct multiboot_mmap {
+ uint32_t mm_size;
+ uint64_t mm_base_addr;
+ uint64_t mm_length;
+ uint32_t mm_type;
+};
+
+/*
+ * Modules. This describes an entry in the modules table as pointed
+ * to by mi_mods_addr.
+ */
+
+struct multiboot_module {
+ uint32_t mmo_start;
+ uint32_t mmo_end;
+ char * mmo_string;
+ uint32_t mmo_reserved;
+};
+
+#endif /* !defined(_LOCORE) */
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Prototypes for public functions defined in multiboot.c.
+ */
+#if !defined(_LOCORE) && defined(_KERNEL)
+void multiboot_pre_reloc(struct multiboot_info *);
+void multiboot_post_reloc(void);
+void multiboot_print_info(void);
+bool multiboot_ksyms_addsyms_elf(void);
+#endif /* !defined(_LOCORE) */
+
+/* --------------------------------------------------------------------- */
+#else /* !defined(_KERNEL) && defined(_STANDALONE) */
+/* LSC FIXME: OLD MINIX DEFINITION: should be removed and replace with
+ definition above... */
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
#endif /* __ASSEMBLY__ */
+#endif /* !defined(_KERNEL) && defined(_STANDALONE) */
#endif /* __MULTIBOOT_H__ */
-/* $NetBSD: types.h,v 1.70 2010/12/22 04:15:02 christos Exp $ */
+/* $NetBSD: types.h,v 1.74 2011/07/06 18:46:04 dyoung Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
/* The x86 does not have strict alignment requirements. */
#define __NO_STRICT_ALIGNMENT
-#define __HAVE_DEVICE_REGISTER
+#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_CPU_DATA_FIRST
#define __HAVE_CPU_COUNTER
#define __HAVE_MD_CPU_OFFLINE
#define __HAVE_ATOMIC_AS_MEMBAR
#define __HAVE_CPU_LWP_SETPRIVATE
#define __HAVE_INTR_CONTROL
+#define __HAVE_MM_MD_OPEN
+#define __HAVE___LWP_GETPRIVATE_FAST
+#if !defined(__minix)
+#define __HAVE_TLS_VARIANT_II
+#endif /* !defined(__minix) */
+#define __HAVE_COMMON___TLS_GET_ADDR
#if defined(_KERNEL)
#define __HAVE_RAS
.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
-# MINIX LSC seems to be still needed
-#LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
-LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start -L${DESTDIR}/${LIBDIR}
+LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
CPPFLAGS+= -I ${.OBJDIR}
+.if defined(__MINIX)
+CPPFLAGS+=-isystem ${DESTDIR}/usr/include
+CPPFLAGS+= -D_MINIX
+.endif # defined(__MINIX)
# Make sure we override any optimization options specified by the user
COPTS= -Os
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I$S
-.if defined(__MINIX)
-CPPFLAGS+= -I${DESTDIR}/usr/include
-CPPFLAGS+= -I${.CURDIR}/../../../../../../
-.endif
CPPFLAGS+= -DSUPPORT_PS2
CPPFLAGS+= -DDIRECT_SERIAL
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN= ${KERNLIB}
.else
-# MINIX
-LIBKERN= # use MINIX minc
+# use MINIX minc
+LIBKERN= ${DESTDIR}/usr/lib/libminc.a
.endif
### find out what to use for libz
# Anything that calls 'real_to_prot' must have a %pc < 0x10000.
# We link the program, find the callers (all in libi386), then
# explicitly pull in the required objects before any other library code.
-# MINIX (LSC adding LDADD still needed?)
${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
${_MKTARGET_LINK}
bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \
- ${OBJS} ${LIBLIST} ${LDADD} | ( \
+ ${OBJS} ${LIBLIST} | ( \
while read symbol file; do \
[ -z "$$file" ] && continue; \
[ "$$symbol" = real_to_prot ] && break; \
done; \
) )"; \
${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 \
- -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST} ${LDADD}
+ -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
${OBJCOPY} -O binary ${PROG}.syms ${PROG}
.ifndef __MINIX
# $NetBSD: Makefile,v 1.3 2005/12/11 12:17:48 christos Exp $
-# MINIX (LSC this still needed?)
-# Adding cleaning of specific target? -D_MINIX is not defined at top level ?
+# LSC FIXME: Why change the name?
PROG= boot_monitor
-CLEANFILES= lib
-
-CPPFLAGS+= -D_MINIX
.include <../Makefile.boot>
-/* $NetBSD: boot2.c,v 1.57 2011/12/25 06:09:09 tsutsui Exp $ */
+/* $NetBSD: boot2.c,v 1.58 2012/08/04 03:51:27 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
void command_consdev(char *);
void command_modules(char *);
void command_multiboot(char *);
+#ifdef __minix
void command_load_mods(char *);
+#endif
const struct bootblk_command commands[] = {
{ "help", command_help },
{ "consdev", command_consdev },
{ "modules", command_modules },
{ "load", module_add },
+#ifdef __minix
{ "load_mods", command_load_mods },
+#endif
{ "multiboot", command_multiboot },
{ "vesa", command_vesa },
{ "splash", splash_add },
"vesa {modenum|on|off|enabled|disabled|list}\n"
"modules {on|off|enabled|disabled}\n"
"load {path_to_module}\n"
+#ifdef __minix
"load_mods {path_to_modules}, pattern might be used\n"
+#endif
"multiboot [xdNx:][filename] [<args>]\n"
"userconf {command}\n"
"rndseed {path_to_rndseed_file}\n"
const char *save = default_filename;
default_filename = "/";
+#ifndef __minix
+ ls(arg);
+#else
ls(arg, NULL);
+#endif
default_filename = save;
}
+#ifdef __minix
void
command_load_mods(char *arg)
{
ls(arg, module_add);
default_filename = save;
}
+#endif
/* ARGSUSED */
void
command_boot(char *arg)
{
char *filename;
- int howto;
+ int howto, tell;
+
+ if (!parseboot(arg, &filename, &howto))
+ return;
- if (parseboot(arg, &filename, &howto))
- bootit(filename, howto, (howto & AB_VERBOSE) != 0);
+ tell = ((howto & AB_VERBOSE) != 0);
+ if (filename != NULL) {
+ bootit(filename, howto, tell);
+ } else {
+ int i;
+ for (i = 0; i < NUMNAMES; i++) {
+ bootit(names[i][0], howto, tell);
+ bootit(names[i][1], howto, tell);
+ }
+ }
}
void
-/* $NetBSD: conf.c,v 1.5 2008/04/05 18:21:34 tsutsui Exp $ */
+/* $NetBSD: conf.c,v 1.6 2012/01/16 18:46:20 christos Exp $ */
/*
* Copyright (c) 1997
# $NetBSD: Makefile,v 1.14 2010/12/29 17:44:03 jakllsch Exp $
-SUBDIR=
-#SUBDIR= bootxx_ffsv1 .WAIT bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
-#SUBDIR+=bootxx_msdos bootxx_ustarfs
+.if defined(__MINIX)
+SUBDIR= bootxx_minixfs3
+.else
+SUBDIR= bootxx_ffsv1 .WAIT bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
+SUBDIR+=bootxx_msdos bootxx_ustarfs
+.endif # defined(__MINIX)
# Ext2fs doesn't have enough free space (it has only 1KB)
# to store this primary bootloader, but we can put it into
# an independent small 'boot' partition as NetBSD/hp300 does.
-#
-# However MINIX implements a solution using the empty space before subpartition
-.if !empty(CC:M*pcc)
-# PCC cannot compile bootxx_ext2fs because it lacks regparm aka compactcall
-SUBDIR+=bootxx_minixfs3
-.else
-SUBDIR+=bootxx_ext2fs bootxx_minixfs3
-.endif
+SUBDIR+=bootxx_ext2fs
LIBOBJ= ${.OBJDIR}
.MAKEOVERRIDES+= LIBOBJ
.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
-LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start -L${DESTDIR}/${LIBDIR}
+LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
CPPFLAGS+= -DBOOTXX
# CPPFLAGS+= -D__daddr_t=int32_t
CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
CPPFLAGS+= -DXXfs_read=${FS}_read
CPPFLAGS+= -DXXfs_stat=${FS}_stat
CPPFLAGS+= -DFS=${FS}
-# clang generates too big bootxx_xxx
-.if !empty(CC:M*clang)
-CPPFLAGS+= -Os
-.endif
# CPPFLAGS+= -DBOOT_MSG_COM0
# Make sure we override any optimization options specified by the user
-#.include "${.PARSEDIR}/../Makefile.inc"
-#COPTS= ${OPT_SIZE.${ACTIVE_CC}}
-#DBG=
+.include "${.PARSEDIR}/../Makefile.inc"
+COPTS= ${OPT_SIZE.${ACTIVE_CC}}
+DBG=
CPPFLAGS+= -DNO_LBA_CHECK
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I$S
-.if defined(__MINIX)
-CPPFLAGS+= -I${DESTDIR}/usr/include
-CPPFLAGS+= -I${.CURDIR}/../../../../../../
-.endif
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
-DLIBSA_NO_TWIDDLE \
SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
.if defined(__MINIX)
SAMISCMAKEFLAGS+="SA_INCLUDE_NET=no"
+CPPFLAGS+= -isystem ${DESTDIR}/usr/include
+CPPFLAGS+= -D_MINIX
+AFLAGS+= -Wa,--divide
.endif
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN= ${KERNLIB}
.else
-# MINIX
-LIBKERN= # use MINIX minc
+# use MINIX minc
+LIBKERN= ${DESTDIR}/usr/lib/libminc.a
.endif
+
cleandir distclean: .WAIT cleanlibdir
cleanlibdir:
${PROG}: ${OBJS} ${LIBLIST}
${_MKTARGET_LINK}
${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
- -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST} ${LDADD}
+ -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
${OBJCOPY} -O binary ${PROG}.sym ${PROG}
@ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
done:
/* if we fail here, so will fstat, so keep going */
- if (fd == -1 || fstat(fd, &sb) == -1) {
+ if (fd == -1 || fstat(fd, &sb) == -1)
#ifndef __minix
return "Can't open /boot\r\n";
#else
return "Can't open /boot_monitor\r\n";
#endif
- }
biosdev = (uint32_t)sb.st_size;
#if 0
return "/boot too large\r\n";
#endif
- if (read(fd, (void *)SECONDARY_LOAD_ADDRESS, biosdev) != biosdev) {
+ if (read(fd, (void *)SECONDARY_LOAD_ADDRESS, biosdev) != biosdev)
#ifndef __minix
return "/boot load failed\r\n";
#else
return "/boot_monitor load failed\r\n";
#endif
- }
- if (*(uint32_t *)(SECONDARY_LOAD_ADDRESS + 4) != X86_BOOT_MAGIC_2) {
+ if (*(uint32_t *)(SECONDARY_LOAD_ADDRESS + 4) != X86_BOOT_MAGIC_2)
#ifndef __minix
return "Invalid /boot file format\r\n";
#else
return "Invalid /boot_monitor file format\r\n";
#endif
- }
/* We need to jump to the secondary bootstrap in realmode */
return 0;
pop %ecx
movl $boot_params, %esi
orb $X86_BP_FLAGS_LBA64VALID, 4(%esi)
- lcall $SECONDARY_LOAD_ADDRESS >> 4, $0
+ lcall $SECONDARY_LOAD_ADDRESS/16, $0
boot_fail:
push %ax /* error string from boot1 */
# $NetBSD: Makefile,v 1.1 2010/09/11 13:06:37 tsutsui Exp $
FS=ext2fs
-CLEANFILES= lib
-CPPFLAGS+= -D_MINIX
-CFLAGS+= -Os
.include <../Makefile.bootxx>
PROG=bootxx_minixfs3
FS=minixfs3
-CLEANFILES= lib
MINIX3_FIRST_SUBP_OFFSET=32
NOMAN= # defined
.include <bsd.own.mk>
+.if defined(__MINIX)
+AFLAGS+= -Wa,--divide
+.endif
+
STRIPFLAG= # nothing
LIBCRT0= # nothing
DPSRCS+= machine x86
-AFLAGS+= -Wa,--divide
-
CLEANFILES+= ${PROG}.tmp
${PROG}: ${OBJS}
-/* $NetBSD: biosdisk.c,v 1.39 2011/09/21 08:57:12 gsutre Exp $ */
+/* $NetBSD: biosdisk.c,v 1.42 2012/07/03 15:24:37 tsutsui Exp $ */
/*
* Copyright (c) 1996, 1998
gptsector[0] = GPT_HDR_BLKNO;
if (set_geometry(&d->ll, &ed) == 0 && d->ll.flags & BIOSDISK_INT13EXT) {
gptsector[1] = ed.totsec - 1;
- d->ll.secsize = ed.sbytes;
+ /* Sanity check values returned from BIOS */
+ if (ed.sbytes >= 512 && (ed.sbytes & (ed.sbytes - 1)) == 0)
+ d->ll.secsize = ed.sbytes;
} else {
#ifdef DISK_DEBUG
printf("Unable to determine extended disk geometry - "
if (readsects(&d->ll, sector, 1, d->buf, 0)) {
#ifdef DISK_DEBUG
- printf("Error reading MFS sector %d\n", sector);
+ printf("Error reading MFS sector %"PRId64"\n", sector);
#endif
return EIO;
}
struct disklabel dflt_lbl;
struct mbr_partition mbr[MBR_PART_COUNT];
struct partition *p;
- int sector, i;
+ uint32_t sector;
+ int i;
int error;
int typ;
- int ext_base, this_ext, next_ext;
+ uint32_t ext_base, this_ext, next_ext;
#ifdef COMPAT_386BSD_MBRPART
int sector_386bsd = -1;
#endif
next_ext = 0;
if (readsects(&d->ll, this_ext, 1, d->buf, 0)) {
#ifdef DISK_DEBUG
- printf("error reading MBR sector %d\n", this_ext);
+ printf("error reading MBR sector %u\n", this_ext);
#endif
return EIO;
}
continue;
sector = this_ext + mbr[i].mbrp_start;
#ifdef DISK_DEBUG
- printf("ptn type %d in sector %d\n", typ, sector);
+ printf("ptn type %d in sector %u\n", typ, sector);
#endif
if (typ == MBR_PTYPE_MINIX_14B) {
if (!read_minix_subp(d, &dflt_lbl,
call _C_LABEL(prot_to_real) # enter real mode
.code16
+#if defined(__minix)
cmp $0x08, %al # backspace?
jne print_char
jmp do_int
print_char:
+#endif /* defined(__minix) */
movw $1,%bx
- movb $0x0e,%ah # print character
+ movb $0x0e,%ah
movb %al, %cl
+#if defined(__minix)
do_int:
+#endif /* defined(__minix) */
int $0x10
calll _C_LABEL(real_to_prot) # back to protected mode
movb $0x0,%ah
int $0x16
- movw %ax,%bx
+ movb %al,%bl
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
- movw %bx, 28(%esp)
+ movb %bl, 28(%esp)
popa
ret
-/* $NetBSD: exec.c,v 1.49 2011/11/28 07:56:54 tls Exp $ */
+/* $NetBSD: exec.c,v 1.50 2012/05/21 21:34:16 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
close(fd);
- /* Now we know the root fs type, load modules for it. */
+ /* If the root fs type is unusual, load its module. */
if (fsmod != NULL)
module_add(fsmod);
+#if defined(__minix)
if (fsmod !=NULL && fsmod2 != NULL && strcmp(fsmod, fsmod2) != 0)
module_add(fsmod2);
+#endif /* defined(__minix) */
/*
* Gather some information for the kernel. Do this after the
void (*c_fn)(char *);
};
void bootmenu(void);
-void prompt(int);
void docommand(char *);
+#if defined(__minix)
void editline(char *, size_t, char *);
+void prompt(int);
+#endif
/* in "user code": */
void command_help(char *);
__compactcall void conputc(int);
void conclr(void);
+#if defined(__minix)
int getchar_ex(void);
+#endif
int getextmem2(int *);
__compactcall int getextmemps2(void *);
for (;;) {
char *c = input;
+ input[0] = '\0';
printf("> ");
editline(input, sizeof(input), NULL);
--- /dev/null
+/* $NetBSD: getopt.c,v 1.5 2009/03/14 15:36:08 dsl Exp $ */
+
+/*
+ * Copyright (c) 1987, 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.
+ */
+
+/* from: netbsd:lib/libc/stdlib/getopt.c */
+
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/stand.h>
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt(int nargc, char * const *nargv, const char *ostr)
+{
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return (-1);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int)'-')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ printf("illegal option -- %c\n", optopt);
+ return (BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ printf("option requires an argument -- %c\n",
+ optopt);
+ return (BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
+}
--- /dev/null
+/* $NetBSD: nfs.c,v 1.19 2011/12/25 06:09:09 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 1993 John Brezak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce 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 <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#ifdef _STANDALONE
+#include <lib/libkern/libkern.h>
+#else
+#include <string.h>
+#endif
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include "rpcv2.h"
+#include "nfsv2.h"
+
+#include <lib/libsa/stand.h>
+#include "net.h"
+#include "netif.h"
+#include "nfs.h"
+#include "rpc.h"
+
+/* Define our own NFS attributes. */
+struct nfsv2_fattrs {
+ n_long fa_type;
+ n_long fa_mode;
+ n_long fa_nlink;
+ n_long fa_uid;
+ n_long fa_gid;
+ n_long fa_size;
+ n_long fa_blocksize;
+ n_long fa_rdev;
+ n_long fa_blocks;
+ n_long fa_fsid;
+ n_long fa_fileid;
+ struct nfsv2_time fa_atime;
+ struct nfsv2_time fa_mtime;
+ struct nfsv2_time fa_ctime;
+};
+
+
+struct nfs_read_args {
+ u_char fh[NFS_FHSIZE];
+ n_long off;
+ n_long len;
+ n_long xxx; /* XXX what's this for? */
+};
+
+/* Data part of nfs rpc reply (also the largest thing we receive) */
+#define NFSREAD_SIZE 1024
+struct nfs_read_repl {
+ n_long errno;
+ struct nfsv2_fattrs fa;
+ n_long count;
+ u_char data[NFSREAD_SIZE];
+};
+
+#ifndef NFS_NOSYMLINK
+struct nfs_readlnk_repl {
+ n_long errno;
+ n_long len;
+ char path[NFS_MAXPATHLEN];
+};
+#endif
+
+struct nfs_iodesc {
+ struct iodesc *iodesc;
+ off_t off;
+ u_char fh[NFS_FHSIZE];
+ struct nfsv2_fattrs fa; /* all in network order */
+};
+
+int nfs_getrootfh(struct iodesc *, char *, u_char *);
+int nfs_lookupfh(struct nfs_iodesc *, const char *, int,
+ struct nfs_iodesc *);
+#ifndef NFS_NOSYMLINK
+int nfs_readlink(struct nfs_iodesc *, char *);
+#endif
+ssize_t nfs_readdata(struct nfs_iodesc *, off_t, void *, size_t);
+
+/*
+ * Fetch the root file handle (call mount daemon)
+ * Return zero or error number.
+ */
+int
+nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
+{
+ size_t len;
+ struct args {
+ n_long len;
+ char path[FNAME_SIZE];
+ } *args;
+ struct repl {
+ n_long errno;
+ u_char fh[NFS_FHSIZE];
+ } *repl;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct args d;
+ } sdata;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct repl d;
+ } rdata;
+ ssize_t cc;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_getrootfh: %s\n", path);
+#endif
+
+ args = &sdata.d;
+ repl = &rdata.d;
+
+ memset(args, 0, sizeof(*args));
+ len = strlen(path);
+ if (len > sizeof(args->path))
+ len = sizeof(args->path);
+ args->len = htonl(len);
+ memcpy(args->path, path, len);
+ len = 4 + roundup(len, 4);
+
+ cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT,
+ args, len, repl, sizeof(*repl));
+ if (cc == -1) {
+ /* errno was set by rpc_call */
+ return (errno);
+ }
+ if (cc < 4)
+ return (EBADRPC);
+ if (repl->errno)
+ return (ntohl(repl->errno));
+ memcpy(fhp, repl->fh, sizeof(repl->fh));
+ return (0);
+}
+
+/*
+ * Lookup a file. Store handle and attributes.
+ * Return zero or error number.
+ */
+int
+nfs_lookupfh(struct nfs_iodesc *d, const char *name, int len, struct nfs_iodesc *newfd)
+{
+ int rlen;
+ struct args {
+ u_char fh[NFS_FHSIZE];
+ n_long len;
+ char name[FNAME_SIZE];
+ } *args;
+ struct repl {
+ n_long errno;
+ u_char fh[NFS_FHSIZE];
+ struct nfsv2_fattrs fa;
+ } *repl;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct args d;
+ } sdata;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct repl d;
+ } rdata;
+ ssize_t cc;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("lookupfh: called\n");
+#endif
+
+ args = &sdata.d;
+ repl = &rdata.d;
+
+ memset(args, 0, sizeof(*args));
+ memcpy(args->fh, d->fh, sizeof(args->fh));
+ if ((size_t)len > sizeof(args->name))
+ len = sizeof(args->name);
+ memcpy(args->name, name, len);
+ args->len = htonl(len);
+ len = 4 + roundup(len, 4);
+ len += NFS_FHSIZE;
+
+ rlen = sizeof(*repl);
+
+ cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP,
+ args, len, repl, rlen);
+ if (cc == -1)
+ return (errno); /* XXX - from rpc_call */
+ if (cc < 4)
+ return (EIO);
+ if (repl->errno) {
+ /* saerrno.h now matches NFS error numbers. */
+ return (ntohl(repl->errno));
+ }
+ memcpy(&newfd->fh, repl->fh, sizeof(newfd->fh));
+ memcpy(&newfd->fa, &repl->fa, sizeof(newfd->fa));
+ return (0);
+}
+
+#ifndef NFS_NOSYMLINK
+/*
+ * Get the destination of a symbolic link.
+ */
+int
+nfs_readlink(struct nfs_iodesc *d, char *buf)
+{
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ u_char fh[NFS_FHSIZE];
+ } sdata;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct nfs_readlnk_repl d;
+ } rdata;
+ ssize_t cc;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("readlink: called\n");
+#endif
+
+ memcpy(sdata.fh, d->fh, NFS_FHSIZE);
+ cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK,
+ sdata.fh, NFS_FHSIZE,
+ &rdata.d, sizeof(rdata.d));
+ if (cc == -1)
+ return (errno);
+
+ if (cc < 4)
+ return (EIO);
+
+ if (rdata.d.errno)
+ return (ntohl(rdata.d.errno));
+
+ rdata.d.len = ntohl(rdata.d.len);
+ if (rdata.d.len > NFS_MAXPATHLEN)
+ return (ENAMETOOLONG);
+
+ memcpy(buf, rdata.d.path, rdata.d.len);
+ buf[rdata.d.len] = 0;
+ return (0);
+}
+#endif
+
+/*
+ * Read data from a file.
+ * Return transfer count or -1 (and set errno)
+ */
+ssize_t
+nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
+{
+ struct nfs_read_args *args;
+ struct nfs_read_repl *repl;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct nfs_read_args d;
+ } sdata;
+ struct {
+ n_long h[RPC_HEADER_WORDS];
+ struct nfs_read_repl d;
+ } rdata;
+ ssize_t cc;
+ long x;
+ int hlen, rlen;
+
+ args = &sdata.d;
+ repl = &rdata.d;
+
+ memcpy(args->fh, d->fh, NFS_FHSIZE);
+ args->off = htonl((n_long)off);
+ if (len > NFSREAD_SIZE)
+ len = NFSREAD_SIZE;
+ args->len = htonl((n_long)len);
+ args->xxx = htonl((n_long)0);
+ hlen = sizeof(*repl) - NFSREAD_SIZE;
+
+ cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ,
+ args, sizeof(*args),
+ repl, sizeof(*repl));
+ if (cc == -1) {
+ /* errno was already set by rpc_call */
+ return (-1);
+ }
+ if (cc < hlen) {
+ errno = EBADRPC;
+ return (-1);
+ }
+ if (repl->errno) {
+ errno = ntohl(repl->errno);
+ return (-1);
+ }
+ rlen = cc - hlen;
+ x = ntohl(repl->count);
+ if (rlen < x) {
+ printf("nfsread: short packet, %d < %ld\n", rlen, x);
+ errno = EBADRPC;
+ return (-1);
+ }
+ memcpy(addr, repl->data, x);
+ return (x);
+}
+
+/*
+ * Open a file.
+ * return zero or error number
+ */
+__compactcall int
+nfs_open(const char *path, struct open_file *f)
+{
+ static struct nfs_iodesc nfs_root_node;
+ struct iodesc *desc;
+ struct nfs_iodesc *currfd;
+ const char *cp;
+#ifndef NFS_NOSYMLINK
+ struct nfs_iodesc *newfd;
+ struct nfsv2_fattrs *fa;
+ const char *ncp;
+ int c;
+ char namebuf[NFS_MAXPATHLEN + 1];
+ char linkbuf[NFS_MAXPATHLEN + 1];
+ int nlinks = 0;
+#endif
+ int error;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_open: %s\n", path);
+#endif
+ if (!rootpath[0]) {
+ printf("no rootpath, no nfs\n");
+ return (ENXIO);
+ }
+
+ if (!(desc = socktodesc(*(int *)(f->f_devdata))))
+ return (EINVAL);
+
+ /* Bind to a reserved port. */
+ desc->myport = htons(--rpc_port);
+ desc->destip = rootip;
+ if ((error = nfs_getrootfh(desc, rootpath, nfs_root_node.fh)))
+ return (error);
+ nfs_root_node.iodesc = desc;
+
+#ifndef NFS_NOSYMLINK
+ /* Fake up attributes for the root dir. */
+ fa = &nfs_root_node.fa;
+ fa->fa_type = htonl(NFDIR);
+ fa->fa_mode = htonl(0755);
+ fa->fa_nlink = htonl(2);
+
+ currfd = &nfs_root_node;
+ newfd = 0;
+
+ cp = path;
+ while (*cp) {
+ /*
+ * Remove extra separators
+ */
+ while (*cp == '/')
+ cp++;
+
+ if (*cp == '\0')
+ break;
+ /*
+ * Check that current node is a directory.
+ */
+ if (currfd->fa.fa_type != htonl(NFDIR)) {
+ error = ENOTDIR;
+ goto out;
+ }
+
+ /* allocate file system specific data structure */
+ newfd = alloc(sizeof(*newfd));
+ newfd->iodesc = currfd->iodesc;
+ newfd->off = 0;
+
+ /*
+ * Get next component of path name.
+ */
+ {
+ int len = 0;
+
+ ncp = cp;
+ while ((c = *cp) != '\0' && c != '/') {
+ if (++len > NFS_MAXNAMLEN) {
+ error = ENOENT;
+ goto out;
+ }
+ cp++;
+ }
+ }
+
+ /* lookup a file handle */
+ error = nfs_lookupfh(currfd, ncp, cp - ncp, newfd);
+ if (error)
+ goto out;
+
+ /*
+ * Check for symbolic link
+ */
+ if (newfd->fa.fa_type == htonl(NFLNK)) {
+ int link_len, len;
+
+ error = nfs_readlink(newfd, linkbuf);
+ if (error)
+ goto out;
+
+ link_len = strlen(linkbuf);
+ len = strlen(cp);
+
+ if (link_len + len > MAXPATHLEN
+ || ++nlinks > MAXSYMLINKS) {
+ error = ENOENT;
+ goto out;
+ }
+
+ memcpy(&namebuf[link_len], cp, len + 1);
+ memcpy(namebuf, linkbuf, link_len);
+
+ /*
+ * If absolute pathname, restart at root.
+ * If relative pathname, restart at parent directory.
+ */
+ cp = namebuf;
+ if (*cp == '/') {
+ if (currfd != &nfs_root_node)
+ dealloc(currfd, sizeof(*currfd));
+ currfd = &nfs_root_node;
+ }
+
+ dealloc(newfd, sizeof(*newfd));
+ newfd = 0;
+
+ continue;
+ }
+
+ if (currfd != &nfs_root_node)
+ dealloc(currfd, sizeof(*currfd));
+ currfd = newfd;
+ newfd = 0;
+ }
+
+ error = 0;
+
+out:
+ if (newfd)
+ dealloc(newfd, sizeof(*newfd));
+#else
+ /* allocate file system specific data structure */
+ currfd = alloc(sizeof(*currfd));
+ currfd->iodesc = desc;
+ currfd->off = 0;
+
+ cp = path;
+ /*
+ * Remove extra separators
+ */
+ while (*cp == '/')
+ cp++;
+
+ /* XXX: Check for empty path here? */
+
+ error = nfs_lookupfh(&nfs_root_node, cp, strlen(cp), currfd);
+#endif
+ if (!error) {
+ f->f_fsdata = (void *)currfd;
+ fsmod = "nfs";
+ return (0);
+ }
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_open: %s lookupfh failed: %s\n",
+ path, strerror(error));
+#endif
+#ifndef NFS_NOSYMLINK
+ if (currfd != &nfs_root_node)
+#endif
+ dealloc(currfd, sizeof(*currfd));
+
+ return (error);
+}
+
+__compactcall int
+nfs_close(struct open_file *f)
+{
+ struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_close: fp=0x%lx\n", (u_long)fp);
+#endif
+
+ if (fp)
+ dealloc(fp, sizeof(struct nfs_iodesc));
+ f->f_fsdata = (void *)0;
+
+ return (0);
+}
+
+/*
+ * read a portion of a file
+ */
+__compactcall int
+nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
+ /* resid: out */
+{
+ struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
+ ssize_t cc;
+ char *addr = buf;
+
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_read: size=%lu off=%d\n", (u_long)size,
+ (int)fp->off);
+#endif
+ while ((int)size > 0) {
+#if !defined(LIBSA_NO_TWIDDLE)
+ twiddle();
+#endif
+ cc = nfs_readdata(fp, fp->off, (void *)addr, size);
+ /* XXX maybe should retry on certain errors */
+ if (cc == -1) {
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_read: read: %s", strerror(errno));
+#endif
+ return (errno); /* XXX - from nfs_readdata */
+ }
+ if (cc == 0) {
+#ifdef NFS_DEBUG
+ if (debug)
+ printf("nfs_read: hit EOF unexpectantly");
+#endif
+ goto ret;
+ }
+ fp->off += cc;
+ addr += cc;
+ size -= cc;
+ }
+ret:
+ if (resid)
+ *resid = size;
+
+ return (0);
+}
+
+/*
+ * Not implemented.
+ */
+__compactcall int
+nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid)
+ /* resid: out */
+{
+
+ return (EROFS);
+}
+
+__compactcall off_t
+nfs_seek(struct open_file *f, off_t offset, int where)
+{
+ struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata;
+ n_long size = ntohl(d->fa.fa_size);
+
+ switch (where) {
+ case SEEK_SET:
+ d->off = offset;
+ break;
+ case SEEK_CUR:
+ d->off += offset;
+ break;
+ case SEEK_END:
+ d->off = size - offset;
+ break;
+ default:
+ return (-1);
+ }
+
+ return (d->off);
+}
+
+/* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */
+const int nfs_stat_types[8] = {
+ 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 };
+
+__compactcall int
+nfs_stat(struct open_file *f, struct stat *sb)
+{
+ struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
+ n_long ftype, mode;
+
+ ftype = ntohl(fp->fa.fa_type);
+ mode = ntohl(fp->fa.fa_mode);
+ mode |= nfs_stat_types[ftype & 7];
+
+ sb->st_mode = mode;
+ sb->st_nlink = ntohl(fp->fa.fa_nlink);
+ sb->st_uid = ntohl(fp->fa.fa_uid);
+ sb->st_gid = ntohl(fp->fa.fa_gid);
+ sb->st_size = ntohl(fp->fa.fa_size);
+
+ return (0);
+}
+
+#if defined(LIBSA_ENABLE_LS_OP)
+__compactcall void
+nfs_ls(struct open_file *f, const char *pattern)
+{
+ printf("Currently ls command is unsupported by nfs\n");
+ return;
+}
+#endif
.PATH: ${.CURDIR}/..
LDFLAGS+= -nostdlib -Wl,-e,start
-# MINIX LSC DO we need to remove the includes??
-CPPFLAGS+= -I. -I${.CURDIR}/../../lib #-I${S}
+CPPFLAGS+= -I. -I${.CURDIR}/../../lib -I${S}
+.if defined(__MINIX)
CPPFLAGS+= -DLOADADDR=${LOADADDR}
+AFLAGS+= -Wa,--divide
+.endif
.if ${MACHINE_ARCH} == "x86_64"
LDFLAGS+= -Wl,-m,elf_i386
AFLAGS+= -m32
.endif
-AFLAGS+= "-Wa,--divide"
+BUILDSYMLINKS+= $S/arch/i386/include machine \
+ $S/arch/x86/include x86
-# NetBSD can be compiled from a foreign host, MINIX do not. So commented out.
-# Make sys/ a local thing for benefit of cross-compilers
-#S= ${.CURDIR}/../../../../..
-#CPPFLAGS+= -I${S}
-# And same for machine/; need a bit more work because of symlink
-#BUILDSYMLINKS+= $S/arch/i386/include machine \
-# $S/arch/x86/include x86
-#DPSRCS+= machine x86
+DPSRCS+= machine x86
CLEANFILES+= ${PROG}.tmp
--- /dev/null
+/* $NetBSD: syslog.h,v 1.1 2012/10/10 22:51:12 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.
+ */
+#ifndef _COMPAT_SYS_SYSLOG_H_
+#define _COMPAT_SYS_SYSLOG_H_
+
+struct syslog_data60 {
+ int log_file;
+ int connected;
+ int opened;
+ int log_stat;
+ const char *log_tag;
+ int log_fac;
+ int log_mask;
+};
+
+__BEGIN_DECLS
+#ifdef __LIBC12_SOURCE__
+void closelog_r(struct syslog_data60 *);
+void openlog_r(const char *, int, int, struct syslog_data60 *);
+int setlogmask_r(int, struct syslog_data60 *);
+void syslog_r(int, struct syslog_data60 *, const char *, ...)
+ __printflike(3, 4);
+void vsyslog_r(int, struct syslog_data60 *, const char *, __va_list)
+ __printflike(3, 0);
+void syslogp_r(int, struct syslog_data60 *, const char *, const char *,
+ const char *, ...) __printflike(5, 6);
+void vsyslogp_r(int, struct syslog_data60 *, const char *, const char *,
+ const char *, __va_list) __printflike(5, 0);
+
+struct syslog_data;
+void __closelog_r60(struct syslog_data *);
+void __openlog_r60(const char *, int, int, struct syslog_data *);
+int __setlogmask_r60(int, struct syslog_data *);
+void __syslog_r60(int, struct syslog_data *, const char *, ...)
+ __printflike(3, 4);
+void __vsyslog_r60(int, struct syslog_data *, const char *, __va_list)
+ __printflike(3, 0);
+void __syslogp_r60(int, struct syslog_data *, const char *, const char *,
+ const char *, ...) __printflike(5, 6);
+void __vsyslogp_r60(int, struct syslog_data *, const char *, const char *,
+ const char *, __va_list) __printflike(5, 0);
+#endif
+__END_DECLS
+
+#endif /* !_COMPAT_SYS_SYSLOG_H_ */
.include <bsd.own.mk>
-.ifndef __MINIX
.PATH.c: ${SADIR} ${.PARSEDIR}/../../../common/lib/libc/string
-.else
+.ifdef __MINIX
.PATH.c: ${SADIR} ${.PARSEDIR}/../../../common/lib/libc/md
.endif
SRCS+= dosfs.c
SRCS+= ext2fs.c
SRCS+= minixfs3.c
+SRCS+= fnmatch.c
# for historic compatibility ufs == ffsv1
SRCS+= ufs.c
-/* $NetBSD: cd9660.c,v 1.28 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: cd9660.c,v 1.29 2012/07/23 00:49:20 mhitch Exp $ */
/*
* Copyright (C) 1996 Wolfgang Solfrank.
break;
bno = fp->off / ISO_DEFAULT_BLOCK_SIZE + fp->bno;
if (fp->off & (ISO_DEFAULT_BLOCK_SIZE - 1)
+ || (fp->off + ISO_DEFAULT_BLOCK_SIZE) > fp->size
|| size < ISO_DEFAULT_BLOCK_SIZE)
dp = buf;
else
if (nread > off + size)
nread = off + size;
nread -= off;
+ if (nread > fp->size - fp->off)
+ nread = fp->size - fp->off;
memcpy(start, buf + off, nread);
start = (char *)start + nread;
fp->off += nread;
#ifndef ETHER_CRC_POLY_LE
#define ETHER_CRC_POLY_LE 0xedb88320
#endif
-#ifndef __minix
uint32_t
crc32(uint32_t crc, const uint8_t *const buf, size_t len)
-#else
-uLong crc32(uLong crc, const Bytef *buf, uInt len)
-#endif
{
uint32_t c, carry;
size_t i, j;
-/* $NetBSD: ext2fs.c,v 1.11 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ext2fs.c,v 1.13 2012/05/21 21:34:16 dsl Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
"LNK"
};
-static int
-fn_match(const char *fname, const char *pattern)
-{
- char fc, pc;
-
- do {
- fc = *fname++;
- pc = *pattern++;
- if (!fc && !pc)
- return 1;
- if (pc == '?' && fc)
- pc = fc;
- } while (fc == pc);
-
- if (pc != '*')
- return 0;
- /*
- * Too hard (and unnecessary really) too check for "*?name" etc....
- * "**" will look for a '*' and "*?" a '?'
- */
- pc = *pattern++;
- if (!pc)
- return 1;
- while ((fname = strchr(fname, pc)))
- if (fn_match(++fname, pattern))
- return 1;
- return 0;
-}
#endif /* LIBSA_ENABLE_LS_OP */
static int read_inode(ino32_t, struct open_file *);
printf("bad dir entry\n");
goto out;
}
- if (pattern && !fn_match(dp->e2d_name, pattern))
+ if (pattern && !fnmatch(dp->e2d_name, pattern))
continue;
n = alloc(sizeof *n + strlen(dp->e2d_name));
if (!n) {
-/* $NetBSD: ffsv1.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ffsv1.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
#define LIBSA_FFSv1
-/* $NetBSD: ffsv2.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ffsv2.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
#define LIBSA_FFSv2
--- /dev/null
+/* $NetBSD: fnmatch.c,v 1.1 2012/01/16 18:44:13 christos Exp $ */
+
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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, 1991 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Author: David Golub
+ *
+ * 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 "stand.h"
+#include <lib/libkern/libkern.h>
+
+#if defined(LIBSA_ENABLE_LS_OP)
+int
+fnmatch(const char *fname, const char *pattern)
+{
+ char fc, pc;
+
+ do {
+ fc = *fname++;
+ pc = *pattern++;
+ if (!fc && !pc)
+ return 1;
+ if (pc == '?' && fc)
+ pc = fc;
+ } while (fc == pc);
+
+ if (pc != '*')
+ return 0;
+ /*
+ * Too hard (and unnecessary really) too check for "*?name" etc....
+ * "**" will look for a '*' and "*?" a '?'
+ */
+ pc = *pattern++;
+ if (!pc)
+ return 1;
+ while ((fname = strchr(fname, pc)))
+ if (fnmatch(++fname, pattern))
+ return 1;
+ return 0;
+}
+#endif /* LIBSA_ENABLE_LS_OP */
-/* $NetBSD: globals.c,v 1.8 2008/11/19 12:36:41 ad Exp $ */
+/* $NetBSD: globals.c,v 1.9 2012/05/21 21:34:16 dsl Exp $ */
/*
* globals.c:
char rootpath[FNAME_SIZE]; /* root mount path */
char bootfile[FNAME_SIZE]; /* bootp says to boot this */
char hostname[FNAME_SIZE]; /* our hostname */
-#ifdef __minix
-char *fsmod = NULL;
-#else
-char *fsmod = "ffs"; /* guessed file system module name */
-#endif
+char *fsmod = NULL; /* file system module name to load */
char *fsmod2; /* a requisite module */
struct in_addr myip; /* my ip address */
struct in_addr rootip; /* root ip address */
-/* $NetBSD: lfsv1.c,v 1.4 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: lfsv1.c,v 1.5 2012/05/21 21:34:16 dsl Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 1
-/* $NetBSD: lfsv2.c,v 1.4 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: lfsv2.c,v 1.5 2012/05/21 21:34:16 dsl Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 2
printf("no ls support for this file system\n");
out:
+ /* LSC: MINIX Modification for correct glob support, beware! */
if (p != NULL)
dealloc(p, size + 1);
close(fd);
-/* $NetBSD$ */
+/* $NetBSD: minixfs3.c,v 1.1 2012/01/16 18:44:13 christos Exp $ */
/*-
* Copyright (c) 2012
char e_name[1];
};
-static int
-fn_match(const char *fname, const char *pattern)
-{
- char fc, pc;
-
- do {
- fc = *fname++;
- pc = *pattern++;
- if (!fc && !pc)
- return 1;
- if (pc == '?' && fc)
- pc = fc;
- } while (fc == pc);
-
- if (pc != '*')
- return 0;
- /*
- * Too hard (and unnecessary really) too check for "*?name" etc....
- * "**" will look for a '*' and "*?" a '?'
- */
- pc = *pattern++;
- if (!pc)
- return 1;
- while ((fname = strchr(fname, pc)))
- if (fn_match(++fname, pattern))
- return 1;
- return 0;
-}
#endif /* LIBSA_ENABLE_LS_OP */
static int read_inode(ino32_t, struct open_file *);
static int block_map(struct open_file *, block_t, block_t *);
-static int buf_read_file(struct open_file *, char **, size_t *);
+static int buf_read_file(struct open_file *, void *, size_t *);
static int search_directory(const char *, int, struct open_file *, ino32_t *);
static int read_sblock(struct open_file *, struct mfs_sblock *);
* Return the location in the buffer and the amount in the buffer.
*/
static int
-buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
+buf_read_file(struct open_file *f, void *v, size_t *size_p)
{
+ char **buf_p = v;
struct file *fp = (struct file *)f->f_fsdata;
struct mfs_sblock *fs = fp->f_fs;
long off;
fp->f_seekp = 0;
while (fp->f_seekp < (off_t)fp->f_di.mdi_size) {
- rc = buf_read_file(f, (char**)&dbuf, &buf_size);
+ rc = buf_read_file(f, (void *)&dbuf, &buf_size);
if (rc)
return rc;
if (buf_size == 0)
fp->f_seekp = 0;
while (fp->f_seekp < (off_t)fp->f_di.mdi_size) {
- int rc = buf_read_file(f, (char**)&dbuf, &buf_size);
+ int rc = buf_read_file(f, &dbuf, &buf_size);
if (rc)
goto out;
if (fs2h32(dp->mfsd_ino) == 0)
continue;
- if (pattern && !fn_match(dp->mfsd_name, pattern))
+ if (pattern && !fnmatch(dp->mfsd_name, pattern))
continue;
/* Compute the length of the name,
-/* $NetBSD$ */
+/* $NetBSD: minixfs3.h,v 1.1 2012/01/16 18:44:13 christos Exp $ */
/*-
* Copyright (c) 2012
-/* $NetBSD: stand.h,v 1.74 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: stand.h,v 1.76 2012/05/21 21:34:16 dsl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
extern const char hexdigits[];
+int fnmatch(const char *, const char *);
+
/* XXX: These should be removed eventually. */
void bcopy(const void *, void *, size_t);
void bzero(void *, size_t);
-/* $NetBSD: ufs.c,v 1.56 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ufs.c,v 1.58 2012/05/21 21:34:16 dsl Exp $ */
/*-
* Copyright (c) 1993
0,
"WHT"
};
-
-static int
-fn_match(const char *fname, const char *pattern)
-{
- char fc, pc;
-
- do {
- fc = *fname++;
- pc = *pattern++;
- if (!fc && !pc)
- return 1;
- if (pc == '?' && fc)
- pc = fc;
- } while (fc == pc);
-
- if (pc != '*')
- return 0;
- /*
- * Too hard (and unnecessary really) too check for "*?name" etc....
- * "**" will look for a '*' and "*?" a '?'
- */
- pc = *pattern++;
- if (!pc)
- return 1;
- while ((fname = strchr(fname, pc)))
- if (fn_match(++fname, pattern))
- return 1;
- return 0;
-}
#endif /* LIBSA_ENABLE_LS_OP */
#ifdef LIBSA_LFS
printf("bad dir entry\n");
goto out;
}
- if (pattern && !fn_match(dp->d_name, pattern))
+ if (pattern && !fnmatch(dp->d_name, pattern))
continue;
n = alloc(sizeof *n + strlen(dp->d_name));
if (!n) {
statvfs.h sysctl.h stdarg.h stdint.h \
syslimits.h syslog.h \
termios.h time.h times.h \
- tree.h ttycom.h \
+ tls.h tree.h ttycom.h \
ttydefaults.h types.h \
ucontext.h ucred.h uio.h un.h unistd.h utsname.h uuid.h \
\
-/* $NetBSD: ansi.h,v 1.13 2010/03/27 22:14:10 tnozaki Exp $ */
+/* $NetBSD: ansi.h,v 1.14 2011/07/17 20:54:54 joerg Exp $ */
/*-
* Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
#include <machine/ansi.h>
typedef char * __caddr_t; /* core address */
-typedef __uint32_t __gid_t; /* group id */
+typedef __uint32_t __gid_t; /* group id */
typedef __uint32_t __in_addr_t; /* IP(v4) address */
typedef __uint16_t __in_port_t; /* "Internet" port number */
-typedef unsigned short __mode_t; /* file permissions */
-typedef long __off_t; /* file offset */
-typedef int __pid_t; /* process id */
+typedef __uint16_t __mode_t; /* file permissions */
+typedef __int32_t __off_t; /* file offset */
+typedef __int32_t __pid_t; /* process id */
typedef __uint8_t __sa_family_t; /* socket address family */
typedef __int32_t __socklen_t; /* socket-related datum length */
-typedef __uint32_t __uid_t; /* user id */
-typedef unsigned long __fsblkcnt_t; /* fs block count (statvfs) */
-typedef unsigned long __fsfilcnt_t; /* fs file count */
+typedef __uint32_t __uid_t; /* user id */
+typedef __uint32_t __fsblkcnt_t; /* fs block count (statvfs) */
+typedef __uint32_t __fsfilcnt_t; /* fs file count */
struct __tag_wctrans_t;
typedef struct __tag_wctrans_t *__wctrans_t;
#define _BSD_WCTYPE_T_ __wctype_t /* wctype_t */
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
+#ifdef __lint__
+typedef char *__va_list;
+#else
+typedef __builtin_va_list __va_list;
+#endif
+
#endif /* !_SYS_ANSI_H_ */
-/* $NetBSD: bitops.h,v 1.7 2010/03/21 14:28:15 christos Exp $ */
+/* $NetBSD: bitops.h,v 1.9 2011/07/30 16:35:58 christos Exp $ */
/*-
* Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
_ilog2_helper(_n, 2) \
_ilog2_helper(_n, 1) \
_ilog2_helper(_n, 0) \
- -1) : ((sizeof(_n) >= 4 ? fls64(_n) : fls32(_n)) - 1) \
+ -1) : ((sizeof(_n) > 4 ? fls64(_n) : fls32(_n)) - 1) \
)
static __inline void
int _l;
_l = fls32(_div - 1);
- _mt = 0x100000000ULL * ((1ULL << _l) - _div);
+ _mt = (uint64_t)(0x100000000ULL * ((1ULL << _l) - _div));
*_m = (uint32_t)(_mt / _div + 1);
*_s1 = (_l > 1) ? 1 : _l;
*_s2 = (_l == 0) ? 0 : _l - 1;
/* ARGSUSED */
static __inline uint32_t
-fast_divide32(uint32_t _v, uint32_t _div, uint32_t _m, uint8_t _s1,
+fast_divide32(uint32_t _v, uint32_t _div __unused, uint32_t _m, uint8_t _s1,
uint8_t _s2)
{
uint32_t _t;
-/* $NetBSD: cdefs.h,v 1.81 2010/12/25 22:30:52 joerg Exp $ */
+/* $NetBSD: cdefs.h,v 1.100 2012/08/24 05:47:51 dholland Exp $ */
/*
* Copyright (c) 1991, 1993
#include <sys/cdefs_aout.h>
#endif
+#ifdef __GNUC__
+#define __strict_weak_alias(alias,sym) \
+ __unused static __typeof__(alias) *__weak_alias_##alias = &sym; \
+ __weak_alias(alias,sym)
+#else
+#define __strict_weak_alias(alias,sym) __weak_alias(alias,sym)
+#endif
+
+/*
+ * Optional marker for size-optimised MD calling convention.
+ */
+#ifndef __compactcall
+#define __compactcall
+#endif
+
/*
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
#define __aconst
#endif
+/*
+ * Compile Time Assertion.
+ */
+#ifdef __COUNTER__
+#define __CTASSERT(x) __CTASSERT0(x, __ctassert, __COUNTER__)
+#else
+#define __CTASSERT(x) __CTASSERT0(x, __ctassert, __LINE__)
+#endif
+#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z)
+#define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1]
+
/*
* The following macro is used to remove const cast-away warnings
* from gcc -Wcast-qual; it should be used with caution because it
#define __noinline /* nothing */
#endif
+#if __GNUC_PREREQ__(3, 0)
+#define __always_inline __attribute__((__always_inline__))
+#else
+#define __always_inline /* nothing */
+#endif
+
+#if __GNUC_PREREQ__(4, 1)
+#define __returns_twice __attribute__((__returns_twice__))
+#else
+#define __returns_twice /* nothing */
+#endif
+
+#if __GNUC_PREREQ__(4, 5)
+#define __noclone __attribute__((__noclone__))
+#else
+#define __noclone /* nothing */
+#endif
+
#if __GNUC_PREREQ__(2, 7)
#define __unused __attribute__((__unused__))
#else
#define __used __unused
#endif
+#if __GNUC_PREREQ__(3, 1)
+#define __noprofile __attribute__((__no_instrument_function__))
+#else
+#define __noprofile /* nothing */
+#endif
+
#if defined(__cplusplus)
#define __BEGIN_EXTERN_C extern "C" {
#define __END_EXTERN_C }
#define __packed _Pragma("packed 1")
#define __aligned(x) _Pragma("aligned " __STRING(x))
#define __section(x) _Pragma("section " ## x)
+#elif defined(_MSC_VER)
+#define __packed /* ignore */
#else
#define __packed error: no __packed for this compiler
#define __aligned(x) error: no __aligned for this compiler
#define __restrict /* delete __restrict when not supported */
#elif __STDC_VERSION__ >= 199901L
#define __restrict restrict
-#elif !__GNUC_PREREQ__(2, 92)
+#elif __GNUC_PREREQ__(2, 92)
+#define __restrict __restrict__
+#else
#define __restrict /* delete __restrict when not supported */
#endif
#if !defined(_STANDALONE) && !defined(_KERNEL)
#if defined(__GNUC__) || defined(__PCC__)
#define __RENAME(x) ___RENAME(x)
-#else
-#ifdef __lint__
+#elif defined(__lint__)
#define __RENAME(x) __symbolrename(x)
#else
#error "No function renaming possible"
-#endif /* __lint__ */
#endif /* __GNUC__ */
#else /* _STANDALONE || _KERNEL */
#define __RENAME(x) no renaming in kernel or standalone environment
#define __link_set_foreach(pvar, set) \
for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
-#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
+#define __link_set_entry(set, idx) (__link_set_start(set)[idx])
/*
* Return the number of elements in a statically-allocated array,
#define __CAST(__dt, __st) ((__dt)(__st))
#endif
-#ifdef _MINIX
-/* If compiling in Minix tree, Minix ANSI definitions are always useful. */
+#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \
+ (~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL)
+
+#ifndef __ASSEMBLER__
+static __inline long long __zeroll(void) { return 0; }
+static __inline int __negative_p(double x) { return x < 0; }
+#else
+#define __zeroll() (0LL)
+#define __negative_p(x) ((x) < 0)
#endif
+#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1))))
+#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1))))
+#define __type_min_u(t) ((t)0ULL)
+#define __type_max_u(t) ((t)~0ULL)
+#define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1)
+#define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t))
+#define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t))
+
+
+#define __type_fit_u(t, a) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \
+ (((a) & __type_mask(t)) == 0) : !__negative_p(a))
+
+#define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \
+ ((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \
+ ((intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
+
+/*
+ * return true if value 'a' fits in type 't'
+ */
+#define __type_fit(t, a) (__type_is_signed(t) ? \
+ __type_fit_s(t, a) : __type_fit_u(t, a))
+
#endif /* !_SYS_CDEFS_H_ */
#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym, 25)
#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym, 27)
-#ifdef __minix
-/* GNU binutils 2.x doesn't support a.out link sets. We need to workaround
- * this by explicitely creating the N_SETV structure. */
-#define __link_set_decl(set, ptype)
-#else
#define __link_set_decl(set, ptype) \
extern struct { \
int __ls_length; \
ptype *__ls_items[1]; \
} __link_set_##set
-#endif /* !__minix */
#define __link_set_start(set) (&(__link_set_##set).__ls_items[0])
#define __link_set_end(set) \
-/* $NetBSD: cdefs_elf.h,v 1.34 2010/12/08 01:18:55 joerg Exp $ */
+/* $NetBSD: cdefs_elf.h,v 1.40 2012/03/04 16:14:48 tron Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
__asm(".weak " _C_LABEL_STRING(#sym));
#if __GNUC_PREREQ__(4, 0)
-#define __weak_reference(sym) __attribute__((__weakref__))
+#define __weak_reference(sym) __attribute__((__weakref__(#sym)))
#else
#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym))
#endif
-#if defined(__clang__)
-#define __warn_references(sym,msg) \
- static __attribute__((__used__, __section__(".gnu.warning." #sym))) \
- const char ___CONCAT(__warn_reference_##sym,__COUNTER__)[] = msg;
+#if __GNUC_PREREQ__(4, 2)
+#define __weakref_visible static
#else
+#define __weakref_visible extern
+#endif
+
#define __warn_references(sym,msg) \
__asm(".pushsection .gnu.warning." #sym "\n" \
".ascii \"" msg "\"\n" \
".popsection");
-#endif
#else /* !__STDC__ */
#endif /* !__STDC__ */
-#if defined(__clang__)
-#define __SECTIONSTRING(_sec, _str) \
- static __attribute__((__used__, __section__(#_sec))) const char \
- ___CONCAT(__sectstr,__COUNTER__)[] = _str
-#elif __STDC__
+#if __STDC__
#define __SECTIONSTRING(_sec, _str) \
__asm(".pushsection " #_sec "\n" \
".asciz \"" _str "\"\n" \
#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n)
#define __link_set_decl(set, ptype) \
- extern ptype * const __start_link_set_##set[]; \
- extern ptype * const __stop_link_set_##set[] \
+ extern ptype * const __start_link_set_##set[] __dso_hidden; \
+ extern ptype * const __stop_link_set_##set[] __dso_hidden \
#define __link_set_start(set) (__start_link_set_##set)
#define __link_set_end(set) (__stop_link_set_##set)
__attribute__((__section__(".data.read_mostly")))
#define __cacheline_aligned \
- __attribute__((__aligned__(COHERENCY_UNIT) \
+ __attribute__((__aligned__(COHERENCY_UNIT), \
__section__(".data.cacheline_aligned")))
#endif /* _KERNEL */
#include <sys/featuretest.h>
#include <sys/ctype_bits.h>
-
+/* LSC: cast to unsigned char in order to prevent char as indice errors. */
#define isdigit(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_N))
#define islower(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_L))
#define isspace(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_S))
#include <sys/types.h>
#endif
+#if defined(__minix) && !defined(_STANDALONE)
+#include <minix/partition.h>
+#endif
+
/*
* Each disk has a label which includes information about the hardware
* disk geometry, filesystem partitions, and drive specific information.
uint16_t d_npartitions; /* number of partitions in following */
uint32_t d_bbsize; /* size of boot area at sn0, bytes */
uint32_t d_sbsize; /* max size of fs superblock, bytes */
+#if defined(__minix) && !defined(_STANDALONE)
+ struct partition /* the partition table */
+ d_partitions[MAXPARTITIONS]; /* actually may be more */
+#else
struct partition { /* the partition table */
uint32_t p_size; /* number of sectors in partition */
uint32_t p_offset; /* starting sector */
#define p_cpg __partition_u1.cpg
#define p_sgs __partition_u1.sgs
} d_partitions[MAXPARTITIONS]; /* actually may be more */
+#endif /* defined(__minix) */
};
#if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H
* file is included in an ordinary user program, EPERM has the value ( 1).
*/
-#ifndef _ERRNO_H /* check if <errno.h> is already included */
-# define _ERRNO_H /* it is not included; note that fact */
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
/* Now define _SIGN as "" or "-" depending on _SYSTEM. */
#ifdef _SYSTEM
#define EDEADEPT (_SIGN 302 ) /* specified endpoint is not alive */
#define EBADCPU (_SIGN 303 ) /* requested CPU does not work */
-#endif /* _ERRNO_H */
+#endif /* !_SYS_ERRNO_H_ */
/* Never define _REENTRANT on Minix */
-#ifdef __minix
+#ifndef __minix
#if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \
!defined(_REENTRANT)
__RENAME(__getfh30);
#endif
+#if !defined(__minix)
int unmount(const char *, int);
+#endif /* !defined(__minix) */
#if defined(_NETBSD_SOURCE)
#ifndef __LIBC12_SOURCE__
+#if !defined(__minix)
+/* LSC FIXME: we should remove our definition, and make sure all the tools uses the new one*/
int mount(const char *, const char *, int, void *, size_t) __RENAME(__mount50);
+#endif /* !defined(__minix) */
int fhopen(const void *, size_t, int) __RENAME(__fhopen40);
int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat50);
#endif
-/* $NetBSD: ptree.h,v 1.3 2008/11/25 15:13:47 ad Exp $ */
+/* $NetBSD: ptree.h,v 1.8 2012/10/06 22:15:09 matt Exp $ */
+
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _SYS_PTREE_H_
#define _SYS_PTREE_H_
typedef struct pt_node {
uintptr_t ptn_slots[2]; /* must be first */
-#define PT_SLOT_LEFT 0
-#define PT_SLOT_RIGHT 1
+#define PT_SLOT_LEFT 0u
+#define PT_SLOT_RIGHT 1u
#ifdef _PT_PRIVATE
-#define PT_SLOT_ROOT 0
-#define PT_SLOT_OTHER 1
-#define PT_SLOT_ODDMAN 1
-#define PT_TYPE_LEAF 0x00000000
-#define PT_TYPE_BRANCH 0x00000001
-#define PT_TYPE_MASK 0x00000001
+#define PT_SLOT_ROOT 0u
+#define PT_SLOT_OTHER 1u
+#define PT_SLOT_ODDMAN 1u
+#define PT_TYPE_LEAF ((uintptr_t)0x00000000u)
+#define PT_TYPE_BRANCH ((uintptr_t)0x00000001u)
+#define PT_TYPE_MASK ((uintptr_t)0x00000001u)
#endif /* _PT_PRIVATE */
uint32_t ptn_nodedata;
#ifdef _PT_PRIVATE
-#define PTN_LEAF_POSITION_BITS 8
-#define PTN_LEAF_POSITION_SHIFT 0
-#define PTN_BRANCH_POSITION_BITS 8
-#define PTN_BRANCH_POSITION_SHIFT 8
+#define PTN_LEAF_POSITION_BITS 8u
+#define PTN_LEAF_POSITION_SHIFT 0u
+#define PTN_BRANCH_POSITION_BITS 8u
+#define PTN_BRANCH_POSITION_SHIFT 8u
#ifndef PTNOMASK
-#define PTN_MASK_BITLEN_BITS 15
-#define PTN_MASK_BITLEN_SHIFT 16
-#define PTN_MASK_FLAG 0x80000000
+#define PTN_MASK_BITLEN_BITS 15u
+#define PTN_MASK_BITLEN_SHIFT 16u
+#define PTN_MASK_FLAG 0x80000000u
#endif
#endif /* _PT_PRIVATE */
uint32_t ptn_branchdata;
#ifdef _PT_PRIVATE
-#define PTN_BRANCH_BITOFF_BITS 15
-#define PTN_BRANCH_BITOFF_SHIFT 0
-#define PTN_BRANCH_BITLEN_BITS 8
-#define PTN_BRANCH_BITLEN_SHIFT 16
+#define PTN_BRANCH_BITOFF_BITS 15u
+#define PTN_BRANCH_BITOFF_SHIFT 0u
+#define PTN_BRANCH_BITLEN_BITS 8u
+#define PTN_BRANCH_BITLEN_SHIFT 16u
#if 0
-#define PTN_ORIENTATION_BITS 1
-#define PTN_ORIENTATION_SHIFT 30
+#define PTN_ORIENTATION_BITS 1u
+#define PTN_ORIENTATION_SHIFT 30u
#endif
-#define PTN_BRANCH_UNUSED 0x3f000000
-#define PTN_XBRANCH_FLAG 0x80000000
+#define PTN_BRANCH_UNUSED 0x3f000000u
+#define PTN_XBRANCH_FLAG 0x80000000u
#endif /* _PT_PRIVATE */
} pt_node_t;
#endif /* _PT_PRIVATE */
typedef struct pt_tree_ops {
- bool (*ptto_matchnode)(const void *, const void *, pt_bitoff_t,
- pt_bitoff_t *, pt_slot_t *);
- bool (*ptto_matchkey)(const void *, const void *, pt_bitoff_t,
- pt_bitlen_t);
- pt_slot_t (*ptto_testnode)(const void *, pt_bitoff_t, pt_bitlen_t);
- pt_slot_t (*ptto_testkey)(const void *, pt_bitoff_t, pt_bitlen_t);
+ bool (*ptto_matchnode)(const void *, const void *,
+ pt_bitoff_t, pt_bitoff_t *, pt_slot_t *, void *);
+ bool (*ptto_matchkey)(const void *, const void *,
+ pt_bitoff_t, pt_bitlen_t, void *);
+ pt_slot_t (*ptto_testnode)(const void *,
+ pt_bitoff_t, pt_bitlen_t, void *);
+ pt_slot_t (*ptto_testkey)(const void *,
+ pt_bitoff_t, pt_bitlen_t, void *);
} pt_tree_ops_t;
typedef struct pt_tree {
const pt_tree_ops_t *pt_ops;
size_t pt_node_offset;
size_t pt_key_offset;
- uintptr_t pt_spare[4];
+ void *pt_context;
+ uintptr_t pt_spare[3];
} pt_tree_t;
#define PT_FILTER_MASK 0x00000001 /* node is a mask */
typedef bool (*pt_filter_t)(void *, const void *, int);
-void ptree_init(pt_tree_t *, const pt_tree_ops_t *, size_t, size_t);
+void ptree_init(pt_tree_t *, const pt_tree_ops_t *, void *, size_t, size_t);
bool ptree_insert_node(pt_tree_t *, void *);
bool ptree_insert_mask_node(pt_tree_t *, void *, pt_bitlen_t);
-void * ptree_find_filtered_node(pt_tree_t *, void *, pt_filter_t, void *);
+bool ptree_mask_node_p(pt_tree_t *, const void *, pt_bitlen_t *);
+void * ptree_find_filtered_node(pt_tree_t *, const void *, pt_filter_t, void *);
#define ptree_find_node(pt,key) \
ptree_find_filtered_node((pt), (key), NULL, NULL)
void ptree_remove_node(pt_tree_t *, void *);
#define RBT_HALT 0 /* shutdown and return to monitor */
#define RBT_REBOOT 1 /* reboot the system through the monitor */
#define RBT_PANIC 2 /* a server panics */
-#define RBT_MONITOR 3 /* let the monitor do this */
+#define RBT_POWEROFF 3 /* power off, reset if not possible */
#define RBT_RESET 4 /* hard reset the system */
#define RBT_DEFAULT 5 /* return to monitor, reset if not possible */
#define RBT_INVALID 6 /* first invalid reboot flag */
+
/*
* Arguments to reboot system call. These are passed to the boot program,
* and then on to init.
+/* $NetBSD: socket.h,v 1.107 2012/06/22 18:26:35 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1985, 1986, 1988, 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.
+ *
+ * @(#)socket.h 8.6 (Berkeley) 5/3/95
+ */
+
#ifndef _SYS_SOCKET_H_
#define _SYS_SOCKET_H_
/* SO_OSNDTIMEO 0x1005 */
/* SO_ORCVTIMEO 0x1006 */
#define SO_ERROR 0x1007 /* get error status and clear */
-#define SO_TYPE 0x1008 /* get socket type */
#define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */
int msg_flags; /* flags on received message */
};
+#define MSG_OOB 0x0001 /* process out-of-band data */
+#define MSG_PEEK 0x0002 /* peek at incoming message */
+#define MSG_DONTROUTE 0x0004 /* send without using routing tables */
+#define MSG_EOR 0x0008 /* complete record */
/*
* Header for ancillary data objects in msg_control buffer.
* Used for additional information with/about a datagram
int socketpair(int, int, int, int *);
__END_DECLS
-#define MSG_OOB 0x0001 /* process out-of-band data */
-#define MSG_PEEK 0x0002 /* peek at incoming message */
-#define MSG_DONTROUTE 0x0004 /* send without using routing tables */
-#define MSG_EOR 0x0008 /* complete record */
#endif /* !_SYS_SOCKET_H_ */
#define MINIX_ST_BLKSIZE PAGE_SIZE
#endif
+#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <sys/cdefs.h>
__BEGIN_DECLS
#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
__END_DECLS
+#endif /* !_KERNEL && !_STANDALONE */
#endif /* !_SYS_STAT_H_ */
-/* $NetBSD: syslog.h,v 1.32 2008/10/31 16:12:18 christos Exp $ */
+/* $NetBSD: syslog.h,v 1.35 2012/10/10 22:51:55 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
/* Used by reentrant functions */
struct syslog_data {
+ int log_version;
int log_file;
- int connected;
- int opened;
+ int log_connected;
+ int log_opened;
int log_stat;
const char *log_tag;
+ char log_hostname[256]; /* MAXHOSTNAMELEN */
int log_fac;
int log_mask;
};
#define SYSLOG_DATA_INIT { \
+ .log_version = 1, \
.log_file = -1, \
+ .log_connected = 0, \
+ .log_opened = 0, \
+ .log_stat = 0, \
+ .log_tag = 0, \
+ .log_hostname = { '\0' }, \
.log_fac = LOG_USER, \
.log_mask = 0xff, \
}
-/*
- * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two
- * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
- * of them here we may collide with the utility's includes. It's unreasonable
- * for utilities to have to include one of them to include syslog.h, so we get
- * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
- */
-#include <machine/ansi.h>
#include <sys/cdefs.h>
#include <sys/featuretest.h>
+#include <sys/ansi.h>
__BEGIN_DECLS
void closelog(void);
void openlog(const char *, int, int);
int setlogmask(int);
-void syslog(int, const char *, ...)
- __attribute__((__format__(__printf__,2,3)));
+void syslog(int, const char *, ...) __printflike(2, 3);
#if defined(_NETBSD_SOURCE)
-void vsyslog(int, const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,2,0)));
-void closelog_r(struct syslog_data *);
-void openlog_r(const char *, int, int, struct syslog_data *);
-int setlogmask_r(int, struct syslog_data *);
+void vsyslog(int, const char *, __va_list) __printflike(2, 0);
+#ifndef __LIBC12_SOURCE__
+void closelog_r(struct syslog_data *) __RENAME(__closelog_r60);
+void openlog_r(const char *, int, int, struct syslog_data *)
+ __RENAME(__openlog_r60);
+int setlogmask_r(int, struct syslog_data *) __RENAME(__setlogmask_r60);
void syslog_r(int, struct syslog_data *, const char *, ...)
- __attribute__((__format__(__printf__,3,4)));
-void vsyslog_r(int, struct syslog_data *, const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,3,0)));
-void syslogp(int, const char *, const char *, const char *, ...)
- __attribute__((__format__(__printf__,4,5)));
-void vsyslogp(int, const char *, const char *, const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,4,0)));
-void syslogp_r(int, struct syslog_data *, const char *, const char *,
- const char *, ...)
- __attribute__((__format__(__printf__,5,6)));
-void vsyslogp_r(int, struct syslog_data *, const char *, const char *,
- const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,5,0)));
+ __RENAME(__syslog_r60) __printflike(3, 4);
+void vsyslog_r(int, struct syslog_data *, const char *, __va_list)
+ __RENAME(__vsyslog_r60) __printflike(3, 0);
+void syslogp_r(int, struct syslog_data *, const char *, const char *,
+ const char *, ...) __RENAME(__syslogp_r60) __printflike(5, 6);
+void vsyslogp_r(int, struct syslog_data *, const char *, const char *,
+ const char *, __va_list) __RENAME(__vsyslogp_r60) __printflike(5, 0);
+#endif
+void syslogp(int, const char *, const char *, const char *, ...)
+ __printflike(4, 5);
+void vsyslogp(int, const char *, const char *, const char *, __va_list)
+ __printflike(4, 0);
#endif
__END_DECLS
#else /* !_KERNEL */
void logpri(int);
-void log(int, const char *, ...)
- __attribute__((__format__(__printf__,2,3)));
-void vlog(int, const char *, _BSD_VA_LIST_)
- __attribute__((__format__(__printf__,2,0)));
-void addlog(const char *, ...)
- __attribute__((__format__(__printf__,1,2)));
+void log(int, const char *, ...) __printflike(2, 3);
+void vlog(int, const char *, __va_list) __printflike(2, 0);
+void addlog(const char *, ...) __printflike(1, 2);
void logwakeup(void);
#endif /* !_KERNEL */
--- /dev/null
+/* $NetBSD: tls.h,v 1.1 2011/03/09 23:10:07 joerg Exp $ */
+/*-
+ * Copyright (c) 2011 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.
+ */
+
+#ifndef _SYS_TLS_H_
+#define _SYS_TLS_H_
+
+#include <sys/cdefs.h>
+#include <machine/types.h>
+
+#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
+
+#if defined(__HAVE_TLS_VARIANT_I) && defined(__HAVE_TLS_VARIANT_II)
+#error Only one TLS variant can be supported at a time
+#endif
+
+struct tls_tcb {
+#ifdef __HAVE_TLS_VARIANT_I
+ void **tcb_dtv;
+ void *tcb_pthread;
+#else
+ void *tcb_self;
+ void **tcb_dtv;
+ void *tcb_pthread;
+#endif
+};
+
+__BEGIN_PUBLIC_DECLS
+struct tls_tcb *_rtld_tls_allocate(void);
+void _rtld_tls_free(struct tls_tcb *);
+void _rtld_tls_static_setup(void);
+__END_PUBLIC_DECLS
+#endif /* __HAVE_TLS_VARIANT_I || __HAVE_TLS_VARIANT_II */
+
+#endif /* _SYS_TLS_H_ */
#ifdef _MINIX
/* some Minix specific types that do not conflict with posix */
-typedef u32_t zone_t; /* zone number */
-typedef u32_t block_t; /* block number */
-typedef u32_t bit_t; /* bit number in a bit map */
-typedef u16_t zone1_t; /* zone number for V1 file systems */
-typedef u32_t bitchunk_t; /* collection of bits in a bitmap */
+typedef uint32_t zone_t; /* zone number */
+typedef uint32_t block_t; /* block number */
+typedef uint32_t bit_t; /* bit number in a bit map */
+typedef uint16_t zone1_t; /* zone number for V1 file systems */
+typedef uint32_t bitchunk_t; /* collection of bits in a bitmap */
#endif
/* ANSI C makes writing down the promotion of unsigned types very messy. When
gid_t gid;
};
+#ifdef __minix
+/* LSC FIXME: Remove this! Compatibility thing, only used in pfs/uds.c */
+struct ucred_old
+{
+ pid_t pid;
+ short uid;
+ char gid;
+};
+#endif /* def __minix */
+
/* Userland's view of credentials. This should not change */
struct uucred {
unsigned short cr_unused; /* not used, compat */
#include <dirent.h>
#include <sys/stat.h>
+#include "installboot.h"
+
#define BOOTBLOCK 0 /* Of course */
#define BOOT_BLOCK_SIZE 1024
#define SIGNATURE 0xAA55 /* Boot block signature. */
#include <unistd.h>
#include <string.h>
+#include "installboot.h"
+
#ifndef DFL_SECSIZE
#define DFL_SECSIZE 512
#endif
incr_link(inode);
}
-void enter_symlink(ino_t inode, char *link)
+void enter_symlink(ino_t inode, char *lnk)
{
zone_t z;
char *buf;
buf = alloc_block();
z = alloc_zone();
- strcpy(buf, link);
+ strcpy(buf, lnk);
put_block(z, buf);
- add_zone(inode, z, (size_t) strlen(link), current_time);
+ add_zone(inode, z, (size_t) strlen(lnk), current_time);
free(buf);
}
int f;
{
int ct, k;
- zone_t z;
+ zone_t z = 0;
char *buf;
uint32_t timeval;
}
}
- printf("Directory-inode %lu beyond direct blocks. Could not enter %s\n",
+ printf("Directory-inode %u beyond direct blocks. Could not enter %s\n",
parent, name);
pexit("Halt");
}
if (k > nrinodes) break;
{
if (inode2[i].d2_mode != 0) {
- printf("Inode %2lu: mode=", k);
+ printf("Inode %2u: mode=", k);
printf("%06o", inode2[i].d2_mode);
printf(" uid=%2d gid=%2d size=",
inode2[i].d2_uid, inode2[i].d2_gid);