Re: switch /usr/share/locale to different layout

2013-05-31 Thread Stefan Sperling
On Fri, May 31, 2013 at 01:05:08AM -0430, Andres Perera wrote:
 Besides being redundant, it's generally better to bail on open() error
 instead of checking if the length is less than PATH_MAX in
 anticipation.
 
 [Unrelated to your patch, but since we are on the subject of path
 checks in setlocale()...]
 
 However, since the routines also use locale data paths as keys for a
 dynamically allocated cache of their contents, a single check should
 persist. This raises an unrelated issue about the cache index: since
 libc doesn't support arbitrary paths for locale files, there's no need
 to index the cache by full locale data paths because all of the paths
 are anchored at _PATH_LOCALE.

That's true nowadays. However, there used to be an environment
variable to override _PATH_LOCALE. But that code had a bug and
was deemed unnecessary, so I removed it in r1.6 of setrunelocale.c.
The caching could now be adjusted, I guess. But it's not a big deal
so I'll leave it alone.
 
  on src/lib/libc/locale/setrunelocale.c, _xpg4_setrunelocale():
 
 184  len = snprintf(path, sizeof(path),
 185  %s/%s/LC_CTYPE, _PATH_LOCALE, encoding);
 186  if (len  0 || len = sizeof(path))
 187  return ENAMETOOLONG;
 
  This section is modified as part of my diff, isn't it?
 
 Sorry, this assertion remains correct after your diff so there was no
 need for me to list it.
 
 In any case, it's also redundant and should be zapped to prevent
 further confusion. There's yet another (x  PATH_MAX) check--making it
 the third one--which is a better candidate to keep due to its coupling
 with the cache population logic:

Right, the check is redundant during the
_xpg4_setrunelocale-_newrunelocale. But I'd like keep the idiom
that checks the result of snprintf() in place.

 
 125 int
 126 _newrunelocale(const char *path)
 127 {
 128 struct localetable *lt;
 129 FILE *fp;
 130 _RuneLocale *rl;
 131
 132 if (strlen(path) + 1  sizeof(lt-path))
 133 return EINVAL;
 
 
   +   /* Assume whatever.encoding locale name. */
 
  There should be some notion of syntax for cc_LL.CTYPE, even if only
  mentioned in comments.
 
  E.g.,
 
  ISO 3166-1 for country codes and BCP 47 for language tags.
 
  glibc did not do this and directly because of that it's a mess to
  navigate their structure.
 
  You mean we should specify encoding name syntax in a comment?
  If so, my answer would be that recognized encoding names are
  specified by filenames we use in /usr/share/locale. A comment
  documenting the same would risk becoming obsolete over time.
 
  Updated diff, with the redundant check removed:
 
 [...]



Re: switch /usr/share/locale to different layout

2013-05-31 Thread Vladimir Támara Patiño

On Thu, May 30, 2013 at 10:05:45PM +0200, Stefan Sperling wrote:

Does anyone see problems with this plan?


Sounds good.  


I agree with Andres, that a structure should be required for the locale
name, I guess fine starting with C, POSIX, C.encoding, POSIX.encoding, 
ll.encoding or ll_CC.encoding, with CC according to ISO 3166-1 alfa-2,

and ll according to ISO 639-1.

Although POSIX doesn't impose structure on the locale names, neither in
the directory structure, besides order, in my humble opinion it could make 
in future easier the implemenation of localedef (

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html ).
to be able to put in the correct directory each part.

--
Dios, gracias por tu amor infinito.
--  
 Vladimir Támara Patiño.  http://vtamara.pasosdeJesus.org/

 http://www.pasosdejesus.org/dominio_publico_colombia.html



Re: switch /usr/share/locale to different layout

2013-05-31 Thread Stefan Sperling
On Fri, May 31, 2013 at 07:30:20AM -0500, Vladimir Támara Patiño wrote:
 I agree with Andres, that a structure should be required for the locale
 name, I guess fine starting with C, POSIX, C.encoding,
 POSIX.encoding, ll.encoding or ll_CC.encoding, with CC according to
 ISO 3166-1 alfa-2,
 and ll according to ISO 639-1.

Sure.

My point is that all that matters for the LC_CTYPE case is
the 'encoding' part,  where we support whatever directory names
are used in /usr/share/locale/ to store the LC_CTYPE files.

That's why my diff says whatever.encoding in the context
of the LC_CTYPE support code. I don't mean to imply that the
whatever part couldn't be specified elsewhere.

If, say, LC_COLLATE requires information of the form ll_CC then
the code configuring collation must enforce that requirement.
The LC_CTYPE code doesn't need to enforce it.



Re: [NEW] ugold(4) driver for Microdia's USB TEMPer variant (take 2)

2013-05-31 Thread Luis Coronado
Upgraded my icinga/cacti box to -current, latest ugold patch applied. All
good:

from dmesg

OpenBSD 5.3-current (GENERIC.MP) #0: Wed May 29 09:47:39 CST 2013
r...@sbrnms..xxx:/usr/src/sys/arch/amd64/compile/GENERIC.MP

uhidev0 at uhub3 port 1 configuration 1 interface 0 RDing TEMPerV1.2 rev
2.00/0.01 addr 2
uhidev0: iclass 3/1, 1 report id
ugold0 at uhidev0 reportid 1
uhidev1 at uhub3 port 1 configuration 1 interface 1 RDing TEMPerV1.2 rev
2.00/0.01 addr 2
uhidev1: iclass 3/1
ugold1 at uhidev1
ugold1: type ds75/12bit (temperature)
uhidev2 at uhub5 port 1 configuration 1 interface 0 RDing TEMPerV1.2 rev
2.00/0.01 addr 2
uhidev2: iclass 3/1, 1 report id
ugold2 at uhidev2 reportid 1
uhidev3 at uhub5 port 1 configuration 1 interface 1 RDing TEMPerV1.2 rev
2.00/0.01 addr 2
uhidev3: iclass 3/1
ugold3 at uhidev3
ugold3: type ds75/12bit (temperature)

sysctl hw.sensors.ugold*

hw.sensors.ugold1.temp0=21.87 degC (inner)
hw.sensors.ugold3.temp0=24.25 degC (inner)

-luis


On Sun, May 12, 2013 at 12:41 PM, SASANO Takayoshi u...@mx5.nisiq.netwrote:

 Hello,

 Here is the driver for Microdia's USB TEMPer with some fixes.

 http://www.uaa.org.uk/gomitext/2013/20130513/20130513.diff

 - removed intermediate buffer (sc_ibuf), all USB interrupt responses
   will be processed in ugold_intr().
 - use uhidev_set_report() to issue HID command.
 - add ugold* at uhidev? into GENERIC for alpha, amd64, armish, hppa, i386,
   landisk, loongson, macppc, sgi (IP27, IP30, IP32), socppc and sparc64.

 Regards,
 
 SASANO Takayoshi u...@mx5.nisiq.net




Apple USB touchpad

2013-05-31 Thread Martin Pieuchot
Diff below moves tpms(4) from arch/macppc/dev to dev/usb because early
MacBooks (Core and Core2 duo machines) also come with an Apple Touchpad
and may use this driver.

I didn't add this driver to i386 and amd64's GENERIC yet because I don't
think it will work without a bit more love.  But I'd like to move the
source before starting to work on the new synaptics touchpad features
and hopefully multitouch support.

ok?

Index: sys/dev/usb/files.usb
===
RCS file: /cvs/src/sys/dev/usb/files.usb,v
retrieving revision 1.104
diff -u -p -r1.104 files.usb
--- sys/dev/usb/files.usb   29 Apr 2013 13:38:35 -  1.104
+++ sys/dev/usb/files.usb   31 May 2013 16:46:56 -
@@ -103,6 +103,11 @@ device uhts: wsmousedev
 attach uhts at uhidbus
 file   dev/usb/uhts.c  uhts
 
+# Apple USB Touchpad
+device tpms: hid, wsmousedev
+attach tpms at uhidbus
+file   dev/usb/tpms.c  tpms
+
 # Cypress microcontroller based serial adpaters
 device ucycom: hid, ucombus
 attach ucycom at uhidbus
Index: sys/dev/usb/tpms.c
===
RCS file: sys/dev/usb/tpms.c
diff -N sys/dev/usb/tpms.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/dev/usb/tpms.c  31 May 2013 16:46:56 -
@@ -0,0 +1,653 @@
+/* $OpenBSD: tpms.c,v 1.16 2012/02/24 06:19:00 guenther Exp $  */
+
+/*
+ * Copyright (c) 2005, Johan Wallén
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce 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 copyright holder may not be used to endorse or
+ *promote products derived from this software without specific
+ *prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED 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 OWNER BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The tpms driver provides support for the trackpad on new (post
+ * February 2005) Apple PowerBooks and iBooks that are not standard
+ * USB HID mice.
+ */
+
+/*
+ * The protocol (that is, the interpretation of the data generated by
+ * the trackpad) is taken from the Linux appletouch driver version
+ * 0.08 by Johannes Berg, Stelian Pop and Frank Arnold.  The method
+ * used to detect fingers on the trackpad is also taken from that
+ * driver.
+ */
+
+/*
+ * PROTOCOL:
+ *
+ * The driver transfers continuously 81 byte events.  The last byte is
+ * 1 if the button is pressed, and is 0 otherwise. Of the remaining
+ * bytes, 26 + 16 = 42 are sensors detecting pressure in the X or
+ * horizontal, and Y or vertical directions, respectively.  On 12 and
+ * 15 inch PowerBooks, only the 16 first sensors in the X-direction
+ * are used. In the X-direction, the sensors correspond to byte
+ * positions
+ *
+ *   2, 7, 12, 17, 22, 27, 32, 37, 4, 9, 14, 19, 24, 29, 34, 39, 42,
+ *   47, 52, 57, 62, 67, 72, 77, 44 and 49;
+ *
+ * in the Y direction, the sensors correspond to byte positions
+ *
+ *   1, 6, 11, 16, 21, 26, 31, 36, 3, 8, 13, 18, 23, 28, 33 and 38.
+ *
+ * The change in the sensor values over time is more interesting than
+ * their absolute values: if the pressure increases, we know that the
+ * finger has just moved there.
+ *
+ * We keep track of the previous sample (of sensor values in the X and
+ * Y directions) and the accumulated change for each sensor.  When we
+ * receive a new sample, we add the difference of the new sensor value
+ * and the old value to the accumulated change.  If the accumulator
+ * becomes negative, we set it to zero.  The effect is that the
+ * accumulator is large for sensors whose pressure has recently
+ * increased.  If there is little change in pressure (or if the
+ * pressure decreases), the accumulator drifts back to zero.
+ *
+ * Since there is some fluctuations, we ignore accumulator values
+ * below a threshold.  The raw finger position is computed 

Re: Apple USB touchpad

2013-05-31 Thread Martin Pieuchot
On 31/05/13(Fri) 13:00, Martin Pieuchot wrote:
 Diff below moves tpms(4) from arch/macppc/dev to dev/usb because early
 MacBooks (Core and Core2 duo machines) also come with an Apple Touchpad
 and may use this driver.
 
 I didn't add this driver to i386 and amd64's GENERIC yet because I don't
 think it will work without a bit more love.  But I'd like to move the
 source before starting to work on the new synaptics touchpad features
 and hopefully multitouch support.

Here's a new diff that rename the driver to utpms(4) to be coherent with
other USB devices as suggested by jcs@.

Tested on:
utpms0 at uhidev2: Fountain Trackpad
wsmouse1 at utpms0 mux 0

ok?

Index: sys/dev/usb/files.usb
===
RCS file: /cvs/src/sys/dev/usb/files.usb,v
retrieving revision 1.104
diff -u -p -r1.104 files.usb
--- sys/dev/usb/files.usb   29 Apr 2013 13:38:35 -  1.104
+++ sys/dev/usb/files.usb   31 May 2013 18:13:45 -
@@ -103,6 +103,11 @@ device uhts: wsmousedev
 attach uhts at uhidbus
 file   dev/usb/uhts.c  uhts
 
+# Apple USB Touchpad
+device utpms: hid, wsmousedev
+attach utpms at uhidbus
+file   dev/usb/utpms.c utpms
+
 # Cypress microcontroller based serial adpaters
 device ucycom: hid, ucombus
 attach ucycom at uhidbus
Index: sys/dev/usb/utpms.c
===
RCS file: sys/dev/usb/utpms.c
diff -N sys/dev/usb/utpms.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/dev/usb/utpms.c 31 May 2013 18:13:45 -
@@ -0,0 +1,651 @@
+/* $OpenBSD: utpms.c,v 1.16 2012/02/24 06:19:00 guenther Exp $ */
+
+/*
+ * Copyright (c) 2005, Johan Wallén
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce 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 copyright holder may not be used to endorse or
+ *promote products derived from this software without specific
+ *prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED 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 OWNER BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The utpms driver provides support for the trackpad on new (post
+ * February 2005) Apple PowerBooks and iBooks that are not standard
+ * USB HID mice.
+ */
+
+/*
+ * The protocol (that is, the interpretation of the data generated by
+ * the trackpad) is taken from the Linux appletouch driver version
+ * 0.08 by Johannes Berg, Stelian Pop and Frank Arnold.  The method
+ * used to detect fingers on the trackpad is also taken from that
+ * driver.
+ */
+
+/*
+ * PROTOCOL:
+ *
+ * The driver transfers continuously 81 byte events.  The last byte is
+ * 1 if the button is pressed, and is 0 otherwise. Of the remaining
+ * bytes, 26 + 16 = 42 are sensors detecting pressure in the X or
+ * horizontal, and Y or vertical directions, respectively.  On 12 and
+ * 15 inch PowerBooks, only the 16 first sensors in the X-direction
+ * are used. In the X-direction, the sensors correspond to byte
+ * positions
+ *
+ *   2, 7, 12, 17, 22, 27, 32, 37, 4, 9, 14, 19, 24, 29, 34, 39, 42,
+ *   47, 52, 57, 62, 67, 72, 77, 44 and 49;
+ *
+ * in the Y direction, the sensors correspond to byte positions
+ *
+ *   1, 6, 11, 16, 21, 26, 31, 36, 3, 8, 13, 18, 23, 28, 33 and 38.
+ *
+ * The change in the sensor values over time is more interesting than
+ * their absolute values: if the pressure increases, we know that the
+ * finger has just moved there.
+ *
+ * We keep track of the previous sample (of sensor values in the X and
+ * Y directions) and the accumulated change for each sensor.  When we
+ * receive a new sample, we add the difference of the new sensor value
+ * and the old value to the accumulated change.  If the accumulator
+ * becomes negative, we set it to zero.  The effect is that the
+ * accumulator is large for sensors whose pressure has 

vmxnet3

2013-05-31 Thread Masao Uebayashi
This is a newly written driver for VMware VMXNET3 ethernet controller.

- vic(4) was not used as a base because VMXNET3 is very different from
  previous VMXNET versions.
- Simple test shows that performance is comparable to VMXNET3 driver from
  open-vm-tools.
- Man page is missing (ongoing).

Briefly tested by yasuoka@, reyk@, and me.

Index: sys/dev/pci/if_vmx.c
===
--- sys/dev/pci/if_vmx.c(revision 0)
+++ sys/dev/pci/if_vmx.c(revision 142107)
@@ -0,0 +1,1232 @@
+/* $OpenBSD$   */
+
+/*
+ * Copyright (c) 2013 Tsubai Masanari
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include bpfilter.h
+#include vlan.h
+
+#include sys/param.h
+#include sys/device.h
+#include sys/mbuf.h
+#include sys/socket.h
+#include sys/sockio.h
+#include sys/systm.h
+
+#include net/bpf.h
+#include net/if.h
+#include net/if_arp.h
+#include net/if_media.h
+#include net/if_types.h
+
+#include netinet/in.h
+#include netinet/if_ether.h
+#include netinet/in_systm.h
+#include netinet/ip.h
+#include netinet/tcp.h
+#include netinet/udp.h
+
+#include net/if_vlan_var.h
+
+#include machine/bus.h
+
+#include dev/pci/if_vmxreg.h
+#include dev/pci/pcivar.h
+#include dev/pci/pcireg.h
+#include dev/pci/pcidevs.h
+
+#define NRXQUEUE 1
+#define NTXQUEUE 1
+
+#define NTXDESC 64
+#define NRXDESC 64
+#define NTXCOMPDESC NTXDESC
+#define NRXCOMPDESC (NRXDESC * 2)  /* ring1 + ring2 */
+
+#define VMXNET3_DRIVER_VERSION 0x0001
+
+struct vmxnet3_txring {
+   struct mbuf *m[NTXDESC];
+   bus_dmamap_t dmap[NTXDESC];
+   struct vmxnet3_txdesc *txd;
+   u_int head;
+   u_int next;
+   u_int8_t gen;
+};
+
+struct vmxnet3_rxring {
+   struct mbuf *m[NRXDESC];
+   bus_dmamap_t dmap[NRXDESC];
+   struct vmxnet3_rxdesc *rxd;
+   u_int fill;
+   u_int8_t gen;
+   u_int8_t rid;
+};
+
+struct vmxnet3_comp_ring {
+   union {
+   struct vmxnet3_txcompdesc *txcd;
+   struct vmxnet3_rxcompdesc *rxcd;
+   };
+   u_int next;
+   u_int8_t gen;
+};
+
+struct vmxnet3_txqueue {
+   struct vmxnet3_txring cmd_ring;
+   struct vmxnet3_comp_ring comp_ring;
+   struct vmxnet3_txq_shared *ts;
+};
+
+struct vmxnet3_rxqueue {
+   struct vmxnet3_rxring cmd_ring[2];
+   struct vmxnet3_comp_ring comp_ring;
+   struct vmxnet3_rxq_shared *rs;
+};
+
+struct vmxnet3_softc {
+   struct device sc_dev;
+   struct arpcom sc_arpcom;
+   struct ifmedia sc_media;
+
+   bus_space_tag_t sc_iot0;
+   bus_space_tag_t sc_iot1;
+   bus_space_handle_t sc_ioh0;
+   bus_space_handle_t sc_ioh1;
+   bus_dma_tag_t sc_dmat;
+
+   struct vmxnet3_txqueue sc_txq[NTXQUEUE];
+   struct vmxnet3_rxqueue sc_rxq[NRXQUEUE];
+   struct vmxnet3_driver_shared *sc_ds;
+   void *sc_mcast;
+};
+
+#define VMXNET3_STAT
+
+#ifdef VMXNET3_STAT
+struct {
+   u_int ntxdesc;
+   u_int nrxdesc;
+   u_int txhead;
+   u_int txdone;
+   u_int maxtxlen;
+   u_int rxdone;
+   u_int rxfill;
+   u_int intr;
+} vmxstat = {
+   NTXDESC, NRXDESC
+};
+#endif
+
+#define JUMBO_LEN (1024*9)
+#define DMAADDR(map) ((map)-dm_segs[0].ds_addr)
+
+#define READ_BAR0(sc, reg) bus_space_read_4((sc)-sc_iot0, (sc)-sc_ioh0, reg)
+#define READ_BAR1(sc, reg) bus_space_read_4((sc)-sc_iot1, (sc)-sc_ioh1, reg)
+#define WRITE_BAR0(sc, reg, val) \
+   bus_space_write_4((sc)-sc_iot0, (sc)-sc_ioh0, reg, val)
+#define WRITE_BAR1(sc, reg, val) \
+   bus_space_write_4((sc)-sc_iot1, (sc)-sc_ioh1, reg, val)
+#define WRITE_CMD(sc, cmd) WRITE_BAR1(sc, VMXNET3_BAR1_CMD, cmd)
+#define vtophys(va) 0  /* XXX ok? */
+
+int vmxnet3_match(struct device *, void *, void *);
+void vmxnet3_attach(struct device *, struct device *, void *);
+int vmxnet3_dma_init(struct vmxnet3_softc *);
+int vmxnet3_alloc_txring(struct vmxnet3_softc *, int);
+int vmxnet3_alloc_rxring(struct vmxnet3_softc *, int);
+void vmxnet3_txinit(struct vmxnet3_softc *, struct vmxnet3_txqueue *);
+void vmxnet3_rxinit(struct vmxnet3_softc *, struct vmxnet3_rxqueue *);
+void vmxnet3_txstop(struct vmxnet3_softc *, struct vmxnet3_txqueue *);
+void vmxnet3_rxstop(struct vmxnet3_softc *, struct vmxnet3_rxqueue *);
+void 

Re: vmxnet3

2013-05-31 Thread Reyk Floeter
Hi,

this is some nice work!

The new virtual VMXNET3 chipset supports a few features that haven't
been available in the previous chipsets, including VLAN Guest Tagging
(VGT), or simply the ability to pass tagged VLANs from VMware hosts
to external switches, and checksum offloading (hint, hint).

A few comments about the driver below:
- I like the simplicity (especially compared to VMware's VMXNET3 driver)
- The diff should include an initial manpage vmx(4) ;)
- The bitfields in the descriptor definitions should be replaced
with u_int* types and related shifts/masks.
- A few things like IFCAP_VLAN_HWTAGGING are indicated, but it doesn't
seem to be fully implemented yet.

I'm voting for committing it and to do further changes in the tree.

Reyk

On Fri, May 31, 2013 at 02:23:01PM -0400, Masao Uebayashi wrote:
 This is a newly written driver for VMware VMXNET3 ethernet controller.
 
 - vic(4) was not used as a base because VMXNET3 is very different from
   previous VMXNET versions.
 - Simple test shows that performance is comparable to VMXNET3 driver from
   open-vm-tools.
 - Man page is missing (ongoing).
 
 Briefly tested by yasuoka@, reyk@, and me.
 
 Index: sys/dev/pci/if_vmx.c
 ===
 --- sys/dev/pci/if_vmx.c  (revision 0)
 +++ sys/dev/pci/if_vmx.c  (revision 142107)
 @@ -0,0 +1,1232 @@
 +/*   $OpenBSD$   */
 +
 +/*
 + * Copyright (c) 2013 Tsubai Masanari
 + *
 + * Permission to use, copy, modify, and distribute this software for any
 + * purpose with or without fee is hereby granted, provided that the above
 + * copyright notice and this permission notice appear in all copies.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 + */
 +
 +#include bpfilter.h
 +#include vlan.h
 +
 +#include sys/param.h
 +#include sys/device.h
 +#include sys/mbuf.h
 +#include sys/socket.h
 +#include sys/sockio.h
 +#include sys/systm.h
 +
 +#include net/bpf.h
 +#include net/if.h
 +#include net/if_arp.h
 +#include net/if_media.h
 +#include net/if_types.h
 +
 +#include netinet/in.h
 +#include netinet/if_ether.h
 +#include netinet/in_systm.h
 +#include netinet/ip.h
 +#include netinet/tcp.h
 +#include netinet/udp.h
 +
 +#include net/if_vlan_var.h
 +
 +#include machine/bus.h
 +
 +#include dev/pci/if_vmxreg.h
 +#include dev/pci/pcivar.h
 +#include dev/pci/pcireg.h
 +#include dev/pci/pcidevs.h
 +
 +#define NRXQUEUE 1
 +#define NTXQUEUE 1
 +
 +#define NTXDESC 64
 +#define NRXDESC 64
 +#define NTXCOMPDESC NTXDESC
 +#define NRXCOMPDESC (NRXDESC * 2)/* ring1 + ring2 */
 +
 +#define VMXNET3_DRIVER_VERSION 0x0001
 +
 +struct vmxnet3_txring {
 + struct mbuf *m[NTXDESC];
 + bus_dmamap_t dmap[NTXDESC];
 + struct vmxnet3_txdesc *txd;
 + u_int head;
 + u_int next;
 + u_int8_t gen;
 +};
 +
 +struct vmxnet3_rxring {
 + struct mbuf *m[NRXDESC];
 + bus_dmamap_t dmap[NRXDESC];
 + struct vmxnet3_rxdesc *rxd;
 + u_int fill;
 + u_int8_t gen;
 + u_int8_t rid;
 +};
 +
 +struct vmxnet3_comp_ring {
 + union {
 + struct vmxnet3_txcompdesc *txcd;
 + struct vmxnet3_rxcompdesc *rxcd;
 + };
 + u_int next;
 + u_int8_t gen;
 +};
 +
 +struct vmxnet3_txqueue {
 + struct vmxnet3_txring cmd_ring;
 + struct vmxnet3_comp_ring comp_ring;
 + struct vmxnet3_txq_shared *ts;
 +};
 +
 +struct vmxnet3_rxqueue {
 + struct vmxnet3_rxring cmd_ring[2];
 + struct vmxnet3_comp_ring comp_ring;
 + struct vmxnet3_rxq_shared *rs;
 +};
 +
 +struct vmxnet3_softc {
 + struct device sc_dev;
 + struct arpcom sc_arpcom;
 + struct ifmedia sc_media;
 +
 + bus_space_tag_t sc_iot0;
 + bus_space_tag_t sc_iot1;
 + bus_space_handle_t sc_ioh0;
 + bus_space_handle_t sc_ioh1;
 + bus_dma_tag_t sc_dmat;
 +
 + struct vmxnet3_txqueue sc_txq[NTXQUEUE];
 + struct vmxnet3_rxqueue sc_rxq[NRXQUEUE];
 + struct vmxnet3_driver_shared *sc_ds;
 + void *sc_mcast;
 +};
 +
 +#define VMXNET3_STAT
 +
 +#ifdef VMXNET3_STAT
 +struct {
 + u_int ntxdesc;
 + u_int nrxdesc;
 + u_int txhead;
 + u_int txdone;
 + u_int maxtxlen;
 + u_int rxdone;
 + u_int rxfill;
 + u_int intr;
 +} vmxstat = {
 + NTXDESC, NRXDESC
 +};
 +#endif
 +
 +#define JUMBO_LEN (1024*9)
 +#define DMAADDR(map) ((map)-dm_segs[0].ds_addr)
 +
 +#define READ_BAR0(sc, reg) bus_space_read_4((sc)-sc_iot0, (sc)-sc_ioh0, 
 reg)
 +#define READ_BAR1(sc, reg) bus_space_read_4((sc)-sc_iot1, (sc)-sc_ioh1, 
 reg)
 +#define 

Re: vmxnet3

2013-05-31 Thread Theo de Raadt
 I'm voting for committing it and to do further changes in the tree.

that's the right process.



ping6: format time consistently

2013-05-31 Thread Christian Weisgerber
This is not very pretty:

16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=13 hlim=51 time=40.682 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=14 hlim=51 time=40.235 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=15 hlim=51 time=41.13 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=16 hlim=51 time=40.23 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=17 hlim=51 time=40.535 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=18 hlim=51 time=39.635 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=19 hlim=51 time=40.231 ms
16 bytes from 2001:638:208:ef1b:0:ff:fe00:4, icmp_seq=20 hlim=51 time=40.829 ms

We don't want to truncate trailing zeros.

ok?

Index: ping6.c
===
RCS file: /cvs/src/sbin/ping6/ping6.c,v
retrieving revision 1.83
diff -u -p -r1.83 ping6.c
--- ping6.c 16 Apr 2013 22:10:48 -  1.83
+++ ping6.c 31 May 2013 19:26:14 -
@@ -1351,7 +1351,7 @@ pr_pack(u_char *buf, int cc, struct msgh
sizeof(dstsa)));
}
if (timing)
-   (void)printf( time=%g ms, triptime);
+   (void)printf( time=%.3f ms, triptime);
if (dupflag)
(void)printf((DUP!));
if (options  F_AUD_RECV)
-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: vmxnet3

2013-05-31 Thread Reyk Floeter
Hi,

On Fri, May 31, 2013 at 02:23:01PM -0400, Masao Uebayashi wrote:
 This is a newly written driver for VMware VMXNET3 ethernet controller.
 

I created a manpage that I will commit shortly after the driver is in.

reyk

Index: vmx.4
===
RCS file: vmx.4
diff -N vmx.4
--- /dev/null   1 Jan 1970 00:00:00 -
+++ vmx.4   31 May 2013 19:55:49 -
@@ -0,0 +1,111 @@
+.\$OpenBSD$
+.\
+.\ Copyright (c) 2006,2013 Reyk Floeter r...@openbsd.org
+.\
+.\ Permission to use, copy, modify, and distribute this software for any
+.\ purpose with or without fee is hereby granted, provided that the above
+.\ copyright notice and this permission notice appear in all copies.
+.\
+.\ THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\
+.Dd $Mdocdate$
+.Dt VMX 4
+.Os
+.Sh NAME
+.Nm vmx
+.Nd VMware VMXNET3 Virtual Interface Controller device
+.Sh SYNOPSIS
+.Cd vmx* at pci?
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the VMXNET3 virtual NIC available in virtual
+machines by VMware.
+It appears as a simple Ethernet device but is actually a virtual network
+interface to the underlying host operating system.
+.Pp
+This driver supports the
+.Ic VMXNET3
+driver protocol, as an alternative to the emulated
+.Xr pcn 4 ,
+.Xr em 4
+and the earlier VMXNET
+.Xr vic 4
+interfaces also available in the VMware environment.
+The
+.Nm vmx
+driver is optimized for the virtual machine, it can provide advanced
+capabilities depending on the underlying host operating system and
+the physical network interface controller of the host.
+In comparison to the earlier VMXNET versions,
+as supported by the
+.Xr vic 4
+driver,
+VMXNET3 supports additional features like multiqueue support, IPv6
+checksum offloading, MSI/MSI-X support and hardware VLAN tagging in
+VMware's VLAN Guest Tagging (VGT) mode.
+.Pp
+The
+.Nm
+driver supports VMXNET3 VMware virtual NICs provided by the virtual
+machine hardware version 7 or newer, as provided by the following
+products:
+.Pp
+.Bl -bullet -compact -offset indent
+.It
+VMware ESX/ESXi 4.0 and newer
+.It
+VMware Server 2.0 and newer
+.It
+VMware Workstation 6.5 and newer
+.It
+VMware Fusion 2.0 and newer
+.El
+.Pp
+The
+.Nm
+driver supports the following media types:
+.Bl -tag -width autoselect
+.It autoselect
+Enable autoselection of the media type and options.
+The driver always uses the fastest available speed and the media
+options provided by the underlying host of the virtual machine.
+.It 10GbaseT mediaopt full-duplex
+Set 10Gbps operation.
+.It 1000baseT mediaopt full-duplex
+Set 1000Mbps operation.
+.El
+.Pp
+For more information on configuring this device, see
+.Xr ifconfig 8 .
+.Sh EXAMPLES
+The following entry must be added to the VMware configuration file
+to provide the
+.Nm
+device:
+.Bd -literal -offset indent
+ethernet0.virtualDev = vmxnet3
+.Ed
+.Sh SEE ALSO
+.Xr arp 4 ,
+.Xr em 4 ,
+.Xr ifmedia 4 ,
+.Xr intro 4 ,
+.Xr netintro 4 ,
+.Xr pci 4 ,
+.Xr pcn 4 ,
+.Xr vic 4 ,
+.Xr hostname.if 5 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Tsubai Masanari .
Index: vic.4
===
RCS file: /cvs/src/share/man/man4/vic.4,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 vic.4
--- vic.4   28 Jul 2008 19:52:21 -  1.21
+++ vic.4   31 May 2013 19:55:50 -
@@ -88,6 +88,7 @@ ethernet0.virtualDev = vmxnet
 .Xr netintro 4 ,
 .Xr pci 4 ,
 .Xr pcn 4 ,
+.Xr vmx 4 ,
 .Xr hostname.if 5 ,
 .Xr ifconfig 8
 .Sh AUTHORS
Index: Makefile
===
RCS file: /cvs/src/share/man/man4/Makefile,v
retrieving revision 1.546
diff -u -p -u -p -r1.546 Makefile
--- Makefile19 May 2013 20:32:47 -  1.546
+++ Makefile31 May 2013 19:55:50 -
@@ -67,7 +67,7 @@ MAN=  aac.4 ac97.4 acphy.4 \
uyap.4 \
vether.4 vga.4 vgafb.4 vge.4 \
viapm.4 viasio.4 vic.4 video.4 vio.4 vioblk.4 viomb.4 virtio.4 vlan.4 \
-   vmt.4 vnd.4 vr.4 \
+   vmt.4 vmx.4 vnd.4 vr.4 \
vscsi.4 vte.4 \
watchdog.4 wb.4 wbenv.4 wbng.4 wbsd.4 wbsio.4 wd.4 wdc.4 wdsc.4 we.4 \
wi.4 wpi.4 wscons.4 wsdisplay.4 wskbd.4 wsmouse.4 wsmux.4 \



Re: UPDATE: xf86-input-synaptics 1.7.0

2013-05-31 Thread Martin Pieuchot
On 20/05/13(Mon) 23:57, Alexandr Shadchin wrote:
 On Thu, May 02, 2013 at 10:11:23PM +0600, Alexandr Shadchin wrote:
  Hi,
  
  This update xf86-input-synaptics to the latest release 1.7.0.
  http://koba.devio.us/distfiles/xf86-input-synaptics-1.7.0.diff
  
  Tested on amd64 and i386.
  
  Comments ? OK ?
  
  -- 
  Alexandr Shadchin
  
 
 Prepare diff for xf86-input-synaptics 1.7.1
 http://koba.devio.us/distfiles/xf86-input-synaptics-1.7.1.diff

Tested with an ALPS touchpad, no regression, I'm ok with this going in.

Martin



Re: UPDATE: xf86-input-synaptics 1.7.0

2013-05-31 Thread joshua stein
  Prepare diff for xf86-input-synaptics 1.7.1
  http://koba.devio.us/distfiles/xf86-input-synaptics-1.7.1.diff
 
 Tested with an ALPS touchpad, no regression, I'm ok with this going in.

tested on elantech v4, no problems.  ok jcs@



catopen(3) improvements

2013-05-31 Thread Stefan Sperling
The base system supports localization of error messages in strerror().
catopen(3) is used to read files that contain translated versions
of error messages.

Currently these files have arbitrary encodings. Most are latin1,
one is UTF-8, one is KOI8. These encodings are currently used
regardless of locale, so in some cases the strings look garbled.

The diff below adds support for locale-specific messages, so that
the proper encoding is used for output. Since we lack iconv() in
base we cannot convert messages at runtime. Pre-generated message
files are needed instead.

Existing lib/libc/nls/*.msg files are renamed to the names shown in
the libc/Makefile part of the diff, and new ones are added to support
the UTF-8 locale (converted from the existing .msg files with iconv).
I'm not including this change in the diff since that would mix four
different character sets in a single email.

While here, update catopen(3) to comply with POSIX-2008.

I see no point in listing errno values in the catopen(3) man page.
The current list is incomplete and all errors originate from
library functions that catopen(3) uses.

The complete diff which includes new message files passes make build.
There are distrib/sets changes which I'm not including below either.

Index: lib/libc/Makefile
===
RCS file: /cvs/src/lib/libc/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- lib/libc/Makefile   15 Aug 2012 18:08:22 -  1.31
+++ lib/libc/Makefile   31 May 2013 19:30:12 -
@@ -17,7 +17,11 @@ LDADD=-nodefaultlibs -lgcc
 LIBCSRCDIR=${.CURDIR}
 .include ${LIBCSRCDIR}/Makefile.inc
 
-NLS=   C.msg Pig.msg da.msg de.msg es.msg fi.msg fr.msg nl.msg no.msg ru.msg 
sv.msg it.msg
+NLS=   C.msg Pig.msg da-ISO8859-1.msg da-UTF-8.msg de-ISO8859-1.msg \
+   de-UTF-8.msg es-ISO8859-1.msg es-UTF-8.msg fi-ISO8859-1.msg \
+   fi-UTF-8.msg fr-ISO8859-1.msg fr-UTF-8.msg it-UTF-8.msg \
+   nl-ISO8859-1.msg nl-UTF-8.msg no-ISO8859-1.msg no-UTF-8.msg \
+   ru-KOI8-R.msg ru-UTF-8.msg sv-ISO8859-1.msg sv-UTF-8.msg
 
 copy-to-libkern:   copy-to-libkern-machind copy-to-libkern-machdep
 
Index: lib/libc/nls/catopen.3
===
RCS file: /cvs/src/lib/libc/nls/catopen.3,v
retrieving revision 1.6
diff -u -p -r1.6 catopen.3
--- lib/libc/nls/catopen.3  31 May 2007 19:19:30 -  1.6
+++ lib/libc/nls/catopen.3  31 May 2013 19:45:37 -
@@ -33,9 +33,14 @@ is used with
 substituted for
 .Ql \%N .
 .Pp
-The
+If the
+.Fa oflag
+argument is NL_CAT_LOCALE, the LC_MESSAGES environment variable
+is used to select the message catalog.
+If the
 .Fa oflag
-argument is reserved for future use and should be set to zero.
+argument is zero, the LANG environment variable is used to select
+the message catalog.
 .Sh RETURN VALUES
 Upon successful completion,
 .Fn catopen
@@ -43,11 +48,6 @@ returns a message catalog descriptor.
 Otherwise, \-1 is returned and
 .Va errno
 is set to indicate the error.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory available.
-.El
 .Sh SEE ALSO
 .Xr catclose 3 ,
 .Xr catgets 3
@@ -55,4 +55,4 @@ Insufficient memory available.
 The
 .Fn catopen
 function conforms to
-.St -xpg3 .
+.St -p1003.1-2008 .
Index: lib/libc/nls/catopen.c
===
RCS file: /cvs/src/lib/libc/nls/catopen.c,v
retrieving revision 1.14
diff -u -p -r1.14 catopen.c
--- lib/libc/nls/catopen.c  12 Jul 2011 21:31:20 -  1.14
+++ lib/libc/nls/catopen.c  31 May 2013 19:41:34 -
@@ -41,11 +41,63 @@
 #include fcntl.h
 #include nl_types.h
 
-#define NLS_DEFAULT_PATH /usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L
+#define NLS_DEFAULT_PATH 
/usr/share/nls/%L/%N.cat:/usr/share/nls/%l-%c/%N.cat:/usr/share/nls/%l/%N.cat:
 #define NLS_DEFAULT_LANG C
 
 static nl_catd load_msgcat(const char *);
 
+/*
+ * Helpers for parsing components of locale names.
+ * Locale names are of the form language[_territory][.codeset].
+ * See POSIX-1-2008 8.2 Internationalization Variables
+ */
+
+static char *
+parse_lang(const char *lang)
+{
+   char *sep, *locname;
+
+   locname = strdup(lang);
+   if (locname == NULL)
+   return NULL;
+
+   sep = strchr(locname, '_');
+   if (sep)
+   *sep = '\0';
+
+   return locname;
+}
+
+static char *
+parse_territory(const char *lang)
+{
+   char *sep, *territory;
+
+   sep = strchr(lang, '_');
+   if (sep  strrchr(sep + 1, '.')) {
+   territory = strdup(sep + 1);
+   if (territory) {
+   sep = strrchr(territory, '.');
+   *sep = '\0';
+   return territory;
+   }
+   }
+
+   return NULL;
+}
+
+static char *
+parse_codeset(const char *lang)
+{
+   char *sep;
+
+   sep = strrchr(lang, '.');
+   if (sep)
+   return 

Re: switch /usr/share/locale to different layout

2013-05-31 Thread Stefan Sperling
On Thu, May 30, 2013 at 10:05:45PM +0200, Stefan Sperling wrote:
 Does anyone see problems with this plan?

Haven't heard any objections. Updated diff which contains small
tweaks and patches an mtree file to no longer create directories
for arbitrary locales, some of which we don't even support.

Index: etc/mtree/4.4BSD.dist
===
RCS file: /cvs/src/etc/mtree/4.4BSD.dist,v
retrieving revision 1.229
diff -u -p -r1.229 4.4BSD.dist
--- etc/mtree/4.4BSD.dist   26 Mar 2013 20:03:38 -  1.229
+++ etc/mtree/4.4BSD.dist   31 May 2013 22:44:49 -
@@ -773,381 +773,6 @@ syscall   gname=bin uname=root
 
 # ./usr/share/locale
 locale
-# ./usr/share/locale/bg_BG.CP1251
-bg_BG.CP1251
-# ./usr/share/locale/bg_BG.CP1251
-..
-
-# ./usr/share/locale/ca_ES.ISO8859-1
-ca_ES.ISO8859-1
-# ./usr/share/locale/ca_ES.ISO8859-1
-..
-
-# ./usr/share/locale/ca_ES.ISO8859-15
-ca_ES.ISO8859-15
-# ./usr/share/locale/ca_ES.ISO8859-15
-..
-
-# ./usr/share/locale/cs_CZ.ISO8859-2
-cs_CZ.ISO8859-2
-# ./usr/share/locale/cs_CZ.ISO8859-2
-..
-
-# ./usr/share/locale/da_DK.ISO8859-1
-da_DK.ISO8859-1
-# ./usr/share/locale/da_DK.ISO8859-1
-..
-
-# ./usr/share/locale/da_DK.ISO8859-15
-da_DK.ISO8859-15
-# ./usr/share/locale/da_DK.ISO8859-15
-..
-
-# ./usr/share/locale/de_AT
-de_AT
-# ./usr/share/locale/de_AT
-..
-
-# ./usr/share/locale/de_AT.ISO8859-1
-de_AT.ISO8859-1
-# ./usr/share/locale/de_AT.ISO8859-1
-..
-
-# ./usr/share/locale/de_AT.ISO8859-15
-de_AT.ISO8859-15
-# ./usr/share/locale/de_AT.ISO8859-15
-..
-
-# ./usr/share/locale/de_CH.ISO8859-1
-de_CH.ISO8859-1
-# ./usr/share/locale/de_CH.ISO8859-1
-..
-
-# ./usr/share/locale/de_CH.ISO8859-15
-de_CH.ISO8859-15
-# ./usr/share/locale/de_CH.ISO8859-15
-..
-
-# ./usr/share/locale/de_DE.ISO8859-1
-de_DE.ISO8859-1
-# ./usr/share/locale/de_DE.ISO8859-1
-..
-
-# ./usr/share/locale/de_DE.ISO8859-15
-de_DE.ISO8859-15
-# ./usr/share/locale/de_DE.ISO8859-15
-..
-
-# ./usr/share/locale/el_GR.ISO8859-7
-el_GR.ISO8859-7
-# ./usr/share/locale/el_GR.ISO8859-7
-..
-
-# ./usr/share/locale/en_AU.ISO8859-1
-en_AU.ISO8859-1
-# ./usr/share/locale/en_AU.ISO8859-1
-..
-
-# ./usr/share/locale/en_AU.ISO8859-15
-en_AU.ISO8859-15
-# ./usr/share/locale/en_AU.ISO8859-15
-..
-
-# ./usr/share/locale/en_CA.ISO8859-1
-en_CA.ISO8859-1
-# ./usr/share/locale/en_CA.ISO8859-1
-..
-
-# ./usr/share/locale/en_CA.ISO8859-15
-en_CA.ISO8859-15
-# ./usr/share/locale/en_CA.ISO8859-15
-..
-
-# ./usr/share/locale/en_GB.ISO8859-1
-en_GB.ISO8859-1
-# ./usr/share/locale/en_GB.ISO8859-1
-..
-
-# ./usr/share/locale/en_GB.ISO8859-15
-en_GB.ISO8859-15
-# ./usr/share/locale/en_GB.ISO8859-15
-..
-
-# ./usr/share/locale/en_US.ISO8859-1
-en_US.ISO8859-1
-# ./usr/share/locale/en_US.ISO8859-1
-..
-
-# ./usr/share/locale/en_US.ISO8859-15
-en_US.ISO8859-15
-# ./usr/share/locale/en_US.ISO8859-15
-..
-
-# ./usr/share/locale/en_US.UTF-8
-en_US.UTF-8
-# ./usr/share/locale/en_US.UTF-8
-..
-
-# ./usr/share/locale/es_ES.ISO8859-1
-es_ES.ISO8859-1
-# ./usr/share/locale/es_ES.ISO8859-1
-..
-
-# ./usr/share/locale/es_ES.ISO8859-15
-es_ES.ISO8859-15
-# ./usr/share/locale/es_ES.ISO8859-15
-..
-
-# ./usr/share/locale/fi_FI.ISO8859-1
-fi_FI.ISO8859-1
-# ./usr/share/locale/fi_FI.ISO8859-1
-..
-
-# ./usr/share/locale/fi_FI.ISO8859-15
-fi_FI.ISO8859-15
-# ./usr/share/locale/fi_FI.ISO8859-15
-..
-
-# ./usr/share/locale/fr_BE.ISO8859-1
-fr_BE.ISO8859-1
-# ./usr/share/locale/fr_BE.ISO8859-1
-..
-
-# ./usr/share/locale/fr_BE.ISO8859-15
-fr_BE.ISO8859-15
-# ./usr/share/locale/fr_BE.ISO8859-15
-..
-
-# ./usr/share/locale/fr_CA.ISO8859-1
-fr_CA.ISO8859-1
-# ./usr/share/locale/fr_CA.ISO8859-1
-..
-
-# ./usr/share/locale/fr_CA.ISO8859-15
-fr_CA.ISO8859-15
-# ./usr/share/locale/fr_CA.ISO8859-15
-..
-
-# ./usr/share/locale/fr_CH.ISO8859-1
-fr_CH.ISO8859-1
-# ./usr/share/locale/fr_CH.ISO8859-1
-..
-
-# ./usr/share/locale/fr_CH.ISO8859-15
-fr_CH.ISO8859-15
-# ./usr/share/locale/fr_CH.ISO8859-15
-..
-
-# ./usr/share/locale/fr_FR.ISO8859-1
-fr_FR.ISO8859-1
-# ./usr/share/locale/fr_FR.ISO8859-1
-..
-
-# ./usr/share/locale/fr_FR.ISO8859-15
-fr_FR.ISO8859-15
-# ./usr/share/locale/fr_FR.ISO8859-15
-..
-
-# ./usr/share/locale/hr_HR.ISO8859-2
-hr_HR.ISO8859-2
-# ./usr/share/locale/hr_HR.ISO8859-2
-..
-
-# ./usr/share/locale/hu_HU.ISO8859-2
-hu_HU.ISO8859-2
-# ./usr/share/locale/hu_HU.ISO8859-2
-..
-
-# ./usr/share/locale/hy_AM.ARMSCII-8
-hy_AM.ARMSCII-8
-# ./usr/share/locale/hy_AM.ARMSCII-8
-..
-
-# ./usr/share/locale/is_IS.ISO8859-1
-is_IS.ISO8859-1
-# ./usr/share/locale/is_IS.ISO8859-1
-..
-
-# ./usr/share/locale/is_IS.ISO8859-15
-is_IS.ISO8859-15
-# ./usr/share/locale/is_IS.ISO8859-15
-..
-
-# ./usr/share/locale/it_CH.ISO8859-1
-it_CH.ISO8859-1
-# ./usr/share/locale/it_CH.ISO8859-1
-..
-
-# ./usr/share/locale/it_CH.ISO8859-15
-it_CH.ISO8859-15
-# ./usr/share/locale/it_CH.ISO8859-15
-..
-
-# ./usr/share/locale/it_IT.ISO8859-1
-it_IT.ISO8859-1
-# ./usr/share/locale/it_IT.ISO8859-1
-..
-
-# 

Re: catopen(3) improvements

2013-05-31 Thread Matthew Dempsky
On Fri, May 31, 2013 at 5:19 PM, Stefan Sperling s...@openbsd.org wrote:
 Existing lib/libc/nls/*.msg files are renamed to the names shown in
 the libc/Makefile part of the diff, and new ones are added to support
 the UTF-8 locale (converted from the existing .msg files with iconv).
 I'm not including this change in the diff since that would mix four
 different character sets in a single email.

Is it possible for us to use UTF-8 for all of the source files, but
convert them to KOI8 or ISO-8859-1 as appropriate at build/install
time?  Or is that what you mean by we don't have iconv in base, so
there's no functionality in base for converting between two charsets?



Re: catopen(3) improvements

2013-05-31 Thread Stefan Sperling
On Fri, May 31, 2013 at 05:34:34PM -0700, Matthew Dempsky wrote:
 On Fri, May 31, 2013 at 5:19 PM, Stefan Sperling s...@openbsd.org wrote:
  Existing lib/libc/nls/*.msg files are renamed to the names shown in
  the libc/Makefile part of the diff, and new ones are added to support
  the UTF-8 locale (converted from the existing .msg files with iconv).
  I'm not including this change in the diff since that would mix four
  different character sets in a single email.
 
 Is it possible for us to use UTF-8 for all of the source files, but
 convert them to KOI8 or ISO-8859-1 as appropriate at build/install
 time?  Or is that what you mean by we don't have iconv in base, so
 there's no functionality in base for converting between two charsets?

Yes. Conversion currently depends on the GNU iconv port.
If iconv existed in base we could use just the UTF-8 source files.



Re: catopen(3) improvements

2013-05-31 Thread Matthew Dempsky
On Fri, May 31, 2013 at 5:43 PM, Stefan Sperling s...@openbsd.org wrote:
 Yes. Conversion currently depends on the GNU iconv port.
 If iconv existed in base we could use just the UTF-8 source files.

Hmm, I see.  In that case, I guess committing converted files makes sense.

In your man page diff, you should make use of .Dv and .Ev to identify
the defines and environment variables.

Instead of setting FD_CLOEXEC with fcntl(), just use O_CLOEXEC when opening.

It looks like parse_lang() won't handle locales like C.UTF-8 because
there's no '_'.

I think you should be able to implement the %l/%t/%c stuff without
needing to call strdup() for each one (e.g., by just doing a one time
pass over the locale string up front and noting where the '_' and '.'
chars are).  Otherwise, you should report strdup() failures as ENOMEM
to the catopen() caller, I think.



Re: catopen(3) improvements

2013-05-31 Thread Alexander Bluhm
On Sat, Jun 01, 2013 at 02:19:26AM +0200, Stefan Sperling wrote:
 -NLS= C.msg Pig.msg da.msg de.msg es.msg fi.msg fr.msg nl.msg no.msg ru.msg 
 sv.msg it.msg
 +NLS= C.msg Pig.msg da-ISO8859-1.msg da-UTF-8.msg de-ISO8859-1.msg \
 + de-UTF-8.msg es-ISO8859-1.msg es-UTF-8.msg fi-ISO8859-1.msg \
 + fi-UTF-8.msg fr-ISO8859-1.msg fr-UTF-8.msg it-UTF-8.msg \
 + nl-ISO8859-1.msg nl-UTF-8.msg no-ISO8859-1.msg no-UTF-8.msg \
 + ru-KOI8-R.msg ru-UTF-8.msg sv-ISO8859-1.msg sv-UTF-8.msg

Why not use a . to separate language from codeset here for consistency?
Like de.UTF-8

bluhm



Re: catopen(3) improvements

2013-05-31 Thread Stefan Sperling
On Fri, May 31, 2013 at 06:01:14PM -0700, Matthew Dempsky wrote:
 In your man page diff, you should make use of .Dv and .Ev to identify
 the defines and environment variables.
 
 Instead of setting FD_CLOEXEC with fcntl(), just use O_CLOEXEC when opening.
 
 It looks like parse_lang() won't handle locales like C.UTF-8 because
 there's no '_'.

Fixed.

 I think you should be able to implement the %l/%t/%c stuff without
 needing to call strdup() for each one (e.g., by just doing a one time
 pass over the locale string up front and noting where the '_' and '.'
 chars are).  Otherwise, you should report strdup() failures as ENOMEM
 to the catopen() caller, I think.

Nice, this makes the diff a lot smaller. Thanks!

Also using dots in filenames as suggested by bluhm.

Index: lib/libc/Makefile
===
RCS file: /cvs/src/lib/libc/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- lib/libc/Makefile   15 Aug 2012 18:08:22 -  1.31
+++ lib/libc/Makefile   1 Jun 2013 01:22:57 -
@@ -17,7 +17,11 @@ LDADD=-nodefaultlibs -lgcc
 LIBCSRCDIR=${.CURDIR}
 .include ${LIBCSRCDIR}/Makefile.inc
 
-NLS=   C.msg Pig.msg da.msg de.msg es.msg fi.msg fr.msg nl.msg no.msg ru.msg 
sv.msg it.msg
+NLS=   C.msg Pig.msg da.ISO8859-1.msg da.UTF-8.msg de.ISO8859-1.msg \
+   de.UTF-8.msg es.ISO8859-1.msg es.UTF-8.msg fi.ISO8859-1.msg \
+   fi.UTF-8.msg fr.ISO8859-1.msg fr.UTF-8.msg it.UTF-8.msg \
+   nl.ISO8859-1.msg nl.UTF-8.msg no.ISO8859-1.msg no.UTF-8.msg \
+   ru-KOI8-R.msg ru.UTF-8.msg sv.ISO8859-1.msg sv.UTF-8.msg
 
 copy-to-libkern:   copy-to-libkern-machind copy-to-libkern-machdep
 
Index: lib/libc/nls/catopen.3
===
RCS file: /cvs/src/lib/libc/nls/catopen.3,v
retrieving revision 1.6
diff -u -p -r1.6 catopen.3
--- lib/libc/nls/catopen.3  31 May 2007 19:19:30 -  1.6
+++ lib/libc/nls/catopen.3  1 Jun 2013 01:24:33 -
@@ -33,9 +33,18 @@ is used with
 substituted for
 .Ql \%N .
 .Pp
-The
+If the
+.Fa oflag
+argument is
+.Dv NL_CAT_LOCALE ,
+the
+.Ev LC_MESSAGES
+environment variable is used to select the message catalog.
+If the
 .Fa oflag
-argument is reserved for future use and should be set to zero.
+argument is zero, the
+.Ev LANG
+environment variable is used to select the message catalog.
 .Sh RETURN VALUES
 Upon successful completion,
 .Fn catopen
@@ -43,11 +52,6 @@ returns a message catalog descriptor.
 Otherwise, \-1 is returned and
 .Va errno
 is set to indicate the error.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory available.
-.El
 .Sh SEE ALSO
 .Xr catclose 3 ,
 .Xr catgets 3
@@ -55,4 +59,4 @@ Insufficient memory available.
 The
 .Fn catopen
 function conforms to
-.St -xpg3 .
+.St -p1003.1-2008 .
Index: lib/libc/nls/catopen.c
===
RCS file: /cvs/src/lib/libc/nls/catopen.c,v
retrieving revision 1.14
diff -u -p -r1.14 catopen.c
--- lib/libc/nls/catopen.c  12 Jul 2011 21:31:20 -  1.14
+++ lib/libc/nls/catopen.c  1 Jun 2013 02:11:10 -
@@ -41,7 +41,7 @@
 #include fcntl.h
 #include nl_types.h
 
-#define NLS_DEFAULT_PATH /usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L
+#define NLS_DEFAULT_PATH 
/usr/share/nls/%L/%N.cat:/usr/share/nls/%l.%c/%N.cat:/usr/share/nls/%l/%N.cat
 #define NLS_DEFAULT_LANG C
 
 static nl_catd load_msgcat(const char *);
@@ -53,7 +53,7 @@ _catopen(const char *name, int oflag)
char tmppath[PATH_MAX];
char *nlspath;
char *lang;
-   char *s, *t;
+   char *s, *t, *sep, *dot;
const char *u;
nl_catd catd;

@@ -66,28 +66,66 @@ _catopen(const char *name, int oflag)
 
if (issetugid() != 0 || (nlspath = getenv(NLSPATH)) == NULL)
nlspath = NLS_DEFAULT_PATH;
-   if ((lang = getenv(LANG)) == NULL)
+
+   lang = NULL;
+   if (oflag  NL_CAT_LOCALE)
+   lang = getenv(LC_MESSAGES);
+   if (lang == NULL)
+   lang = getenv(LANG);
+   if (lang == NULL)
+   lang = NLS_DEFAULT_LANG;
+   if (strcmp(lang, POSIX) == 0)
lang = NLS_DEFAULT_LANG;
 
s = nlspath;
-   t = tmppath;
+   t = tmppath;
+
+   /*
+* Locale names are of the form language[_territory][.codeset].
+* See POSIX-1-2008 8.2 Internationalization Variables
+*/
+   sep = strchr(lang, '_');
+   dot = strrchr(lang, '.');
do {
while (*s  *s != ':') {
if (*s == '%') {
switch (*(++s)) {
-   case 'L':   /* locale */
+   case 'L':   /* LANG or LC_MESSAGES */
u = lang;
while (*u  t  tmppath + PATH_MAX-1)
*t++ = 

mg(1) M-} forward para diff

2013-05-31 Thread Mark Lumsden
A while back, I committed a diff that fixed scrolling backwards by
 paragraph in mg. I thought I would give it a while before writing the
corresponding diff for going forwards, just to make sure there were no
problems with the first diff. 

So here it is. Before you compile this diff, (and if you are using mg)
put your cursor on the very first character of the first paragraph -
an 'A', then do M-} your cursor stops on the 2nd line. In emacs it
would stop on the 5th line. Currently mg stops moving forward when it
finds a new line with a space on the first character, this diff checks
the whole line before determinig if the line is a paragraph break or
not. 

ok?

mark

Index: paragraph.c
===
RCS file: /cvs/src/usr.bin/mg/paragraph.c,v
retrieving revision 1.24
diff -u -p -r1.24 paragraph.c
--- paragraph.c 19 May 2013 10:27:11 -  1.24
+++ paragraph.c 1 Jun 2013 05:40:02 -
@@ -63,37 +63,32 @@ gotobop(int f, int n)
 int
 gotoeop(int f, int n)
 {
+   int col;
+   int nospace = 0;
+
/* the other way... */
if (n  0)
return (gotobop(f, -n));
 
/* for each one asked for */
while (n--  0) {
-   /* Find the first word on/after the current line */
-   curwp-w_doto = 0;
-   while (forwchar(FFRAND, 1)  inword() == 0);
+   while (lforw(curwp-w_dotp) != curbp-b_headp) {
+   col = 0;
+   curwp-w_doto = 0;
 
-   curwp-w_doto = 0;
-   curwp-w_dotp = lforw(curwp-w_dotp);
+   while (col  llength(curwp-w_dotp) 
+   (isspace(lgetc(curwp-w_dotp, col
+   col++;
 
-   /* and scan forword until we hit a NLSP or ... */
-   while (curwp-w_dotp != curbp-b_headp) {
-   if (llength(curwp-w_dotp) 
-   lgetc(curwp-w_dotp, 0) != ' ' 
-   lgetc(curwp-w_dotp, 0) != '.' 
-   lgetc(curwp-w_dotp, 0) != '\t') {
-   curwp-w_dotp = lforw(curwp-w_dotp);
-   curwp-w_dotline++;
+   if (col = llength(curwp-w_dotp)) {
+   if (nospace)
+   break;
} else
-   break;
-   }
-   if (curwp-w_dotp == curbp-b_headp) {
-   /* beyond end of buffer, cleanup time */
-   curwp-w_dotp = lback(curwp-w_dotp);
-   curwp-w_doto = llength(curwp-w_dotp);
-   break;
-   } else
+   nospace = 1;
+
+   curwp-w_dotp = lforw(curwp-w_dotp);
curwp-w_dotline++;
+   }
}
/* force screen update */
curwp-w_rflag |= WFMOVE;