limits: allow querying limits, and reset limits for each pass

Allow limits to be queried via a %limit() preprocessor function and a
__?NASM_LIMITS?__ macro.

Reset limits at the top of each pass. Note that the pass number limits
are checked at the *end* of the pass, so a %pragma limit will be
properly honored anyway.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-04-09 16:56:01 -07:00
parent 444ef5a122
commit fe5235ffc9
8 changed files with 224 additions and 7 deletions

View file

@ -964,9 +964,20 @@ enum nasm_limit {
LIMIT_MAX /* Must be at end */
};
#define LIMIT_MAX_VAL (INT64_MAX >> 1) /* Absolute maximum for any limit */
extern int64_t nasm_limit[LIMIT_MAX];
extern enum directive_result nasm_set_limit(const char *, const char *);
enum get_limit_which {
GET_LIMIT_CURRENT,
GET_LIMIT_INIT,
GET_LIMIT_DEFAULT,
GET_LIMIT_MAX
};
extern int64_t nasm_get_limit(const char *, enum get_limit_which);
extern const char *nasm_limit_name(enum nasm_limit);
/*
* The data structure defining an output format driver, and the
* interfaces to the functions therein.