ifunc.mac: the ilog2 warning may want to be both ceil and floor

There is no reason why the warning-generating ilog2 has to be only the
floor variant.  However, I am pretty sure we can simply implement the
ilog2cw() as a macro only; we can always fix that if that turns out to
be incorrect.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2016-05-24 23:03:17 -07:00
parent 57a0581394
commit aa958b1ab6
3 changed files with 14 additions and 8 deletions

View file

@ -7,7 +7,6 @@
The NASM 2 series supports x86-64, and is the production version of NASM
since 2007.
\S{cl-2.12.02} Version 2.12.02
\b Fix preprocessor errors, especially \c{%error} and \c{%warning},
@ -27,6 +26,9 @@ since 2007.
macro, display the file and line numbers for the expanded macros.
Macros defined with \c{.nolist} do not get displayed.
\b Add macros \c{ilog2fw()} and \c{ilog2cw()} to the \c{ifunc} macro
package. See \k{ilog2}.
\S{cl-2.12.01} Version 2.12.01

View file

@ -4333,21 +4333,23 @@ The macros provided are:
These functions calculate the integer logarithm base 2 of their
argument, considered as an unsigned integer. The only differences
between the functions is their behavior if the argument provided is
not a power of two.
between the functions is their respective behavior if the argument
provided is not a power of two.
The function \i\c{ilog2e()} (alias \i\c{ilog2()}) generate an error if
The function \i\c{ilog2e()} (alias \i\c{ilog2()}) generates an error if
the argument is not a power of two.
The function \i\c{ilog2w()} generate a warning if the argument is not
a power of two.
The function \i\c{ilog2f()} rounds the argument down to the nearest
power of two; if the argument is zero it returns zero.
The function \i\c{ilog2c()} rounds the argument up to the nearest
power of two.
The functions \i\c{ilog2fw()} (alias \i\c{ilog2w()}) and
\i\c{ilog2cw()} generate a warning if the argument is not a power of
two, but otherwise behaves like \c{ilog2f()} and \c{ilog2c()},
respectively.
\C{directive} \i{Assembler Directives}

View file

@ -1,6 +1,6 @@
;; --------------------------------------------------------------------------
;;
;; Copyright 2012 The NASM Authors - All Rights Reserved
;; Copyright 2012-2016 The NASM Authors - All Rights Reserved
;; See the file AUTHORS included with the NASM distribution for
;; the specific copyright holders.
;;
@ -42,5 +42,7 @@ USE: ifunc
%idefine ilog2(x) (__ilog2e__(x))
%idefine ilog2e(x) (__ilog2e__(x))
%idefine ilog2w(x) (__ilog2w__(x))
%idefine ilog2fw(x) (__ilog2w__(x))
%idefine ilog2f(x) (__ilog2f__(x))
%idefine ilog2cw(x) (__ilog2w__(x) * 0 + __ilog2c__(x))
%idefine ilog2c(x) (__ilog2c__(x))