summaryrefslogtreecommitdiff
path: root/nasm.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-05-31 10:25:37 -0700
committerH. Peter Anvin <hpa@zytor.com>2012-05-31 10:25:37 -0700
commit290b4cb3a4d32ec8260e88b4e67fc968cf9adb5e (patch)
treede83fd4983a16831905213858b417239aa58cb75 /nasm.h
parent3d1d159e1c876308712fd5e21089dfddfbad1e69 (diff)
downloadnasm-290b4cb3a4d32ec8260e88b4e67fc968cf9adb5e.tar.gz
nasm-290b4cb3a4d32ec8260e88b4e67fc968cf9adb5e.tar.bz2
nasm-290b4cb3a4d32ec8260e88b4e67fc968cf9adb5e.zip
eval: add general support for "integer functions" and add ilog2*()
Add general support in the function parser for "integer functions" (actually implemented as special unary operators, then wrapped in macros) and implement a family of integer logarithms. The only difference is the behavior on a non-power-of-two argument: ilog2[e] -- throw an error ilog2w -- throw a warning ilog2f -- round down to power of 2 ilog2c -- round up to power of 2 This is useful for back-converting from masks to bit values. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasm.h')
-rw-r--r--nasm.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/nasm.h b/nasm.h
index f7dd060..7422635 100644
--- a/nasm.h
+++ b/nasm.h
@@ -225,6 +225,7 @@ enum token_type { /* token types, other than chars */
TOKEN_WRT, /* WRT */
TOKEN_FLOATIZE, /* __floatX__ */
TOKEN_STRFUNC, /* __utf16*__, __utf32*__ */
+ TOKEN_IFUNC, /* __ilog2*__ */
};
enum floatize {
@@ -248,6 +249,13 @@ enum strfunc {
STRFUNC_UTF32BE,
};
+enum ifunc {
+ IFUNC_ILOG2E,
+ IFUNC_ILOG2W,
+ IFUNC_ILOG2F,
+ IFUNC_ILOG2C,
+};
+
size_t string_transform(char *, size_t, char **, enum strfunc);
/*