[U-Boot] [U-Boot, v2] Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Ismael Luceno Cortes ismael.luceno at silicon-gears.com
Fri Mar 15 10:13:14 UTC 2019


On 08/Mar/2019 18:28, Martin Husemann wrote:
> On Fri, Mar 08, 2019 at 12:17:09PM -0500, Tom Rini wrote:
> > OK, so a few thoughts here.
> > - What's the portable way to do hex-based math?  If we really need it?
> 
> Use printf(3) to convert to/from hex, and standard shell arithmetic
> with $(( )).
> 
> Looks horrible, but something like:
> 
> v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) ))
> printf "v = %d (%x)\n" $v $v
> 
> 
> ... maybe arranged into some sh helper functions.

dash, bash, mksh, zsh, all ksh-compatible shells in fact, support hex
numbers on arithmetic expressions, no need for conversion.


More information about the U-Boot mailing list