Browse Source

scripts: kconfig: Add min/max functions

Similar to arithmetic functions, min/max can be useful to use in kconfig.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
pull/74302/head
Pieter De Gendt 11 months ago committed by Carles Cufí
parent
commit
2f234c627c
  1. 6
      scripts/kconfig/kconfigfunctions.py

6
scripts/kconfig/kconfigfunctions.py

@ -963,6 +963,10 @@ def arith(kconf, name, *args): @@ -963,6 +963,10 @@ def arith(kconf, name, *args):
return str(int(functools.reduce(operator.truediv, intarray)))
elif name == "mod":
return str(int(functools.reduce(operator.mod, intarray)))
elif name == "max":
return str(int(functools.reduce(max, intarray)))
elif name == "min":
return str(int(functools.reduce(min, intarray)))
else:
assert False
@ -1046,6 +1050,8 @@ functions = { @@ -1046,6 +1050,8 @@ functions = {
"mul": (arith, 1, 255),
"div": (arith, 1, 255),
"mod": (arith, 1, 255),
"max": (arith, 1, 255),
"min": (arith, 1, 255),
"inc": (inc_dec, 1, 255),
"dec": (inc_dec, 1, 255),
}

Loading…
Cancel
Save