[svn-commits] branch group/new_loader_completion r29557 - in /team/group/new_loader_complet...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon May 22 14:29:42 MST 2006


Author: kpfleming
Date: Mon May 22 16:29:42 2006
New Revision: 29557

URL: http://svn.digium.com/view/asterisk?rev=29557&view=rev
Log:
remove the last of the symbol-handling code that won't be used

Modified:
    team/group/new_loader_completion/include/asterisk/module.h
    team/group/new_loader_completion/loader.c

Modified: team/group/new_loader_completion/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/include/asterisk/module.h?rev=29557&r1=29556&r2=29557&view=diff
==============================================================================
--- team/group/new_loader_completion/include/asterisk/module.h (original)
+++ team/group/new_loader_completion/include/asterisk/module.h Mon May 22 16:29:42 2006
@@ -157,143 +157,34 @@
 struct ast_module_user_list;
 
 /*! \page ModMngmnt The Asterisk Module management interface
- * \par The following is part of the new module management code.
  *
  * All modules must implement the module API (load, unload...)
  * whose functions are exported through fields of a "struct module_symbol";
- *
- * Modules exporting extra symbols (data or functions), should list
- * them into an array of struct symbol_entry:
- *     struct symbol_entry exported_symbols[]
- * of symbols, with a NULL name on the last entry
- *
- * Functions should be added with MOD_FUNC(name),
- * data structures with MOD_DATA(_name).
- * The array in turn is referenced by struct module_symbols.
- * (Typically, a module will export only a single symbol, which points
- * to a record containing all the methods. This is the API of the module,
- * and should be known to the module's clients as well.
- *
- * \par Connections to symbols in other modules
- * Modules that require symbols supplied by other modules should
- * provide an array
- *     struct symbol_entry required_symbols[]
- * of symbols, with a NULL name on the last entry, containing the
- * name of the desired symbol.
- * For good measure, we also provide the size in both caller and calle
- * to figure out if there is a mismatch (not terribly useful because most
- * objects are a single word, but still... )
- * The symbol can be added to the array with MOD_WANT(symbol) macro.
- * required_symbols is also pointed by through struct module_symbols.
- *
- * Typically, the whole interface exported by a module should be
- * in a single structure named after the module, as follows.
- * Say the module high level name is 'foo', then we should have
- * - in include/asterisk/foo.h
- *     struct foo_interface {
- *		int (*f)(int, char *); -- first function exported 
- *		const char (*g)(int); -- second function exported 
- *		char *buf;
- *		...		-- other fields
- *     }
- * - in the module exporting the interface, e.g. res/res_foo.c
- *	static int f(int, char *);
- *	static const char *g(int);
- *	const char buf[BUFSZ];
- *     struct foo_interface foo = {
- *	.f = f,
- *	.g = g,
- *	.buf = buf,
- *     }
- *
- * \note NOTE: symbol names are 'global' in this module namespace, so it
- * will be wiser to name exported symbols with a prefix indicating the module
- * supplying it, e.g. foo_f, foo_g, foo_buf. Internally to the module,
- * symbols are still static so they can keep short and meaningful names.
- * The macros MOD_FIELD and METHOD_BASE() below help setting these entries.
- *
- *	MOD_FIELD(f1),		-- field and function name are the same
- *	METHOD_BASE(foo_, f1),  -- field and function name differ by a prefix
- *	.f1 = function_name,    -- generic case
- *     }
- *
- * Note that the loader requires that no fields of exported_symbols
- * are NULL, because that is used as an indication of the end of the array.
- *
- * \par Module states
- * Modules can be in a number of different states, as below:
- * - \b MS_FAILED    attempt to load failed. This is final.
- * - \b MS_NEW       just added to the list, symbols unresolved.
- * - \b MS_RESOLVED  all symbols resolved, but supplier modules not active yet.
- * - \b MS_CANLOAD   all symbols resolved and suppliers are all active
- *              (or we are in a cyclic dependency and we are breaking a loop)
- * - \b MS_ACTIVE    load() returned successfully.
- *
- * 
- * \par Module Types
- * For backward compatibility, we have 3 types of loadable modules:
- *
- * - \b MOD_0 these are the 'old style' modules, which export a number
- *       of callbacks, and their full interface, as globally visible
- *       symbols. The module needs to be loaded with RTLD_LAZY and
- *       RTLD_GLOBAL to make symbols visible to other modules, and
- *       to avoid load failures due to cross dependencies.
- *
- * - \b MOD_1 almost as above, but the generic callbacks are all into a
- *       a structure, mod_data. Same load requirements as above.
- *
- * - \b MOD_2 this is the 'new style' format for modules. The module must
- *       explictly declare which simbols are exported and which
- *       symbols from other modules are used, and the code in this
- *       loader will implement appropriate checks to load the modules
- *       in the correct order. Also this allows to load modules
- *       with RTLD_NOW and RTLD_LOCAL so there is no chance of run-time
- *       bugs due to unresolved symbols or name conflicts.
- */
-
-struct ast_module_symbol {
-	const char *name;
-	void *value;
-	int size;
-	struct ast_module *src;	/* module sourcing it, filled by loader */
-};
-
-/*
- * Constructors for symbol_entry values
- */
-#define	MOD_FUNC(f)	{ .name = #f, .value = f, .size = sizeof(f) }
-#define	MOD_DATA(d)	{ .name = #d, .value = &d, .size = sizeof(_name) }
-#define	MOD_WANT(s)	{ .name = #s, .value = &s, 0 }   /* required symbols */
-
-/*
- * Constructors for fields of foo_interface
- */
-#define	MOD_FIELD(f)    . ## f = f
-#define	METHOD_BASE(_base, _name)       . ## _name = _base ## _name
+ */
 
 enum ast_module_flags {
 	AST_MODFLAG_DEFAULT = 0,
 	AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
 };
 
-/* The 'self' pointer for a module; it will be set by the loader before
-   it calls the module's load_module() entrypoint, and used by various
-   other macros that need to identify the module.
-*/
-
 struct ast_module_info {
 
+	/* The 'self' pointer for a module; it will be set by the loader before
+	   it calls the module's load_module() entrypoint, and used by various
+	   other macros that need to identify the module.
+	*/
+
 	struct ast_module *self;
 
-	int (*load)(void);	/* register stuff etc. Optional. */
-
-	int (*reload)(void);	/* config etc. Optional. */
-
-	int (*unload)(void);	/* unload. called with the module locked */
-
-	const char *name;			/* name of the module for loader reference and CLI commands */
-
-	const char *description;		/* user friendly description of the module. */
+	int (*load)(void);		/* register stuff etc. Optional. */
+
+	int (*reload)(void);		/* config etc. Optional. */
+
+	int (*unload)(void);		/* unload. called with the module locked */
+
+	const char *name;		/* name of the module for loader reference and CLI commands */
+
+	const char *description;	/* user friendly description of the module. */
 
 	/*! 
 	 * This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of

Modified: team/group/new_loader_completion/loader.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/loader.c?rev=29557&r1=29556&r2=29557&view=diff
==============================================================================
--- team/group/new_loader_completion/loader.c (original)
+++ team/group/new_loader_completion/loader.c Mon May 22 16:29:42 2006
@@ -78,40 +78,9 @@
 { 0x87, 0x76, 0x79, 0x35, 0x23, 0xea, 0x3a, 0xd3,
   0x25, 0x2a, 0xbb, 0x35, 0x87, 0xe4, 0x22, 0x24 };
 
-/*
- * Modules can be in a number of different states, as below:
- * MS_FAILED	attempt to load failed. This is final.
- * MS_NEW	just added to the list, symbols unresolved.
- * MS_RESOLVED	all symbols resolved, but supplier modules not active yet.
- * MS_CANLOAD	all symbols resolved and suppliers are all active
- *		(or we are in a cyclic dependency and we are breaking a loop)
- * MS_ACTIVE	load() returned successfully.
- */
-enum st_t {  /* possible states of a module */
-	MS_FAILED = 0,              /*!< cannot load */
-	MS_NEW = 1,                 /*!< nothing known */
-	MS_RESOLVED = 2,            /*!< all required resolved */
-	MS_CANLOAD = 3,             /*!< as above, plus cyclic depend.*/
-	MS_ACTIVE = 4,              /*!< all done */
-};
-
-/*! \note
- * All module symbols are in module_symbols.
- * Modules are then linked in a list of struct module,
- * whereas updaters are in a list of struct loadupdate.
- *
- * Both lists (basically, the entire loader) are protected by
- * the lock in module_list.
- *
- * A second lock, reloadlock, is used to prevent concurrent reloads
- */
-
 struct ast_module {
 	const struct ast_module_info *mod;
 	void *lib;					/* the shared lib, or NULL if embedded */
-
-	enum st_t state;
-	int export_refcount;				/* how many users of exported symbols */
 	int usecount;					/* the number of 'users' currently in this module */
 	struct ast_module_user_list users;		/* the list of users in the module */
 	AST_LIST_ENTRY(ast_module) entry;
@@ -134,13 +103,6 @@
 void ast_module_unregister(const struct ast_module_info *mod)
 {
 }
-
-/*! \note
- * helper localuser routines.
- * All of these routines are extremely expensive, so the use of
- * macros is totally unnecessary from the point of view of performance:
- * the extra function call will be totally negligible in all cases.
- */
 
 struct ast_module_user *__ast_module_user_add(struct ast_module *mod,
 					      struct ast_channel *chan)
@@ -485,8 +447,6 @@
 	
 	modlistver++;
 
-	cur->state = MS_NEW;
-
 	/* give the module a copy of its own handle, for later use in registrations and the like */
 	*((struct ast_module **) &(m->self)) = cur;
 
@@ -506,7 +466,6 @@
 
        AST_LIST_LOCK(&module_list);
        m = __load_resource(resource_name);
-       ret = (m->state == MS_FAILED) ? -1 : 0;
        AST_LIST_UNLOCK(&module_list);
 
        return ret;



More information about the svn-commits mailing list