This rather large commit changes the way modules are loaded.

As partly documented in loader.c and include/asterisk/module.h,
modules are now expected to return all of their methods and flags
into a structure 'mod_data', and are normally loaded with RTLD_NOW
| RTLD_LOCAL, so symbols are resolved immediately and conflicts
should be less likely.  Only in a small number of cases (res_*,
typically) modules are loaded RTLD_GLOBAL, so they can export
symbols.
 
The core of the change is only the two files loader.c and
include/asterisk/module.h, all the rest is simply adaptation of the
existing modules to the new API, a rather mechanical (but believe
me, time and finger-consuming!) process whose detail you can figure
out by svn diff'ing any single module.

Expect some minor compilation issue after this change, please
report it on mantis http://bugs.digium.com/view.php?id=6968
so we collect all the feedback in one place.

I am just sorry that this change missed SVN version number 20000!



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20003 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-14 14:08:19 +00:00
parent 33a3a7375a
commit e43bc6634d
162 changed files with 1273 additions and 2386 deletions

View File

@@ -138,8 +138,6 @@ static off_t g723_tell(struct ast_filestream *fs)
return -1;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format g723_1_f = {
.name = "g723sf",
.exts = "g723|g723sf",
@@ -150,30 +148,27 @@ static const struct ast_format g723_1_f = {
.tell = g723_tell,
.read = g723_read,
.buf_size = G723_MAX_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&g723_1_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(g723_1_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "G.723.1 Simple Timestamp File Format";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -190,8 +190,6 @@ static off_t g726_tell(struct ast_filestream *fs)
return -1;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format f[] = {
{
.name = "g726-40",
@@ -206,7 +204,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
},
{
.name = "g726-32",
@@ -221,7 +219,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
},
{
.name = "g726-24",
@@ -236,7 +234,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
},
{
.name = "g726-16",
@@ -251,7 +249,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
},
{ .format = 0 } /* terminator */
};
@@ -259,7 +257,7 @@ static const struct ast_format f[] = {
/*
* Module interface (load_module, unload_module, usecount, description, key)
*/
int load_module()
static int load_module(void *mod)
{
int i;
@@ -272,7 +270,7 @@ int load_module()
return 0;
}
int unload_module()
static int unload_module(void *mod)
{
int i;
@@ -283,18 +281,14 @@ int unload_module()
return(0);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw G.726 (16/24/32/40kbps) data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -134,8 +134,6 @@ static off_t g729_tell(struct ast_filestream *fs)
return (offset/BUF_SIZE)*G729A_SAMPLES;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format g729_f = {
.name = "g729",
.exts = "g729",
@@ -146,30 +144,27 @@ static const struct ast_format g729_f = {
.tell = g729_tell,
.read = g729_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&g729_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(g729_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw G729 data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -156,8 +156,6 @@ static off_t gsm_tell(struct ast_filestream *fs)
return (offset/GSM_FRAME_SIZE)*GSM_SAMPLES;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format gsm_f = {
.name = "gsm",
.exts = "gsm",
@@ -168,30 +166,27 @@ static const struct ast_format gsm_f = {
.tell = gsm_tell,
.read = gsm_read,
.buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, /* 2 gsm frames */
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&gsm_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(gsm_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw GSM data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -163,8 +163,6 @@ static off_t h263_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format h263_f = {
.name = "h263",
.exts = "h264",
@@ -177,30 +175,27 @@ static const struct ast_format h263_f = {
.read = h263_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct h263_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&h263_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(h263_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw h263 data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -156,8 +156,6 @@ static off_t h264_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format h264_f = {
.name = "h264",
.exts = "h264",
@@ -170,30 +168,27 @@ static const struct ast_format h264_f = {
.read = h264_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct h264_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&h264_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(h264_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw h264 data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -132,8 +132,6 @@ static off_t ilbc_tell(struct ast_filestream *fs)
return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format ilbc_f = {
.name = "iLBC",
.exts = "ilbc",
@@ -144,31 +142,27 @@ static const struct ast_format ilbc_f = {
.tell = ilbc_tell,
.read = ilbc_read,
.buf_size = ILBC_BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&ilbc_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(ilbc_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw iLBC data";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -115,30 +115,25 @@ static struct ast_imager jpeg_format = {
jpeg_write_image,
};
int load_module()
static int load_module(void *mod)
{
return ast_image_register(&jpeg_format);
}
int unload_module()
static int unload_module(void *mod)
{
ast_image_unregister(&jpeg_format);
return 0;
}
int usecount()
{
/* We never really have any users */
return 0;
}
const char *description()
static const char *description(void)
{
return desc;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -523,8 +523,6 @@ static off_t ogg_vorbis_tell(struct ast_filestream *s)
return -1;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format vorbis_f = {
.name = "ogg_vorbis",
.exts = "ogg",
@@ -539,31 +537,27 @@ static const struct ast_format vorbis_f = {
.close = ogg_vorbis_close,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct vorbis_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&vorbis_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(vorbis_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "OGG/Vorbis audio";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -414,8 +414,6 @@ static off_t au_tell(struct ast_filestream *fs)
return offset - AU_HEADER_SIZE;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format alaw_f = {
.name = "alaw",
.exts = "alaw|al",
@@ -426,7 +424,7 @@ static const struct ast_format alaw_f = {
.tell = pcm_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
#ifdef REALTIME_WRITE
.open = pcma_open,
.rewrite = pcma_rewrite,
@@ -444,7 +442,7 @@ static const struct ast_format pcm_f = {
.tell = pcm_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
static const struct ast_format au_f = {
@@ -459,10 +457,10 @@ static const struct ast_format au_f = {
.tell = au_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, /* this many shorts */
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
int index;
@@ -476,23 +474,20 @@ int load_module()
|| ast_format_register(&au_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(pcm_f.name) || ast_format_unregister(alaw_f.name)
|| ast_format_unregister(au_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw/Sun uLaw/ALaw 8khz Audio support (PCM,PCMA,AU)";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -116,8 +116,6 @@ static off_t slinear_tell(struct ast_filestream *fs)
return ftello(fs->f) / 2;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format slin_f = {
.name = "sln",
.exts = "sln|raw",
@@ -128,30 +126,27 @@ static const struct ast_format slin_f = {
.tell = slinear_tell,
.read = slinear_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&slin_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(slin_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Raw Signed Linear Audio support (SLN)";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -121,8 +121,6 @@ static off_t vox_tell(struct ast_filestream *fs)
return offset;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format vox_f = {
.name = "vox",
.exts = "vox",
@@ -133,30 +131,27 @@ static const struct ast_format vox_f = {
.tell = vox_tell,
.read = vox_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&vox_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(vox_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Dialogic VOX (ADPCM) File Format";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -498,8 +498,6 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - 44)/2;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format wav_f = {
.name = "wav",
.exts = "wav",
@@ -514,30 +512,27 @@ static const struct ast_format wav_f = {
.close = wav_close,
.buf_size = WAV_BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct wav_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&wav_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(wav_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Microsoft WAV format (8000hz Signed Linear)";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;

View File

@@ -541,8 +541,6 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES;
}
static struct ast_format_lock me = { .usecnt = -1 };
static const struct ast_format wav49_f = {
.name = "wav49",
.exts = "WAV|wav49",
@@ -557,30 +555,27 @@ static const struct ast_format wav49_f = {
.close = wav_close,
.buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct wavg_desc),
.lockp = &me,
.module = &mod_data, /* XXX */
};
int load_module()
static int load_module(void *mod)
{
return ast_format_register(&wav49_f);
}
int unload_module()
static int unload_module(void *mod)
{
return ast_format_unregister(wav49_f.name);
}
int usecount()
{
return me.usecnt;
}
const char *description()
static const char *description(void)
{
return "Microsoft WAV format (Proprietary GSM)";
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD1;