Placate gcc's strict aliasing rules with an extra cast.
authorRyan C. Gordon
Thu, 20 Oct 2005 06:53:56 +0000
changeset 116105d4b93b911e
parent 1160 72c6c3e5bb85
child 1162 2651158f59b8
Placate gcc's strict aliasing rules with an extra cast.
Casts to (char *) will disable strict aliasing when the compiler sees it.
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Thu Oct 13 09:47:06 2005 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Thu Oct 20 06:53:56 2005 +0000
     1.3 @@ -93,28 +93,29 @@
     1.4  static int (*SDL_NAME(snd_pcm_nonblock))(snd_pcm_t *pcm, int nonblock);
     1.5  #define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof)
     1.6  
     1.7 +/* cast funcs to char* first, to please GCC's strict aliasing rules. */
     1.8  static struct {
     1.9  	const char *name;
    1.10  	void **func;
    1.11  } alsa_functions[] = {
    1.12 -	{ "snd_pcm_open",	(void**)&SDL_NAME(snd_pcm_open)		},
    1.13 -	{ "snd_pcm_close",	(void**)&SDL_NAME(snd_pcm_close)	},
    1.14 -	{ "snd_pcm_writei",	(void**)&SDL_NAME(snd_pcm_writei)	},
    1.15 -	{ "snd_pcm_resume",	(void**)&SDL_NAME(snd_pcm_resume)	},
    1.16 -	{ "snd_pcm_prepare",	(void**)&SDL_NAME(snd_pcm_prepare)	},
    1.17 -	{ "snd_pcm_drain",	(void**)&SDL_NAME(snd_pcm_drain)	},
    1.18 -	{ "snd_strerror",	(void**)&SDL_NAME(snd_strerror)		},
    1.19 -	{ "snd_pcm_hw_params_sizeof",		(void**)&SDL_NAME(snd_pcm_hw_params_sizeof)		},
    1.20 -	{ "snd_pcm_hw_params_any",		(void**)&SDL_NAME(snd_pcm_hw_params_any)		},
    1.21 -	{ "snd_pcm_hw_params_set_access",	(void**)&SDL_NAME(snd_pcm_hw_params_set_access)		},
    1.22 -	{ "snd_pcm_hw_params_set_format",	(void**)&SDL_NAME(snd_pcm_hw_params_set_format)		},
    1.23 -	{ "snd_pcm_hw_params_set_channels",	(void**)&SDL_NAME(snd_pcm_hw_params_set_channels)	},
    1.24 -	{ "snd_pcm_hw_params_get_channels",	(void**)&SDL_NAME(snd_pcm_hw_params_get_channels)	},
    1.25 -	{ "snd_pcm_hw_params_set_rate_near",	(void**)&SDL_NAME(snd_pcm_hw_params_set_rate_near)	},
    1.26 -	{ "snd_pcm_hw_params_set_period_size_near",	(void**)&SDL_NAME(snd_pcm_hw_params_set_period_size_near)	},
    1.27 -	{ "snd_pcm_hw_params_set_periods_near",	(void**)&SDL_NAME(snd_pcm_hw_params_set_periods_near)	},
    1.28 -	{ "snd_pcm_hw_params",	(void**)&SDL_NAME(snd_pcm_hw_params)	},
    1.29 -	{ "snd_pcm_nonblock",	(void**)&SDL_NAME(snd_pcm_nonblock)	},
    1.30 +	{ "snd_pcm_open",	(void**)(char*)&SDL_NAME(snd_pcm_open)		},
    1.31 +	{ "snd_pcm_close",	(void**)(char*)&SDL_NAME(snd_pcm_close)	},
    1.32 +	{ "snd_pcm_writei",	(void**)(char*)&SDL_NAME(snd_pcm_writei)	},
    1.33 +	{ "snd_pcm_resume",	(void**)(char*)&SDL_NAME(snd_pcm_resume)	},
    1.34 +	{ "snd_pcm_prepare",	(void**)(char*)&SDL_NAME(snd_pcm_prepare)	},
    1.35 +	{ "snd_pcm_drain",	(void**)(char*)&SDL_NAME(snd_pcm_drain)	},
    1.36 +	{ "snd_strerror",	(void**)(char*)&SDL_NAME(snd_strerror)		},
    1.37 +	{ "snd_pcm_hw_params_sizeof",		(void**)(char*)&SDL_NAME(snd_pcm_hw_params_sizeof)		},
    1.38 +	{ "snd_pcm_hw_params_any",		(void**)(char*)&SDL_NAME(snd_pcm_hw_params_any)		},
    1.39 +	{ "snd_pcm_hw_params_set_access",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_access)		},
    1.40 +	{ "snd_pcm_hw_params_set_format",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_format)		},
    1.41 +	{ "snd_pcm_hw_params_set_channels",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_channels)	},
    1.42 +	{ "snd_pcm_hw_params_get_channels",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_channels)	},
    1.43 +	{ "snd_pcm_hw_params_set_rate_near",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_rate_near)	},
    1.44 +	{ "snd_pcm_hw_params_set_period_size_near",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_period_size_near)	},
    1.45 +	{ "snd_pcm_hw_params_set_periods_near",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_periods_near)	},
    1.46 +	{ "snd_pcm_hw_params",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params)	},
    1.47 +	{ "snd_pcm_nonblock",	(void**)(char*)&SDL_NAME(snd_pcm_nonblock)	},
    1.48  };
    1.49  
    1.50  static void UnloadALSALibrary(void) {