From: Jaroslav Kysela Date: Wed, 24 Oct 2001 14:14:11 +0000 (+0000) Subject: Changes for static build. X-Git-Tag: v1.0.3~629 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=27472b56a68c2ba7479f345560796b937afbf986;p=alsa-lib.git Changes for static build. --- diff --git a/INSTALL b/INSTALL index b4e080e9..76474d4c 100644 --- a/INSTALL +++ b/INSTALL @@ -34,4 +34,15 @@ For compilation you can use these commands: make Note: Some automake packages have missing aclocal program. Use newer version - in this case. + in the case. + +Compilation of static library +----------------------------- + +If you would like to use the static ALSA library, you need to use these +options for the configure script: + + ./configure --enable-shared=no --enable-static=yes + +Unfortunately, due to bug in the libtool script, the shared and static +library cannot be built together. diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index 1bad25ed..ba518b84 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -30,6 +30,6 @@ SHOW_INCLUDE_FILES = NO JAVADOC_AUTOBRIEF = NO INHERIT_DOCS = YES ENABLED_SECTIONS = "" -PREDEFINED = "DOC_HIDDEN" +PREDEFINED = PIC "DOC_HIDDEN" OPTIMIZE_OUTPUT_FOR_C = YES # doxygen 1.2.6 option diff --git a/include/global.h b/include/global.h index bfacac2d..cd72e552 100644 --- a/include/global.h +++ b/include/global.h @@ -38,14 +38,45 @@ #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) /**< don't print warning when attribute is not used */ #endif -/** helper macro for SND_DLSYM_BUILD_VERSION */ +#ifdef PIC /* dynamic build */ + +/** helper macro for SND_DLSYM_BUILD_VERSION \hideinitializer */ #define __SND_DLSYM_VERSION(name, version) _ ## name ## version -/** build version for versioned dynamic symbol */ -#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version) +/** build version for versioned dynamic symbol \hideinitializer */ +#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version); + +#else /* static build */ + +struct snd_dlsym_link { + struct snd_dlsym_link *next; + const char *dlsym_name; + const void *dlsym_ptr; +}; + +extern struct snd_dlsym_link *snd_dlsym_start; + +/** helper macro for SND_DLSYM_BUILD_VERSION \hideinitializer */ +#define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version +/** build version for versioned dynamic symbol \hideinitializer */ +#define SND_DLSYM_BUILD_VERSION(name, version) \ + static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \ + void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \ + void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \ + __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \ + __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \ + __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \ + snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \ + } + +#endif + /** get version of dynamic symbol as string */ #define SND_DLSYM_VERSION(version) __STRING(version) -int snd_dlsym_verify(void *handle, const char *name, const char *version); +void *snd_dlopen(const char *file, int mode); +void *snd_dlsym(void *handle, const char *name, const char *version); +int snd_dlclose(void *handle); + /** Async notification client handler */ typedef struct _snd_async_handler snd_async_handler_t; diff --git a/src/conf.c b/src/conf.c index d7ea6c12..671b2d77 100644 --- a/src/conf.c +++ b/src/conf.c @@ -31,8 +31,8 @@ #include #include -#include #include +#include #include "local.h" #ifndef DOC_HIDDEN @@ -1801,17 +1801,15 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, void buf[len-1] = '\0'; func_name = buf; } - h = dlopen(lib, RTLD_NOW); - if ((err = snd_dlsym_verify(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_HOOK))) < 0) - goto _err; - func = h ? dlsym(h, func_name) : NULL; + h = snd_dlopen(lib, RTLD_NOW); + func = h ? snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_HOOK)) : NULL; err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!func) { SNDERR("symbol %s is not defined inside %s", func_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: @@ -1822,7 +1820,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, void err = func(root, config, &nroot, private_data); if (err < 0) SNDERR("function %s returned error: %s", func_name, snd_strerror(err)); - dlclose(h); + snd_dlclose(h); if (err >= 0 && nroot) snd_config_substitute(root, nroot); } @@ -1869,9 +1867,6 @@ static int snd_config_hooks(snd_config_t *config, void *private_data) return err; } -#ifndef DOC_HIDDEN -SND_DLSYM_BUILD_VERSION(snd_config_hook_load, SND_CONFIG_DLSYM_VERSION_HOOK); -#endif /** * \brief Load configuration from specified files * \param root Configuration root node @@ -2001,14 +1996,14 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t snd_config_delete(n); return err; } - #ifndef DOC_HIDDEN -int snd_determine_driver(int card, char **driver); +SND_DLSYM_BUILD_VERSION(snd_config_hook_load, SND_CONFIG_DLSYM_VERSION_HOOK); #endif #ifndef DOC_HIDDEN -SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK); +int snd_determine_driver(int card, char **driver); #endif + /** * \brief Load configuration for all present cards * \param root Configuration root node @@ -2056,6 +2051,9 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, *dst = NULL; return 0; } +#ifndef DOC_HIDDEN +SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK); +#endif /** * \brief Update #snd_config rereading (if needed) files specified in @@ -2510,19 +2508,16 @@ static int _snd_config_evaluate(snd_config_t *src, buf[len-1] = '\0'; func_name = buf; } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_EVALUATE))) < 0) - goto _err; - func = dlsym(h, func_name); - } + h = snd_dlopen(lib, RTLD_NOW); + if (h) + func = snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_EVALUATE)); err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); return -ENOENT; } else if (!func) { SNDERR("symbol %s is not defined inside %s", func_name, lib); - dlclose(h); + snd_dlclose(h); return -ENXIO; } _err: @@ -2533,7 +2528,7 @@ static int _snd_config_evaluate(snd_config_t *src, err = func(&eval, root, src, private_data); if (err < 0) SNDERR("function %s returned error: %s", func_name, snd_strerror(err)); - dlclose(h); + snd_dlclose(h); if (err >= 0 && eval) snd_config_substitute(src, eval); } diff --git a/src/confmisc.c b/src/confmisc.c index 70c2a8d2..efdb0713 100644 --- a/src/confmisc.c +++ b/src/confmisc.c @@ -142,7 +142,6 @@ int snd_config_get_ctl_iface(snd_config_t *conf) * Helper functions for the configuration file */ -SND_DLSYM_BUILD_VERSION(snd_func_getenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n, *d; @@ -220,8 +219,8 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v free(def); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_getenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *d; @@ -246,8 +245,8 @@ int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, _end: return err; } +SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_concat, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -311,8 +310,8 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v __error: return err; } +SND_DLSYM_BUILD_VERSION(snd_func_concat, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED) { @@ -321,6 +320,7 @@ int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, err = snd_config_set_string(*dst, DATADIR "/alsa"); return 0; } +SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE); static int open_ctl(long card, snd_ctl_t **ctl) { @@ -344,7 +344,6 @@ static int string_from_integer(char **dst, long v) } #endif -SND_DLSYM_BUILD_VERSION(snd_func_private_string, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data) { int err; @@ -356,6 +355,7 @@ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNU err = snd_config_set_string(*dst, (char *)private_data); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_private_string, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_determine_driver(int card, char **driver) { @@ -389,7 +389,6 @@ int snd_determine_driver(int card, char **driver) return err; } -SND_DLSYM_BUILD_VERSION(snd_func_private_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_private_card_strtype(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data) { char *driver; @@ -403,8 +402,8 @@ int snd_func_private_card_strtype(snd_config_t **dst, snd_config_t *root ATTRIBU free(driver); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_private_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_card_strtype(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -436,8 +435,8 @@ int snd_func_card_strtype(snd_config_t **dst, snd_config_t *root, snd_config_t * free(str); return snd_func_private_card_strtype(dst, root, src, (void *)v); } +SND_DLSYM_BUILD_VERSION(snd_func_card_strtype, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_card_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -487,8 +486,8 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_ctl_close(ctl); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_card_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_pcm_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -560,8 +559,8 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v snd_ctl_close(ctl); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_pcm_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, void *private_data) { char *res = NULL; @@ -585,8 +584,8 @@ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIB free(res); return err; } +SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION_EVALUATE); -SND_DLSYM_BUILD_VERSION(snd_func_refer, SND_CONFIG_DLSYM_VERSION_EVALUATE); int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -645,3 +644,4 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, vo _end: return err; } +SND_DLSYM_BUILD_VERSION(snd_func_refer, SND_CONFIG_DLSYM_VERSION_EVALUATE); diff --git a/src/control/Makefile.am b/src/control/Makefile.am index bfb0e594..072bdf2b 100644 --- a/src/control/Makefile.am +++ b/src/control/Makefile.am @@ -2,7 +2,7 @@ EXTRA_LTLIBRARIES = libcontrol.la libcontrol_la_SOURCES = cards.c hcontrol.c \ control.c control_hw.c control_shm.c \ - setup.c + setup.c control_symbols.c noinst_HEADERS = control_local.h diff --git a/src/control/control.c b/src/control/control.c index d21a7a0f..029a860f 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -33,8 +33,8 @@ #include #include #include -#include #include +#include #include #include "control_local.h" @@ -475,6 +475,9 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, snd_config_iterator_t i, next; const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_ctl_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL; +#ifndef PIC + extern void *snd_control_open_symbols(void); +#endif void *h; if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -529,21 +532,19 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, open_name = buf; snprintf(buf, sizeof(buf), "_snd_ctl_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_control_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION)); err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/control/control_hw.c b/src/control/control_hw.c index df364731..e9b147c5 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -29,6 +29,11 @@ #include #include "control_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_control_hw = ""; +#endif + #ifndef F_SETSIG #define F_SETSIG 10 #endif @@ -336,7 +341,6 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode) return 0; } -SND_DLSYM_BUILD_VERSION(_snd_ctl_hw_open, SND_CONTROL_DLSYM_VERSION); int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf) { snd_config_iterator_t i, next; @@ -368,4 +372,4 @@ int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root ATTRIBU return -EINVAL; return snd_ctl_hw_open(handlep, name, card, 0); } - +SND_DLSYM_BUILD_VERSION(_snd_ctl_hw_open, SND_CONTROL_DLSYM_VERSION); diff --git a/src/control/control_shm.c b/src/control/control_shm.c index f4572eb6..24b416e6 100644 --- a/src/control/control_shm.c +++ b/src/control/control_shm.c @@ -35,6 +35,11 @@ #include #include "aserver.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_control_shm = ""; +#endif + typedef struct { int socket; volatile snd_ctl_shm_ctrl_t *ctrl; @@ -553,7 +558,6 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname return result; } -SND_DLSYM_BUILD_VERSION(_snd_ctl_shm_open, SND_CONTROL_DLSYM_VERSION); int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode) { snd_config_iterator_t i, next; @@ -668,3 +672,4 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c snd_config_delete(sconfig); return err; } +SND_DLSYM_BUILD_VERSION(_snd_ctl_shm_open, SND_CONTROL_DLSYM_VERSION); diff --git a/src/dlmisc.c b/src/dlmisc.c index 61e58f45..4fd497b0 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -30,6 +30,41 @@ #include #include "local.h" +#ifndef DOC_HIDDEN +#ifndef PIC +struct snd_dlsym_link *snd_dlsym_start = NULL; +#endif +#endif + +/** + * \brief Open the dynamic library, with ALSA extension + * \param name name, similar to dlopen + * \param mode mode, similar to dlopen + * \return pointer to handle + */ +void *snd_dlopen(const char *name, int mode) +{ +#ifndef PIC + if (name == NULL) + return &snd_dlsym_start; +#endif + return dlopen(name, mode); +} + +/** + * \brief Close the dynamic library, with ALSA extension + * \param handle handle, similar to dlclose + * \return zero if success, otherwise an error code + */ +int snd_dlclose(void *handle) +{ +#ifndef PIC + if (handle == &snd_dlsym_start) + return 0; +#endif + return dlclose(handle); +} + /** * \brief Verify dynamically loaded symbol * \param handle dlopen handle @@ -37,7 +72,7 @@ * \param version version of symbol * \return zero is success, otherwise a negative error code */ -int snd_dlsym_verify(void *handle, const char *name, const char *version) +static int snd_dlsym_verify(void *handle, const char *name, const char *version) { int res; char *vname; @@ -54,3 +89,31 @@ int snd_dlsym_verify(void *handle, const char *name, const char *version) SNDERR("unable to verify version for symbol %s", name); return res; } +/** + * \brief Resolve the symbol, with ALSA extension + * \param handle handle, similar to dlsym + * \param name symbol name + * \param version symbol version + */ +void *snd_dlsym(void *handle, const char *name, const char *version) +{ + int err; + +#ifndef PIC + if (handle == &snd_dlsym_start) { + /* it's the funny part, we are looking for a symbol */ + /* in a static library */ + struct snd_dlsym_link *link = snd_dlsym_start; + while (link) { + if (!strcmp(name, link->dlsym_name)) + return (void *)link->dlsym_ptr; + link = link->next; + } + return NULL; + } +#endif + err = snd_dlsym_verify(handle, name, version); + if (err < 0) + return NULL; + return dlsym(handle, name); +} diff --git a/src/hwdep/Makefile.am b/src/hwdep/Makefile.am index 471b7a78..0b626b90 100644 --- a/src/hwdep/Makefile.am +++ b/src/hwdep/Makefile.am @@ -1,6 +1,6 @@ EXTRA_LTLIBRARIES=libhwdep.la -libhwdep_la_SOURCES = hwdep.c hwdep_hw.c +libhwdep_la_SOURCES = hwdep.c hwdep_hw.c hwdep_symbols.c noinst_HEADERS = hwdep_local.h all: libhwdep.la diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index ac76f469..5180de95 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -48,6 +48,9 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, snd_config_iterator_t i, next; const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_hwdep_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL; +#ifndef PIC + extern void *snd_hwdep_open_symbols(void); +#endif void *h; if (snd_config_get_type(hwdep_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -102,20 +105,18 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, open_name = buf; snprintf(buf, sizeof(buf), "_snd_hwdep_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_hwdep_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION)); if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/hwdep/hwdep_hw.c b/src/hwdep/hwdep_hw.c index 2a436171..63ea4d6d 100644 --- a/src/hwdep/hwdep_hw.c +++ b/src/hwdep/hwdep_hw.c @@ -27,6 +27,11 @@ #include #include "hwdep_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_hwdep_hw = ""; +#endif + #define SNDRV_FILE_HWDEP "/dev/snd/hwC%iD%i" #define SNDRV_HWDEP_VERSION_MAX SNDRV_PROTOCOL_VERSION(1, 0, 0) @@ -137,7 +142,6 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi return 0; } -SND_DLSYM_BUILD_VERSION(_snd_hwdep_hw_open, SND_HWDEP_DLSYM_VERSION); int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int mode) @@ -178,3 +182,4 @@ int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name, return -EINVAL; return snd_hwdep_hw_open(hwdep, name, card, device, mode); } +SND_DLSYM_BUILD_VERSION(_snd_hwdep_hw_open, SND_HWDEP_DLSYM_VERSION); diff --git a/src/pcm/Makefile.am b/src/pcm/Makefile.am index 58026004..38d41b44 100644 --- a/src/pcm/Makefile.am +++ b/src/pcm/Makefile.am @@ -7,7 +7,7 @@ libpcm_la_SOURCES = atomic.c mask.c interval.c \ pcm_route.c pcm_mulaw.c pcm_alaw.c pcm_adpcm.c \ pcm_rate.c pcm_plug.c pcm_misc.c pcm_mmap.c pcm_multi.c \ pcm_shm.c pcm_file.c pcm_null.c pcm_share.c \ - pcm_meter.c pcm_hooks.c + pcm_meter.c pcm_hooks.c pcm_symbols.c noinst_HEADERS = atomic.h pcm_local.h pcm_plugin.h mask.h mask_inline.h \ interval.h interval_inline.h plugin_ops.h diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 61ea1852..4ff5df8c 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -38,12 +38,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "pcm_local.h" /** @@ -1027,6 +1027,9 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, int (*open_func)(snd_pcm_t **, const char *, snd_config_t *, snd_config_t *, snd_pcm_stream_t, int) = NULL; +#ifndef PIC + extern void *snd_pcm_open_symbols(void); +#endif void *h; if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -1081,21 +1084,19 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, open_name = buf; snprintf(buf, sizeof(buf), "_snd_pcm_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_pcm_open_symbols(); /* this call is for static linking only */ +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION)); err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: @@ -1139,7 +1140,6 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, } #ifndef DOC_HIDDEN - int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name, snd_pcm_stream_t stream, int mode) { diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index 2b43154d..d21b263d 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -51,6 +51,11 @@ IMA compatability project proceedings, Vol 2, Issue 2, May 1992. #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_adpcm = ""; +#endif + typedef void (*adpcm_f)(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, @@ -541,7 +546,6 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_adpcm_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -586,5 +590,4 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_adpcm_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index dd1e9d9b..d11df70d 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -23,6 +23,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_alaw = ""; +#endif + typedef void (*alaw_f)(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, @@ -414,7 +419,6 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_alaw_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -459,5 +463,4 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_alaw_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index 796b7633..3e02f03c 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -23,6 +23,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_copy = ""; +#endif + typedef struct { /* This field need to be the first */ snd_pcm_plugin_t plug; @@ -184,7 +189,6 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_copy_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -221,4 +225,4 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - +SND_DLSYM_BUILD_VERSION(_snd_pcm_copy_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 9e21d52f..525f35de 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -23,6 +23,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_file = ""; +#endif + typedef enum _snd_pcm_file_format { SND_PCM_FILE_FORMAT_RAW } snd_pcm_file_format_t; @@ -456,7 +461,6 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_file_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -520,3 +524,4 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } +SND_DLSYM_BUILD_VERSION(_snd_pcm_file_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_hooks.c b/src/pcm/pcm_hooks.c index 47f066f5..59a625bd 100644 --- a/src/pcm/pcm_hooks.c +++ b/src/pcm/pcm_hooks.c @@ -22,6 +22,11 @@ #include #include "pcm_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_hooks = ""; +#endif + #ifndef DOC_HIDDEN struct _snd_pcm_hook { snd_pcm_t *pcm; @@ -430,7 +435,6 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_hooks_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -499,6 +503,7 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, *pcmp = rpcm; return 0; } +SND_DLSYM_BUILD_VERSION(_snd_pcm_hooks_open, SND_PCM_DLSYM_VERSION); #endif diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 6223f77e..9bdaf5ab 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -31,6 +31,11 @@ #include "pcm_local.h" #include "../control/control_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_hw = ""; +#endif + #ifndef F_SETSIG #define F_SETSIG 10 #endif @@ -654,7 +659,6 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, int card, int device, in return ret; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_hw_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -709,4 +713,4 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, } return snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream, mode); } - +SND_DLSYM_BUILD_VERSION(_snd_pcm_hw_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 3b4a68dc..ca33a48c 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -23,6 +23,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_linear = ""; +#endif + typedef struct { /* This field need to be the first */ snd_pcm_plugin_t plug; @@ -319,7 +324,6 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_linear_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -363,5 +367,4 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_linear_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index 54517306..bde9bb63 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -34,6 +34,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_meter = ""; +#endif + #if defined(__sparc__) || defined(__ia64__) || defined(__mips__) /* asm/atomic.h is unavailable on sparc and ia64 */ #define atomic_t int @@ -728,8 +733,6 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name, return err >= 0 ? open_func(pcm, name, root, conf) : err; } - -SND_DLSYM_BUILD_VERSION(_snd_pcm_meter_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -807,6 +810,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, } return 0; } +SND_DLSYM_BUILD_VERSION(_snd_pcm_meter_open, SND_PCM_DLSYM_VERSION); #endif diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 620d7ac7..461a64a3 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -23,6 +23,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_mulaw = ""; +#endif + typedef void (*mulaw_f)(const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, const snd_pcm_channel_area_t *dst_areas, @@ -429,7 +434,6 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfor return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_mulaw_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -474,5 +478,4 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_mulaw_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index 0c2f6d1a..5c6fe74b 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -26,6 +26,11 @@ #include #include "pcm_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_multi = ""; +#endif + typedef struct { snd_pcm_t *pcm; unsigned int channels_count; @@ -659,7 +664,6 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_multi_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -863,4 +867,4 @@ _free: free(channels_schannel); return err; } - +SND_DLSYM_BUILD_VERSION(_snd_pcm_multi_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index 186766ce..cac6f189 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -25,6 +25,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_null = ""; +#endif + typedef struct { snd_timestamp_t trigger_tstamp; snd_pcm_state_t state; @@ -364,7 +369,6 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_null_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -380,3 +384,4 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, } return snd_pcm_null_open(pcmp, name, stream, mode); } +SND_DLSYM_BUILD_VERSION(_snd_pcm_null_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index 5ac7319e..72739fc6 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -22,6 +22,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_plug = ""; +#endif + enum snd_pcm_plug_route_policy { PLUG_ROUTE_POLICY_NONE, PLUG_ROUTE_POLICY_DEFAULT, @@ -788,7 +793,6 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, #define MAX_CHANNELS 64 -SND_DLSYM_BUILD_VERSION(_snd_pcm_plug_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -872,4 +876,4 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - +SND_DLSYM_BUILD_VERSION(_snd_pcm_plug_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 8aee1517..ed65dccb 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -24,6 +24,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_rate = ""; +#endif + #define DIV (1<<16) typedef struct { @@ -528,7 +533,6 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sform return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_rate_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -576,5 +580,4 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_rate_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index a229cb0c..cb50e6bb 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -24,6 +24,11 @@ #include "pcm_local.h" #include "pcm_plugin.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_route = ""; +#endif + /* The best possible hack to support missing optimization in gcc 2.7.2.3 */ #if ROUTE_PLUGIN_RESOLUTION & (ROUTE_PLUGIN_RESOLUTION - 1) != 0 #define div(a) a /= ROUTE_PLUGIN_RESOLUTION @@ -833,7 +838,6 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt #define MAX_CHANNELS 32 -SND_DLSYM_BUILD_VERSION(_snd_pcm_route_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -906,5 +910,4 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, snd_pcm_close(spcm); return err; } - - +SND_DLSYM_BUILD_VERSION(_snd_pcm_route_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index a91375b6..39700875 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -32,6 +32,10 @@ #include #include "pcm_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_share = ""; +#endif static LIST_HEAD(snd_pcm_share_slaves); static pthread_mutex_t snd_pcm_share_slaves_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -1365,7 +1369,6 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, return 0; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_share_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -1478,3 +1481,4 @@ _free: free(channels_map); return err; } +SND_DLSYM_BUILD_VERSION(_snd_pcm_share_open, SND_PCM_DLSYM_VERSION); diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c index bbadb255..1851a02a 100644 --- a/src/pcm/pcm_shm.c +++ b/src/pcm/pcm_shm.c @@ -38,6 +38,11 @@ #include #include "aserver.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_shm = ""; +#endif + typedef struct { int socket; volatile snd_pcm_shm_ctrl_t *ctrl; @@ -719,7 +724,6 @@ int is_local(struct hostent *hent) return i < numreqs; } -SND_DLSYM_BUILD_VERSION(_snd_pcm_shm_open, SND_PCM_DLSYM_VERSION); int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) @@ -833,4 +837,4 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_delete(sconfig); return err; } - +SND_DLSYM_BUILD_VERSION(_snd_pcm_shm_open, SND_PCM_DLSYM_VERSION); diff --git a/src/rawmidi/Makefile.am b/src/rawmidi/Makefile.am index 7b374de4..5e7945ed 100644 --- a/src/rawmidi/Makefile.am +++ b/src/rawmidi/Makefile.am @@ -1,6 +1,6 @@ EXTRA_LTLIBRARIES=librawmidi.la -librawmidi_la_SOURCES = rawmidi.c rawmidi_hw.c +librawmidi_la_SOURCES = rawmidi.c rawmidi_hw.c rawmidi_symbols.c noinst_HEADERS = rawmidi_local.h all: librawmidi.la diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 5718d96a..4cf1efa8 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -74,6 +74,9 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_rawmidi_t **, snd_rawmidi_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL; +#ifndef PIC + extern void *snd_rawmidi_open_symbols(void); +#endif void *h; if (snd_config_get_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -128,20 +131,19 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp open_name = buf; snprintf(buf, sizeof(buf), "_snd_rawmidi_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_RAWMIDI_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_rawmidi_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_RAWMIDI_DLSYM_VERSION)); + err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index b5103d68..07011d43 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -29,7 +29,12 @@ #include "../control/control_local.h" #include "rawmidi_local.h" -#define SNDRV_FILE_RAWMIDI "/dev/snd/midiC%iD%i" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_rawmidi_hw = ""; +#endif + +#define SNDRV_FILE_RAWMIDI "/dev/snd/midiC%iD%i" #define SNDRV_RAWMIDI_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0) typedef struct { @@ -302,7 +307,6 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, return -ENOMEM; } -SND_DLSYM_BUILD_VERSION(_snd_rawmidi_hw_open, SND_RAWMIDI_DLSYM_VERSION); int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int mode) @@ -348,4 +352,4 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, return -EINVAL; return snd_rawmidi_hw_open(inputp, outputp, name, card, device, subdevice, mode); } - +SND_DLSYM_BUILD_VERSION(_snd_rawmidi_hw_open, SND_RAWMIDI_DLSYM_VERSION); diff --git a/src/seq/Makefile.am b/src/seq/Makefile.am index 003b0a6f..f5b71ead 100644 --- a/src/seq/Makefile.am +++ b/src/seq/Makefile.am @@ -1,6 +1,7 @@ EXTRA_LTLIBRARIES=libseq.la -libseq_la_SOURCES = seq_hw.c seq.c seq_event.c seqmid.c seq_midi_event.c +libseq_la_SOURCES = seq_hw.c seq.c seq_event.c seqmid.c seq_midi_event.c \ + seq_symbols.c noinst_HEADERS = seq_local.h all: libseq.la diff --git a/src/seq/seq.c b/src/seq/seq.c index 6dcd27ce..da51aa10 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -26,8 +26,8 @@ * */ -#include #include +#include #include "seq_local.h" /**************************************************************************** @@ -77,6 +77,9 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, int (*open_func)(snd_seq_t **, const char *, snd_config_t *, snd_config_t *, int, int) = NULL; +#ifndef PIC + extern void *snd_seq_open_symbols(void); +#endif void *h; if (snd_config_get_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -129,21 +132,19 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, open_name = buf; snprintf(buf, sizeof(buf), "_snd_seq_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_SEQ_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_seq_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_SEQ_DLSYM_VERSION)); err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index a6637665..38a30e69 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -24,6 +24,11 @@ #include #include "seq_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_seq_hw = ""; +#endif + #define SNDRV_FILE_SEQ "/dev/snd/seq" #define SNDRV_FILE_ALOADSEQ "/dev/aloadSEQ" #define SNDRV_SEQ_VERSION_MAX SNDRV_PROTOCOL_VERSION(1, 0, 0) @@ -503,7 +508,6 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) return 0; } -SND_DLSYM_BUILD_VERSION(_snd_seq_hw_open, SND_SEQ_DLSYM_VERSION); int _snd_seq_hw_open(snd_seq_t **handlep, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int streams, int mode) @@ -520,4 +524,4 @@ int _snd_seq_hw_open(snd_seq_t **handlep, char *name, } return snd_seq_hw_open(handlep, name, streams, mode); } - +SND_DLSYM_BUILD_VERSION(_snd_seq_hw_open, SND_SEQ_DLSYM_VERSION); diff --git a/src/timer/Makefile.am b/src/timer/Makefile.am index a81401dc..e7cf77b6 100644 --- a/src/timer/Makefile.am +++ b/src/timer/Makefile.am @@ -1,6 +1,7 @@ EXTRA_LTLIBRARIES=libtimer.la -libtimer_la_SOURCES = timer.c timer_hw.c timer_query.c timer_query_hw.c +libtimer_la_SOURCES = timer.c timer_hw.c timer_query.c timer_query_hw.c \ + timer_symbols.c noinst_HEADERS = timer_local.h all: libtimer.la diff --git a/src/timer/timer.c b/src/timer/timer.c index 4ebf8131..297b3cf0 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -47,6 +47,9 @@ static int snd_timer_open_conf(snd_timer_t **timer, snd_config_iterator_t i, next; const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_timer_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL; +#ifndef PIC + extern void *snd_timer_open_symbols(void); +#endif void *h; if (snd_config_get_type(timer_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -101,20 +104,19 @@ static int snd_timer_open_conf(snd_timer_t **timer, open_name = buf; snprintf(buf, sizeof(buf), "_snd_timer_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_TIMER_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_timer_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_TIMER_DLSYM_VERSION)); + err = 0; if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index dd1f20d7..7921c9e7 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -27,6 +27,11 @@ #include #include "timer_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_timer_hw = ""; +#endif + #define SNDRV_FILE_TIMER "/dev/snd/timer" #define SNDRV_TIMER_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0) @@ -200,7 +205,6 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int return 0; } -SND_DLSYM_BUILD_VERSION(_snd_timer_hw_open, SND_TIMER_DLSYM_VERSION); int _snd_timer_hw_open(snd_timer_t **timer, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int mode) @@ -260,3 +264,4 @@ int _snd_timer_hw_open(snd_timer_t **timer, char *name, return -EINVAL; return snd_timer_hw_open(timer, name, dev_class, dev_sclass, card, device, subdevice, mode); } +SND_DLSYM_BUILD_VERSION(_snd_timer_hw_open, SND_TIMER_DLSYM_VERSION); diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c index 17731764..fe24fa66 100644 --- a/src/timer/timer_query.c +++ b/src/timer/timer_query.c @@ -46,6 +46,9 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, snd_config_iterator_t i, next; const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_timer_query_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL; +#ifndef PIC + extern void *snd_timer_query_open_symbols(void); +#endif void *h; if (snd_config_get_type(timer_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) @@ -100,20 +103,18 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, open_name = buf; snprintf(buf, sizeof(buf), "_snd_timer_query_%s_open", str); } - h = dlopen(lib, RTLD_NOW); - if (h) { - if ((err = snd_dlsym_verify(h, open_name, SND_DLSYM_VERSION(SND_TIMER_QUERY_DLSYM_VERSION))) < 0) { - dlclose(h); - goto _err; - } - open_func = dlsym(h, open_name); - } +#ifndef PIC + snd_timer_query_open_symbols(); +#endif + h = snd_dlopen(lib, RTLD_NOW); + if (h) + open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_TIMER_QUERY_DLSYM_VERSION)); if (!h) { SNDERR("Cannot open shared library %s", lib); err = -ENOENT; } else if (!open_func) { SNDERR("symbol %s is not defined inside %s", open_name, lib); - dlclose(h); + snd_dlclose(h); err = -ENXIO; } _err: diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c index e63a4811..a7b84505 100644 --- a/src/timer/timer_query_hw.c +++ b/src/timer/timer_query_hw.c @@ -27,6 +27,11 @@ #include #include "timer_local.h" +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_timer_query_hw = ""; +#endif + #define SNDRV_FILE_TIMER "/dev/snd/timer" #define SNDRV_TIMER_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0) @@ -88,7 +93,6 @@ int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mo return 0; } -SND_DLSYM_BUILD_VERSION(_snd_timer_query_hw_open, SND_TIMER_QUERY_DLSYM_VERSION); int _snd_timer_query_hw_open(snd_timer_query_t **timer, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int mode) @@ -106,3 +110,4 @@ int _snd_timer_query_hw_open(snd_timer_query_t **timer, char *name, } return snd_timer_query_hw_open(timer, name, mode); } +SND_DLSYM_BUILD_VERSION(_snd_timer_query_hw_open, SND_TIMER_QUERY_DLSYM_VERSION); diff --git a/test/Makefile.am b/test/Makefile.am index f76e6524..e2b3c5d3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -11,6 +11,6 @@ rawmidi_LDADD=../src/libasound.la midiloop_LDADD=../src/libasound.la INCLUDES=-I$(top_srcdir)/include -CFLAGS=-Wall -pipe -g +CFLAGS=-static -Wall -pipe -g EXTRA_DIST=seq-decoder.c seq-sender.c midifile.h midifile.c midifile.3 diff --git a/test/midiloop.c b/test/midiloop.c index a3a31738..a27d41a4 100644 --- a/test/midiloop.c +++ b/test/midiloop.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "../include/asoundlib.h" #include #include