Makefile.inc: Add left shift macro
Add a macro to shift a value to the left by a specified number of bits. Change-Id: Ib3fb43b620f31fee2a41f00ddf7294edc81a60f6 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/21601 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
This commit is contained in:
28
Makefile.inc
28
Makefile.inc
@ -113,19 +113,20 @@ $(foreach supported_arch,$(ARCH_SUPPORTED), \
|
|||||||
# macros work on all formats understood by printf(1)
|
# macros work on all formats understood by printf(1)
|
||||||
# values are space separated if using more than one value
|
# values are space separated if using more than one value
|
||||||
#
|
#
|
||||||
# int-add: adds an arbitrary length list of integers
|
# int-add: adds an arbitrary length list of integers
|
||||||
# int-subtract: subtracts the the second of two integers from the first
|
# int-subtract: subtracts the the second of two integers from the first
|
||||||
# int-multiply: multiplies an arbitrary length list of integers
|
# int-multiply: multiplies an arbitrary length list of integers
|
||||||
# int-divide: divides the first integer by the second
|
# int-divide: divides the first integer by the second
|
||||||
# int-remainder: arithmetic remainder of the first number divided by the second
|
# int-remainder: arithmetic remainder of the first number divided by the second
|
||||||
# int-lt: 1 if the first value is less than the second. 0 otherwise
|
# int-shift-left: Shift $1 left by $2 bits
|
||||||
# int-gt: 1 if the first values is greater than the second. 0 otherwise
|
# int-lt: 1 if the first value is less than the second. 0 otherwise
|
||||||
# int-eq: 1 if the two values are equal. 0 otherwise
|
# int-gt: 1 if the first values is greater than the second. 0 otherwise
|
||||||
# int-align: align $1 to $2 units
|
# int-eq: 1 if the two values are equal. 0 otherwise
|
||||||
# file-size: returns the filesize of the given file
|
# int-align: align $1 to $2 units
|
||||||
# tolower: returns the value in all lowercase
|
# file-size: returns the filesize of the given file
|
||||||
# toupper: returns the value in all uppercase
|
# tolower: returns the value in all lowercase
|
||||||
# ws_to_under: returns the value with any whitespace changed to underscores
|
# toupper: returns the value in all uppercase
|
||||||
|
# ws_to_under: returns the value with any whitespace changed to underscores
|
||||||
_toint=$(shell printf "%d" $1)
|
_toint=$(shell printf "%d" $1)
|
||||||
_int-add2=$(shell expr $(call _toint,$1) + $(call _toint,$2))
|
_int-add2=$(shell expr $(call _toint,$1) + $(call _toint,$2))
|
||||||
int-add=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-add,$(call _int-add2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1)))
|
int-add=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-add,$(call _int-add2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1)))
|
||||||
@ -134,6 +135,7 @@ _int-multiply2=$(shell expr $(call _toint,$1) \* $(call _toint,$2))
|
|||||||
int-multiply=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-multiply,$(call _int-multiply2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1)))
|
int-multiply=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-multiply,$(call _int-multiply2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1)))
|
||||||
int-divide=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) / $(call _toint,$(word 2,$1))))
|
int-divide=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) / $(call _toint,$(word 2,$1))))
|
||||||
int-remainder=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) % $(call _toint,$(word 2,$1))))
|
int-remainder=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) % $(call _toint,$(word 2,$1))))
|
||||||
|
int-shift-left=$(shell echo "$(call _toint,$(word 1, $1)) * (2 ^ $(call _toint,$(word 2, $1)))" | bc)
|
||||||
int-lt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \< $(call _toint,$(word 2,$1))))
|
int-lt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \< $(call _toint,$(word 2,$1))))
|
||||||
int-gt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \> $(call _toint,$(word 2,$1))))
|
int-gt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \> $(call _toint,$(word 2,$1))))
|
||||||
int-eq=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) = $(call _toint,$(word 2,$1))))
|
int-eq=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) = $(call _toint,$(word 2,$1))))
|
||||||
|
Reference in New Issue
Block a user