listing: make "list engine active" part of the list options
List engine active is useful information in its own right. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
8c9b8ec2e2
commit
42de8879a2
3 changed files with 28 additions and 17 deletions
|
@ -130,6 +130,7 @@ static void list_cleanup(void)
|
||||||
list_emit();
|
list_emit();
|
||||||
fclose(listfp);
|
fclose(listfp);
|
||||||
listfp = NULL;
|
listfp = NULL;
|
||||||
|
active_list_options = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_init(const char *fname)
|
static void list_init(const char *fname)
|
||||||
|
@ -153,6 +154,8 @@ static void list_init(const char *fname)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
active_list_options = list_options | 1;
|
||||||
|
|
||||||
*listline = '\0';
|
*listline = '\0';
|
||||||
listlineno = 0;
|
listlineno = 0;
|
||||||
list_errors = NULL;
|
list_errors = NULL;
|
||||||
|
|
|
@ -126,35 +126,38 @@ extern bool user_nolist;
|
||||||
extern uint64_t list_options, active_list_options;
|
extern uint64_t list_options, active_list_options;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This maps the characters a-z, A-Z and 0-9 onto a 64-bit bitmask
|
* This maps the characters a-z, A-Z and 0-9 onto a 64-bit bitmask.
|
||||||
* (with two bits left over for future use! This isn't particularly
|
* Bit 0 is used to indicate that the listing engine is active, and
|
||||||
* efficient code, but just about every instance of it should be
|
* bit 1 is reserved, so this will only return mask bits 2 and higher;
|
||||||
* fed a constant, so the entire function can be precomputed at
|
* as there are 62 possible characters this fits nicely.
|
||||||
* compile time. The only cases where the full computation is needed
|
*
|
||||||
* is when parsing the -L option or %pragma list options, neither of
|
* The mask returned is 0 for invalid characters, accessing no bits at
|
||||||
* which is in any way performance critical.
|
* all.
|
||||||
|
*
|
||||||
|
* This isn't particularly efficient code, but just about every
|
||||||
|
* instance of it should be fed a constant, so the entire function can
|
||||||
|
* be precomputed at compile time. The only cases where the full
|
||||||
|
* computation is needed is when parsing the -L option or %pragma list
|
||||||
|
* options, neither of which is in any way performance critical.
|
||||||
*
|
*
|
||||||
* The character + represents ALL listing options.
|
* The character + represents ALL listing options.
|
||||||
*
|
|
||||||
* This returns 0 for invalid values, so that no bit is accessed
|
|
||||||
* for unsupported characters.
|
|
||||||
*/
|
*/
|
||||||
static inline const_func uint64_t list_option_mask(unsigned char x)
|
static inline const_func uint64_t list_option_mask(unsigned char x)
|
||||||
{
|
{
|
||||||
if (x >= 'a') {
|
if (x >= 'a') {
|
||||||
if (x > 'z')
|
if (x > 'z')
|
||||||
return 0;
|
return 0;
|
||||||
x = x - 'a';
|
x = x - 'a' + 2;
|
||||||
} else if (x >= 'A') {
|
} else if (x >= 'A') {
|
||||||
if (x > 'Z')
|
if (x > 'Z')
|
||||||
return 0;
|
return 0;
|
||||||
x = x - 'A' + 26;
|
x = x - 'A' + 2 + 26;
|
||||||
} else if (x >= '0') {
|
} else if (x >= '0') {
|
||||||
if (x > '9')
|
if (x > '9')
|
||||||
return 0;
|
return 0;
|
||||||
x = x - '0' + 26*2;
|
x = x - '0' + 2 + 26*2;
|
||||||
} else if (x == '+') {
|
} else if (x == '+') {
|
||||||
return ~UINT64_C(0);
|
return ~UINT64_C(1);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +165,7 @@ static inline const_func uint64_t list_option_mask(unsigned char x)
|
||||||
return UINT64_C(1) << x;
|
return UINT64_C(1) << x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if the listing engine is active and a certain option is set. */
|
||||||
static inline pure_func bool list_option(unsigned char x)
|
static inline pure_func bool list_option(unsigned char x)
|
||||||
{
|
{
|
||||||
return unlikely(active_list_options & list_option_mask(x));
|
return unlikely(active_list_options & list_option_mask(x));
|
||||||
|
@ -173,6 +177,12 @@ static inline pure_func bool list_on_every_pass(void)
|
||||||
return unlikely(list_options & list_option_mask('p'));
|
return unlikely(list_options & list_option_mask('p'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Is the listing engine active? */
|
||||||
|
static inline pure_func bool list_active(void)
|
||||||
|
{
|
||||||
|
return (active_list_options & 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pragma handler */
|
/* Pragma handler */
|
||||||
enum directive_result list_pragma(const struct pragma *);
|
enum directive_result list_pragma(const struct pragma *);
|
||||||
|
|
||||||
|
|
|
@ -1685,9 +1685,8 @@ static void assemble_file(const char *fname, struct strlist *depend_list)
|
||||||
cpu = cmd_cpu;
|
cpu = cmd_cpu;
|
||||||
if (listname) {
|
if (listname) {
|
||||||
if (pass_final() || list_on_every_pass()) {
|
if (pass_final() || list_on_every_pass()) {
|
||||||
active_list_options = list_options;
|
|
||||||
lfmt->init(listname);
|
lfmt->init(listname);
|
||||||
} else if (active_list_options) {
|
} else if (list_active()) {
|
||||||
/*
|
/*
|
||||||
* Looks like we used the list engine on a previous pass,
|
* Looks like we used the list engine on a previous pass,
|
||||||
* but now it is turned off, presumably via %pragma -p
|
* but now it is turned off, presumably via %pragma -p
|
||||||
|
@ -1695,7 +1694,6 @@ static void assemble_file(const char *fname, struct strlist *depend_list)
|
||||||
lfmt->cleanup();
|
lfmt->cleanup();
|
||||||
if (!keep_all)
|
if (!keep_all)
|
||||||
remove(listname);
|
remove(listname);
|
||||||
active_list_options = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue