summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-09-24 10:20:40 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-09-24 10:20:40 -0700
commit7383b407d9dac305ff150431df40f03051f6d6c9 (patch)
tree69cfc73ee6fb266625cd6b6f3dd0c8108126f0bb
parent917a3496f062ce35547816b560ba5a1b2c563574 (diff)
downloadnasm-7383b407d9dac305ff150431df40f03051f6d6c9.tar.gz
Add __PASS__ builtin macro
Add a new builtin macro, __PASS__, which is either 1 (for a preparatory pass), 2 (for a final pass, including preprocessor only), or 0 (for dependency generation.) This might be useful in special contexts. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--preproc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/preproc.c b/preproc.c
index 915b0cbe..ba895a55 100644
--- a/preproc.c
+++ b/preproc.c
@@ -4218,6 +4218,8 @@ static void
pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
ListGen * listgen, StrList **deplist)
{
+ Token *t;
+
_error = errfunc;
cstk = NULL;
istk = nasm_malloc(sizeof(Include));
@@ -4256,6 +4258,15 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
*deptail = sl;
deptail = &sl->next;
}
+
+ /* Define the __PASS__ macro. This is defined here unlike
+ all the other builtins, because it is special -- it varies between
+ passes. */
+ t = nasm_malloc(sizeof(*t));
+ t->next = NULL;
+ make_tok_num(t, pass);
+ t->a.mac = NULL;
+ define_smacro(NULL, "__PASS__", true, 0, t);
}
static char *pp_getline(void)