From: cheloha Date: Thu, 12 Oct 2023 15:16:44 +0000 (+0000) Subject: bt(5), btrace(8): add support for binary modulo operator ('%') X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b9c158ac990f3d15a0a2021062d99a04d46ec95d;p=openbsd bt(5), btrace(8): add support for binary modulo operator ('%') Link: https://marc.info/?l=openbsd-tech&m=169695435209410&w=2 ok mpi@ --- diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y index 0a8d9c62fb3..12c445d2dd2 100644 --- a/usr.sbin/btrace/bt_parse.y +++ b/usr.sbin/btrace/bt_parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parse.y,v 1.53 2023/09/11 19:01:26 mpi Exp $ */ +/* $OpenBSD: bt_parse.y,v 1.54 2023/10/12 15:16:44 cheloha Exp $ */ /* * Copyright (c) 2019-2023 Martin Pieuchot @@ -184,7 +184,7 @@ filter : /* empty */ { $$ = NULL; } * Give higher precedence to: * 1. && and || * 2. ==, !=, <<, <, >=, >, +, =, &, ^, | - * 3. * and / + * 3. *, /, % */ expr : expr OP_LAND term { $$ = ba_op(B_AT_OP_LAND, $1, $3); } | expr OP_LOR term { $$ = ba_op(B_AT_OP_LOR, $1, $3); } @@ -207,6 +207,7 @@ term : term OP_EQ fterm { $$ = ba_op(B_AT_OP_EQ, $1, $3); } fterm : fterm '*' factor { $$ = ba_op(B_AT_OP_MULT, $1, $3); } | fterm '/' factor { $$ = ba_op(B_AT_OP_DIVIDE, $1, $3); } + | fterm '%' factor { $$ = ba_op(B_AT_OP_MODULO, $1, $3); } | factor ; diff --git a/usr.sbin/btrace/bt_parser.h b/usr.sbin/btrace/bt_parser.h index 9cbcace6f48..051bd72815d 100644 --- a/usr.sbin/btrace/bt_parser.h +++ b/usr.sbin/btrace/bt_parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parser.h,v 1.24 2023/09/11 19:01:26 mpi Exp $ */ +/* $OpenBSD: bt_parser.h,v 1.25 2023/10/12 15:16:44 cheloha Exp $ */ /* * Copyright (c) 2019-2021 Martin Pieuchot @@ -163,6 +163,7 @@ struct bt_arg { B_AT_OP_MINUS, B_AT_OP_MULT, B_AT_OP_DIVIDE, + B_AT_OP_MODULO, B_AT_OP_BAND, B_AT_OP_XOR, B_AT_OP_BOR, diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 8feb0ef3250..847fa2f652a 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.78 2023/09/15 10:59:02 claudio Exp $ */ +/* $OpenBSD: btrace.c,v 1.79 2023/10/12 15:16:44 cheloha Exp $ */ /* * Copyright (c) 2019 - 2023 Martin Pieuchot @@ -1416,6 +1416,9 @@ baexpr2long(struct bt_arg *ba, struct dt_evt *dtev) case B_AT_OP_DIVIDE: result = lval / rval; break; + case B_AT_OP_MODULO: + result = lval % rval; + break; case B_AT_OP_BAND: result = lval & rval; break; @@ -1526,6 +1529,8 @@ ba_name(struct bt_arg *ba) return "*"; case B_AT_OP_DIVIDE: return "/"; + case B_AT_OP_MODULO: + return "%"; case B_AT_OP_BAND: return "&"; case B_AT_OP_XOR: