CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: matt Date: Wed Jan 2 05:54:58 UTC 2013 Added Files: src/common/lib/libc/arch/arm/string: strcpy.S strlcpy.S strncpy.S Log Message: Add an assembly version of strcpy/strncpy/strlcpy. (they all use a common source with defines to determine which to build). To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/common/lib/libc/arch/arm/string/strcpy.S \ src/common/lib/libc/arch/arm/string/strlcpy.S \ src/common/lib/libc/arch/arm/string/strncpy.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/common/lib/libc/arch/arm/string/strcpy.S diff -u /dev/null src/common/lib/libc/arch/arm/string/strcpy.S:1.1 --- /dev/null Wed Jan 2 05:54:58 2013 +++ src/common/lib/libc/arch/arm/string/strcpy.S Wed Jan 2 05:54:58 2013 @@ -0,0 +1,519 @@ +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +RCSID("$NetBSD: strcpy.S,v 1.1 2013/01/02 05:54:58 matt Exp $") + +#ifdef STRLCPY +#define FUNCNAME strlcpy +#elif defined(STRNCPY) +#define FUNCNAME strncpy +#else +#define FUNCNAME strcpy +#endif + +#ifdef __ARMEL__ +#define lslo lsr /* shift to lower address */ +#define lshi lsl /* shift to higher address */ +#define BYTE0 0x00ff +#define BYTE1 0xff00 +#define BYTE2 0x00ff +#define BYTE3 0xff00 +#else +#define lslo lsl /* shift to lower address */ +#define lshi lsr /* shift to higher address */ +#define BYTE0 0xff00 +#define BYTE1 0x00ff +#define BYTE2 0xff00 +#define BYTE3 0x00ff +#endif + +/* + * On armv6 and later, to quickly determine if a word contains a NUL (0) byte, + * we add 254 to each byte using the UQADD8 (unsigned saturating add 8) + * instruction. For every non-NUL byte, the result for that byte will become + * 255. For NUL, it will be 254. When we complement the result of all 4 adds, + * if the result is non-0 then we must have encountered a NUL. + * + * For earlier architecture, we just use tst on all 4 bytes. There are other + * algorithms to detect NULs but they take longer and use more instructions. + */ + +/* + * char *strcpy(char *dst, const char *src); + * char *strncpy(char *dst, const char *src, size_t len); + * size_t strlcpy(char *dst, const char *src, size_t len); + */ + + .text +ENTRY(FUNCNAME) +#if defined(STRLCPY) + cmp r2, #1 /* is length 1 or less? */ + bhi 1f /* no, do normal */ + moveq r3, #0 /* = 1? load NUL */ + streqb r3, [r0] /* = 1? write NUL to dst */ + mov r0, r1 /* move src to r0 */ + b _C_LABEL(strlen) /* and tailcall strlen */ +1: + sub r2, r2, #1 /* leave one byte for NUL */ +#endif +#if defined(STRNCPY) + cmp r2, #0 /* 0 length? */ + RETc(eq) /* yes, just return */ +#endif + push {r4-r9} /* save some registers */ +#ifdef _ARM_ARCH_6 +#ifdef _ARM_ARCH_7 + movw r7, #0xfefe /* magic constant; 254 in each byte */ +#else + mov r7, #0xfe /* put 254 in low byte */ + orr r7, r7, r7, lsl #8 /* move to next byte */ +#endif + orr r7, r7, r7, lsl #16 /* move to next halfword */ +#endif + +#if defined(STRLCPY) + add r6, r1, #1 /* save for return (deal with NUL) */ +#else + mov r6, r0 /* save for return */ +#endif + +.Ldst_align: + tst r0, #3 /* check for dst alignment */ + beq .Ldst_aligned /* ok, proceed to next check */ + ldrb r5, [r1], #1 /* load a byte */ +#if defined(STRNCPY) + subs r2, r2, #1 /* subtract out from count */ + bmi .Ldst_full /* zero? the dst has no more room */ +#endif
CVS commit: src/sys/arch/arm/omap
Module Name:src Committed By: jmcneill Date: Tue Jan 1 23:22:44 UTC 2013 Modified Files: src/sys/arch/arm/omap: files.omap2 omapfb.c Log Message: If EDID is supplied, parse and print it. While here, try not to crash if is_console is false. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/omap/files.omap2 cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/omap/omapfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/omap/files.omap2 diff -u src/sys/arch/arm/omap/files.omap2:1.20 src/sys/arch/arm/omap/files.omap2:1.21 --- src/sys/arch/arm/omap/files.omap2:1.20 Tue Jan 1 13:05:21 2013 +++ src/sys/arch/arm/omap/files.omap2 Tue Jan 1 23:22:44 2013 @@ -1,4 +1,4 @@ -# $NetBSD: files.omap2,v 1.20 2013/01/01 13:05:21 jmcneill Exp $ +# $NetBSD: files.omap2,v 1.21 2013/01/01 23:22:44 jmcneill Exp $ # # Configuration info for Texas Instruments OMAP2/OMAP3 CPU support # Based on xscale/files.pxa2x0 @@ -125,7 +125,7 @@ file arch/arm/omap/obio_ohci.c obioohci attach ehci at obio with omap3_ehci file arch/arm/omap/omap3_ehci.c omap3_ehci -device omapfb: rasops16, rasops8, wsemuldisplaydev, vcons +device omapfb: rasops16, rasops8, wsemuldisplaydev, vcons, edid attach omapfb at obio file arch/arm/omap/omapfb.c omapfb Index: src/sys/arch/arm/omap/omapfb.c diff -u src/sys/arch/arm/omap/omapfb.c:1.6 src/sys/arch/arm/omap/omapfb.c:1.7 --- src/sys/arch/arm/omap/omapfb.c:1.6 Tue Dec 11 22:47:40 2012 +++ src/sys/arch/arm/omap/omapfb.c Tue Jan 1 23:22:44 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: omapfb.c,v 1.6 2012/12/11 22:47:40 matt Exp $ */ +/* $NetBSD: omapfb.c,v 1.7 2013/01/01 23:22:44 jmcneill Exp $ */ /* * Copyright (c) 2010 Michael Lorenz @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: omapfb.c,v 1.6 2012/12/11 22:47:40 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: omapfb.c,v 1.7 2013/01/01 23:22:44 jmcneill Exp $"); #include #include @@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: omapfb.c,v 1 #include #include +#include + struct omapfb_softc { device_t sc_dev; @@ -77,6 +79,9 @@ struct omapfb_softc { struct vcons_data vd; int sc_mode; uint8_t sc_cmap_red[256], sc_cmap_green[256], sc_cmap_blue[256]; + + uint8_t sc_edid_data[1024]; + size_t sc_edid_size; }; static int omapfb_match(device_t, cfdata_t, void *); @@ -157,8 +162,9 @@ omapfb_attach(device_t parent, device_t struct rasops_info *ri; struct wsemuldisplaydev_attach_args aa; prop_dictionary_t dict; + prop_data_t edid_data; unsigned long defattr; - bool is_console; + bool is_console = false; uint32_t sz, reg; int segs, i, j, adr; @@ -208,8 +214,24 @@ omapfb_attach(device_t parent, device_t #endif dict = device_properties(self); prop_dictionary_get_bool(dict, "is_console", &is_console); + edid_data = prop_dictionary_get(dict, "EDID"); //is_console = 1; + if (edid_data != NULL) { + struct edid_info ei; + + sc->sc_edid_size = min(prop_data_size(edid_data), 1024); + memset(sc->sc_edid_data, 0, sizeof(sc->sc_edid_data)); + memcpy(sc->sc_edid_data, prop_data_data_nocopy(edid_data), + sc->sc_edid_size); + + edid_parse(sc->sc_edid_data, &ei); + edid_print(&ei); + } + + if (!is_console) + return; + /* setup video DMA */ sc->sc_vramsize = (12 << 20) + 0x1000; /* 12MB + CLUT */
CVS commit: src/sys/arch/evbarm/beagle
Module Name:src Committed By: jmcneill Date: Tue Jan 1 23:21:26 UTC 2013 Modified Files: src/sys/arch/evbarm/beagle: beagle_machdep.c Log Message: Read EDID data on Beagleboard and pass it to omapfb driver if found. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/evbarm/beagle/beagle_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/beagle/beagle_machdep.c diff -u src/sys/arch/evbarm/beagle/beagle_machdep.c:1.32 src/sys/arch/evbarm/beagle/beagle_machdep.c:1.33 --- src/sys/arch/evbarm/beagle/beagle_machdep.c:1.32 Mon Dec 31 13:20:16 2012 +++ src/sys/arch/evbarm/beagle/beagle_machdep.c Tue Jan 1 23:21:26 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: beagle_machdep.c,v 1.32 2012/12/31 13:20:16 jmcneill Exp $ */ +/* $NetBSD: beagle_machdep.c,v 1.33 2013/01/01 23:21:26 jmcneill Exp $ */ /* * Machine dependent functions for kernel setup for TI OSK5912 board. @@ -125,7 +125,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.32 2012/12/31 13:20:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.33 2013/01/01 23:21:26 jmcneill Exp $"); #include "opt_machdep.h" #include "opt_ddb.h" @@ -181,6 +181,9 @@ __KERNEL_RCSID(0, "$NetBSD: beagle_machd #include #include +#include +#include + #include "prcm.h" #include "omapwdt32k.h" @@ -195,6 +198,8 @@ static char beagle_default_boot_args[] = char *boot_args = beagle_default_boot_args; char *boot_file = NULL; +static uint8_t beagle_edid[128]; /* EDID storage */ + u_int uboot_args[4] = { 0 }; /* filled in by beagle_start.S (not in bss) */ /* Same things, but for the free (unused by the kernel) memory. */ @@ -681,6 +686,40 @@ omap3530_memprobe(void) } #endif +/* + * EDID can be read from DVI-D (HDMI) port on BeagleBoard from + * If EDID data is present, this function fills in the supplied edid_buf + * and returns true. Otherwise, it returns false and the contents of the + * buffer are undefined. + */ +static bool +beagle_read_edid(uint8_t *edid_buf, size_t edid_buflen) +{ + i2c_tag_t ic = NULL; + uint8_t reg; + int error; + +#if defined(OMAP_3530) + /* On Beagleboard, EDID is accessed using I2C2 ("omapiic2"). */ + extern i2c_tag_t omap3_i2c_get_tag(device_t); + ic = omap3_i2c_get_tag(device_find_by_xname("omapiic2")); +#endif + + if (ic == NULL) + return false; + + iic_acquire_bus(ic, 0); + for (reg = DDC_EDID_START; reg < edid_buflen; reg++) { + error = iic_exec(ic, I2C_OP_READ_WITH_STOP, DDC_ADDR, + ®, sizeof(reg), &edid_buf[reg], 1, 0); + if (error) + break; + } + iic_release_bus(ic, 0); + + return error == 0 ? true : false; +} + void beagle_device_register(device_t self, void *aux) { @@ -737,4 +776,13 @@ beagle_device_register(device_t self, vo #endif return; } + + if (device_is_a(self, "omapfb")) { + if (beagle_read_edid(beagle_edid, sizeof(beagle_edid))) { + prop_dictionary_set(dict, "EDID", + prop_data_create_data(beagle_edid, + sizeof(beagle_edid))); + } + return; + } }
CVS commit: src/sys/arch/arm/omap
Module Name:src Committed By: jmcneill Date: Tue Jan 1 23:20:25 UTC 2013 Modified Files: src/sys/arch/arm/omap: omap3_i2c.c Log Message: add a function to lookup the i2c controller tag for the specified device_t To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/omap/omap3_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/omap/omap3_i2c.c diff -u src/sys/arch/arm/omap/omap3_i2c.c:1.1 src/sys/arch/arm/omap/omap3_i2c.c:1.2 --- src/sys/arch/arm/omap/omap3_i2c.c:1.1 Mon Dec 31 12:45:49 2012 +++ src/sys/arch/arm/omap/omap3_i2c.c Tue Jan 1 23:20:24 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: omap3_i2c.c,v 1.1 2012/12/31 12:45:49 jmcneill Exp $ */ +/* $NetBSD: omap3_i2c.c,v 1.2 2013/01/01 23:20:24 jmcneill Exp $ */ /*- * Copyright (c) 2012 Jared D. McNeill @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: omap3_i2c.c,v 1.1 2012/12/31 12:45:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: omap3_i2c.c,v 1.2 2013/01/01 23:20:24 jmcneill Exp $"); #include "opt_omap.h" @@ -88,6 +88,8 @@ static int omap3_i2c_wait(struct omap3_i static int omap3_i2c_stat(struct omap3_i2c_softc *); static int omap3_i2c_flush(struct omap3_i2c_softc *); +i2c_tag_t omap3_i2c_get_tag(device_t); + CFATTACH_DECL2_NEW(omap3_i2c, sizeof(struct omap3_i2c_softc), omap3_i2c_match, omap3_i2c_attach, NULL, NULL, omap3_i2c_rescan, omap3_i2c_childdet); @@ -434,3 +436,15 @@ omap3_i2c_flush(struct omap3_i2c_softc * return 0; } + +i2c_tag_t +omap3_i2c_get_tag(device_t dev) +{ + struct omap3_i2c_softc *sc; + + if (dev == NULL) + return NULL; + sc = device_private(dev); + + return &sc->sc_ic; +}
CVS commit: src/external/cddl/osnet/lib/libzpool
Module Name:src Committed By: dsl Date: Tue Jan 1 19:03:26 UTC 2013 Modified Files: src/external/cddl/osnet/lib/libzpool: kernel.c Log Message: Comment out the unused 'struct proc p0;' This is userspace, it isn't supposed to know what a 'struct proc' is. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/libzpool/kernel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/lib/libzpool/kernel.c diff -u src/external/cddl/osnet/lib/libzpool/kernel.c:1.5 src/external/cddl/osnet/lib/libzpool/kernel.c:1.6 --- src/external/cddl/osnet/lib/libzpool/kernel.c:1.5 Tue Dec 28 13:36:09 2010 +++ src/external/cddl/osnet/lib/libzpool/kernel.c Tue Jan 1 19:03:26 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: kernel.c,v 1.5 2010/12/28 13:36:09 haad Exp $ */ +/* $NetBSD: kernel.c,v 1.6 2013/01/01 19:03:26 dsl Exp $ */ /* * CDDL HEADER START @@ -29,7 +29,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include -__RCSID("$NetBSD: kernel.c,v 1.5 2010/12/28 13:36:09 haad Exp $"); +__RCSID("$NetBSD: kernel.c,v 1.6 2013/01/01 19:03:26 dsl Exp $"); #include #include @@ -65,7 +65,7 @@ struct utsname utsname = { }; /* this only exists to have its address taken */ -struct proc p0; +// struct proc p0; /* * =
CVS commit: src/external/cddl/osnet/dist/lib/libzfs/common
Module Name:src Committed By: dsl Date: Tue Jan 1 19:02:19 UTC 2013 Modified Files: src/external/cddl/osnet/dist/lib/libzfs/common: libzfs_util.c Log Message: This needs an explicit include of sys/ioctl.h. XXX: There is some crappy code in here :-) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c diff -u src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c:1.4 src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c:1.5 --- src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c:1.4 Fri Dec 24 16:13:58 2010 +++ src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_util.c Tue Jan 1 19:02:19 2013 @@ -40,6 +40,7 @@ #include #include #include +#include #include
CVS commit: src/sbin/swapctl
Module Name:src Committed By: dsl Date: Tue Jan 1 19:01:11 UTC 2013 Modified Files: src/sbin/swapctl: swapctl.c Log Message: Explicitly include sys/ioctl.h To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sbin/swapctl/swapctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/swapctl/swapctl.c diff -u src/sbin/swapctl/swapctl.c:1.38 src/sbin/swapctl/swapctl.c:1.39 --- src/sbin/swapctl/swapctl.c:1.38 Wed Dec 26 10:15:28 2012 +++ src/sbin/swapctl/swapctl.c Tue Jan 1 19:01:10 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: swapctl.c,v 1.38 2012/12/26 10:15:28 mlelstv Exp $ */ +/* $NetBSD: swapctl.c,v 1.39 2013/01/01 19:01:10 dsl Exp $ */ /* * Copyright (c) 1996, 1997, 1999 Matthew R. Green @@ -64,11 +64,12 @@ #include #ifndef lint -__RCSID("$NetBSD: swapctl.c,v 1.38 2012/12/26 10:15:28 mlelstv Exp $"); +__RCSID("$NetBSD: swapctl.c,v 1.39 2013/01/01 19:01:10 dsl Exp $"); #endif #include +#include #include #include #include
CVS commit: src/sbin/dkscan_bsdlabel
Module Name:src Committed By: dsl Date: Tue Jan 1 18:44:27 UTC 2013 Modified Files: src/sbin/dkscan_bsdlabel: dkscan_util.c Log Message: Explicitly include sys/ioctl.h To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/dkscan_bsdlabel/dkscan_util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dkscan_bsdlabel/dkscan_util.c diff -u src/sbin/dkscan_bsdlabel/dkscan_util.c:1.2 src/sbin/dkscan_bsdlabel/dkscan_util.c:1.3 --- src/sbin/dkscan_bsdlabel/dkscan_util.c:1.2 Mon Apr 28 20:23:08 2008 +++ src/sbin/dkscan_bsdlabel/dkscan_util.c Tue Jan 1 18:44:27 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dkscan_util.c,v 1.2 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: dkscan_util.c,v 1.3 2013/01/01 18:44:27 dsl Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include
CVS commit: src/lib/libpthread
Module Name:src Committed By: dsl Date: Tue Jan 1 18:42:39 UTC 2013 Modified Files: src/lib/libpthread: pthread.c Log Message: Don't rely on sys/lwp.h includeing sys/resource.h for us. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/lib/libpthread/pthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread/pthread.c diff -u src/lib/libpthread/pthread.c:1.141 src/lib/libpthread/pthread.c:1.142 --- src/lib/libpthread/pthread.c:1.141 Wed Nov 14 23:25:05 2012 +++ src/lib/libpthread/pthread.c Tue Jan 1 18:42:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.141 2012/11/14 23:25:05 christos Exp $ */ +/* $NetBSD: pthread.c,v 1.142 2013/01/01 18:42:39 dsl Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: pthread.c,v 1.141 2012/11/14 23:25:05 christos Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.142 2013/01/01 18:42:39 dsl Exp $"); #define __EXPOSE_STACK 1 @@ -39,6 +39,7 @@ __RCSID("$NetBSD: pthread.c,v 1.141 2012 #include #include #include +#include #include #include
CVS commit: src/lib/libutil
Module Name:src Committed By: dsl Date: Tue Jan 1 18:32:17 UTC 2013 Modified Files: src/lib/libutil: getfsspecname.c Log Message: Don't rely on something including sys/ioctl.h for us. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libutil/getfsspecname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libutil/getfsspecname.c diff -u src/lib/libutil/getfsspecname.c:1.3 src/lib/libutil/getfsspecname.c:1.4 --- src/lib/libutil/getfsspecname.c:1.3 Sun Apr 8 20:56:12 2012 +++ src/lib/libutil/getfsspecname.c Tue Jan 1 18:32:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $ */ +/* $NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,9 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $"); +__RCSID("$NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $"); #include +#include #include #include
CVS commit: src/sys/arch/arm/omap
Module Name:src Committed By: jakllsch Date: Tue Jan 1 17:28:27 UTC 2013 Modified Files: src/sys/arch/arm/omap: omap_space.c Log Message: Hook up generic_bs_sr_4 for bus_space_set_region_4 in the OMAP bus space. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/omap/omap_space.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/omap/omap_space.c diff -u src/sys/arch/arm/omap/omap_space.c:1.6 src/sys/arch/arm/omap/omap_space.c:1.7 --- src/sys/arch/arm/omap/omap_space.c:1.6 Sat Sep 1 14:44:43 2012 +++ src/sys/arch/arm/omap/omap_space.c Tue Jan 1 17:28:27 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: omap_space.c,v 1.6 2012/09/01 14:44:43 matt Exp $ */ +/* $NetBSD: omap_space.c,v 1.7 2013/01/01 17:28:27 jakllsch Exp $ */ /* * bus_space functions for Texas Instruments OMAP processor. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: omap_space.c,v 1.6 2012/09/01 14:44:43 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: omap_space.c,v 1.7 2013/01/01 17:28:27 jakllsch Exp $"); #include #include @@ -155,7 +155,7 @@ struct bus_space omap_bs_tag = { /* set region */ generic_bs_sr_1, generic_armv4_bs_sr_2, - bs_notimpl_bs_sr_4, + generic_bs_sr_4, bs_notimpl_bs_sr_8, /* copy */
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jan 1 15:34:02 UTC 2013 Modified Files: src/lib/libedit: map.c Log Message: remove dead assignment (Christoph Mallon) To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/lib/libedit/map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/map.c diff -u src/lib/libedit/map.c:1.32 src/lib/libedit/map.c:1.33 --- src/lib/libedit/map.c:1.32 Tue Jan 1 10:33:06 2013 +++ src/lib/libedit/map.c Tue Jan 1 10:34:02 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: map.c,v 1.32 2013/01/01 15:33:06 christos Exp $ */ +/* $NetBSD: map.c,v 1.33 2013/01/01 15:34:02 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: map.c,v 1.32 2013/01/01 15:33:06 christos Exp $"); +__RCSID("$NetBSD: map.c,v 1.33 2013/01/01 15:34:02 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1249,7 +1249,7 @@ map_bind(EditLine *el, int argc, const C Char inbuf[EL_BUFSIZ]; Char outbuf[EL_BUFSIZ]; const Char *in = NULL; - Char *out = NULL; + Char *out; el_bindings_t *bp, *ep; int cmd; int key;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jan 1 15:33:06 UTC 2013 Modified Files: src/lib/libedit: map.c Log Message: Fix pasto that affected bind -k (Christoph Mallon) To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/libedit/map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/map.c diff -u src/lib/libedit/map.c:1.31 src/lib/libedit/map.c:1.32 --- src/lib/libedit/map.c:1.31 Fri Nov 18 15:39:18 2011 +++ src/lib/libedit/map.c Tue Jan 1 10:33:06 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: map.c,v 1.31 2011/11/18 20:39:18 christos Exp $ */ +/* $NetBSD: map.c,v 1.32 2013/01/01 15:33:06 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: map.c,v 1.31 2011/11/18 20:39:18 christos Exp $"); +__RCSID("$NetBSD: map.c,v 1.32 2013/01/01 15:33:06 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1368,7 +1368,7 @@ map_bind(EditLine *el, int argc, const C return -1; } if (key) - terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype); + terminal_set_arrow(el, in, keymacro_map_cmd(el, cmd), ntype); else { if (in[1]) { keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype);
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Tue Jan 1 13:05:46 UTC 2013 Modified Files: src/sys/arch/evbarm/conf: BEAGLEBOARD Log Message: add OMAP3 SCM (temp sensor) To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/evbarm/conf/BEAGLEBOARD Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/BEAGLEBOARD diff -u src/sys/arch/evbarm/conf/BEAGLEBOARD:1.38 src/sys/arch/evbarm/conf/BEAGLEBOARD:1.39 --- src/sys/arch/evbarm/conf/BEAGLEBOARD:1.38 Mon Dec 31 13:28:30 2012 +++ src/sys/arch/evbarm/conf/BEAGLEBOARD Tue Jan 1 13:05:46 2013 @@ -1,5 +1,5 @@ # -# $NetBSD: BEAGLEBOARD,v 1.38 2012/12/31 13:28:30 jmcneill Exp $ +# $NetBSD: BEAGLEBOARD,v 1.39 2013/01/01 13:05:46 jmcneill Exp $ # # BEAGLEBOARD -- TI OMAP 3530 Eval Board Kernel # @@ -219,7 +219,10 @@ omapgpio4 at obio2 addr 0x49056000 size gpio* at omapgpio? -# # I2C Controller +# System Control Module +omapscm0 at obio0 addr 0x48002000 size 0x1000 + +# I2C Controller omapiic0 at obio0 addr 0x4807 size 0x80 omapiic1 at obio0 addr 0x48072000 size 0x80 omapiic2 at obio0 addr 0x4806 size 0x80
CVS commit: src/sys/arch/arm/omap
Module Name:src Committed By: jmcneill Date: Tue Jan 1 13:05:21 UTC 2013 Modified Files: src/sys/arch/arm/omap: files.omap2 Added Files: src/sys/arch/arm/omap: omap3_scm.c Log Message: Add OMAP3530 temperature sensor support To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/omap/files.omap2 cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/omap/omap3_scm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/omap/files.omap2 diff -u src/sys/arch/arm/omap/files.omap2:1.19 src/sys/arch/arm/omap/files.omap2:1.20 --- src/sys/arch/arm/omap/files.omap2:1.19 Mon Dec 31 12:45:49 2012 +++ src/sys/arch/arm/omap/files.omap2 Tue Jan 1 13:05:21 2013 @@ -1,4 +1,4 @@ -# $NetBSD: files.omap2,v 1.19 2012/12/31 12:45:49 jmcneill Exp $ +# $NetBSD: files.omap2,v 1.20 2013/01/01 13:05:21 jmcneill Exp $ # # Configuration info for Texas Instruments OMAP2/OMAP3 CPU support # Based on xscale/files.pxa2x0 @@ -53,6 +53,11 @@ device omapiic: i2cbus, i2cexec attach omapiic at obio with omap3_i2c file arch/arm/omap/omap3_i2c.c omap3_i2c +# OMAP3 system control module +device omapscm: sysmon_envsys +attach omapscm at obio with omap3_scm +file arch/arm/omap/omap3_scm.c omap3_scm + # OMAP dual-mode timer device omapdmtimer file arch/arm/omap/omap_dmtimer.c omapdmtimer Added files: Index: src/sys/arch/arm/omap/omap3_scm.c diff -u /dev/null src/sys/arch/arm/omap/omap3_scm.c:1.1 --- /dev/null Tue Jan 1 13:05:21 2013 +++ src/sys/arch/arm/omap/omap3_scm.c Tue Jan 1 13:05:21 2013 @@ -0,0 +1,227 @@ +/* $NetBSD: omap3_scm.c,v 1.1 2013/01/01 13:05:21 jmcneill Exp $ */ + +/*- + * Copyright (c) 2013 Jared D. McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. 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 +__KERNEL_RCSID(0, "$NetBSD: omap3_scm.c,v 1.1 2013/01/01 13:05:21 jmcneill Exp $"); + +#include "opt_omap.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#define SCM_BASE_3530 0x48002000 +#define SCM_SIZE_3530 0x1000 +#define SCM_OFFSET_INTERFACE_3530 0 +#define SCM_OFFSET_GENERAL_3530 0x270 + +#if defined(OMAP_3530) +#define SCM_BASE SCM_BASE_3530 +#define SCM_SIZE SCM_SIZE_3530 +#define SCM_OFFSET_INTERFACE SCM_OFFSET_INTERFACE_3530 +#define SCM_OFFSET_GENERAL SCM_OFFSET_GENERAL_3530 +#endif + +/* INTERFACE */ +#define CONTROL_REVISION (SCM_OFFSET_INTERFACE + 0x00) + +/* GENERAL */ +#define CONTROL_TEMP_SENSOR (SCM_OFFSET_GENERAL + 0x2b4) +#define CONTROL_TEMP_SENSOR_CONTCONV __BIT(9) +#define CONTROL_TEMP_SENSOR_SOC __BIT(8) +#define CONTROL_TEMP_SENSOR_EOCZ __BIT(7) +#define CONTROL_TEMP_SENSOR_TEMP_MASK __BITS(6,0) + +/* CONTROL_TEMP_SENSOR TEMP bits to tenths of a degree */ +static const int omap3_scm_adc2temp[128] = { + -400, -400, -400, -400, -400, + -389, -375, -361, -333, -318, + -304, -290, -275, -261, -247, + -233, -219, -205, -191, -177, + -163, -149, -134, -120, -106, + -92, -78, -64, -50, -35, + -21, -7, 8, 23, 37, + 51, 66, 80, 94, 108, + 123, 137, 151, 165, 179, + 194, 208, 222, 236, 251, + 265, 279, 293, 307, 321, + 335, 349, 364, 378, 392, + 306, 420, 434, 449, 463, + 477, 491, 505, 519, 533, + 546, 560, 574, 588, 602, + 616, 630, 644, 657, 671, + 685, 699, 713, 727, 741, + 755, 769, 783, 797, 811, + 823, 838, 852, 865, 879, + 893, 906, 920, 934, 947, + 961, 975, 989, 1002, 1016, + 1030, 1043, 1057, 1071, 1085, + 1098, 1112, 1126, 1140, 1153, + 1167, 1181, 1194, 1208, 1222, + 1235, 1249, 1250, 1250, 1250, + 1250, 1250, 1250 +}; + +struct omap3_scm_softc { + device_t sc_dev; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + + /* GENERAL */ + struct sysmon_envsys *sc_sme; + envsys_data_t sc_sensor; +}; + +#define SCM_
CVS commit: src/usr.bin/units
Module Name:src Committed By: apb Date: Tue Jan 1 12:45:06 UTC 2013 Modified Files: src/usr.bin/units: units.c Log Message: fix incomplete comment To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/units/units.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/units/units.c diff -u src/usr.bin/units/units.c:1.21 src/usr.bin/units/units.c:1.22 --- src/usr.bin/units/units.c:1.21 Tue Jan 1 11:51:55 2013 +++ src/usr.bin/units/units.c Tue Jan 1 12:45:06 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: units.c,v 1.21 2013/01/01 11:51:55 apb Exp $ */ +/* $NetBSD: units.c,v 1.22 2013/01/01 12:45:06 apb Exp $ */ /* * units.c Copyright (c) 1993 by Adrian Mariano (adr...@cam.cornell.edu) @@ -768,7 +768,7 @@ listunits(int expand) * expand thename, not thedefn, so that * we can catch errors in the name itself. * e.g. a name that contains a hyphen - * will be interpreted + * will be interpreted as multiplication. */ initializeunit(&theunit); if (addunit(&theunit, thedefn/*XXX*/, 0) != 0
CVS commit: src/sys/dev/pci
Module Name:src Committed By: macallan Date: Tue Jan 1 12:13:28 UTC 2013 Modified Files: src/sys/dev/pci: files.pci radeonfb.c Log Message: add a compile option to override the fallback to software drawing of bitmap fonts on R3xx ( options RADEONFB_ALWAYS_ACCEL_PUTCHAR ) since this works just fine on my RV350. Next step: don't map VRAM if we don't need it. To generate a diff of this commit: cvs rdiff -u -r1.361 -r1.362 src/sys/dev/pci/files.pci cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/radeonfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/files.pci diff -u src/sys/dev/pci/files.pci:1.361 src/sys/dev/pci/files.pci:1.362 --- src/sys/dev/pci/files.pci:1.361 Mon Dec 17 20:37:59 2012 +++ src/sys/dev/pci/files.pci Tue Jan 1 12:13:28 2013 @@ -1,4 +1,4 @@ -# $NetBSD: files.pci,v 1.361 2012/12/17 20:37:59 mbalmer Exp $ +# $NetBSD: files.pci,v 1.362 2013/01/01 12:13:28 macallan Exp $ # # Config file and device description for machine-independent PCI code. # Included by ports that need it. Requires that the SCSI files be @@ -856,6 +856,7 @@ defflag opt_radeonfb.h RADEONFB_BIOS_INI defflag opt_radeonfb.h RADEONFB_BIOS_DEBUG defflag opt_radeonfb.h RADEONFB_MMAP_BARS defflag opt_radeonfb.h RADEONFB_DEPTH_32 +defflag opt_radeonfb.h RADEONFB_ALWAYS_ACCEL_PUTCHAR # Chelsio Terminator 3 (T3) 10 gigabit ethernet device cxgbc { } @@ -1050,7 +1051,7 @@ defflag opt_voyager.h VOYAGER_DEBUG include "dev/pci/hdaudio/files.hdaudio" # Permedia 2 / Sun PGX32 / Raptor -device pm2fb: wsemuldisplaydev, rasops8, rasops32, vcons, videomode, i2cbus, i2c_bitbang, ddc_read_edid, edid +device pm2fb: wsemuldisplaydev, rasops8, rasops32, vcons, videomode, i2cbus, i2c_bitbang, ddc_read_edid, edid, glyphcache attach pm2fb at pci file dev/pci/pm2fb.c pm2fb defflag opt_pm2fb.h PM2FB_DEBUG Index: src/sys/dev/pci/radeonfb.c diff -u src/sys/dev/pci/radeonfb.c:1.72 src/sys/dev/pci/radeonfb.c:1.73 --- src/sys/dev/pci/radeonfb.c:1.72 Mon Dec 31 11:11:17 2012 +++ src/sys/dev/pci/radeonfb.c Tue Jan 1 12:13:28 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: radeonfb.c,v 1.72 2012/12/31 11:11:17 macallan Exp $ */ +/* $NetBSD: radeonfb.c,v 1.73 2013/01/01 12:13:28 macallan Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.72 2012/12/31 11:11:17 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.73 2013/01/01 12:13:28 macallan Exp $"); #include #include @@ -170,7 +170,9 @@ static void radeonfb_cursor(void *, int, static void radeonfb_putchar(void *, int, int, unsigned, long); static void radeonfb_putchar_aa32(void *, int, int, unsigned, long); static void radeonfb_putchar_aa8(void *, int, int, unsigned, long); +#ifndef RADEONFB_ALWAYS_ACCEL_PUTCHAR static void radeonfb_putchar_wrapper(void *, int, int, unsigned, long); +#endif static int radeonfb_set_backlight(struct radeonfb_display *, int); static int radeonfb_get_backlight(struct radeonfb_display *); @@ -2396,6 +2398,7 @@ radeonfb_init_screen(void *cookie, struc /* pick a putchar method based on font and Radeon model */ if (ri->ri_font->stride < ri->ri_font->fontwidth) { /* got a bitmap font */ +#ifndef RADEONFB_ALWAYS_ACCEL_PUTCHAR if (IS_R300(dp->rd_softc)) { /* * radeonfb_putchar() doesn't work right on some R3xx @@ -2404,9 +2407,9 @@ radeonfb_init_screen(void *cookie, struc * into vram */ ri->ri_ops.putchar = radeonfb_putchar_wrapper; - } else { + } else +#endif ri->ri_ops.putchar = radeonfb_putchar; - } } else { /* got an alpha font */ switch(ri->ri_depth) { @@ -2965,6 +2968,7 @@ radeonfb_putchar_aa8(void *cookie, int r * just sync the engine and call rasops*_putchar() */ +#ifndef RADEONFB_ALWAYS_ACCEL_PUTCHAR static void radeonfb_putchar_wrapper(void *cookie, int row, int col, u_int c, long attr) { @@ -2975,6 +2979,7 @@ radeonfb_putchar_wrapper(void *cookie, i radeonfb_engine_idle(dp->rd_softc); dp->rd_putchar(ri, row, col, c, attr); } +#endif static void radeonfb_eraserows(void *cookie, int row, int nrows, long fillattr)
CVS commit: src/doc
Module Name:src Committed By: apb Date: Tue Jan 1 11:53:28 UTC 2013 Modified Files: src/doc: CHANGES Log Message: units(1): add -l and -L options. [apb 20130101] To generate a diff of this commit: cvs rdiff -u -r1.1773 -r1.1774 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1773 src/doc/CHANGES:1.1774 --- src/doc/CHANGES:1.1773 Wed Dec 26 19:20:30 2012 +++ src/doc/CHANGES Tue Jan 1 11:53:28 2013 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1773 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1774 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -162,3 +162,4 @@ Changes from NetBSD 6.0 to NetBSD 7.0: dhcpcd(8): Import dhcpcd-5.6.6 [roy 20121219] arm: support NEON in userland [matt 20121226] kernel: allow MD kernel code to use PCUs [matt 20121226] + units(1): add -l and -L options. [apb 20130101]
CVS commit: src/usr.bin/units
Module Name:src Committed By: apb Date: Tue Jan 1 11:51:56 UTC 2013 Modified Files: src/usr.bin/units: units.1 units.c Log Message: Add -l and -L options to units(1). "-l" simply lists all unit definitions, while "-L" alsoreduces them to depend only on a few primitive units (such as m, kg, sec). To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.bin/units/units.1 cvs rdiff -u -r1.20 -r1.21 src/usr.bin/units/units.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/units/units.1 diff -u src/usr.bin/units/units.1:1.18 src/usr.bin/units/units.1:1.19 --- src/usr.bin/units/units.1:1.18 Fri Dec 28 13:25:25 2012 +++ src/usr.bin/units/units.1 Tue Jan 1 11:51:55 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: units.1,v 1.18 2012/12/28 13:25:25 apb Exp $ +.\" $NetBSD: units.1,v 1.19 2013/01/01 11:51:55 apb Exp $ .Dd December 28, 2012 .Dt UNITS 1 .Os @@ -8,7 +8,7 @@ .Sh SYNOPSIS .Nm .Op Fl f Ar filename -.Op Fl qv +.Op Fl lLqv .Oo .Op Ar count .Ar from-unit to-unit @@ -25,6 +25,24 @@ The following options and arguments are .Bl -tag -width "-fXfilenameX" -offset indent .It Fl f Ar filename Specifies the name of the units data file to load. +.It Fl l No or Fl L +List all unit definitions to the standard output, +instead of performing any conversions. +The result may include error messages and comments, beginning with +.Ql \&/ . +.Pp +With the +.Fl l +option, unit definitions will be listed in a format +almost identical to the the units data file that was loaded, +except that comments will be removed, spacing may be changed, +and lines may be re-ordered. +.Pp +With the +.Fl L +option, all unit definitions will be reduced to a form that +depends on only a few primitive units (such as +.Sy m , kg , sec ) . .It Fl q Suppresses prompting of the user for units and the display of statistics about the number of units loaded. Index: src/usr.bin/units/units.c diff -u src/usr.bin/units/units.c:1.20 src/usr.bin/units/units.c:1.21 --- src/usr.bin/units/units.c:1.20 Tue Jan 1 11:44:00 2013 +++ src/usr.bin/units/units.c Tue Jan 1 11:51:55 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: units.c,v 1.20 2013/01/01 11:44:00 apb Exp $ */ +/* $NetBSD: units.c,v 1.21 2013/01/01 11:51:55 apb Exp $ */ /* * units.c Copyright (c) 1993 by Adrian Mariano (adr...@cam.cornell.edu) @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,13 @@ #define PRIMITIVECHAR '!' +static int precision = 8; /* for printf with "%.*g" format */ + +static const char *errprefix = NULL; /* if not NULL, then prepend this + * to error messages and send them to + * stdout instead of stderr. + */ + static const char *powerstring = "^"; static struct { @@ -98,9 +106,27 @@ dupstr(const char *str) static void +mywarnx(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + if (errprefix) { + /* warn to stdout, with errprefix prepended */ + printf("%s", errprefix); + vprintf(fmt, args); + printf("%s", "\n"); + } else { + /* warn to stderr */ + vwarnx(fmt, args); + } + va_end(args); +} + +static void readerror(int linenum) { - warnx("Error in units file '%s' line %d", UNITSFILE, linenum); + mywarnx("Error in units file '%s' line %d", UNITSFILE, linenum); } @@ -168,8 +194,9 @@ readunits(const char *userfile) continue; if (lineptr[strlen(lineptr) - 1] == '-') { /* it's a prefix */ if (prefixcount == MAXPREFIXES) { -warnx("Memory for prefixes exceeded in line %d", -linenum); +mywarnx( + "Memory for prefixes exceeded in line %d", + linenum); continue; } lineptr[strlen(lineptr) - 1] = 0; @@ -181,7 +208,7 @@ readunits(const char *userfile) } } if (isdup) { -warnx( +mywarnx( "Redefinition of prefix '%s' on line %d ignored", lineptr, linenum); continue; @@ -199,7 +226,7 @@ readunits(const char *userfile) } else { /* it's not a prefix */ if (unitcount == MAXUNITS) { -warnx("Memory for units exceeded in line %d", +mywarnx("Memory for units exceeded in line %d", linenum); continue; } @@ -210,7 +237,7 @@ readunits(const char *userfile) } } if (isdup) { -warnx( +mywarnx( "Redefinition of unit '%s' on line %d ignored", lineptr, linenum); continue; @@ -244,7 +271,7 @@ addsubunit(const char *product[], const for (ptr = product; *ptr && *ptr != NULLUNIT; ptr++); if (ptr >= product + MAXSUBUNITS) { - warnx("Memory overflow in unit reduction"); + mywarnx("Memory overflow in unit reduction"); return 1; } if (!*ptr) @@ -260,7 +287,7 @@ showunit(struct unittype * theunit) int printedslash; int counter = 1; - printf("\t%.8g", theunit->factor); + printf("\t%.*g", precision, theunit->factor); for (ptr = theunit->numerator; *ptr; ptr++) { if (ptr > theunit->numerator && **pt
CVS commit: src/usr.bin/units
Module Name:src Committed By: apb Date: Tue Jan 1 11:44:01 UTC 2013 Modified Files: src/usr.bin/units: units.c Log Message: Correctly ignore duplicate definitions. "continue" applies only to the innermost loop. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.bin/units/units.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/units/units.c diff -u src/usr.bin/units/units.c:1.19 src/usr.bin/units/units.c:1.20 --- src/usr.bin/units/units.c:1.19 Fri Dec 28 17:07:03 2012 +++ src/usr.bin/units/units.c Tue Jan 1 11:44:00 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: units.c,v 1.19 2012/12/28 17:07:03 apb Exp $ */ +/* $NetBSD: units.c,v 1.20 2013/01/01 11:44:00 apb Exp $ */ /* * units.c Copyright (c) 1993 by Adrian Mariano (adr...@cam.cornell.edu) @@ -109,7 +109,7 @@ readunits(const char *userfile) { FILE *unitfile; char line[80], *lineptr; - int len, linenum, i; + int len, linenum, i, isdup; unitcount = 0; linenum = 0; @@ -173,14 +173,20 @@ readunits(const char *userfile) continue; } lineptr[strlen(lineptr) - 1] = 0; - prefixtable[prefixcount].prefixname = dupstr(lineptr); - for (i = 0; i < prefixcount; i++) -if (!strcmp(prefixtable[i].prefixname, lineptr)) { - warnx( - "Redefinition of prefix '%s' on line %d ignored", - lineptr, linenum); - continue; + for (isdup = 0, i = 0; i < prefixcount; i++) { +if (!strcmp(prefixtable[i].prefixname, +lineptr)) { + isdup = 1; + break; } + } + if (isdup) { +warnx( + "Redefinition of prefix '%s' on line %d ignored", +lineptr, linenum); +continue; + } + prefixtable[prefixcount].prefixname = dupstr(lineptr); lineptr += len + 1; if (!strlen(lineptr)) { readerror(linenum); @@ -197,14 +203,19 @@ readunits(const char *userfile) linenum); continue; } - unittable[unitcount].uname = dupstr(lineptr); - for (i = 0; i < unitcount; i++) + for (isdup = 0, i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, lineptr)) { - warnx( -"Redefinition of unit '%s' on line %d ignored", - lineptr, linenum); - continue; + isdup = 1; + break; } + } + if (isdup) { +warnx( +"Redefinition of unit '%s' on line %d ignored", +lineptr, linenum); +continue; + } + unittable[unitcount].uname = dupstr(lineptr); lineptr += len + 1; lineptr += strspn(lineptr, " \n\t"); if (!strlen(lineptr)) {