diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-05-27 18:05:51 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-05-27 18:05:51 +0200 |
commit | c60e0bb8d9ff77590bf127ea09f2258421973823 (patch) | |
tree | a04778aef5a7f507c884f1859ac23c44d0e97e22 | |
parent | 397c63c7dee0f85a2d9776d5bb8aa98776a99ccd (diff) | |
download | salsa-lib-c60e0bb8d9ff77590bf127ea09f2258421973823.tar.gz |
Add --enable-abicheck configure option
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | src/control.c | 7 | ||||
-rw-r--r-- | src/ctl_func.h | 5 | ||||
-rw-r--r-- | src/ctl_macros.h | 9 | ||||
-rw-r--r-- | src/hcontrol.c | 7 | ||||
-rw-r--r-- | src/hctl_func.h | 5 | ||||
-rw-r--r-- | src/hctl_macros.h | 10 | ||||
-rw-r--r-- | src/local.h | 7 | ||||
-rw-r--r-- | src/mixer.c | 7 | ||||
-rw-r--r-- | src/mixer_func.h | 4 | ||||
-rw-r--r-- | src/mixer_macros.h | 12 | ||||
-rw-r--r-- | src/pcm.c | 7 | ||||
-rw-r--r-- | src/pcm_func.h | 5 | ||||
-rw-r--r-- | src/pcm_macros.h | 10 | ||||
-rw-r--r-- | src/rawmidi.c | 7 | ||||
-rw-r--r-- | src/rawmidi_func.h | 5 | ||||
-rw-r--r-- | src/rawmidi_macros.h | 12 | ||||
-rw-r--r-- | src/recipe.h.in | 4 |
19 files changed, 141 insertions, 0 deletions
@@ -102,6 +102,9 @@ It's disabled as default. With option --enable-libasound, libasound.so will be created as an opt-in ABI-compatible library with the genuine ALSA-lib. +When --enable-abicheck is given, each open function checks the ABI +compatibility with the installed library. + All these options can be enabled via a single option, --enable-everything, for your convenience. diff --git a/configure.ac b/configure.ac index 2227ed9..70c552b 100644 --- a/configure.ac +++ b/configure.ac @@ -121,6 +121,11 @@ AC_ARG_ENABLE(float, [drop the support for 4bit PCM (IMA ADPCM)]), support_4bit="$enableval", support_4bit="yes") +AC_ARG_ENABLE(abicheck, + AS_HELP_STRING([--enable-abicheck], + [enable library ABI check]), + abicheck="$enableval", abicheck="no") + AC_ARG_ENABLE(everything, AS_HELP_STRING([--enable-everything], [enable everything :)]), @@ -141,6 +146,7 @@ if test "$everything" = "yes"; then output_buffer="yes" support_float="yes" support_4bit="yes" + abicheck="yes" fi SALSA_DEPLIBS="" @@ -183,6 +189,7 @@ else SALSA_MARK_DEPRECATED=0 fi AC_SUBST(SALSA_MARK_DEPRECATED) + if test "$output_buffer" = "yes"; then SALSA_SUPPORT_OUTPUT_BUFFER=1 else @@ -205,6 +212,13 @@ else fi AC_SUBST(SALSA_SUPPORT_4BIT_PCM) +if test "$abicheck" = "yes"; then + SALSA_CHECK_ABI=1 +else + SALSA_CHECK_ABI=0 +fi +AC_SUBST(SALSA_CHECK_ABI) + if test "$delight_valgrind" = "yes"; then AC_DEFINE(DELIGHT_VALGRIND) fi @@ -261,3 +275,4 @@ echo " - Make ABI-compatible libasound.so: $libasound" echo " - Mark deprecated attribute: $markdeprecated" echo " - Support string-output via snd_output: $output_buffer" echo " - Support floating-point: $support_float" +echo " - Enable library ABI check: $abicheck" diff --git a/src/control.c b/src/control.c index 522f986..ff47a74 100644 --- a/src/control.c +++ b/src/control.c @@ -38,12 +38,19 @@ * open/close */ +#if SALSA_CHECK_ABI +int _snd_ctl_open(snd_ctl_t **ctlp, const char *name, int mode, + unsigned int magic) +#else int snd_ctl_open(snd_ctl_t **ctlp, const char *name, int mode) +#endif { snd_ctl_t *ctl; char filename[sizeof(SALSA_DEVPATH) + 24]; int err, fmode, fd, card, ver; + check_incompatible_abi(magic, SALSA_CTL_MAGIC); + *ctlp = NULL; err = _snd_dev_get_device(name, &card, NULL, NULL); diff --git a/src/ctl_func.h b/src/ctl_func.h index 87ff259..32de1c6 100644 --- a/src/ctl_func.h +++ b/src/ctl_func.h @@ -27,7 +27,12 @@ int snd_card_get_index(const char *name); int snd_card_get_name(int card, char **name); int snd_card_get_longname(int card, char **name); +#if SALSA_CHECK_ABI +int _snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode, + unsigned int magic); +#else int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode); +#endif int snd_ctl_close(snd_ctl_t *ctl); int snd_ctl_wait(snd_ctl_t *ctl, int timeout); diff --git a/src/ctl_macros.h b/src/ctl_macros.h index fae15c0..d690942 100644 --- a/src/ctl_macros.h +++ b/src/ctl_macros.h @@ -28,6 +28,15 @@ struct _snd_ctl { }; +#if SALSA_CHECK_ABI +#define SALSA_CTL_MAGIC sizeof(struct _snd_ctl) +__SALSA_EXPORT_FUNC +int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode) +{ + return _snd_ctl_open(ctl, name, mode, SALSA_CTL_MAGIC); +} +#endif + __SALSA_EXPORT_FUNC int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock) { diff --git a/src/hcontrol.c b/src/hcontrol.c index 22a862b..86d4aed 100644 --- a/src/hcontrol.c +++ b/src/hcontrol.c @@ -34,11 +34,18 @@ /* * open/close */ +#if SALSA_CHECK_ABI +int _snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode, + unsigned int magic) +#else int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode) +#endif { snd_ctl_t *ctl; int err; + check_incompatible_abi(magic, SALSA_HCTL_MAGIC); + err = snd_ctl_open(&ctl, name, mode); if (err < 0) return err; diff --git a/src/hctl_func.h b/src/hctl_func.h index 5d925d0..678b548 100644 --- a/src/hctl_func.h +++ b/src/hctl_func.h @@ -18,7 +18,12 @@ typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl, typedef int (*snd_hctl_elem_callback_t)(snd_hctl_elem_t *elem, unsigned int mask); +#if SALSA_CHECK_ABI +int _snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode, + unsigned int magic); +#else int snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode); +#endif int snd_hctl_open_ctl(snd_hctl_t **hctlp, snd_ctl_t *ctl); int snd_hctl_close(snd_hctl_t *hctl); snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id); diff --git a/src/hctl_macros.h b/src/hctl_macros.h index 8ebe476..fc1348b 100644 --- a/src/hctl_macros.h +++ b/src/hctl_macros.h @@ -34,6 +34,16 @@ struct _snd_hctl_elem { }; +#if SALSA_CHECK_ABI +#define SALSA_HCTL_MAGIC \ + ((sizeof(struct _snd_hctl) << 8) | sizeof(struct _snd_hctl_elem)) +__SALSA_EXPORT_FUNC +int snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode) +{ + return _snd_hctl_open(hctl, name, mode, SALSA_HCTL_MAGIC); +} +#endif + __SALSA_EXPORT_FUNC int snd_hctl_wait(snd_hctl_t *hctl, int timeout) { diff --git a/src/local.h b/src/local.h index 64ea15a..05e09da 100644 --- a/src/local.h +++ b/src/local.h @@ -17,4 +17,11 @@ int _snd_pcm_munmap(snd_pcm_t *pcm); #define memzero_valgrind(buf, size) #endif +#if SALSA_CHECK_ABI +#include <assert.h> +#define check_incompatible_abi(magic, orig) assert(magic == orig) +#else +#define check_incompatible_abi(magic, orig) +#endif + #endif /* __LOCAL_H_INC */ diff --git a/src/mixer.c b/src/mixer.c index 11ac673..3f87eca 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -33,9 +33,16 @@ static int hctl_event_handler(snd_hctl_t *hctl, unsigned int mask, snd_hctl_elem_t *elem); +#if SALSA_CHECK_ABI +int _snd_mixer_open(snd_mixer_t **mixerp, int mode, unsigned int magic) +#else int snd_mixer_open(snd_mixer_t **mixerp, int mode) +#endif { snd_mixer_t *mixer; + + check_incompatible_abi(magic, SALSA_MIXER_MAGIC); + mixer = calloc(1, sizeof(*mixer)); *mixerp = mixer; if (mixer == NULL) diff --git a/src/mixer_func.h b/src/mixer_func.h index 841c5fa..3eb0174 100644 --- a/src/mixer_func.h +++ b/src/mixer_func.h @@ -56,7 +56,11 @@ struct snd_mixer_selem_regopt { typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t; +#if SALSA_CHECK_ABI +int _snd_mixer_open(snd_mixer_t **mixer, int mode, unsigned int magic); +#else int snd_mixer_open(snd_mixer_t **mixer, int mode); +#endif int snd_mixer_close(snd_mixer_t *mixer); int snd_mixer_handle_events(snd_mixer_t *mixer); int snd_mixer_attach(snd_mixer_t *mixer, const char *name); diff --git a/src/mixer_macros.h b/src/mixer_macros.h index c1372bf..8c8ae86 100644 --- a/src/mixer_macros.h +++ b/src/mixer_macros.h @@ -89,6 +89,18 @@ struct _snd_mixer_elem { }; +#if SALSA_CHECK_ABI +#define SALSA_MIXER_MAGIC \ + (sizeof(struct _snd_mixer) | (sizeof(struct _snd_mixer_elem) << 8) | \ + (sizeof(snd_selem_item_head_t) + sizeof(snd_selem_vol_item_t) + \ + sizeof(snd_selem_sw_item_t) + sizeof(snd_selem_enum_item_t))) +__SALSA_EXPORT_FUNC +int snd_mixer_open(snd_mixer_t **mixer, int mode) +{ + return _snd_mixer_open(mixer, mode, SALSA_MIXER_MAGIC); +} +#endif + __SALSA_EXPORT_FUNC int snd_mixer_poll_descriptors_count(snd_mixer_t *mixer) { @@ -49,14 +49,21 @@ static int get_pcm_subdev(int fd) return info.subdevice; } +#if SALSA_CHECK_ABI +int _snd_pcm_open(snd_pcm_t **pcmp, const char *name, + snd_pcm_stream_t stream, int mode, unsigned int magic) +#else int snd_pcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) +#endif { char filename[sizeof(SALSA_DEVPATH) + 24]; int card, dev, subdev; int fd, err, fmode, ver; snd_pcm_t *pcm = NULL; + check_incompatible_abi(magic, SALSA_PCM_MAGIC); + *pcmp = NULL; err = _snd_dev_get_device(name, &card, &dev, &subdev); diff --git a/src/pcm_func.h b/src/pcm_func.h index 7cea5f5..d1c6b42 100644 --- a/src/pcm_func.h +++ b/src/pcm_func.h @@ -77,8 +77,13 @@ typedef struct _snd_pcm_channel_area { unsigned int step; } snd_pcm_channel_area_t; +#if SALSA_CHECK_ABI +int _snd_pcm_open(snd_pcm_t **pcm, const char *name, + snd_pcm_stream_t stream, int mode, unsigned int magic); +#else int snd_pcm_open(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode); +#endif int snd_pcm_close(snd_pcm_t *pcm); int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); int snd_pcm_hw_free(snd_pcm_t *pcm); diff --git a/src/pcm_macros.h b/src/pcm_macros.h index 91daab6..85ff656 100644 --- a/src/pcm_macros.h +++ b/src/pcm_macros.h @@ -74,6 +74,16 @@ struct _snd_pcm { * Macros */ +#if SALSA_CHECK_ABI +#define SALSA_PCM_MAGIC sizeof(struct _snd_pcm) +__SALSA_EXPORT_FUNC +int snd_pcm_open(snd_pcm_t **pcm, const char *name, + snd_pcm_stream_t stream, int mode) +{ + return _snd_pcm_open(pcm, name, stream, mode, SALSA_PCM_MAGIC); +} +#endif + __SALSA_EXPORT_FUNC int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) { diff --git a/src/rawmidi.c b/src/rawmidi.c index e30ddf5..46332ac 100644 --- a/src/rawmidi.c +++ b/src/rawmidi.c @@ -66,14 +66,21 @@ static snd_rawmidi_t *new_rmidi(snd_rawmidi_hw_t *hw, int stream, int mode) return rmidi; } +#if SALSA_CHECK_ABI +int _snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, + const char *name, int mode, unsigned int magic) +#else int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode) +#endif { int fd, err, fmode, ver; int card, dev, subdev; char filename[sizeof(SALSA_DEVPATH) + 24]; snd_rawmidi_hw_t *hw; + check_incompatible_abi(magic, SALSA_RAWMIDI_MAGIC); + if (in_rmidi) *in_rmidi = NULL; if (out_rmidi) diff --git a/src/rawmidi_func.h b/src/rawmidi_func.h index c6c49fd..e108e93 100644 --- a/src/rawmidi_func.h +++ b/src/rawmidi_func.h @@ -16,7 +16,12 @@ typedef enum _snd_rawmidi_type { SND_RAWMIDI_TYPE_VIRTUAL /* not used by SALSA */ } snd_rawmidi_type_t; +#if SALSA_CHECK_ABI +int _snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, + const char *name, int mode, unsigned int magic); +#else int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode); +#endif int snd_rawmidi_close(snd_rawmidi_t *rmidi); diff --git a/src/rawmidi_macros.h b/src/rawmidi_macros.h index 9586c18..c32b440 100644 --- a/src/rawmidi_macros.h +++ b/src/rawmidi_macros.h @@ -34,6 +34,18 @@ struct _snd_rawmidi { /* */ +#if SALSA_CHECK_ABI +#define SALSA_RAWMIDI_MAGIC \ + ((sizeof(struct _snd_rawmidi_hw) << 8) | sizeof(struct _snd_rawmidi)) +__SALSA_EXPORT_FUNC +int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, + const char *name, int mode) +{ + return _snd_rawmidi_open(in_rmidi, out_rmidi, name, mode, + SALSA_RAWMIDI_MAGIC); +} +#endif + __SALSA_EXPORT_FUNC __SALSA_NOT_IMPLEMENTED int snd_rawmidi_open_lconf(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode, snd_config_t *lconf) diff --git a/src/recipe.h.in b/src/recipe.h.in index b59b867..9a99150 100644 --- a/src/recipe.h.in +++ b/src/recipe.h.in @@ -22,6 +22,10 @@ /* Support 4bit PCM (IMA ADPCM) */ #define SALSA_SUPPORT_4BIT_PCM @SALSA_SUPPORT_4BIT_PCM@ +/* Enable library ABI check */ +#define SALSA_CHECK_ABI @SALSA_CHECK_ABI@ + +/* Default device path prefix */ #define SALSA_DEVPATH "@DEVPATH@" #endif /* __ALSA_RECIPE_H */ |