svn commit: r235773 - head/contrib/ncurses/man

2012-05-22 Thread Dimitry Andric
Author: dim
Date: Tue May 22 06:28:53 2012
New Revision: 235773
URL: http://svn.freebsd.org/changeset/base/235773

Log:
  Correct use_screen() and use_window() prototypes in curs_threads(3x).
  
  Submitted by: Yanhui Shen shen@gmail.com
  MFC after:3 days

Modified:
  head/contrib/ncurses/man/curs_threads.3x

Modified: head/contrib/ncurses/man/curs_threads.3x
==
--- head/contrib/ncurses/man/curs_threads.3xTue May 22 05:18:30 2012
(r235772)
+++ head/contrib/ncurses/man/curs_threads.3xTue May 22 06:28:53 2012
(r235773)
@@ -45,9 +45,9 @@
 .br
 \fBint set_tabsize(int size);\fR
 .br
-\fBint use_screen(SCREEN *scr, NCURSES_WINDOW_CB func, void *data);\fR
+\fBint use_screen(SCREEN *scr, NCURSES_SCREEN_CB func, void *data);\fR
 .br
-\fBint use_window(WINDOW *win, NCURSES_SCREEN_CB func, void *data);\fR
+\fBint use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data);\fR
 .br
 .SH DESCRIPTION
 This implementation can be configured to provide rudimentary support
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235774 - head/sys/dev/ath

2012-05-22 Thread Adrian Chadd
Author: adrian
Date: Tue May 22 06:31:03 2012
New Revision: 235774
URL: http://svn.freebsd.org/changeset/base/235774

Log:
  Fix up some corner cases with aggregation handling.
  
  I've come across a weird scenario in net80211 where two TX streams will
  happily attempt to setup an aggregation session together.
  If we're very lucky, it happens concurrently on separate CPUs and the
  total lack of locking in the net80211 aggregation code causes this stuff
  to race. Badly.
  
  So 1 call would occur to the ath(4) addba start, but only one call would
  complete to addba complete or timeout.  The TID would thus stay paused.
  
  The real fix is to implement some proper per-node (or maybe per-TID)
  locking in net80211, which then could be leveraged by the ath(4) TX
  aggregation code.
  
  Whilst I'm at it, shuffle around the debugging messages a bit.
  I like to keep people on their toes.

Modified:
  head/sys/dev/ath/if_ath_tx.c
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_ath_tx.c
==
--- head/sys/dev/ath/if_ath_tx.cTue May 22 06:28:53 2012
(r235773)
+++ head/sys/dev/ath/if_ath_tx.cTue May 22 06:31:03 2012
(r235774)
@@ -1580,21 +1580,21 @@ ath_tx_start(struct ath_softc *sc, struc
 * reached.)
 */
if (txq == avp-av_mcastq) {
-   DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
+   DPRINTF(sc, ATH_DEBUG_SW_TX,
%s: bf=%p: mcastq: TX'ing\n, __func__, bf);
ATH_TXQ_LOCK(txq);
ath_tx_xmit_normal(sc, txq, bf);
ATH_TXQ_UNLOCK(txq);
} else if (type == IEEE80211_FC0_TYPE_CTL 
subtype == IEEE80211_FC0_SUBTYPE_BAR) {
-   DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
+   DPRINTF(sc, ATH_DEBUG_SW_TX,
%s: BAR: TX'ing direct\n, __func__);
ATH_TXQ_LOCK(txq);
ath_tx_xmit_normal(sc, txq, bf);
ATH_TXQ_UNLOCK(txq);
} else {
/* add to software queue */
-   DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
+   DPRINTF(sc, ATH_DEBUG_SW_TX,
%s: bf=%p: swq: TX'ing\n, __func__, bf);
ath_tx_swq(sc, ni, txq, bf);
}
@@ -3113,7 +3113,7 @@ ath_tx_tid_cleanup(struct ath_softc *sc,
struct ath_buf *bf, *bf_next;
ath_bufhead bf_cq;
 
-   DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
+   DPRINTF(sc, ATH_DEBUG_SW_TX_BAW,
%s: TID %d: called\n, __func__, tid);
 
TAILQ_INIT(bf_cq);
@@ -4336,7 +4336,15 @@ ath_addba_request(struct ieee80211_node 
 * fall within it.
 */
ATH_TXQ_LOCK(sc-sc_ac2q[atid-ac]);
-   ath_tx_tid_pause(sc, atid);
+   /*
+* This is a bit annoying.  Until net80211 HT code inherits some
+* (any) locking, we may have this called in parallel BUT only
+* one response/timeout will be called.  Grr.
+*/
+   if (atid-addba_tx_pending == 0) {
+   ath_tx_tid_pause(sc, atid);
+   atid-addba_tx_pending = 1;
+   }
ATH_TXQ_UNLOCK(sc-sc_ac2q[atid-ac]);
 
DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
@@ -4397,6 +4405,7 @@ ath_addba_response(struct ieee80211_node
r = sc-sc_addba_response(ni, tap, status, code, batimeout);
 
ATH_TXQ_LOCK(sc-sc_ac2q[atid-ac]);
+   atid-addba_tx_pending = 0;
/*
 * XXX dirty!
 * Slide the BAW left edge to wherever net80211 left it for us.
@@ -4500,6 +4509,10 @@ ath_addba_response_timeout(struct ieee80
DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
%s: called; resuming\n, __func__);
 
+   ATH_TXQ_LOCK(sc-sc_ac2q[atid-ac]);
+   atid-addba_tx_pending = 0;
+   ATH_TXQ_UNLOCK(sc-sc_ac2q[atid-ac]);
+
/* Note: This updates the aggregate state to (again) pending */
sc-sc_addba_response_timeout(ni, tap);
 

Modified: head/sys/dev/ath/if_athvar.h
==
--- head/sys/dev/ath/if_athvar.hTue May 22 06:28:53 2012
(r235773)
+++ head/sys/dev/ath/if_athvar.hTue May 22 06:31:03 2012
(r235774)
@@ -106,6 +106,7 @@ struct ath_tid {
TAILQ_ENTRY(ath_tid)axq_qelem;
int sched;
int paused; /* 0 if the TID has been paused */
+   int addba_tx_pending;   /* TX ADDBA pending */
int bar_wait;   /* waiting for BAR */
int bar_tx; /* BAR TXed */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235775 - head/sys/modules/bwi

2012-05-22 Thread Ulrich Spoerlein
Author: uqs
Date: Tue May 22 06:33:08 2012
New Revision: 235775
URL: http://svn.freebsd.org/changeset/base/235775

Log:
  Fix make depend.

Modified:
  head/sys/modules/bwi/Makefile

Modified: head/sys/modules/bwi/Makefile
==
--- head/sys/modules/bwi/Makefile   Tue May 22 06:31:03 2012
(r235774)
+++ head/sys/modules/bwi/Makefile   Tue May 22 06:33:08 2012
(r235775)
@@ -5,7 +5,7 @@
 KMOD   = if_bwi
 
 SRCS   = if_bwi.c if_bwi_pci.c bwimac.c bwiphy.c bwirf.c
-SRCS   += device_if.h bus_if.h pci_if.h opt_inet.h opt_bwi.h
+SRCS   += device_if.h bus_if.h pci_if.h opt_inet.h opt_bwi.h opt_wlan.h
 
 opt_bwi.h:
echo '#define BWI_DEBUG 1'  opt_bwi.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235739 - head/lib/libc/gen

2012-05-22 Thread Bruce Evans

On Mon, 21 May 2012, Guy Helmer wrote:


Log:
 Apply style(9) to return and switch/case statements.

 Reviewed by:   delphij (prior version of the patch)

Modified:
 head/lib/libc/gen/getnetgrent.c

Modified: head/lib/libc/gen/getnetgrent.c
==
--- head/lib/libc/gen/getnetgrent.c Mon May 21 19:58:40 2012
(r235738)
+++ head/lib/libc/gen/getnetgrent.c Mon May 21 21:04:29 2012
(r235739)
...
@@ -311,32 +311,35 @@ _revnetgr_lookup(char* lookupdom, char*

for (rot = 0; ; rot++) {
switch (rot) {
-   case(0): snprintf(key, MAXHOSTNAMELEN, %s.%s,
- str, dom?dom:lookupdom);
-break;
-   case(1): snprintf(key, MAXHOSTNAMELEN, %s.*,
- str);
-break;
-   case(2): snprintf(key, MAXHOSTNAMELEN, *.%s,
- dom?dom:lookupdom);
-break;
-   case(3): snprintf(key, MAXHOSTNAMELEN, *.*);
-break;
-   default: return(0);
+   case(0):
+   snprintf(key, MAXHOSTNAMELEN, %s.%s, str,
+   dom ? dom : lookupdom);
+   break;
+   case(1):
+   snprintf(key, MAXHOSTNAMELEN, %s.*, str);
+   break;
+   case(2):
+   snprintf(key, MAXHOSTNAMELEN, *.%s,
+   dom ? dom : lookupdom);
+   break;
+   case(3):
+   snprintf(key, MAXHOSTNAMELEN, *.*);
+   break;


Thanks, but a fuller application would have removed the obfuscatory
parentheses that make case() look like a function call...


+   default: return (0);


... and split the case statements after : in all cases.


}
y = yp_match(lookupdom, map, key, strlen(key), result,
 resultlen);


You fixed the continuation indentation in the case statement but not here.


if (y == 0) {
rv = _listmatch(result, group, resultlen);
free(result);
-   if (rv) return(1);
+   if (rv) return (1);


Another statement not started on a new line.


} else if (y != YPERR_KEY) {
/*
 * If we get an error other than 'no
 * such key in map' then something is
 * wrong and we should stop the search.
 */
-   return(-1);
+   return (-1);
}
}
}


These style bugs weren't in the CSRG version of course.  The YP code added
many.  The most obvious ones are the case(n) and gnu-style continuation
indentation.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235776 - head/sys/vm

2012-05-22 Thread Andrew Turner
Author: andrew
Date: Tue May 22 07:04:23 2012
New Revision: 235776
URL: http://svn.freebsd.org/changeset/base/235776

Log:
  Fix booting on ARM.
  
  In PHYS_TO_VM_PAGE() when VM_PHYSSEG_DENSE is set the check if we are past
  the end of vm_page_array was incorrect causing it to return NULL. This
  value is then used in vm_phys_add_page causing a data abort.
  
  Reviewed by:  alc, kib, imp
  Tested by:stas

Modified:
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Tue May 22 06:33:08 2012(r235775)
+++ head/sys/vm/vm_page.c   Tue May 22 07:04:23 2012(r235776)
@@ -647,7 +647,7 @@ PHYS_TO_VM_PAGE(vm_paddr_t pa)
long pi;
 
pi = atop(pa);
-   if (pi = first_page  pi  vm_page_array_size) {
+   if (pi = first_page  (pi - first_page)  vm_page_array_size) {
m = vm_page_array[pi - first_page];
return (m);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235777 - head/sys/kern

2012-05-22 Thread Hartmut Brandt
Author: harti
Date: Tue May 22 07:23:41 2012
New Revision: 235777
URL: http://svn.freebsd.org/changeset/base/235777

Log:
  Make dumptid non-static. It is used by libkvm to detect whether
  this is a VNET-kernel or not. gcc used to put the static symbol into
  the symbol table, clang does not. This fixes the 'netstat: no namelist'
  error seen on clang+VNET systems.

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Tue May 22 07:04:23 2012
(r235776)
+++ head/sys/kern/kern_shutdown.c   Tue May 22 07:23:41 2012
(r235777)
@@ -151,7 +151,7 @@ static struct dumperinfo dumper;/* our 
 
 /* Context information for dump-debuggers. */
 static struct pcb dumppcb; /* Registers. */
-static lwpid_t dumptid;/* Thread ID. */
+lwpid_t dumptid;   /* Thread ID. */
 
 static void poweroff_wait(void *, int);
 static void shutdown_halt(void *junk, int howto);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235778 - in head/sys: boot/fdt/dts conf dev/fdt geom sys

2012-05-22 Thread Grzegorz Bernacki
Author: gber
Date: Tue May 22 08:33:14 2012
New Revision: 235778
URL: http://svn.freebsd.org/changeset/base/235778

Log:
  Add a new geom class which allows to divide NAND Flash chip
  into partitions.
  
  Partitions are created based on data in dts file which are
  extracted and interpreted by slicer.
  
  Obtained from: Semihalf
  Supported by:  FreeBSD Foundation, Juniper Networks

Added:
  head/sys/dev/fdt/fdt_slicer.c   (contents, props changed)
  head/sys/geom/geom_flashmap.c   (contents, props changed)
  head/sys/sys/slicer.h   (contents, props changed)
Modified:
  head/sys/boot/fdt/dts/sheevaplug.dts
  head/sys/conf/files
  head/sys/dev/fdt/fdt_common.h

Modified: head/sys/boot/fdt/dts/sheevaplug.dts
==
--- head/sys/boot/fdt/dts/sheevaplug.dtsTue May 22 07:23:41 2012
(r235777)
+++ head/sys/boot/fdt/dts/sheevaplug.dtsTue May 22 08:33:14 2012
(r235778)
@@ -88,7 +88,16 @@
bank-width = 2;
device-width = 1;
 
+   slice@0 {
+   reg = 0x0 0x20;
+   label = u-boot;
+   read-only;
+   };
 
+   slice@20 {
+   reg = 0x20 0x1fe0;
+   label = root;
+   };
};
};
 

Modified: head/sys/conf/files
==
--- head/sys/conf/files Tue May 22 07:23:41 2012(r235777)
+++ head/sys/conf/files Tue May 22 08:33:14 2012(r235778)
@@ -1223,6 +1223,7 @@ dev/fatm/if_fatm.coptional fatm pci
 dev/fb/splash.coptional splash
 dev/fdt/fdt_common.c   optional fdt
 dev/fdt/fdt_pci.c  optional fdt pci
+dev/fdt/fdt_slicer.c   optional fdt cfi | fdt nand
 dev/fdt/fdt_static_dtb.S   optional fdt fdt_dtb_static
 dev/fdt/fdtbus.c   optional fdt
 dev/fdt/simplebus.coptional fdt
@@ -2388,6 +2389,7 @@ geom/geom_disk.c  standard
 geom/geom_dump.c   standard
 geom/geom_event.c  standard
 geom/geom_fox.coptional geom_fox
+geom/geom_flashmap.c   optional fdt cfi | fdt nand
 geom/geom_io.c standard
 geom/geom_kern.c   standard
 geom/geom_map.coptional geom_map

Modified: head/sys/dev/fdt/fdt_common.h
==
--- head/sys/dev/fdt/fdt_common.h   Tue May 22 07:23:41 2012
(r235777)
+++ head/sys/dev/fdt/fdt_common.h   Tue May 22 08:33:14 2012
(r235778)
@@ -32,6 +32,7 @@
 #ifndef _FDT_COMMON_H_
 #define _FDT_COMMON_H_
 
+#include sys/slicer.h
 #include contrib/libfdt/libfdt_env.h
 #include dev/ofw/ofw_bus.h
 #include machine/fdt.h

Added: head/sys/dev/fdt/fdt_slicer.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/fdt/fdt_slicer.c   Tue May 22 08:33:14 2012
(r235778)
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2012 Semihalf.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/kernel.h
+#include sys/module.h
+#include sys/slicer.h
+
+#include dev/fdt/fdt_common.h
+
+#define DEBUG
+#undef DEBUG
+
+#ifdef DEBUG
+#define debugf(fmt, args...) do { printf(%s(): , __func__);  

svn commit: r235779 - head/sys/boot/fdt/dts

2012-05-22 Thread Grzegorz Bernacki
Author: gber
Date: Tue May 22 09:27:57 2012
New Revision: 235779
URL: http://svn.freebsd.org/changeset/base/235779

Log:
  Divide nand flash for DB6281 into two partitions. One for u-boot
  and second one for general use.
  
  Obtained from: Semihalf
  Supported by:  FreeBSD Foundation, Juniper Networks

Modified:
  head/sys/boot/fdt/dts/db88f6281.dts

Modified: head/sys/boot/fdt/dts/db88f6281.dts
==
--- head/sys/boot/fdt/dts/db88f6281.dts Tue May 22 08:33:14 2012
(r235778)
+++ head/sys/boot/fdt/dts/db88f6281.dts Tue May 22 09:27:57 2012
(r235779)
@@ -89,7 +89,16 @@
bank-width = 2;
device-width = 1;
 
+   slice@0 {
+   reg = 0x0 0x20;
+   label = u-boot;
+   read-only;
+   };
 
+   slice@20 {
+   reg = 0x20 0x7e0;
+   label = root;
+   };
};
};
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235780 - head/include

2012-05-22 Thread Hartmut Brandt
Author: harti
Date: Tue May 22 09:59:49 2012
New Revision: 235780
URL: http://svn.freebsd.org/changeset/base/235780

Log:
  Fix a compilation error with some compilers: __attribute__
  requires two parenthesis for its argument, but instead of using
  __attribute__ directly, use the appropriate __nonnull macro
  from cdefs.h.

Modified:
  head/include/malloc_np.h

Modified: head/include/malloc_np.h
==
--- head/include/malloc_np.hTue May 22 09:27:57 2012(r235779)
+++ head/include/malloc_np.hTue May 22 09:59:49 2012(r235780)
@@ -55,13 +55,11 @@ int mallctlbymib(const size_t *mib, size
 #defineALLOCM_ERR_OOM  1
 #defineALLOCM_ERR_NOT_MOVED2
 
-intallocm(void **ptr, size_t *rsize, size_t size, int flags)
-__attribute__(nonnull(1));
+intallocm(void **ptr, size_t *rsize, size_t size, int flags) __nonnull(1);
 intrallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
-int flags) __attribute__(nonnull(1));
-intsallocm(const void *ptr, size_t *rsize, int flags)
-__attribute__(nonnull(1));
-intdallocm(void *ptr, int flags) __attribute__(nonnull(1));
+int flags) __nonnull(1);
+intsallocm(const void *ptr, size_t *rsize, int flags) __nonnull(1);
+intdallocm(void *ptr, int flags) __nonnull(1);
 intnallocm(size_t *rsize, size_t size, int flags);
 __END_DECLS
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Dag-Erling Smørgrav
Baptiste Daroussin b...@freebsd.org writes:
 Log:
   Import byacc from invisible island, it brings us lots of compatibilities 
 with
   bison, keeping full compatibility with our previous yacc
   implementation.

This commit broke the build, in large part because Baptiste tested with
Clang instead of GCC, and GCC generates a warning when compiling the
generated code.  Baptiste has a patch ready to commit, currently
undergoing review by myself and other interested parties.

I chose not to ask Baptiste to revert the commit, because it is a
complex commit that copies some files from a vendor branch into contrib
and removes others from the usr.bin/yacc, and I wasn't sure that
reverting it wouldn't cause trouble with merge tracking.

Lessons learned:

1) always test a *stock* build before committing:

   % cd /usr/src  env __MAKE_CONF=/dev/null make buildworld

2) the contrib part and the usr.bin part should probably have been
   committed separately.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235767 - head/lib/libc/net

2012-05-22 Thread Bruce Evans

On Mon, 21 May 2012, Garrett Cooper wrote:


On Mon, May 21, 2012 at 6:28 PM, Kevin Lo ke...@freebsd.org wrote:

Author: kevlo
Date: Tue May 22 01:28:32 2012
New Revision: 235767
URL: http://svn.freebsd.org/changeset/base/235767

Log:
?Add missing header needed by free()

?Reported by: ?tinderbox


Please don't use binary characters in mail.


Thank you for saving my mailbox :)!!!

FWIW, it's weird because my STABLE-9 box didn't reproduce this.


This seems to be a bug in both nsparser.y and the new yacc:
- new yacc: it is incompatible.

  Old yacc includes stdlib.h and string.h as the first thing in the
  generated file, so the C code copied from the .y part sees them too.

  New yacc puts more its code including its all includes (which still
  involve stdlib.h) at the end of the generated file.

  Including stdlib.h nearly first is from Lite2 (skeleton.c 1.7 in 1997).
  Much later, FreeBSD moved it to the very first thing in the generated
  file, so as to use namespace pollution (__unused) from it early.
  __unused was ifdefed and was defined by the yacc skeleton if stdlib.h
  didn't define it.  It took much churn to produce this, but it seems to
  have been garbage, since old yacc didn't actually generate any use of
  __unused.  The definition was apparently compatibilty cruft to hide
  unportabilities in .y files that use __unused (I guess these failed for
  bootstrapping).  New yacc doesn't define __unused.

- nsparser.y: it uses free() but never declared it.  It depended on
  namespace pollution in the yacc code, and this pollution being in a
  particular order.

The yyparse() incompatibilities seem to be bugs on both sides too:
- Old yacc didn't declare yyparse() automatically, so .y files had to do
  it, but probably shouldn't have.

- New yacc still doesn't declare yylex() or yyerror() automatically, so
  applications still have to declare them.

- Some of these may be more the responsibility of the yacc library (to
  supply defaults) than others.  I couldn't see who is required to declare
  them in POSIX.1-2001.  However, a bad example in POSIX.1 has extern int
  yyparse(); in main() just before calling yyparse().  Badness in this
  example include several style bugs and the declaration being incomplete
  (missing void).
Old yacc has about 20 lines of ifdefs half just to supply this void
for STDC but not for KR.  New yacc no longer supports KR, at least
here, but it still has 11 lines of ifdefs to get the declaration of
yyparse() right for bison compatibility).
  I don't know if the badness includes having the home made declaration.

Nearby bugs: all CSRG and FreeBSD changes including copyrights and
history seem to have been lost.  Just after the old include of stdlib.h,
skeleton.c used to produce a string yyrcsid[] with __FBSDID() for
skeleton.c itself in it.  New yacc generates a string yysccsid with
a hard-coded berkeley 1993 id in it, and the name in this id doesn't
even match the file name (it is yaccpar).  Another FreeBSD change was
to remove this bogus id from the generated file.

Some relevant FreeBSD changes:

% Index: skeleton.c
% ===
% RCS file: /home/ncvs/src/usr.bin/yacc/skeleton.c,v
% retrieving revision 1.1.1.2
% retrieving revision 1.37
% diff -u -2 -r1.1.1.2 -r1.37
% --- skeleton.c6 Jan 1997 03:03:46 -   1.1.1.2
% +++ skeleton.c12 Feb 2003 18:03:55 -  1.37
% @@ -35,7 +35,12 @@
%   */
% 
% +#if 0

%  #ifndef lint
%  static char sccsid[] = @(#)skeleton.c  5.8 (Berkeley) 4/29/95;
% -#endif /* not lint */
% +#endif
% +#endif

FreeBSD normally comments out vendor ids like this.  5.8 is from Lite2;
Lite1 had 5.7.  New yacc doesn't have any of this.  It apparently started
from older yacc (before Lite1; indeed, it agrees with the FreeBSD-1 == Net/2
version in not having any CSRG copyrights or this sccsid).

% +
% +#include sys/cdefs.h
% +__FBSDID($FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.37 2003/02/12 18:03:55 davidc 
Exp $);

FreeBSD normally adds this to source files.  Except in contrib.  yacc is
now mostly in contrib, although it hasn't changed all that much.

% 
%  #include defs.h

% @@ -53,31 +58,42 @@
%  /*  are conditional. */
% 
% -char *banner[] =

% +const char *banner[] =

New yacc has this change too.

%  {
% +#include stdlib.h,

See above.

%  #ifndef lint,
% -static char yysccsid[] = \@(#)yaccpar1.9 (Berkeley) 
02/21/93\;,

Was in Net/2 (?), FreeBSD-1, Lite1 and Lite2.  Came back with new yacc.
It's interesting that yaccpar 1.9 (Berkeley) 1.9 02/21/93 is only 3 months
before the correct id skeleton.c 5.7 (Berkeley) 5/24/93.

Hmm, the FreeBSD-1 history is even more instructive than I first
thought.  FreeBSD-1 started with the CSRG version of skeleton.c on
1993/06/12.  This had CSRG copyrights and ids, and yaccpar was at 1.8
01/20/90.  But this was upgraded to the newest version on

svn commit: r235781 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2012-05-22 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue May 22 10:54:42 2012
New Revision: 235781
URL: http://svn.freebsd.org/changeset/base/235781

Log:
  Fix enforcement of file size limit with O_APPEND on ZFS.
  
  vn_rlimit_fsize takes uio-uio_offset and uio-uio_resid into account
  when determining whether given write would exceed RLIMIT_FSIZE.
  
  When APPEND flag is specified, ZFS updates uio-uio_offset to point to the
  end of file.
  
  But this happens after a call to vn_rlimit_fsize, so vn_rlimit_fsize check
  can be rendered ineffective by thread that opens some file with O_APPEND
  and lseeks below RLIMIT_FSIZE before calling write.
  
  Submitted by: Mateusz Guzik mjguzik at gmail dot com
  MFC after:2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue May 
22 09:59:49 2012(r235780)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue May 
22 10:54:42 2012(r235781)
@@ -838,6 +838,12 @@ zfs_write(vnode_t *vp, uio_t *uio, int i
rl = zfs_range_lock(zp, woff, n, RL_WRITER);
}
 
+   if (vn_rlimit_fsize(vp, uio, uio-uio_td)) {
+   zfs_range_unlock(rl);
+   ZFS_EXIT(zfsvfs);
+   return (EFBIG);
+   }
+
if (woff = limit) {
zfs_range_unlock(rl);
ZFS_EXIT(zfsvfs);
@@ -5696,9 +5702,6 @@ zfs_freebsd_write(ap)
} */ *ap;
 {
 
-   if (vn_rlimit_fsize(ap-a_vp, ap-a_uio, ap-a_uio-uio_td))
-   return (EFBIG);
-
return (zfs_write(ap-a_vp, ap-a_uio, ioflags(ap-a_ioflag),
ap-a_cred, NULL));
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235782 - in head/sys: dev/agp modules/agp sys

2012-05-22 Thread Konstantin Belousov
Author: kib
Date: Tue May 22 10:59:26 2012
New Revision: 235782
URL: http://svn.freebsd.org/changeset/base/235782

Log:
  A rewrite of the i810 bits of the agp(4) driver.  New driver supports
  operations required by GEMified i915.ko. It also attaches to SandyBridge
  and IvyBridge CPU northbridges now.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 month

Added:
  head/sys/dev/agp/agp_i810.h   (contents, props changed)
Modified:
  head/sys/dev/agp/agp.c
  head/sys/dev/agp/agp_i810.c
  head/sys/dev/agp/agp_if.m
  head/sys/dev/agp/agppriv.h
  head/sys/dev/agp/agpreg.h
  head/sys/dev/agp/agpvar.h
  head/sys/modules/agp/Makefile
  head/sys/sys/agpio.h

Modified: head/sys/dev/agp/agp.c
==
--- head/sys/dev/agp/agp.c  Tue May 22 10:54:42 2012(r235781)
+++ head/sys/dev/agp/agp.c  Tue May 22 10:59:26 2012(r235782)
@@ -239,7 +239,8 @@ agp_generic_attach(device_t dev)
if (memsize = agp_max[i][0])
break;
}
-   if (i == agp_max_size) i = agp_max_size - 1;
+   if (i == agp_max_size)
+   i = agp_max_size - 1;
sc-as_maxmem = agp_max[i][1]  20U;
 
/*
@@ -803,6 +804,13 @@ agp_unbind_user(device_t dev, agp_unbind
 }
 
 static int
+agp_chipset_flush(device_t dev)
+{
+
+   return (AGP_CHIPSET_FLUSH(dev));
+}
+
+static int
 agp_open(struct cdev *kdev, int oflags, int devtype, struct thread *td)
 {
device_t dev = kdev-si_drv1;
@@ -869,6 +877,8 @@ agp_ioctl(struct cdev *kdev, u_long cmd,
case AGPIOC_UNBIND:
return agp_unbind_user(dev, (agp_unbind *)data);
 
+   case AGPIOC_CHIPSET_FLUSH:
+   return agp_chipset_flush(dev);
}
 
return EINVAL;

Modified: head/sys/dev/agp/agp_i810.c
==
--- head/sys/dev/agp/agp_i810.c Tue May 22 10:54:42 2012(r235781)
+++ head/sys/dev/agp/agp_i810.c Tue May 22 10:59:26 2012(r235782)
@@ -1,8 +1,12 @@
 /*-
  * Copyright (c) 2000 Doug Rabson
  * Copyright (c) 2000 Ruslan Ermilov
+ * Copyright (c) 2011 The FreeBSD Foundation
  * All rights reserved.
  *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -28,6 +32,9 @@
 /*
  * Fixes for 830/845G support: David Dawes da...@xfree86.org
  * 852GM/855GM/865G support added by David Dawes da...@xfree86.org
+ *
+ * This is generic Intel GTT handling code, morphed from the AGP
+ * bridge code.
  */
 
 #include sys/cdefs.h
@@ -35,10 +42,17 @@ __FBSDID($FreeBSD$);
 
 #include opt_bus.h
 
+#if 0
+#defineKTR_AGP_I810KTR_DEV
+#else
+#defineKTR_AGP_I8100
+#endif
+
 #include sys/param.h
 #include sys/systm.h
 #include sys/malloc.h
 #include sys/kernel.h
+#include sys/ktr.h
 #include sys/module.h
 #include sys/bus.h
 #include sys/lock.h
@@ -47,8 +61,10 @@ __FBSDID($FreeBSD$);
 
 #include dev/agp/agppriv.h
 #include dev/agp/agpreg.h
+#include dev/agp/agp_i810.h
 #include dev/pci/pcivar.h
 #include dev/pci/pcireg.h
+#include dev/pci/pci_private.h
 
 #include vm/vm.h
 #include vm/vm_object.h
@@ -63,6 +79,88 @@ __FBSDID($FreeBSD$);
 
 MALLOC_DECLARE(M_AGP);
 
+struct agp_i810_match;
+
+static int agp_i810_check_active(device_t bridge_dev);
+static int agp_i830_check_active(device_t bridge_dev);
+static int agp_i915_check_active(device_t bridge_dev);
+static int agp_sb_check_active(device_t bridge_dev);
+
+static void agp_82852_set_desc(device_t dev,
+const struct agp_i810_match *match);
+static void agp_i810_set_desc(device_t dev, const struct agp_i810_match 
*match);
+
+static void agp_i810_dump_regs(device_t dev);
+static void agp_i830_dump_regs(device_t dev);
+static void agp_i855_dump_regs(device_t dev);
+static void agp_i915_dump_regs(device_t dev);
+static void agp_i965_dump_regs(device_t dev);
+static void agp_sb_dump_regs(device_t dev);
+
+static int agp_i810_get_stolen_size(device_t dev);
+static int agp_i830_get_stolen_size(device_t dev);
+static int agp_i915_get_stolen_size(device_t dev);
+static int agp_sb_get_stolen_size(device_t dev);
+
+static int agp_i810_get_gtt_mappable_entries(device_t dev);
+static int agp_i830_get_gtt_mappable_entries(device_t dev);
+static int agp_i915_get_gtt_mappable_entries(device_t dev);
+
+static int agp_i810_get_gtt_total_entries(device_t dev);
+static int agp_i965_get_gtt_total_entries(device_t dev);
+static int agp_gen5_get_gtt_total_entries(device_t dev);
+static int agp_sb_get_gtt_total_entries(device_t dev);
+
+static int agp_i810_install_gatt(device_t dev);
+static int agp_i830_install_gatt(device_t dev);
+
+static void agp_i810_deinstall_gatt(device_t dev);
+static void agp_i830_deinstall_gatt(device_t dev);
+
+static 

svn commit: r235783 - in head/sys/dev/drm2: . i915

2012-05-22 Thread Konstantin Belousov
Author: kib
Date: Tue May 22 11:07:44 2012
New Revision: 235783
URL: http://svn.freebsd.org/changeset/base/235783

Log:
  Add the code for new Intel GPU driver, which supports GEM, KMS and
  works with new generations of GPUs (IronLake, SandyBridge and
  supposedly IvyBridge).
  
  The driver is not connected to the build yet.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Added:
  head/sys/dev/drm2/
  head/sys/dev/drm2/drm.h   (contents, props changed)
  head/sys/dev/drm2/drmP.h   (contents, props changed)
  head/sys/dev/drm2/drm_agpsupport.c   (contents, props changed)
  head/sys/dev/drm2/drm_atomic.h   (contents, props changed)
  head/sys/dev/drm2/drm_auth.c   (contents, props changed)
  head/sys/dev/drm2/drm_bufs.c   (contents, props changed)
  head/sys/dev/drm2/drm_context.c   (contents, props changed)
  head/sys/dev/drm2/drm_crtc.c   (contents, props changed)
  head/sys/dev/drm2/drm_crtc.h   (contents, props changed)
  head/sys/dev/drm2/drm_crtc_helper.c   (contents, props changed)
  head/sys/dev/drm2/drm_crtc_helper.h   (contents, props changed)
  head/sys/dev/drm2/drm_dma.c   (contents, props changed)
  head/sys/dev/drm2/drm_dp_helper.h   (contents, props changed)
  head/sys/dev/drm2/drm_dp_iic_helper.c   (contents, props changed)
  head/sys/dev/drm2/drm_drawable.c   (contents, props changed)
  head/sys/dev/drm2/drm_drv.c   (contents, props changed)
  head/sys/dev/drm2/drm_edid.c   (contents, props changed)
  head/sys/dev/drm2/drm_edid.h   (contents, props changed)
  head/sys/dev/drm2/drm_edid_modes.h   (contents, props changed)
  head/sys/dev/drm2/drm_fb_helper.c   (contents, props changed)
  head/sys/dev/drm2/drm_fb_helper.h   (contents, props changed)
  head/sys/dev/drm2/drm_fops.c   (contents, props changed)
  head/sys/dev/drm2/drm_fourcc.h   (contents, props changed)
  head/sys/dev/drm2/drm_gem.c   (contents, props changed)
  head/sys/dev/drm2/drm_gem_names.c   (contents, props changed)
  head/sys/dev/drm2/drm_gem_names.h   (contents, props changed)
  head/sys/dev/drm2/drm_hashtab.c   (contents, props changed)
  head/sys/dev/drm2/drm_hashtab.h   (contents, props changed)
  head/sys/dev/drm2/drm_internal.h   (contents, props changed)
  head/sys/dev/drm2/drm_ioctl.c   (contents, props changed)
  head/sys/dev/drm2/drm_irq.c   (contents, props changed)
  head/sys/dev/drm2/drm_linux_list.h   (contents, props changed)
  head/sys/dev/drm2/drm_linux_list_sort.c   (contents, props changed)
  head/sys/dev/drm2/drm_lock.c   (contents, props changed)
  head/sys/dev/drm2/drm_memory.c   (contents, props changed)
  head/sys/dev/drm2/drm_mm.c   (contents, props changed)
  head/sys/dev/drm2/drm_mm.h   (contents, props changed)
  head/sys/dev/drm2/drm_mode.h   (contents, props changed)
  head/sys/dev/drm2/drm_modes.c   (contents, props changed)
  head/sys/dev/drm2/drm_pci.c   (contents, props changed)
  head/sys/dev/drm2/drm_pciids.h   (contents, props changed)
  head/sys/dev/drm2/drm_sarea.h   (contents, props changed)
  head/sys/dev/drm2/drm_scatter.c   (contents, props changed)
  head/sys/dev/drm2/drm_sman.c   (contents, props changed)
  head/sys/dev/drm2/drm_sman.h   (contents, props changed)
  head/sys/dev/drm2/drm_stub.c   (contents, props changed)
  head/sys/dev/drm2/drm_sysctl.c   (contents, props changed)
  head/sys/dev/drm2/drm_vm.c   (contents, props changed)
  head/sys/dev/drm2/i915/
  head/sys/dev/drm2/i915/i915_debug.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_dma.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_drm.h   (contents, props changed)
  head/sys/dev/drm2/i915/i915_drv.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_drv.h   (contents, props changed)
  head/sys/dev/drm2/i915/i915_gem.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_gem_evict.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_gem_execbuffer.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_gem_gtt.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_gem_tiling.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_irq.c   (contents, props changed)
  head/sys/dev/drm2/i915/i915_reg.h   (contents, props changed)
  head/sys/dev/drm2/i915/i915_suspend.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_bios.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_bios.h   (contents, props changed)
  head/sys/dev/drm2/i915/intel_crt.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_display.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_dp.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_drv.h   (contents, props changed)
  head/sys/dev/drm2/i915/intel_fb.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_hdmi.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_iic.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_lvds.c   (contents, props changed)
  head/sys/dev/drm2/i915/intel_modes.c   (contents, props changed)
  

Re: svn commit: r235777 - head/sys/kern

2012-05-22 Thread Bruce Evans

On Tue, 22 May 2012, Hartmut Brandt wrote:


Log:
 Make dumptid non-static. It is used by libkvm to detect whether
 this is a VNET-kernel or not. gcc used to put the static symbol into
 the symbol table, clang does not. This fixes the 'netstat: no namelist'
 error seen on clang+VNET systems.

Modified:
 head/sys/kern/kern_shutdown.c


That would be a bug in clang if it were done for static symbols generally,
but here the bug seems to be that the symbol is not declared as __used.

gcc does the same for a file containing only static int x;, but it
is apparently confused by dumptid being initialized non-statically,
although the initialization has no side effects.  If dumptid were a
local variable, then clang would probably warn about the variable being
unused, but gcc-4.2.1 never detects such unused variables (thus code
that compiles with gcc -Wunused -Werror often fails with clang).  Here
the initialization is to curthread-td_tid, so it isn't clear if the
compiler can tell if it has no side effects.  curthread() is actually
__curthread().  __curthread() is now declared as __pure2, but that
never worked for me with older compilers (its result wasn't cached).
If the compilers can tell that the expression has no side effects,
then it is another bug that they don't warn about it having no effect
when it is only assigned to the apparently-unused variable dumptid.


Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Tue May 22 07:04:23 2012
(r235776)
+++ head/sys/kern/kern_shutdown.c   Tue May 22 07:23:41 2012
(r235777)
@@ -151,7 +151,7 @@ static struct dumperinfo dumper;/* our

/* Context information for dump-debuggers. */
static struct pcb dumppcb;  /* Registers. */
-static lwpid_t dumptid;/* Thread ID. */
+lwpid_t dumptid;   /* Thread ID. */

static void poweroff_wait(void *, int);
static void shutdown_halt(void *junk, int howto);


Now there are 3 bugs instead of 1:
- the variable is declared (implicit) extern instead of static
- the extern declaration is in a section for static declaration
- the variable is still not declared as __used.  If the compiler did
  a more extensive usage analysis, that looked at all object files but
  not at the libkvm API, then it should remove this variable anyway
  when it is not declared as __used.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235780 - head/include

2012-05-22 Thread Bruce Evans

On Tue, 22 May 2012, Hartmut Brandt wrote:


Log:
 Fix a compilation error with some compilers: __attribute__
 requires two parenthesis for its argument, but instead of using
 __attribute__ directly, use the appropriate __nonnull macro
 from cdefs.h.


This also fixes:
- the style bug of hard-coding __attribute__(())
- the namespace pollution of using nonnull() instead of __nonnull__().


Modified: head/include/malloc_np.h
==
--- head/include/malloc_np.hTue May 22 09:27:57 2012(r235779)
+++ head/include/malloc_np.hTue May 22 09:59:49 2012(r235780)
@@ -55,13 +55,11 @@ int mallctlbymib(const size_t *mib, size
#define ALLOCM_ERR_OOM  1
#define ALLOCM_ERR_NOT_MOVED2

-intallocm(void **ptr, size_t *rsize, size_t size, int flags)
-__attribute__(nonnull(1));
+intallocm(void **ptr, size_t *rsize, size_t size, int flags) __nonnull(1);
int rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
-int flags) __attribute__(nonnull(1));
-intsallocm(const void *ptr, size_t *rsize, int flags)
-__attribute__(nonnull(1));
-intdallocm(void *ptr, int flags) __attribute__(nonnull(1));
+int flags) __nonnull(1);
+intsallocm(const void *ptr, size_t *rsize, int flags) __nonnull(1);
+intdallocm(void *ptr, int flags) __nonnull(1);
int nallocm(size_t *rsize, size_t size, int flags);
__END_DECLS


Many unfixed bugs are visible nearby, starting with the namespace pollution
of parameter names in the application namespace.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235777 - head/sys/kern

2012-05-22 Thread Hartmut Brandt
On Tue, 22 May 2012, Bruce Evans wrote:

BEOn Tue, 22 May 2012, Hartmut Brandt wrote:
BE
BE Log:
BE  Make dumptid non-static. It is used by libkvm to detect whether
BE  this is a VNET-kernel or not. gcc used to put the static symbol into
BE  the symbol table, clang does not. This fixes the 'netstat: no namelist'
BE  error seen on clang+VNET systems.
BE 
BE Modified:
BE  head/sys/kern/kern_shutdown.c
BE
BEThat would be a bug in clang if it were done for static symbols generally,
BEbut here the bug seems to be that the symbol is not declared as __used.

I don't get this. Why should a symbol declared static be in the symbol 
table (except for debugging purposes) ? It has internal linkage and so has 
a meaning only in the given file. What is the linker supposed to do with 
several static symbols with the same name from several object files? If 
several files declared static dumptids, which one would kldsym be supposed 
to return?

harti

BE
BEgcc does the same for a file containing only static int x;, but it
BEis apparently confused by dumptid being initialized non-statically,
BEalthough the initialization has no side effects.  If dumptid were a
BElocal variable, then clang would probably warn about the variable being
BEunused, but gcc-4.2.1 never detects such unused variables (thus code
BEthat compiles with gcc -Wunused -Werror often fails with clang).  Here
BEthe initialization is to curthread-td_tid, so it isn't clear if the
BEcompiler can tell if it has no side effects.  curthread() is actually
BE__curthread().  __curthread() is now declared as __pure2, but that
BEnever worked for me with older compilers (its result wasn't cached).
BEIf the compilers can tell that the expression has no side effects,
BEthen it is another bug that they don't warn about it having no effect
BEwhen it is only assigned to the apparently-unused variable dumptid.
BE
BE Modified: head/sys/kern/kern_shutdown.c
BE 
==
BE --- head/sys/kern/kern_shutdown.c  Tue May 22 07:04:23 2012
BE (r235776)
BE +++ head/sys/kern/kern_shutdown.c  Tue May 22 07:23:41 2012
BE (r235777)
BE @@ -151,7 +151,7 @@ static struct dumperinfo dumper;   /* our
BE 
BE /* Context information for dump-debuggers. */
BE static struct pcb dumppcb; /* Registers. */
BE -static lwpid_t dumptid;   /* Thread ID. */
BE +lwpid_t dumptid;  /* Thread ID. */
BE 
BE static void poweroff_wait(void *, int);
BE static void shutdown_halt(void *junk, int howto);
BE
BENow there are 3 bugs instead of 1:
BE- the variable is declared (implicit) extern instead of static
BE- the extern declaration is in a section for static declaration
BE- the variable is still not declared as __used.  If the compiler did
BE  a more extensive usage analysis, that looked at all object files but
BE  not at the libkvm API, then it should remove this variable anyway
BE  when it is not declared as __used.
BE
BEBruce
BE
BE
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Dimitry Andric
On 2012-05-22 12:22, Dag-Erling Smørgrav wrote:
 Baptiste Daroussin b...@freebsd.org writes:
 Log:
   Import byacc from invisible island, it brings us lots of compatibilities 
 with
   bison, keeping full compatibility with our previous yacc
   implementation.
 
 This commit broke the build, in large part because Baptiste tested with
 Clang instead of GCC, and GCC generates a warning when compiling the
 generated code.

It doesn't seem to compile with clang either, at least not as of r235777:

/usr/src/bin/expr/expr.y:291:2: error: implicit declaration of function 
'yyparse' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
yyparse();
^

Note that it looks like the expr.c file is still generated with the
system yacc, so I'm not entirely sure what's going on here...

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235739 - head/lib/libc/gen

2012-05-22 Thread Guy Helmer
On May 22, 2012, at 1:48 AM, Bruce Evans wrote:

 On Mon, 21 May 2012, Guy Helmer wrote:
 
 Log:
 Apply style(9) to return and switch/case statements.
 
 Reviewed by: delphij (prior version of the patch)
 
 Modified:
 head/lib/libc/gen/getnetgrent.c
 
 Modified: head/lib/libc/gen/getnetgrent.c
 ==
 --- head/lib/libc/gen/getnetgrent.c  Mon May 21 19:58:40 2012
 (r235738)
 +++ head/lib/libc/gen/getnetgrent.c  Mon May 21 21:04:29 2012
 (r235739)
 ...
 @@ -311,32 +311,35 @@ _revnetgr_lookup(char* lookupdom, char*
 
  for (rot = 0; ; rot++) {
  switch (rot) {
 -case(0): snprintf(key, MAXHOSTNAMELEN, %s.%s,
 -  str, dom?dom:lookupdom);
 - break;
 -case(1): snprintf(key, MAXHOSTNAMELEN, %s.*,
 -  str);
 - break;
 -case(2): snprintf(key, MAXHOSTNAMELEN, *.%s,
 -  dom?dom:lookupdom);
 - break;
 -case(3): snprintf(key, MAXHOSTNAMELEN, *.*);
 - break;
 -default: return(0);
 +case(0):
 +snprintf(key, MAXHOSTNAMELEN, %s.%s, str,
 +dom ? dom : lookupdom);
 +break;
 +case(1):
 +snprintf(key, MAXHOSTNAMELEN, %s.*, str);
 +break;
 +case(2):
 +snprintf(key, MAXHOSTNAMELEN, *.%s,
 +dom ? dom : lookupdom);
 +break;
 +case(3):
 +snprintf(key, MAXHOSTNAMELEN, *.*);
 +break;
 
 Thanks, but a fuller application would have removed the obfuscatory
 parentheses that make case() look like a function call...
 
 +default: return (0);
 
 ... and split the case statements after : in all cases.
 
  }
  y = yp_match(lookupdom, map, key, strlen(key), result,
   resultlen);
 
 You fixed the continuation indentation in the case statement but not here.
 
  if (y == 0) {
  rv = _listmatch(result, group, resultlen);
  free(result);
 -if (rv) return(1);
 +if (rv) return (1);
 
 Another statement not started on a new line.
 
  } else if (y != YPERR_KEY) {
  /*
   * If we get an error other than 'no
   * such key in map' then something is
   * wrong and we should stop the search.
   */
 -return(-1);
 +return (-1);
  }
  }
 }
 
 These style bugs weren't in the CSRG version of course.  The YP code added
 many.  The most obvious ones are the case(n) and gnu-style continuation
 indentation.
 

I am not sure how to best resolve the long lines in the block of code to free 
grp-ng_str[] elements. The indentation is quite deep at that point, and 
breaking short statements over multiple lines would make the code quite ugly.

Would this resolve the other issues you pointed out?

Index: lib/libc/gen/getnetgrent.c
===
--- lib/libc/gen/getnetgrent.c  (revision 235784)
+++ lib/libc/gen/getnetgrent.c  (working copy)
@@ -309,28 +309,30 @@
 
for (rot = 0; ; rot++) {
switch (rot) {
-   case(0):
+   case 0:
snprintf(key, MAXHOSTNAMELEN, %s.%s, str,
dom ? dom : lookupdom);
break;
-   case(1):
+   case 1:
snprintf(key, MAXHOSTNAMELEN, %s.*, str);
break;
-   case(2):
+   case 2:
snprintf(key, MAXHOSTNAMELEN, *.%s,
dom ? dom : lookupdom);
break;
-   case(3):
+   case 3:
snprintf(key, MAXHOSTNAMELEN, *.*);
break;
-   default: return (0);
+   default:
+   return (0);
}
y = yp_match(lookupdom, map, key, strlen(key), result,
-resultlen);
+   resultlen);
if (y == 0) {
rv = _listmatch(result, group, resultlen);
free(result);
-   if (rv) return (1);
+   if (rv)
+   return (1);
} else if (y != YPERR_KEY) {
/*
 * If we get an error other than 'no
@@ -418,7 

Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Garrett Cooper
On Tue, May 22, 2012 at 6:32 AM, Dimitry Andric d...@freebsd.org wrote:
 On 2012-05-22 12:22, Dag-Erling Smørgrav wrote:
 Baptiste Daroussin b...@freebsd.org writes:
 Log:
   Import byacc from invisible island, it brings us lots of compatibilities 
 with
   bison, keeping full compatibility with our previous yacc
   implementation.

 This commit broke the build, in large part because Baptiste tested with
 Clang instead of GCC, and GCC generates a warning when compiling the
 generated code.

 It doesn't seem to compile with clang either, at least not as of r235777:

 /usr/src/bin/expr/expr.y:291:2: error: implicit declaration of function 
 'yyparse' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        yyparse();
        ^

 Note that it looks like the expr.c file is still generated with the
 system yacc, so I'm not entirely sure what's going on here...

I mentioned it in a private email, but the issue is that the yacc
used during the build seems to be coming from the base system (despite
the fact that it's a bootstrap tool). Once I installed yacc onto my
stable-9 system at work, all of the changes that should have been
checked in with this commit became apparent.
Thanks,
-Garrett

1022 .if ${BOOTSTRAPPING}  96
1023 _lex=   usr.bin/lex
1024 _yacc=  usr.bin/yacc
1025 .endif
# ...
1068 bootstrap-tools:
1069 .for _tool in \
1070 ${_clang_tblgen} \
1071 ${_kerberos5_bootstrap_tools} \
1072 ${_dtrace_tools} \
1073 ${_strfile} \
1074 ${_gperf} \
1075 ${_groff} \
1076 ${_ar} \
1077 ${_dtc} \
1078 ${_awk} \
1079 usr.bin/lorder \
1080 usr.bin/makewhatis \
1081 ${_mklocale} \
1082 usr.bin/rpcgen \
1083 ${_sed} \
1084 ${_lex} \
1085 ${_yacc} \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Dimitry Andric
On 2012-05-22 16:44, Garrett Cooper wrote:
...
 I mentioned it in a private email, but the issue is that the yacc
 used during the build seems to be coming from the base system (despite
 the fact that it's a bootstrap tool). Once I installed yacc onto my
 stable-9 system at work, all of the changes that should have been
 checked in with this commit became apparent.
 Thanks,
 -Garrett
 
 1022 .if ${BOOTSTRAPPING}  96

Yes, Dag-Erling mentioned he will fix this particular test for head,
which needs a version bump.

Though I still think it might have been less churn if yacc had just
continued to not declare yyparse()... :)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Gabor Kovesdan

On 2012.05.22. 17:03, Dimitry Andric wrote:

...

 I mentioned it in a private email, but the issue is that the yacc
used during the build seems to be coming from the base system (despite
the fact that it's a bootstrap tool). Once I installed yacc onto my
stable-9 system at work, all of the changes that should have been
checked in with this commit became apparent.
Thanks,
-Garrett

1022 .if ${BOOTSTRAPPING}  96

Yes, Dag-Erling mentioned he will fix this particular test for head,
which needs a version bump.
Maybe I'm missing some point but what if we always use yacc and lex from 
the source tree instead of from the base system? That would be the most 
logical way of doing this and whether they are built early or just in 
the world phase does not make that much difference, does it?


Gabor

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235787 - head/sys/kern

2012-05-22 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue May 22 15:58:27 2012
New Revision: 235787
URL: http://svn.freebsd.org/changeset/base/235787

Log:
  Fix panic with RACCT that could occur in low memory (or out of swap)
  situations, due to fork1() calling racct_proc_exit() without calling
  racct_proc_fork() first.
  
  Submitted by: Mateusz Guzik mjguzik at gmail dot com (earlier version)
  Reviewed by:  Mateusz Guzik mjguzik at gmail dot com

Modified:
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_racct.c

Modified: head/sys/kern/kern_fork.c
==
--- head/sys/kern/kern_fork.c   Tue May 22 15:26:55 2012(r235786)
+++ head/sys/kern/kern_fork.c   Tue May 22 15:58:27 2012(r235787)
@@ -939,8 +939,8 @@ fail:
 #ifdef MAC
mac_proc_destroy(newproc);
 #endif
-fail1:
racct_proc_exit(newproc);
+fail1:
if (vm2 != NULL)
vmspace_free(vm2);
uma_zfree(proc_zone, newproc);

Modified: head/sys/kern/kern_racct.c
==
--- head/sys/kern/kern_racct.c  Tue May 22 15:26:55 2012(r235786)
+++ head/sys/kern/kern_racct.c  Tue May 22 15:58:27 2012(r235787)
@@ -573,6 +573,9 @@ out:
PROC_UNLOCK(child);
PROC_UNLOCK(parent);
 
+   if (error != 0)
+   racct_proc_exit(child);
+
return (error);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235788 - in head: . sys/sys

2012-05-22 Thread Dag-Erling Smorgrav
Author: des
Date: Tue May 22 15:59:07 2012
New Revision: 235788
URL: http://svn.freebsd.org/changeset/base/235788

Log:
  Bump __FreeBSD_version for the byacc import, and update _bootstrap_tools.

Modified:
  head/Makefile.inc1
  head/sys/sys/param.h

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue May 22 15:58:27 2012(r235787)
+++ head/Makefile.inc1  Tue May 22 15:59:07 2012(r235788)
@@ -1021,6 +1021,9 @@ _sed= usr.bin/sed
 
 .if ${BOOTSTRAPPING}  96
 _lex=  usr.bin/lex
+.endif
+
+.if ${BOOTSTRAPPING}  113
 _yacc= usr.bin/yacc
 .endif
 
@@ -1081,8 +1084,8 @@ bootstrap-tools:
 ${_mklocale} \
 usr.bin/rpcgen \
 ${_sed} \
-${_lex} \
 ${_yacc} \
+${_lex} \
 usr.bin/xinstall \
 ${_gensnmptree} \
 usr.sbin/config

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue May 22 15:58:27 2012(r235787)
+++ head/sys/sys/param.hTue May 22 15:59:07 2012(r235788)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 112  /* Master, propagated to newvers */
+#define __FreeBSD_version 113  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Dag-Erling Smørgrav
Gabor Kovesdan ga...@freebsd.org writes:
 Maybe I'm missing some point but what if we always use yacc and lex
 from the source tree instead of from the base system? That would be
 the most logical way of doing this and whether they are built early or
 just in the world phase does not make that much difference, does it?

Bootstrap tools are built twice, so we try to only build them when we
know that we need them, i.e. when cross-building (for machine-dependent
tools) or when building on a system that has an older, incompatible
version of the tool.  For lex and yacc, the latter case applies, since
they are machine-independent.

My final test build just completed.  I just committed the version bump
and the bootstrap change; Baptiste will commit the yyparse() fix later
today.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235723 - in head: contrib/byacc tools/regression/usr.bin/yacc usr.bin/yacc usr.bin/yacc/test

2012-05-22 Thread Baptiste Daroussin
On Tue, May 22, 2012 at 06:01:31PM +0200, Dag-Erling Smørgrav wrote:
 Gabor Kovesdan ga...@freebsd.org writes:
  Maybe I'm missing some point but what if we always use yacc and lex
  from the source tree instead of from the base system? That would be
  the most logical way of doing this and whether they are built early or
  just in the world phase does not make that much difference, does it?
 
 Bootstrap tools are built twice, so we try to only build them when we
 know that we need them, i.e. when cross-building (for machine-dependent
 tools) or when building on a system that has an older, incompatible
 version of the tool.  For lex and yacc, the latter case applies, since
 they are machine-independent.
 
 My final test build just completed.  I just committed the version bump
 and the bootstrap change; Baptiste will commit the yyparse() fix later
 today.
 

Should be done, sorry all for the mess, lots of lessons learned.

regards,
Bapt


pgpbHHdOUzwaK.pgp
Description: PGP signature


Re: svn commit: r235777 - head/sys/kern

2012-05-22 Thread Bjoern A. Zeeb

On 22. May 2012, at 07:23 , Hartmut Brandt wrote:

 Author: harti
 Date: Tue May 22 07:23:41 2012
 New Revision: 235777
 URL: http://svn.freebsd.org/changeset/base/235777
 
 Log:
  Make dumptid non-static. It is used by libkvm to detect whether
  this is a VNET-kernel or not.

Just for clarifications - it's used to detect whether we are operating on
a crash dump or not in the vnet case.


 gcc used to put the static symbol into
  the symbol table, clang does not. This fixes the 'netstat: no namelist'
  error seen on clang+VNET systems.
 
 Modified:
  head/sys/kern/kern_shutdown.c
 
 Modified: head/sys/kern/kern_shutdown.c
 ==
 --- head/sys/kern/kern_shutdown.c Tue May 22 07:04:23 2012
 (r235776)
 +++ head/sys/kern/kern_shutdown.c Tue May 22 07:23:41 2012
 (r235777)
 @@ -151,7 +151,7 @@ static struct dumperinfo dumper;  /* our 
 
 /* Context information for dump-debuggers. */
 static struct pcb dumppcb;/* Registers. */
 -static lwpid_t dumptid;  /* Thread ID. */
 +lwpid_t dumptid; /* Thread ID. */
 
 static void poweroff_wait(void *, int);
 static void shutdown_halt(void *junk, int howto);

-- 
Bjoern A. Zeeb You have to have visions!
   It does not matter how good you are. It matters what good you do!

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235794 - head/contrib/gcc

2012-05-22 Thread David E. O'Brien
Author: obrien
Date: Tue May 22 17:11:18 2012
New Revision: 235794
URL: http://svn.freebsd.org/changeset/base/235794

Log:
  Record that r235793 (-objc) has been merged from vendor/gcc into HEAD.

Modified:
Directory Properties:
  head/contrib/gcc/   (props changed)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235795 - head/sys/kern

2012-05-22 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue May 22 17:30:02 2012
New Revision: 235795
URL: http://svn.freebsd.org/changeset/base/235795

Log:
  Don't leak locks in prison_racct_modify().
  
  Submitted by: Mateusz Guzik mjguzik at gmail dot com
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_jail.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Tue May 22 17:11:18 2012(r235794)
+++ head/sys/kern/kern_jail.c   Tue May 22 17:30:02 2012(r235795)
@@ -4491,8 +4491,11 @@ prison_racct_modify(struct prison *pr)
sx_slock(allproc_lock);
sx_xlock(allprison_lock);
 
-   if (strcmp(pr-pr_name, pr-pr_prison_racct-prr_name) == 0)
+   if (strcmp(pr-pr_name, pr-pr_prison_racct-prr_name) == 0) {
+   sx_xunlock(allprison_lock);
+   sx_sunlock(allproc_lock);
return;
+   }
 
oldprr = pr-pr_prison_racct;
pr-pr_prison_racct = NULL;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235777 - head/sys/kern

2012-05-22 Thread Bruce Evans

On Tue, 22 May 2012, Hartmut Brandt wrote:


On Tue, 22 May 2012, Bruce Evans wrote:

BEOn Tue, 22 May 2012, Hartmut Brandt wrote:
BE
BE Log:
BE  Make dumptid non-static. It is used by libkvm to detect whether
BE  this is a VNET-kernel or not. gcc used to put the static symbol into
BE  the symbol table, clang does not. This fixes the 'netstat: no namelist'
BE  error seen on clang+VNET systems.
BE
BE Modified:
BE  head/sys/kern/kern_shutdown.c
BE
BEThat would be a bug in clang if it were done for static symbols generally,
BEbut here the bug seems to be that the symbol is not declared as __used.

I don't get this. Why should a symbol declared static be in the symbol
table (except for debugging purposes) ?


It must be there for debugging purposes and historical compatibility
(mainly other debugging uses, including kvm).  Static symbols are not
really special here.  The C standard doesn't even require a symbol table,
and it is only implementation details and debugging and historical
compatibility that require putting global symbols in symbol tables.


It has internal linkage and so has
a meaning only in the given file. What is the linker supposed to do with
several static symbols with the same name from several object files?


Same as it always did.  The names are in per-object-file namespaces for
the linker, so they don't conflict for linking, but they mess up primitive
debuggers starting with nm.


If
several files declared static dumptids, which one would kldsym be supposed
to return?


libkvm and kldsym would be broken.  I don't know of any even
non-primitive debuggers that can handle this.  In gdb the only way
that I know of to print a non-unique variable is to display the source
file that declares the variable using something like `l' on a function
in that file; the variable scope is then that of the selected file.
The address file.c:foo only works for displaying functions.  The
latter probably depends on a full symbol table.  When there is no
symbol table, `l' of course doesn't work; `disass foo works.  disass
file.c:foo of course doesn't work.  disass file.o:foo should work,
but doesn't, even when there is a full symbol table.  When the file.*:
address doesn't work, this is is initially because it misparsed as the
symbol file.  Actually, I know of the primitive way which works even
using ddb with all symbols broken in ddb, and have had to use this several
times: you find the address of things using nm or something less
primitive on another system, and guess which address to use if several
variables have the same name, and type it in.

BTW, kernels have lots of conflicting symbols which mess up debugging
using primitive debuggers like ddb.
/usr/src/tools/tools/kernxref/kernxref.sh was supposed to be used to
find and fix these as well as finding and fixing public variables that
should be static, but it is rarely used.  uniq reports removing 382
out of 28443 (non-unique) symbols in a fairly current kernel with not
many features configured.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235797 - head/contrib/gcc

2012-05-22 Thread David E. O'Brien
Author: obrien
Date: Tue May 22 18:18:06 2012
New Revision: 235797
URL: http://svn.freebsd.org/changeset/base/235797

Log:
  Do not incorrectly warn when printing a quad_t using %qd on 64-bit 
platforms.

Modified:
  head/contrib/gcc/c-format.c

Modified: head/contrib/gcc/c-format.c
==
--- head/contrib/gcc/c-format.c Tue May 22 17:44:01 2012(r235796)
+++ head/contrib/gcc/c-format.c Tue May 22 18:18:06 2012(r235797)
@@ -287,7 +287,11 @@ static const format_length_info printf_l
 {
   { h, FMT_LEN_h, STD_C89, hh, FMT_LEN_hh, STD_C99 },
   { l, FMT_LEN_l, STD_C89, ll, FMT_LEN_ll, STD_C9L },
+#ifdef __LP64__
+  { q, FMT_LEN_l, STD_EXT, NULL, 0, 0 },
+#else
   { q, FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
+#endif
   { L, FMT_LEN_L, STD_C89, NULL, 0, 0 },
   { z, FMT_LEN_z, STD_C99, NULL, 0, 0 },
   { Z, FMT_LEN_z, STD_EXT, NULL, 0, 0 },
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235799 - head/lib/libjail

2012-05-22 Thread Jamie Gritton
Author: jamie
Date: Tue May 22 18:30:32 2012
New Revision: 235799
URL: http://svn.freebsd.org/changeset/base/235799

Log:
  The fix in r235291 re-broke the allow.nomount case.  Re-fix it
  by testing for the right parameter name.

Modified:
  head/lib/libjail/jail.c

Modified: head/lib/libjail/jail.c
==
--- head/lib/libjail/jail.c Tue May 22 18:30:14 2012(r235798)
+++ head/lib/libjail/jail.c Tue May 22 18:30:32 2012(r235799)
@@ -853,7 +853,7 @@ jailparam_free(struct jailparam *jp, uns
 static int
 jailparam_type(struct jailparam *jp)
 {
-   char *p, *nname;
+   char *p, *name, *nname;
size_t miblen, desclen;
int i, isarray;
struct {
@@ -863,7 +863,8 @@ jailparam_type(struct jailparam *jp)
int mib[CTL_MAXNAME];
 
/* The lastjid parameter isn't real. */
-   if (!strcmp(jp-jp_name, lastjid)) {
+   name = jp-jp_name;
+   if (!strcmp(name, lastjid)) {
jp-jp_valuelen = sizeof(int);
jp-jp_ctltype = CTLTYPE_INT | CTLFLAG_WR;
return (0);
@@ -872,19 +873,19 @@ jailparam_type(struct jailparam *jp)
/* Find the sysctl that describes the parameter. */
mib[0] = 0;
mib[1] = 3;
-   snprintf(desc.s, sizeof(desc.s), SJPARAM .%s, jp-jp_name);
+   snprintf(desc.s, sizeof(desc.s), SJPARAM .%s, name);
miblen = sizeof(mib) - 2 * sizeof(int);
if (sysctl(mib, 2, mib + 2, miblen, desc.s, strlen(desc.s))  0) {
if (errno != ENOENT) {
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
-   sysctl(0.3.%s): %s, jp-jp_name, strerror(errno));
+   sysctl(0.3.%s): %s, name, strerror(errno));
return (-1);
}
/*
 * The parameter probably doesn't exist.  But it might be
 * the no counterpart to a boolean.
 */
-   nname = nononame(jp-jp_name);
+   nname = nononame(name);
if (nname == NULL) {
unknown_parameter:
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
@@ -892,8 +893,10 @@ jailparam_type(struct jailparam *jp)
errno = ENOENT;
return (-1);
}
-   snprintf(desc.s, sizeof(desc.s), SJPARAM .%s, nname);
+   name = alloca(strlen(nname) + 1);
+   strcpy(name, nname);
free(nname);
+   snprintf(desc.s, sizeof(desc.s), SJPARAM .%s, name);
miblen = sizeof(mib) - 2 * sizeof(int);
if (sysctl(mib, 2, mib + 2, miblen, desc.s,
strlen(desc.s))  0)
@@ -906,7 +909,7 @@ jailparam_type(struct jailparam *jp)
if (sysctl(mib, (miblen / sizeof(int)) + 2, desc, desclen,
NULL, 0)  0) {
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
-   sysctl(0.4.%s): %s, jp-jp_name, strerror(errno));
+   sysctl(0.4.%s): %s, name, strerror(errno));
return (-1);
}
jp-jp_ctltype = desc.i;
@@ -952,7 +955,7 @@ jailparam_type(struct jailparam *jp)
if (sysctl(mib + 2, miblen / sizeof(int), desc.s, desclen,
NULL, 0)  0) {
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
-   sysctl( SJPARAM .%s): %s, jp-jp_name,
+   sysctl( SJPARAM .%s): %s, name,
strerror(errno));
return (-1);
}
@@ -970,7 +973,7 @@ jailparam_type(struct jailparam *jp)
if (sysctl(mib + 2, miblen / sizeof(int),
NULL, jp-jp_valuelen, NULL, 0)  0) {
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
-   sysctl( SJPARAM .%s): %s, jp-jp_name,
+   sysctl( SJPARAM .%s): %s, name,
strerror(errno));
return (-1);
}
@@ -995,10 +998,9 @@ jailparam_type(struct jailparam *jp)
sysctl(0.1): %s, strerror(errno));
return (-1);
}
-   if (desclen ==
-   sizeof(SJPARAM) + strlen(jp-jp_name) + 2 
+   if (desclen == sizeof(SJPARAM) + strlen(name) + 2 
memcmp(SJPARAM ., desc.s, sizeof(SJPARAM)) == 0 
-   memcmp(jp-jp_name, desc.s + sizeof(SJPARAM),
+   memcmp(name, desc.s + sizeof(SJPARAM),
desclen - sizeof(SJPARAM) - 2) == 0 
desc.s[desclen - 2] == '.')
goto mib_desc;

Re: svn commit: r235623 - in head/contrib/gcc: . config/rs6000 config/sparc

2012-05-22 Thread David O'Brien
On Fri, May 18, 2012 at 07:02:40PM +, Pedro F. Giffuni wrote:
 Log:
   Bring in a subset of gcc fixes that were back ported to
   the GCC 4.1 branch and are available under GPLv2.

I do not understand this -- We're using GCC 4.2.1 @r127959, but you
are bringing in patches that are against 4.1.

What version of GCC were the changes back ported from if not 4.2.0 or
4.2.1?


BTW, these also should have been imported into ^/vendor/gcc/ and then
merged into ^/head/contrib/gcc as there are commercial users of FreeBSD
that have to modify their compiler to be able to consume FreeBSD source
code.  And provenance and licensing matters to these folks.

-- 
-- David  (obr...@freebsd.org)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235623 - in head/contrib/gcc: . config/rs6000 config/sparc

2012-05-22 Thread Pedro Giffuni

Hi David;

On 05/22/12 13:27, David O'Brien wrote:

On Fri, May 18, 2012 at 07:02:40PM +, Pedro F. Giffuni wrote:

Log:
   Bring in a subset of gcc fixes that were back ported to
   the GCC 4.1 branch and are available under GPLv2.

I do not understand this -- We're using GCC 4.2.1 @r127959, but you
are bringing in patches that are against 4.1.

What version of GCC were the changes back ported from if not 4.2.0 or
4.2.1?


Most of them originated in gcc 4.3 branch and were backported to
gcc  4.2.2 under the GPLv3. Those patches were further backported
to gcc 4.1.x which continued to be released under GPLv2.

Technically I cannot take patches from the gcc 4.2.x where x =2 so
I took them from the gcc 4.1 branch.



BTW, these also should have been imported into ^/vendor/gcc/ and then
merged into ^/head/contrib/gcc as there are commercial users of FreeBSD
that have to modify their compiler to be able to consume FreeBSD source
code.  And provenance and licensing matters to these folks.



This was discussed in private with mm@, as he brought some GPLv2
changes from the gcc 4.3 branch. We don't carry gcc 4.3 or 4.1 in
the vendors area and the code from those branches that we can
merge is relatively small. (We do keep a changelog for gcc4.3
changes for reference.)

FWIW, we also merged the complete libstdc++ from gcc 4.2.4 as
libstdc++ remained under LGPLv2 for all the gcc 4.2 branch.

Pedro.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235801 - head/sys/net80211

2012-05-22 Thread Adrian Chadd
Author: adrian
Date: Tue May 22 19:37:12 2012
New Revision: 235801
URL: http://svn.freebsd.org/changeset/base/235801

Log:
  Fix some corner cases in the ieee80211_send_bar() handling.
  
  * If the first call succeeded but failed to transmit, a timer would
reschedule it via bar_timeout().  Unfortunately bar_timeout() didn't
check the return value from the ieee80211_send_bar() reattempt and
if that failed (eg the driver ic_raw_xmit() failed), it would never
re-arm the timer.
  
  * If BARPEND is cleared (which ieee80211_send_bar() will do if it can't
TX), then re-arming the timer isn't enough - once bar_timeout() occurs,
it'll see BARPEND is 0 and not run through the rest of the routine.
So when rearming the timer, also set that flag.
  
  * If the TX wasn't occuring, bar_tx_complete() wouldn't be called and the
driver callback wouldn't be called either.  So the driver had no idea
that the BAR TX attempt had failed.  In the ath(4) case, TX would stay
paused.
  
(There's no callback to indicate that BAR TX had failed or not;
only a BAR TX was attempted.  That's a separate, later problem.)
  
So call the driver callback (ic_bar_response()) before the ADDBA session
is torn down, so it has a chance of being notified that things didn't
quite go to plan.
  
  I've verified that yes, this does suspend traffic for ath(4), retry BAR
  TX even if the driver is failing ic_raw_xmit(), and then eventually giving
  up and sending a DELBA.  I'll address the out of ath_buf issue in ath(4)
  in a subsequent commit - this commit just fixes the edge case where any
  driver is (way) out of internal buffers/descriptors and fails frame TX.
  
  PR:   kern/168170
  Reviewed by:  bschmidt
  MFC after:1 month

Modified:
  head/sys/net80211/ieee80211_ht.c

Modified: head/sys/net80211/ieee80211_ht.c
==
--- head/sys/net80211/ieee80211_ht.cTue May 22 18:31:56 2012
(r235800)
+++ head/sys/net80211/ieee80211_ht.cTue May 22 19:37:12 2012
(r235801)
@@ -2166,6 +2166,9 @@ ieee80211_ampdu_stop(struct ieee80211_no
}
 }
 
+/* XXX */
+static void bar_start_timer(struct ieee80211_tx_ampdu *tap);
+
 static void
 bar_timeout(void *arg)
 {
@@ -2184,11 +2187,34 @@ bar_timeout(void *arg)
return;
/* XXX ? */
if (tap-txa_attempts = ieee80211_bar_maxtries) {
+   struct ieee80211com *ic = ni-ni_ic;
+
ni-ni_vap-iv_stats.is_ampdu_bar_tx_fail++;
+   /*
+* If (at least) the last BAR TX timeout was due to
+* an ieee80211_send_bar() failures, then we need
+* to make sure we notify the driver that a BAR
+* TX did occur and fail.  This gives the driver
+* a chance to undo any queue pause that may
+* have occured.
+*/
+   ic-ic_bar_response(ni, tap, 1);
ieee80211_ampdu_stop(ni, tap, IEEE80211_REASON_TIMEOUT);
} else {
ni-ni_vap-iv_stats.is_ampdu_bar_tx_retry++;
-   ieee80211_send_bar(ni, tap, tap-txa_seqpending);
+   if (ieee80211_send_bar(ni, tap, tap-txa_seqpending) != 0) {
+   /*
+* If ieee80211_send_bar() fails here, the
+* timer may have stopped and/or the pending
+* flag may be clear.  Because of this,
+* fake the BARPEND and reset the timer.
+* A retransmission attempt will then occur
+* during the next timeout.
+*/
+   /* XXX locking */
+   tap-txa_flags |= IEEE80211_AGGR_BARPEND;
+   bar_start_timer(tap);
+   }
}
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235802 - head/usr.bin/minigzip

2012-05-22 Thread Xin LI
Author: delphij
Date: Tue May 22 19:40:54 2012
New Revision: 235802
URL: http://svn.freebsd.org/changeset/base/235802

Log:
  commandline - command line
  
  MFC after:1 week

Modified:
  head/usr.bin/minigzip/minigzip.1

Modified: head/usr.bin/minigzip/minigzip.1
==
--- head/usr.bin/minigzip/minigzip.1Tue May 22 19:37:12 2012
(r235801)
+++ head/usr.bin/minigzip/minigzip.1Tue May 22 19:40:54 2012
(r235802)
@@ -24,7 +24,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 3, 2002
+.Dd May 22, 2012
 .Dt MINIGZIP 1
 .Os
 .Sh NAME
@@ -48,7 +48,7 @@ output.
 The default operation is compression, decompression can be
 selected by supplying the
 .Fl d
-flag on the commandline.
+flag on the command line.
 .Pp
 If any
 .Ar file
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235803 - head/sys/kern

2012-05-22 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue May 22 19:43:20 2012
New Revision: 235803
URL: http://svn.freebsd.org/changeset/base/235803

Log:
  Fix use-after-free in kern_jail_set() triggered e.g. by attempts
  to clear persist flag from empty persistent jail, like this:
  
  jail -c persist=1
  jail -n 1 -m persist=0
  
  Submitted by: Mateusz Guzik mjguzik at gmail dot com
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_jail.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Tue May 22 19:40:54 2012(r235802)
+++ head/sys/kern/kern_jail.c   Tue May 22 19:43:20 2012(r235803)
@@ -1811,6 +1811,16 @@ kern_jail_set(struct thread *td, struct 
}
}
 
+#ifdef RACCT
+   if (!created) {
+   sx_sunlock(allprison_lock);
+   prison_racct_modify(pr);
+   sx_slock(allprison_lock);
+   }
+#endif
+
+   td-td_retval[0] = pr-pr_id;
+
/*
 * Now that it is all there, drop the temporary reference from existing
 * prisons.  Or add a reference to newly created persistent prisons
@@ -1832,12 +1842,6 @@ kern_jail_set(struct thread *td, struct 
sx_sunlock(allprison_lock);
}
 
-#ifdef RACCT
-   if (!created)
-   prison_racct_modify(pr);
-#endif
-
-   td-td_retval[0] = pr-pr_id;
goto done_errmsg;
 
  done_deref_locked:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235804 - head/sys/dev/ath

2012-05-22 Thread Adrian Chadd
Author: adrian
Date: Tue May 22 19:50:21 2012
New Revision: 235804
URL: http://svn.freebsd.org/changeset/base/235804

Log:
  Re-up the TX ath_buf limit from 128 to 512.
  
  I'll have to leave this high for now, until I've done some significant
  surgery with how ath_bufs (and descriptors) are handled.
  
  This should significantly cut down on the opportunities for a full TX
  queue hanging traffic.  I'll continue making things work though; I'm
  mostly doing this for users. :)

Modified:
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_athvar.h
==
--- head/sys/dev/ath/if_athvar.hTue May 22 19:43:20 2012
(r235803)
+++ head/sys/dev/ath/if_athvar.hTue May 22 19:50:21 2012
(r235804)
@@ -47,7 +47,7 @@
  * 802.11n requires more TX and RX buffers to do AMPDU.
  */
 #ifdef ATH_ENABLE_11N
-#defineATH_TXBUF   128
+#defineATH_TXBUF   512
 #defineATH_RXBUF   512
 #endif
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r234482 - in head/sys: fs/msdosfs fs/nfsserver kern sys

2012-05-22 Thread Attilio Rao
2012/4/22 Pawel Jakub Dawidek p...@freebsd.org:
 On Fri, Apr 20, 2012 at 06:50:44AM +, Kirk McKusick wrote:
 Author: mckusick
 Date: Fri Apr 20 06:50:44 2012
 New Revision: 234482
 URL: http://svn.freebsd.org/changeset/base/234482

 Log:
   This change creates a new list of active vnodes associated with
   a mount point. Active vnodes are those with a non-zero use or hold
   count, e.g., those vnodes that are not on the free list. Note that
   this list is in addition to the list of all the vnodes associated
   with a mount point.

   To avoid adding another set of linkage pointers to the vnode
   structure, the active list uses the existing linkage pointers
   used by the free list (previously named v_freelist, now renamed
   v_actfreelist).

   This update adds the MNT_VNODE_FOREACH_ACTIVE interface that loops
   over just the active vnodes associated with a mount point (typically
   less than 1% of the vnodes associated with the mount point).
 [...]
 @@ -1099,6 +1128,14 @@ insmntque1(struct vnode *vp, struct moun
       VNASSERT(mp-mnt_nvnodelistsize = 0, vp,
               (neg mount point vnode list size));
       mp-mnt_nvnodelistsize++;
 +     KASSERT((vp-v_iflag  VI_ACTIVE) == 0,
 +         (Activating already active vnode));
 +     vp-v_iflag |= VI_ACTIVE;
 +     mtx_lock(vnode_free_list_mtx);
 +     TAILQ_INSERT_HEAD(mp-mnt_activevnodelist, vp, v_actfreelist);
 +     mp-mnt_activevnodelistsize++;
 +     mtx_unlock(vnode_free_list_mtx);
 +     VI_UNLOCK(vp);
       MNT_IUNLOCK(mp);
       return (0);
  }


 Now, for every vnode that is activated, it has to go through global
 mutex, which seems like scalability issue to me. With ZFS it is typical
 to have a lot of file systems and this global mutex was not needed
 before (well, it was needed, but only to get vnode from the free list).

 If we require vnode interlock to be held during v_actfreelist
 manipulation then why can't we use interlock+vnode_free_list_mtx when
 operating on the free list and interlock+per-mountpoint-lock when
 operating on mnt_activevnodelist?

I think this is the better idea for this case and it should really be fixed.
However, note that a per-mount lock here is far from being ideal as
you would contest a lot on the mountpoint if you have a lot of
activated vnodes.
Anyway the approach you propose doesn't introduce any scalability
difference than what we already had in place for pre-234482.

Also, it would be good to implement things like:
   mtx_assert(MNT_MTX(mp), MA_OWNED);

by providing appropriate wrappers as we do in vnode interface.

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235797 - head/contrib/gcc

2012-05-22 Thread Bruce Evans

On Tue, 22 May 2012, David E. O'Brien wrote:


Log:
 Do not incorrectly warn when printing a quad_t using %qd on 64-bit platforms.


I think I like this, since it is technically correct, and will find a
different set of type mismatches.


Modified: head/contrib/gcc/c-format.c
==
--- head/contrib/gcc/c-format.c Tue May 22 17:44:01 2012(r235796)
+++ head/contrib/gcc/c-format.c Tue May 22 18:18:06 2012(r235797)
@@ -287,7 +287,11 @@ static const format_length_info printf_l
{
  { h, FMT_LEN_h, STD_C89, hh, FMT_LEN_hh, STD_C99 },
  { l, FMT_LEN_l, STD_C89, ll, FMT_LEN_ll, STD_C9L },
+#ifdef __LP64__
+  { q, FMT_LEN_l, STD_EXT, NULL, 0, 0 },
+#else
  { q, FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
+#endif
  { L, FMT_LEN_L, STD_C89, NULL, 0, 0 },
  { z, FMT_LEN_z, STD_C99, NULL, 0, 0 },
  { Z, FMT_LEN_z, STD_EXT, NULL, 0, 0 },



Of course, %qd should never be used.  On LP32, quad_t is long long, while
on LP64, quad_t is long, so any use of %qd required messy ifdefs or
casting a quad_t arg to long long to work on LP64.  Now, %qd actually
matches quad_t on LP64, so casting to long long is no longer needed, but
anything that does it is broken and would require changing to cast to
quad_t, or perhaps to omit the cast.  You might find too much bugware that
(1) uses %qd
(2) uses it on args that don't always have type quad_t
(3) casts to long long.  Casting to quad_t didn't work on LP64 before, so
probably nothing in FreeBSD does it.

Grepping for %q in /sys finds only a few uses of %q with a few type
mismatches (different mismatches before and after this commit).  (I
didn't grep for more compicated formats with stuff between the % and the
q.):

% ./compat/ndis/subr_ntoskrnl.c:printf(timer sets: %qu\n, 
ntoskrnl_timer_sets);
% ./compat/ndis/subr_ntoskrnl.c:printf(timer reloads: %qu\n, 
ntoskrnl_timer_reloads);
% ./compat/ndis/subr_ntoskrnl.c:printf(timer cancels: %qu\n, 
ntoskrnl_timer_cancels);
% ./compat/ndis/subr_ntoskrnl.c:printf(timer fires: %qu\n, 
ntoskrnl_timer_fires);

This was broken before on LP64.  It now works accidentally.  All these %qu
formats are bogus, since the variables don't have type quad_t; they have
type uint64_t.  Now that %q works, quad_t's are actually easier to print
that int64_t's since there is a format letter just for them.  But this
only helps if the variables actually have type quad_t.

% ./dev/esp/ncr53c9x.c: panic(%s: lun %qx for ecb %p does not exist, 
__func__,
% ./dev/esp/ncr53c9x.c: panic(%s: slot %d for lun %qx has %p 
instead of ecb 

This is under DIAGNOSTIC and is now broken.  Again the variable doesn't have
type [u_]quad_t.  It has type int64_t.  This is printed using the doubly-
incompatible format %qx (signed type but unsigned format; int64 type but
quad format letter).  Then to be bug for bug compatible with old gcc, this
incompatible format was cast to a different doubly-incompatible type.

% ./fs/msdosfs/msdosfs_vnops.c: printf(va_blocksize %lx, va_rdev %x, 
va_bytes %qx, va_gen %lx\n,

This is under the non-option MSDOSFS_DEBUG.  It was broken before, but now
works, since va_bytes actually has type u_quad_t and was not bogusly cast
to unsigned long long).

% ./fs/nfsclient/nfs_clstate.c: printf(lck typ=%d fst=%qd 
end=%qd\n,
% ./fs/nfsclient/nfs_clstate.c: printf(lck typ=%d fst=%qd 
end=%qd\n,

These are under !__FreeBSD__ ifdefs.  The ifdefs are related to the type
errors.  The types are u_int64_t.  Under FreeBSD, they are printed
correctly with only 1 type error for each: they are bogusly cast to
intmax_t (sign error), then printed with %ju (this matches the sign of
the variables but is a sign error relative to the cast.  The errors
normally cancel).  Under !__FreeBSD__, they are printed using %qd,
without any casts.  There is now a sign error in the format, and type
mismatches.  This would now compiler under FreeBSD despite all the
type mismatches -- the sign error doesn't matter in practice; u_int64_t
matches u_quad_t on all supported arches, and after your changes the
logical mismatch is no longer detected by gcc.

% ./geom/geom_map.c:ret = sscanf(line, search:%qi:%qi:%63c,

This has more than the usual density of bugs:
- scanf() is unusable but is used
- %q format is used
- % the variables are further from being quad_t's than usual.  They are
  off_t's.  off_t happens to have type int64_t, so this works accidentally
  on all supported arches.
- %qi is an unusual spelling of %qd.

You didn't change gcc for scanf.  q for it still maps to FMT_LEN_ll.
The above should never have compiled on LP64.

% ./gnu/fs/xfs/FreeBSD/xfs_buf.c:   printf(bread failed specvp %p blkno 
%qd BBTOB(len) %ld\n,

The variable has type xfs_daddr_t, which is __s64, which is signed long long
int in xfs/FreeBSD.  This used to be compatible with %qd, but no longer is.
xfs shouldn't 

Re: svn commit: r235797 - head/contrib/gcc

2012-05-22 Thread gnn
At Wed, 23 May 2012 06:05:06 +1000 (EST),
Bruce Evans wrote:
 
 On Tue, 22 May 2012, David E. O'Brien wrote:
 
  Log:
   Do not incorrectly warn when printing a quad_t using %qd on 64-bit 
  platforms.
 
 I think I like this, since it is technically correct, and will find a
 different set of type mismatches.
 
  Modified: head/contrib/gcc/c-format.c
  ==
  --- head/contrib/gcc/c-format.c Tue May 22 17:44:01 2012
  (r235796)
  +++ head/contrib/gcc/c-format.c Tue May 22 18:18:06 2012
  (r235797)
  @@ -287,7 +287,11 @@ static const format_length_info printf_l
  {
{ h, FMT_LEN_h, STD_C89, hh, FMT_LEN_hh, STD_C99 },
{ l, FMT_LEN_l, STD_C89, ll, FMT_LEN_ll, STD_C9L },
  +#ifdef __LP64__
  +  { q, FMT_LEN_l, STD_EXT, NULL, 0, 0 },
  +#else
{ q, FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
  +#endif
{ L, FMT_LEN_L, STD_C89, NULL, 0, 0 },
{ z, FMT_LEN_z, STD_C99, NULL, 0, 0 },
{ Z, FMT_LEN_z, STD_EXT, NULL, 0, 0 },
 
 
 Of course, %qd should never be used.  On LP32, quad_t is long long, while
 on LP64, quad_t is long, so any use of %qd required messy ifdefs or
 casting a quad_t arg to long long to work on LP64.  Now, %qd actually
 matches quad_t on LP64, so casting to long long is no longer needed, but
 anything that does it is broken and would require changing to cast to
 quad_t, or perhaps to omit the cast.  You might find too much bugware that
 (1) uses %qd
 (2) uses it on args that don't always have type quad_t
 (3) casts to long long.  Casting to quad_t didn't work on LP64 before, so
  probably nothing in FreeBSD does it.
 
 Grepping for %q in /sys finds only a few uses of %q with a few type
 mismatches (different mismatches before and after this commit).  (I
 didn't grep for more compicated formats with stuff between the % and the
 q.):
 
 % ./compat/ndis/subr_ntoskrnl.c:  printf(timer sets: %qu\n, 
 ntoskrnl_timer_sets);
 % ./compat/ndis/subr_ntoskrnl.c:  printf(timer reloads: %qu\n, 
 ntoskrnl_timer_reloads);
 % ./compat/ndis/subr_ntoskrnl.c:  printf(timer cancels: %qu\n, 
 ntoskrnl_timer_cancels);
 % ./compat/ndis/subr_ntoskrnl.c:  printf(timer fires: %qu\n, 
 ntoskrnl_timer_fires);
 
 This was broken before on LP64.  It now works accidentally.  All these %qu
 formats are bogus, since the variables don't have type quad_t; they have
 type uint64_t.  Now that %q works, quad_t's are actually easier to print
 that int64_t's since there is a format letter just for them.  But this
 only helps if the variables actually have type quad_t.
 
 % ./dev/esp/ncr53c9x.c:   panic(%s: lun %qx for ecb %p does not 
 exist, __func__,
 % ./dev/esp/ncr53c9x.c:   panic(%s: slot %d for lun %qx 
 has %p instead of ecb 
 
 This is under DIAGNOSTIC and is now broken.  Again the variable doesn't have
 type [u_]quad_t.  It has type int64_t.  This is printed using the doubly-
 incompatible format %qx (signed type but unsigned format; int64 type but
 quad format letter).  Then to be bug for bug compatible with old gcc, this
 incompatible format was cast to a different doubly-incompatible type.
 
 % ./fs/msdosfs/msdosfs_vnops.c:   printf(va_blocksize %lx, 
 va_rdev %x, va_bytes %qx, va_gen %lx\n,
 
 This is under the non-option MSDOSFS_DEBUG.  It was broken before, but now
 works, since va_bytes actually has type u_quad_t and was not bogusly cast
 to unsigned long long).
 
 % ./fs/nfsclient/nfs_clstate.c:   printf(lck typ=%d 
 fst=%qd end=%qd\n,
 % ./fs/nfsclient/nfs_clstate.c:   printf(lck typ=%d 
 fst=%qd end=%qd\n,
 
 These are under !__FreeBSD__ ifdefs.  The ifdefs are related to the type
 errors.  The types are u_int64_t.  Under FreeBSD, they are printed
 correctly with only 1 type error for each: they are bogusly cast to
 intmax_t (sign error), then printed with %ju (this matches the sign of
 the variables but is a sign error relative to the cast.  The errors
 normally cancel).  Under !__FreeBSD__, they are printed using %qd,
 without any casts.  There is now a sign error in the format, and type
 mismatches.  This would now compiler under FreeBSD despite all the
 type mismatches -- the sign error doesn't matter in practice; u_int64_t
 matches u_quad_t on all supported arches, and after your changes the
 logical mismatch is no longer detected by gcc.
 
 % ./geom/geom_map.c:  ret = sscanf(line, search:%qi:%qi:%63c,
 
 This has more than the usual density of bugs:
 - scanf() is unusable but is used
 - %q format is used
 - % the variables are further from being quad_t's than usual.  They are
off_t's.  off_t happens to have type int64_t, so this works accidentally
on all supported arches.
 - %qi is an unusual spelling of %qd.
 
 You didn't change gcc for scanf.  q for it still maps to FMT_LEN_ll.
 The above should never have compiled on LP64.
 
 % ./gnu/fs/xfs/FreeBSD/xfs_buf.c: 

Re: svn commit: r235797 - head/contrib/gcc

2012-05-22 Thread mdf
On Tue, May 22, 2012 at 1:05 PM, Bruce Evans b...@optusnet.com.au wrote:
 On Tue, 22 May 2012, David E. O'Brien wrote:

 Log:
  Do not incorrectly warn when printing a quad_t using %qd on 64-bit
 platforms.


 I think I like this, since it is technically correct, and will find a
 different set of type mismatches.

We run with the following at Isilon, which is somewhat bogus because
it allows a bit of sloppiness in types, but is also terribly
convenient since it means no casting on printf arguments is needed:

--- contrib/gcc/c-format.c  2012-05-22 14:08:23.538266746 -0700
+++ /data/sb/head/src/contrib/gcc/c-format.c2012-05-16
12:59:40.937016702 -0700
@@ -2298,10 +2570,20 @@ check_format_types (format_wanted_type *
 equivalent but the above test won't consider them equivalent.  */
   if (wanted_type == char_type_node
   (!pedantic || i  2)
   char_type_flag)
continue;
+
+  /* Isilon: FreeBSD defines int64_t (and others) as one type (e.g. long
+long) on i386 and another type (e.g. long) on amd64. This prevents
+the use of a common format specifier. Treat equal sized integer types
+as equivalent. */
+  if (TREE_CODE (wanted_type) == INTEGER_TYPE
+  TREE_CODE (cur_type) == INTEGER_TYPE
+  int_size_in_bytes (wanted_type) == int_size_in_bytes (cur_type))
+continue;
+
   /* Now we have a type mismatch.  */
   format_type_warning (types-name, format_start, format_length,
   wanted_type, types-pointer_count,
   types-wanted_type_name, orig_cur_type, arg_num);
 }


If there's no objections, I (or David or anyone else) can commit to
the FreeBSD repository.

Cheers,
matthew
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235797 - head/contrib/gcc

2012-05-22 Thread Marcel Moolenaar

On May 22, 2012, at 2:07 PM, m...@freebsd.org wrote:

 On Tue, May 22, 2012 at 1:05 PM, Bruce Evans b...@optusnet.com.au wrote:
 On Tue, 22 May 2012, David E. O'Brien wrote:
 
 Log:
  Do not incorrectly warn when printing a quad_t using %qd on 64-bit
 platforms.
 
 
 I think I like this, since it is technically correct, and will find a
 different set of type mismatches.
 
 We run with the following at Isilon, which is somewhat bogus because
 it allows a bit of sloppiness in types, but is also terribly
 convenient since it means no casting on printf arguments is needed:
 
 --- contrib/gcc/c-format.c  2012-05-22 14:08:23.538266746 -0700
 +++ /data/sb/head/src/contrib/gcc/c-format.c2012-05-16
 12:59:40.937016702 -0700
 @@ -2298,10 +2570,20 @@ check_format_types (format_wanted_type *
 equivalent but the above test won't consider them equivalent.  */
   if (wanted_type == char_type_node
   (!pedantic || i  2)
   char_type_flag)
continue;
 +
 +  /* Isilon: FreeBSD defines int64_t (and others) as one type (e.g. long
 +long) on i386 and another type (e.g. long) on amd64. This prevents
 +the use of a common format specifier. Treat equal sized integer types
 +as equivalent. */
 +  if (TREE_CODE (wanted_type) == INTEGER_TYPE
 +  TREE_CODE (cur_type) == INTEGER_TYPE
 +  int_size_in_bytes (wanted_type) == int_size_in_bytes (cur_type))
 +continue;
 +
   /* Now we have a type mismatch.  */
   format_type_warning (types-name, format_start, format_length,
   wanted_type, types-pointer_count,
   types-wanted_type_name, orig_cur_type, arg_num);
 }
 
 
 If there's no objections, I (or David or anyone else) can commit to
 the FreeBSD repository.

I think such would make support for external (i.e. non-FreeBSD) toolchains
even more problematic. Our format extensions are a big hurdle already. I
think we should not tweak the compiler.

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235816 - head/sys/dev/bce

2012-05-22 Thread Pyun YongHyeon
Author: yongari
Date: Wed May 23 01:20:25 2012
New Revision: 235816
URL: http://svn.freebsd.org/changeset/base/235816

Log:
  Make IPMI work in the bce driver even when the interface is
  configured down.  Formerly, IPMI communication was lost whenever the
  interface was not up.  The reason was that the BCE_EMAC_MODE
  register was not configured with the correct media settings.  There
  are two parts to the fix.
  
  First, resetting the chip in bce_reset() causes the BCE_EMAC_MODE
  register to be initialized to a default value that does not
  necessarily correspond to the actual media settings.  The fix
  implemented here is a bit of a hack.  Ideally, at the end of
  bce_reset() we would poll the PHY to determine the negotiated media,
  and then we would set the BCE_EMAC_MODE register accordingly.  That
  is difficult, since the PHY is abstracted behind the MII layer and is
  not supposed to be queried directly from the MAC driver.  Instead,
  we read the BCE_EMAC_MODE register at the beginning of bce_reset()
  and then restore its media bits to their original values before
  returning.  If IPMI is up and running, then the link is already
  established and the BCE_EMAC_MODE register is already set appropriately
  when bce_reset() is called.  If IPMI is not running, no harm is
  done by preserving the BCE_EMAC_MODE settings.  The driver will set
  the register properly once the interface is configured up and link
  is established.
  
  Second, bce_miibus_statchg() is sometimes called when the link is
  down.  In that case, the reported media settings are invalid.
  Formerly, the driver used them anyway to setup the BCE_EMAC_MODE
  register.  We now avoid changing any MAC registers unless link is
  active and the reported media settings are valid.
  
  Submitted by: jdp
  Tested by:jdp
  MFC after:5 days

Modified:
  head/sys/dev/bce/if_bce.c

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Wed May 23 00:46:19 2012(r235815)
+++ head/sys/dev/bce/if_bce.c   Wed May 23 01:20:25 2012(r235816)
@@ -2062,6 +2062,11 @@ bce_miibus_statchg(device_t dev)
media_status = mii-mii_media_status;
}
 
+   /* Ignore invalid media status. */
+   if ((media_status  (IFM_ACTIVE | IFM_AVALID)) !=
+   (IFM_ACTIVE | IFM_AVALID))
+   goto bce_miibus_statchg_exit;
+
val = REG_RD(sc, BCE_EMAC_MODE);
val = ~(BCE_EMAC_MODE_PORT | BCE_EMAC_MODE_HALF_DUPLEX |
BCE_EMAC_MODE_MAC_LOOP | BCE_EMAC_MODE_FORCE_LINK |
@@ -2131,6 +2136,7 @@ bce_miibus_statchg(device_t dev)
 
/* ToDo: Update watermarks in bce_init_rx_context(). */
 
+bce_miibus_statchg_exit:
DBEXIT(BCE_VERBOSE_PHY);
 }
 
@@ -4997,14 +5003,25 @@ bce_stop(struct bce_softc *sc)
 static int
 bce_reset(struct bce_softc *sc, u32 reset_code)
 {
-   u32 val;
+   u32 emac_mode_save, val;
int i, rc = 0;
+   static const u32 emac_mode_mask = BCE_EMAC_MODE_PORT |
+   BCE_EMAC_MODE_HALF_DUPLEX | BCE_EMAC_MODE_25G;
 
DBENTER(BCE_VERBOSE_RESET);
 
DBPRINT(sc, BCE_VERBOSE_RESET, %s(): reset_code = 0x%08X\n,
__FUNCTION__, reset_code);
 
+   /*
+* If ASF/IPMI is operational, then the EMAC Mode register already
+* contains appropriate values for the link settings that have
+* been auto-negotiated.  Resetting the chip will clobber those
+* values.  Save the important bits so we can restore them after
+* the reset.
+*/
+   emac_mode_save = REG_RD(sc, BCE_EMAC_MODE)  emac_mode_mask;
+
/* Wait for pending PCI transactions to complete. */
REG_WR(sc, BCE_MISC_ENABLE_CLR_BITS,
BCE_MISC_ENABLE_CLR_BITS_TX_DMA_ENABLE |
@@ -5094,6 +5111,11 @@ bce_reset(struct bce_softc *sc, u32 rese
bce_fw_cap_init(sc);
 
 bce_reset_exit:
+   /* Restore EMAC Mode bits needed to keep ASF/IPMI running. */
+   val = REG_RD(sc, BCE_EMAC_MODE);
+   val = (val  ~emac_mode_mask) | emac_mode_save;
+   REG_WR(sc, BCE_EMAC_MODE, val);
+
DBEXIT(BCE_VERBOSE_RESET);
return (rc);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r235601 - head/include/protocols

2012-05-22 Thread Benjamin Kaduk

On Mon, 21 May 2012, John Baldwin wrote:


On Friday, May 18, 2012 11:24:36 am Gleb Kurtsou wrote:

On (18/05/2012 09:41), John Baldwin wrote:

On Friday, May 18, 2012 6:01:31 am Gleb Kurtsou wrote:

Author: gleb
Date: Fri May 18 10:01:31 2012
New Revision: 235601
URL: http://svn.freebsd.org/changeset/base/235601

Log:
  Don't use ino_t in dumprestore protocol definition.

  Since ino_t size is about to change to 64-bits, replace ino_t used in
  dump protocol definition with 32-bit dump_ino_t to preserve backward
  compatibility.  At some point, it may be necessary to use spare fields
  in struct in order to fully support 64-bit inode numbers.

  Sponsored by: Google Summer of Code 2011


A question about your stat changes: did you expand dev_t to 32 bits for

the

AFS folks, or did you leave it as 16 bits?


dev_t is already 32-bit. Changing it to 64-bit was discussed at some
point and from what I recall no decision was made:

http://marc.info/?t=12911947875r=1w=2

I'm going to commit preparatory changes only for now. Then publish diff
for testing. We can still change dev_t to 64-bit if needed. Although I
didn't work on it.


Ah, it was 64-bit they asked for.  If it is easy to do so, I'd favor changing
it since you've already done all the hard work of rolling a new stat
structure.  I'd rather err on wasting 32-bits for dev_t than having to do all
this over again.


Hi John,

Thanks for remembering this -- I'm still pretty swamped with other stuff 
and missed it.

It would indeed be nice for us to have a 64-bit dev_t to work with.

-Ben
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r235821 - head/sys/dev/bge

2012-05-22 Thread Pyun YongHyeon
Author: yongari
Date: Wed May 23 03:35:08 2012
New Revision: 235821
URL: http://svn.freebsd.org/changeset/base/235821

Log:
  Don't force max payload size to 128. Root complex and Endpoint will
  negotiate with each other on the TLP payload size so blindly
  forcing the size to 128 can cause a completion error which in turn
  will stop device.
  
  Reported by:  Geans Pin  geanspin  broadcom dot com 
  MFC after:5 days

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed May 23 02:43:28 2012(r235820)
+++ head/sys/dev/bge/if_bge.c   Wed May 23 03:35:08 2012(r235821)
@@ -3638,8 +3638,6 @@ bge_reset(struct bge_softc *sc)
/* Clear enable no snoop and disable relaxed ordering. */
devctl = ~(PCIM_EXP_CTL_RELAXED_ORD_ENABLE |
PCIM_EXP_CTL_NOSNOOP_ENABLE);
-   /* Set PCIE max payload size to 128. */
-   devctl = ~PCIM_EXP_CTL_MAX_PAYLOAD;
pci_write_config(dev, sc-bge_expcap + PCIR_EXPRESS_DEVICE_CTL,
devctl, 2);
/* Clear error status. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org