diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2023-04-30 15:48:02 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-04-30 14:27:10 +0000 |
commit | afa50399904c71460bc8ca9f2446b58265b72b12 (patch) | |
tree | 522c4bd4710f9c071e4078f5c37099fd270fc2ab | |
parent | eb30d4d6499ab0c68ae5766082a34fa061fac1c4 (diff) | |
download | strace-afa50399904c71460bc8ca9f2446b58265b72b12.tar.gz |
xlat/gen.sh: allow skipping xlat value checking
This enables storing "wrong" values in xlats, so they can be referenced
in cases when there are discrepancies between what UAPI headers provide
and what they used to provide.
* src/xlat/gen.sh (cond_def): Emit static_assert() only if $nocheckval
is not enabled.
(cond_xlat): Add is_shift local variable; check whether $m starts
with "1<<" and set $is_shift if it is; use print_xval() only if neither
is_shift nor nocheckval are set; call print_xlat_pair() if $nocheckval
is set.
(gen_header): Add nocheckval to local variables; handle "#checkval"
and "#nocheckval" directives.
-rwxr-xr-x | src/xlat/gen.sh | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/xlat/gen.sh b/src/xlat/gen.sh index f7f32c604..050c79150 100755 --- a/src/xlat/gen.sh +++ b/src/xlat/gen.sh @@ -59,10 +59,11 @@ cond_def() [ -n "$unconditional" ] || printf '%s\n' \ "#if defined($val) || (defined(HAVE_DECL_$val) && HAVE_DECL_$val)" - printf '%s\n' \ - "DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE" \ - "static_assert(($val) == ($def), \"$val != $def\");" \ - "DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE" + [ -n "$nocheckval" ] || + printf '%s\n' \ + "DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE" \ + "static_assert(($val) == ($def), \"$val != $def\");" \ + "DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE" [ -n "$unconditional" ] || printf '%s\n' \ "#else" \ @@ -141,17 +142,20 @@ print_xlat_pair() cond_xlat() { echo "$1" | { - local val def m xlat + local val def m is_shift='' xlat read val def m="${val%%|*}" + [ "${m}" = "${m#1<<}" ] || is_shift=1 - if [ "${m}" = "${m#1<<}" ]; then + if [ -z "$is_shift$nocheckval" ]; then xlat="$(print_xlat "${val}")" - else + elif [ -n "$is_shift" ]; then m="${m#1<<}" xlat="$(print_xlat_pair "1ULL<<${val#1<<}" "${val}" "$m")" + else + xlat="$(print_xlat_pair "${def}" "${val}" "$m")" fi if [ -z "${def}${unconditional}" ]; then @@ -203,7 +207,7 @@ gen_header() EOF - local unconditional= line + local unconditional='' nocheckval='' line # 1st pass: output directives. while read -r line; do case "$line" in @@ -220,6 +224,12 @@ gen_header() '#unconditional') unconditional=1 ;; + '#checkval') + nocheckval= + ;; + '#nocheckval') + nocheckval=1 + ;; '#val_type '*) # to be processed during 2nd pass ;; @@ -301,7 +311,9 @@ gen_header() echo "DIAG_PUSH_IGNORE_TAUTOLOGICAL_CONSTANT_COMPARE" echo "static const struct xlat_data ${name}_xdata[] = {" - unconditional= val_type= + unconditional= + nocheckval= + val_type= # 2nd pass: output everything. while read -r line; do case "$line" in @@ -318,6 +330,12 @@ gen_header() '#unconditional') unconditional=1 ;; + '#checkval') + nocheckval= + ;; + '#nocheckval') + nocheckval=1 + ;; '#sorted'|'#sorted '*) ;; '#value_indexed') |