diff options
author | H. Peter Anvin <hpa@zytor.com> | 2019-08-27 16:38:48 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2019-08-27 16:42:41 -0700 |
commit | d235408c65fc8176fdd94dd9f7d49074828bfa86 (patch) | |
tree | 1c1813452456e38e4af96a9046b96ac0e4b43998 /macros | |
parent | eaef851689e1d83608741cd5ac7c65e4e47d4acb (diff) | |
download | nasm-d235408c65fc8176fdd94dd9f7d49074828bfa86.tar.gz |
preproc: standard macros now C-safe, %aliases off, fix %? recursion
Enough users expect the namespace starting with underscore to be safe
for symbols. Change our private namespace from __foo__ to
__?foo?__. Use %defalias to provide backwards compatiblity (by using
%defalias instead of %define, we handle the case properly where the
user changes the value.)
Add a preprocessor directive:
%aliases off
... to disable all smacro aliases and thereby making the namespace
clean.
Finally, fix infinite recursion when seeing %? or %?? due to
paste_tokens(). If we don't paste anything, the expansion is done.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'macros')
-rw-r--r-- | macros/fp.mac | 24 | ||||
-rw-r--r-- | macros/ifunc.mac | 14 | ||||
-rwxr-xr-x | macros/macros.pl | 4 | ||||
-rw-r--r-- | macros/masm.mac | 8 | ||||
-rw-r--r-- | macros/smartalign.mac | 222 | ||||
-rw-r--r-- | macros/standard.mac | 138 |
6 files changed, 251 insertions, 159 deletions
diff --git a/macros/fp.mac b/macros/fp.mac index 1334784b..eb297014 100644 --- a/macros/fp.mac +++ b/macros/fp.mac @@ -39,16 +39,16 @@ USE: fp -%define Inf __Infinity__ -%define NaN __QNaN__ -%define QNaN __QNaN__ -%define SNaN __SNaN__ +%define Inf __?Infinity?__ +%define NaN __?QNaN?__ +%define QNaN __?QNaN?__ +%define SNaN __?SNaN?__ -%define float8(x) __float8__(x) -%define float16(x) __float16__(x) -%define float32(x) __float32__(x) -%define float64(x) __float64__(x) -%define float80m(x) __float80m__(x) -%define float80e(x) __float80e__(x) -%define float128l(x) __float128l__(x) -%define float128h(x) __float128h__(x) +%define float8(x) __?float8?__(x) +%define float16(x) __?float16?__(x) +%define float32(x) __?float32?__(x) +%define float64(x) __?float64?__(x) +%define float80m(x) __?float80m?__(x) +%define float80e(x) __?float80e?__(x) +%define float128l(x) __?float128l?__(x) +%define float128h(x) __?float128h?__(x) diff --git a/macros/ifunc.mac b/macros/ifunc.mac index 0fafe8d6..4db46d34 100644 --- a/macros/ifunc.mac +++ b/macros/ifunc.mac @@ -39,10 +39,10 @@ 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)) +%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)) diff --git a/macros/macros.pl b/macros/macros.pl index 260382c2..9fc425d4 100755 --- a/macros/macros.pl +++ b/macros/macros.pl @@ -205,7 +205,9 @@ foreach $args ( @ARGV ) { $lastname = $fname; push(@pkg_list, $pkg); $pkg_number{$pkg} = $npkg++; - $z = pack("C", $pnum{'%define'})."__USE_\U$pkg\E__"; + $z = pack("C", $pnum{'%define'})."__?USE_\U$pkg\E?__"; + printf OUT " /* %4d */ %sEOL,\n", $index, charcify($z); + $z = pack("C", $pnum{'%defalias'})."__USE_\U$pkg\E__ __?USE\U$pkg\E?__"; printf OUT " /* %4d */ %sEOL,\n", $index, charcify($z); $index += length($z)+1; } else { diff --git a/macros/masm.mac b/macros/masm.mac index 6587e015..da7e6eea 100644 --- a/macros/masm.mac +++ b/macros/masm.mac @@ -45,8 +45,8 @@ USE: masm %unimacro segment 1+ %imacro segment 0-1+.nolist - %define __SECT__ [segment %00 %1] - __SECT__ + %define __?SECT?__ [segment %00 %1] + __?SECT?__ %endmacro %imacro ends 0+.nolist @@ -69,8 +69,8 @@ USE: masm %undef ret %endmacro -%idefine ptr __masm_ptr__ -%idefine flat __masm_flat__ ; is %idefine really correct here? +%idefine ptr __?masm_ptr?__ +%idefine flat __?masm_flat?__ ; is %idefine really correct here? %idefine offset %imacro end 0+.nolist diff --git a/macros/smartalign.mac b/macros/smartalign.mac index 0f81ae87..abd496e6 100644 --- a/macros/smartalign.mac +++ b/macros/smartalign.mac @@ -38,147 +38,149 @@ USE: smartalign %imacro alignmode 1-2.nolist %ifidni %1,nop - %define __ALIGN_JMP_THRESHOLD__ 16 + %define __?ALIGN_JMP_THRESHOLD?__ 16 - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_GROUP__ 1 + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_GROUP?__ 1 - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_GROUP__ 1 + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_GROUP?__ 1 - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_GROUP__ 1 + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_GROUP?__ 1 %elifidni %1,generic - %define __ALIGN_JMP_THRESHOLD__ 8 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x89,0xf6 - %define __ALIGN_16BIT_3B__ 0x8d,0x74,0x00 - %define __ALIGN_16BIT_4B__ 0x8d,0xb4,0x00,0x00 - %define __ALIGN_16BIT_5B__ 0x8d,0xb4,0x00,0x00,0x90 - %define __ALIGN_16BIT_6B__ 0x8d,0xb4,0x00,0x00,0x89,0xff - %define __ALIGN_16BIT_7B__ 0x8d,0xb4,0x00,0x00,0x8d,0x7d,0x00 - %define __ALIGN_16BIT_8B__ 0x8d,0xb4,0x00,0x00,0x8d,0xbd,0x00,0x00 - %define __ALIGN_16BIT_GROUP__ 8 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x89,0xf6 - %define __ALIGN_32BIT_3B__ 0x8d,0x76,0x00 - %define __ALIGN_32BIT_4B__ 0x8d,0x74,0x26,0x00 - %define __ALIGN_32BIT_5B__ 0x90,0x8d,0x74,0x26,0x00 - %define __ALIGN_32BIT_6B__ 0x8d,0xb6,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 7 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 8 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x89,0xf6 + %define __?ALIGN_16BIT_3B?__ 0x8d,0x74,0x00 + %define __?ALIGN_16BIT_4B?__ 0x8d,0xb4,0x00,0x00 + %define __?ALIGN_16BIT_5B?__ 0x8d,0xb4,0x00,0x00,0x90 + %define __?ALIGN_16BIT_6B?__ 0x8d,0xb4,0x00,0x00,0x89,0xff + %define __?ALIGN_16BIT_7B?__ 0x8d,0xb4,0x00,0x00,0x8d,0x7d,0x00 + %define __?ALIGN_16BIT_8B?__ 0x8d,0xb4,0x00,0x00,0x8d,0xbd,0x00,0x00 + %define __?ALIGN_16BIT_GROUP?__ 8 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x89,0xf6 + %define __?ALIGN_32BIT_3B?__ 0x8d,0x76,0x00 + %define __?ALIGN_32BIT_4B?__ 0x8d,0x74,0x26,0x00 + %define __?ALIGN_32BIT_5B?__ 0x90,0x8d,0x74,0x26,0x00 + %define __?ALIGN_32BIT_6B?__ 0x8d,0xb6,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 7 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,k8 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_16BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_16BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x66,0x90 - %define __ALIGN_32BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_32BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_32BIT_GROUP__ 4 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_16BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_16BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x66,0x90 + %define __?ALIGN_32BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_32BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_32BIT_GROUP?__ 4 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,k7 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_16BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x8b,0xc0 - %define __ALIGN_32BIT_3B__ 0x8d,0x04,0x20 - %define __ALIGN_32BIT_4B__ 0x8d,0x44,0x20,0x00 - %define __ALIGN_32BIT_5B__ 0x8d,0x44,0x20,0x00,0x90 - %define __ALIGN_32BIT_6B__ 0x8d,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x8d,0x04,0x05,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 7 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_16BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x8b,0xc0 + %define __?ALIGN_32BIT_3B?__ 0x8d,0x04,0x20 + %define __?ALIGN_32BIT_4B?__ 0x8d,0x44,0x20,0x00 + %define __?ALIGN_32BIT_5B?__ 0x8d,0x44,0x20,0x00,0x90 + %define __?ALIGN_32BIT_6B?__ 0x8d,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x8d,0x04,0x05,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 7 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,p6 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_16BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_16BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x66,0x90 - %define __ALIGN_32BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_32BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_32BIT_5B__ 0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_32BIT_6B__ 0x66,0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_8B__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 8 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_64BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_64BIT_5B__ 0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_64BIT_6B__ 0x66,0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_64BIT_7B__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_64BIT_8B__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 - %define __ALIGN_64BIT_GROUP__ 8 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_16BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_16BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x66,0x90 + %define __?ALIGN_32BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_32BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_32BIT_5B?__ 0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_32BIT_6B?__ 0x66,0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_8B?__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 8 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_64BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_64BIT_5B?__ 0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_64BIT_6B?__ 0x66,0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_64BIT_7B?__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_64BIT_8B?__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 + %define __?ALIGN_64BIT_GROUP?__ 8 %else %error unknown alignment mode: %1 %endif %ifnempty %2 %ifidni %2,nojmp - %xdefine __ALIGN_JMP_THRESHOLD__ -1 + %xdefine __?ALIGN_JMP_THRESHOLD?__ -1 %else - %xdefine __ALIGN_JMP_THRESHOLD__ %2 + %xdefine __?ALIGN_JMP_THRESHOLD?__ %2 %endif %endif - %xdefine __ALIGNMODE__ %1,__ALIGN_JMP_THRESHOLD__ + %xdefine __?ALIGNMODE?__ %1,__?ALIGN_JMP_THRESHOLD?__ %endmacro +%defalias __ALIGNMODE__ __?ALIGNMODE?__ + %unimacro align 1-2+.nolist %imacro align 1-2+.nolist sectalign %1 ; align a segment as well %ifnempty %2 times (((%1) - (($-$$) % (%1))) % (%1)) %2 - %elif __PASS__ == 0 || __PASS__ == 3 + %elif __?PASS?__ == 0 || __?PASS?__ == 3 times (((%1) - (($-$$) % (%1))) % (%1)) nop %else %push %assign %$pad (((%1) - (($-$$) % (%1))) % (%1)) - %if __ALIGN_JMP_THRESHOLD__ != -1 && %$pad > __ALIGN_JMP_THRESHOLD__ + %if __?ALIGN_JMP_THRESHOLD?__ != -1 && %$pad > __?ALIGN_JMP_THRESHOLD?__ jmp %$end ; We can't re-use %$pad here as $ will have changed! times (((%1) - (($-$$) % (%1))) % (%1)) nop %else - times (%$pad / __ALIGN_%[__BITS__]BIT_GROUP__) \ - db __ALIGN_%[__BITS__]BIT_%[__ALIGN_%[__BITS__]BIT_GROUP__]B__ - %assign %$pad %$pad % __ALIGN_%[__BITS__]BIT_GROUP__ + times (%$pad / __?ALIGN_%[__?BITS?__]BIT_GROUP?__) \ + db __?ALIGN_%[__?BITS?__]BIT_%[__?ALIGN_%[__?BITS?__]BIT_GROUP?__]B?__ + %assign %$pad %$pad % __?ALIGN_%[__?BITS?__]BIT_GROUP?__ %if %$pad > 0 - db __ALIGN_%[__BITS__]BIT_%[%$pad]B__ + db __?ALIGN_%[__?BITS?__]BIT_%[%$pad]B?__ %endif %endif %$end: diff --git a/macros/standard.mac b/macros/standard.mac index 3a930f40..f6ca65d2 100644 --- a/macros/standard.mac +++ b/macros/standard.mac @@ -49,32 +49,34 @@ STD: nasm ; here, not all of them are: the user-level form of a format-specific ; directive should be defined in the module for that directive. -%define __SECT__ ; it ought to be defined, even if as nothing +%define __?SECT?__ ; it ought to be defined, even if as nothing +%defalias __SECT__ __?SECT?__ %imacro section 1+.nolist - %define __SECT__ [section %1] - __SECT__ + %define __?SECT?__ [section %1] + __?SECT?__ %endmacro %imacro segment 1+.nolist - %define __SECT__ [segment %1] - __SECT__ + %define __?SECT?__ [segment %1] + __?SECT?__ %endmacro -%define __SECTALIGN_ALIGN_UPDATES_SECTION__ 1 +%define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1 %imacro sectalign 1+.nolist %ifidni %1,off - %define __SECTALIGN_ALIGN_UPDATES_SECTION__ 0 + %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 0 %elifidni %1,on - %define __SECTALIGN_ALIGN_UPDATES_SECTION__ 1 + %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1 %else [sectalign %1] %endif %endmacro +%defalias __SECTALIGN_ALIGN_UPDATES_SECTION__ __?SECTALIGN_ALIGN_UPDATES_SECTION?__ %imacro absolute 1+.nolist - %define __SECT__ [absolute %1] - __SECT__ + %define __?SECT?__ [absolute %1] + __?SECT?__ %endmacro %imacro struc 1-2.nolist 0 @@ -87,7 +89,7 @@ STD: nasm %imacro endstruc 0.nolist %{$strucname}_size equ ($-%$strucname) %pop - __SECT__ + __?SECT?__ %endmacro %imacro istruc 1.nolist @@ -107,14 +109,14 @@ STD: nasm %endmacro %imacro align 1-2+.nolist nop - %if __SECTALIGN_ALIGN_UPDATES_SECTION__ + %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__ sectalign %1 %endif times (((%1) - (($-$$) % (%1))) % (%1)) %2 %endmacro %imacro alignb 1-2+.nolist - %if __SECTALIGN_ALIGN_UPDATES_SECTION__ + %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__ sectalign %1 %endif %ifempty %2 @@ -175,30 +177,34 @@ STD: nasm [cpu %1] %endmacro -%define __FLOAT_DAZ__ nodaz -%define __FLOAT_ROUND__ near -; __FLOAT__ contains the whole floating-point configuration so it can +%define __?FLOAT_DAZ?__ nodaz +%define __?FLOAT_ROUND?__ near +; __?FLOAT?__ contains the whole floating-point configuration so it can ; be saved and restored -%define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__ +%define __?FLOAT?__ __?FLOAT_DAZ?__,__?FLOAT_ROUND?__ + +%defalias __FLOAT_DAZ__ __?FLOAT_DAZ?__ +%defalias __FLOAT_ROUND__ __?FLOAT_ROUND?__ +%defalias __FLOAT__ __?FLOAT?__ %imacro float 1-*.nolist %rep %0 [float %1] %ifidni %1,daz - %define __FLOAT_DAZ__ daz + %define __?FLOAT_DAZ?__ daz %elifidni %1,nodaz - %define __FLOAT_DAZ__ nodaz + %define __?FLOAT_DAZ?__ nodaz %elifidni %1,near - %define __FLOAT_ROUND__ near + %define __?FLOAT_ROUND?__ near %elifidni %1,up - %define __FLOAT_ROUND__ up + %define __?FLOAT_ROUND?__ up %elifidni %1,down - %define __FLOAT_ROUND__ down + %define __?FLOAT_ROUND?__ down %elifidni %1,zero - %define __FLOAT_ROUND__ zero + %define __?FLOAT_ROUND?__ zero %elifidni %1,default - %define __FLOAT_DAZ__ nodaz - %define __FLOAT_ROUND__ near + %define __?FLOAT_DAZ?__ nodaz + %define __?FLOAT_ROUND?__ near %endif %rotate 1 %endrep @@ -228,3 +234,85 @@ STD: nasm %? %$dep,%2 %pop %endmacro + +; Compatibility macro aliases +%defalias __NASM_MAJOR__ __?NASM_MAJOR?__ +%defalias __NASM_MINOR__ __?NASM_MINOR?__ +%defalias __NASM_SUBMINOR__ __?NASM_SUBMINOR?__ +%defalias __NASM_PATCHLEVEL__ __?NASM_PATCHLEVEL?__ +%defalias __NASM_SNAPSHOT__ __?NASM_SNAPSHOT?__ +%defalias __NASM_VERSION_ID__ __?NASM_VERSION_ID?__ +%defalias __NASM_VER__ __?NASM_VER?__ + +%defalias __OUTPUT_FORMAT__ __?OUTPUT_FORMAT?__ +%defalias __DEBUG_FORMAT__ __?DEBUG_FORMAT?__ + +%defalias __DATE__ __?DATE?__ +%defalias __DATE_NUM__ __?DATE_NUM?__ +%defalias __TIME__ __?TIME?__ +%defalias __TIME_NUM__ __?TIME_NUM?__ +%defalias __UTC_DATE__ __?UTC_DATE?__ +%defalias __UTC_DATE_NUM__ __?UTC_DATE_NUM?__ +%defalias __UTC_TIME__ __?UTC_TIME?__ +%defalias __UTC_TIME_NUM__ __?UTC_TIME_NUM?__ +%defalias __POSIX_TIME__ __?POSIX_TIME?__ + +%defalias __FILE__ __?FILE?__ +%defalias __LINE__ __?LINE?__ +%defalias __BITS__ __?BITS?__ +%defalias __PTR__ __?PTR?__ +%defalias __PASS__ __?PASS?__ + +; Backwards compatiblity aliases for tokens. The extra level of indirection here +; means %aliases on|off will do the right thing for these as well. +%idefine __?infinity?__ %? +%idefine __?nan?__ %? +%idefine __?qnan?__ %? +%idefine __?snan?__ %? + +%idefine __?float8?__ %? +%idefine __?float16?__ %? +%idefine __?float32?__ %? +%idefine __?float64?__ %? +%idefine __?float80m?__ %? +%idefine __?float80e?__ %? +%idefine __?float128l?__ %? +%idefine __?float128h?__ %? + +%idefine __?utf16?__ %? +%idefine __?utf16le?__ %? +%idefine __?utf16be?__ %? +%idefine __?utf32?__ %? +%idefine __?utf32le?__ %? +%idefine __?utf32be?__ %? + +%idefine __?ilog2e?__ %? +%idefine __?ilog2w?__ %? +%idefine __?ilog2f?__ %? +%idefine __?ilog2c?__ %? + +%idefalias __infinity__ __?infinity?__ +%idefalias __nan__ __?nan?__ +%idefalias __qnan__ __?qnan?__ +%idefalias __snan__ __?snan?__ + +%idefalias __float8__ __?float8?__ +%idefalias __float16__ __?float16?__ +%idefalias __float32__ __?float32?__ +%idefalias __float64__ __?float64?__ +%idefalias __float80m__ __?float80m?__ +%idefalias __float80e__ __?float80e?__ +%idefalias __float128l__ __?float128l?__ +%idefalias __float128h__ __?float128h?__ + +%idefalias __utf16__ __?utf16?__ +%idefalias __utf16le__ __?utf16le?__ +%idefalias __utf16be__ __?utf16be?__ +%idefalias __utf32__ __?utf32?__ +%idefalias __utf32le__ __?utf32le?__ +%idefalias __utf32be__ __?utf32be?__ + +%idefalias __ilog2e__ __?ilog2e?__ +%idefalias __ilog2w__ __?ilog2w?__ +%idefalias __ilog2f__ __?ilog2f?__ +%idefalias __ilog2c__ __?ilog2c?__ |