]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Changes for static build.
authorJaroslav Kysela <perex@perex.cz>
Wed, 24 Oct 2001 14:14:11 +0000 (14:14 +0000)
committerJaroslav Kysela <perex@perex.cz>
Wed, 24 Oct 2001 14:14:11 +0000 (14:14 +0000)
44 files changed:
INSTALL
doc/doxygen.cfg
include/global.h
src/conf.c
src/confmisc.c
src/control/Makefile.am
src/control/control.c
src/control/control_hw.c
src/control/control_shm.c
src/dlmisc.c
src/hwdep/Makefile.am
src/hwdep/hwdep.c
src/hwdep/hwdep_hw.c
src/pcm/Makefile.am
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_copy.c
src/pcm/pcm_file.c
src/pcm/pcm_hooks.c
src/pcm/pcm_hw.c
src/pcm/pcm_linear.c
src/pcm/pcm_meter.c
src/pcm/pcm_mulaw.c
src/pcm/pcm_multi.c
src/pcm/pcm_null.c
src/pcm/pcm_plug.c
src/pcm/pcm_rate.c
src/pcm/pcm_route.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/Makefile.am
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_hw.c
src/seq/Makefile.am
src/seq/seq.c
src/seq/seq_hw.c
src/timer/Makefile.am
src/timer/timer.c
src/timer/timer_hw.c
src/timer/timer_query.c
src/timer/timer_query_hw.c
test/Makefile.am
test/midiloop.c

diff --git a/INSTALL b/INSTALL
index b4e080e9819bbca4dce1e2dddfbabd3a62254844..76474d4ca624d81247fec3da8605c8caa0f23712 100644 (file)
--- 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.
index 1bad25edc47c208784c9a8c2f38ca6ce25fdfe00..ba518b8487b43fd7f9221b8588dd8baa7763e0fe 100644 (file)
@@ -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
index bfacac2d0e38f1385e905fd5865bc666c809e462..cd72e552edd190f2511cd85c532674e73d2b583a 100644 (file)
 #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;
index d7ea6c12c67824565f7ca449ed76e527509bf87a..671b2d7767e63cac1ee6f522699d68cbabb87235 100644 (file)
@@ -31,8 +31,8 @@
 
 #include <stdarg.h>
 #include <wordexp.h>
-#include <sys/stat.h>
 #include <dlfcn.h>
+#include <sys/stat.h>
 #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);
                }
index 70c2a8d2dcc496d3755518e174b1633408e27162..efdb0713da5239c47cb36122dc4c8ad7587ed14c 100644 (file)
@@ -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);
index bfb0e594eecb7e7c3a69d3c60259ec1550e84ac1..072bdf2b38bc37d44b95012dd17c7e72ec9f666d 100644 (file)
@@ -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
 
index d21a7a0ffdb8a3d49b54cab0035e7b508dd9d0a5..029a860fa76c71e3444a0d3d59305980e746dd9a 100644 (file)
@@ -33,8 +33,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
-#include <dlfcn.h>
 #include <signal.h>
+#include <dlfcn.h>
 #include <sys/poll.h>
 #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:
index df364731744b9d941f7f6a69a33dbc9790aad143..e9b147c5d79449cc95f770ea4ced389b7de7bfec 100644 (file)
 #include <sys/ioctl.h>
 #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);
index f4572eb6ad05a4f6d6b76b695d4360b7bb6e6d95..24b416e615e35b092c80ee3c608cdf07132dcfe5 100644 (file)
 #include <netdb.h>
 #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);
index 61e58f45c09dd4e2d1ef78d40742c4c2d41c57c9..4fd497b0578d125817c8f8ad449675f444d5b05a 100644 (file)
 #include <dlfcn.h>
 #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);
+}
index 471b7a78ccf7f8f58a8d17c10f5631cbcbc77dfb..0b626b904a0206ccfbafd4f4d407feb7fcf4a0a5 100644 (file)
@@ -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
 
index ac76f46974687871c0315f1e0622230473d91414..5180de95b61706f6479c564c99b260ba895ddd47 100644 (file)
@@ -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:
index 2a43617146bb243d16685f06cf4a4cb57e4645e3..63ea4d6dd552407ee1dc364a145a27f40dd26bac 100644 (file)
 #include <sys/ioctl.h>
 #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);
index 58026004a4a8932521cf41606cc6de54f85431ad..38d41b44d54cb2a87fcbbdef12a4a06f648d01a0 100644 (file)
@@ -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
 
index 61ea1852dca9428353635c3d689a2bad02e7cf56..4ff5df8c53d652e6dced6ac2c9417288b89df92e 100644 (file)
 #include <malloc.h>
 #include <stdarg.h>
 #include <signal.h>
+#include <dlfcn.h>
 #include <sys/ioctl.h>
 #include <sys/poll.h>
 #include <sys/shm.h>
 #include <sys/mman.h>
 #include <limits.h>
-#include <dlfcn.h>
 #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)
 {
index 2b43154db402769b1dd913cf768aea38cee6bf0e..d21b263dfe41ecaf7d6ec3972d09ce653e57f5f9 100644 (file)
@@ -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);
index dd1e9d9b7018c0c20e4630d23184433d5a8a6b8a..d11df70db19a5ff6b0a0cf2250bb0dace9c79ea1 100644 (file)
 #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);
index 796b76335e712b06474d4d5b20d68092d2feab02..3e02f03cbf2497d74f1b36714e5e597b75e77b7f 100644 (file)
 #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);
index 9e21d52f64ede30ca2e5eddd5b2a36a944810ced..525f35de0aef746e1eca01f49c14702b66168e0e 100644 (file)
 #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);
index 47f066f50f8e8c108905d24b44a26d5a007be4b5..59a625bd26854bc283e63e92951c4f14b2b6b2a1 100644 (file)
 #include <dlfcn.h>
 #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
 
index 6223f77e5377011dfbca3afcecaf6b7a724d8c9c..9bdaf5abe2caa9a1cc4c6763ee9c3893b1ddf57a 100644 (file)
 #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);
index 3b4a68dc39a4b7552422a97bafa38acded16a961..ca33a48cd7ffdbe7cb033c4ee857f2a14ec33fcb 100644 (file)
 #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);
index 54517306075fa4352e9848ad00e9e5c323826f94..bde9bb63d8debfc36dd1de4e80de2aaa7c98e500 100644 (file)
 #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
 
index 620d7ac731ef38879ea270bb7950b78834e790bc..461a64a35c7d952cdd263f35560bbaf3db7fc3e2 100644 (file)
 #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);
index 0c2f6d1aa25d639fc1a31726efb264d3c2e4fe34..5c6fe74b1584719efc4a2107274e2ead2691b675 100644 (file)
 #include <math.h>
 #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);
index 186766ce67861342babda10528df70273d47eb44..cac6f1895993bfbbc0e36c4c787519f77c209a68 100644 (file)
 #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);
index 5ac7319eba7b7cda260a3b7aa5a6cd0a03bc1b5d..72739fc6802d244efc4af95951d3a55793679fc5 100644 (file)
 #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);
index 8aee151790674ad8c9d4dd8104040ffe7255e8c0..ed65dccbafff65312389dcbe53a6504742082f6b 100644 (file)
 #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);
index a229cb0c110ac0cc435adad26c4db8a3e56bc2c8..cb50e6bb350180df6ec21212902c1d94d40440de 100644 (file)
 #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);
index a91375b6350b6925d4de95280a6810a15997b4e2..39700875082be24b9b21384075f1a46350de95f1 100644 (file)
 #include <pthread.h>
 #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);
index bbadb2556bd8781f04a8c8feb16bfd890637a80c..1851a02aad3e29bf081721aff6cf6b98b8cf42e0 100644 (file)
 #include <netdb.h>
 #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);
index 7b374de4d1d3b72b5b82421f337f511c31d9d79d..5e7945ed011aaa70b9b89d44118f5fdc44b1ebc8 100644 (file)
@@ -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
index 5718d96affba04f93e0e53714a12df805baae760..4cf1efa80f82d586991303d50e68bf4d5bb00287 100644 (file)
@@ -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:
index b5103d681cc10a2969b200022aaddfb05a2207e9..07011d43acece93f991634088890a1d4868997dc 100644 (file)
 #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);
index 003b0a6fd5e0880f73b64d7967792194d88db5e8..f5b71ead332b4733009daf63a5872534db93ea34 100644 (file)
@@ -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
index 6dcd27ceb0bb46a5d87689903026d14cd71a91c8..da51aa106f09e9a8d631f931d7a2d6b7086731ab 100644 (file)
@@ -26,8 +26,8 @@
  *
  */
 
-#include <sys/poll.h>
 #include <dlfcn.h>
+#include <sys/poll.h>
 #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:
index a66376650bbe54a2e68e5c41778417248713ee85..38a30e6982aecfa1d5f80a0eb6f4c6a66670a8c7 100644 (file)
 #include <sys/ioctl.h>
 #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);
index a81401dcbff3fed87b6eac8ea265bcc0aec3d2c9..e7cf77b64995b2fb3622f5c76d06b7f765dd5987 100644 (file)
@@ -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
 
index 4ebf8131fb01ea8a9da6d23b1fab6b8b988b61c6..297b3cf0f64c0e0534e46c5240394503d134559e 100644 (file)
@@ -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:
index dd1f20d7d4f299183437d312d50711c09819555a..7921c9e7d8d73d72f06bb251952979a19c4c3ba6 100644 (file)
 #include <sys/ioctl.h>
 #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);
index 17731764908221665b41d46c43ed229b1bd489b9..fe24fa66afe9d31535c30c92fd21c63d214bab33 100644 (file)
@@ -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:
index e63a48114ac23c2fa752bdf9f50a93fc44b679c5..a7b84505d6a216fa3fab3e414d18f94bf04da38a 100644 (file)
 #include <sys/ioctl.h>
 #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);
index f76e65241f5d3bc251e8866fb930c53d52c6f0ce..e2b3c5d3bf7119fbf217dbc01baa98c8e2f5ffbe 100644 (file)
@@ -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
index a3a31738047c1c003de2be7216b84abef5dac5b9..a27d41a4430f4a0163e4650b6ec0b7958df1b787 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <sys/time.h>
 #include "../include/asoundlib.h"
 #include <string.h>
 #include <signal.h>