diff options
author | H. Peter Anvin <hpa@zytor.com> | 2013-11-24 17:13:20 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2013-11-24 17:13:20 -0800 |
commit | af90d3520fe647e390638f93e020c9b2712fd280 (patch) | |
tree | 818aff6f88f0107b417f265949d3747d97a1afb4 | |
parent | 54c7711858e458c4cd0817b21fc4351f9714a7c1 (diff) | |
download | nasm-af90d3520fe647e390638f93e020c9b2712fd280.tar.gz nasm-af90d3520fe647e390638f93e020c9b2712fd280.tar.bz2 nasm-af90d3520fe647e390638f93e020c9b2712fd280.zip |
iflag: Make the insns_flags array const
Make the insns_flags array const, and change the helper functions to
match.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | iflag.h | 14 | ||||
-rw-r--r-- | insns-iflags.pl | 6 |
2 files changed, 11 insertions, 9 deletions
@@ -13,7 +13,7 @@ int ilog2_32(uint32_t v); #define IF_GENBIT(bit) (UINT32_C(1) << (bit)) -static inline unsigned int iflag_test(iflag_t *f,unsigned int bit) +static inline unsigned int iflag_test(const iflag_t *f, unsigned int bit) { unsigned int index = bit / 32; return f->field[index] & (UINT32_C(1) << (bit - (index * 32))); @@ -41,7 +41,7 @@ static inline void iflag_set_all(iflag_t *f) memset(f, 0xff, sizeof(*f)); } -static inline int iflag_cmp(iflag_t *a, iflag_t *b) +static inline int iflag_cmp(const iflag_t *a, const iflag_t *b) { unsigned int i; @@ -55,7 +55,7 @@ static inline int iflag_cmp(iflag_t *a, iflag_t *b) return 0; } -static inline int iflag_cmp_cpu(iflag_t *a, iflag_t *b) +static inline int iflag_cmp_cpu(const iflag_t *a, const iflag_t *b) { if (a->field[3] < b->field[3]) return -1; @@ -64,7 +64,7 @@ static inline int iflag_cmp_cpu(iflag_t *a, iflag_t *b) return 0; } -static inline unsigned int iflag_ffs(iflag_t *a) +static inline unsigned int iflag_ffs(const iflag_t *a) { unsigned int i; @@ -77,7 +77,7 @@ static inline unsigned int iflag_ffs(iflag_t *a) } #define IF_GEN_HELPER(name, op) \ - static inline iflag_t iflag_##name(iflag_t *a, iflag_t *b) \ + static inline iflag_t iflag_##name(const iflag_t *a, const iflag_t *b) \ { \ unsigned int i; \ iflag_t res; \ @@ -122,7 +122,7 @@ IF_GEN_HELPER(xor, ^) #define itemp_arg(itemp) __itemp_arg((itemp)->iflag_idx) #define itemp_armask(itemp) __itemp_armask((itemp)->iflag_idx) -static inline int iflag_cmp_cpu_level(iflag_t *a, iflag_t *b) +static inline int iflag_cmp_cpu_level(const iflag_t *a, const iflag_t *b) { iflag_t v1 = *a; iflag_t v2 = *b; @@ -141,7 +141,7 @@ static inline int iflag_cmp_cpu_level(iflag_t *a, iflag_t *b) return 0; } -static inline iflag_t __iflag_pfmask(iflag_t *a) +static inline iflag_t __iflag_pfmask(const iflag_t *a) { iflag_t r = (iflag_t) { .field[1] = a->field[1], diff --git a/insns-iflags.pl b/insns-iflags.pl index b954c73..8f8e009 100644 --- a/insns-iflags.pl +++ b/insns-iflags.pl @@ -215,7 +215,8 @@ sub write_iflaggen_h() { print N "} iflag_t;\n"; print N "\n"; - printf N "extern iflag_t insns_flags[%d];\n\n", $#insns_flag_values + 1; + printf N "extern const iflag_t insns_flags[%d];\n\n", + $#insns_flag_values + 1; print N "#endif /* NASM_IFLAGGEN_H */\n"; close N; @@ -229,7 +230,8 @@ sub write_iflag_c() { print N "/* This file is auto-generated. Don't edit. */\n"; print N "#include \"iflag.h\"\n\n"; print N "/* Global flags referenced from instruction templates */\n"; - print N sprintf("iflag_t insns_flags[%d] = {\n", $#insns_flag_values + 1); + printf N "const iflag_t insns_flags[%d] = {\n", + $#insns_flag_values + 1; foreach my $i (0 .. $#insns_flag_values) { print N sprintf(" /* %4d */ {{ %s }},\n", $i, $insns_flag_values[$i]); } |