limits: revamp the limit processor, change params limit to dynamic

Revamp the limit processor to allow a limit to have an absolute
maximum other than LIMIT_MAX_VAL.

Use LIMIT_MAX as a final enum parameter == parameter count == final
actual value + 1, which is the more usual construct and doesn't need
manual updating.

Allow setting a limit to the default value by setting it to "0" or
"default".

Accept "max" or "maximum" instead of "unlimited", specifically to
better handle the case of a fixed maximum < LIMIT_MAX_VAL.

Change the mmacro limit parameter to a dynamic limit, in case someone
needs it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-04-09 15:12:19 -07:00
parent e856c2e1dd
commit a8d44ce956
3 changed files with 119 additions and 55 deletions

View file

@ -959,11 +959,13 @@ enum nasm_limit {
LIMIT_MMACROS,
LIMIT_REP,
LIMIT_EVAL,
LIMIT_LINES
LIMIT_LINES,
LIMIT_PARAMS,
LIMIT_MAX /* Must be at end */
};
#define LIMIT_MAX LIMIT_LINES
extern int64_t nasm_limit[LIMIT_MAX+1];
extern enum directive_result nasm_set_limit(const char *, const char *);
extern int64_t nasm_limit[LIMIT_MAX];
extern enum directive_result nasm_set_limit(const char *, const char *);
/*
* The data structure defining an output format driver, and the