From aa958b1ab60ae5522e5fbbef606fe3d86ac65cae Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 24 May 2016 23:03:17 -0700 Subject: [PATCH] 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 --- doc/changes.src | 4 +++- doc/nasmdoc.src | 14 ++++++++------ macros/ifunc.mac | 4 +++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/changes.src b/doc/changes.src index b6c987c0..73d84eb1 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -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 diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index fb7a9444..12cc429b 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -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} diff --git a/macros/ifunc.mac b/macros/ifunc.mac index fc0d313e..0fafe8d6 100644 --- a/macros/ifunc.mac +++ b/macros/ifunc.mac @@ -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))