regress: don't needlessly fiddle with MALLOC_OPTIONS

2021-09-01 Thread Jasper Lievisse Adriaanse
Hi,

As discussed earlier with bluhm, regress tests shouldn't set or modify
MALLOC_OPTIONS (except under very specific situations, like malloc tests).
It would be better to set the options globally through sysctl when
running the suite, as bluhm does.

So remove most cases of MALLOC_OPTIONS from regress and amend the
manpage guidelines accordingly.

OK?

diff 9ca4957b0bf957d4e3a97547c791aeac34911aaf /usr/src
blob - a40fad57e604ca5bf7ccfee8c91bcb68bbb46456
file + regress/bin/csh/Makefile
--- regress/bin/csh/Makefile
+++ regress/bin/csh/Makefile
@@ -20,7 +20,6 @@ REGRESS_TARGETS+= env
 .SUFFIXES: .in
 
 .in:
-   env -i MALLOC_OPTIONS=S ${CSH} <${.CURDIR}/${@}.in 2>&1 | \
-   diff -u ${.CURDIR}/${@}.ok -
+   ${CSH} <${.CURDIR}/${@}.in 2>&1 | diff -u ${.CURDIR}/${@}.ok -
 
 .include 
blob - 3341dabb1403688df8f8e16fa2e31dcd3739d108
file + regress/bin/csh/filec.sh
--- regress/bin/csh/filec.sh
+++ regress/bin/csh/filec.sh
@@ -50,8 +50,7 @@ cd ~
 !
 
 HOME=$tmp
-MALLOC_OPTIONS=S
-export HOME MALLOC_OPTIONS
+export HOME
 
 # NL: Execute command.
 testseq "echo a\n" "? echo a\r\na\r\n? "
blob - aee8864d3f8965a05eb4ca63f0ee80979d4d1591
file + regress/bin/ksh/edit/emacs.sh
--- regress/bin/ksh/edit/emacs.sh
+++ regress/bin/ksh/edit/emacs.sh
@@ -25,10 +25,9 @@ EDITOR=
 ENV=
 HISTFILE=
 MAIL=
-MALLOC_OPTIONS=S
 PS1=' # '
 VISUAL=emacs
-export EDITOR ENV HISTFILE MAIL MALLOC_OPTIONS PS1 VISUAL
+export EDITOR ENV HISTFILE MAIL PS1 VISUAL
 
 # The function testseq() sets up a pseudo terminal and feeds its first
 # argument to a shell on standard input.  It then checks that output
blob - be15c4d1ee8d04be8f36c6f0d647241edbeb70f1
file + regress/bin/ksh/edit/vi.sh
--- regress/bin/ksh/edit/vi.sh
+++ regress/bin/ksh/edit/vi.sh
@@ -25,10 +25,9 @@ EDITOR=
 ENV=
 HISTFILE=
 MAIL=
-MALLOC_OPTIONS=S
 PS1=' # '
 VISUAL=vi
-export EDITOR ENV HISTFILE MAIL MALLOC_OPTIONS PS1 VISUAL
+export EDITOR ENV HISTFILE MAIL PS1 VISUAL
 
 # The function testseq() sets up a pseudo terminal and feeds its first
 # argument to a shell on standard input.  It then checks that output
blob - 4a35e2664dba5fab3029d832bf181cd63bfa8c0a
file + regress/bin/ksh/th
--- regress/bin/ksh/th
+++ regress/bin/ksh/th
@@ -56,8 +56,7 @@
 #  missing, NAME is removed from the
 #  environment.  Programs are run with
 #  the following minimal environment:
-#  USER, LOGNAME, HOME, PATH, SHELL,
-#  MALLOC_OPTIONS=S
+#  USER, LOGNAME, HOME, PATH, SHELL
 #  (values from the current environment
 #  takes higher precedence).
 #  file-setup  mps Used to create files, directories
@@ -233,10 +232,8 @@ grep($do_test{$_} = 1, @ARGV);
 $all_tests = @ARGV == 0;
 
 # Set up a very minimal environment
-%new_env = (
-MALLOC_OPTIONS => 'S',
-);
-foreach $env (('USER', 'LOGNAME', 'HOME', 'PATH', 'SHELL', 'MALLOC_OPTIONS')) {
+%new_env = ();
+foreach $env (('USER', 'LOGNAME', 'HOME', 'PATH', 'SHELL')) {
 $new_env{$env} = $ENV{$env} if defined $ENV{$env};
 }
 if (defined $opt_e) {
blob - f70d94bd6299646db94cbd0ef873bda47536d474
file + regress/usr.bin/doas/Makefile
--- regress/usr.bin/doas/Makefile
+++ regress/usr.bin/doas/Makefile
@@ -114,8 +114,7 @@ ${t}:
/bin/echo $$tdir/bin/echo; \
${SUDO} install -o ${BINOWN} -g ${BINGRP} -m 4555 \
/usr/bin/doas $$tdir/usr/bin/doas; \
-   ${SUDO} env MALLOC_OPTIONS=S chroot -u nobody $$tdir \
-   /usr/bin/doas echo okay
+   ${SUDO} chroot -u nobody $$tdir /usr/bin/doas echo okay
 . endif
 .endfor
 
blob - 7b9898b8ed49bbb82e891f12a98415ac996f9033
file + regress/usr.bin/mail/send.sh
--- regress/usr.bin/mail/send.sh
+++ regress/usr.bin/mail/send.sh
@@ -43,8 +43,7 @@ set ask
 !
 
 HOME=$tmp
-MALLOC_OPTIONS=S
-export HOME MALLOC_OPTIONS
+export HOME
 
 # VERASE: Delete character.
 testseq "\0177" "Subject: "
blob - 64237f6cc9abe1803f2082d0c8d0b91d214b58da
file + regress/usr.bin/make/Makefile
--- regress/usr.bin/make/Makefile
+++ regress/usr.bin/make/Makefile
@@ -8,191 +8,190 @@ REGRESS_TARGETS= t1  t2  t3  t4  t5  t6  t7  t8  t
 
 REGRESS_EXPECTED_FAILURES = t14 t17 t18
 
-MALLOC_OPTIONS?=J
 t1: t1.out
-   env -i PATH=${PATH} MALLOC_OPTIONS=${MALLOC_OPTIONS} ${MAKE} -e -r -f 
${.CURDIR}/mk1 | diff - t1.out
+   env -i PATH=${PATH} ${MAKE} -e -r -f ${.CURDIR}/mk1 | diff - t1.out
 
 # This is a POSIX test. pmake does not pass variables to submakes until
 # after OpenBSD 2.7.
 t2:
-   cd ${.CURDIR} && env -i PATH=${PATH} MALLOC_OPTIONS=${MALLOC_OPTIONS} 
${MAKE} -r -f mk2| diff - t2.out
+   cd ${.CURDIR} && env -i PATH=${PATH} ${MAKE} -r -f mk2| diff - t2.out
 
 t3:
-   cd ${.CURDIR} && env -i PATH=${PATH} MALLOC_OPTIONS=${MALLOC_OPTIONS} 
${MAKE} -r 

Re: ddb trace: fix output for too many arguments

2021-08-30 Thread Jasper Lievisse Adriaanse
On Mon, Jul 12, 2021 at 08:18:20PM +0200, Mark Kettenis wrote:
> > Date: Mon, 12 Jul 2021 20:11:30 +0200
> > From: Jasper Lievisse Adriaanse 
> > 
> > On Sun, Jul 11, 2021 at 03:58:05PM +0200, Jasper Lievisse Adriaanse wrote:
> > > Hi,
> > > 
> > > When printing a trace from ddb, some architectures are limited by the 
> > > number of
> > > registers which are used to pass arguments. If the number of arguments to 
> > > a function
> > > exceeded this number, the code in db_stack_trace_print() would print that 
> > > many arguments
> > > without any indication that one or more arguments aren't printed.
> > > 
> > > Here's a diff that tweaks the output to make it clear there were more 
> > > arguments.
> > > Do we want to print ',...' for each ommited argument (like this diff does)
> > > or perhaps just a single ',...'?
> > 
> > I think just printing a single instance of ',...' gets the point across.
> > OK?
> 
> Actually, since we use -msave-args on amd64 the arguments are saved on
> the stack.  I think this means there is no limit on the number of
> arguments we can print...
Good point, there's no reason to cap narg at 6 any longer unless 
db_ctf_func_numargs()
failed. Here's the diff for amd64. Other platforms could benefit from the
",..." approach but those'll be separate diffs.

OK?

Index: db_trace.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.53
diff -u -p -r1.53 db_trace.c
--- db_trace.c  14 May 2020 06:58:54 -  1.53
+++ db_trace.c  30 Aug 2021 08:44:36 -
@@ -164,8 +164,7 @@ db_stack_trace_print(db_expr_t addr, int
}
}
 
-   narg = db_ctf_func_numargs(sym);
-   if (narg < 0 || narg > 6)
+   if ((narg = db_ctf_func_numargs(sym)) < 0)
narg = 6;
 
if (name == NULL)



Re: ddb trace: fix output for too many arguments

2021-07-12 Thread Jasper Lievisse Adriaanse
On Sun, Jul 11, 2021 at 03:58:05PM +0200, Jasper Lievisse Adriaanse wrote:
> Hi,
> 
> When printing a trace from ddb, some architectures are limited by the number 
> of
> registers which are used to pass arguments. If the number of arguments to a 
> function
> exceeded this number, the code in db_stack_trace_print() would print that 
> many arguments
> without any indication that one or more arguments aren't printed.
> 
> Here's a diff that tweaks the output to make it clear there were more 
> arguments.
> Do we want to print ',...' for each ommited argument (like this diff does)
> or perhaps just a single ',...'?

I think just printing a single instance of ',...' gets the point across.
OK?

Index: arch/amd64/amd64/db_trace.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.53
diff -u -p -r1.53 db_trace.c
--- arch/amd64/amd64/db_trace.c 14 May 2020 06:58:54 -  1.53
+++ arch/amd64/amd64/db_trace.c 12 Jul 2021 18:08:21 -
@@ -137,7 +137,7 @@ db_stack_trace_print(db_expr_t addr, int
 
lastframe = 0;
while (count && frame != 0) {
-   int narg;
+   int narg, extra_args = 0;
unsigned inti;
char *  name;
db_expr_t   offset;
@@ -165,8 +165,12 @@ db_stack_trace_print(db_expr_t addr, int
}
 
narg = db_ctf_func_numargs(sym);
-   if (narg < 0 || narg > 6)
+   if (narg < 0)
narg = 6;
+   else if (narg > 6) {
+   narg = 6;
+   extra_args = 1;
+   }
 
if (name == NULL)
(*pr)("%lx(", callpc);
@@ -204,6 +208,10 @@ db_stack_trace_print(db_expr_t addr, int
if (--narg != 0)
(*pr)(",");
}
+
+   if (extra_args)
+   (*pr)(",...");
+
(*pr)(") at ");
db_printsym(callpc, DB_STGY_PROC, pr);
(*pr)("\n");
Index: arch/powerpc/ddb/db_trace.c
===
RCS file: /cvs/src/sys/arch/powerpc/ddb/db_trace.c,v
retrieving revision 1.17
diff -u -p -r1.17 db_trace.c
--- arch/powerpc/ddb/db_trace.c 14 May 2020 06:58:54 -  1.17
+++ arch/powerpc/ddb/db_trace.c 12 Jul 2021 18:08:21 -
@@ -123,7 +123,7 @@ db_stack_trace_print(db_expr_t addr, int
Elf_Sym *sym;
char*name;
char c, *cp = modif;
-   int  i, narg, trace_proc = 0;
+   int  i, narg, trace_proc = 0, extra_args = 0;
 
while ((c = *cp++) != 0) {
if (c == 't')
@@ -158,8 +158,12 @@ db_stack_trace_print(db_expr_t addr, int
(*pr)("at 0x%lx", lr - 4);
} else {
narg = db_ctf_func_numargs(sym);
-   if (narg < 0 || narg > 8)
+   if (narg < 0)
narg = 8;
+   else if (narg > 8) {
+   narg = 8;
+   extra_args = 1;
+   }
 
(*pr)("%s(", name);
 
@@ -172,6 +176,9 @@ db_stack_trace_print(db_expr_t addr, int
(*pr)(",");
}
}
+
+   if (extra_args)
+   (*pr)(",...");
 
(*pr)(") at ");
db_printsym(lr - 4, DB_STGY_PROC, pr);

-- 
jasper



ddb trace: fix output for too many arguments

2021-07-11 Thread Jasper Lievisse Adriaanse
Hi,

When printing a trace from ddb, some architectures are limited by the number of
registers which are used to pass arguments. If the number of arguments to a 
function
exceeded this number, the code in db_stack_trace_print() would print that many 
arguments
without any indication that one or more arguments aren't printed.

Here's a diff that tweaks the output to make it clear there were more arguments.
Do we want to print ',...' for each ommited argument (like this diff does)
or perhaps just a single ',...'?

Index: amd64/amd64/db_trace.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.53
diff -u -p -r1.53 db_trace.c
--- amd64/amd64/db_trace.c  14 May 2020 06:58:54 -  1.53
+++ amd64/amd64/db_trace.c  11 Jul 2021 13:23:04 -
@@ -137,7 +136,7 @@ db_stack_trace_print(db_expr_t addr, int
 
lastframe = 0;
while (count && frame != 0) {
-   int narg;
+   int narg, extra_args = 0;
unsigned inti;
char *  name;
db_expr_t   offset;
@@ -165,8 +164,12 @@ db_stack_trace_print(db_expr_t addr, int
}
 
narg = db_ctf_func_numargs(sym);
-   if (narg < 0 || narg > 6)
+   if (narg < 0)
+   narg = 6;
+   else if (narg > 6) {
+   extra_args = narg % 6;
narg = 6;
+   }
 
if (name == NULL)
(*pr)("%lx(", callpc);
@@ -204,6 +207,9 @@ db_stack_trace_print(db_expr_t addr, int
if (--narg != 0)
(*pr)(",");
}
+   for (i = extra_args; i > 0; i--)
+   (*pr)(",...");  
+
(*pr)(") at ");
db_printsym(callpc, DB_STGY_PROC, pr);
(*pr)("\n");
Index: powerpc/ddb/db_trace.c
===
RCS file: /cvs/src/sys/arch/powerpc/ddb/db_trace.c,v
retrieving revision 1.17
diff -u -p -r1.17 db_trace.c
--- powerpc/ddb/db_trace.c  14 May 2020 06:58:54 -  1.17
+++ powerpc/ddb/db_trace.c  11 Jul 2021 13:23:04 -
@@ -123,7 +123,7 @@ db_stack_trace_print(db_expr_t addr, int
Elf_Sym *sym;
char*name;
char c, *cp = modif;
-   int  i, narg, trace_proc = 0;
+   int  i, narg, trace_proc = 0, extra_args = 0;
 
while ((c = *cp++) != 0) {
if (c == 't')
@@ -158,8 +158,12 @@ db_stack_trace_print(db_expr_t addr, int
(*pr)("at 0x%lx", lr - 4);
} else {
narg = db_ctf_func_numargs(sym);
-   if (narg < 0 || narg > 8)
+   if (narg < 0)
narg = 8;
+   else if (narg > 8) {
+   extra_args = narg % 8;
+   narg = 8;
+   }
 
(*pr)("%s(", name);
 
@@ -172,6 +176,9 @@ db_stack_trace_print(db_expr_t addr, int
(*pr)(",");
}
}
+
+   for (i = extra_args; i > 0; i--)
+   (*pr)(",...");
 
(*pr)(") at ");
db_printsym(lr - 4, DB_STGY_PROC, pr);
-- 
jasper



Re: [PATCH] wireguard: release correct lock on exceptional case

2020-10-31 Thread Jasper Lievisse Adriaanse
On Sat, Oct 31, 2020 at 03:03:10PM +0100, Jason A. Donenfeld wrote:
> Backtrace from Jesper:
> 
> ddb{0}> show panic
> noise_keypair: lock not held
> ddb{0}> trace
> db_enter() at db_enter+0x10
> panic(81db9b58) at panic+0x12a
> rw_exit_write(8801ed10) at rw_exit_write+0xb5
> noise_remote_begin_session(8801ec10) at 
> noise_remote_begin_session+0x3c
> 1
> wg_send_response(8801ebe0) at wg_send_response+0x7b
> wg_handshake(80588000,fd800e7b5a00) at wg_handshake+0x576
> wg_handshake_worker(80588000) at wg_handshake_worker+0x48
> taskq_thread(80049200) at taskq_thread+0x81
> end trace frame: 0x0, count: -8
> ddb{0}> machine ddbcpu 1
> 
> Reported-by: Jasper Lievisse Adriaanse 
> ---
>  sys/net/wg_noise.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git sys/net/wg_noise.c sys/net/wg_noise.c
> index 66bdecee80e..adb00568eb4 100644
> --- sys/net/wg_noise.c
> +++ sys/net/wg_noise.c
> @@ -459,7 +459,7 @@ noise_remote_begin_session(struct noise_remote *r)
>   NOISE_SYMMETRIC_KEY_LEN, NOISE_SYMMETRIC_KEY_LEN, 0, 0,
>   hs->hs_ck);
>   } else {
> - rw_exit_write(>r_keypair_lock);
> + rw_exit_write(>r_handshake_lock);
>   return EINVAL;
>   }
>  
> -- 
> 2.29.1

Thanks for the quick fix, I've just committed this.

Cheers,
-- 
jasper



Re: btrace: add boolean AND and OR operators

2020-09-14 Thread Jasper Lievisse Adriaanse
On Mon, Sep 14, 2020 at 03:39:04PM +0200, Otto Moerbeek wrote:
> On Mon, Sep 14, 2020 at 03:28:17PM +0200, Jasper Lievisse Adriaanse wrote:
> 
> > Hi,
> > 
> > This diff adds support for the '&' and '|' operators, along with
> > a new testcase.
> > 
> > OK?
> 
> The precedence looks funny
> 
> I'd guess you want
> 
> %left '|'
> %left '&'
> %left '+' '-'
> %left '/' '*'
> 
> To avoid suprises.
> 
>   -Otto
Good point.

Index: usr.sbin/btrace/bt_parse.y
===
RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
retrieving revision 1.16
diff -u -p -r1.16 bt_parse.y
--- usr.sbin/btrace/bt_parse.y  11 Jul 2020 14:52:14 -  1.16
+++ usr.sbin/btrace/bt_parse.y  14 Sep 2020 15:41:40 -
@@ -117,6 +117,8 @@ static int   yylex(void);
 %type   expr vargs map mexpr term
 %type beginend
 
+%left  '|'
+%left  '&'
 %left  '+' '-'
 %left  '/' '*'
 %%
@@ -172,6 +174,8 @@ term: '(' term ')'  { $$ = 
$2; }
| term '-' term { $$ = ba_op('-', $1, $3); }
| term '/' term { $$ = ba_op('/', $1, $3); }
| term '*' term { $$ = ba_op('*', $1, $3); }
+   | term '&' term { $$ = ba_op('&', $1, $3); }
+   | term '|' term { $$ = ba_op('|', $1, $3); }
| NUMBER{ $$ = ba_new($1, B_AT_LONG); }
| builtin   { $$ = ba_new(NULL, $1); }
| gvar  { $$ = bv_get($1); }
@@ -331,6 +335,12 @@ ba_op(const char op, struct bt_arg *da0,
break;
case '/':
type = B_AT_OP_DIVIDE;
+   break;
+   case '&':
+   type = B_AT_OP_AND;
+   break;
+   case '|':
+   type = B_AT_OP_OR;
break;
default:
assert(0);
Index: usr.sbin/btrace/bt_parser.h
===
RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
retrieving revision 1.9
diff -u -p -r1.9 bt_parser.h
--- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -  1.9
+++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:41:40 -
@@ -143,6 +143,8 @@ struct bt_arg {
B_AT_OP_MINUS,
B_AT_OP_MULT,
B_AT_OP_DIVIDE,
+   B_AT_OP_AND,
+   B_AT_OP_OR,
}ba_type;
 };
 
Index: usr.sbin/btrace/btrace.c
===
RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
retrieving revision 1.24
diff -u -p -r1.24 btrace.c
--- usr.sbin/btrace/btrace.c11 Sep 2020 08:16:15 -  1.24
+++ usr.sbin/btrace/btrace.c14 Sep 2020 15:41:40 -
@@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
case B_AT_BI_NSECS:
bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
break;
default:
@@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
case B_AT_OP_DIVIDE:
result = first / second;
break;
+   case B_AT_OP_AND:
+   result = first & second;
+   break;
+   case B_AT_OP_OR:
+   result = first | second;
+   break;
default:
xabort("unsuported operation %d", ba->ba_type);
}
@@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
case B_AT_BI_RETVAL:
val = dtev->dtev_sysretval[0];
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
val = baexpr2long(ba, dtev);
break;
default:
@@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt 
case B_AT_VAR:
str = ba2str(ba_read(ba), dtev);
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
str = buf;
break;
@@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
case B_AT_MF_MAX:
case B_AT_MF_MIN:
case B_AT_MF_SUM:
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
break;
default:
xabort("invalid argument type %d", ba->ba_type);
Index: regress/usr.sbin/btrace/Makefile
=

btrace: add boolean AND and OR operators

2020-09-14 Thread Jasper Lievisse Adriaanse
Hi,

This diff adds support for the '&' and '|' operators, along with
a new testcase.

OK?

Index: usr.sbin/btrace/bt_parse.y
===
RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
retrieving revision 1.16
diff -u -p -r1.16 bt_parse.y
--- usr.sbin/btrace/bt_parse.y  11 Jul 2020 14:52:14 -  1.16
+++ usr.sbin/btrace/bt_parse.y  14 Sep 2020 15:14:10 -
@@ -119,6 +119,7 @@ static int   yylex(void);
 
 %left  '+' '-'
 %left  '/' '*'
+%left  '&' '|'
 %%
 
 grammar: /* empty */
@@ -172,6 +173,8 @@ term: '(' term ')'  { $$ = 
$2; }
| term '-' term { $$ = ba_op('-', $1, $3); }
| term '/' term { $$ = ba_op('/', $1, $3); }
| term '*' term { $$ = ba_op('*', $1, $3); }
+   | term '&' term { $$ = ba_op('&', $1, $3); }
+   | term '|' term { $$ = ba_op('|', $1, $3); }
| NUMBER{ $$ = ba_new($1, B_AT_LONG); }
| builtin   { $$ = ba_new(NULL, $1); }
| gvar  { $$ = bv_get($1); }
@@ -331,6 +334,12 @@ ba_op(const char op, struct bt_arg *da0,
break;
case '/':
type = B_AT_OP_DIVIDE;
+   break;
+   case '&':
+   type = B_AT_OP_AND;
+   break;
+   case '|':
+   type = B_AT_OP_OR;
break;
default:
assert(0);
Index: usr.sbin/btrace/bt_parser.h
===
RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
retrieving revision 1.9
diff -u -p -r1.9 bt_parser.h
--- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -  1.9
+++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:14:10 -
@@ -143,6 +143,8 @@ struct bt_arg {
B_AT_OP_MINUS,
B_AT_OP_MULT,
B_AT_OP_DIVIDE,
+   B_AT_OP_AND,
+   B_AT_OP_OR,
}ba_type;
 };
 
Index: usr.sbin/btrace/btrace.c
===
RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
retrieving revision 1.24
diff -u -p -r1.24 btrace.c
--- usr.sbin/btrace/btrace.c11 Sep 2020 08:16:15 -  1.24
+++ usr.sbin/btrace/btrace.c14 Sep 2020 15:14:10 -
@@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
case B_AT_BI_NSECS:
bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
break;
default:
@@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
case B_AT_OP_DIVIDE:
result = first / second;
break;
+   case B_AT_OP_AND:
+   result = first & second;
+   break;
+   case B_AT_OP_OR:
+   result = first | second;
+   break;
default:
xabort("unsuported operation %d", ba->ba_type);
}
@@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
case B_AT_BI_RETVAL:
val = dtev->dtev_sysretval[0];
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
val = baexpr2long(ba, dtev);
break;
default:
@@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt 
case B_AT_VAR:
str = ba2str(ba_read(ba), dtev);
break;
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
str = buf;
break;
@@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
case B_AT_MF_MAX:
case B_AT_MF_MIN:
case B_AT_MF_SUM:
-   case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+   case B_AT_OP_ADD ... B_AT_OP_OR:
break;
default:
xabort("invalid argument type %d", ba->ba_type);
Index: regress/usr.sbin/btrace/Makefile
===
RCS file: /cvs/src/regress/usr.sbin/btrace/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- regress/usr.sbin/btrace/Makefile19 Mar 2020 15:53:09 -  1.4
+++ regress/usr.sbin/btrace/Makefile14 Sep 2020 15:14:10 -
@@ -3,8 +3,8 @@
 BTRACE?=/usr/sbin/btrace
 
 # scripts that don't need /dev/dt
-BT_LANG_SCRIPTS=   arithm beginend comments delete exit map map-unnamed \
-   maxoperand min+max+sum multismts nsecs+var

dt: add static vfs probes

2020-09-14 Thread Jasper Lievisse Adriaanse
Hi,

Whilst analyzing the cleaner I added tracepoints called 'cleaner' and 
'bufcache_take' to
track its behaviour.

For the sake of symmetry I've added one in bufcache_release() too and moved the 
assignment
of 'pages' until after the KASSERT(), following the flow of bufcache_take().

Sample usage of these probes:

tracepoint:vfs:bufcache_take {
printf("bcache_take:%d(%s) flags: 0x%x cache: %d pages: %d\n",
tid, comm, arg0 , arg1, arg2);
}

tracepoint:vfs:bufcache_rel{
printf("bcache_rel:%d(%s) flags: 0x%x cache: %d pages: %d\n",
tid, comm, arg0, arg1, arg2);
}

tracepoint:vfs:cleaner{
printf("cleaner:%d(%s) flags: 0x%x pushed: %d lodirtypages: %d, 
hidirtypages: %d\n",
tid, comm, arg0, arg1, arg2, arg3);
}

OK to commit this?

Index: dev/dt/dt_prov_static.c
===
RCS file: /cvs/src/sys/dev/dt/dt_prov_static.c,v
retrieving revision 1.4
diff -u -p -r1.4 dt_prov_static.c
--- dev/dt/dt_prov_static.c 13 Sep 2020 14:55:08 -  1.4
+++ dev/dt/dt_prov_static.c 14 Sep 2020 10:43:43 -
@@ -58,6 +58,13 @@ DT_STATIC_PROBE3(uvm, map_insert, "vaddr
 DT_STATIC_PROBE3(uvm, map_remove, "vaddr_t", "vaddr_t", "vm_prot_t");
 
 /*
+ * VFS
+ */
+DT_STATIC_PROBE3(vfs, bufcache_rel, "long", "int", "int64_t");
+DT_STATIC_PROBE3(vfs, bufcache_take, "long", "int", "int64_t");
+DT_STATIC_PROBE4(vfs, cleaner, "long", "int", "long", "long");
+
+/*
  * List of all static probes
  */
 struct dt_probe *dtps_static[] = {
@@ -76,6 +83,10 @@ struct dt_probe *dtps_static[] = {
&_DT_STATIC_P(uvm, fault),
&_DT_STATIC_P(uvm, map_insert),
&_DT_STATIC_P(uvm, map_remove),
+   /* VFS */
+   &_DT_STATIC_P(vfs, bufcache_rel),
+   &_DT_STATIC_P(vfs, bufcache_take),
+   &_DT_STATIC_P(vfs, cleaner),
 };
 
 int
Index: kern/vfs_bio.c
===
RCS file: /cvs/src/sys/kern/vfs_bio.c,v
retrieving revision 1.202
diff -u -p -r1.202 vfs_bio.c
--- kern/vfs_bio.c  12 Sep 2020 11:57:24 -  1.202
+++ kern/vfs_bio.c  14 Sep 2020 10:43:43 -
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* XXX Should really be in buf.h, but for uvm_constraint_range.. */
@@ -1209,6 +1210,9 @@ buf_daemon(void *arg)
}
 
while ((bp = bufcache_getdirtybuf())) {
+   TRACEPOINT(vfs, cleaner, bp->b_flags, pushed,
+   lodirtypages, hidirtypages);
+
if (UNCLEAN_PAGES < lodirtypages &&
bcstats.kvaslots_avail > 2 * RESERVE_SLOTS &&
pushed >= 16)
@@ -1693,6 +1697,9 @@ bufcache_take(struct buf *bp)
KASSERT((bp->cache < NUM_CACHES));
 
pages = atop(bp->b_bufsize);
+
+   TRACEPOINT(vfs, bufcache_take, bp->b_flags, bp->cache, pages);
+
struct bufcache *cache = [bp->cache];
if (!ISSET(bp->b_flags, B_DELWRI)) {
 if (ISSET(bp->b_flags, B_COLD)) {
@@ -1756,8 +1763,11 @@ bufcache_release(struct buf *bp)
int64_t pages;
struct bufcache *cache = [bp->cache];
 
-   pages = atop(bp->b_bufsize);
KASSERT(ISSET(bp->b_flags, B_BC));
+   pages = atop(bp->b_bufsize);
+
+   TRACEPOINT(vfs, bufcache_rel, bp->b_flags, bp->cache, pages);
+
if (fliphigh) {
if (ISSET(bp->b_flags, B_DMA) && bp->cache > 0)
panic("B_DMA buffer release from cache %d",
-- 
jasper



Re: acpitoshiba: remove dead code

2020-03-16 Thread Jasper Lievisse Adriaanse



> On 16 Mar 2020, at 09:49, Stefan Sperling  wrote:
> 
> On Mon, Mar 16, 2020 at 09:29:43AM +0100, Jasper Lievisse Adriaanse wrote:
>> Hi,
>> 
>> The type of brightness and video_output is uint32_t; therefore it
>> can never be less than 0 (which is what HCI_LCD_BRIGHTNESS_MIN and
>> HCI_VIDEO_OUTPUT_CYCLE_MIN are defined to). So trim the checks by
>> removig the impossible cases.
>> 
>> Coverity CID 1453109, 1453169
>> 
>> OK?
> 
> These values ultimately come from aml_val2int() which returns int64_t,
> i.e. a signed value. This driver currently copies that value to a uint32_t,
> shifts it, and this shifted value ends up being copied to an int, and then
> again to a uint32_t, which is then range-checked.
> I don't understand why a range check is done only that late in the game,
> after multiple integer type conversions that seem to be performed for no
> good reason other than that the expected range will fit into an int.
> 
> So an alternative fix could be to switch brightness values in this
> driver to int64_t everywhere, i.e. in toshiba_get_brightness(),
> toshiba_find_brightness(), toshiba_set_brightness(), etc.
> Then you can keep all the code as it is.
> 
> Or read an int64_t with aml_val2int(), shift and range-check it right away,
> and only convert to a narrower type if the value is in the expected range.
> Else error.

Right, it seems that other drivers either use an uint64_t with associated 
shifts or
int to match wsdisplay_params->curval.
Also, it seems this passing around of ‘brightness’ could be avoided by making 
it a member
of acpitoshiba_softc; same goes for 'video_output'.



acpitoshiba: remove dead code

2020-03-16 Thread Jasper Lievisse Adriaanse
Hi,

The type of brightness and video_output is uint32_t; therefore it
can never be less than 0 (which is what HCI_LCD_BRIGHTNESS_MIN and
HCI_VIDEO_OUTPUT_CYCLE_MIN are defined to). So trim the checks by
removig the impossible cases.

Coverity CID 1453109, 1453169

OK?

Index: acpi/acpitoshiba.c
===
RCS file: /cvs/src/sys/dev/acpi/acpitoshiba.c,v
retrieving revision 1.12
diff -u -p -r1.12 acpitoshiba.c
--- acpi/acpitoshiba.c  13 Oct 2019 10:56:31 -  1.12
+++ acpi/acpitoshiba.c  11 Mar 2020 11:35:23 -
@@ -438,9 +438,8 @@ toshiba_set_brightness(struct acpitoshib
for (i = 0; i < HCI_WORDS; ++i)
args[i].type = AML_OBJTYPE_INTEGER;
 
-   if ((*brightness < HCI_LCD_BRIGHTNESS_MIN) ||
-   (*brightness > HCI_LCD_BRIGHTNESS_MAX))
-  return (HCI_FAILURE);
+   if (*brightness > HCI_LCD_BRIGHTNESS_MAX)
+   return (HCI_FAILURE);
 
*brightness <<= HCI_LCD_BRIGHTNESS_SHIFT;
 
@@ -534,8 +533,7 @@ toshiba_set_video_output(struct acpitosh
 
bzero(args, sizeof(args));
 
-   if ((*video_output < HCI_VIDEO_OUTPUT_CYCLE_MIN) ||
-   (*video_output > HCI_VIDEO_OUTPUT_CYCLE_MAX))
+   if (*video_output > HCI_VIDEO_OUTPUT_CYCLE_MAX)
return (HCI_FAILURE);
 
*video_output |= HCI_VIDEO_OUTPUT_FLAG;
-- 
jasper



check disk_lookup return value

2020-03-11 Thread Jasper Lievisse Adriaanse
Hi,

Check return value of disk_lookup before dereference as it can
return NULL. These are Coverity CID 1452925, 1452951, 1452967.

Other functions using disk_lookup (or the re-defined versions like
wdlookup) check the return value already, including in the context
of hibernation (sdmmc_scsi_hibernate_io and wd_hibernate_io). Is there
something special about the instances below or was it merely oversight?


Index: dev/softraid.c
===
RCS file: /cvs/src/sys/dev/softraid.c,v
retrieving revision 1.399
diff -u -p -r1.399 softraid.c
--- dev/softraid.c  10 Mar 2020 08:41:19 -  1.399
+++ dev/softraid.c  11 Mar 2020 12:28:53 -
@@ -5068,6 +5068,8 @@ sr_hibernate_io(dev_t dev, daddr_t blkno
 */
if (op == HIB_INIT) {
dv = disk_lookup(_cd, DISKUNIT(dev));
+   if (dv == NULL)
+   return (EIO);
sd = (struct sd_softc *)dv;
sc = (struct sr_softc *)dv->dv_parent->dv_parent;
 
Index: dev/ic/nvme.c
===
RCS file: /cvs/src/sys/dev/ic/nvme.c,v
retrieving revision 1.72
diff -u -p -r1.72 nvme.c
--- dev/ic/nvme.c   10 Mar 2020 14:49:20 -  1.72
+++ dev/ic/nvme.c   11 Mar 2020 12:28:53 -
@@ -1498,6 +1498,8 @@ nvme_hibernate_io(dev_t dev, daddr_t blk
 
/* find nvme softc */
disk = disk_lookup(_cd, DISKUNIT(dev));
+   if (disk == NULL)
+   return (EIO);
scsibus = disk->dv_parent;
my->sc = (struct nvme_softc *)disk->dv_parent->dv_parent;
 
Index: dev/ic/ahci.c
===
RCS file: /cvs/src/sys/dev/ic/ahci.c,v
retrieving revision 1.34
diff -u -p -r1.34 ahci.c
--- dev/ic/ahci.c   8 Jul 2019 22:02:59 -   1.34
+++ dev/ic/ahci.c   11 Mar 2020 12:28:53 -
@@ -3265,6 +3265,8 @@ ahci_hibernate_io(dev_t dev, daddr_t blk
 
/* map dev to an ahci port */
disk = disk_lookup(_cd, DISKUNIT(dev));
+   if (disk == NULL)
+   return (EIO);
scsibus = disk->dv_parent;
sc = (struct ahci_softc *)disk->dv_parent->dv_parent;
 
-- 
jasper



uplcom: remove dead code

2020-03-11 Thread Jasper Lievisse Adriaanse
Hi,

Remove dead code which is actually duplicated a few lines above
right after err is set. Coverity ID 975917

OK?

Index: dev/usb/uplcom.c
===
RCS file: /cvs/src/sys/dev/usb/uplcom.c,v
retrieving revision 1.73
diff -u -p -U11 -r1.73 uplcom.c
--- dev/usb/uplcom.c18 Nov 2018 16:23:14 -  1.73
+++ dev/usb/uplcom.c11 Mar 2020 12:36:03 -
@@ -619,27 +619,22 @@ uplcom_param(void *addr, int portno, str
if (err) {
DPRINTF(("uplcom_param: err=%s\n", usbd_errstr(err)));
return (EIO);
}
 
if (ISSET(t->c_cflag, CRTSCTS))
uplcom_set_crtscts(sc);
 
if (sc->sc_rts == -1 || sc->sc_dtr == -1)
uplcom_set_line_state(sc);
 
-   if (err) {
-   DPRINTF(("uplcom_param: err=%s\n", usbd_errstr(err)));
-   return (EIO);
-   }
-
return (0);
 }
 
 int
 uplcom_open(void *addr, int portno)
 {
struct uplcom_softc *sc = addr;
usb_device_request_t req;
usbd_status uerr;
int err;
 

-- 
jasper



tcpdump: decode some Setup fields for Control transfers

2020-02-23 Thread Jasper Lievisse Adriaanse
Hi,

Currently the usbpcap is fairly terse in that it prints the endpoints,
type of transfer and data size. Below is a diff to start decoding more
data from the packets, currently focusing on control transfers:

- print the control stage
- for the Setup control transfer stage, print additional information
  about the request. This diff contains the bits to decode the wValue
  for GET_DESCRIPTOR requests, others will follow shortly after making sure
  my approach is right.

with this diff the output (for a selection of packets) goes from this:

22:28:09.517113 bus 0 < addr 1: ep1 intr dlen=2
22:28:09.517145 bus 0 > addr 1: ep0 ctrl dlen=8
22:28:09.517146 bus 0 > addr 1: ep0 ctrl dlen=0
22:28:09.517148 bus 0 < addr 1: ep0 ctrl dlen=4
[..]
22:28:10.138325 bus 0 > addr 0: ep0 ctrl dlen=8

to this:

22:28:09.517113 bus 0 < addr 1: ep1 intr dlen=2
22:28:09.517145 bus 0 > addr 1: ep0 ctrl dlen=8 stage=setup 
bmRequestType=UT_READ_CLASS_OTHER bRequest=GET_STATUS wValue=0x wIndex=0003 
wLength=4
22:28:09.517146 bus 0 > addr 1: ep0 ctrl dlen=0 stage=status
22:28:09.517148 bus 0 < addr 1: ep0 ctrl dlen=4 stage=data
[..]
22:28:10.138325 bus 0 > addr 0: ep0 ctrl dlen=8 stage=setup 
bmRequestType=UT_READ_DEVICE bRequest=GET_DESCRIPTOR type=DEVICE index=0x00 
wIndex= wLength=8

OK?

Index: print-usbpcap.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-usbpcap.c,v
retrieving revision 1.3
diff -u -p -r1.3 print-usbpcap.c
--- print-usbpcap.c 22 Feb 2020 14:05:08 -  1.3
+++ print-usbpcap.c 23 Feb 2020 13:06:55 -
@@ -29,6 +29,41 @@
 
 const char *usbpcap_xfer_type[] = {"isoc", "intr", "ctrl", "bulk"};
 
+struct usbpcap_control_stage_fields {
+   uint8_t  stage;
+   char*name;
+};
+
+static const struct usbpcap_control_stage_fields usb_control_stages[] = {
+   { USBPCAP_CONTROL_STAGE_SETUP,  "setup" },
+   { USBPCAP_CONTROL_STAGE_DATA,   "data" },
+   { USBPCAP_CONTROL_STAGE_STATUS, "status" },
+};
+
+struct usbpcap_request_code_fields {
+   uByterequest;
+   char*name;
+};
+
+static const struct usbpcap_request_code_fields usb_request_codes[] = {
+   { UR_GET_STATUS,"GET_STATUS" },
+   { UR_CLEAR_FEATURE, "CLEAR_FEATURE" },
+   { 0,NULL },
+   { UR_SET_FEATURE,   "SET_FEATURE" },
+   { 0,NULL },
+   { UR_SET_ADDRESS,   "SET_ADDRESS" },
+   { UR_GET_DESCRIPTOR,"GET_DESCRIPTOR" },
+   { UR_SET_DESCRIPTOR,"SET_DESCRIPTOR" },
+   { UR_GET_CONFIG,"GET_CONFIG" },
+   { UR_SET_CONFIG,"SET_CONFIG" },
+   { UR_GET_INTERFACE, "GET_INTERFACE" },
+   { UR_SET_INTERFACE, "SET_INTERFACE" },
+   { UR_SYNCH_FRAME,   "SYNCH_FRAME" },
+};
+
+voidusbpcap_print_descriptor(int);
+voidusbpcap_print_request_type(uint8_t);
+
 void
 usbpcap_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 {
@@ -65,6 +100,40 @@ usbpcap_if_print(u_char *user, const str
 
printf(" dlen=%u", letoh32(uph->uph_dlen));
 
+   if (uph->uph_xfertype == USBPCAP_TRANSFER_CONTROL) {
+   struct usbpcap_ctl_hdr *ctl_hdr = (struct usbpcap_ctl_hdr *)p;
+
+   if (ctl_hdr->uch_stage < nitems(usb_control_stages))
+   printf(" stage=%s", 
usb_control_stages[ctl_hdr->uch_stage].name);
+   else
+   printf(" stage=?");
+
+   if (ctl_hdr->uch_stage == USBPCAP_CONTROL_STAGE_SETUP) {
+   /* Setup packets must be 8 bytes in size as per
+* 9.3 USB Device Requests. */
+   if (letoh32(uph->uph_dlen != 8))
+   goto trunc;
+
+   usb_device_request_t *req =
+   (usb_device_request_t *)(p+sizeof(struct 
usbpcap_ctl_hdr));
+
+   usbpcap_print_request_type(req->bmRequestType);
+
+   if (req->bRequest < nitems(usb_request_codes))
+   printf(" bRequest=%s", 
usb_request_codes[req->bRequest].name);
+   else
+   printf(" bRequest=?");
+
+   if (req->bRequest == UR_GET_DESCRIPTOR)
+   usbpcap_print_descriptor(UGETW(req->wValue));
+   else
+   printf(" wValue=0x%04x", UGETW(req->wValue));
+
+   printf(" wIndex=%04x", UGETW(req->wIndex));
+   printf(" wLength=%u", UGETW(req->wLength));
+   }
+   }
+
if (xflag)
default_print(p + sizeof(*uph), length - sizeof(*uph));
 out:
@@ -72,4 +141,154 @@ out:
return;
 trunc:
printf("[|usb]");
+}
+
+void
+usbpcap_print_descriptor(int value) {
+   printf(" type=");
+   switch (value >> 8) {
+   case UDESC_DEVICE:
+ 

Re: usbdevs: small addition

2020-02-23 Thread Jasper Lievisse Adriaanse
On Sun, Feb 23, 2020 at 11:52:10AM +1100, Jonathan Gray wrote:
> On Sat, Feb 22, 2020 at 04:22:25PM +0100, Jasper Lievisse Adriaanse wrote:
> > Hi,
> > 
> > - add an AMD product found on the APU2
> 
> I would not consider 0x7900 a root hub as it attaches to another hub
> 
> uhub2 at uhub1 port 1 configuration 1 interface 0 "Advanced Micro Devices 
> product 0x7900" rev 2.00/0.18 addr 2
I'll change it to 'Hub' then.

> > - add vendor id for "Synaptics, Inc.
> 
> I'd just go with "Synaptics"
Okey.

> > - add synaptics fingerprint reader found on recent thinkpads; I couldn't 
> > find a proper
> >   name for this device in the Linux usb.ids repository so I went with the 
> > generic
> >   'Fingerprint Reader" that's also used elsewhere in this file.
> 
> does it not supply a string itself?
How would I get the device to do this?

> the lenovo windows driver matches on 0x06cb:0x00bd and 0x06cb:0x00c2
> and calls itself "Synaptics UWP WBDI" which isn't very helpful.
I've added the 0x00c2 to the diff below, re-using the original description for 
now.


Index: usbdevs
===
RCS file: /cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.710
diff -u -p -r1.710 usbdevs
--- usbdevs 27 Jan 2020 15:41:42 -  1.710
+++ usbdevs 23 Feb 2020 10:12:02 -
@@ -262,6 +262,7 @@ vendor AGFA 0x06bd  AGFA-Gevaert
 vendor ASIAMD  0x06be  Asia Microelectronic Development
 vendor PHIDGETS0x06c2  Phidgets
 vendor BIZLINK 0x06c4  Bizlink International
+vendor SYNAPTICS   0x06cb  Synaptics
 vendor KEYSPAN 0x06cd  Keyspan
 vendor AASHIMA 0x06d6  Aashima Technology
 vendor LIEBERT 0x06da  Liebert
@@ -888,6 +889,9 @@ product ALTI2 NEPTUNE3  0x6001  Neptune 3
 product AMBIT WLAN 0x0302  WLAN
 product AMBIT NTL_250  0x6098  NTL 250 cable modem
 
+/* Advanced Micro Devices products */
+product AMD HUB0x7900  Hub
+
 /* Amigo Technology products */
 product AMIGO RT2870_1 0x9031  RT2870
 product AMIGO RT2870_2 0x9041  RT2870
@@ -4167,6 +4171,10 @@ product SWEEX2 LW153 0x0153  LW153
 product SWEEX2 LW154   0x0154  LW154
 product SWEEX2 LW303   0x0302  LW303
 product SWEEX2 LW313   0x0313  LW313
+
+/* Synaptics products */
+product SYNAPTICS FPRINT   0x00bd  Fingerprint Reader
+product SYNAPTICS FPRINT_2 0x00c2  Fingerprint Reader
 
 /* Syntech Information products */
 product SYNTECH SERIAL 0x0001  Serial

-- 
jasper



usbdevs: small addition

2020-02-22 Thread Jasper Lievisse Adriaanse
Hi,

- add an AMD product found on the APU2
- add vendor id for "Synaptics, Inc.
- add synaptics fingerprint reader found on recent thinkpads; I couldn't find a 
proper
  name for this device in the Linux usb.ids repository so I went with the 
generic
  'Fingerprint Reader" that's also used elsewhere in this file.

OK?

Index: usbdevs
===
RCS file: /cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.710
diff -u -p -r1.710 usbdevs
--- usbdevs 27 Jan 2020 15:41:42 -  1.710
+++ usbdevs 22 Feb 2020 15:21:41 -
@@ -262,6 +262,7 @@ vendor AGFA 0x06bd  AGFA-Gevaert
 vendor ASIAMD  0x06be  Asia Microelectronic Development
 vendor PHIDGETS0x06c2  Phidgets
 vendor BIZLINK 0x06c4  Bizlink International
+vendor SYNAPTICS   0x06cb  Synaptics, Inc.
 vendor KEYSPAN 0x06cd  Keyspan
 vendor AASHIMA 0x06d6  Aashima Technology
 vendor LIEBERT 0x06da  Liebert
@@ -888,6 +889,9 @@ product ALTI2 NEPTUNE3  0x6001  Neptune 3
 product AMBIT WLAN 0x0302  WLAN
 product AMBIT NTL_250  0x6098  NTL 250 cable modem
 
+/* Advanced Micro Devices products */
+product AMD HUB0x7900  Root Hub
+
 /* Amigo Technology products */
 product AMIGO RT2870_1 0x9031  RT2870
 product AMIGO RT2870_2 0x9041  RT2870
@@ -4167,6 +4171,9 @@ product SWEEX2 LW153  0x0153  LW153
 product SWEEX2 LW154   0x0154  LW154
 product SWEEX2 LW303   0x0302  LW303
 product SWEEX2 LW313   0x0313  LW313
+
+/* Synaptics, Inc. products */
+product SYNAPTICS FPRINT   0x00bd  Fingerprint Reader
 
 /* Syntech Information products */
 product SYNTECH SERIAL 0x0001  Serial



tcpdump: fix crash with invalid usb packets

2020-02-21 Thread Jasper Lievisse Adriaanse
Hi,

When using -X/-x/-A with tcpdump on a packet where sizeof(*uph) is larger than
'length' we end up passing a negative value as the length to default_print(),
which wraps around and suddenly we're attempting to print 4294976281 elements.
Found with AFL.

OK?

Index: print-usbpcap.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-usbpcap.c,v
retrieving revision 1.2
diff -u -p -r1.2 print-usbpcap.c
--- print-usbpcap.c 12 Feb 2020 20:07:55 -  1.2
+++ print-usbpcap.c 21 Feb 2020 16:11:45 -
@@ -40,7 +40,7 @@ usbpcap_if_print(u_char *user, const str
ts_print(>ts);
 
/* check length */
-   if (caplen < sizeof(uint16_t))
+   if (caplen < sizeof(uint16_t) || length < sizeof(*uph))
goto trunc;
 
uph = (struct usbpcap_pkt_hdr *)p;
-- 
jasper



Re: piixpm(4) add support for newer AMD chipsets

2019-12-16 Thread Jasper Lievisse Adriaanse
On Mon, Dec 16, 2019 at 12:37:51PM +0100, Claudio Jeker wrote:
> This diff should add support for newer smbus controllers used on newer AMD
> chipsets. Especially Hudson-2 and Kerncz based chipsets. On my Ryzen 5 the
> iic(4) busses attach but there is nothing detected on them (well possible
> that I missed something). I also implemented the up to 4 busses available
> on chipsets of the SBx00 series (on Hudson-2 and Kerncz only 2 ports).
> 
> I would be interested if on systems with Ryzen CPUs something attaches to
> those iic(4) busses. Could be that I missed something and fail to properly
> access the bus.
> -- 
> :wq Claudio

On a ThinkPad x395 with:
cpu0: AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx, 2296.08 MHz, 17-18-01

I observe this change in dmesg:

-"AMD FCH SMBus" rev 0x61 at pci0 dev 20 function 0 not configured
+piixpm0 at pci0 dev 20 function 0 "AMD FCH SMBus" rev 0x61: polling
+iic0 at piixpm0
+iic1 at piixpm0

Full dmesg below:

OpenBSD 6.6-current (GENERIC.MP) #1: Mon Dec 16 20:44:36 CET 2019
jas...@tau.office.jasper.la:/sys/arch/amd64/compile/GENERIC.MP
real mem = 14888513536 (14198MB)
avail mem = 14424879104 (13756MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.1 @ 0xb9ecc000 (63 entries)
bios0: vendor LENOVO version "R13ET39W(1.13 )" date 10/11/2019
bios0: LENOVO 20NLCTO1WW
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT SSDT MSDM SLIC BATB HPET APIC MCFG SBST WSMT 
IVRS SSDT CRAT CDIT FPDT SSDT SSDT SSDT UEFI
acpi0: wakeup devices GPP0(S3) GPP1(S3) GPP2(S3) GPP3(S3) GPP4(S3) L850(S3) 
GPP5(S3) GPP6(S3) GP17(S3) XHC0(S3) XHC1(S3) GP18(S3) LID_(S3) SLPB(S3)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpihpet0 at acpi0: 14318180 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx, 2296.00 MHz, 17-18-01
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache, 4MB 64b/line 16-way L3 cache
cpu0: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 24MHz
cpu0: mwait min=64, max=64, C-substates=1.1, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx, 2295.67 MHz, 17-18-01
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache, 4MB 64b/line 16-way L3 cache
cpu1: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu1: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx, 2295.67 MHz, 17-18-01
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu2: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache, 4MB 64b/line 16-way L3 cache
cpu2: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu2: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx, 2295.67 MHz, 17-18-01
cpu3: 

Re: vmctl: print root user in status owner field

2019-12-14 Thread Jasper Lievisse Adriaanse



> On 14 Dec 2019, at 02:16, Klemens Nanni  wrote:
> 
> With "owner root:wheel" (any group) the `vmctl status' output
> will omit the "root" part in the OWNER column:
> 
>   vm "generic" {
>   owner "root:vms"
>   ...
>   }
> 
>   $ vmctl status
>  ID   PID VCPUS  MAXMEM  CURMEM TTYOWNERSTATE NAME
>   1 - 1512M   -   - :vms  stopped generic
> 
> It only omits it if the user is root, presumably to say "only the group
> matters".
> 
> I find this special case confusing as it looks incomplete, instead just
> print whatever is configured: 
> 
>   $ ./obj/vmctl status
>  ID   PID VCPUS  MAXMEM  CURMEM TTYOWNERSTATE NAME
>   1 - 1512M   -   - root:vms  stopped generic
> 
> Feedback? OK?
> 
> 
> Index: vmctl.c
> ===
> RCS file: /cvs/src/usr.sbin/vmctl/vmctl.c,v
> retrieving revision 1.72
> diff -u -p -r1.72 vmctl.c
> --- vmctl.c   12 Dec 2019 03:53:38 -  1.72
> +++ vmctl.c   14 Dec 2019 00:54:23 -
> @@ -768,8 +768,6 @@ print_vm_info(struct vmop_info_result *l
>   (void)strlcpy(user, name, sizeof(user));
>   /* get group name */
>   if (vmi->vir_gid != -1) {
> - if (vmi->vir_uid == 0)
> - *user = '\0';
>   name = group_from_gid(vmi->vir_gid, 1);
>   if (name == NULL)
>   (void)snprintf(group, sizeof(group),
> 

I prefer this output as it’s explicit about the owner. OK with me.

Cheers,
Jasper


Re: [PATCH] add support for versions with '-' before a/b/rc

2019-12-12 Thread Jasper Lievisse Adriaanse
Hello Matija,

Could you please provide a testcase for inclusion in 
src/regress/usr.bin/pkg-config too?
Also, is there a particular port or pkg-config file in the wild that you ran 
into which exhibits this particular pattern?

Cheers,
Jasper

> On 12 Dec 2019, at 18:28, Matija Skala  wrote:
> 
> From fa66eb42d0bd2fec7b364644684e6a4cc9ae9baa Mon Sep 17 00:00:00 2001
> From: Matija Skala 
> Date: Thu, 28 Nov 2019 19:24:42 +0100
> Subject: [PATCH] add support for versions with '-' before a/b/rc
> 
> ---
> usr.bin/pkg-config/pkg-config | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/usr.bin/pkg-config/pkg-config b/usr.bin/pkg-config/pkg-config
> index 6dfbd3224eb..c050e9b058e 100644
> --- a/usr.bin/pkg-config/pkg-config
> +++ b/usr.bin/pkg-config/pkg-config
> @@ -674,13 +674,13 @@ sub compare
>   # is there a valid non-numeric suffix to deal with later?
>   # accepted are (in order): a(lpha) < b(eta) < rc < ' '.
>   # suffix[0] is the 'alpha' part, suffix[1] is the '1' part in 'alpha1'.
> - if ($a =~ s/(rc|beta|b|alpha|a)(\d+)$//) {
> + if ($a =~ s/-?(rc|beta|b|alpha|a)(\d+)$//) {
>   say_debug("valid suffix $1$2 found in $a$1$2.");
>   $suffix_a[0] = $1;
>   $suffix_a[1] = $2;
>   }
> 
> - if ($b =~ s/(rc|beta|b|alpha|a)(\d+)$//) {
> + if ($b =~ s/-?(rc|beta|b|alpha|a)(\d+)$//) {
>   say_debug("valid suffix $1$2 found in $b$1$2.");
>   $suffix_b[0] = $1;
>   $suffix_b[1] = $2;
> 
> 



Re: un-boolean_t sys/ddb/

2019-11-05 Thread Jasper Lievisse Adriaanse


> On 5 Nov 2019, at 13:55, Martin Pieuchot  wrote:
> 
> Take the safe approach of converting `boolean_t' to `int', `TRUE' to `1'
> and `FALSE' to `0'.
> 
> This is to reduce the typedef mess that requires pulling MD/MI headers.
> 
> Per-arch ddb code will follow, ok?
I’m ok with the diff (yay for cleaning that mess), a few trivial nits:

> Index: ddb/db_command.c
> @@ -199,15 +199,14 @@ db_command(struct db_command **last_cmdp
>   int t;
>   charmodif[TOK_STRING_SIZE];
>   db_expr_t   addr, count;
> - boolean_t   have_addr = FALSE;
> - int result;
> + int result, have_addr = 0;

You could merge this with the ‘int t’ a few lines above.

> Index: ddb/db_examine.c
> @@ -145,7 +145,7 @@ db_examine(db_addr_t addr, char *fmt, in
>   for (i = 0; i < size; i++) {
>   value =
>   db_get_value(addr+bytes, 1,
> - FALSE);
> + 0);
This and the next ones can now go on the same line as db_get_value(), no?

>   db_printf("%02lx",
>   (long)value);
>   bytes++;
> @@ -159,7 +159,7 @@ db_examine(db_addr_t addr, char *fmt, in
>   /* Print chars, use . for non-printables */
>   while (bytes--) {
>   value = db_get_value(addr + incr, 1,
> - FALSE);
> + 0);
Idem.

> @@ -198,7 +198,7 @@ db_examine(db_addr_t addr, char *fmt, in
>   incr = 0;
>   for (;;) {
>   value = db_get_value(addr + incr, 1,
> - FALSE);
> + 0);
Idem.

Cheers,
Jasper



Re: vmd(8) i8042 device implementation questions

2019-06-02 Thread Jasper Lievisse Adriaanse
On Sat, Jun 01, 2019 at 06:12:16PM -0500, Katherine Rohl wrote:
> Couple questions:
> 
> > This means no interrupt will be injected. I'm not sure if that's what you 
> > want.
> > See vm.c: vcpu_exit_inout(..). It looks like you may have manually asserted 
> > the
> > IRQ in this file, which is a bit different than what we do in other 
> > devices. That
> > may be okay, though.
> 
> The device can assert zero, one, or two IRQs depending on the state of the 
> input ports. Are we capable of asserting two IRQs at once through 
> vcpu_exit_i8042?
> 
> > For this IRQ, if it's edge triggered, please assert then deassert the line.
> > The i8259 code should handle that properly. What you have here is a level
> > triggered interrupt (eg, the line will stay asserted until someone
> > does a 1 -> 0 transition below). Same goes for the next few cases.
> 
> Would asserting the IRQs through the exit function handle this for me if 
> that???s possible?
> 
> > Also, please bump the revision in the vcpu struct for send/receive
> > as we will be sending a new struct layout now.
> 
> Where exactly? The file revision?
That would be VM_DUMP_VERSION in vmd.h I reckon.

-- 
jasper



vmd: tweak mc146818 periodic interrupt updating

2019-05-26 Thread Jasper Lievisse Adriaanse
Hi,

Whilst looking at the mc146818 code in vmd I noticed something that initially 
struck
me as a pasto as the same code is present in the rtc_update_regb() function. 
However
it led me to look at how other emulators handle the updating of registers. 
Based on
that here's a diff to only reschedule the periodic interrupt after updating 
register A
if something changed in register A.

When updating register A we were checking in register B if the
PIE bit was set in order to decide if rtc_reschedule_per needed
to be called. if that bit was changed then the timer rate would
already have been adjusted by rtc_update_regb so the call from
rtc_update_rega is not needed. This now matches what qemu and
other emulators are doing too.

This has been running fine for a few days in a number of VMs.

OK?

Index: mc146818.c
===
RCS file: /cvs/src/usr.sbin/vmd/mc146818.c,v
retrieving revision 1.18
diff -u -p -r1.18 mc146818.c
--- mc146818.c  12 Jul 2018 10:15:44 -  1.18
+++ mc146818.c  26 May 2019 12:13:32 -
@@ -216,7 +216,7 @@ rtc_update_rega(uint32_t data)
__func__);
 
rtc.regs[MC_REGA] = data;
-   if (rtc.regs[MC_REGB] & MC_REGB_PIE)
+   if ((rtc.regs[MC_REGA] ^ data) & 0x0f)
rtc_reschedule_per();
 }
 

-- 
jasper



rtcdrain: fix function reference in comment

2019-05-21 Thread Jasper Lievisse Adriaanse
Hi,

This appears to have been wrong from the import, the comment explaining why
rtcdrain() is needed is in rtcstart() in the same file. OK?

Index: amd64/isa/clock.c
===
RCS file: /cvs/src/sys/arch/amd64/isa/clock.c,v
retrieving revision 1.28
diff -u -p -r1.28 clock.c
--- amd64/isa/clock.c   27 Jul 2018 21:11:31 -  1.28
+++ amd64/isa/clock.c   21 May 2019 18:36:13 -
@@ -291,7 +291,7 @@ rtcdrain(void *v)
 
/*
* Drain any un-acknowledged RTC interrupts.
-   * See comment in cpu_initclocks().
+   * See comment in rtcstart().
*/
while (mc146818_read(NULL, MC_REGC) & MC_REGC_PF)
; /* Nothing. */
Index: i386/isa/clock.c
===
RCS file: /cvs/src/sys/arch/i386/isa/clock.c,v
retrieving revision 1.53
diff -u -p -r1.53 clock.c
--- i386/isa/clock.c30 Jul 2018 14:19:12 -  1.53
+++ i386/isa/clock.c21 May 2019 18:36:13 -
@@ -192,7 +192,7 @@ rtcdrain(void *v)
 
/*
 * Drain any un-acknowledged RTC interrupts.
-* See comment in cpu_initclocks().
+* See comment in rtcstart().
 */
while (mc146818_read(NULL, MC_REGC) & MC_REGC_PF)
; /* Nothing. */
-- 
jasper



Re: sysupgrade: no new snapshot -> no error

2019-05-04 Thread Jasper Lievisse Adriaanse



> On 3 May 2019, at 17:04, Christian Weisgerber  wrote:
> 
> It is not an error condition if no new snapshot is available.
> (Is it?)
> 
> Index: sysupgrade.sh
> ===
> RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
> retrieving revision 1.9
> diff -u -p -r1.9 sysupgrade.sh
> --- sysupgrade.sh 3 May 2019 13:04:40 -   1.9
> +++ sysupgrade.sh 3 May 2019 14:15:41 -
> @@ -115,7 +115,8 @@ cd ${SETSDIR}
> unpriv -f SHA256.sig ftp -Vmo SHA256.sig ${URL}SHA256.sig
> 
> if cmp -s /var/db/installed.SHA256.sig SHA256.sig && ! $FORCE; then
> - ug_err "Already on latest snapshot."
> + echo "Already on latest snapshot."
> + exit 0
> fi
> 
> _KEY=openbsd-${_KERNV[0]%.*}${_KERNV[0]#*.}-base.pub
> -- 
> Christian "naddy" Weisgerber  na...@mips.inka.de
> 

I don’t think it should be an error condition because it effectively means 
you’re up-to-date -- which is a good thing.

Cheers,
Jasper



httpd: allow for longer "tls ciphers"

2018-08-17 Thread Jasper Lievisse Adriaanse
Hi,

The current limit on 'tls ciphers' is 255 characters which prevents using
the cipher list as recommended by 
https://mozilla.github.io/server-side-tls/ssl-config-generator/
for example (clocks in just shy of 300 characters).

tls ciphers 
"ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"

results in a "ciphers too long" error.

I'm aware that 'secure' and 'compat' are available too, but perhaps
we can increase the limit a bit?

Cheers,
Jasper

Index: httpd.h
===
RCS file: /cvs/src/usr.sbin/httpd/httpd.h,v
retrieving revision 1.138
diff -u -p -r1.138 httpd.h
--- httpd.h 20 Jun 2018 16:43:05 -  1.138
+++ httpd.h 17 Aug 2018 12:42:37 -
@@ -60,7 +60,7 @@
 #define HTTPD_LOGVIS   VIS_NL|VIS_TAB|VIS_CSTYLE
 #define HTTPD_TLS_CERT "/etc/ssl/server.crt"
 #define HTTPD_TLS_KEY  "/etc/ssl/private/server.key"
-#define HTTPD_TLS_CONFIG_MAX   255
+#define HTTPD_TLS_CONFIG_MAX   512
 #define HTTPD_TLS_CIPHERS  "compat"
 #define HTTPD_TLS_DHE_PARAMS   "none"
 #define HTTPD_TLS_ECDHE_CURVES "default"

-- 
jasper



Re: w: don't print any header with -h

2017-12-14 Thread Jasper Lievisse Adriaanse
On Thu, Dec 14, 2017 at 01:35:18PM +0100, Martijn van Duren wrote:
> Hello Jasper,
> 
> On 12/14/17 13:22, Jasper Lievisse Adriaanse wrote:
> > Hi,
> > 
> > currently w(1) on OpenBSD differs from other implementations
> > (GNU/Darwin/FreeBSD/SmartOS) in that 'w -h' does print the
> > 'USER TTY FROM ...' header whereas the others don't.
> > 
> > Is there a specific reason for it or could this diff below go in?
> 
> I don't know about the history to tell you, and I don't particularly
> care about this change either way.
> 
> Do note that our uptime(1) says:
> This is the ???heading??? information from w(1).
> 
> This has been removed from the FreeBSD uptime manpage.
> So if we want to do the same thing, you should also adjust uptime.1.
That still _is_ the heading information from w(1) when ran without flags so I
don't think uptime.1 needs any changes.
 
> > Index: w.c
> > ===
> > RCS file: /cvs/src/usr.bin/w/w.c,v
> > retrieving revision 1.63
> > diff -u -p -r1.63 w.c
> > --- w.c 27 Jul 2017 14:17:34 -  1.63
> > +++ w.c 14 Dec 2017 12:19:34 -
> > @@ -224,7 +224,8 @@ main(int argc, char *argv[])
> >  
> >  #define HEADER "USERTTY FROM  LOGIN@  IDLE WHAT"
> >  #define WUSED  (sizeof(HEADER) - sizeof("WHAT"))
> > -   (void)puts(HEADER);
> > +   if (header)
> > +   (void)puts(HEADER);
> >  
> > kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*kp), );
> > if (kp == NULL)
> > 
> 

-- 
jasper



w: don't print any header with -h

2017-12-14 Thread Jasper Lievisse Adriaanse
Hi,

currently w(1) on OpenBSD differs from other implementations
(GNU/Darwin/FreeBSD/SmartOS) in that 'w -h' does print the
'USER TTY FROM ...' header whereas the others don't.

Is there a specific reason for it or could this diff below go in?

Index: w.c
===
RCS file: /cvs/src/usr.bin/w/w.c,v
retrieving revision 1.63
diff -u -p -r1.63 w.c
--- w.c 27 Jul 2017 14:17:34 -  1.63
+++ w.c 14 Dec 2017 12:19:34 -
@@ -224,7 +224,8 @@ main(int argc, char *argv[])
 
 #define HEADER "USERTTY FROM  LOGIN@  IDLE WHAT"
 #define WUSED  (sizeof(HEADER) - sizeof("WHAT"))
-   (void)puts(HEADER);
+   if (header)
+   (void)puts(HEADER);
 
kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*kp), );
if (kp == NULL)

-- 
jasper



Re: panic when invalid randomness source is provided

2017-11-05 Thread Jasper Lievisse Adriaanse
On Sun, Nov 05, 2017 at 06:05:29PM +, Jasper Lievisse Adriaanse wrote:
> Hi,
> 
> Currently we appear to silently drop randomness if it comes from an invalid
> source. Should we not panic in this case?
> While here, update the comment for enqueue_randomness() after -r1.188.
> 
> OK?
Please disregard this, I'm working on a larger diff now that renders this
particular diff unneeded.

-- 
jasper



panic when invalid randomness source is provided

2017-11-05 Thread Jasper Lievisse Adriaanse
Hi,

Currently we appear to silently drop randomness if it comes from an invalid
source. Should we not panic in this case?
While here, update the comment for enqueue_randomness() after -r1.188.

OK?

Index: rnd.c
===
RCS file: /cvs/src/sys/dev/rnd.c,v
retrieving revision 1.193
diff -u -p -r1.193 rnd.c
--- rnd.c   30 Jul 2017 21:40:14 -  1.193
+++ rnd.c   5 Nov 2017 18:01:08 -
@@ -276,13 +276,11 @@ rnd_qlen(void)
 }
 
 /*
- * This function adds entropy to the entropy pool by using timing
- * delays.  It uses the timer_rand_state structure to make an estimate
- * of how many bits of entropy this call has added to the pool.
+ * This function adds entropy to the entropy queue by using timing
+ * delays.
  *
- * The number "val" is also added to the pool - it should somehow describe
- * the type of event which just happened.  Currently the values of 0-255
- * are for keyboard scan codes, 256 and upwards - for interrupts.
+ * The number "state" is also added to the queue - it should somehow describe
+ * the type of event which just happened.
  */
 void
 enqueue_randomness(u_int state, u_int val)
@@ -292,7 +290,7 @@ enqueue_randomness(u_int state, u_int va
 
 #ifdef DIAGNOSTIC
if (state >= RND_SRC_NUM)
-   return;
+   panic("Invalid randomness source provided: %d", state);
 #endif
 
if (timeout_initialized(_timeout))

-- 
jasper



Re: Remove DDB_STRUCTINFO

2017-09-11 Thread Jasper Lievisse Adriaanse
On Mon, Sep 11, 2017 at 10:01:27AM +, Martin Pieuchot wrote:
> Now that dlg@ implemented 'show struct' using CTF, which makes it
> available in GENERIC kernel we can retire DDB_STRUCTINFO.
> 
> Diff below does that, ok?
I suggested the same dlg, so OK with me.

Cheers,
Jasper
 
> Index: conf/files
> ===
> RCS file: /cvs/src/sys/conf/files,v
> retrieving revision 1.651
> diff -u -p -r1.651 files
> --- conf/files11 Aug 2017 20:50:15 -  1.651
> +++ conf/files11 Sep 2017 09:56:09 -
> @@ -609,7 +609,6 @@ file ddb/db_lex.c ddb
>  file ddb/db_output.c ddb
>  file ddb/db_prof.c   ddb & ddbprof & !gprof
>  file ddb/db_run.cddb
> -file ddb/db_struct.c ddb & ddb_struct
>  file ddb/db_sym.cddb
>  file ddb/db_trap.c   ddb
>  file ddb/db_variables.c  ddb
> Index: ddb//db_command.c
> ===
> RCS file: /cvs/src/sys/ddb/db_command.c,v
> retrieving revision 1.76
> diff -u -p -r1.76 db_command.c
> --- ddb//db_command.c 6 Sep 2017 04:47:26 -   1.76
> +++ ddb//db_command.c 11 Sep 2017 09:03:36 -
> @@ -581,9 +581,6 @@ struct db_command db_show_cmds[] = {
>   { "nfsnode",db_nfsnode_print_cmd,   0,  NULL },
>  #endif
>   { "object", db_object_print_cmd,0,  NULL },
> -#ifdef DDB_STRUCT
> - { "offset", db_struct_offset_cmd,   CS_OWN, NULL },
> -#endif
>   { "page",   db_page_print_cmd,  0,  NULL },
>   { "panic",  db_show_panic_cmd,  0,  NULL },
>   { "pool",   db_pool_print_cmd,  0,  NULL },
> Index: ddb//db_struct.c
> ===
> RCS file: ddb//db_struct.c
> diff -N ddb//db_struct.c
> --- ddb//db_struct.c  1 Sep 2015 05:26:10 -   1.4
> +++ /dev/null 1 Jan 1970 00:00:00 -
> @@ -1,277 +0,0 @@
> -/*   $OpenBSD: db_struct.c,v 1.4 2015/09/01 05:26:10 jsg Exp $   */
> -
> -/*
> - * Copyright (c) 2009 Miodrag Vallat.
> - *
> - * Permission to use, copy, modify, and distribute this software for any
> - * purpose with or without fee is hereby granted, provided that the above
> - * copyright notice and this permission notice appear in all copies.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> - */
> -
> -/*
> - * ddb routines to describe struct information
> - */
> -
> -#include 
> -#include 
> -
> -#include 
> -
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "db_structinfo.h"
> -
> -void db_struct_print_field(uint, int, db_expr_t);
> -
> -/*
> - * Flags to pass db_struct_printf().
> - */
> -
> -#define  DBSP_STRUCT_NAME0x01/* prepend struct name */
> -#define  DBSP_VALUE  0x02/* display field value */
> -
> -void
> -db_struct_print_field(uint fidx, int flags, db_expr_t baseaddr)
> -{
> - const struct ddb_field_info *field;
> - const struct ddb_struct_info *struc;
> - db_expr_t value;
> - uint tmp;
> - size_t namelen;
> - int width, basecol, curcol;
> - char tmpfmt[28];
> -
> - field = _field_info[fidx];
> - basecol = 0;
> -
> - if (ISSET(flags, DBSP_STRUCT_NAME)) {
> - struc = _struct_info[field->sidx];
> - namelen = strlen(ddb_structfield_strings + struc->name);
> - db_printf("%-30s ", ddb_structfield_strings + struc->name);
> - if (namelen > 30)
> - basecol += namelen + 1;
> - else
> - basecol += 30 + 1;
> - }
> -
> - namelen = strlen(ddb_structfield_strings + field->name);
> - if (field->nitems == 1) {
> - db_printf("%-30s ", ddb_structfield_strings + field->name);
> - if (namelen > 30)
> - basecol += namelen + 1;
> - else
> - basecol += 30 + 1;
> - } else {
> - width = 30 - 2;
> - tmp = field->nitems;
> - while (tmp != 0) {
> - width--;
> - tmp /= 10;
> - }
> - if (namelen >= width) {
> - db_printf("%s[%hu] ",
> - ddb_structfield_strings + field->name,
> - field->nitems);
> - basecol += 

Re: [PATCH] urng.4 - Altusmetrum -> Altus Metrum

2017-09-09 Thread Jasper Lievisse Adriaanse
On Fri, Sep 08, 2017 at 10:25:41PM +0100, Raf Czlonka wrote:
> Hi all,
> 
> According to their web pages[0][1] Altus Metrum name comprises two
> words - both capitalised.
> 
> [0] http://altusmetrum.org/
> [1] http://shop.gag.com/about-magento-demo-store
> 
> Regards,
> 
> Raf
This is indeed correct, thanks!
 
> Index: share/man/man4/urng.4
> ===
> RCS file: /cvs/src/share/man/man4/urng.4,v
> retrieving revision 1.2
> diff -u -p -r1.2 urng.4
> --- share/man/man4/urng.4 29 Aug 2017 06:12:36 -  1.2
> +++ share/man/man4/urng.4 8 Sep 2017 21:13:14 -
> @@ -34,14 +34,14 @@ and stirs it into the system entropy poo
>  .Xr add_true_randomness 9 .
>  .Sh HARDWARE
>  The following devices are supported by this driver:
> -.Bl -tag -width "Altusmetrum"
> +.Bl -tag -width "Altus Metrum"
>  .It Araneus Alea II
>  Capable of delivering 100kbit/sec of hardware-generated entropy.
>  The product documentation states that the USB interface used by the
>  Alea II is the same as that used by its predecessor the Alea I;
>  theoretically this means that the Alea I should work but this has not
>  been tested.
> -.It Altusmetrum ChaosKey 1.0
> +.It Altus Metrum ChaosKey 1.0
>  This device is capable of providing entropy at 10Mbit/s.
>  .El
>  .Sh SEE ALSO
> 

-- 
jasper



Re: [PATCH] vm.conf: Clarify VM name constraints

2017-08-31 Thread Jasper Lievisse Adriaanse
On Wed, Aug 30, 2017 at 05:11:26PM -0700, Carlos Cardenas wrote:
> Add VM name constraints to match those in vmctl.8 manpage.
> 
> Comments? Ok?
Applied, thanks.
 
> diff --git usr.sbin/vmd/vm.conf.5 usr.sbin/vmd/vm.conf.5
> index d1e68dbce5d..77a7a4e8cea 100644
> --- usr.sbin/vmd/vm.conf.5
> +++ usr.sbin/vmd/vm.conf.5
> @@ -108,7 +108,9 @@ section starts with a declaration of the virtual machine
>  .Ar name :
>  .Bl -tag -width Ds
>  .It Ic vm Ar name Brq ...
> -This name can be any string, and is typically a hostname.
> +The name can be any alphanumeric string along with '.', '-', and '_'  
> +characters.  However, it cannot start with '.', '-', or '_'.  
> +Typically the name is a hostname.
>  .El
>  .Pp
>  Followed by a block of parameters that is enclosed in curly brackets:
> -- 
> 2.14.1
> 

-- 
jasper



combined usb rng driver

2017-08-27 Thread Jasper Lievisse Adriaanse
Hi

Instead of adding a new driver for each USB RNG device here's a diff to
combine the existing ualea(4) driver and support for a new device (ChaosKey
support by abieber@) into urng(4).

The plan is to merge uonerng(4) into it as well as support for future
devices into this single driver.

This was tested by abieber@ with a ChaosKey and Sean with an Alea II.

OK?

Cheers,
Jasper

Index: share/man/man4/Makefile
===
RCS file: /cvs/src/share/man/man4/Makefile,v
retrieving revision 1.656
diff -u -p -r1.656 Makefile
--- share/man/man4/Makefile 25 Aug 2017 11:17:35 -  1.656
+++ share/man/man4/Makefile 26 Aug 2017 19:44:32 -
@@ -61,7 +61,7 @@ MAN=  aac.4 ac97.4 acphy.4 \
stp.4 sv.4 switch.4 sym.4 tcic.4 tcp.4 termios.4 tht.4 ti.4 tl.4 \
tlphy.4 thmc.4 tpm.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 tun.4 tap.4 \
twe.4 \
-   txp.4 txphy.4 ualea.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
+   txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
ubsec.4 \
ucom.4 uchcom.4 ucycom.4 uslhcom.4 udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uipaq.4 \
@@ -69,7 +69,7 @@ MAN=  aac.4 ac97.4 acphy.4 \
ukphy.4 ulpt.4 umass.4 umb.4 umbg.4 umcs.4 umct.4 umidi.4 umodem.4 \
ums.4 umsm.4 unix.4 uonerng.4 uow.4 uoaklux.4 uoakrh.4 uoakv.4 upd.4 \
upgt.4 upl.4 uplcom.4 ural.4 ure.4 url.4 urlphy.4 \
-   urndis.4 urtw.4 urtwn.4 usb.4 uscom.4 uslcom.4 usps.4 \
+   urndis.4 urng.4 urtw.4 urtwn.4 usb.4 uscom.4 uslcom.4 usps.4 \
uthum.4 uticom.4 utpms.4 utwitch.4 utrh.4 uts.4 utvfu.4 uvideo.4 \
uvisor.4 uvscom.4 uwacom.4 \
vether.4 vga.4 vgafb.4 vge.4 \
Index: share/man/man4/ualea.4
===
RCS file: share/man/man4/ualea.4
diff -N share/man/man4/ualea.4
--- share/man/man4/ualea.4  16 Apr 2015 08:56:53 -  1.1
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,54 +0,0 @@
-.\"$OpenBSD: ualea.4,v 1.1 2015/04/16 08:56:53 mpi Exp $
-.\"
-.\" Copyright (c) 2007 Marc Balmer <mbal...@openbsd.org>
-.\" Copyright (c) 2015 Sean Levy <att...@stalphonsos.com>
-.\"
-.\" Permission to use, copy, modify, and distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd $Mdocdate: April 16 2015 $
-.Dt UALEA 4
-.Os
-.Sh NAME
-.Nm ualea
-.Nd Araneus Alea II USB TRNG
-.Sh SYNOPSIS
-.Cd "ualea* at uhub?"
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for the Araneus Alea II, a USB true random
-number generator (TRNG).
-It delivers 100kbit/sec of hardware-generated entropy.
-.Nm
-reads raw entropy from the Alea II and uses
-.Xr add_true_randomness 9
-to add it to the system entropy pool.
-.Pp
-The product documentation states that the USB interface used by the
-Alea II is the same as that used by its predecessor the Alea I;
-theoretically this means that the Alea I should work but this has not
-been tested.
-.Sh SEE ALSO
-.Xr intro 4 ,
-.Xr usb 4 ,
-.Xr add_true_randomness 9
-.Sh HISTORY
-The
-.Nm
-driver first appeared in
-.Ox 5.7 .
-.Sh AUTHORS
-The
-.Nm
-driver was written by
-.An Sean Levy Aq Mt att...@stalphonsos.com .
Index: share/man/man4/urng.4
===
RCS file: share/man/man4/urng.4
diff -N share/man/man4/urng.4
--- /dev/null   1 Jan 1970 00:00:00 -
+++ share/man/man4/urng.4   26 Aug 2017 20:34:54 -
@@ -0,0 +1,63 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2015 Sean Levy <att...@stalphonsos.com>
+.\" Copyright (c) 2017 Jasper Lievisse Adriaanse <jas...@openbsd.org>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 

db_{interface,trace}.c: ansify function definitions

2016-09-19 Thread Jasper Lievisse Adriaanse
OK?

Index: alpha/alpha/db_trace.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/db_trace.c,v
retrieving revision 1.18
diff -u -p -r1.18 db_trace.c
--- alpha/alpha/db_trace.c  19 Sep 2016 17:59:18 -  1.18
+++ alpha/alpha/db_trace.c  19 Sep 2016 18:00:58 -
@@ -171,12 +171,8 @@ disp(x)
  * symbols available.
  */
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr)(const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
u_long  *frame;
int i, framesize;
Index: arm/arm/db_trace.c
===
RCS file: /cvs/src/sys/arch/arm/arm/db_trace.c,v
retrieving revision 1.7
diff -u -p -r1.7 db_trace.c
--- arm/arm/db_trace.c  19 Sep 2016 17:59:18 -  1.7
+++ arm/arm/db_trace.c  19 Sep 2016 18:00:58 -
@@ -81,12 +81,8 @@ db_regs_t ddb_regs;
 #define FR_RFP (-3)
 
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr) (const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...)))
 {
u_int32_t   *frame, *lastframe;
char c, *cp = modif;
Index: hppa/hppa/db_interface.c
===
RCS file: /cvs/src/sys/arch/hppa/hppa/db_interface.c,v
retrieving revision 1.37
diff -u -p -r1.37 db_interface.c
--- hppa/hppa/db_interface.c1 Mar 2016 21:35:13 -   1.37
+++ hppa/hppa/db_interface.c19 Sep 2016 18:00:58 -
@@ -134,10 +134,7 @@ Debugger()
 }
 
 void
-db_read_bytes(addr, size, data)
-   vaddr_t addr;
-   size_t size;
-   char *data;
+db_read_bytes(vaddr_t addr, size_t size, char *data)
 {
register char *src = (char *)addr;
 
@@ -146,10 +143,7 @@ db_read_bytes(addr, size, data)
 }
 
 void
-db_write_bytes(addr, size, data)
-   vaddr_t addr;
-   size_t size;
-   char *data;
+db_write_bytes(vaddr_t addr, size_t size, char *data)
 {
register char *dst = (char *)addr;
 
@@ -166,8 +160,7 @@ db_write_bytes(addr, size, data)
  * Print trap reason.
  */
 void
-kdbprinttrap(type, code)
-   int type, code;
+kdbprinttrap(int type, int code)
 {
type &= ~T_USER;/* just in case */
db_printf("kernel: ");
@@ -182,9 +175,7 @@ kdbprinttrap(type, code)
  *  db_ktrap - field a BPT trap
  */
 int
-db_ktrap(type, code, regs)
-   int type, code;
-   db_regs_t *regs;
+db_ktrap(int type, int code, db_regs_t *regs)
 {
extern label_t *db_recover;
int s;
@@ -226,19 +217,14 @@ db_ktrap(type, code, regs)
  *  Any address is allowed for now.
  */
 int
-db_valid_breakpoint(addr)
-   db_addr_t addr;
+db_valid_breakpoint(db_addr_t addr)
 {
return (1);
 }
 
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr)(const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
register_t *fp, pc, rp, *argp;
db_sym_t sym;
Index: m88k/m88k/db_trace.c
===
RCS file: /cvs/src/sys/arch/m88k/m88k/db_trace.c,v
retrieving revision 1.15
diff -u -p -r1.15 db_trace.c
--- m88k/m88k/db_trace.c9 Mar 2016 08:58:50 -   1.15
+++ m88k/m88k/db_trace.c19 Sep 2016 18:00:58 -
@@ -806,11 +806,8 @@ db_stack_trace_cmd2(db_regs_t *regs, int
  * printed.
  */
 void
-db_stack_trace_print(db_expr_t addr,
-  int have_addr,
-  db_expr_t count,
-  char *modif,
-  int (*pr)(const char *, ...))
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
enum {
Default, Stack, Frame

-- 
jasper



sys/systm.h: drop read_symtab_from_file() proto

2016-09-17 Thread Jasper Lievisse Adriaanse
This seems to be a leftover from when the actual function itself was removed
at some point?

Index: systm.h
===
RCS file: /cvs/src/sys/sys/systm.h,v
retrieving revision 1.117
diff -u -p -r1.117 systm.h
--- systm.h 13 Sep 2016 08:32:44 -  1.117
+++ systm.h 17 Sep 2016 11:04:10 -
@@ -308,7 +308,6 @@ extern int (*mountroot)(void);
 #if defined(DDB) || defined(KGDB)
 /* debugger entry points */
 void   Debugger(void); /* in DDB only */
-intread_symtab_from_file(struct proc *,struct vnode *,const char *);
 #endif
 
 #ifdef BOOT_CONFIG

-- 
jasper



define ELF_CTF in exec_elf.h

2016-09-16 Thread Jasper Lievisse Adriaanse
Hi,

This moves the definition of ELF_CTF into exec_elf.h and adjusts the
loadfile_elf.c copies accordingly.

OK?

Index: share/man/man5/elf.5
===
RCS file: /cvs/src/share/man/man5/elf.5,v
retrieving revision 1.32
diff -u -p -r1.32 elf.5
--- share/man/man5/elf.57 Sep 2016 18:42:01 -   1.32
+++ share/man/man5/elf.516 Sep 2016 19:16:37 -
@@ -877,6 +877,13 @@ fixed-size entries.
 .Pp
 Various sections hold program and control information:
 .Bl -tag -width ".shstrtab"
+.It .SUNW_ctf
+This section contains the (un)compressed Compact C-Type Format data
+describing the object's types and symbols.
+This section is of type
+.Dv SHT_NOBITS .
+The attribute used is
+.Dv SHF_ALLOC .
 .It .bss
 This section holds uninitialized data that contribute to the program's
 memory image.
Index: sys/ddb/db_ctf.c
===
RCS file: /cvs/src/sys/ddb/db_ctf.c,v
retrieving revision 1.1
diff -u -p -r1.1 db_ctf.c
--- sys/ddb/db_ctf.c16 Sep 2016 19:13:17 -  1.1
+++ sys/ddb/db_ctf.c16 Sep 2016 19:16:37 -
@@ -56,8 +56,6 @@ static char   *db_ctf_decompress(const ch
 static int  db_ctf_print_functions();
 static int  db_ctf_nsyms(void);
 
-#defineELF_CTF ".SUNW_ctf"
-
 /*
  * Entrypoint to verify CTF presence, initialize the header, decompress
  * the data, etc.
Index: sys/lib/libsa/loadfile_elf.c
===
RCS file: /cvs/src/sys/lib/libsa/loadfile_elf.c,v
retrieving revision 1.12
diff -u -p -r1.12 loadfile_elf.c
--- sys/lib/libsa/loadfile_elf.c13 Sep 2016 18:09:14 -  1.12
+++ sys/lib/libsa/loadfile_elf.c16 Sep 2016 19:16:37 -
@@ -234,7 +234,7 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_l
if (shp[i].sh_type == SHT_SYMTAB ||
shp[i].sh_type == SHT_STRTAB ||
!strcmp(shstr + shp[i].sh_name, ".debug_line") ||
-   !strcmp(shstr + shp[i].sh_name, ".SUNW_ctf")) {
+   !strcmp(shstr + shp[i].sh_name, ELF_CTF)) {
if (havesyms && (flags & LOAD_SYM)) {
PROGRESS(("%s%ld", first ? " [" : "+",
(u_long)shp[i].sh_size));
Index: sys/sys/exec_elf.h
===
RCS file: /cvs/src/sys/sys/exec_elf.h,v
retrieving revision 1.63
diff -u -p -r1.63 exec_elf.h
--- sys/sys/exec_elf.h  7 Sep 2016 20:12:42 -   1.63
+++ sys/sys/exec_elf.h  16 Sep 2016 19:16:36 -
@@ -264,6 +264,7 @@ typedef struct {
 /* Section names */
 #define ELF_BSS ".bss" /* uninitialized data */
 #define ELF_DATA".data"/* initialized data */
+#defineELF_CTF ".SUNW_ctf" /* CTF data */
 #define ELF_DEBUG   ".debug"   /* debug */
 #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
 #define ELF_DYNSTR  ".dynstr"  /* dynamic string table */
Index: usr.sbin/vmd/loadfile_elf.c
===
RCS file: /cvs/src/usr.sbin/vmd/loadfile_elf.c,v
retrieving revision 1.18
diff -u -p -r1.18 loadfile_elf.c
--- usr.sbin/vmd/loadfile_elf.c 13 Sep 2016 19:07:47 -  1.18
+++ usr.sbin/vmd/loadfile_elf.c 16 Sep 2016 19:16:37 -
@@ -779,7 +779,7 @@ elf64_exec(int fd, Elf64_Ehdr *elf, u_lo
if (shp[i].sh_type == SHT_SYMTAB ||
shp[i].sh_type == SHT_STRTAB ||
!strcmp(shstr + shp[i].sh_name, ".debug_line") ||
-   !strcmp(shstr + shp[i].sh_name, ".SUNW_ctf")) {
+   !strcmp(shstr + shp[i].sh_name, ELF_CTF)) {
if (havesyms && (flags & LOAD_SYM)) {
if (lseek(fd, (off_t)shp[i].sh_offset,
SEEK_SET) == -1) {

Cheers,
-- 
jasper



libsa, stop saving memory

2016-09-14 Thread Jasper Lievisse Adriaanse
Hi,

nothing defines SAVE_MEMORY nor has it been modified since -r1.1.
ok to zap it?

Index: cread.c
===
RCS file: /cvs/src/sys/lib/libsa/cread.c,v
retrieving revision 1.13
diff -u -p -r1.13 cread.c
--- cread.c 18 Jan 2009 21:46:50 -  1.13
+++ cread.c 14 Sep 2016 18:39:23 -
@@ -47,11 +47,7 @@
 
 #define zmemcpymemcpy
 
-#ifdef SAVE_MEMORY
-#define Z_BUFSIZE 1024
-#else
 #define Z_BUFSIZE 4096
-#endif
 
 static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
 
@@ -210,11 +206,7 @@ open(const char *fname, int mode)
goto errout;
bzero(s, sizeof(struct sd));
 
-#ifdef SAVE_MEMORY
-   if (inflateInit2(&(s->stream), -11) != Z_OK)
-#else
if (inflateInit2(&(s->stream), -15) != Z_OK)
-#endif
goto errout;
 
s->stream.next_in  = s->inbuf = (unsigned char *)alloc(Z_BUFSIZE);

-- 
jasper



Re: generate pkg-config files at build time

2016-09-13 Thread Jasper Lievisse Adriaanse
On Tue, Sep 13, 2016 at 06:35:08PM +0200, Martin Natano wrote:
> Currently pkg-config files are generated at install time, while they
> should be generated at build time like everything else. One reason why
> generating files during install is bad is that the two steps might be
> run by two differnt users, resulting in permission problems.
> 
> While there I removed the dependency from the install target on the
> pkg-config files as this is also not done for libraries and programs.
> If you didn't build before install you are fucked anyway.
> 
> Ok?
> 
> natano
Makes sense; OK.

> Index: lib/libcrypto/Makefile
> ===
> RCS file: /cvs/src/lib/libcrypto/Makefile,v
> retrieving revision 1.5
> diff -u -p -r1.5 Makefile
> --- lib/libcrypto/Makefile11 Sep 2016 14:31:02 -  1.5
> +++ lib/libcrypto/Makefile12 Sep 2016 18:19:53 -
> @@ -431,10 +431,11 @@ distribution:
>   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
>  ${.CURDIR}/x509v3.cnf ${DESTDIR}/etc/ssl/x509v3.cnf
>  
> +all: ${PC_FILES}
>  ${PC_FILES}: opensslv.h
>   /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
>  
> -beforeinstall: ${PC_FILES}
> +beforeinstall:
>   ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \
>   -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/
>  
> Index: lib/libexpat/Makefile
> ===
> RCS file: /cvs/src/lib/libexpat/Makefile,v
> retrieving revision 1.10
> diff -u -p -r1.10 Makefile
> --- lib/libexpat/Makefile 4 Sep 2016 09:54:25 -   1.10
> +++ lib/libexpat/Makefile 12 Sep 2016 18:20:08 -
> @@ -17,10 +17,11 @@ includes:
> ${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) \
> ${.CURDIR}/lib/expat_external.h 
> ${DESTDIR}/usr/include/expat_external.h
>  
> +all: ${PC_FILES}
>  ${PC_FILES}: lib/expat.h
>   /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
>  
> -beforeinstall: ${PC_FILES}
> +beforeinstall:
>   ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \
>   -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/
>  
> Index: lib/libfuse/Makefile
> ===
> RCS file: /cvs/src/lib/libfuse/Makefile,v
> retrieving revision 1.9
> diff -u -p -r1.9 Makefile
> --- lib/libfuse/Makefile  4 Sep 2016 09:54:25 -   1.9
> +++ lib/libfuse/Makefile  12 Sep 2016 18:20:16 -
> @@ -29,10 +29,11 @@ includes:
>   eval "$$j"; \
>   done
>  
> +all: ${PC_FILES}
>  ${PC_FILES}: fuse_private.h
>   /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
>  
> -beforeinstall: ${PC_FILES}
> +beforeinstall:
>   ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \
>   -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/
>  
> Index: lib/libssl/Makefile
> ===
> RCS file: /cvs/src/lib/libssl/Makefile,v
> retrieving revision 1.21
> diff -u -p -r1.21 Makefile
> --- lib/libssl/Makefile   4 Sep 2016 09:54:25 -   1.21
> +++ lib/libssl/Makefile   12 Sep 2016 18:20:34 -
> @@ -48,10 +48,11 @@ includes:
>  
>  .include 
>  
> +all: ${PC_FILES}
>  ${PC_FILES}: ${.CURDIR}/../libcrypto/opensslv.h
>   /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
>  
> -beforeinstall: ${PC_FILES}
> +beforeinstall:
>   nm -o lib${LIB}.a | egrep -w 'printf|fprintf' && \
>   (echo please fix stdio usage in this library; false) || true
>  .for p in ${PC_FILES}
> Index: lib/libz/Makefile
> ===
> RCS file: /cvs/src/lib/libz/Makefile,v
> retrieving revision 1.19
> diff -u -p -r1.19 Makefile
> --- lib/libz/Makefile 4 Sep 2016 09:54:25 -   1.19
> +++ lib/libz/Makefile 12 Sep 2016 18:20:44 -
> @@ -19,10 +19,11 @@ includes:
>   eval "$$j"; \
>   done
>  
> +all: ${PC_FILES}
>  ${PC_FILES}: zlib.h
>   /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
>  
> -beforeinstall: ${PC_FILES}
> +beforeinstall:
>   ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \
>   -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/
>  
> 

-- 
jasper



Re: db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Jasper Lievisse Adriaanse
On Fri, Sep 09, 2016 at 01:54:46PM -0700, Philip Guenther wrote:
> On Fri, Sep 9, 2016 at 11:38 AM, Jasper Lievisse Adriaanse
> <jas...@openbsd.org> wrote:
> > Do we really want the filename to be printed in the message? If so we should
> > use __FILE__. On the other hand, having the function name makes more sense 
> > to
> > me.
> 
> This is a "not found" message in response to an explicit user command:
> why does the user care what *source file* is generating that message?
I have no idea why the user would care about the source file. However the
function triggering it might be of some more information, albeit of dubious
added value. Perhaps the message should be normalized across the board
following arm/sparc64?

> arm and sparc64 do the Right Thing IMO:
> if (p == NULL) {
> (*pr)("not found\n");
> return;
> }
> 
> Philip Guenther
 

-- 
jasper



db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Jasper Lievisse Adriaanse
Hi,

Do we really want the filename to be printed in the message? If so we should
use __FILE__. On the other hand, having the function name makes more sense to
me.

OK?

Index: amd64/amd64/db_trace.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.20
diff -u -p -r1.20 db_trace.c
--- amd64/amd64/db_trace.c  4 Sep 2016 09:22:28 -   1.20
+++ amd64/amd64/db_trace.c  9 Sep 2016 18:35:09 -
@@ -174,7 +174,7 @@ db_stack_trace_print(db_expr_t addr, boo
if (trace_proc) {
struct proc *p = pfind((pid_t)addr);
if (p == NULL) {
-   (*pr) ("db_trace.c: process not found\n");
+   (*pr) ("%s: process not found\n", __func__);
return;
}
frame = (struct callframe *)p->p_addr->u_pcb.pcb_rbp;
Index: i386/i386/db_trace.c
===
RCS file: /cvs/src/sys/arch/i386/i386/db_trace.c,v
retrieving revision 1.19
diff -u -p -r1.19 db_trace.c
--- i386/i386/db_trace.c3 Mar 2016 12:44:09 -   1.19
+++ i386/i386/db_trace.c9 Sep 2016 18:35:09 -
@@ -186,11 +186,11 @@ db_stack_trace_print(db_expr_t addr, boo
frame = (struct callframe *)ddb_regs.tf_ebp;
callpc = (db_addr_t)ddb_regs.tf_eip;
} else if (trace_thread) {
-   (*pr) ("db_trace.c: can't trace thread\n");
+   (*pr) ("%s: can't trace thread\n", __func__);
} else if (trace_proc) {
struct proc *p = pfind((pid_t)addr);
if (p == NULL) {
-   (*pr) ("db_trace.c: process not found\n");
+   (*pr) ("%s: process not found\n", __func__);
return;
}
frame = (struct callframe *)p->p_addr->u_pcb.pcb_ebp;

-- 
jasper



Re: add EdgeRouter Pro to www/octeon.html

2016-03-19 Thread Jasper Lievisse Adriaanse
On Fri, Mar 18, 2016 at 08:44:11AM +0100, Marcus MERIGHI wrote:
> Hello,
> 
> "The patch seems to work fine on an EdgeRouter Pro.
> OK visa@"
> (http://marc.info/?l=openbsd-tech=145822792814191)
> 
> EdgeRouter Pro is not on octeon.html, put it there?
> 
> Bye, Marcus
Last time I checked the ethernet wasn't working either, so while we can boot on
it, I'm not too sure if we should list it yet.

> Index: octeon.html
> ===
> RCS file: /cvs/www/octeon.html,v
> retrieving revision 1.27
> diff -u -p -u -r1.27 octeon.html
> --- octeon.html   13 Jan 2016 14:25:49 -  1.27
> +++ octeon.html   18 Mar 2016 07:39:28 -
> @@ -70,7 +70,8 @@ Portwell CAM-0100
>  http://www.ubnt.com/edgemax/edgerouter-lite/;>Ubiquiti Networks
>  EdgeRouter LITE
>  http://www.ubnt.com/edgemax/edgerouter-poe/;>Ubiquiti Networks
> -EdgeRouter PoE
> +http://www.ubnt.com/edgemax/edgerouter-pro/;>Ubiquiti Networks
> +EdgeRouter Pro
>  
>  
>  
> 

-- 
jasper



Re: libgtop2: Use getifaddrs(3) instead of KVM

2015-12-06 Thread Jasper Lievisse Adriaanse
On Sat, Dec 05, 2015 at 05:05:07PM +0100, Martin Pieuchot wrote:
> Here's a rewrite of glibtop_get_netload_p().  I tested it with custom
> code because I could not trigger this code path with our ports.
> 
> This unbreaks devel/libgtop2 after the recent  commit.
> 
> I believe this should go upstream, how should I submit this?
I can merge it directly upstream (with proper git authorship set). Note that
our libgtop could use an update but as of yet I didn't get around to
fixing the build breakage yet. When that's been done I'll merge your patch
upstream, alright?

> ok?
OK with me.
 
> Index: Makefile
> ===
> RCS file: /cvs/ports/devel/libgtop2/Makefile,v
> retrieving revision 1.130
> diff -u -p -r1.130 Makefile
> --- Makefile  22 May 2015 11:31:13 -  1.130
> +++ Makefile  5 Dec 2015 15:58:01 -
> @@ -6,7 +6,7 @@ GNOME_VERSION=2.30.0
>  GNOME_PROJECT=   libgtop
>  PKGNAME= libgtop2-${VERSION}
>  
> -REVISION=3
> +REVISION=4
>  
>  SHARED_LIBS= gtop-2.09.0 # .10.0
>  
> Index: patches/patch-sysdeps_openbsd_netload_c
> ===
> RCS file: patches/patch-sysdeps_openbsd_netload_c
> diff -N patches/patch-sysdeps_openbsd_netload_c
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ patches/patch-sysdeps_openbsd_netload_c   5 Dec 2015 15:59:31 -
> @@ -0,0 +1,345 @@
> +$OpenBSD$
> +
> +Rewrite of glibtop_get_netload_p() to use getifaddrs(3) instead of KVM.
> +
> +--- sysdeps/openbsd/netload.c.orig   Mon Apr 28 23:09:24 2014
>  sysdeps/openbsd/netload.cSat Dec  5 16:27:56 2015
> +@@ -1,48 +1,39 @@
> +-/* Copyright (C) 1998-99 Martin Baulig
> +-   This file is part of LibGTop 1.0.
> ++/*
> ++ * Copyright (c) 2015 Martin Pieuchot 
> ++ *
> ++ * Permission to use, copy, modify, and distribute this software for any
> ++ * purpose with or without fee is hereby granted, provided that the above
> ++ * copyright notice and this permission notice appear in all copies.
> ++ *
> ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> ++ */
> + 
> +-   Contributed by Martin Baulig , October 1998.
> ++#include "config.h"
> + 
> +-   LibGTop is free software; you can redistribute it and/or modify it
> +-   under the terms of the GNU General Public License as published by
> +-   the Free Software Foundation; either version 2 of the License,
> +-   or (at your option) any later version.
> ++#include 
> ++#include 
> ++#include 
> + 
> +-   LibGTop is distributed in the hope that it will be useful, but WITHOUT
> +-   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +-   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +-   for more details.
> +-
> +-   You should have received a copy of the GNU General Public License
> +-   along with LibGTop; see the file COPYING. If not, write to the
> +-   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> +-   Boston, MA 02111-1307, USA.
> +-*/
> +-
> +-#include 
> +-#include 
> +-#include 
> +-#include 
> +-
> +-#include 
> +-
> +-#include 
> +-
> + #include 
> + #include 
> +-#include 
> + 
> +-#include 
> +-
> +-#include 
> +-
> + #include 
> +-#define _KERNEL
> + #include 
> +-#undef _KERNEL
> + #include 
> + 
> ++#include 
> ++
> ++#include "glibtop.h"
> ++#include "glibtop/netload.h"
> ++
> + static const unsigned long _glibtop_sysdeps_netload =
> ++(1L << GLIBTOP_NETLOAD_MTU) +
> + (1L << GLIBTOP_NETLOAD_IF_FLAGS) +
> + (1L << GLIBTOP_NETLOAD_PACKETS_IN) +
> + (1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
> +@@ -55,183 +46,115 @@ static const unsigned long _glibtop_sysdeps_netload =
> + (1L << GLIBTOP_NETLOAD_ERRORS_TOTAL) +
> + (1L << GLIBTOP_NETLOAD_COLLISIONS);
> + 
> +-static const unsigned _glibtop_sysdeps_netload_data =
> +-(1L << GLIBTOP_NETLOAD_ADDRESS) +
> +-(1L << GLIBTOP_NETLOAD_SUBNET) +
> +-(1L << GLIBTOP_NETLOAD_MTU);
> +-
> +-/* nlist structure for kernel access */
> +-static struct nlist nlst [] = {
> +-{ "_ifnet" },
> +-{ 0 }
> +-};
> +-
> +-/* Init function. */
> +-
> + void
> + _glibtop_init_netload_p (glibtop *server)
> + {
> + server->sysdeps.netload = _glibtop_sysdeps_netload;
> +-
> +-if (kvm_nlist (server->machine.kd, nlst) < 0)
> +-glibtop_error_io_r (server, "kvm_nlist");
> + }
> + 
> +-/* Provides Network statistics. */
> +-
> + void
> + 

Re: WAPBL implementation

2015-10-28 Thread Jasper Lievisse Adriaanse
On Wed, Oct 28, 2015 at 09:06:54AM -0200, Walter Neto wrote:
> Adding WAPBL support for dumpfs(8)
> 
> next diffs:
> - tunefs(8) showing log information and setting log size
> - fsck_ffs(8) WAPBL support
> 
> ok jasper@
Correction:
I only pointed out that we should have the option to somehow get information
about the log. I did not OK this or the original WAPBL diff.

-- 
jasper



Re: [PATCH] pkg-config compare() fails for libevent (at least)

2015-08-12 Thread Jasper Lievisse Adriaanse
On Tue, Aug 11, 2015 at 01:20:24PM -0500, attila wrote:
 Hello tech@,
 
 On the 6 Aug snap I ran into this issue:
 
   $ pkg_info | grep libevent
   libevent-2.0.22 event notification library
   $ pkg-config --atleast-version=2.0.1 libevent  echo yes
   Argument 22-stabl isn't numeric in numeric eq (==) at /usr/bin/pkg-config 
 line 662.
   yes
 
 So it works but spits out that error.  The issue is that the libevent
 port reports its version as 2.0.22-stable, which does not follow the
 convention used by the compare() sub in pkg-config.  The attached
 patch gets rid of the error albeit in a very pointilistic way; perhaps
 a more general solution is desired, but I'm not sure what the best
 approach is, especially given that there is something called
 pkg-config available pretty much everywhere but based on very
 different implementations...
 
 It doesn't appear as though my patch introduces any regressions,
 although I'm still sussing out how the regression tests work so I'm
 not sure if I'm doing anything wrong... it appears that five of
 pkg-config's regression tests fail regardless of my patch:
 
   FAIL usr.bin/pkg-config/static-cflags2
   FAIL usr.bin/pkg-config/static-libs2
   FAIL usr.bin/pkg-config/static-libs3
   FAIL usr.bin/pkg-config/static-libs4
   FAIL usr.bin/pkg-config/missing-req-2
 
 In all cases it looks like the difference is ordering, except for the
 last where two errors are produced but only one is expected.  I'll
 work on a patch to fix these failures next.
That's indeed the case and patches to fix that are welcome.
 
 Feedback, comments most welcome.
Could you please add regress tests for this issue you're solving too?
 
 Pax, -A
 --
 http://trac.haqistan.net | att...@stalphonsos.com | 0xE6CC1EDB
 

 Index: pkg-config
 ===
 RCS file: /cvs/src/usr.bin/pkg-config/pkg-config,v
 retrieving revision 1.85
 diff -u -p -r1.85 pkg-config
 --- pkg-config17 Nov 2014 22:16:23 -  1.85
 +++ pkg-config11 Aug 2015 17:53:24 -
 @@ -625,16 +625,16 @@ sub compare
   # is there a valid non-numeric suffix to deal with later?
   # accepted are (in order): a(lpha)  b(eta)  rc  ' '.
   # suffix[0] is the 'alpha' part, suffix[1] is the '1' part in 'alpha1'.
 - if ($a =~ s/(rc|beta|b|alpha|a)(\d+)$//) {
 - say_debug(valid suffix $1$2 found in $a$1$2.);
 - $suffix_a[0] = $1;
 - $suffix_a[1] = $2;
 + if ($a =~ s/(|-)(stable|rc|beta|b|alpha|a)(|\d+)$//) {
 + say_debug(valid suffix $2$3 found in $a$2$3.);
 + $suffix_a[0] = $2;
 + $suffix_a[1] = $3;
   }
  
 - if ($b =~ s/(rc|beta|b|alpha|a)(\d+)$//) {
 - say_debug(valid suffix $1$2 found in $b$1$2.);
 - $suffix_b[0] = $1;
 - $suffix_b[1] = $2;
 + if ($b =~ s/(|-)(stable|rc|beta|b|alpha|a)(|\d+)$//) {
 + say_debug(valid suffix $2$3 found in $b$2$3.);
 + $suffix_b[0] = $2;
 + $suffix_b[1] = $3;
   }
  
   # The above are standard suffixes; deal with single alphabetical


-- 
jasper



sed -i

2015-07-17 Thread Jasper Lievisse Adriaanse
Hi,

Here's a diff to add the '-i' flag to sed to do inplace edits. It's mostly
from FreeBSD with some adjustments to prevent a race with unlink() and fopen()
during the tempfile creation.

It's been tested in a full ports bulk (thanks aja), and went through a build
of base and xenocara.
Regress tests will also be added for this.

This diff is already OK millert@. Any more OKs?

Index: defs.h
===
RCS file: /cvs/src/usr.bin/sed/defs.h,v
retrieving revision 1.5
diff -u -p -r1.5 defs.h
--- defs.h  19 Jan 2015 15:30:52 -  1.5
+++ defs.h  16 Jul 2015 18:45:58 -
@@ -128,6 +128,7 @@ typedef struct {
char *space;/* Current space pointer. */
size_t len; /* Current length. */
int deleted;/* If deleted. */
+   int append_newline; /* If originally terminated by \n. */
char *back; /* Backing memory. */
size_t blen;/* Backing memory length. */
 } SPACE;
Index: extern.h
===
RCS file: /cvs/src/usr.bin/sed/extern.h,v
retrieving revision 1.9
diff -u -p -r1.9 extern.h
--- extern.h13 Apr 2015 05:11:23 -  1.9
+++ extern.h16 Jul 2015 00:23:57 -
@@ -40,17 +40,19 @@ extern regmatch_t *match;
 extern size_t maxnsub;
 extern u_long linenum;
 extern size_t appendnum;
-extern int lastline;
 extern int Eflag, aflag, eflag, nflag;
-extern char *fname;
+extern const char *fname, *outfname;
+extern FILE *infile, *outfile;
 
 voidcfclose(struct s_command *, struct s_command *);
 voidcompile(void);
-voidcspace(SPACE *, char *, size_t, enum e_spflag);
+voidcspace(SPACE *, const char *, size_t, enum e_spflag);
 char   *cu_fgets(char **, size_t *);
 voiderr(int, const char *, ...);
 int mf_fgets(SPACE *, enum e_spflag);
+int lastline(void);
 voidprocess(void);
+voidresetranges(void);
 char   *strregerror(int, regex_t *);
 void   *xmalloc(size_t);
 void   *xreallocarray(void *, size_t, size_t);
Index: main.c
===
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.18
diff -u -p -r1.18 main.c
--- main.c  26 Nov 2014 18:34:51 -  1.18
+++ main.c  16 Jul 2015 19:21:16 -
@@ -34,6 +34,7 @@
  */
 
 #include sys/types.h
+#include sys/stat.h
 
 #include ctype.h
 #include errno.h
@@ -45,6 +46,7 @@
 #include stdlib.h
 #include string.h
 #include unistd.h
+#include libgen.h
 
 #include defs.h
 #include extern.h
@@ -78,15 +80,23 @@ struct s_flist {
  */
 static struct s_flist *files, **fl_nextp = files;
 
+FILE *infile;  /* Current input file */
+FILE *outfile; /* Current output file */
+
 int Eflag, aflag, eflag, nflag;
+static int rval;   /* Exit status */
 
 /*
  * Current file and line number; line numbers restart across compilation
- * units, but span across input files.
+ * units, but span across input files.  The latter is optional if editing
+ * in place.
  */
-char *fname;   /* File name. */
+const char *fname; /* File name. */
+const char *outfname;  /* Output file name */
+static char oldfname[PATH_MAX];/* Old file name (for in-place editing) 
*/
+static char tmpfname[PATH_MAX];/* Temporary file name (for in-place 
editing) */
+char *inplace; /* Inplace edit file extension */
 u_long linenum;
-int lastline;  /* TRUE on the last line of the last file */
 
 static void add_compunit(enum e_cut, char *);
 static void add_file(char *);
@@ -97,7 +107,8 @@ main(int argc, char *argv[])
int c, fflag;
 
fflag = 0;
-   while ((c = getopt(argc, argv, Eae:f:nru)) != -1)
+   inplace = NULL;
+   while ((c = getopt(argc, argv, Eae:f:i::nru)) != -1)
switch (c) {
case 'E':
case 'r':
@@ -114,6 +125,9 @@ main(int argc, char *argv[])
fflag = 1;
add_compunit(CU_FILE, optarg);
break;
+   case 'i':
+   inplace = optarg ? optarg : ;
+   break;
case 'n':
nflag = 1;
break;
@@ -123,8 +137,8 @@ main(int argc, char *argv[])
default:
case '?':
(void)fprintf(stderr,
-   usage: sed [-aEnru] command [file ...]\n
-  sed [-aEnru] [-e command] [-f command_file] 
[file ...]\n);
+   usage: sed [-aEnru] [-i [extension]] command [file 
...]\n
+  sed [-aEnru] [-i [extension]] [-e command] 
[-f command_file] [file ...]\n);
exit(1);
}
argc -= optind;
@@ -148,7 +162,7 @@ main(int argc, char *argv[])

Re: Do you need/prefer the non-DUID option in the installer?

2015-03-15 Thread Jasper Lievisse Adriaanse
On Sun, Mar 15, 2015 at 11:24:32AM -0400, Kenneth Westerback wrote:
 Using DUIDs in the installed /etc/fstab has been the default for some time 
 now.
 
 We'd like to eliminate the question in the installer and just use
 DUIDs unconditionally.
 
 But first we need to know you are aware of any circumstances where
 people need or prefer to use the non-DUID option when installing?
 
  Ken

I think there were issues on Octeon when using DUIDs by default.
Did anyone else run into this too?

-- 
jasper



Re: syslogd sending via tcp

2014-12-28 Thread Jasper Lievisse Adriaanse
On Sun, Dec 28, 2014 at 05:33:08PM +0100, Alexander Bluhm wrote:
 Jasper tested and found that it only worked on loopback.  I have
 forgotten to check for EINPROGRESS after connect.  So here is a new
 diff.
 
 bluhm
Succesfully tested now with a remote logstash host.
 
 Index: privsep.c
 ===
 RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/privsep.c,v
 retrieving revision 1.48
 diff -u -p -r1.48 privsep.c
 --- privsep.c 5 Oct 2014 18:14:01 -   1.48
 +++ privsep.c 28 Dec 2014 15:48:51 -
 @@ -317,17 +317,34 @@ priv_init(char *conf, int numeric, int l
   servname[servname_len - 1] = '\0';
  
   memset(hints, 0, sizeof(hints));
 - if (strcmp(protoname, udp) == 0) {
 + switch (strlen(protoname)) {
 + case 3:
   hints.ai_family = AF_UNSPEC;
 - } else if (strcmp(protoname, udp4) == 0) {
 - hints.ai_family = AF_INET;
 - } else if (strcmp(protoname, udp6) == 0) {
 - hints.ai_family = AF_INET6;
 + break;
 + case 4:
 + switch (protoname[3]) {
 + case '4':
 + hints.ai_family = AF_INET;
 + break;
 + case '6':
 + hints.ai_family = AF_INET6;
 + break;
 + default:
 + errx(1, bad ip version %s, protoname);
 + }
 + break;
 + default:
 + errx(1, bad protocol length %s, protoname);
 + }
 + if (strncmp(protoname, udp, 3) == 0) {
 + hints.ai_socktype = SOCK_DGRAM;
 + hints.ai_protocol = IPPROTO_UDP;
 + } else if (strncmp(protoname, tcp, 3) == 0) {
 + hints.ai_socktype = SOCK_STREAM;
 + hints.ai_protocol = IPPROTO_TCP;
   } else {
   errx(1, unknown protocol %s, protoname);
   }
 - hints.ai_socktype = SOCK_DGRAM;
 - hints.ai_protocol = IPPROTO_UDP;
   i = getaddrinfo(hostname, servname, hints, res0);
   if (i != 0 || res0 == NULL) {
   addr_len = 0;
 Index: syslogd.c
 ===
 RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
 retrieving revision 1.136
 diff -u -p -r1.136 syslogd.c
 --- syslogd.c 10 Dec 2014 19:42:14 -  1.136
 +++ syslogd.c 28 Dec 2014 16:25:55 -
 @@ -50,13 +50,14 @@
   * extensive changes by Ralph Campbell
   * more extensive changes by Eric Allman (again)
   * memory buffer logging by Damien Miller
 - * IPv6, libevent by Alexander Bluhm
 + * IPv6, libevent, sending via TCP by Alexander Bluhm
   */
  
  #define  MAXLINE 1024/* maximum line length */
  #define MIN_MEMBUF   (MAXLINE * 4)   /* Minimum memory buffer size */
  #define MAX_MEMBUF   (256 * 1024)/* Maximum memory buffer size */
  #define MAX_MEMBUF_NAME  64  /* Max length of membuf log 
 name */
 +#define MAX_TCPBUF   (256 * 1024)/* Maximum tcp event buffer size */
  #define  MAXSVLINE   120 /* maximum saved line length */
  #define DEFUPRI  (LOG_USER|LOG_NOTICE)
  #define DEFSPRI  (LOG_KERN|LOG_CRIT)
 @@ -132,6 +133,8 @@ struct filed {
   charf_loghost[1+4+3+1+MAXHOSTNAMELEN+1+NI_MAXSERV];
   /* @proto46://[hostname]:servname\0 */
   struct sockaddr_storage f_addr;
 + struct bufferevent  *f_bufev;
 + int f_fd;
   } f_forw;   /* forwarding address */
   charf_fname[MAXPATHLEN];
   struct {
 @@ -170,16 +173,17 @@ int repeatinterval[] = { 30, 120, 600 };
  #define F_FILE   1   /* regular file */
  #define F_TTY2   /* terminal */
  #define F_CONSOLE3   /* console terminal */
 -#define F_FORW   4   /* remote machine */
 +#define F_FORWUDP4   /* remote machine via UDP */
  #define F_USERS  5   /* list of users */
  #define F_WALL   6   /* everyone logged on */
  #define F_MEMBUF 7   /* memory buffer */
  #define F_PIPE   8   /* pipe 

Re: Typo in Tetris

2014-08-04 Thread Jasper Lievisse Adriaanse
On Sun, Aug 03, 2014 at 02:27:37PM +0100, Sam Hart wrote:
 Absolutely trivial, but none the less ...

It's not a typo if and only if iff was meant.

 --- tetris-orig/shapes.c  2014-08-03 14:12:09.0 +0100
 +++ tetris/shapes.c   2014-08-03 14:12:26.0 +0100
 @@ -76,7 +76,7 @@
  };
  
  /*
 - * Return true iff the given shape fits in the given position,
 + * Return true if the given shape fits in the given position,
   * taking the current board into account.
   */
  int



Re: got me a 16-core octeon donated.

2014-05-15 Thread Jasper Lievisse Adriaanse
On Thu, May 15, 2014 at 11:03:10PM +0200, Mark Kettenis wrote:
  Date: Thu, 15 May 2014 22:04:16 +0200
  From: Janne Johansson icepic...@gmail.com
  
  After some insight from jasper, I stripped away the randomdata section and
  voila:
  
  Copyright (c) 1982, 1986, 1989, 1991, 1993
  The Regents of the University of California.  All rights reserved.
  Copyright (c) 1995-2014 OpenBSD. All rights reserved.
  http://www.OpenBSD.org
  
  OpenBSD 5.5 (RAMDISK) #0: Fri Mar 14 12:10:56 CET 2014
  r...@octeon.office.jasper.la:/usr/src/sys/arch/octeon/compile/RAMDISK
  real mem = 4002201600 (3816MB)
  avail mem = 3970760704 (3786MB)
  warning: no entropy supplied by boot loader
  mainbus0 at root
  cpu0 at mainbus0: Unknown CPU type (0x0) rev 0.3 500 MHz, Software FP
  emulation
  cpu0: cache L1-I 32KB D 16KB 4 way, L2 128KB direct
  clock0 at mainbus0: int 5
  iobus0 at mainbus0
  octcf at iobus0 base 0x1d000800 irq 0 not configured
  pcibus0 at iobus0 irq 0
  pci0 at pcibus0 bus 0
  0:0:0: mem address conflict 0xf800/0x800
  0:2:0: bridge mem address conflict 0x1000/0x10
  vendor Cavium, unknown product 0x0005 (class processor subclass MIPS, rev
  0x03) at pci0 dev 0 function 0 not configured
  Pericom PI7C21P100 PCIX-PCIX rev 0x01 at pci0 dev 2 function 0 not
  configured
 
 Looks like ppb(4) is missing from the kernel config.
It is, I've got a diff to add it along with some devices when I get a chance
to test them on my board.



unbreak ftp progressbar

2014-01-29 Thread Jasper Lievisse Adriaanse
Hi,

At least with ftp -Vm the progressbar was messing up the display as it was
printing the output on the same line and would wrap around creating displays
such as  http://pbot.rmdir.de/gOeAYNv30HnQk-4I4xmKZg
Seems like typo from the introduction of the -D flag.

OK?

Index: util.c
===
RCS file: /cvs/src/usr.bin/ftp/util.c,v
retrieving revision 1.65
diff -u -p -r1.65 util.c
--- util.c  23 Jan 2014 00:39:15 -  1.65
+++ util.c  29 Jan 2014 13:52:07 -
@@ -825,7 +825,7 @@ progressmeter(int flag, const char *file
overhead += 3;
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
-   %-*.*s%s %3d%% , l, l, title,
+   \r%-*.*s%s %3d%% , l, l, title,
dotdot, ratio);
overhead += l + 1;
} else



Re: Allwinner

2013-10-21 Thread Jasper Lievisse Adriaanse
On Fri, Oct 11, 2013 at 11:46:39PM +0300, Artturi Alm wrote:
 On 10/11/13 20:39, Markus Hennecke wrote:
 On Sat, 5 Oct 2013, Artturi Alm wrote:
 
 Current version attached, extract to /sys/arch/armv7 and read the short
 notes file, no more out of allwinner/ patches needed thanks to armv7.
 
 A20 support still needs a workaround under /sys/arch/arm/cortex/ which
 i didn't include as i think support is still 'subtly' broken anyway..
 And ahci is still not working for me, but there's a couple of
 new drivers included.
 Ethernet driver survived make build of userland with /usr/src mounted
 via nfs, fwiw.
 
 Now this is totally usable for me as-is already, so any feedback is
 welcome, be it finding out possible bugs and/or confirming it's working.
 
 Great work! I made a few changes to fix the timer code for the A20 CPU,
 the diff to your code is attached. With this I am almost booting the
 kernel on a cubieboard 2:
 
 Copyright (c) 1982, 1986, 1989, 1991, 1993
  The Regents of the University of California.  All rights reserved.
 Copyright (c) 1995-2013 OpenBSD. All rights reserved.  http://www.OpenBSD.org
 
 OpenBSD 5.4-current (GENERIC-ALLWINNER) #22: Fri Oct 11 19:17:11 CEST 2013
  
  mar...@antigone.markus-hennecke.de:/usr/src/sys/arch/armv7/compile/GENERIC-ALLWINNER
 real mem  = 1073741824 (1024MB)
 avail mem = 1040007168 (991MB)
 mainbus0 at root
 cortex0 at mainbus0
 ampintc0 at cortex0 nirq 160
 cpu0 at mainbus0: ARM Cortex A7 rev 4 (ARMv7 core)
 cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
 cpu0: 32KB(32b/l,2way) I-cache, 32KB(64b/l,4way) wr-back D-cache
 allwinner0 at mainbus0: A20
 awpio0 at allwinner0
 awccmu0 at allwinner0
 awtimer0 at allwinner0: tick rate 32KHz hz 100  stat rate 32KHz stathz 128   
   counter 24000 KHz
 awdog0 at allwinner0
 awrtc0 at allwinner0
 awuart0 at allwinner0: console
 awe0 at allwinner0
 awe0: address 00:00:00:00:00:00
 rlphy0 at awe0 phy 1: RTL8201L 10/100 PHY, rev. 1
 ahci0 at allwinner0 GHC 0x8000AE AHCI 1.1
 ahci0: capabilities 
 0x6726ff80NCQ,SSNTF,SALP,SAL,SCLO,SAM,SPM,PMD,SSC,PSC,CCCS, 1 ports, 32 
 cmds, gen 1 (1.5Gbps) and 2 (3Gbps)
 ahci0: ports implemented: 0x0001
 ahci0.0: port reset
 ahci0: no device detected on port 0
 scsibus0 at ahci0: 32 targets
 ehci0 at allwinner0
 usb0 at ehci0: USB revision 2.0
 uhub0 at usb0 Allwinner EHCI root hub rev 2.00/1.00 addr 1
 ehci1 at allwinner0
 usb1 at ehci1: USB revision 2.0
 uhub1 at usb1 Allwinner EHCI root hub rev 2.00/1.00 addr 1
 gpio0 at awpio0: 18 pins
 gpio1 at awpio0: 24 pins
 gpio2 at awpio0: 25 pins
 gpio3 at awpio0: 28 pins
 gpio4 at awpio0: 12 pins
 gpio5 at awpio0: 6 pins
 gpio6 at awpio0: 12 pins
 gpio7 at awpio0: 28 pins
 gpio8 at awpio0: 22 pins
 /dev/ksyms: Symbol table not valid.
 
 Here the output stops, I will look into that later. At this point I am
 unable to figure out how to set the ethaddr in the u-boot version I am
 using. setenv ethaddr xx:xx:xx:xx:xx:xx doesn't seem to have any effect.
 
 Kind regards
 Markus
 
 
 Hi,
 
 Thanks for the patch, it looks correct when compared to the user manual
 and shows how ugly sources may get when not paid enough attention,
 will fix the whitespaces there also. Note that Cortex-A7 should
 support agtimer found in arch/arm/cortex, which would allow cleaning
 up awtimer.c from the 'added on'-kind of hacks to support A20,
 priorities have kept me from trying that one out so far.
 
 To allow it to boot further you would have to change ICP_ADDR and
 ICD_ADDR in ampintc, iirc. possibly 0x1000 and 0x2000 respectively,
 which is not the fix that would ever get commited even if allwinner
 would be on cvs, as it'll break Cortex-A9, and unfortunately, masking
 by cpu is not working option either, there is example of where it would
 fail already (exynos).
 FDT is the only clean solution i can think of, when there is priority on
 keeping arch/arm/cortex free of SoC-dependent code.
 
 About ethaddr, have you tried pinging another host from u-boot?
 Does your u-boot support emac? the one i initially downloaded for
 cubieboard2 did not iirc., if you can boot the bsd.umg over network,
 and still get 00:00:00:00:00:00, i will power up my cb2 to fix awe,
 as it's so far untested on A20 afaik.
 
 
 -Artturi

I'm going to commit the initial allwinner diff along with Martin's diff
tomorrow unless strong objection is raised.
This needs to be worked on intree instead of letting it rot on the mailinglist. 

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: arch/: unitialized vars

2013-06-28 Thread Jasper Lievisse Adriaanse
On Fri, Jun 28, 2013 at 09:11:13AM +0200, Janne Johansson wrote:
 Now the hard part is to figure out exactly where it should have been
 initialized and to what. Just setting it to 0 somewhere is not necessarily
 better.
It seems the mips64/mips64/cache_tfp.c one is a proper bug. Looking at the
caching routines for the r10k, I'd propose this (untested):

Index: cache_tfp.c
===
RCS file: /cvs/src/sys/arch/mips64/mips64/cache_tfp.c,v
retrieving revision 1.1
diff -p -u -r1.1 cache_tfp.c
--- cache_tfp.c 29 Sep 2012 21:37:03 -  1.1
+++ cache_tfp.c 28 Jun 2013 07:16:38 -
@@ -106,6 +106,7 @@ tfp_SyncCache(struct cpu_info *ci)
 
sr = disableintr();
va = ci-ci_l1datacachesize;
+   eva = va + ci-ci_l1instcacheset;
for (va = 0; va  eva; va += TFP_DCTW_STEP)
tfp_dctw_zero(va);
setsr(sr);

But I reckon Miod would be able to a conclusive answer here.

 2013/6/28 Maxime Villard rusty...@gmx.fr
 
  Hi,
  some other uninitialized vars found by my scanner in arch/.
 
  == hp300/dev/hd.c
  At l.544, 'error' is not initialized.
  == luna88k/luna88k/autoconf.c
  At l.132, 'c' may be uninitialized.
  == mips64/mips64/cache_tfp.c
  At l.109, 'eva' is not initialized.
  == sparc/dev/zs.c
  At l.513, 'tmp' may be uninitialized.
  == sparc64/dev/vdsp.c
  At l.384, 'err' may be uninitialized. This variable should
  be the return value of hv_ldc_tx_get_state(), see l.417.
  == zaurus/dev/vdsp.c
  At l.897, 'parity' is not initialized.
 
 
 
 
 -- 
 May the most significant bit of your life be positive.

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: mg(1): shell-command

2013-05-22 Thread Jasper Lievisse Adriaanse
);
 +
 + argv[2] = cmd;
 +
 + len = strlen(cmd);
 +
 + if ((text = malloc(len + 1)) == NULL) {
 + ewprintf(Cannot allocate memory.);
 + return (FALSE);
 + }
 +
 + return shellcmdoutput(argv, NULL, 0);
 +}
 +
 +
 +int
 +shellcmdoutput(char* const argv[], char* const text, int len)
 +{
 +
 + struct buffer *bp;
 + char*shellp;
 + int  ret;
 +
   bp = bfind(*Shell Command Output*, TRUE);
   bp-b_flag |= BFREADONLY;
   if (bclear(bp) != TRUE) {
 @@ -443,7 +488,6 @@ piperegion(int f, int n)
   return (FALSE);
   }
  
 - region_get_data(region, text, len);
   shellp = getenv(SHELL);
  
   ret = pipeio(shellp, argv, text, len, bp);
 

-- 
Regards,

Jasper Lievisse Adriaanse,
Engineering team M:tier



Re: mg(1): shell-command

2013-05-22 Thread Jasper Lievisse Adriaanse
On Wed, May 22, 2013 at 07:42:42AM +, Mark Lumsden wrote:
 To make the shell-command-on-region and this command behave
 like that requires another diff.
 
 mark
I'm fine with this diff going in first and polishing it intree, it works fine
for commands with  1 line of output.
 
 On Wed, May 22, 2013 at 09:32:45AM +0200, Jasper Lievisse Adriaanse wrote:
  On Tue, May 21, 2013 at 07:54:31PM +, Mark Lumsden wrote:
   This diff modifies the shell-command-on-region function and gives us
   shell-command. It makes getting output from other commands into mg
   really easy. Comments/oks?
   
   -lum
  
  It seems Emacs doesn't split the window if the output from the command is 
  only
  a single line (like 'date'), which is behaviour I quite like if you want to
  check something small.
  
   Index: def.h
   ===
   RCS file: /cvs/src/usr.bin/mg/def.h,v
   retrieving revision 1.135
   diff -u -p -r1.135 def.h
   --- def.h 25 Mar 2013 11:41:44 -  1.135
   +++ def.h 21 May 2013 19:46:38 -
   @@ -592,6 +592,7 @@ intregion_get_data(struct region *, c
void  region_put_data(const char *, int);
int   markbuffer(int, int);
int   piperegion(int, int);
   +int   shellcommand(int, int);
int   pipeio(const char * const, char * const[], char * 
   const, int,
  struct buffer *);

   Index: funmap.c
   ===
   RCS file: /cvs/src/usr.bin/mg/funmap.c,v
   retrieving revision 1.45
   diff -u -p -r1.45 funmap.c
   --- funmap.c  27 Dec 2012 18:51:52 -  1.45
   +++ funmap.c  21 May 2013 19:46:38 -
   @@ -179,6 +179,7 @@ static struct funmap functnames[] = {
 {setfillcol, set-fill-column,},
 {setmark, set-mark-command,},
 {setprefix, set-prefix-string,},
   + {shellcommand, shell-command,},
 {piperegion, shell-command-on-region,},
 {shrinkwind, shrink-window,},
#ifdef NOTAB
   Index: keymap.c
   ===
   RCS file: /cvs/src/usr.bin/mg/keymap.c,v
   retrieving revision 1.50
   diff -u -p -r1.50 keymap.c
   --- keymap.c  7 Jun 2012 15:15:04 -   1.50
   +++ keymap.c  21 May 2013 19:46:38 -
   @@ -217,8 +217,9 @@ static PF metacV[] = {
 pagenext/* ^V */
};

   -static PF metasp[] = {
   - justone /* space */
   +static PF metaspex[] = {
   + justone,/* space */
   + shellcommand/* ! */
};

static PF metapct[] = {
   @@ -317,7 +318,7 @@ struct KEYMAPE (8 + IMAPEXT) metamap = {
 CCHR('V'), CCHR('V'), metacV, NULL
 },
 {
   - ' ', ' ', metasp, NULL
   + ' ', '!', metaspex, NULL
 },
 {
 '%', '%', metapct, NULL
   Index: mg.1
   ===
   RCS file: /cvs/src/usr.bin/mg/mg.1,v
   retrieving revision 1.75
   diff -u -p -r1.75 mg.1
   --- mg.1  28 Dec 2012 16:12:50 -  1.75
   +++ mg.1  21 May 2013 19:46:38 -
   @@ -268,6 +268,8 @@ suspend-emacs
scroll-other-window
.It M-SPC
just-one-space
   +.It M-!
   +shell-command
.It M-.
find-tag
.It M-*
   @@ -835,6 +837,8 @@ Used by auto-fill-mode.
Sets the mark in the current window to the current dot location.
.It set-prefix-string
Sets the prefix string to be used by the 'prefix-region' command.
   +.It shell-command
   +Execute external command from mini-buffer.
.It shell-command-on-region
Provide the text in region to the shell command as input.
.It shrink-window
   Index: region.c
   ===
   RCS file: /cvs/src/usr.bin/mg/region.c,v
   retrieving revision 1.32
   diff -u -p -r1.32 region.c
   --- region.c  27 Dec 2012 18:49:59 -  1.32
   +++ region.c  21 May 2013 19:46:38 -
   @@ -28,6 +28,7 @@ static  int iomux(int, char * const, int,
static   int preadin(int, struct buffer *);
static   voidpwriteout(int, char **, int *);
static   int setsize(struct region *, RSIZE);
   +static   int shellcmdoutput(char * const[], char * const, int);

/*
 * Kill the region.  Ask getregion to figure out the bounds of the 
   region.
   @@ -406,9 +407,8 @@ int
piperegion(int f, int n)
{
 struct region region;
   - struct buffer *bp;
   - int len, ret;
   - char *cmd, cmdbuf[NFILEN], *shellp, *text;
   + int len;
   + char *cmd, cmdbuf[NFILEN], *text;
 char *argv[] = {sh, -c, (char *) NULL, (char *) NULL};

 /* C-u M-| is not supported yet */
   @@ -436,6 +436,51 @@ piperegion(int f, int n)
 return (FALSE);
 }

   + region_get_data(region, text, len

Re: drm@macppc, please test

2012-12-07 Thread Jasper Lievisse Adriaanse
On Fri, Dec 07, 2012 at 05:28:42AM +0100, J??r??mie Courr??ges-Anglas wrote:
 Hi,
 
 this is seems to work as expected, known issues included.
 glxgears runs OK but displays some artifacts, and the console is full of
 garbage after exiting X.
 
 I've put the dmesg, Xorg.0.log, etc here:
 
 http://autogeree.net/~jca/tmp/g4-drm/
 
 Thanks a lot, it's quite nice to have DRI. :)
 
 -- 
 J??r??mie Courr??ges-Anglas
 GPG Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494
Nice, I now get  750 FPS on my iBook g4:

memc0 at mainbus0: uni-n rev 0xd2
vgafb0 at pci0 dev 16 function 0 ATI Radeon Mobility 9550 rev 0x80, mmio

GL_RENDERER   = Mesa DRI R300 (RV350 4E56) AGP 4x  TCL

Though I'm observing the same artifcats as Jeremie is getting.
Still, great work Martin! 

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



mg: column-number-mode

2012-12-03 Thread Jasper Lievisse Adriaanse
Hi,

Some weeks ago the column number display was removed from the modeline; while
it's totally understandable this is a horror on slower displays, it's still
usefull on faster displays.

mg has a line-number-mode, but not a column-number-mode like Emacs has. This
diff adds the column-number-mode, and thus partly reverting the previous change.
Column numbers are still disabled by default.

I've also removed the unconditional LINENOMODE define which is unused elsewhere,
but the linenos handling could use some more cleanup; which is for a later diff.

OK?

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.131
diff -p -u -r1.131 def.h
--- def.h   27 Nov 2012 19:46:46 -  1.131
+++ def.h   3 Dec 2012 10:53:14 -
@@ -424,6 +424,7 @@ voidvtinit(void);
 void   vttidy(void);
 void   update(void);
 intlinenotoggle(int, int);
+intcolnotoggle(int, int);
 
 /* echo.c X */
 voideerase(void);
Index: display.c
===
RCS file: /cvs/src/usr.bin/mg/display.c,v
retrieving revision 1.38
diff -p -u -r1.38 display.c
--- display.c   11 Nov 2012 20:40:49 -  1.38
+++ display.c   3 Dec 2012 10:53:14 -
@@ -101,10 +101,8 @@ struct video blanks;   /* Blank line im
  */
 struct score *score;   /* [NROW * NROW] */
 
-#ifndef LINENOMODE
-#define LINENOMODE TRUE
-#endif /* !LINENOMODE */
-static int  linenos = LINENOMODE;
+static int  linenos = TRUE;
+static int  colnos  = FALSE;
 
 /* Is macro recording enabled? */
 extern int macrodef;
@@ -129,6 +127,19 @@ linenotoggle(int f, int n)
return (TRUE);
 }
 
+int
+colnotoggle(int f, int n)
+{
+   if (f  FFARG)
+   colnos = n  0;
+   else
+   colnos = !colnos;
+
+   sgarbf = TRUE;
+
+   return (TRUE);
+}
+
 /*
  * Reinit the display data structures, this is called when the terminal
  * size changes.
@@ -835,7 +846,12 @@ modeline(struct mgwin *wp)
++n;
 
if (linenos) {
-   len = snprintf(sl, sizeof(sl), --L%d, wp-w_dotline);
+   if (colnos)
+   len = snprintf(sl, sizeof(sl), --L%d--C%d, 
wp-w_dotline,
+   getcolpos());
+   else
+   len = snprintf(sl, sizeof(sl), --L%d, wp-w_dotline);
+
if (len  sizeof(sl)  len != -1)
n += vtputs(sl);
}
Index: funmap.c
===
RCS file: /cvs/src/usr.bin/mg/funmap.c,v
retrieving revision 1.43
diff -p -u -r1.43 funmap.c
--- funmap.c27 Nov 2012 19:46:46 -  1.43
+++ funmap.c3 Dec 2012 10:53:14 -
@@ -40,6 +40,7 @@ static struct funmap functnames[] = {
{capword, capitalize-word,},
{changedir, cd,},
{clearmark, clear-mark,},
+   {colnotoggle, column-number-mode,},
{copyregion, copy-region-as-kill,},
 #ifdef REGEX
{cntmatchlines, count-matches,},
Index: mg.1
===
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.72
diff -p -u -r1.72 mg.1
--- mg.127 Nov 2012 19:46:46 -  1.72
+++ mg.13 Dec 2012 10:53:14 -
@@ -414,6 +414,8 @@ upper case, and subsequent letters to lo
 .It cd
 Change the global working directory.
 See also global-wd-mode.
+.It column-number-mode
+Show the current column number in the mode line.
 .It copy-region-as-kill
 Copy all of the characters in the region to the kill buffer,
 clearing the mark afterwards.

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



mg: make-directory

2012-11-15 Thread Jasper Lievisse Adriaanse
Hi,

One of the things lacking in mg was support M-x make-directory, which comes
quite handy. This diff mimics the rather silent behaviour of Emacs: there's
basically no feedback in case creating the directory failed for whatever
reason. Should we be more verbose about it, or just stay in line with Emacs?

diff --git def.h def.h
index 6a752d5..11e3c24 100644
--- def.h
+++ def.h
@@ -335,6 +335,7 @@ void dirinit(void);
 int changedir(int, int);
 int showcwdir(int, int);
 int getcwdir(char *, size_t);
+int makedir(int, int);
 
 /* dired.c */
 struct buffer  *dired_(char *);
diff --git dir.c dir.c
index 2352773..18eb946 100644
--- dir.c
+++ dir.c
@@ -9,6 +9,8 @@
  * Modified for MG 2a by Mic Kaczmarczik 03-Aug-1987
  */
 
+#include sys/stat.h
+
 #include def.h
 
 static char mgcwd[NFILEN];
@@ -75,3 +77,62 @@ getcwdir(char *buf, size_t len)
 
return (TRUE);
 }
+
+/* Create the directory and it's parents. */
+/* ARGSUSED */
+int
+makedir(int f, int n)
+{
+   struct stat  sb;
+   int  finished, ishere;
+   mode_t   dir_mode, mode, oumask;
+   char bufc[NFILEN], *path, *slash;
+
+   (void)strlcpy(bufc, curbp-b_cwd, sizeof(bufc));
+   if ((path = eread(Make directory: , bufc, NFILEN,
+   EFDEF | EFNEW | EFCR | EFFILE)) == NULL)
+   return (ABORT);
+   else if (path[0] == '\0')
+   return (FALSE);
+
+   slash = path;
+   oumask = umask(0);
+   mode = 0777  ~oumask;
+   dir_mode = mode | S_IWUSR | S_IXUSR;
+
+   for (;;) {
+   slash += strspn(slash, /);
+   slash += strcspn(slash, /);
+
+   finished = (*slash == '\0');
+   *slash = '\0';
+
+   ishere = !stat(path, sb);
+   if (!finished  ishere  S_ISDIR(sb.st_mode)) {
+   *slash = '/';
+   continue;
+   }
+
+   if (mkdir(path, finished ? mode : dir_mode) == 0) {
+   if (mode  0777  chmod(path, mode)  0) {
+   umask(oumask);
+   return (ABORT);
+   }
+   } else {
+   if (!ishere || !S_ISDIR(sb.st_mode)) {
+   eerase();
+   umask(oumask);
+   return (ABORT);
+   }
+   }
+
+   if (finished)
+   break;
+
+   *slash = '/';
+   }
+
+   eerase();
+   umask(oumask);
+   return (TRUE);
+}
diff --git file.c file.c
index 8c1297b..2717931 100644
--- file.c
+++ file.c
@@ -258,13 +258,14 @@ readin(char *fname)
dp = dirname(fname);
if (stat(dp, statbuf) == -1  errno == ENOENT) {
/* no read-only; like emacs */
-   ewprintf(Parent directory missing);
+   ewprintf(Use M-x make-directory RET RET to 
+   create the directory and it's parents);
} else if (access(dp, W_OK) == -1  
errno == EACCES) {
ewprintf(File not found and directory
 write-protected);
ro = TRUE;
-   } 
+   }
}
}
if (ro == TRUE)
diff --git funmap.c funmap.c
index 66dd414..9a1be39 100644
--- funmap.c
+++ funmap.c
@@ -198,6 +198,7 @@ static struct funmap functnames[] = {
{csprevfile, cscope-prev-file,},
{cscreatelist, cscope-create-list-of-files-to-index,},
{revertbuffer, revert-buffer,},
+   {makedir, make-directory,},
{NULL, NULL,}
 };
 
diff --git mg.1 mg.1
index 42411c6..3d46675 100644
--- mg.1
+++ mg.1
@@ -662,6 +662,8 @@ Bind a key mapping in the local (topmost) mode.
 Unbind a key mapping in the local (topmost) mode.
 .It make-backup-files
 Toggle generation of backup files.
+.It make-directory
+Prompt the user for a path or directory name which is then created.
 .It mark-whole-buffer
 Marks whole buffer as a region by putting dot at the beginning and mark
 at the end of buffer.


-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



glib threading issues

2012-10-19 Thread Jasper Lievisse Adriaanse
Hi,

As some of you may be aware we're having a lot of issues in the glib port
related to threading. And it seems it's now affecting non-GNOME ports as well.
irssi just crashed on sparc64:

(gdb) bt
#0  0x0003781ec820 in ?? () from /usr/lib/libpthread.so.17.0
#1  0x000377ee700c in _thread_tag_init (tag=0xfffd2511) at 
/usr/src/lib/librthread/rthread_libc.c:46
#2  0x00037e15b404 in g_main_context_iteration () from 
/usr/local/lib/libglib-2.0.so.3400.0
#3  0x00037e15b4b0 in g_main_context_iteration () from 
/usr/local/lib/libglib-2.0.so.3400.0
#4  0x000173864ac4 in main () from /usr/local/bin/irssi
(gdb) 

I'll rebuild irssi and glib with debugging symbols in order to get a better
backtrace...but it seems the issues are far more reaching than we initially 
feared.

It would be great if someone could help robert/ajacoutot/me in tracking down
these issues.

Thanks,
Jasper



mg: revert-buffer

2012-10-12 Thread Jasper Lievisse Adriaanse
Hi,

Here's a diff that implement revert-buffer (C-x r). I've split gotoline into
the 'goto-line' specifics and the code that actually jumps to the line so it
can be re-used by revert-buffer to restore the current line.

OK?

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish

Index: basic.c
===
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.37
diff -p -u -r1.37 basic.c
--- basic.c 18 Jun 2012 09:26:03 -  1.37
+++ basic.c 12 Oct 2012 10:25:14 -
@@ -485,7 +485,6 @@ swapmark(int f, int n)
 int
 gotoline(int f, int n)
 {
-   struct line  *clp;
char   buf[32], *bufp;
const char *err;
 
@@ -501,6 +500,16 @@ gotoline(int f, int n)
return (FALSE);
}
}
+   return(setlineno(n));
+}
+
+/*
+ * Set the line number and switch to it.
+ */
+int
+setlineno(int n){
+   struct line  *clp;
+
if (n = 0) {
if (n == 0)
n++;
Index: buffer.c
===
RCS file: /cvs/src/usr.bin/mg/buffer.c,v
retrieving revision 1.81
diff -p -u -r1.81 buffer.c
--- buffer.c31 Aug 2012 18:06:42 -  1.81
+++ buffer.c12 Oct 2012 10:25:14 -
@@ -861,4 +861,35 @@ checkdirty(struct buffer *bp)
 
return (TRUE);
 }
-   
+
+/*
+ * Revert the current buffer to whatever is on disk.
+ */
+/* ARGSUSED */
+int
+revertbuffer(int f, int n){
+   struct mgwin *wp = wheadp;
+   struct buffer *bp = wp-w_bufp;
+   char fbuf[NFILEN + 32];
+   int lineno;
+
+   if (!strlen(bp-b_fname)) {
+   ewprintf(Cannot revert buffer not associated with any files.);
+   return (FALSE);
+   }
+
+   snprintf(fbuf, sizeof(fbuf), Revert buffer from file %s, bp-b_fname);
+
+   if (eyorn(fbuf)) {
+   /* Save our current line, so we can go back it after reloading 
the file. */
+   lineno = wp-w_dotline;
+   if (readin(bp-b_list.l_name)) {
+   return(setlineno(lineno));
+   } else {
+   ewprintf(File %s no longer readable!, bp-b_fname);
+   return (FALSE);
+   }
+   }
+
+   return (FALSE);
+}
Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.125
diff -p -u -r1.125 def.h
--- def.h   31 Aug 2012 18:06:42 -  1.125
+++ def.h   12 Oct 2012 10:25:14 -
@@ -414,6 +414,7 @@ int  notmodified(int, int);
 int popbuftop(struct buffer *, int);
 int getbufcwd(char *, size_t);
 int checkdirty(struct buffer *);
+int revertbuffer(int, int);
 
 /* display.c */
 intvtresize(int, int, int);
@@ -494,6 +495,7 @@ int  setmark(int, int);
 int clearmark(int, int);
 int swapmark(int, int);
 int gotoline(int, int);
+int setlineno(int);
 
 /* random.c X */
 int showcpos(int, int);
Index: funmap.c
===
RCS file: /cvs/src/usr.bin/mg/funmap.c,v
retrieving revision 1.40
diff -p -u -r1.40 funmap.c
--- funmap.c14 Jun 2012 17:21:22 -  1.40
+++ funmap.c12 Oct 2012 10:25:15 -
@@ -196,7 +196,8 @@ static struct funmap functnames[] = {
{csprevmatch, cscope-prev-symbol,},
{csnextfile, cscope-next-file,},
{csprevfile, cscope-prev-file,},
-   {cscreatelist, cscope-create-list-of-files-to-index},
+   {cscreatelist, cscope-create-list-of-files-to-index,},
+   {revertbuffer, revert-buffer,},
{NULL, NULL,}
 };
 
Index: keymap.c
===
RCS file: /cvs/src/usr.bin/mg/keymap.c,v
retrieving revision 1.50
diff -p -u -r1.50 keymap.c
--- keymap.c7 Jun 2012 15:15:04 -   1.50
+++ keymap.c12 Oct 2012 10:25:15 -
@@ -177,7 +177,7 @@ static PF cXcar[] = {
nextwind,   /* o */
prevwind,   /* p */
rescan, /* q */
-   rescan, /* r */
+   revertbuffer,   /* r */
savebuffers,/* s */
rescan, /* t */
undo/* u */
Index: mg.1
===
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.68
diff -p -u -r1.68 mg.1
--- mg.111 Jul 2012 19:56:13 -  1.68
+++ mg.112 Oct 2012 10:25:15 -
@@ -249,6 +249,8 @@ other-window
 other-window
 .It C-x p
 previous-window
+.It C-x r
+revert-buffer
 .It C-x s
 save-some-buffers
 .It C-x u
@@ -752,6 +754,8 @@ is negative, it is that line from the bo
 .It redraw-display
 Refresh the display.
 Recomputes all window sizes in case something has changed.

Re: mg: revert-buffer

2012-10-12 Thread Jasper Lievisse Adriaanse
Seems I broke something between testing and sending out the diff. Updating
diff coming later.

On Fri, Oct 12, 2012 at 12:40:47PM +0200, Christiano F. Haesbaert wrote:
 I want this baadlyyy, ill have a look.
 On Oct 12, 2012 12:30 PM, Jasper Lievisse Adriaanse jas...@openbsd.org
 wrote:
 
  Hi,
 
  Here's a diff that implement revert-buffer (C-x r). I've split gotoline
  into
  the 'goto-line' specifics and the code that actually jumps to the line so
  it
  can be re-used by revert-buffer to restore the current line.
 
  OK?
 
  --
  Cheers,
  Jasper
 
  Stay Hungry. Stay Foolish
 
  Index: basic.c
  ===
  RCS file: /cvs/src/usr.bin/mg/basic.c,v
  retrieving revision 1.37
  diff -p -u -r1.37 basic.c
  --- basic.c 18 Jun 2012 09:26:03 -  1.37
  +++ basic.c 12 Oct 2012 10:25:14 -
  @@ -485,7 +485,6 @@ swapmark(int f, int n)
   int
   gotoline(int f, int n)
   {
  -   struct line  *clp;
  char   buf[32], *bufp;
  const char *err;
 
  @@ -501,6 +500,16 @@ gotoline(int f, int n)
  return (FALSE);
  }
  }
  +   return(setlineno(n));
  +}
  +
  +/*
  + * Set the line number and switch to it.
  + */
  +int
  +setlineno(int n){
  +   struct line  *clp;
  +
  if (n = 0) {
  if (n == 0)
  n++;
  Index: buffer.c
  ===
  RCS file: /cvs/src/usr.bin/mg/buffer.c,v
  retrieving revision 1.81
  diff -p -u -r1.81 buffer.c
  --- buffer.c31 Aug 2012 18:06:42 -  1.81
  +++ buffer.c12 Oct 2012 10:25:14 -
  @@ -861,4 +861,35 @@ checkdirty(struct buffer *bp)
 
  return (TRUE);
   }
  -
  +
  +/*
  + * Revert the current buffer to whatever is on disk.
  + */
  +/* ARGSUSED */
  +int
  +revertbuffer(int f, int n){
  +   struct mgwin *wp = wheadp;
  +   struct buffer *bp = wp-w_bufp;
  +   char fbuf[NFILEN + 32];
  +   int lineno;
  +
  +   if (!strlen(bp-b_fname)) {
  +   ewprintf(Cannot revert buffer not associated with any
  files.);
  +   return (FALSE);
  +   }
  +
  +   snprintf(fbuf, sizeof(fbuf), Revert buffer from file %s,
  bp-b_fname);
  +
  +   if (eyorn(fbuf)) {
  +   /* Save our current line, so we can go back it after
  reloading the file. */
  +   lineno = wp-w_dotline;
  +   if (readin(bp-b_list.l_name)) {
  +   return(setlineno(lineno));
  +   } else {
  +   ewprintf(File %s no longer readable!,
  bp-b_fname);
  +   return (FALSE);
  +   }
  +   }
  +
  +   return (FALSE);
  +}
  Index: def.h
  ===
  RCS file: /cvs/src/usr.bin/mg/def.h,v
  retrieving revision 1.125
  diff -p -u -r1.125 def.h
  --- def.h   31 Aug 2012 18:06:42 -  1.125
  +++ def.h   12 Oct 2012 10:25:14 -
  @@ -414,6 +414,7 @@ int  notmodified(int, int);
   int popbuftop(struct buffer *, int);
   int getbufcwd(char *, size_t);
   int checkdirty(struct buffer *);
  +int revertbuffer(int, int);
 
   /* display.c */
   intvtresize(int, int, int);
  @@ -494,6 +495,7 @@ int  setmark(int, int);
   int clearmark(int, int);
   int swapmark(int, int);
   int gotoline(int, int);
  +int setlineno(int);
 
   /* random.c X */
   int showcpos(int, int);
  Index: funmap.c
  ===
  RCS file: /cvs/src/usr.bin/mg/funmap.c,v
  retrieving revision 1.40
  diff -p -u -r1.40 funmap.c
  --- funmap.c14 Jun 2012 17:21:22 -  1.40
  +++ funmap.c12 Oct 2012 10:25:15 -
  @@ -196,7 +196,8 @@ static struct funmap functnames[] = {
  {csprevmatch, cscope-prev-symbol,},
  {csnextfile, cscope-next-file,},
  {csprevfile, cscope-prev-file,},
  -   {cscreatelist, cscope-create-list-of-files-to-index},
  +   {cscreatelist, cscope-create-list-of-files-to-index,},
  +   {revertbuffer, revert-buffer,},
  {NULL, NULL,}
   };
 
  Index: keymap.c
  ===
  RCS file: /cvs/src/usr.bin/mg/keymap.c,v
  retrieving revision 1.50
  diff -p -u -r1.50 keymap.c
  --- keymap.c7 Jun 2012 15:15:04 -   1.50
  +++ keymap.c12 Oct 2012 10:25:15 -
  @@ -177,7 +177,7 @@ static PF cXcar[] = {
  nextwind,   /* o */
  prevwind,   /* p */
  rescan, /* q */
  -   rescan, /* r */
  +   revertbuffer,   /* r */
  savebuffers,/* s */
  rescan, /* t */
  undo

Re: mg: revert-buffer

2012-10-12 Thread Jasper Lievisse Adriaanse
, 2012 at 12:26:53PM +0200, Jasper Lievisse Adriaanse wrote:
 Hi,
 
 Here's a diff that implement revert-buffer (C-x r). I've split gotoline into
 the 'goto-line' specifics and the code that actually jumps to the line so it
 can be re-used by revert-buffer to restore the current line.
 
 OK?
 
 -- 
 Cheers,
 Jasper
 
 Stay Hungry. Stay Foolish
 
 Index: basic.c
 ===
 RCS file: /cvs/src/usr.bin/mg/basic.c,v
 retrieving revision 1.37
 diff -p -u -r1.37 basic.c
 --- basic.c   18 Jun 2012 09:26:03 -  1.37
 +++ basic.c   12 Oct 2012 10:25:14 -
 @@ -485,7 +485,6 @@ swapmark(int f, int n)
  int
  gotoline(int f, int n)
  {
 - struct line  *clp;
   char   buf[32], *bufp;
   const char *err;
  
 @@ -501,6 +500,16 @@ gotoline(int f, int n)
   return (FALSE);
   }
   }
 + return(setlineno(n));
 +}
 +
 +/*
 + * Set the line number and switch to it.
 + */
 +int
 +setlineno(int n){
 + struct line  *clp;
 +
   if (n = 0) {
   if (n == 0)
   n++;
 Index: buffer.c
 ===
 RCS file: /cvs/src/usr.bin/mg/buffer.c,v
 retrieving revision 1.81
 diff -p -u -r1.81 buffer.c
 --- buffer.c  31 Aug 2012 18:06:42 -  1.81
 +++ buffer.c  12 Oct 2012 10:25:14 -
 @@ -861,4 +861,35 @@ checkdirty(struct buffer *bp)
  
   return (TRUE);
  }
 - 
 +
 +/*
 + * Revert the current buffer to whatever is on disk.
 + */
 +/* ARGSUSED */
 +int
 +revertbuffer(int f, int n){
 + struct mgwin *wp = wheadp;
 + struct buffer *bp = wp-w_bufp;
 + char fbuf[NFILEN + 32];
 + int lineno;
 +
 + if (!strlen(bp-b_fname)) {
 + ewprintf(Cannot revert buffer not associated with any files.);
 + return (FALSE);
 + }
 +
 + snprintf(fbuf, sizeof(fbuf), Revert buffer from file %s, bp-b_fname);
 +
 + if (eyorn(fbuf)) {
 + /* Save our current line, so we can go back it after reloading 
 the file. */
 + lineno = wp-w_dotline;
 + if (readin(bp-b_list.l_name)) {
 + return(setlineno(lineno));
 + } else {
 + ewprintf(File %s no longer readable!, bp-b_fname);
 + return (FALSE);
 + }
 + }
 +
 + return (FALSE);
 +}
 Index: def.h
 ===
 RCS file: /cvs/src/usr.bin/mg/def.h,v
 retrieving revision 1.125
 diff -p -u -r1.125 def.h
 --- def.h 31 Aug 2012 18:06:42 -  1.125
 +++ def.h 12 Oct 2012 10:25:14 -
 @@ -414,6 +414,7 @@ intnotmodified(int, int);
  int   popbuftop(struct buffer *, int);
  int   getbufcwd(char *, size_t);
  int   checkdirty(struct buffer *);
 +int   revertbuffer(int, int);
  
  /* display.c */
  int  vtresize(int, int, int);
 @@ -494,6 +495,7 @@ intsetmark(int, int);
  int   clearmark(int, int);
  int   swapmark(int, int);
  int   gotoline(int, int);
 +int   setlineno(int);
  
  /* random.c X */
  int   showcpos(int, int);
 Index: funmap.c
 ===
 RCS file: /cvs/src/usr.bin/mg/funmap.c,v
 retrieving revision 1.40
 diff -p -u -r1.40 funmap.c
 --- funmap.c  14 Jun 2012 17:21:22 -  1.40
 +++ funmap.c  12 Oct 2012 10:25:15 -
 @@ -196,7 +196,8 @@ static struct funmap functnames[] = {
   {csprevmatch, cscope-prev-symbol,},
   {csnextfile, cscope-next-file,},
   {csprevfile, cscope-prev-file,},
 - {cscreatelist, cscope-create-list-of-files-to-index},
 + {cscreatelist, cscope-create-list-of-files-to-index,},
 + {revertbuffer, revert-buffer,},
   {NULL, NULL,}
  };
  
 Index: keymap.c
 ===
 RCS file: /cvs/src/usr.bin/mg/keymap.c,v
 retrieving revision 1.50
 diff -p -u -r1.50 keymap.c
 --- keymap.c  7 Jun 2012 15:15:04 -   1.50
 +++ keymap.c  12 Oct 2012 10:25:15 -
 @@ -177,7 +177,7 @@ static PF cXcar[] = {
   nextwind,   /* o */
   prevwind,   /* p */
   rescan, /* q */
 - rescan, /* r */
 + revertbuffer,   /* r */
   savebuffers,/* s */
   rescan, /* t */
   undo/* u */
 Index: mg.1
 ===
 RCS file: /cvs/src/usr.bin/mg/mg.1,v
 retrieving revision 1.68
 diff -p -u -r1.68 mg.1
 --- mg.1  11 Jul 2012 19:56:13 -  1.68
 +++ mg.1  12 Oct 2012 10:25:15 -
 @@ -249,6 +249,8 @@ other-window
  other-window
  .It C-x p
  previous-window
 +.It C-x r
 +revert-buffer
  .It C-x s
  save-some-buffers
  .It C-x u
 @@ -752,6 +754,8 @@ is negative, it is that line from the bo

make mg statusline a bit more informative

2012-10-10 Thread Jasper Lievisse Adriaanse
Currently the statusline in mg shows the line and column numbers, which is
nice but doesn't let you know your relative position in the file.

Emacs shows 'top', 'bot', 'all' or your relative position like '42%'. This
diff implements that behaviour in mg too.

From:
 (fundamental-fill)--L3--C31
to:
 (fundamental-fill)--9%--L69--C0
 or
 (fundamental-fill)--all--L1--C0

you get the idea.

Index: display.c
===
RCS file: /cvs/src/usr.bin/mg/display.c,v
retrieving revision 1.37
diff -p -u -r1.37 display.c
--- display.c   4 Jun 2009 02:23:37 -   1.37
+++ display.c   10 Oct 2012 11:56:51 -
@@ -835,8 +835,21 @@ modeline(struct mgwin *wp)
++n;
 
if (linenos) {
-   len = snprintf(sl, sizeof(sl), --L%d--C%d, wp-w_dotline,
-   getcolpos());
+   char location[4], r_location[4];
+
+   if (bp-b_lines = wp-w_ntrows) {
+   strlcpy(location, all, sizeof(location));
+   } else if (wp-w_dotline = wp-w_ntrows) {
+   strlcpy(location, top, sizeof(location));
+   } else if (wp-w_dotline = (bp-b_lines - wp-w_ntrows)) {
+   strlcpy(location, bot, sizeof(location));
+   } else {
+   snprintf(r_location, sizeof(r_location), %d%%, (100 * 
wp-w_dotline) / bp-b_lines);
+   strlcpy(location, r_location, sizeof(location));
+   }
+
+   len = snprintf(sl, sizeof(sl), --%s--L%d--C%d,
+  location, wp-w_dotline, getcolpos());
if (len  sizeof(sl)  len != -1)
n += vtputs(sl);
}


-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: make mg statusline a bit more informative

2012-10-10 Thread Jasper Lievisse Adriaanse
On Wed, Oct 10, 2012 at 03:31:30PM +0200, Mark Kettenis wrote:
  Date: Wed, 10 Oct 2012 15:12:59 +0200
  From: Jasper Lievisse Adriaanse jas...@openbsd.org
  
  Currently the statusline in mg shows the line and column numbers, which is
  nice but doesn't let you know your relative position in the file.
  
  Emacs shows 'top', 'bot', 'all' or your relative position like '42%'. This
  diff implements that behaviour in mg too.
 
 Emacs uses 'Top', 'Bot' and 'All' and:
 
  From:
   (fundamental-fill)--L3--C31
  to:
   (fundamental-fill)--9%--L69--C0
  --L69--C0--9%--
 
   or
   (fundamental-fill)--all--L1--C0
 
  --L1--C0--All--
Sure, let's go all the way then :)

Index: display.c
===
RCS file: /cvs/src/usr.bin/mg/display.c,v
retrieving revision 1.37
diff -p -u -r1.37 display.c
--- display.c   4 Jun 2009 02:23:37 -   1.37
+++ display.c   10 Oct 2012 13:39:00 -
@@ -835,8 +835,21 @@ modeline(struct mgwin *wp)
++n;
 
if (linenos) {
-   len = snprintf(sl, sizeof(sl), --L%d--C%d, wp-w_dotline,
-   getcolpos());
+   char location[4], r_location[4];
+
+   if (bp-b_lines = wp-w_ntrows) {
+   strlcpy(location, All, sizeof(location));
+   } else if (wp-w_dotline = wp-w_ntrows) {
+   strlcpy(location, Top, sizeof(location));
+   } else if (wp-w_dotline = (bp-b_lines - wp-w_ntrows)) {
+   strlcpy(location, Bot, sizeof(location));
+   } else {
+   snprintf(r_location, sizeof(r_location), %d%%, (100 * 
wp-w_dotline) / bp-b_lines);
+   strlcpy(location, r_location, sizeof(location));
+   }
+
+   len = snprintf(sl, sizeof(sl), --L%d--C%d--%s,
+  wp-w_dotline, getcolpos(), location);
if (len  sizeof(sl)  len != -1)
n += vtputs(sl);
}


-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: Diff to support so-called gaming USB keyboards

2012-07-05 Thread Jasper Lievisse Adriaanse
On Tue, Jul 03, 2012 at 03:23:16PM -0700, Mike Larkin wrote:
 Many low-cost USB keyboards have a limit of either 3 or 6 simultaneous
 keypresses before they wedge and stop supplying any more keypress events
 (at least until you release one of the pressed keys).
 
 Some newer (usually called gaming) keyboards use a different way of
 reporting keypress events in order to support an arbitrary number of
 simultaneous keypresses (likely under the assumption that in certain
 games, you might need more than 3 or 6 keys pressed at the same time).
 
 Our USB HID keyboard code had some bad assumptions in it - namely, that
 every key reported in this fashion was a 'modifier' key like shift,
 alt, or control, and that there would only be 8 such keys maximum.
 
 The diff below reworks the HID keyboard code a bit to remove these
 assumptions and support these newer style USB keyboards. It also
 changes the term 'modifier' to 'variable' which is a more proper
 description of these keys (as per the HID spec), in various 
 comments and printfs.
 
 If you have a USB keyboard (whether or not it is a gaming variety),
 please test this diff to ensure that it does not break you. I've tested
 on i386 and amd64 on a variety of keyboards and haven't seen any
 problems, so it's time to turn it loose to a wider audience.
 
 -ml
This keyboard is still working fine:

uhidev2 at uhub2 port 1 configuration 1 interface 0 Microsoft Natural\M-. 
Ergonomic Keyboard 4000 rev 2.00/1.73 addr 2
uhidev2: iclass 3/1
ukbd1 at uhidev2: 8 variable keys, 6 key codes
wskbd2 at ukbd1 mux 1
wskbd2: connecting to wsdisplay0
uhidev3 at uhub2 port 1 configuration 1 interface 1 Microsoft Natural\M-. 
Ergonomic Keyboard 4000 rev 2.00/1.73 addr 2
uhidev3: iclass 3/0, 1 report id
uhid0 at uhidev3 reportid 1: input=7, output=0, feature=0

Although it's still suffering from the fact I need to detach/attach the cables
upon every boot/suspend otherwise it just sits there playing dead. But that's
unrelated to this diff.

 Index: hidkbd.c
 ===
 RCS file: /cvs/src/sys/dev/usb/hidkbd.c,v
 retrieving revision 1.5
 diff -a -u -r1.5 hidkbd.c
 --- hidkbd.c  9 Nov 2011 14:22:38 -   1.5
 +++ hidkbd.c  29 Jun 2012 06:45:59 -
 @@ -41,6 +41,7 @@
  #include sys/kernel.h
  #include sys/device.h
  #include sys/ioctl.h
 +#include sys/malloc.h
  
  #include dev/usb/usb.h
  #include dev/usb/usbhid.h
 @@ -164,6 +165,8 @@
  {
   const char *parserr;
  
 + kbd-sc_var = NULL;
 +
   parserr = hidkbd_parse_desc(kbd, id, desc, dlen);
   if (parserr != NULL) {
   printf(: %s\n, parserr);
 @@ -171,8 +174,8 @@
   }
  
  #ifdef DIAGNOSTIC
 - printf(: %d modifier keys, %d key codes,
 - kbd-sc_nmod, kbd-sc_nkeycode);
 + printf(: %d variable keys, %d key codes,
 + kbd-sc_nvar, kbd-sc_nkeycode);
  #endif
  
   kbd-sc_device = self;
 @@ -245,6 +248,9 @@
   if (kbd-sc_wskbddev != NULL)
   rv = config_detach(kbd-sc_wskbddev, flags);
  
 + if (kbd-sc_var != NULL)
 + free(kbd-sc_var, M_DEVBUF);
 +
   return (rv);
  }
  
 @@ -263,11 +269,9 @@
   }
  #endif
  
 - /* extract key modifiers */
 - ud-modifiers = 0;
 - for (i = 0; i  kbd-sc_nmod; i++)
 - if (hid_get_data(data, kbd-sc_modloc[i]))
 - ud-modifiers |= kbd-sc_mods[i].mask;
 + /* extract variable keys */
 + for (i = 0; i  kbd-sc_nvar; i++) 
 + ud-var[i] = (u_int8_t)hid_get_data(data, kbd-sc_var[i].loc);
  
   /* extract keycodes */
   memcpy(ud-keycode, data + kbd-sc_keycodeloc.pos / 8,
 @@ -311,7 +315,6 @@
  void
  hidkbd_decode(struct hidkbd *kbd, struct hidkbd_data *ud)
  {
 - uint32_t mod, omod;
   u_int16_t ibuf[MAXKEYS];/* chars events */
   int s;
   int nkeys, i, j;
 @@ -347,15 +350,15 @@
   return; /* ignore  */
   }
   nkeys = 0;
 - mod = ud-modifiers;
 - omod = kbd-sc_odata.modifiers;
 - if (mod != omod)
 - for (i = 0; i  kbd-sc_nmod; i++)
 - if (( mod  kbd-sc_mods[i].mask) !=
 - (omod  kbd-sc_mods[i].mask))
 - ADDKEY(kbd-sc_mods[i].key |
 -(mod  kbd-sc_mods[i].mask
 -   ? PRESS : RELEASE));
 +
 + for (i = 0; i  kbd-sc_nvar; i++)
 + if ((kbd-sc_odata.var[i]  kbd-sc_var[i].mask) !=
 + (ud-var[i]  kbd-sc_var[i].mask)) {
 + ADDKEY(kbd-sc_var[i].key |
 + ((ud-var[i]  kbd-sc_var[i].mask) ?
 + PRESS : RELEASE));
 + }
 +
   if (memcmp(ud-keycode, kbd-sc_odata.keycode, kbd-sc_nkeycode) != 0) {
   /* Check for released keys. */
   for (i = 0; i  kbd-sc_nkeycode; i++) {
 @@ -547,10 +550,36 @@
  {
   struct hid_data *d;
   struct hid_item h;
 

Re: tinyscheme + mg

2012-06-28 Thread Jasper Lievisse Adriaanse
On Thu, Jun 28, 2012 at 08:35:18AM -0400, Kjell Wooding wrote:
 Thoughts, since we have been down this road before.
 
 1. You can remap keys, in your ~/.mg file
 
 2. I should point out that all of mg (other than theo.c) is currently
 PUBLIC DOMAIN, not merely BSD, so this change is significant, license-wise.
 Please be pedantic about including licenses.
 
 3. Why scheme? Yes, emacs uses Lisp. But seriously, so? Why not just add,
 say, perl bindings?
 
 4. Seriously, please be pedantic about licenses. Part of me dies when we
 see a new source file without one.
 
 I'm all for adding support for scripting into mg, though I would be tempted
 to rip out all nonessential functionality first (ng? ;) and add it back via
 the scripting language. I would think the goal should be to make mg
 significantly *smaller* any such change
 
 -kj
Regarding the licenses, Kettenis pointed out I forgot to add the original
copyright headers, which I have since added to my local repo.

It's reproduced here for reference:

Copyright (c) 2000, Dimitrios Souflis
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

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.

Neither the name of Dimitrios Souflis nor the names of the
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

I'm totally fine with putting mgscheme.c into the public domain, if tedu
agrees too of course.

 On Thursday, June 28, 2012, Loganaden Velvindron wrote:
 
  If Jasper is going to take care of it, why not :-) ?
 
  I'd like to get the ability to remap keys, without hacking src.
 
  (As an mg user)
 
  On Thu, Jun 28, 2012 at 2:06 PM, Mark Lumsden 
  m...@showcomplex.comjavascript:;
  wrote:
   Here is an updated diff for mg with tinyscheme integration. It's based
  on
   tedu's original diff with various tweaks and changes. For those worried
  about
   mg being too bloated, rest assured, it's still small and lean and a big
  part
   smaller than vi ;-)
   It's not fully possible to turn mg into your mail client, but I'd like
  to commit
   this diff and work on it futher in tree (not the mail-client thing,
  that would
   bloat mg and that's far from desired).
  
   Includes some fixes by lum@ and Sunil Nimmagadda too.
  
   Diff is also at http://crappydiffs.org/tinyschemg.diff
  
  
   I would appreciate some feedback on the inclusion of this diff in mg
   since I am unlikely to use tinyscheme myself but can see why others
   would like it added. Are there are strong feelings about it either
   way?
  
   -lum
  
 
 
 
  --
  Brightest day,
  Blackest night,
  No bug shall escape my sight,
  And those who worship evil's mind,
  be wary of my powers,
  puffy lantern's light !
 

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: tinyscheme + mg

2012-06-28 Thread Jasper Lievisse Adriaanse
On Thu, Jun 28, 2012 at 10:12:38AM -0400, Ted Unangst wrote:
 On Thu, Jun 28, 2012 at 15:21, Jasper Lievisse Adriaanse wrote:
  On Thu, Jun 28, 2012 at 08:35:18AM -0400, Kjell Wooding wrote:
 
  2. I should point out that all of mg (other than theo.c) is currently
  PUBLIC DOMAIN, not merely BSD, so this change is significant, license-wise.
  Please be pedantic about including licenses.
 
 I think it's reasonable to maintain an ifdef to omit scheme (and
 theo.c if you like, as I'd probably redo that in scheme) to get
 pure public domain mg.
The cscope.c and ctags.c files are also non-PD at the moment.
 
  3. Why scheme? Yes, emacs uses Lisp. But seriously, so? Why not just add,
  say, perl bindings?
 
 In large part, yes, because emacs uses lisp.  I think it's fun.
 
 If you need a technical reason, it's because 90% of the mg commands,
 like copy-region-as-kill, are not legal perl function names.
Seconded.
 
  I'm totally fine with putting mgscheme.c into the public domain, if tedu
  agrees too of course.
 
 It's not a big deal, but I'd prefer to keep it BSD.  Most of it
 already has to be, so it seems logical that all scheme extensions are
 one license.


-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: compat_linux: Fix counting in futex_wake.

2012-06-19 Thread Jasper Lievisse Adriaanse
On Tue, Jun 19, 2012 at 12:13:09PM +0300, Paul Irofti wrote:
 Count should always be zero no matter if we need to relocate or not.
 
 Okay?
Makes sense to me (including the other diffs you sent which I didn't reply to 
individually).

 Index: linux_futex.c
 ===
 RCS file: /cvs/src/sys/compat/linux/linux_futex.c,v
 retrieving revision 1.4
 diff -u -p -r1.4 linux_futex.c
 --- linux_futex.c 19 Jun 2012 08:50:59 -  1.4
 +++ linux_futex.c 19 Jun 2012 09:10:20 -
 @@ -496,12 +496,10 @@ int
  futex_wake(struct futex *f, int n, struct futex *newf, int n2)
  {
   struct waiting_proc *wp;
 - int count;
 + int count = 0;
  
   KASSERT(newf != f);
   MUTEX_ASSERT_LOCKED(futex_lock);
 -
 - count = newf ? 0 : 1;
  
   /*
* first, wake up any threads sleeping on this futex.
 

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish



Re: [PATCH] dired mg patch

2011-08-19 Thread Jasper Lievisse Adriaanse
On Thu, Aug 18, 2011 at 08:30:02AM -0400, Loganaden Velvindron wrote:
 I used a function for warping the dot. This
 makes the diff simpler.
Since kjell@ has slacked out; any objections to committing this revision of
the diff?

 Index: dired.c
 ===
 RCS file: /cvs/src/usr.bin/mg/dired.c,v
 retrieving revision 1.48
 diff -u -p -r1.48 dired.c
 --- dired.c   23 Jan 2011 00:45:03 -  1.48
 +++ dired.c   18 Aug 2011 12:23:47 -
 @@ -36,6 +36,11 @@ static int  d_rename(int, int);
  static intd_shell_command(int, int);
  static intd_create_directory(int, int);
  static intd_makename(struct line *, char *, size_t);
 +static intd_warpdot(char *);
 +static intd_forwpage(int, int);
 +static intd_backpage(int, int);
 +static intd_forwline(int, int);
 +static intd_backline(int, int);
  static void   reaper(int);
  
  extern struct keymap_s helpmap, cXmap, metamap;
 @@ -57,15 +62,15 @@ static PF dirednul[] = {
  static PF diredcl[] = {
   reposition, /* ^L */
   d_findfile, /* ^M */
 - forwline,   /* ^N */
 + d_forwline, /* ^N */
   rescan, /* ^O */
 - backline,   /* ^P */
 + d_backline, /* ^P */
   rescan, /* ^Q */
   backisearch,/* ^R */
   forwisearch,/* ^S */
   rescan, /* ^T */
   universal_argument, /* ^U */
 - forwpage,   /* ^V */
 + d_forwpage, /* ^V */
   rescan, /* ^W */
   NULL/* ^X */
  };
 @@ -77,7 +82,7 @@ static PF diredcz[] = {
   rescan, /* ^] */
   rescan, /* ^^ */
   rescan, /* ^_ */
 - forwline,   /* SP */
 + d_forwline, /* SP */
   d_shell_command,/* ! */
   rescan, /*  */
   rescan, /* # */
 @@ -99,9 +104,9 @@ static PF diredc[] = {
  };
  
  static PF diredn[] = {
 - forwline,   /* n */
 + d_forwline, /* n */
   d_ffotherwindow,/* o */
 - backline,   /* p */
 + d_backline, /* p */
   rescan, /* q */
   d_rename,   /* r */
   rescan, /* s */
 @@ -116,13 +121,32 @@ static PF direddl[] = {
   d_undelbak  /* del */
  };
  
 +static PF diredbp[] = {
 + d_backpage  /* v */ 
 +};
 +
 +static PF dirednull[] = {
 + NULL
 +};
 +
  #ifndef  DIRED_XMAPS
  #define  NDIRED_XMAPS0   /* number of extra map sections */
  #endif /* DIRED_XMAPS */
  
 -static struct KEYMAPE (6 + NDIRED_XMAPS + IMAPEXT) diredmap = {
 - 6 + NDIRED_XMAPS,
 - 6 + NDIRED_XMAPS + IMAPEXT,
 +static struct KEYMAPE (1 + IMAPEXT) d_backpagemap = {
 + 1,
 + 1 + IMAPEXT,
 + rescan, 
 + {
 + {
 + 'v', 'v', diredbp, NULL
 + }
 + }
 +};
 +
 +static struct KEYMAPE (7 + NDIRED_XMAPS + IMAPEXT) diredmap = {
 + 7 + NDIRED_XMAPS,
 + 7 + NDIRED_XMAPS + IMAPEXT,
   rescan,
   {
  #ifndef NO_HELP
 @@ -138,6 +162,10 @@ static struct KEYMAPE (6 + NDIRED_XMAPS 
   CCHR('L'), CCHR('X'), diredcl, (KEYMAP *)  cXmap
   },
   {
 + CCHR('['), CCHR('['), dirednull, (KEYMAP *)  
 + d_backpagemap
 + },
 + {
   CCHR('Z'), '+', diredcz, (KEYMAP *)  metamap
   },
   {
 @@ -592,6 +620,75 @@ d_makename(struct line *lp, char *fn, si
   return ((lgetc(lp, 2) == 'd') ? TRUE : FALSE);
  }
  
 +static int
 +d_warpdot(char *l_text)
 +{
 + char *track, *anchor = NULL;
 + int col = 0;
 +
 + track = l_text;
 + while (track != NULL  track - l_text = strlen(l_text)) {
 + if(strspn(track,  )  0) {
 + track += strspn(track,  );
 + col++;
 + if (col == 9) {
 + anchor = track;
 + break;
 + }
 + }
 + else
 + track++;
 + }
 + if (anchor == NULL)
 + return (NULL);
 + else
 + return (anchor - l_text);
 +}
 +
 +static int
 +d_forwpage(int f, int n) 
 +{
 + forwpage(f | FFRAND, n);
 + if (d_warpdot(curwp-w_dotp-l_text) == NULL)
 + curwp-w_doto = 0;
 + else
 + curwp-w_doto = d_warpdot(curwp-w_dotp-l_text);   
 + return TRUE;
 +}
 +
 +static int 
 +d_backpage (int f, int n)
 +{
 + backpage(f | FFRAND, n);
 + if (d_warpdot(curwp-w_dotp-l_text) == NULL)
 + curwp-w_doto = 0;
 + else
 + curwp-w_doto = d_warpdot(curwp-w_dotp-l_text);
 + 

Re: kdump: resolve sysctl numbers

2011-07-27 Thread Jasper Lievisse Adriaanse
On Wed, Jul 27, 2011 at 10:58:22AM -0400, Ted Unangst wrote:
 On Wed, Jul 27, 2011, Otto Moerbeek wrote:
 
  +#define SETNAME(name) do { names = (name); limit = nitems(name); } while 
  (0)
 
 userland is not supposed to use nitems I think?  But it keeps sneaking
 in because the kernel headers don't protect it.
That's right. It's used in some places like pcidump, npppd and tmux, but it's
locally defined as:

#ifndef nitems
#define nitems(_a)  (sizeof((_a)) / sizeof((_a)[0]))
#endif

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: minor mount_ntfs cleanup

2011-06-28 Thread Jasper Lievisse Adriaanse
On Mon, Jun 27, 2011 at 06:15:15PM -0400, Kenneth R Westerback wrote:
 On Mon, Jun 27, 2011 at 04:52:46PM -0400, Ted Unangst wrote:
  The original porting effort left behind some unneeded bits.
 
 I'm not going to encourage NTFS use by ok'ing it. But if I was, I
 would.
 
  Ken
Yep, Ok with me.

  Index: mount_ntfs.c
  ===
  RCS file: /cvs/src/sbin/mount_ntfs/mount_ntfs.c,v
  retrieving revision 1.13
  diff -u -r1.13 mount_ntfs.c
  --- mount_ntfs.c27 Jun 2011 19:47:22 -  1.13
  +++ mount_ntfs.c27 Jun 2011 20:51:26 -
  @@ -34,39 +34,26 @@
* Id: mount_ntfs.c,v 1.1.1.1 1999/02/03 03:51:19 semenu Exp
*/
   
  -#include sys/cdefs.h
   #include sys/param.h
  -#define NTFS
   #include sys/mount.h
   #include sys/stat.h
  -#include ctype.h
  +
   #include err.h
  -#include grp.h
  -#include pwd.h
   #include stdio.h
   #include stdlib.h
   #include string.h
   #include sysexits.h
   #include unistd.h
  -#include util.h
   
   #include mntopts.h
   
   static const struct mntopt mopts[] = {
  MOPT_STDOPTS,
  -#ifdef MNT_GETARGS
  -   MOPT_GETARGS,
  -#endif
  { NULL }
   };
   
  -#ifndef __dead2
  -#define __dead2 __attribute__((__noreturn__))
  -#endif
  -
  -static voidusage(void) __dead2;
  -mode_t a_mask(char *);
  -int main(int, char **);
  +static __dead void usage(void);
  +static mode_t a_mask(char *);
   
   int
   main(int argc, char *argv[])
  @@ -77,7 +64,7 @@
  char *dev, dir[MAXPATHLEN];
   
  mntflags = set_gid = set_uid = set_mask = 0;
  -   (void)memset(args, '\0', sizeof(args));
  +   memset(args, 0, sizeof(args));
   
  while ((c = getopt(argc, argv, aiu:g:m:o:)) !=  -1) {
  switch (c) {
  @@ -102,15 +89,12 @@
  case 'o':
  getmntopts(optarg, mopts, mntflags);
  break;
  -   case '?':
  default:
  usage();
  break;
  }
  }
   
  -   mntflags |= MNT_RDONLY;
  -
  if (optind + 2 != argc)
  usage();
   
  @@ -119,7 +103,9 @@
  err(1, realpath %s, argv[optind + 1]);
   
  args.fspec = dev;
  -   args.export_info.ex_root = 65534;   /* unchecked anyway on DOS fs */
  +   args.export_info.ex_root = 65534;   /* unchecked anyway on NTFS */
  +
  +   mntflags |= MNT_RDONLY;
  if (mntflags  MNT_RDONLY)
  args.export_info.ex_flags = MNT_EXRDONLY;
  else
  @@ -138,18 +124,10 @@
  if (mount(MOUNT_NTFS, dir, mntflags, args)  0)
  err(EX_OSERR, %s on %s, dev, dir);
   
  -#ifdef MNT_GETARGS
  -   if (mntflags  MNT_GETARGS) {
  -   char buf[1024];
  -   (void)snprintb(buf, sizeof(buf), NTFS_MFLAG_BITS, args.flag);
  -   printf(uid=%d, gid=%d, mode=0%o, flags=%s\n, args.uid,
  -   args.gid, args.mode, buf);
  -   }
  -#endif
  -   exit (0);
  +   exit(0);
   }
   
  -mode_t
  +static mode_t
   a_mask(char *s)
   {
  int done, rv;
 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: [Update] xenocara/xkeyboard-config

2011-06-24 Thread Jasper Lievisse Adriaanse
On Thu, Jun 23, 2011 at 06:08:47PM +0600, Alexandr Shadchin wrote:
 Hi,
 
 I prepared update package xkeyboard-config to the latest release 2.3.
 Patch available on http://koba.devio.us/distfiles/xkeyboard-config-2.3.diff
 Tested on amd64.
 
 -- 
 Alexandr Shadchin

No problems here on amd64 with sun type 6. 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: switch to xkeyboard-config XKB configuration: please test

2011-05-31 Thread Jasper Lievisse Adriaanse
On Tue, May 31, 2011 at 08:22:09PM +0200, Antoine Jacoutot wrote:
 On Mon, 30 May 2011, Matthieu Herrb wrote:
 
  Hi,
  
  Some years ago X.Org decided to switch to a new set of XKB (the X
  Keyboard extension) data files known as xkeyboard-config. 
  
  For various reasons (local changes, complexity of the build system for 
  xkeyboard-config, slacking) Xenocara is still using the old and
  unmaintained xkb-data. 
  
  The update is needed for libxklavier which is a required library for
  some Desktop related ports. Keyboard handling in GNOME3 for one will
  not work at all without this update. KDE4 may require the same at some
  point and same goes for ports that use xkeyboard-config.
  
  With the help of Alexandr Shadchin, Xenocara now ready to switch to
  xkeyboard-config, but we'd like to have a last round of tests. 
  
  For this apply the patch below and rebuild xenocara from sources. 
  
  Please note that this will move the xkb data files from /etc/X11 to
  /usr/X11R6/share/X11 
  
  Report success/failures to shadchin@ and me. Thanks.
 
 Works beautifully for me on i386 and amd64. I also tried macppc, it 
 worked but I'm using a regular keyboard, not an apple one, so I'm not 
 sure that counts :)
 
 
  Index: share/mk/bsd.xconf.mk
  ===
  RCS file: /cvs/OpenBSD/xenocara/share/mk/bsd.xconf.mk,v
  retrieving revision 1.18
  diff -u -p -u -r1.18 bsd.xconf.mk
  --- share/mk/bsd.xconf.mk   8 Mar 2011 20:48:59 -   1.18
  +++ share/mk/bsd.xconf.mk   29 May 2011 17:07:33 -
  @@ -19,4 +19,4 @@ XENOCARA_BUILD_PIXMAN?=yes
   .endif
   
   # Build xkeyboard-config?
  -XENOCARA_USE_XKEYBOARD_CONFIG?=no
  +XENOCARA_USE_XKEYBOARD_CONFIG?=yes
  
  
 
 -- 
 Antoine

Works fine on my i386, amd64 and sparc64 (all with standard keyboards). I
should be able to test a Sun Type 6 USB beginning next week. 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: Bus Pirate: bus hacking tool for hardware developers

2011-05-13 Thread Jasper Lievisse Adriaanse
On Thu, May 12, 2011 at 06:00:53PM +, Jona Joachim wrote:
 Hi,
 I just wanted to share this board that I discovered today:
 http://dangerousprototypes.com/bus-pirate-manual/
 
 It's an uftdi(4) board that gives you access to the following bus
 protocols:
 1-Wire, I2C, SPI, JTAG, RS-232, MIDI, ...
 http://dangerousprototypes.com/docs/Features_overview
 
 I remember the photos of Theo soldering the I2C temperature chips to his
 RAM, so I thought some of you might find this interesting.
 
 Note: I haven't tested it yet but I read some very good critics
 
 Best regards,
 Jona
 
 -- 
 Worse is better
 Richard P. Gabriel
 

I got a buspirate last week and I hope to have a port ready next week with
some nice utils, like an SPI sniffer and stuff like that :)

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: NELEM() - nitems() in sys/i386/i386/est.c and bin/ksh/

2011-05-13 Thread Jasper Lievisse Adriaanse
On Fri, May 13, 2011 at 03:08:36AM +0400, Vadim Zhukov wrote:
 Hello all.
 
 This diff removes NELEM() definitions in favour of nitems(). Not sure
 about bin/ksh/ part, but sys/i386/i386/est.c is obviously a leftover.
 
 There are more NELEM() items in tree, but they belong to foreign stuff
 and therefore should not be touched, as far as I understand.
 
 -- 
   Best wishes,
 Vadim Zhukov
 
 A: Because it messes up the order in which people normally read text.
 Q: Why is top-posting such a bad thing?
 A: Top-posting.
 Q: What is the most annoying thing in e-mail?

the est.c diff is correct (and has been committed), but the ksh part isn't. we
don't want userland to use nitems() yet.

 Index: sys/arch/i386/i386/est.c
 ===
 RCS file: /cvs/src/sys/arch/i386/i386/est.c,v
 retrieving revision 1.36
 diff -u -p -r1.36 est.c
 --- sys/arch/i386/i386/est.c  5 Jul 2010 22:47:41 -   1.36
 +++ sys/arch/i386/i386/est.c  12 May 2011 23:03:48 -
 @@ -862,10 +862,8 @@ struct fqlist {
   struct est_op *table;
  };
  
 -#define NELEM(x) (sizeof(x) / sizeof((x)[0]))
 -
  #define ENTRY(ven, bus_clk, tab) \
 - { CPUVENDOR_##ven, bus_clk == BUS133 ? 1 : 0, NELEM(tab), tab }
 + { CPUVENDOR_##ven, bus_clk == BUS133 ? 1 : 0, nitems(tab), tab }
  
  #define BUS_CLK(fqp) ((fqp)-bus_clk ? BUS133 : BUS100)
  
 @@ -1082,7 +1080,7 @@ est_init(const char *cpu_device, int ven
   /*
* Find an entry which matches (vendor, bus_clock, idhi, idlo)
*/
 - for (i = 0; i  NELEM(est_cpus); i++) {
 + for (i = 0; i  nitems(est_cpus); i++) {
   fql = est_cpus[i];
   if (vendor == fql-vendor  bus_clock == BUS_CLK(fql)
idhi == fql-table[0].ctrl
 Index: bin/ksh/c_ulimit.c
 ===
 RCS file: /cvs/src/bin/ksh/c_ulimit.c,v
 retrieving revision 1.17
 diff -u -p -r1.17 c_ulimit.c
 --- bin/ksh/c_ulimit.c21 Mar 2008 12:51:19 -  1.17
 +++ bin/ksh/c_ulimit.c12 May 2011 23:03:48 -
 @@ -53,7 +53,7 @@ c_ulimit(char **wp)
  #endif /* RLIMIT_VMEM */
   { (char *) 0 }
   };
 - static char options[4 + NELEM(limits) * 2];
 + static char options[4 + nitems(limits) * 2];
   int how = SOFT | HARD;
   const struct limits *l;
   int optc, all = 0;
 Index: bin/ksh/edit.c
 ===
 RCS file: /cvs/src/bin/ksh/edit.c,v
 retrieving revision 1.34
 diff -u -p -r1.34 edit.c
 --- bin/ksh/edit.c20 May 2010 01:13:07 -  1.34
 +++ bin/ksh/edit.c12 May 2011 23:03:48 -
 @@ -223,7 +223,7 @@ set_editmode(const char *ed)
  
   if ((rcp = strrchr(ed, '/')))
   ed = ++rcp;
 - for (i = 0; i  NELEM(edit_flags); i++)
 + for (i = 0; i  nitems(edit_flags); i++)
   if (strstr(ed, options[(int) edit_flags[i]].name)) {
   change_flag(edit_flags[i], OF_SPECIAL, 1);
   return;
 Index: bin/ksh/emacs.c
 ===
 RCS file: /cvs/src/bin/ksh/emacs.c,v
 retrieving revision 1.43
 diff -u -p -r1.43 emacs.c
 --- bin/ksh/emacs.c   14 Mar 2011 21:20:01 -  1.43
 +++ bin/ksh/emacs.c   12 May 2011 23:03:49 -
 @@ -1312,7 +1312,7 @@ x_bind( const char *a1, const char *a2,
  
   /* List function names */
   if (list) {
 - for (f = 0; f  NELEM(x_ftab); f++)
 + for (f = 0; f  nitems(x_ftab); f++)
   if (x_ftab[f].xf_name 
   !(x_ftab[f].xf_flags  XF_NOBIND))
   shprintf(%s\n, x_ftab[f].xf_name);
 @@ -1352,11 +1352,11 @@ x_bind( const char *a1, const char *a2,
   if (*a2 == 0)
   f = XFUNC_insert;
   else if (!macro) {
 - for (f = 0; f  NELEM(x_ftab); f++)
 + for (f = 0; f  nitems(x_ftab); f++)
   if (x_ftab[f].xf_name 
   strcmp(x_ftab[f].xf_name, a2) == 0)
   break;
 - if (f == NELEM(x_ftab) || x_ftab[f].xf_flags  XF_NOBIND) {
 + if (f == nitems(x_ftab) || x_ftab[f].xf_flags  XF_NOBIND) {
   bi_errorf(%s: no such function, a2);
   return 1;
   }
 @@ -1402,7 +1402,7 @@ x_init_emacs(void)
   for (i = 1; i  X_NTABS; i++)
   for (j = 0; j  X_TABSZ; j++)
   x_tab[i][j] = XFUNC_error;
 - for (i = 0; i  NELEM(x_defbindings); i++)
 + for (i = 0; i  nitems(x_defbindings); i++)
   x_tab[(unsigned char)x_defbindings[i].xdb_tab]
 [x_defbindings[i].xdb_char]
   = x_defbindings[i].xdb_func;
  
 Index: bin/ksh/jobs.c
 

Re: Quick sanity test for sili(4)/ahci(4) diff

2011-05-06 Thread Jasper Lievisse Adriaanse
On Fri, May 06, 2011 at 10:52:19AM -0700, Matthew Dempsky wrote:
 If you have a sili(4) or ahci(4), I'd appreciate a quick test of the
 diff below.  As long as you can still mount your disks without
 panicking, then it worked. :)
 
 One test for each is sufficient, so please reply to the list to save
 others from redundant effort.
Works fine with this on amd64:

ahci1 at pci0 dev 17 function 0 ATI SBx00 SATA rev 0x00: apic 4 int 22, AHCI 
1.1

Cheers,
Jasper

 Index: ata/atascsi.c
 ===
 RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ata/atascsi.c,v
 retrieving revision 1.104
 diff -u -p -r1.104 atascsi.c
 --- ata/atascsi.c 5 May 2011 19:23:05 -   1.104
 +++ ata/atascsi.c 6 May 2011 17:41:20 -
 @@ -1590,10 +1590,12 @@ atascsi_io_get(void *cookie)
  void
  atascsi_io_put(void *cookie, void *io)
  {
 - struct ata_xfer *xa = io;
 + struct atascsi_host_port*ahp = cookie;
 + struct atascsi  *as = ahp-ahp_as;
 + struct ata_xfer *xa = io;
  
   xa-state = ATA_S_COMPLETE; /* XXX this state machine is dumb */
 - xa-ata_put_xfer(xa);
 + as-as_methods-ata_put_xfer(xa);
  }
  
  void
 Index: ata/atascsi.h
 ===
 RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ata/atascsi.h,v
 retrieving revision 1.45
 diff -u -p -r1.45 atascsi.h
 --- ata/atascsi.h 26 Jan 2011 21:41:00 -  1.45
 +++ ata/atascsi.h 5 May 2011 19:33:35 -
 @@ -18,6 +18,9 @@
   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */
  
 +#ifndef _DEV_ATA_ATASCSI_H_
 +#define _DEV_ATA_ATASCSI_H_
 +
  struct atascsi;
  struct scsi_link;
  
 @@ -327,8 +330,6 @@ struct ata_xfer {
   void*atascsi_private;
  
   int pmp_port;
 -
 - void(*ata_put_xfer)(struct ata_xfer *);
  };
  
  /*
 @@ -339,6 +340,7 @@ struct atascsi_methods {
   int (*probe)(void *, int, int);
   void(*free)(void *, int, int);
   struct ata_xfer *   (*ata_get_xfer)(void *, int);
 + void(*ata_put_xfer)(struct ata_xfer *);
   void(*ata_cmd)(struct ata_xfer *);
  };
  
 @@ -368,3 +370,5 @@ int   atascsi_probe_dev(struct atascsi *,
  int  atascsi_detach_dev(struct atascsi *, int, int, int);
  
  void ata_complete(struct ata_xfer *);
 +
 +#endif /* _DEV_ATA_ATASCSI_H_ */
 Index: ic/sili.c
 ===
 RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/sili.c,v
 retrieving revision 1.47
 diff -u -p -r1.47 sili.c
 --- ic/sili.c 26 Jan 2011 21:41:00 -  1.47
 +++ ic/sili.c 5 May 2011 19:34:11 -
 @@ -211,6 +211,7 @@ struct atascsi_methods sili_atascsi_meth
   sili_ata_probe,
   sili_ata_free,
   sili_ata_get_xfer,
 + sili_ata_put_xfer,
   sili_ata_cmd
  };
  
 @@ -833,7 +834,6 @@ sili_ccb_alloc(struct sili_port *sp)
   ccb-ccb_xa.fis = (struct ata_fis_h2d *)prb-fis;
   ccb-ccb_xa.packetcmd = ((struct sili_prb_packet *)prb)-cdb;
   ccb-ccb_xa.tag = i;
 - ccb-ccb_xa.ata_put_xfer = sili_ata_put_xfer;
   ccb-ccb_xa.state = ATA_S_COMPLETE;
  
   sili_put_ccb(ccb);
 Index: pci/ahci.c
 ===
 RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/pci/ahci.c,v
 retrieving revision 1.177
 diff -u -p -r1.177 ahci.c
 --- pci/ahci.c24 Apr 2011 11:09:48 -  1.177
 +++ pci/ahci.c5 May 2011 19:33:58 -
 @@ -622,6 +622,7 @@ struct atascsi_methods ahci_atascsi_meth
   ahci_ata_probe,
   ahci_ata_free,
   ahci_ata_get_xfer,
 + ahci_ata_put_xfer,
   ahci_ata_cmd
  };
  
 @@ -1227,8 +1228,6 @@ nomem:
   (struct ata_fis_h2d *)ccb-ccb_cmd_table-cfis;
   ccb-ccb_xa.packetcmd = ccb-ccb_cmd_table-acmd;
   ccb-ccb_xa.tag = i;
 -
 - ccb-ccb_xa.ata_put_xfer = ahci_ata_put_xfer;
  
   ccb-ccb_xa.state = ATA_S_COMPLETE;
   ahci_put_ccb(ccb);
 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: adb(4)/pm_direct.c cleanup

2011-05-03 Thread Jasper Lievisse Adriaanse
On Tue, May 03, 2011 at 08:11:52AM +0530, Martin Pieuchot wrote:
 On macppc, the pm_* methods are always attached to a PMU (or PMU99), so
 no need to check for hardware.
 
 Tested here with a powerbook6,5.
 
 Ok?
This appears to be working fine on my PowerBook4,1 (ibook g3), will do more
testing tomorrow if needed. There's no dmesg change.

[ using 481912 bytes of bsd ELF symbol table ]
console out [ATY,RageM3p29s]console in [keyboard] , using ADB
: memaddr 9400 size 400, : consaddr 96008000, : ioaddr 9002, size 
2: memtag 8000, iotag 8000: width 1024 linebytes 1024 height 768 depth 8
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2011 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 4.9-current (GENERIC) #0: Tue Oct  5 17:18:42 CEST 2010
jasper@cupertino:/usr/src/sys/arch/macppc/compile/GENERIC
real mem = 402653184 (384MB)
avail mem = 376979456 (359MB)
mainbus0 at root: model PowerBook4,1
cpu0 at mainbus0: 750 (Revision 0x3311): 600 MHz: 256KB backside cache
mem0 at mainbus0
spdmem0 at mem0: SDRAM non-parity PC66
spdmem1 at mem0: 256MB SDRAM non-parity PC100CL2
memc0 at mainbus0: uni-n
kiic0 at memc0 offset 0xf8001000
iic0 at kiic0
mpcpcibr0 at mainbus0 pci: uni-north, Revision 0xff
pci0 at mpcpcibr0 bus 0
pchb0 at pci0 dev 11 function 0 Apple Pangea AGP rev 0x00
vgafb0 at pci0 dev 16 function 0 ATI Mobility M3 rev 0x02, mmio
wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation)
mpcpcibr1 at mainbus0 pci: uni-north, Revision 0x0
pci1 at mpcpcibr1 bus 0
pchb1 at pci1 dev 11 function 0 Apple Pangea rev 0x00
macobio0 at pci1 dev 23 function 0 Apple Pangea Macio rev 0x00
openpic0 at macobio0 offset 0x4: version 0x4614 little endian
macgpio0 at macobio0 offset 0x50
macgpio1 at macgpio0 irq 47
pgs0 at macgpio0: irq 55
firewire-linkon at macgpio0 not configured
gpio1 at macgpio0 not configured
gpio9 at macgpio0 not configured
extint-gpio4 at macgpio0 not configured
extint-gpio12 at macgpio0 not configured
escc-legacy at macobio0 offset 0x12000 not configured
zsc0 at macobio0 offset 0x13000: irq 22,23
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
tumbler0 at macobio0 offset 0x1: irq 30,1,2
timer at macobio0 offset 0x15000 not configured
adb0 at macobio0 offset 0x16000 irq 25: via-pmu, 3 targets
akbd0 at adb0 addr 2: PowerBook G4 keyboard (Inverted T)
wskbd0 at akbd0: console keyboard, using wsdisplay0
ams0 at adb0 addr 3: EMP trackpad tpad 2-button, 400 dpi
wsmouse0 at ams0 mux 0
abtn0 at adb0 addr 7: brightness/volume/eject buttons
apm0 at adb0: battery flags 0x5, 7% charged
battery at macobio0 offset 0x0 not configured
backlight at macobio0 offset 0xf300 not configured
kiic1 at macobio0 offset 0x18000
iic1 at kiic1
wdc0 at macobio0 offset 0x1f000 irq 19: DMA
wd0 at wdc0 channel 0 drive 0: HTS424040M9AT00
wd0: 16-sector PIO, LBA48, 38154MB, 78140160 sectors
atapiscsi0 at wdc0 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: TOSHIBA, DVD-ROM SD-R2002, 1B29 ATAPI 5/cdrom 
removable
wd0(wdc0:0:0): using PIO mode 4, DMA mode 2
cd0(wdc0:0:1): using PIO mode 4, DMA mode 2
wi0 at macobio0 offset 0x3 irq 57:
wi0: Firmware 4.16 variant 1, address 00:10:c6:6a:93:64
audio0 at tumbler0
ohci0 at pci1 dev 24 function 0 Apple Pangea USB rev 0x00: irq 27, version 1.0
ohci1 at pci1 dev 25 function 0 Apple Pangea USB rev 0x00: irq 28, version 1.0
usb0 at ohci0: USB revision 1.0
uhub0 at usb0 Apple OHCI root hub rev 1.00/1.00 addr 1
usb1 at ohci1: USB revision 1.0
uhub1 at usb1 Apple OHCI root hub rev 1.00/1.00 addr 1
mpcpcibr2 at mainbus0 pci: uni-north, Revision 0x16
pci2 at mpcpcibr2 bus 0
pchb2 at pci2 dev 11 function 0 Apple Pangea PCI rev 0x00
Apple Pangea FireWire rev 0x00 at pci2 dev 14 function 0 not configured
gem0 at pci2 dev 15 function 0 Apple Pangea GMAC rev 0x00: irq 41, address 
00:03:93:62:98:f8
bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
bootpath: /pci@f200/mac-io@17/ata-4@1f000/disk@0:/bsd
root on wd0a swap on wd0b dump on wd0b

 Index: dev/adb.c
 ===
 RCS file: /cvs/src/sys/arch/macppc/dev/adb.c,v
 retrieving revision 1.29
 diff -u -p -r1.29 adb.c
 --- dev/adb.c 1 Feb 2009 17:04:26 -   1.29
 +++ dev/adb.c 3 May 2011 02:27:28 -
 @@ -1307,7 +1307,6 @@ adb_setup_hw_type(void)
  
   case ADB_HW_PMU:
   adbSoftPower = 1;
 - pm_setup_adb();
   return;
  
   default:
 Index: dev/pm_direct.c
 ===
 RCS file: /cvs/src/sys/arch/macppc/dev/pm_direct.c,v
 retrieving revision 1.22
 diff -u -p -r1.22 pm_direct.c
 --- dev/pm_direct.c   18 Feb 2007 19:33:48 -  1.22
 +++ dev/pm_direct.c   3 May 2011 02:27:28 -
 @@ -54,10 +54,6 @@
  /* hardware dependent values */
  #define ADBDelay 

Re: man.conf, pick up ports manpages by default

2011-04-11 Thread Jasper Lievisse Adriaanse
On Mon, Apr 11, 2011 at 09:19:57AM +0100, Stuart Henderson wrote:
 it's useful for ports developers to be able to read the infrastructure
 manpages (dpb, pkg_subst, update-patches, etc) without making changes
 to the default configuration.
 
 as with X11R6, this fails cleanly if the relevant directories are not
 present.
 
 ok?
Certainly OK with me, this would be one less local modification for me.
Please get another OK too though.

 Index: man.conf
 ===
 RCS file: /cvs/src/etc/man.conf,v
 retrieving revision 1.16
 diff -u -p -r1.16 man.conf
 --- man.conf  19 Oct 2010 20:05:52 -  1.16
 +++ man.conf  11 Apr 2011 08:04:16 -
 @@ -31,7 +31,7 @@ _build  .tbl.gz /usr/bin/gzcat %s | /us
  # directory with all of the subdirectories listed for the keyword _subdir.
  
  # default
 -_default /usr/{share,X11R6,local}/man/
 +_default /usr/{share,X11R6,local,ports/infrastructure}/man/
  
  # Other sections that represent complete man subdirectories.
  X11  /usr/X11R6/man/
 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: pmap prefer diff

2011-04-06 Thread Jasper Lievisse Adriaanse
On Tue, Apr 05, 2011 at 06:42:47PM +0200, Ariane van der Steldt wrote:
 Hi,
 
 So it turns out that my allocator is not capable of handling the pmap_prefer
 horror. This diff exports the actual parameters of pmap_prefer, so I can
 make the allocator deal with this intelligently.
 
 I need compile tests on:
 - arm
 - hppa
 - hppa64
 - m68k
 - mips64
 - sh
 - sparc
 - sparc64
 Since the code is not actually called, it should not affect running of 
 kernels.
 
 Ok?
 -- 
 Ariane
Compiles fine on sh with a small tweak of using
vaddr_t  pmap_prefer_align(void);
instead of 
vaddr_t  pmap_prefer_align();


 Index: arch//arm/include/pmap.h
 ===
 RCS file: /cvs/src/sys/arch/arm/include/pmap.h,v
 retrieving revision 1.17
 diff -u -d -p -r1.17 pmap.h
 --- arch//arm/include/pmap.h  23 Mar 2011 16:54:34 -  1.17
 +++ arch//arm/include/pmap.h  5 Apr 2011 16:30:58 -
 @@ -620,6 +620,14 @@ vaddr_t  pmap_prefer(vaddr_t, vaddr_t);
  
  extern uint32_t pmap_alias_dist;
  extern uint32_t pmap_alias_bits;
 +
 +/* pmap prefer alias alignment. */
 +#define PMAP_PREFER_ALIGN()  (pmap_alias_dist)
 +/* pmap prefer offset withing alignment. */
 +#define PMAP_PREFER_OFFSET(of)   
 \
 +(PMAP_PREFER_ALIGN() == 0 ? 0 : ((of)  (PMAP_PREFER_ALIGN() - 1)))
 +
 +
  #endif /* _LOCORE */
  
  #endif /* _KERNEL */
 Index: arch//hppa/include/pmap.h
 ===
 RCS file: /cvs/src/sys/arch/hppa/include/pmap.h,v
 retrieving revision 1.40
 diff -u -d -p -r1.40 pmap.h
 --- arch//hppa/include/pmap.h 26 Dec 2010 15:40:59 -  1.40
 +++ arch//hppa/include/pmap.h 5 Apr 2011 16:30:59 -
 @@ -101,6 +101,11 @@ pmap_prefer(vaddr_t offs, vaddr_t hint)
   return pmap_prefer_hint;
  }
  
 +/* pmap prefer alignment */
 +#define PMAP_PREFER_ALIGN()  (HPPA_PGALIAS)
 +/* pmap prefer offset within alignment */
 +#define PMAP_PREFER_OFFSET(of)   ((of)  HPPA_PGAOFF)
 +
  #define  pmap_sid2pid(s) (((s) + 1)  1)
  #define pmap_kernel()(kernel_pmap_store)
  #define  pmap_resident_count(pmap)   
 ((pmap)-pm_stats.resident_count)
 Index: arch//hppa64/include/pmap.h
 ===
 RCS file: /cvs/src/sys/arch/hppa64/include/pmap.h,v
 retrieving revision 1.4
 diff -u -d -p -r1.4 pmap.h
 --- arch//hppa64/include/pmap.h   26 Dec 2010 15:40:59 -  1.4
 +++ arch//hppa64/include/pmap.h   5 Apr 2011 16:30:59 -
 @@ -68,6 +68,11 @@ pmap_prefer(vaddr_t offs, vaddr_t hint)
   return pmap_prefer_hint;
  }
  
 +/* pmap prefer alignment */
 +#define PMAP_PREFER_ALIGN()  (HPPA_PGALIAS)
 +/* pmap prefer offset within alignment */
 +#define PMAP_PREFER_OFFSET(of)   ((of)  HPPA_PGAOFF)
 +
  #define  PMAP_GROWKERNEL
  #define  PMAP_STEAL_MEMORY
  
 Index: arch//m68k/include/pmap_motorola.h
 ===
 RCS file: /cvs/src/sys/arch/m68k/include/pmap_motorola.h,v
 retrieving revision 1.22
 diff -u -d -p -r1.22 pmap_motorola.h
 --- arch//m68k/include/pmap_motorola.h23 Mar 2011 16:54:35 -  
 1.22
 +++ arch//m68k/include/pmap_motorola.h5 Apr 2011 16:30:59 -
 @@ -139,6 +139,12 @@ void pmap_kenter_cache(vaddr_t, paddr_t,
  #ifdef M68K_MMU_HP
  vaddr_t  pmap_prefer(vaddr_t, vaddr_t);
  #define  PMAP_PREFER(foff, va)   pmap_prefer((foff), (va))
 +
 +extern int   pmap_aliasmask; /* separation at which VA aliasing is ok */
 +/* pmap prefer alignment */
 +#define PMAP_PREFER_ALIGN()  (pmap_aliasmask ? pmap_aliasmask + 1 : 0)
 +/* pmap prefer offset */
 +#define PMAP_PREFER_OFFSET(of)   ((of)  pmap_aliasmask)
  #endif
  
  #endif   /* _KERNEL */
 Index: arch//m68k/m68k/pmap_motorola.c
 ===
 RCS file: /cvs/src/sys/arch/m68k/m68k/pmap_motorola.c,v
 retrieving revision 1.59
 diff -u -d -p -r1.59 pmap_motorola.c
 --- arch//m68k/m68k/pmap_motorola.c   6 Dec 2010 20:57:16 -   1.59
 +++ arch//m68k/m68k/pmap_motorola.c   5 Apr 2011 16:30:59 -
 @@ -276,9 +276,6 @@ vaddr_t   virtual_end;/* VA of last avai
  TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist;
  int  pv_nfree;
  
 -#if defined(M68K_MMU_HP)
 -extern int   pmap_aliasmask; /* separation at which VA aliasing is ok */
 -#endif
  #if defined(M68040) || defined(M68060)
  int  protostfree;/* prototype (default) free ST map */
  #endif
 Index: arch//mips64/include/pmap.h
 ===
 RCS file: /cvs/src/sys/arch/mips64/include/pmap.h,v
 retrieving revision 1.25
 diff -u -d -p -r1.25 pmap.h
 --- arch//mips64/include/pmap.h   23 Mar 2011 16:54:36 -  1.25
 +++ arch//mips64/include/pmap.h   5 Apr 2011 16:30:59 -
 @@ -125,6 +125,13 @@ extern 

Re: azalia(4) resume diff

2011-03-01 Thread Jasper Lievisse Adriaanse
On Mon, Feb 28, 2011 at 08:56:57PM -0500, Brad wrote:
 On Mon, Feb 28, 2011 at 11:16:49PM +, Jacob Meuser wrote:
  some ATI azalia controllers are brojen after resume, as in PR 6550.
  the following diff gathers most of the pci conf register manipulation
  done in azalia_pci_attach() into a new function, azalia_configure_pci(),
  and calls that function in azalia_pci_attach() and azalia_resume().
  
  this fixes one reported case of post-resume brokenness and doesn't
  cause any problems on other machines I've tested on, including an
  ATI device that was working.  waiting to hear back about the PR and
  other reports, but wanted to get this out for testing asap.
  
  please test.  thanks.
 
 This doesn't change anything about the symptom mentioned in the PR
 and its still broken after resume.
FWIW it does fix suspend for me on my desktop. Without this diff everything
comes back properly, except for audio which sounds like stuttering static.
With this diff my desktop behaves like my laptop when it comes to audio, just
works.

 -- 
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.
 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: YP=no in mk.conf and ypldap

2011-02-09 Thread Jasper Lievisse Adriaanse
On Wed, Feb 09, 2011 at 02:48:54PM -0500, Ted Unangst wrote:
 On Wed, Feb 9, 2011 at 3:00 AM, Dinar Talypov di...@yantel.ru wrote:
  While building system with YP=no set in mk.conf
  I have found a bug: ypldap depends on yp in libc.
 
 Thanks, I should be able to commit this later tonight.
I committed it some hours ago already.

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: recieve - receive (sys/)

2011-01-21 Thread Jasper Lievisse Adriaanse
The pxe.h defines are unused elsewhere, btw.


On Thu, Jan 20, 2011 at 11:35:34PM +0100, Jasper Lievisse Adriaanse wrote:
 Hi,
 
 Obvious typo, though the pxe.h parts may have to wait untill after the lock?
 Otherwise OK?
 
 -- 
 Cheers,
 Jasper
 
 Capable, generous men do not create victims, they nurture them.
 
 Index: arch/i386/stand/libsa/pxe.h
 ===
 RCS file: /cvs/src/sys/arch/i386/stand/libsa/pxe.h,v
 retrieving revision 1.5
 diff -p -u -r1.5 pxe.h
 --- arch/i386/stand/libsa/pxe.h   20 Nov 2010 20:11:19 -  1.5
 +++ arch/i386/stand/libsa/pxe.h   20 Jan 2011 22:30:49 -
 @@ -330,7 +330,7 @@ typedef struct {
   PXENV_STATUS_t  Status;
   uint16_tFuncFlag;   /* PXENV_UNDI_ISR_OUT_xxx */
   uint16_tBufferLength;   /* Length of Frame */
 - uint16_tFrameLength;/* Total length of reciever
 + uint16_tFrameLength;/* Total length of receiver
  frame */
   uint16_tFrameHeaderLength;  /* Length of the media header
  in Frame */
 @@ -351,7 +351,7 @@ typedef struct {
*/
  #define PXENV_UNDI_ISR_OUT_DONE  0
  #define PXENV_UNDI_ISR_OUT_TRANSMIT  2
 -#define PXENV_UNDI_ISR_OUT_RECIEVE   3
 +#define PXENV_UNDI_ISR_OUT_RECEIVE   3
  #define PXENV_UNDI_ISR_OUT_BUSY  4
  } __packed t_PXENV_UNDI_ISR;
  
 Index: arch/amd64/stand/libsa/pxe.h
 ===
 RCS file: /cvs/src/sys/arch/amd64/stand/libsa/pxe.h,v
 retrieving revision 1.5
 diff -p -u -r1.5 pxe.h
 --- arch/amd64/stand/libsa/pxe.h  20 Nov 2010 20:11:19 -  1.5
 +++ arch/amd64/stand/libsa/pxe.h  20 Jan 2011 22:30:49 -
 @@ -330,7 +330,7 @@ typedef struct {
   PXENV_STATUS_t  Status;
   uint16_tFuncFlag;   /* PXENV_UNDI_ISR_OUT_xxx */
   uint16_tBufferLength;   /* Length of Frame */
 - uint16_tFrameLength;/* Total length of reciever
 + uint16_tFrameLength;/* Total length of receiver
  frame */
   uint16_tFrameHeaderLength;  /* Length of the media header
  in Frame */
 @@ -351,7 +351,7 @@ typedef struct {
*/
  #define PXENV_UNDI_ISR_OUT_DONE  0
  #define PXENV_UNDI_ISR_OUT_TRANSMIT  2
 -#define PXENV_UNDI_ISR_OUT_RECIEVE   3
 +#define PXENV_UNDI_ISR_OUT_RECEIVE   3
  #define PXENV_UNDI_ISR_OUT_BUSY  4
  } __packed t_PXENV_UNDI_ISR;
  
 Index: dev/pci/drm/drmP.h
 ===
 RCS file: /cvs/src/sys/dev/pci/drm/drmP.h,v
 retrieving revision 1.126
 diff -p -u -r1.126 drmP.h
 --- dev/pci/drm/drmP.h18 Jul 2010 21:01:06 -  1.126
 +++ dev/pci/drm/drmP.h20 Jan 2011 22:30:49 -
 @@ -324,7 +324,7 @@ struct drm_vblank_info {
   u_int32_tvb_max;/* counter reg size */
   struct drm_vblank {
   struct drmevlist vbl_events;/* vblank events */
 - u_int32_tvbl_last;  /* Last recieved */
 + u_int32_tvbl_last;  /* Last received */
   u_int32_tvbl_count; /* interrupt no. */
   int  vbl_refs;  /* Number of users */
   int  vbl_enabled;   /* Enabled? */
 Index: dev/usb/utwitch.c
 ===
 RCS file: /cvs/src/sys/dev/usb/utwitch.c,v
 retrieving revision 1.2
 diff -p -u -r1.2 utwitch.c
 --- dev/usb/utwitch.c 19 Dec 2010 21:32:58 -  1.2
 +++ dev/usb/utwitch.c 20 Jan 2011 22:30:49 -
 @@ -250,7 +250,7 @@ utwitch_intr(struct uhidev *addr, void *
   switch (buf[0]) {
   case CMD_ACK:
   if (buf[1] == sc-issueing_cmd) {
 - DPRINTF((ack recieved for cmd 0x%.2x\n, buf[1]));
 + DPRINTF((ack received for cmd 0x%.2x\n, buf[1]));
   sc-accepted_cmd = buf[1];
   } else {
   DPRINTF((cmd-ack mismatch: recved 0x%.2x, expect 
 0x%.2x\n,
 

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



zap some dead code from bdes(1)

2011-01-20 Thread Jasper Lievisse Adriaanse
As per subject, since #define something test for in the very next line, makes
it clear the other code can go. No binary change of course. OK?

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.

Index: bdes.c
===
RCS file: /cvs/src/usr.bin/bdes/bdes.c,v
retrieving revision 1.16
diff -p -u -r1.16 bdes.c
--- bdes.c  27 Oct 2009 23:59:36 -  1.16
+++ bdes.c  20 Jan 2011 18:22:08 -
@@ -102,31 +102,12 @@ void  usage(void);
 #defineMEMZERO(dest,len)   bzero((dest),(len))
 
 /* Hide the calls to the primitive encryption routines. */
-#defineFASTWAY
-#ifdef FASTWAY
 #defineDES_KEY(buf) \
if (des_setkey(buf)) \
err(1, des_setkey);
 #defineDES_XFORM(buf) \
if (des_cipher(buf, buf, 0L, (inverse ? -1 : 1))) \
err(1, des_cipher);
-#else
-#defineDES_KEY(buf){   
\
-   char bits1[64]; /* bits of key */   \
-   expand(buf, bits1); \
-   if (setkey(bits1))  \
-   err(1, setkey);   \
-   }
-#defineDES_XFORM(buf)  {   
\
-   char bits1[64]; /* bits of message */   \
-   expand(buf, bits1); \
-   if (encrypt(bits1, inverse))\
-   err(1, encrypt);  \
-   compress(bits1, buf);   \
-   }
-void   expand(Desbuf, char *);
-void   compress(Desbuf, char *);
-#endif
 
 /*
  * this does an error-checking write
@@ -1009,36 +990,6 @@ cfbauth(void)
(void)putchar(CHAR(msgbuf, 0));
}
 }
-
-#ifndef FASTWAY
-/*
- * change from 8 bits/Uchar to 1 bit/Uchar
- */
-void
-expand(Desbuf from, char *to)
-{
-   int i, j;   /* counters in for loop */
-
-   for (i = 0; i  8; i++)
-   for (j = 0; j  8; j++)
-   *to++ = (CHAR(from, i)(7-j))01;
-}
-
-/*
- * change from 1 bit/char to 8 bits/Uchar
- */
-void
-compress(char *from, Desbuf to)
-{
-   int i, j;   /* counters in for loop */
-
-   for (i = 0; i  8; i++) {
-   CHAR(to, i) = 0;
-   for (j = 0; j  8; j++)
-   CHAR(to, i) = ((*from++)(7-j))|CHAR(to, i);
-   }
-}
-#endif
 
 extern char *__progname;
 /*



recieve - receive (sys/)

2011-01-20 Thread Jasper Lievisse Adriaanse
Hi,

Obvious typo, though the pxe.h parts may have to wait untill after the lock?
Otherwise OK?

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.

Index: arch/i386/stand/libsa/pxe.h
===
RCS file: /cvs/src/sys/arch/i386/stand/libsa/pxe.h,v
retrieving revision 1.5
diff -p -u -r1.5 pxe.h
--- arch/i386/stand/libsa/pxe.h 20 Nov 2010 20:11:19 -  1.5
+++ arch/i386/stand/libsa/pxe.h 20 Jan 2011 22:30:49 -
@@ -330,7 +330,7 @@ typedef struct {
PXENV_STATUS_t  Status;
uint16_tFuncFlag;   /* PXENV_UNDI_ISR_OUT_xxx */
uint16_tBufferLength;   /* Length of Frame */
-   uint16_tFrameLength;/* Total length of reciever
+   uint16_tFrameLength;/* Total length of receiver
   frame */
uint16_tFrameHeaderLength;  /* Length of the media header
   in Frame */
@@ -351,7 +351,7 @@ typedef struct {
 */
 #  define PXENV_UNDI_ISR_OUT_DONE  0
 #  define PXENV_UNDI_ISR_OUT_TRANSMIT  2
-#  define PXENV_UNDI_ISR_OUT_RECIEVE   3
+#  define PXENV_UNDI_ISR_OUT_RECEIVE   3
 #  define PXENV_UNDI_ISR_OUT_BUSY  4
 } __packed t_PXENV_UNDI_ISR;
 
Index: arch/amd64/stand/libsa/pxe.h
===
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/pxe.h,v
retrieving revision 1.5
diff -p -u -r1.5 pxe.h
--- arch/amd64/stand/libsa/pxe.h20 Nov 2010 20:11:19 -  1.5
+++ arch/amd64/stand/libsa/pxe.h20 Jan 2011 22:30:49 -
@@ -330,7 +330,7 @@ typedef struct {
PXENV_STATUS_t  Status;
uint16_tFuncFlag;   /* PXENV_UNDI_ISR_OUT_xxx */
uint16_tBufferLength;   /* Length of Frame */
-   uint16_tFrameLength;/* Total length of reciever
+   uint16_tFrameLength;/* Total length of receiver
   frame */
uint16_tFrameHeaderLength;  /* Length of the media header
   in Frame */
@@ -351,7 +351,7 @@ typedef struct {
 */
 #  define PXENV_UNDI_ISR_OUT_DONE  0
 #  define PXENV_UNDI_ISR_OUT_TRANSMIT  2
-#  define PXENV_UNDI_ISR_OUT_RECIEVE   3
+#  define PXENV_UNDI_ISR_OUT_RECEIVE   3
 #  define PXENV_UNDI_ISR_OUT_BUSY  4
 } __packed t_PXENV_UNDI_ISR;
 
Index: dev/pci/drm/drmP.h
===
RCS file: /cvs/src/sys/dev/pci/drm/drmP.h,v
retrieving revision 1.126
diff -p -u -r1.126 drmP.h
--- dev/pci/drm/drmP.h  18 Jul 2010 21:01:06 -  1.126
+++ dev/pci/drm/drmP.h  20 Jan 2011 22:30:49 -
@@ -324,7 +324,7 @@ struct drm_vblank_info {
u_int32_tvb_max;/* counter reg size */
struct drm_vblank {
struct drmevlist vbl_events;/* vblank events */
-   u_int32_tvbl_last;  /* Last recieved */
+   u_int32_tvbl_last;  /* Last received */
u_int32_tvbl_count; /* interrupt no. */
int  vbl_refs;  /* Number of users */
int  vbl_enabled;   /* Enabled? */
Index: dev/usb/utwitch.c
===
RCS file: /cvs/src/sys/dev/usb/utwitch.c,v
retrieving revision 1.2
diff -p -u -r1.2 utwitch.c
--- dev/usb/utwitch.c   19 Dec 2010 21:32:58 -  1.2
+++ dev/usb/utwitch.c   20 Jan 2011 22:30:49 -
@@ -250,7 +250,7 @@ utwitch_intr(struct uhidev *addr, void *
switch (buf[0]) {
case CMD_ACK:
if (buf[1] == sc-issueing_cmd) {
-   DPRINTF((ack recieved for cmd 0x%.2x\n, buf[1]));
+   DPRINTF((ack received for cmd 0x%.2x\n, buf[1]));
sc-accepted_cmd = buf[1];
} else {
DPRINTF((cmd-ack mismatch: recved 0x%.2x, expect 
0x%.2x\n,



recieve - receive (usr.sbin)

2011-01-20 Thread Jasper Lievisse Adriaanse
OK?

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.

Index: npppd/l2tp/l2tp_call.c
===
RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tp_call.c,v
retrieving revision 1.6
diff -p -u -r1.6 l2tp_call.c
--- npppd/l2tp/l2tp_call.c  24 Sep 2010 14:50:30 -  1.6
+++ npppd/l2tp/l2tp_call.c  20 Jan 2011 22:34:37 -
@@ -155,7 +155,7 @@ l2tp_call_disconnect(l2tp_call *_this, i
  * control packet
  */
 
-/* call it when control packet is recieved */
+/* call it when control packet is received */
 int
 l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
 u_char *pkt, int pktlen)
Index: npppd/l2tp/l2tp_ctrl.c
===
RCS file: /cvs/src/usr.sbin/npppd/l2tp/l2tp_ctrl.c,v
retrieving revision 1.5
diff -p -u -r1.5 l2tp_ctrl.c
--- npppd/l2tp/l2tp_ctrl.c  24 Sep 2010 14:50:30 -  1.5
+++ npppd/l2tp/l2tp_ctrl.c  20 Jan 2011 22:34:38 -
@@ -535,7 +535,7 @@ l2tp_ctrl_timeout(int fd, short evtype, 
curr_time - _this-last_snd_ctrl =
L2TP_CTRL_WAIT_CALL_TIMEOUT) {
if (_this-ncalls == 0)
-   /* fail to recieve first call */
+   /* fail to receive first call */
l2tp_ctrl_log(_this, LOG_WARNING,
timeout waiting call);
l2tp_ctrl_stop(_this,
@@ -706,7 +706,7 @@ l2tp_ctrl_reset_timeout(l2tp_ctrl *_this
 /*
  * protocols / send and receive
  */
-/* Recieve packet */
+/* Receive packet */
 void
 l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
 struct sockaddr *sock, void *nat_t_ctx, u_char *pkt, int pktlen)
@@ -1037,7 +1037,7 @@ l2tp_ctrl_input(l2tpd *_this, int listen
/*
 * RFC specifies that sent of StopCCN in the state,
 * However as this implementation only support Passive
-* open, this packet will not recieved.
+* open, this packet will not received.
 */
/* FALLTHROUGH */
case L2TP_AVP_MESSAGE_TYPE_SCCCN:
Index: npppd/npppd/eap.c
===
RCS file: /cvs/src/usr.sbin/npppd/npppd/eap.c,v
retrieving revision 1.5
diff -p -u -r1.5 eap.c
--- npppd/npppd/eap.c   22 Sep 2010 11:48:38 -  1.5
+++ npppd/npppd/eap.c   20 Jan 2011 22:34:38 -
@@ -236,7 +236,7 @@ eap_input(eap *_this, unsigned char *pkt
if (code == EAP_FAILURE) {
/* discard */
eap_log(_this, LOG_NOTICE,
-   Recieved unexpected packet from peer (code = %d), code);
+   Received unexpected packet from peer (code = %d), code);
return;
}
 
@@ -292,11 +292,11 @@ eap_input(eap *_this, unsigned char *pkt
  * discard
  */
eap_log(_this, LOG_DEBUG,
-   recieve eap length = %d, 
+   receive eap length = %d, 
eap info: code = %d, id = %d, length = %d, type = %d, 
name length = %d,
len, code, id, length, type, _this-name_len );
-eap_log(_this, LOG_NOTICE, Recieved unexpected eap packet from peer);
+eap_log(_this, LOG_NOTICE, Received unexpected eap packet from peer);
return;
 }
 
Index: npppd/pptp/pptp.h
===
RCS file: /cvs/src/usr.sbin/npppd/pptp/pptp.h,v
retrieving revision 1.4
diff -p -u -r1.4 pptp.h
--- npppd/pptp/pptp.h   2 Jul 2010 21:20:57 -   1.4
+++ npppd/pptp/pptp.h   20 Jan 2011 22:34:38 -
@@ -300,7 +300,7 @@ typedef struct _pptp_call {
pptp_ctrl   *ctrl; /* parent */
unsignedid;
 
-   int ifidx; /* recieve interface index */
+   int ifidx; /* receive interface index */
 
int state;
 
@@ -310,8 +310,8 @@ typedef struct _pptp_call {
uint32_tsnd_una;/* next ack notification */
uint32_tsnd_nxt;/* next transmit sequence # */
 
-   uint32_trcv_nxt;/* recieved sequence # */
-   uint32_trcv_acked;  /* latest acked recieved sequence # */
+   uint32_trcv_nxt;/* received sequence # */
+   uint32_trcv_acked;  /* latest acked received sequence # */
 
int winsz;  /* current window size */
int maxwinsz;   /* maximum window size */
Index: npppd/pptp/pptpd.c
===
RCS file: /cvs/src/usr.sbin/npppd/pptp/pptpd.c,v
retrieving revision 1.7
diff -p -u -r1.7 pptpd.c
--- npppd/pptp/pptpd.c  27 Sep 2010 00:12:16 -  1.7
+++ 

Re: Workaround for data corruption issue with ALI M5229 IDE chip used with Sun Blade 100/Netra X1.

2011-01-13 Thread Jasper Lievisse Adriaanse
On Wed, Jan 12, 2011 at 08:32:12PM -0500, Brad wrote:
 The following diff is ported from NetBSD (the workaround originated from
 OpenSolaris) to workaround the issue of data corruption with the ALI M5229
 IDE chipset when using UltraDMA. Same workaround is also used by 
 FreeBSD/Linux.
 This chipset is found in some sparc64 systems such as the Blade 100 and
 Netra X1.
As well as Blade 1500, Fire T200, Fire v120 and Fire v210..

 I don't have any such systems but I went digging for this being curious
 why the nasty hack was added to the kernel configs to disable UltraDMA
 to workaround this bug and thus penalizing other IDE/SATA controllers
 that could be in the same system. If you have one of the mentioned
 systems please test this.
 
 
 Index: dev/pci/pciide.c
 ===
 RCS file: /home/cvs/src/sys/dev/pci/pciide.c,v
 retrieving revision 1.323
 diff -u -p -r1.323 pciide.c
 --- dev/pci/pciide.c  18 Nov 2010 18:12:52 -  1.323
 +++ dev/pci/pciide.c  13 Jan 2011 00:22:14 -
 @@ -212,6 +212,8 @@ void natsemi_irqack(struct channel_softc
  void ns_scx200_chip_map(struct pciide_softc *, struct pci_attach_args *);
  void ns_scx200_setup_channel(struct channel_softc *);
  
 +int acer_pcib_match(struct pci_attach_args *);
 +void acer_do_reset(struct channel_softc *);
  void acer_chip_map(struct pciide_softc *, struct pci_attach_args *);
  void acer_setup_channel(struct channel_softc *);
  int  acer_pci_intr(void *);
 @@ -289,6 +291,11 @@ struct pciide_product_desc {
   void (*chip_map)(struct pciide_softc *, struct pci_attach_args *);
  };
  
 +struct pciide_acer_softc {
 + struct pciide_softc pciide_sc;
 + struct pci_attach_args pcib_pa;
 +};
 +
  /* Flags for ide_flags */
  #define IDE_PCI_CLASS_OVERRIDE   0x0001  /* accept even if class != 
 pciide */
  #define IDE_16BIT_IOSPACE0x0002  /* I/O space BARS ignore upper word */
 @@ -5619,10 +5626,27 @@ ns_scx200_setup_channel(struct channel_s
   pciide_print_modes(cp);
  }
  
 +int
 +acer_pcib_match(struct pci_attach_args *pa)
 +{
 + /*
 +  * We need to access the PCI config space of the pcib, see
 +  * acer_do_reset().
 +  */
 + if (PCI_CLASS(pa-pa_class) == PCI_CLASS_BRIDGE 
 + PCI_SUBCLASS(pa-pa_class) == PCI_SUBCLASS_BRIDGE_ISA 
 + PCI_VENDOR(pa-pa_id) == PCI_VENDOR_ALI 
 + PCI_PRODUCT(pa-pa_id) == PCI_PRODUCT_ALI_M1533)
 + return (1);
 +
 + return (0);
 +}
 +
  void
  acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
  {
   struct pciide_channel *cp;
 + struct pciide_acer_softc *acer_sc = (struct pciide_acer_softc *)sc;
   int channel;
   pcireg_t cr, interface;
   bus_size_t cmdsize, ctlsize;
 @@ -5684,6 +5708,12 @@ acer_chip_map(struct pciide_softc *sc, s
   pciide_pci_read(sc-sc_pc, sc-sc_tag, ACER_0x4B)
   | ACER_0x4B_CDETECT);
  
 + if (rev == 0xC3) {
 + /* Install reset bug workaround */
 + if (pci_find_device(acer_sc-pcib_pa, acer_pcib_match))
 + sc-sc_wdcdev.reset = acer_do_reset;
 + }
 +
   for (channel = 0; channel  sc-sc_wdcdev.nchannels; channel++) {
   cp = sc-pciide_channels[channel];
   if (pciide_chansetup(sc, channel, interface) == 0)
 @@ -5713,6 +5743,31 @@ acer_chip_map(struct pciide_softc *sc, s
   }
   acer_setup_channel(cp-wdc_channel);
   }
 +}
 +
 +void
 +acer_do_reset(struct channel_softc *chp)
 +{
 + struct pciide_channel *cp = (struct pciide_channel *)chp;
 + struct pciide_softc *sc = (struct pciide_softc *)cp-wdc_channel.wdc;
 + struct pciide_acer_softc *acer_sc = (struct pciide_acer_softc *)sc;
 + u_int8_t reg;
 +
 + /*
 +  * From OpenSolaris: after a reset we need to disable/enable the
 +  * corresponding channel, or data corruption will occur in
 +  * UltraDMA modes.
 +  */
 +
 + wdc_do_reset(chp);
 +
 + reg = pciide_pci_read(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
 + ACER_PCIB_CTRL);
 + pciide_pci_write(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
 + ACER_PCIB_CTRL, reg  ~ACER_PCIB_CTRL_ENCHAN(chp-channel));
 + delay(1000);
 + pciide_pci_write(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
 + ACER_PCIB_CTRL, reg);
  }
  
  void
 Index: dev/pci/pciide_acer_reg.h
 ===
 RCS file: /home/cvs/src/sys/dev/pci/pciide_acer_reg.h,v
 retrieving revision 1.8
 diff -u -p -r1.8 pciide_acer_reg.h
 --- dev/pci/pciide_acer_reg.h 23 Jul 2010 07:47:13 -  1.8
 +++ dev/pci/pciide_acer_reg.h 12 Jan 2011 05:14:26 -
 @@ -89,6 +89,10 @@
  #define ACER_0x79_REVC2_EN   0x4
  #define ACER_0x79_EN 0x2
  
 +/* OpenSolaris: channel enable/disable in the PCI-ISA bridge */
 +#define ACER_PCIB_CTRL   0x58
 +#define ACER_PCIB_CTRL_ENCHAN(chan) (0x4  (chan))
 +
  /*
 

Re: Workaround for data corruption issue with ALI M5229 IDE chip used with Sun Blade 100/Netra X1.

2011-01-13 Thread Jasper Lievisse Adriaanse
On Thu, Jan 13, 2011 at 09:02:26AM +0100, Jasper Lievisse Adriaanse wrote:
 On Wed, Jan 12, 2011 at 08:32:12PM -0500, Brad wrote:
  The following diff is ported from NetBSD (the workaround originated from
  OpenSolaris) to workaround the issue of data corruption with the ALI M5229
  IDE chipset when using UltraDMA. Same workaround is also used by 
  FreeBSD/Linux.
  This chipset is found in some sparc64 systems such as the Blade 100 and
  Netra X1.
 As well as Blade 1500, Fire T200, Fire v120 and Fire v210..
 
  I don't have any such systems but I went digging for this being curious
  why the nasty hack was added to the kernel configs to disable UltraDMA
  to workaround this bug and thus penalizing other IDE/SATA controllers
  that could be in the same system. If you have one of the mentioned
  systems please test this.
Fwiw, my X1 is still working fine.

  Index: dev/pci/pciide.c
  ===
  RCS file: /home/cvs/src/sys/dev/pci/pciide.c,v
  retrieving revision 1.323
  diff -u -p -r1.323 pciide.c
  --- dev/pci/pciide.c18 Nov 2010 18:12:52 -  1.323
  +++ dev/pci/pciide.c13 Jan 2011 00:22:14 -
  @@ -212,6 +212,8 @@ void natsemi_irqack(struct channel_softc
   void ns_scx200_chip_map(struct pciide_softc *, struct pci_attach_args *);
   void ns_scx200_setup_channel(struct channel_softc *);
   
  +int acer_pcib_match(struct pci_attach_args *);
  +void acer_do_reset(struct channel_softc *);
   void acer_chip_map(struct pciide_softc *, struct pci_attach_args *);
   void acer_setup_channel(struct channel_softc *);
   int  acer_pci_intr(void *);
  @@ -289,6 +291,11 @@ struct pciide_product_desc {
  void (*chip_map)(struct pciide_softc *, struct pci_attach_args *);
   };
   
  +struct pciide_acer_softc {
  +   struct pciide_softc pciide_sc;
  +   struct pci_attach_args pcib_pa;
  +};
  +
   /* Flags for ide_flags */
   #define IDE_PCI_CLASS_OVERRIDE 0x0001  /* accept even if class != 
  pciide */
   #define IDE_16BIT_IOSPACE  0x0002  /* I/O space BARS ignore upper word */
  @@ -5619,10 +5626,27 @@ ns_scx200_setup_channel(struct channel_s
  pciide_print_modes(cp);
   }
   
  +int
  +acer_pcib_match(struct pci_attach_args *pa)
  +{
  +   /*
  +* We need to access the PCI config space of the pcib, see
  +* acer_do_reset().
  +*/
  +   if (PCI_CLASS(pa-pa_class) == PCI_CLASS_BRIDGE 
  +   PCI_SUBCLASS(pa-pa_class) == PCI_SUBCLASS_BRIDGE_ISA 
  +   PCI_VENDOR(pa-pa_id) == PCI_VENDOR_ALI 
  +   PCI_PRODUCT(pa-pa_id) == PCI_PRODUCT_ALI_M1533)
  +   return (1);
  +
  +   return (0);
  +}
  +
   void
   acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
   {
  struct pciide_channel *cp;
  +   struct pciide_acer_softc *acer_sc = (struct pciide_acer_softc *)sc;
  int channel;
  pcireg_t cr, interface;
  bus_size_t cmdsize, ctlsize;
  @@ -5684,6 +5708,12 @@ acer_chip_map(struct pciide_softc *sc, s
  pciide_pci_read(sc-sc_pc, sc-sc_tag, ACER_0x4B)
  | ACER_0x4B_CDETECT);
   
  +   if (rev == 0xC3) {
  +   /* Install reset bug workaround */
  +   if (pci_find_device(acer_sc-pcib_pa, acer_pcib_match))
  +   sc-sc_wdcdev.reset = acer_do_reset;
  +   }
  +
  for (channel = 0; channel  sc-sc_wdcdev.nchannels; channel++) {
  cp = sc-pciide_channels[channel];
  if (pciide_chansetup(sc, channel, interface) == 0)
  @@ -5713,6 +5743,31 @@ acer_chip_map(struct pciide_softc *sc, s
  }
  acer_setup_channel(cp-wdc_channel);
  }
  +}
  +
  +void
  +acer_do_reset(struct channel_softc *chp)
  +{
  +   struct pciide_channel *cp = (struct pciide_channel *)chp;
  +   struct pciide_softc *sc = (struct pciide_softc *)cp-wdc_channel.wdc;
  +   struct pciide_acer_softc *acer_sc = (struct pciide_acer_softc *)sc;
  +   u_int8_t reg;
  +
  +   /*
  +* From OpenSolaris: after a reset we need to disable/enable the
  +* corresponding channel, or data corruption will occur in
  +* UltraDMA modes.
  +*/
  +
  +   wdc_do_reset(chp);
  +
  +   reg = pciide_pci_read(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
  +   ACER_PCIB_CTRL);
  +   pciide_pci_write(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
  +   ACER_PCIB_CTRL, reg  ~ACER_PCIB_CTRL_ENCHAN(chp-channel));
  +   delay(1000);
  +   pciide_pci_write(acer_sc-pcib_pa.pa_pc, acer_sc-pcib_pa.pa_tag,
  +   ACER_PCIB_CTRL, reg);
   }
   
   void
  Index: dev/pci/pciide_acer_reg.h
  ===
  RCS file: /home/cvs/src/sys/dev/pci/pciide_acer_reg.h,v
  retrieving revision 1.8
  diff -u -p -r1.8 pciide_acer_reg.h
  --- dev/pci/pciide_acer_reg.h   23 Jul 2010 07:47:13 -  1.8
  +++ dev/pci/pciide_acer_reg.h   12 Jan 2011 05:14:26 -
  @@ -89,6 +89,10 @@
   #define ACER_0x79_REVC2_EN 0x4
   #define ACER_0x79_EN   0x2

config -b needs -s (and visa versa)?

2011-01-05 Thread Jasper Lievisse Adriaanse
Right now, config doesn't work when either -b or -s is specified. It does work
when both or none are specified. Does anyone know what the correct behaviour
should be?

Here is a diff that would at least make this behaviour explicit (if correct, 
OK?).

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.

Index: config.8
===
RCS file: /cvs/src/usr.sbin/config/config.8,v
retrieving revision 1.54
diff -p -u -r1.54 config.8
--- config.810 Dec 2009 22:07:19 -  1.54
+++ config.85 Jan 2011 13:33:28 -
@@ -39,8 +39,7 @@
 .Sh SYNOPSIS
 .Nm config
 .Op Fl p
-.Op Fl b Ar builddir
-.Op Fl s Ar srcdir
+.Op Fl b Ar builddir Fl s Ar srcdir
 .Op Ar config-file
 .Nm config
 .Op Fl u
Index: main.c
===
RCS file: /cvs/src/usr.sbin/config/main.c,v
retrieving revision 1.41
diff -p -u -r1.41 main.c
--- main.c  27 Oct 2009 23:59:51 -  1.41
+++ main.c  5 Jan 2011 13:33:29 -
@@ -84,7 +84,7 @@ usage(void)
extern char *__progname;
 
fprintf(stderr,
-   usage: %s [-p] [-b builddir] [-s srcdir] [config-file]\n
+   usage: %s [-p] [-b builddir -s srcdir] [config-file]\n
   %s [-u] [-f | -o outfile] -e infile\n,
__progname, __progname);
 
@@ -162,6 +162,12 @@ main(int argc, char *argv[])
argv += optind;
if (argc  1 || (eflag  argv[0] == NULL))
usage();
+
+   if ((builddir  !srcdir) || (!builddir  srcdir)) {
+   fprintf(stderr, config: both -b (builddir) and -s 
(sourcedir));
+   fprintf(stderr,  need to be specified\n);
+   usage();
+   }
 
if (eflag) {
 #ifdef MAKE_BOOTSTRAP



drops NENTS in favor of nitems

2010-12-06 Thread Jasper Lievisse Adriaanse
This diff drops another nitems() copy we have in tree, NENTS().
Compile tested on amd64, no binary change.
OK?

-- 
Cheers,
Jasper

During times of universal deceit,
 telling the truth becomes a revolutionary act.

Index: arch/alpha/stand/netboot/if_prom.c
===
RCS file: /cvs/src/sys/arch/alpha/stand/netboot/if_prom.c,v
retrieving revision 1.4
diff -p -u -r1.4 if_prom.c
--- arch/alpha/stand/netboot/if_prom.c  9 Mar 2008 12:03:03 -   1.4
+++ arch/alpha/stand/netboot/if_prom.c  6 Dec 2010 18:00:02 -
@@ -61,7 +61,7 @@ struct netif_dif prom_ifs[] = {
 {  0,  1,  prom_stats[0], 0,  },
 };
 
-struct netif_stats prom_stats[NENTS(prom_ifs)];
+struct netif_stats prom_stats[nitems(prom_ifs)];
 
 struct netbbinfo netbbinfo = {
0xfeedbabedeadbeef, /* magic number */
@@ -82,7 +82,7 @@ struct netif_driver prom_netif_driver = 
prom_put,   /* netif_put */
prom_end,   /* netif_end */
prom_ifs,   /* netif_ifs */
-   NENTS(prom_ifs) /* netif_nifs */
+   nitems(prom_ifs)/* netif_nifs */
 };
 
 int netfd, broken_firmware;
Index: arch/amd64/stand/boot/conf.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/boot/conf.c,v
retrieving revision 1.15
diff -p -u -r1.15 conf.c
--- arch/amd64/stand/boot/conf.c11 Aug 2010 14:18:52 -  1.15
+++ arch/amd64/stand/boot/conf.c6 Dec 2010 18:00:02 -
@@ -56,10 +56,10 @@ void (*i386_probe2[])(void) = {
 };
 
 struct i386_boot_probes probe_list[] = {
-   { probing, i386_probe1, NENTS(i386_probe1) },
-   { disk,i386_probe2, NENTS(i386_probe2) }
+   { probing, i386_probe1, nitems(i386_probe1) },
+   { disk,i386_probe2, nitems(i386_probe2) }
 };
-int nibprobes = NENTS(probe_list);
+int nibprobes = nitems(probe_list);
 
 
 struct fs_ops file_system[] = {
@@ -74,7 +74,7 @@ struct fs_ops file_system[] = {
  cd9660_stat, cd9660_readdir },
 #endif
 };
-int nfsys = NENTS(file_system);
+int nfsys = nitems(file_system);
 
 struct devsw   devsw[] = {
{ BIOS, biosstrategy, biosopen, biosclose, biosioctl },
@@ -82,7 +82,7 @@ struct devsw  devsw[] = {
{ TFTP, tftpstrategy, tftpopen, tftpclose, tftpioctl },
 #endif
 };
-int ndevs = NENTS(devsw);
+int ndevs = nitems(devsw);
 
 struct consdev constab[] = {
{ pc_probe, pc_init, pc_getc, pc_putc },
Index: arch/amd64/stand/cdboot/conf.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/cdboot/conf.c,v
retrieving revision 1.15
diff -p -u -r1.15 conf.c
--- arch/amd64/stand/cdboot/conf.c  11 Aug 2010 14:18:52 -  1.15
+++ arch/amd64/stand/cdboot/conf.c  6 Dec 2010 18:00:02 -
@@ -57,10 +57,10 @@ void (*amd64_probe2[])(void) = {
 };
 
 struct i386_boot_probes probe_list[] = {
-   { probing, amd64_probe1, NENTS(amd64_probe1) },
-   { disk,amd64_probe2, NENTS(amd64_probe2) }
+   { probing, amd64_probe1, nitems(amd64_probe1) },
+   { disk,amd64_probe2, nitems(amd64_probe2) }
 };
-int nibprobes = NENTS(probe_list);
+int nibprobes = nitems(probe_list);
 
 struct fs_ops file_system[] = {
{ cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek,
@@ -76,12 +76,12 @@ struct fs_ops file_system[] = {
  fat_stat,fat_readdir},
 #endif
 };
-int nfsys = NENTS(file_system);
+int nfsys = nitems(file_system);
 
 struct devsw   devsw[] = {
{ BIOS, biosstrategy, biosopen, biosclose, biosioctl },
 };
-int ndevs = NENTS(devsw);
+int ndevs = nitems(devsw);
 
 struct consdev constab[] = {
{ pc_probe, pc_init, pc_getc, pc_putc },
Index: arch/amd64/stand/libsa/dev_i386.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/dev_i386.c,v
retrieving revision 1.3
diff -p -u -r1.3 dev_i386.c
--- arch/amd64/stand/libsa/dev_i386.c   27 Jun 2007 20:29:37 -  1.3
+++ arch/amd64/stand/libsa/dev_i386.c   6 Dec 2010 18:00:02 -
@@ -38,13 +38,13 @@ const char bdevs[][4] = {
wd, , fd, , sd, st, cd, mcd,
, , , , , , , scd, , hd, 
 };
-const int nbdevs = NENTS(bdevs);
+const int nbdevs = nitems(bdevs);
 
 const char cdevs[][4] = {
cn, , , , , , , ,
com, , , , pc
 };
-const int ncdevs = NENTS(cdevs);
+const int ncdevs = nitems(cdevs);
 
 /* pass dev_t to the open routines */
 int
Index: arch/amd64/stand/libsa/memprobe.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/memprobe.c,v
retrieving revision 1.7
diff -p -u -r1.7 memprobe.c
--- arch/amd64/stand/libsa/memprobe.c   2 Jul 2010 00:36:52 -   1.7
+++ arch/amd64/stand/libsa/memprobe.c   6 Dec 2010 18:00:03 -
@@ -221,14 +221,14 @@ addrprobe(u_int kloc)
 {
__volatile 

Consistent 'include' rules in 'files.' files.

2010-12-06 Thread Jasper Lievisse Adriaanse
As per subject, tested on amd64/macppc. OK?

-- 
Cheers,
Jasper

During times of universal deceit,
 telling the truth becomes a revolutionary act.

Index: alpha/conf/files.alpha
===
RCS file: /cvs/src/sys/arch/alpha/conf/files.alpha,v
retrieving revision 1.90
diff -p -u -r1.90 files.alpha
--- alpha/conf/files.alpha  30 Jun 2010 20:38:49 -  1.90
+++ alpha/conf/files.alpha  6 Dec 2010 18:53:05 -
@@ -35,7 +35,7 @@ major {vnd = 9}
 #
 # Media Independent Interface (mii)
 #
-include../../../dev/mii/files.mii
+includedev/mii/files.mii
 
 #
 # Machine-independent SCSI drivers
@@ -269,7 +269,7 @@ filedev/pci/if_hme_pci.chme_pci
 # ISA PnP
 #
 
-include../../../dev/isa/files.isapnp
+includedev/isa/files.isapnp
 file   arch/alpha/isa/isapnp_machdep.c isapnp
 
 #
Index: amd64/conf/files.amd64
===
RCS file: /cvs/src/sys/arch/amd64/conf/files.amd64,v
retrieving revision 1.59
diff -p -u -r1.59 files.amd64
--- amd64/conf/files.amd64  13 Nov 2010 04:16:42 -  1.59
+++ amd64/conf/files.amd64  6 Dec 2010 18:53:06 -
@@ -225,7 +225,7 @@ include dev/gpio/files.gpio
 #
 # ACPI
 #
-include ../../../dev/acpi/files.acpi
+include dev/acpi/files.acpi
 file   arch/amd64/amd64/acpi_machdep.c acpi
 file   arch/amd64/amd64/acpi_wakecode.Sacpi  !small_kernel
 
Index: armish/conf/files.armish
===
RCS file: /cvs/src/sys/arch/armish/conf/files.armish,v
retrieving revision 1.13
diff -p -u -r1.13 files.armish
--- armish/conf/files.armish16 May 2009 05:47:25 -  1.13
+++ armish/conf/files.armish6 Dec 2010 18:53:07 -
@@ -14,7 +14,7 @@ file  arch/armish/armish/armish_machdep.c
 file   arch/armish/armish/autoconf.c
 file   arch/arm/arm/disksubr.c disk
 
-include ../../../scsi/files.scsi
+include scsi/files.scsi
 
 # Use the generic ARM soft interrupt code.
 file   arch/arm/arm/softintr.c
@@ -67,11 +67,11 @@ include dev/bluetooth/files.bluetooth
 include dev/mii/files.mii
 
 # PCI
-include ../../../dev/pci/files.pci
+include dev/pci/files.pci
 file   arch/armish/dev/pciide_machdep.cpciide
 
-include ../../../dev/puc/files.puc
-include ../../../dev/atapiscsi/files.atapiscsi
+include dev/puc/files.puc
+include dev/atapiscsi/files.atapiscsi
 
 
 #
Index: aviion/conf/files.aviion
===
RCS file: /cvs/src/sys/arch/aviion/conf/files.aviion,v
retrieving revision 1.7
diff -p -u -r1.7 files.aviion
--- aviion/conf/files.aviion21 Apr 2010 19:33:47 -  1.7
+++ aviion/conf/files.aviion6 Dec 2010 18:53:07 -
@@ -35,7 +35,7 @@ file  arch/aviion/dev/if_ile_syscon.c i
 attach oosiop at syscon with oosiop_syscon
 file   arch/aviion/dev/oosiop_syscon.c oosiop_syscon
 
-include../../../scsi/files.scsi
+include scsi/files.scsi
 
 major  {sd = 4}
 major  {st = 5}
Index: beagle/conf/files.beagle
===
RCS file: /cvs/src/sys/arch/beagle/conf/files.beagle,v
retrieving revision 1.4
diff -p -u -r1.4 files.beagle
--- beagle/conf/files.beagle1 Jun 2010 03:01:02 -   1.4
+++ beagle/conf/files.beagle6 Dec 2010 18:53:07 -
@@ -28,7 +28,7 @@ file  arch/arm/armv7/armv7_mutex.c
 # note that the order of the devices in _this_ file
 # affects the order that the devices will configure.
 
-include ../../../dev/sdmmc/files.sdmmc
+include dev/sdmmc/files.sdmmc
 
 device prcm
 attach prcm at ahb
@@ -77,8 +77,8 @@ file arch/beagle/dev/omdisplay.c  omdisp
 #
 # Machine-independent SCSI drivers
 #
-include ../../../scsi/files.scsi
-include ../../../dev/atapiscsi/files.atapiscsi
+include scsi/files.scsi
+include dev/atapiscsi/files.atapiscsi
 
 # CPU support and integrated peripherals
 file   arch/arm/arm/irq_dispatch.S
Index: gumstix/conf/files.gumstix
===
RCS file: /cvs/src/sys/arch/gumstix/conf/files.gumstix,v
retrieving revision 1.1
diff -p -u -r1.1 files.gumstix
--- gumstix/conf/files.gumstix  26 Nov 2008 14:18:11 -  1.1
+++ gumstix/conf/files.gumstix  6 Dec 2010 18:53:07 -
@@ -18,8 +18,8 @@ file  arch/gumstix/gumstix/gumstix_machde
 #
 # Machine-independent SCSI drivers
 #
-include ../../../scsi/files.scsi
-include ../../../dev/atapiscsi/files.atapiscsi
+include scsi/files.scsi
+include dev/atapiscsi/files.atapiscsi
 
 # CPU support and integrated peripherals
 include arch/arm/xscale/files.pxa2x0
Index: i386/conf/files.i386
===
RCS file: /cvs/src/sys/arch/i386/conf/files.i386,v
retrieving revision 1.199
diff -p -u -r1.199 files.i386
--- i386/conf/files.i38614 Oct 2010 21:23:04 

systat and livelocks

2010-11-25 Thread Jasper Lievisse Adriaanse
Hi,

Currently the 'mbufs' view of systat only shows the difference of livelocks,
this diff also adds the actual total (or sum). This is info most people are
actually looking for anyway (as noticed by kettenis and sthen yesterday).

OK?

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish.

Index: mbufs.c
===
RCS file: /cvs/src/usr.bin/systat/mbufs.c,v
retrieving revision 1.31
diff -p -u -r1.31 mbufs.c
--- mbufs.c 5 Nov 2010 10:07:30 -   1.31
+++ mbufs.c 25 Nov 2010 13:55:48 -
@@ -61,7 +61,8 @@ field_def fields_mbuf[] = {
{IFACE, 8, 16, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0},
{RXDELAY, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{TXDELAY, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
-   {LIVELOCKS, 5, 10, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
+   {LIVELOCKS (NOW), 5, 15, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
+   {(SUM), 5, 10, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{SIZE, 3, 5, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{ALIVE, 3, 5, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{LWM, 3, 5, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
@@ -72,15 +73,16 @@ field_def fields_mbuf[] = {
 
 #define FIELD_ADDR(x) (fields_mbuf[x])
 
-#define FLD_MB_IFACE   FIELD_ADDR(0)
-#define FLD_MB_RXDELAY FIELD_ADDR(1)
-#define FLD_MB_TXDELAY FIELD_ADDR(2)
-#define FLD_MB_LLOCKS  FIELD_ADDR(3)
-#define FLD_MB_MSIZE   FIELD_ADDR(4)
-#define FLD_MB_MALIVE  FIELD_ADDR(5)
-#define FLD_MB_MLWMFIELD_ADDR(6)
-#define FLD_MB_MHWMFIELD_ADDR(7)
-#define FLD_MB_MCWMFIELD_ADDR(8)
+#define FLD_MB_IFACE   FIELD_ADDR(0)
+#define FLD_MB_RXDELAY FIELD_ADDR(1)
+#define FLD_MB_TXDELAY FIELD_ADDR(2)
+#define FLD_MB_LLOCKS_NOW  FIELD_ADDR(3)
+#define FLD_MB_LLOCKS_SUM  FIELD_ADDR(4)
+#define FLD_MB_MSIZE   FIELD_ADDR(5)
+#define FLD_MB_MALIVE  FIELD_ADDR(6)
+#define FLD_MB_MLWMFIELD_ADDR(7)
+#define FLD_MB_MHWMFIELD_ADDR(8)
+#define FLD_MB_MCWMFIELD_ADDR(9)
 
 
 /* Define views */
@@ -89,7 +91,7 @@ field_def *view_mbuf[] = {
 #if NOTYET
FLD_MB_RXDELAY, FLD_MB_TXDELAY,
 #endif
-   FLD_MB_LLOCKS, FLD_MB_MSIZE, FLD_MB_MALIVE, FLD_MB_MLWM, FLD_MB_MHWM,
+   FLD_MB_LLOCKS_NOW, FLD_MB_LLOCKS_SUM, FLD_MB_MSIZE, FLD_MB_MALIVE, 
FLD_MB_MLWM, FLD_MB_MHWM,
FLD_MB_MCWM, NULL
 };
 
@@ -353,7 +355,8 @@ showmbuf(struct if_info *ifi, int p, int
print_fld_str(FLD_MB_IFACE, ifi-name);
 
if (p == -1  ifi == interfaces) {
-   print_fld_uint(FLD_MB_LLOCKS, mcllivelocks_diff);
+   print_fld_uint(FLD_MB_LLOCKS_NOW, mcllivelocks_diff);
+   print_fld_uint(FLD_MB_LLOCKS_SUM, mcllivelocks_cur);
print_fld_size(FLD_MB_MSIZE, mbpool.pr_size);
print_fld_size(FLD_MB_MALIVE, mbpool.pr_nget - mbpool.pr_nput);
print_fld_size(FLD_MB_MHWM, mbpool.pr_hiwat);



Re: A tiny feature for mg(1): beginning-of-line

2010-10-06 Thread Jasper Lievisse Adriaanse
Would this be OK with anyone? (With a tweak to start the new sentece on a new 
line).
I've sent this to three usual mg developers, but none bothered to answer.

On Sun, Sep 12, 2010 at 08:28:43PM -0700, Chris Palmer wrote:
 I have found this feature useful in other text editors. Maybe you will too?
 
 
 --- mg.1.orig Sun Sep 12 20:23:21 2010
 +++ mg.1  Sun Sep 12 20:24:36 2010
 @@ -320,7 +320,8 @@ Move cursor backwards by the specified number of words
  .It beginning-of-buffer
  Move cursor to the top of the buffer.
  .It beginning-of-line
 -Move cursor to the beginning of the line.
 +Move cursor to the beginning of the line. Calling this function again moves
 +the cursor to the first non-whitespace character of the line.
  .It blink-and-insert
  Self-insert a character, then search backwards and blink its
  matching delimeter.
 
 
 --- basic.c.orig  Sun Sep 12 20:01:41 2010
 +++ basic.c   Sun Sep 12 20:18:56 2010
 @@ -22,7 +22,21 @@
  int
  gotobol(int f, int n)
  {
 - curwp-w_doto = 0;
 + if (0 != curwp-w_doto)
 + curwp-w_doto = 0;
 + else {
 + char * ln = curwp-w_dotp-l_text;
 + int i = 0;
 +
 + if (ln)
 + while (*ln  isspace(*ln)) {
 + i++;
 + ln++;
 + }
 +
 + curwp-w_doto = i;
 + }
 +
   return (TRUE);
  }
 
 
 -- 
 http://noncombatant.org/
 

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish.



Re: A tiny feature for mg(1): beginning-of-line

2010-10-06 Thread Jasper Lievisse Adriaanse
On Wed, Oct 06, 2010 at 11:37:39AM +, Christian Weisgerber wrote:
 Jasper Lievisse Adriaanse jas...@humppa.nl wrote:
 
  Would this be OK with anyone?
 
   -Move cursor to the beginning of the line.
   +Move cursor to the beginning of the line. Calling this function again 
   moves
   +the cursor to the first non-whitespace character of the line.
 
 That's not the way emacs behaves and mg is supposed to be
 finger-compatible with emacs.
 
 -- 
 Christian naddy Weisgerber  na...@mips.inka.de
Actually, Ingo forwarded me some mails from Kjell about this and that it subtly
breaks c-mode.. So it can't go in as is.

-- 
Cheers,
Jasper

Stay Hungry. Stay Foolish.



Re: RFC: changes to ports infrastructure

2010-08-19 Thread Jasper Lievisse Adriaanse
On Thu, Aug 19, 2010 at 11:55:22AM +0200, Marc Espie wrote:
 I want to tweak the directory structure for ports.
 I'd like to go for a lot of stuff to 
 
 ports/infrastructure/bin
 ports/infrastructure/lib
 ports/infrastructure/man
 
 the current setup (build, fetch, install, package) is my mistake, and
 frankly it sucks. Some of the scripts are callable outside of bsd.port.mk,
 and you have to remember the path. There is no standard documentation out
 of the scripts, and there are a few perl modules that could use one
 single place.
 
 I would keep db, plist, templates. I don't think they're that confusing.
 
 The only drawback is that we're going to lose cvs history. doesn't seem
 like such a big problem to me. Also, third party may lose compatibility
 as scripts move around. That's easy to solve with symlinks, so I don't
 care too much.
 
 Did I miss anything ?
I think losing cvs history for mk/ would be worst. But since that dir
doesn't move I don't care too much for losing the history of the other
files.

I can only add a yes please, as the current setup is rather confusing.

Cheers,
Jasper

-- 
Stay Hungry. Stay Foolish.



rename sgi's power(4) to nmi(4)

2010-04-01 Thread Jasper Lievisse Adriaanse
hi,

the attached diff renames sgi's power(4) driver to nmi(4). that name
makes actually a lot more sense.

i'll commit the manpage bits separately.

ok?

-- 
Stay Hungry. Stay Foolish.


Index: share/man/man4/man4.sgi/Makefile
===
RCS file: /cvs/src/share/man/man4/man4.sgi/Makefile,v
retrieving revision 1.20
diff -p -u -p -u -r1.20 Makefile
--- share/man/man4/man4.sgi/Makefile8 Mar 2010 01:47:00 -   1.20
+++ share/man/man4/man4.sgi/Makefile29 Mar 2010 21:39:39 -
@@ -2,7 +2,7 @@
 
 MAN=   dsrtc.4 gbe.4 iec.4 impact.4 intro.4 ioc.4 iockbc.4 iof.4 \
macebus.4 mavb.4 mec.4 mkbc.4 odyssey.4 \
-   owmac.4 owserial.4 power.4 xbow.4 xbridge.4 xheart.4
+   owmac.4 owserial.4 nmi.4 xbow.4 xbridge.4 xheart.4
 MLINKS=macebus.4 macepcibr.4 \
xbridge.4 xbpci.4
 
Index: share/man/man4/man4.sgi/nmi.4
===
RCS file: share/man/man4/man4.sgi/nmi.4
diff -N share/man/man4/man4.sgi/nmi.4
--- /dev/null   1 Jan 1970 00:00:00 -
+++ share/man/man4/man4.sgi/nmi.4   29 Mar 2010 21:39:39 -
@@ -0,0 +1,57 @@
+.\ $OpenBSD$
+.\
+.\ Copyright (c) 2007,2010 Jasper Lievisse Adriaanse jas...@openbsd.org
+.\ All rights reserved.
+.\
+.\ Permission to use, copy, modify, and distribute this software for any
+.\ purpose with or without fee is hereby granted, provided that the above
+.\ copyright notice and this permission notice appear in all copies.
+.\
+.\ THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\
+.Dd $Mdocdate$
+.Dt NMI 4 sgi
+.Os
+.Sh NAME
+.Nm nmi
+.Nd non-meaningful interrupt
+.Sh SYNOPSIS
+.Cd nmi0 at macebus0 Pq O2
+.Cd nmi0 at mainbus0 Pq Octane
+.Sh DESCRIPTION
+The SGI O2 and Octane machines are equiped with a button that generates
+a non-meaningfull interrupt (NMI) when pressed.
+The
+.Nm
+driver catches that interrupt.
+If the
+.Va machdep.kbdreset
+.Xr sysctl 8
+is set to 1,
+.Nm
+will then signal
+.Xr init 8
+to do a clean
+.Xr shutdown 8 .
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr macebus 4 ,
+.Xr init 8 ,
+.Xr rc.shutdown 8 ,
+.Xr sysctl 8
+.Sh HISTORY
+Support for the
+.Nm
+driver first appeared in
+.Ox 4.8 .
+.Sh AUTHORS
+The
+.Nm
+driver was written by
+.An Jasper Lievisse Adriaanse Aq jas...@openbsd.org .
Index: share/man/man4/man4.sgi/power.4
===
RCS file: share/man/man4/man4.sgi/power.4
diff -N share/man/man4/man4.sgi/power.4
--- share/man/man4/man4.sgi/power.4 26 Oct 2009 18:38:09 -  1.3
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,57 +0,0 @@
-.\ $OpenBSD: power.4,v 1.3 2009/10/26 18:38:09 miod Exp $
-.\
-.\ Copyright (c) 2007 Jasper Lievisse Adriaanse jas...@openbsd.org
-.\ All rights reserved.
-.\
-.\ Permission to use, copy, modify, and distribute this software for any
-.\ purpose with or without fee is hereby granted, provided that the above
-.\ copyright notice and this permission notice appear in all copies.
-.\
-.\ THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\
-.Dd $Mdocdate: October 26 2009 $
-.Dt POWER 4 sgi
-.Os
-.Sh NAME
-.Nm power
-.Nd power button
-.Sh SYNOPSIS
-.Cd power0 at macebus0 Pq O2
-.Cd power0 at mainbus0 Pq Octane
-.Sh DESCRIPTION
-The SGI O2 and Octane machines generate an interrupt when the power button
-on the front panel is pressed.
-The
-.Nm
-driver catches that interrupt.
-If the
-.Va machdep.kbdreset
-.Xr sysctl 8
-is set to 1,
-.Nm
-will then signal
-.Xr init 8
-to do a clean
-.Xr shutdown 8 .
-.Sh SEE ALSO
-.Xr intro 4 ,
-.Xr macebus 4 ,
-.Xr init 8 ,
-.Xr rc.shutdown 8 ,
-.Xr sysctl 8
-.Sh HISTORY
-Support for the
-.Nm
-driver first appeared in
-.Ox 4.3 .
-.Sh AUTHORS
-The
-.Nm
-driver was written by
-.An Jasper Lievisse Adriaanse Aq jas...@openbsd.org .
Index: sys/arch/sgi/conf/GENERIC-IP30
===
RCS file: /cvs/src/sys/arch/sgi/conf/GENERIC-IP30,v
retrieving revision 1.28
diff -p -u -p -u -r1.28 GENERIC-IP30
--- sys/arch/sgi/conf/GENERIC-IP30

Re: spelling gnu/usr.bin/perl/util.c

2009-12-16 Thread Jasper Lievisse Adriaanse
On Tue, Dec 15, 2009 at 08:53:56PM -0500, Brad Tilley wrote:
 If these are annoying, I will stop sending.
please submit this diff to upstream as it's maintained there, not in our
tree.

cheers,
jasper

 # cvs diff -Nup gnu/usr.bin/perl/util.c
 Index: gnu/usr.bin/perl/util.c
 ===
 RCS file: /cvs/src/gnu/usr.bin/perl/util.c,v
 retrieving revision 1.13
 diff -N -u -p gnu/usr.bin/perl/util.c
 --- gnu/usr.bin/perl/util.c 12 Oct 2009 18:24:22 -  1.13
 +++ gnu/usr.bin/perl/util.c 16 Dec 2009 01:51:34 -
 @@ -2507,7 +2507,7 @@ Perl_my_popen(pTHX_ const char *cmd, const char
 *mode)
 
  #ifdef PERLIO_USING_CRLF
 /* Since we circumvent IO layers when we manipulate low-level
 -  filedescriptors directly, need to manually switch to the
 +  file descriptors directly, need to manually switch to the
default, binary, low-level mode; see PerlIOBuf_open(). */
 PerlLIO_setmode((*mode == 'r'), O_BINARY);
  #endif
 @@ -2971,7 +2971,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int
 flags
 *statusp = SvIVX(sv);
 /* The hash iterator is currently on this entry, so
 simply
calling hv_delete would trigger the lazy delete,
which on
 -  aggregate does more work, beacuse next call to
 hv_iterinit()
 +  aggregate does more work, because next call to
 hv_iterinit()
would spot the flag, and have to call the delete
routine,
while in the meantime any new entries can't re-use
that
memory.  */
 @@ -4071,7 +4071,7 @@ Fill the sv with current working directory
  /* Originally written in Perl by John Bazik; rewritten in C by Ben
  Sugars.
   * rewritten again by dougm, optimized for use with xs TARG, and to
   prefer
   * getcwd(3) if available
 - * Comments from the orignal:
 + * Comments from the original:
   * This is a faster version of getcwd.  It's also more dangerous
   * because you might chdir out of a directory that you can't chdir
   * back into. */
 

-- 
Intelligence should guide our actions, but in harmony with the
  texture of the situation at hand
-- Francisco Varela