remove kern.arand from sysctl.8 and rnd.c (comment)

2016-09-22 Thread Rob Pierce

Index: sysctl.8
===
RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
retrieving revision 1.205
diff -u -p -r1.205 sysctl.8
--- sysctl.87 Sep 2016 17:30:12 -   1.205
+++ sysctl.823 Sep 2016 02:16:14 -
@@ -144,7 +144,6 @@ and a few require a kernel compiled with
 .It kern.sysvmsg Ta integer Ta no
 .It kern.sysvsem Ta integer Ta no
 .It kern.sysvshm Ta integer Ta no
-.It kern.arandom Ta u_int Ta no
 .It kern.msgbufsize Ta integer Ta no
 .It kern.malloc.buckets Ta string Ta no
 .It kern.malloc.bucket. Ta string Ta no

Index: rnd.c
===
RCS file: /cvs/src/sys/dev/rnd.c,v
retrieving revision 1.186
diff -u -p -r1.186 rnd.c
--- rnd.c   22 Sep 2016 22:04:02 -  1.186
+++ rnd.c   23 Sep 2016 02:25:06 -
@@ -85,9 +85,8 @@
  * The output of this single ChaCha20 engine is then shared amongst many
  * consumers in the kernel and userland via a few interfaces:
  * arc4random_buf(), arc4random(), arc4random_uniform(), randomread()
- * for the set of /dev/random nodes, the sysctl kern.arandom, and the
- * system call getentropy(), which provides seeds for process-context
- * pseudorandom generators.
+ * for the set of /dev/random nodes, and the system call getentropy(),
+ * which provides seeds for process-context pseudorandom generators.
  *
  * Acknowledgements:
  * =



Two more arm aeabi functions for the kernel

2016-09-22 Thread Mark Kettenis
These functions are necessary to build our kernel with clang.  I
picked these from NetBSD as I didn't quite like the way FreeBSD
implemented them.  I stripped all the unecessary bits from the NetBSD
implementation (which is shared with userland).

Do the file names with the leading underscores bother people?  I could
rename the files ldivmod.S and uldivmod.S.

These seem to be the last two missing symbols.

ok?


Index: lib/libkern/arch/arm/__aeabi_ldivmod.S
===
RCS file: lib/libkern/arch/arm/__aeabi_ldivmod.S
diff -N lib/libkern/arch/arm/__aeabi_ldivmod.S
--- /dev/null   1 Jan 1970 00:00:00 -
+++ lib/libkern/arch/arm/__aeabi_ldivmod.S  22 Sep 2016 20:03:42 -
@@ -0,0 +1,133 @@
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#ifdef __ARMEB__
+#defineALO r1  /* incoming numerator, outgoing quotient */
+#defineAHI r0  /* incoming numerator, outgoing quotient */
+#defineBLO r3  /* incoming denominator, outgoing remainder */
+#defineBHI r2  /* incoming denominator, outgoing remainder */
+#else
+#defineALO r0  /* incoming numerator, outgoing quotient */
+#defineAHI r1  /* incoming numerator, outgoing quotient */
+#defineBLO r2  /* incoming denominator, outgoing remainder */
+#defineBHI r3  /* incoming denominator, outgoing remainder */
+#endif
+
+ENTRY(__aeabi_ldivmod)
+   push{r4-r6, lr}
+#defineNEG r5
+   movsNEG, #0
+
+   cmp BHI, #0
+   bge 2f
+   movsNEG, #1 /* flip quotient sign */
+   bl  .Lnegate_b
+   bcs .Lmaxdenom
+
+2:
+   cmp AHI, #0
+   eorlt   NEG, NEG, #3/* flip quotient sign, flip remainder sign */
+   bllt.Lnegate_a
+
+   /*
+* Arguments are setup, allocate some stack for the remainder
+* and call __qdivrem for the heavy lifting.
+*/
+   sub sp, sp, #16
+   addsr4, sp, #8
+   str r4, [sp]
+   bl  __qdivrem
+   add sp, sp, #8
+
+   /*
+* The quotient is already in the right place and neither value
+* needs its sign flipped.
+*/
+   cmp NEG, #0 /* any signs to flip? */
+   beq .Lnegate_neither
+
+   cmp NEG, #2 /* does remainder need to be negative? */
+   beq .Lnegate_b_only /* 2 means b only */
+   bgt .Lnegate_both   /* 3 means both */
+.Lnegate_a_only:
+   bl  .Lnegate_a  /* 1 means a only */
+.Lnegate_neither:
+   pop {r2-r6, pc} /* grab b from stack */
+.Lnegate_both:
+   bl  .Lnegate_a
+.Lnegate_b_only:
+   pop {r2-r3} /* get remainder */
+   bl  .Lnegate_b  /* negate it */
+   pop {r4-r6, pc}
+
+   .align  0
+.Lnegate_a:
+   negsALO, ALO
+   rsc AHI, AHI, #0
+   mov pc, lr
+
+   .align  0
+.Lnegate_b:
+   negsBLO, BLO
+   rsc BHI, BHI, #0
+   mov pc, lr
+
+   .align  0
+.Lmaxdenom:
+   /*
+* We had a carry so the denominator must have INT64_MIN
+* Also BLO and BHI never changed values so we can use
+* them to see if the numerator has the same value.  We
+* don't have to worry about sign.
+*/
+   cmp BHI, AHI
+   cmpeq   BLO, ALO
+   bne 1f
+
+   /*
+* They were 

Re: aeabi stuff in libkern

2016-09-22 Thread Philip Guenther
On Thu, Sep 22, 2016 at 8:10 AM, Mark Kettenis  wrote:
> clang generates these calls using the official aeabi names instead of
> the gcc names.  Just add an alias for them.  FreeBSD does something
> similar.
>
> ok?

ok guenther@



Migrated Link in faq6.html

2016-09-22 Thread wuy13

The link to "run netstart" is incorrect. Corrected link to the man page.

Index: faq6.html
===
RCS file: /cvs/www/faq/faq6.html,v
retrieving revision 1.416
diff -u -p -r1.416 faq6.html
--- faq6.html   18 Sep 2016 11:22:37 -  1.416
+++ faq6.html   22 Sep 2016 12:33:03 -
@@ -325,7 +325,7 @@ inet alias 192.168.0.3 255.255.255.255
 inet alias 192.168.0.4 255.255.255.255
 

-Once you've created this file, run 
netstart or
+Once you've created this file, href="http://man.openbsd.org/netstart;>run netstart or

 reboot.
 To view all aliases, use $ ifconfig -A



aeabi stuff in libkern

2016-09-22 Thread Mark Kettenis
clang generates these calls using the official aeabi names instead of
the gcc names.  Just add an alias for them.  FreeBSD does something
similar.

ok?


Index: lib/libkern/arch/arm/divsi3.S
===
RCS file: /cvs/src/sys/lib/libkern/arch/arm/divsi3.S,v
retrieving revision 1.3
diff -u -p -r1.3 divsi3.S
--- lib/libkern/arch/arm/divsi3.S   30 Dec 2014 08:12:52 -  1.3
+++ lib/libkern/arch/arm/divsi3.S   22 Sep 2016 15:07:07 -
@@ -385,3 +385,6 @@ L_udivide_l1:
addhs   r3, r3, r2
mov r0, r3
mov pc, lr
+
+STRONG_ALIAS(__aeabi_idiv, __divsi3)
+STRONG_ALIAS(__aeabi_uidiv, __udivsi3)



Re: Check terminal width in ps(1)

2016-09-22 Thread Theo Buehler
On Thu, Sep 22, 2016 at 04:23:08AM -0600, Anthony J. Bentley wrote:
> Hi,
> 
> Unlike all the other software in the tree that checks terminal sizes, 
> ps(1) used to check the stdin and stderr terminal sizes as well as stdout.
> When I unified the terminal size checks in the tree in March, I missed
> this, and now "ps aux | blah" gets wrapped to 79 characters no matter
> how big the terminal is.
> 
> The below diff brings back the old behavior: if the output is a pipe,
> ps will check if either stderr or stdin is a terminal and if so will use
> its width.
> 
> ok?

ok.

It's nicer this way than the negated checks that were there in r1.69.

> 
> Index: ps.c
> ===
> RCS file: /cvs/src/bin/ps/ps.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 ps.c
> --- ps.c  17 Mar 2016 05:27:10 -  1.70
> +++ ps.c  22 Sep 2016 10:14:10 -
> @@ -105,7 +105,10 @@ main(int argc, char *argv[])
>   termwidth = 0;
>   if ((cols = getenv("COLUMNS")) != NULL)
>   termwidth = strtonum(cols, 1, INT_MAX, NULL);
> - if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 &&
> + if (termwidth == 0 &&
> + (ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 ||
> + ioctl(STDERR_FILENO, TIOCGWINSZ, ) == 0 ||
> + ioctl(STDIN_FILENO, TIOCGWINSZ, ) == 0) &&
>   ws.ws_col > 0)
>   termwidth = ws.ws_col - 1;
>   if (termwidth == 0)
> Index: ps.1
> ===
> RCS file: /cvs/src/bin/ps/ps.1,v
> retrieving revision 1.108
> diff -u -p -r1.108 ps.1
> --- ps.1  8 Sep 2016 15:54:36 -   1.108
> +++ ps.1  22 Sep 2016 10:14:10 -
> @@ -543,8 +543,13 @@ If set to a positive integer,
>  output is formatted to the given width in columns.
>  Otherwise,
>  .Nm
> -defaults to the terminal width \(mi 1, or 79 columns if the output is not a
> -terminal.
> +defaults to the terminal width \(mi 1,
> +or 79 columns if none of
> +.Dv stdout ,
> +.Dv stderr
> +and
> +.Dv stdin
> +are a terminal.
>  .It Ev TZ
>  The time zone to use when displaying dates.
>  See
> 



Check terminal width in ps(1)

2016-09-22 Thread Anthony J. Bentley
Hi,

Unlike all the other software in the tree that checks terminal sizes, 
ps(1) used to check the stdin and stderr terminal sizes as well as stdout.
When I unified the terminal size checks in the tree in March, I missed
this, and now "ps aux | blah" gets wrapped to 79 characters no matter
how big the terminal is.

The below diff brings back the old behavior: if the output is a pipe,
ps will check if either stderr or stdin is a terminal and if so will use
its width.

ok?

Index: ps.c
===
RCS file: /cvs/src/bin/ps/ps.c,v
retrieving revision 1.70
diff -u -p -r1.70 ps.c
--- ps.c17 Mar 2016 05:27:10 -  1.70
+++ ps.c22 Sep 2016 10:14:10 -
@@ -105,7 +105,10 @@ main(int argc, char *argv[])
termwidth = 0;
if ((cols = getenv("COLUMNS")) != NULL)
termwidth = strtonum(cols, 1, INT_MAX, NULL);
-   if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 &&
+   if (termwidth == 0 &&
+   (ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 ||
+   ioctl(STDERR_FILENO, TIOCGWINSZ, ) == 0 ||
+   ioctl(STDIN_FILENO, TIOCGWINSZ, ) == 0) &&
ws.ws_col > 0)
termwidth = ws.ws_col - 1;
if (termwidth == 0)
Index: ps.1
===
RCS file: /cvs/src/bin/ps/ps.1,v
retrieving revision 1.108
diff -u -p -r1.108 ps.1
--- ps.18 Sep 2016 15:54:36 -   1.108
+++ ps.122 Sep 2016 10:14:10 -
@@ -543,8 +543,13 @@ If set to a positive integer,
 output is formatted to the given width in columns.
 Otherwise,
 .Nm
-defaults to the terminal width \(mi 1, or 79 columns if the output is not a
-terminal.
+defaults to the terminal width \(mi 1,
+or 79 columns if none of
+.Dv stdout ,
+.Dv stderr
+and
+.Dv stdin
+are a terminal.
 .It Ev TZ
 The time zone to use when displaying dates.
 See



Re: Minor improvement to socket(2) man page

2016-09-22 Thread Philip Guenther
On Wed, Sep 21, 2016 at 6:23 PM, Michael McConville  wrote:
> The current version is somewhat awkward and forgets to mention that
> errno is set. I adapted the paragraph found in most other system call
> man pages.

There are six syscalls that return an fd on success...and their
manpages all have totally different wording for the return value.
Whee.

accept
 The call returns -1 on error.  If it succeeds, it returns a non-negative
 integer that is a descriptor for the accepted socket.

fhopen
 Upon successful completion, fhopen() returns the file descriptor for the
 opened file, while fhstat() and fhstatfs() return 0.  Otherwise, -1 is
 returned and errno is set to indicate the error.

kqueue
 kqueue() creates a new kernel event queue and returns a file descriptor.
 If there was an error creating the kernel event queue, a value of -1 is
 returned and errno set.

open
 If successful, open() returns a non-negative integer, termed a file
 descriptor.  Otherwise, a value of -1 is returned and errno is set to
 indicate the error.

openat: same manpage as open but totally unmentioned in the RETURN
VALUES section

socket
 A -1 is returned if an error occurs, otherwise the return value is a
 descriptor referencing the socket.

  Some consistency that doesn't sacrifice clarity would be nice...



[PATCH] Remove deprecated newaliases NOTE

2016-09-22 Thread Consus
Since smtpd now uses file table instead of db this NOTE is not accurate.
---
 etc/mail/aliases | 4 
 1 file changed, 4 deletions(-)

diff --git a/etc/mail/aliases b/etc/mail/aliases
index fe08bf1..38f7691 100644
--- a/etc/mail/aliases
+++ b/etc/mail/aliases
@@ -4,10 +4,6 @@
 #  Aliases in this file will NOT be expanded in the header from
 #  Mail, but WILL be visible over networks or from /usr/libexec/mail.local.
 #
-#  >>  The program "newaliases" must be run after
-#  >> NOTE >>  this file is updated for any changes to
-#  >>  show through to smtpd.
-#
 
 # Basic system aliases -- these MUST be present
 MAILER-DAEMON: postmaster
-- 
2.9.3