Make some static tables and strings constants.

By doing this we move them from the .data section to .rodata setion,
or from .data.rel to .data.rel.ro.

The .rodata section is mapped directly from the on-disk file, which is
always a save, while .data.rel.ro is mapped directly when using
prelink, which is a save in a lot of cases.

Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
This commit is contained in:
Diego E. 'Flameeyes' Pettenò 2008-11-21 01:21:32 +01:00
parent 29a14294fc
commit 8ed98db259
14 changed files with 49 additions and 49 deletions

View file

@ -1005,7 +1005,7 @@ static void usage(void)
int main(int argc, char **argv)
{
static struct option long_options[] = {
static const struct option long_options[] = {
{"help", 0, 0, 'h'},
{ 0 , 0 , 0, 0 }
};

View file

@ -44,7 +44,7 @@ void snd_async_init(void)
}
#else
/** async signal number */
static int snd_async_signo = SIGIO;
static const int snd_async_signo = SIGIO;
#endif
static LIST_HEAD(snd_async_handlers);

View file

@ -89,10 +89,10 @@ typedef struct {
#endif
/* First table lookup for Ima-ADPCM quantizer */
static char IndexAdjust[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
static const char IndexAdjust[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
/* Second table lookup for Ima-ADPCM quantizer */
static short StepSize[89] = {
static const short StepSize[89] = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
50, 55, 60, 66, 73, 80, 88, 97, 107, 118,

View file

@ -654,7 +654,7 @@ static int hw_param_interval_refine_minmax(snd_pcm_hw_params_t *params,
int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
snd_pcm_direct_t *dshare = pcm->private_data;
static snd_mask_t access = { .bits = {
static const snd_mask_t access = { .bits = {
(1<<SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) |
(1<<SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) |
(1<<SNDRV_PCM_ACCESS_RW_INTERLEAVED) |

View file

@ -45,14 +45,14 @@ typedef struct snd_pcm_extplug_priv {
struct snd_ext_parm sparams[SND_PCM_EXTPLUG_HW_PARAMS];
} extplug_priv_t;
static int hw_params_type[SND_PCM_EXTPLUG_HW_PARAMS] = {
static const int hw_params_type[SND_PCM_EXTPLUG_HW_PARAMS] = {
[SND_PCM_EXTPLUG_HW_FORMAT] = SND_PCM_HW_PARAM_FORMAT,
[SND_PCM_EXTPLUG_HW_CHANNELS] = SND_PCM_HW_PARAM_CHANNELS
};
#define is_mask_type(i) (hw_params_type[i] < SND_PCM_HW_PARAM_FIRST_INTERVAL)
static unsigned int excl_parbits[SND_PCM_EXTPLUG_HW_PARAMS] = {
static const unsigned int excl_parbits[SND_PCM_EXTPLUG_HW_PARAMS] = {
[SND_PCM_EXTPLUG_HW_FORMAT] = (SND_PCM_HW_PARBIT_FORMAT|
SND_PCM_HW_PARBIT_SUBFORMAT |
SND_PCM_HW_PARBIT_SAMPLE_BITS),

View file

@ -100,14 +100,14 @@ static void setup_wav_header(snd_pcm_t *pcm, struct wav_fmt *fmt)
static int write_wav_header(snd_pcm_t *pcm)
{
snd_pcm_file_t *file = pcm->private_data;
static char header[] = {
static const char header[] = {
'R', 'I', 'F', 'F',
0x24, 0, 0, 0,
'W', 'A', 'V', 'E',
'f', 'm', 't', ' ',
0x10, 0, 0, 0,
};
static char header2[] = {
static const char header2[] = {
'd', 'a', 't', 'a',
0, 0, 0, 0
};

View file

@ -453,7 +453,7 @@ int snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo
snd_pcm_t *pcm;
snd_pcm_iec958_t *iec;
int err;
static unsigned char default_status_bits[] = {
static const unsigned char default_status_bits[] = {
IEC958_AES0_CON_EMPHASIS_NONE,
IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
0,

View file

@ -146,7 +146,7 @@ static int snd_pcm_ioplug_prepare(snd_pcm_t *pcm)
return 0;
}
static int hw_params_type[SND_PCM_IOPLUG_HW_PARAMS] = {
static const int hw_params_type[SND_PCM_IOPLUG_HW_PARAMS] = {
[SND_PCM_IOPLUG_HW_ACCESS] = SND_PCM_HW_PARAM_ACCESS,
[SND_PCM_IOPLUG_HW_FORMAT] = SND_PCM_HW_PARAM_FORMAT,
[SND_PCM_IOPLUG_HW_CHANNELS] = SND_PCM_HW_PARAM_CHANNELS,
@ -483,7 +483,7 @@ static int snd_pcm_ioplug_drain(snd_pcm_t *pcm)
static int snd_pcm_ioplug_pause(snd_pcm_t *pcm, int enable)
{
ioplug_priv_t *io = pcm->private_data;
static snd_pcm_state_t states[2] = {
static const snd_pcm_state_t states[2] = {
SND_PCM_STATE_RUNNING, SND_PCM_STATE_PAUSED
};
int prev, err;

View file

@ -623,7 +623,7 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
return 0;
}
static int linear_formats[4][2][2] = {
static const int linear_formats[4][2][2] = {
{ { SNDRV_PCM_FORMAT_S8, SNDRV_PCM_FORMAT_S8 },
{ SNDRV_PCM_FORMAT_U8, SNDRV_PCM_FORMAT_U8 } },
{ { SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_FORMAT_S16_BE },
@ -634,7 +634,7 @@ static int linear_formats[4][2][2] = {
{ SNDRV_PCM_FORMAT_U32_LE, SNDRV_PCM_FORMAT_U32_BE } }
};
static int linear24_formats[3][2][2] = {
static const int linear24_formats[3][2][2] = {
{ { SNDRV_PCM_FORMAT_S24_3LE, SNDRV_PCM_FORMAT_S24_3BE },
{ SNDRV_PCM_FORMAT_U24_3LE, SNDRV_PCM_FORMAT_U24_3BE } },
{ { SNDRV_PCM_FORMAT_S20_3LE, SNDRV_PCM_FORMAT_S20_3BE },

View file

@ -1232,7 +1232,7 @@ void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params,
#define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
const char *snd_pcm_hw_param_names[] = {
const char *const snd_pcm_hw_param_names[] = {
HW_PARAM(ACCESS),
HW_PARAM(FORMAT),
HW_PARAM(SUBFORMAT),
@ -1660,7 +1660,7 @@ int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
typedef struct _snd_pcm_hw_rule snd_pcm_hw_rule_t;
typedef int (*snd_pcm_hw_rule_func_t)(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule);
const snd_pcm_hw_rule_t *rule);
struct _snd_pcm_hw_rule {
int var;
@ -1670,7 +1670,7 @@ struct _snd_pcm_hw_rule {
};
static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
snd_interval_t t;
snd_interval_mul(hw_param_interval_c(params, rule->deps[0]),
@ -1679,7 +1679,7 @@ static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,
}
static int snd_pcm_hw_rule_div(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
snd_interval_t t;
snd_interval_div(hw_param_interval_c(params, rule->deps[0]),
@ -1688,7 +1688,7 @@ static int snd_pcm_hw_rule_div(snd_pcm_hw_params_t *params,
}
static int snd_pcm_hw_rule_muldivk(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
snd_interval_t t;
snd_interval_muldivk(hw_param_interval_c(params, rule->deps[0]),
@ -1698,7 +1698,7 @@ static int snd_pcm_hw_rule_muldivk(snd_pcm_hw_params_t *params,
}
static int snd_pcm_hw_rule_mulkdiv(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
snd_interval_t t;
snd_interval_mulkdiv(hw_param_interval_c(params, rule->deps[0]),
@ -1708,7 +1708,7 @@ static int snd_pcm_hw_rule_mulkdiv(snd_pcm_hw_params_t *params,
}
static int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
int changed = 0;
snd_pcm_format_t k;
@ -1733,7 +1733,7 @@ static int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params,
static int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params,
snd_pcm_hw_rule_t *rule)
const snd_pcm_hw_rule_t *rule)
{
unsigned int min, max;
snd_pcm_format_t k;
@ -1767,7 +1767,7 @@ static int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params,
return changed;
}
static snd_pcm_hw_rule_t refine_rules[] = {
static const snd_pcm_hw_rule_t refine_rules[] = {
{
.var = SND_PCM_HW_PARAM_FORMAT,
.func = snd_pcm_hw_rule_format,
@ -1911,7 +1911,7 @@ static snd_pcm_hw_rule_t refine_rules[] = {
#define RULES (sizeof(refine_rules) / sizeof(refine_rules[0]))
static snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PARAM_FIRST_MASK + 1] = {
static const snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PARAM_FIRST_MASK + 1] = {
[SND_PCM_HW_PARAM_ACCESS - SND_PCM_HW_PARAM_FIRST_MASK] = {
.bits = { 0x1f },
},
@ -1923,7 +1923,7 @@ static snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PARAM_FIR
},
};
static snd_interval_t refine_intervals[SND_PCM_HW_PARAM_LAST_INTERVAL - SND_PCM_HW_PARAM_FIRST_INTERVAL + 1] = {
static const snd_interval_t refine_intervals[SND_PCM_HW_PARAM_LAST_INTERVAL - SND_PCM_HW_PARAM_FIRST_INTERVAL + 1] = {
[SND_PCM_HW_PARAM_SAMPLE_BITS - SND_PCM_HW_PARAM_FIRST_INTERVAL] = {
.min = 1, .max = UINT_MAX,
.openmin = 0, .openmax = 0, .integer = 1, .empty = 0,
@ -2022,7 +2022,7 @@ int snd_pcm_hw_refine_soft(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t
do {
again = 0;
for (k = 0; k < RULES; k++) {
snd_pcm_hw_rule_t *r = &refine_rules[k];
const snd_pcm_hw_rule_t *r = &refine_rules[k];
unsigned int d;
int doit = 0;
for (d = 0; r->deps[d] >= 0; d++) {

View file

@ -87,7 +87,7 @@ static int snd_pcm_plug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
return 0;
}
static snd_pcm_format_t linear_preferred_formats[] = {
static const snd_pcm_format_t linear_preferred_formats[] = {
#ifdef SND_LITTLE_ENDIAN
SND_PCM_FORMAT_S16_LE,
SND_PCM_FORMAT_U16_LE,
@ -176,7 +176,7 @@ static snd_pcm_format_t linear_preferred_formats[] = {
#endif
#ifdef BUILD_PCM_NONLINEAR
static snd_pcm_format_t nonlinear_preferred_formats[] = {
static const snd_pcm_format_t nonlinear_preferred_formats[] = {
#ifdef BUILD_PCM_PLUGIN_MULAW
SND_PCM_FORMAT_MU_LAW,
#endif
@ -190,7 +190,7 @@ static snd_pcm_format_t nonlinear_preferred_formats[] = {
#endif
#ifdef BUILD_PCM_PLUGIN_LFLOAT
static snd_pcm_format_t float_preferred_formats[] = {
static const snd_pcm_format_t float_preferred_formats[] = {
#ifdef SND_LITTLE_ENDIAN
SND_PCM_FORMAT_FLOAT_LE,
SND_PCM_FORMAT_FLOAT64_LE,
@ -205,7 +205,7 @@ static snd_pcm_format_t float_preferred_formats[] = {
};
#endif
static char linear_format_widths[32] = {
static const char linear_format_widths[32] = {
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 1,
0, 1, 0, 1, 0, 0, 0, 1,
@ -615,7 +615,7 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
snd_pcm_plug_params_t *slave)
{
snd_pcm_plug_t *plug = pcm->private_data;
static int (*funcs[])(snd_pcm_t *_pcm, snd_pcm_t **new, snd_pcm_plug_params_t *s, snd_pcm_plug_params_t *d) = {
static int (*const funcs[])(snd_pcm_t *_pcm, snd_pcm_t **new, snd_pcm_plug_params_t *s, snd_pcm_plug_params_t *d) = {
#ifdef BUILD_PCM_PLUGIN_MMAP_EMUL
snd_pcm_plug_change_mmap,
#endif

View file

@ -61,7 +61,7 @@ typedef struct {
#define ZERO_DB 0.0
#define MAX_DB_UPPER_LIMIT 50
static unsigned int preset_dB_value[PRESET_RESOLUTION] = {
static const unsigned int preset_dB_value[PRESET_RESOLUTION] = {
0x00b8, 0x00bd, 0x00c1, 0x00c5, 0x00ca, 0x00cf, 0x00d4, 0x00d9,
0x00de, 0x00e3, 0x00e8, 0x00ed, 0x00f3, 0x00f9, 0x00fe, 0x0104,
0x010a, 0x0111, 0x0117, 0x011e, 0x0124, 0x012b, 0x0132, 0x0139,
@ -714,7 +714,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
/* set up dB table */
if (min_dB == PRESET_MIN_DB && max_dB == ZERO_DB && resolution == PRESET_RESOLUTION)
svol->dB_value = preset_dB_value;
svol->dB_value = (unsigned int*)preset_dB_value;
else {
#ifndef HAVE_SOFT_FLOAT
svol->dB_value = calloc(resolution, sizeof(unsigned int));

View file

@ -108,7 +108,7 @@ copy_64: as_s64(dst) = as_s64c(src); goto COPY_END;
#ifdef CONV_LABELS
/* src_wid src_endswap sign_toggle dst_wid dst_endswap */
static void *conv_labels[4 * 2 * 2 * 4 * 2] = {
static void *const conv_labels[4 * 2 * 2 * 4 * 2] = {
&&conv_xxx1_xxx1, /* 8h -> 8h */
&&conv_xxx1_xxx1, /* 8h -> 8s */
&&conv_xxx1_xx10, /* 8h -> 16h */
@ -341,7 +341,7 @@ conv_1234_123C: as_u32(dst) = as_u32c(src) ^ 0x80; goto CONV_END;
#ifdef GET16_LABELS
/* src_wid src_endswap sign_toggle */
static void *get16_labels[4 * 2 * 2 + 4 * 3] = {
static void *const get16_labels[4 * 2 * 2 + 4 * 3] = {
&&get16_1_10, /* 8h -> 16h */
&&get16_1_90, /* 8h ^> 16h */
&&get16_1_10, /* 8s -> 16h */
@ -407,7 +407,7 @@ get16_123_B2_18: sample = (_get_triple_s(src) >> 2) ^ 0x8000; goto GET16_END;
#ifdef PUT16_LABELS
/* dst_wid dst_endswap sign_toggle */
static void *put16_labels[4 * 2 * 2] = {
static void *const put16_labels[4 * 2 * 2] = {
&&put16_12_1, /* 16h -> 8h */
&&put16_12_9, /* 16h ^> 8h */
&&put16_12_1, /* 16h -> 8s */
@ -453,7 +453,7 @@ put16_12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT16_END;
#ifdef GET32_LABELS
/* src_wid src_endswap sign_toggle */
static void *get32_labels[4 * 2 * 2 + 4 * 3] = {
static void *const get32_labels[4 * 2 * 2 + 4 * 3] = {
&&get32_1_1000, /* 8h -> 32h */
&&get32_1_9000, /* 8h ^> 32h */
&&get32_1_1000, /* 8s -> 32h */
@ -528,7 +528,7 @@ __conv24_get: goto *put;
#ifdef PUT32_LABELS
/* dst_wid dst_endswap sign_toggle */
static void *put32_labels[4 * 2 * 2 + 4 * 3] = {
static void *const put32_labels[4 * 2 * 2 + 4 * 3] = {
&&put32_1234_1, /* 32h -> 8h */
&&put32_1234_9, /* 32h ^> 8h */
&&put32_1234_1, /* 32h -> 8s */
@ -604,7 +604,7 @@ put32_1234_329_18: _put_triple_s(dst, (sample ^ 0x80000000) >> 14); goto PUT32_E
#ifdef GETU_LABELS
/* width endswap sign_toggle */
static void *getu_labels[4 * 2 * 2] = {
static void *const getu_labels[4 * 2 * 2] = {
&&getu_1_1, /* 8h -> 8h */
&&getu_1_9, /* 8h ^> 8h */
&&getu_1_1, /* 8s -> 8h */
@ -645,7 +645,7 @@ getu_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GETU_END;
#ifdef GETS_LABELS
/* width endswap sign_toggle */
static void *gets_labels[4 * 2 * 2] = {
static void *const gets_labels[4 * 2 * 2] = {
&&gets_1_1, /* 8h -> 8h */
&&gets_1_9, /* 8h ^> 8h */
&&gets_1_1, /* 8s -> 8h */
@ -686,7 +686,7 @@ gets_1234_C321: sample = (int32_t)bswap_32(as_s32c(src) ^ 0x80); goto GETS_END;
#ifdef PUT_LABELS
/* width endswap sign_toggle */
static void *put_labels[4 * 2 * 2] = {
static void *const put_labels[4 * 2 * 2] = {
&&put_1_1, /* 8h -> 8h */
&&put_1_9, /* 8h ^> 8h */
&&put_1_1, /* 8h -> 8s */
@ -726,7 +726,7 @@ put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END;
#ifdef PUT32F_LABELS
/* type (0 = float, 1 = float64), endswap */
static void *put32float_labels[2 * 2] = {
static void *const put32float_labels[2 * 2] = {
&&put32f_1234_1234F, /* 32h -> (float)h */
&&put32f_1234_4321F, /* 32h -> (float)s */
&&put32f_1234_1234D, /* 32h -> (float64)h */
@ -745,7 +745,7 @@ put32f_1234_4321D: tmp_double.d = (double_t)((int32_t)sample) / (double_t)0x8000
#ifdef GET32F_LABELS
/* type (0 = float, 1 = float64), endswap */
static void *get32float_labels[2 * 2] = {
static void *const get32float_labels[2 * 2] = {
&&get32f_1234F_1234, /* (float)h -> 32h */
&&get32f_4321F_1234, /* (float)s -> 32h */
&&get32f_1234D_1234, /* (float64)h -> 32h */
@ -924,7 +924,7 @@ static inline void _norms(const void *src, void *dst,
}
/* src_wid dst_sign dst_wid dst_end */
static void *norms_labels[4 * 2 * 4 * 2] = {
static void *const norms_labels[4 * 2 * 4 * 2] = {
&&norms_8_u8, /* s8 -> u8 */
&&norms_8_u8, /* s8 -> u8 */
&&norms_8_u16h, /* s8 -> u16h */

View file

@ -78,7 +78,7 @@ static void songpos_decode(const snd_seq_event_t *ev, unsigned char *buf);
* event list
*/
#ifndef DOC_HIDDEN
static struct status_event_list_t {
static const struct status_event_list_t {
int event;
int qlen;
event_encode_t encode;
@ -116,7 +116,7 @@ static struct status_event_list_t {
static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int len, const snd_seq_event_t *ev);
static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, const snd_seq_event_t *ev);
static struct extra_event_list_t {
static const struct extra_event_list_t {
int event;
int (*decode)(snd_midi_event_t *dev, unsigned char *buf, int len, const snd_seq_event_t *ev);
} extra_event[] = {
@ -549,12 +549,12 @@ static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int co
static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, const snd_seq_event_t *ev)
{
unsigned char cmd;
char *cbytes;
static char cbytes_nrpn[4] = { MIDI_CTL_NONREG_PARM_NUM_MSB,
const char *cbytes;
static const char cbytes_nrpn[4] = { MIDI_CTL_NONREG_PARM_NUM_MSB,
MIDI_CTL_NONREG_PARM_NUM_LSB,
MIDI_CTL_MSB_DATA_ENTRY,
MIDI_CTL_LSB_DATA_ENTRY };
static char cbytes_rpn[4] = { MIDI_CTL_REGIST_PARM_NUM_MSB,
static const char cbytes_rpn[4] = { MIDI_CTL_REGIST_PARM_NUM_MSB,
MIDI_CTL_REGIST_PARM_NUM_LSB,
MIDI_CTL_MSB_DATA_ENTRY,
MIDI_CTL_LSB_DATA_ENTRY };