mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
libc/modlib: Add build a configuration logic for a shared module library.
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
|
||||
int mod_depend(FAR struct module_s *importer, FAR struct module_s *exporter)
|
||||
{
|
||||
#if CONFIG_MODULE_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_MODLIB_MAXDEPEND > 0
|
||||
int freendx;
|
||||
int i;
|
||||
|
||||
@@ -82,11 +82,11 @@ int mod_depend(FAR struct module_s *importer, FAR struct module_s *exporter)
|
||||
* list of dependencies.
|
||||
*
|
||||
* The list dependency list is a a dumb, upacked array of pointers. This
|
||||
* should not be too inefficient if the number of CONFIG_MODULE_MAXDEPEND
|
||||
* should not be too inefficient if the number of CONFIG_LIBC_MODLIB_MAXDEPEND
|
||||
* is small. Otherwise, a more dynamic data structure would be in order.
|
||||
*/
|
||||
|
||||
for (i = 0, freendx = -1; i < CONFIG_MODULE_MAXDEPEND; i++)
|
||||
for (i = 0, freendx = -1; i < CONFIG_LIBC_MODLIB_MAXDEPEND; i++)
|
||||
{
|
||||
FAR const struct module_s *modp;
|
||||
|
||||
@@ -167,7 +167,7 @@ int mod_depend(FAR struct module_s *importer, FAR struct module_s *exporter)
|
||||
|
||||
int mod_undepend(FAR struct module_s *importer)
|
||||
{
|
||||
#if CONFIG_MODULE_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_MODLIB_MAXDEPEND > 0
|
||||
FAR struct module_s *exporter;
|
||||
int i;
|
||||
|
||||
@@ -175,11 +175,11 @@ int mod_undepend(FAR struct module_s *importer)
|
||||
|
||||
/* Decrement the dependency count on each of exporters of symbols used by
|
||||
* this importer module. This is an upacked array of pointers. This
|
||||
* should not be too inefficient if the number of CONFIG_MODULE_MAXDEPEND
|
||||
* should not be too inefficient if the number of CONFIG_LIBC_MODLIB_MAXDEPEND
|
||||
* is small. Otherwise, a more dynamic data structure would be in order.
|
||||
*/
|
||||
|
||||
for (i = 0; i < CONFIG_MODULE_MAXDEPEND; i++)
|
||||
for (i = 0; i < CONFIG_LIBC_MODLIB_MAXDEPEND; i++)
|
||||
{
|
||||
exporter = importer->dependencies[i];
|
||||
if (exporter != NULL)
|
||||
|
||||
@@ -55,15 +55,15 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_MODULE_DUMPBUFFER have to
|
||||
* be defined or CONFIG_MODULE_DUMPBUFFER does nothing.
|
||||
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
* have to be defined or CONFIG_LIBC_MODLIB_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_MODULE_DUMPBUFFER)
|
||||
# undef CONFIG_MODULE_DUMPBUFFER
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_LIBC_MODLIB_DUMPBUFFER)
|
||||
# undef CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_DUMPBUFFER
|
||||
#ifdef CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
# define mod_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
|
||||
#else
|
||||
# define mod_dumpbuffer(m,b,n)
|
||||
|
||||
@@ -59,14 +59,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to be defined or
|
||||
* CONFIG_MODULE_DUMPBUFFER does nothing.
|
||||
* CONFIG_LIBC_MODLIB_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_DEBUG_BINFMT)
|
||||
# undef CONFIG_MODULE_DUMPBUFFER
|
||||
# undef CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_DUMPBUFFER
|
||||
#ifdef CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
# define mod_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
|
||||
#else
|
||||
# define mod_dumpbuffer(m,b,n)
|
||||
@@ -144,7 +144,7 @@ static void mod_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
* Name: mod_dumpinitializer
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MODULE_DUMPBUFFER
|
||||
#ifdef CONFIG_LIBC_MODLIB_DUMPBUFFER
|
||||
static void mod_dumpinitializer(mod_initializer_t initializer,
|
||||
FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
|
||||
@@ -71,14 +71,14 @@ int mod_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* No.. allocate one now */
|
||||
|
||||
loadinfo->iobuffer = (FAR uint8_t *)kmm_malloc(CONFIG_MODULE_BUFFERSIZE);
|
||||
loadinfo->iobuffer = (FAR uint8_t *)kmm_malloc(CONFIG_LIBC_MODLIB_BUFFERSIZE);
|
||||
if (!loadinfo->iobuffer)
|
||||
{
|
||||
serr("ERROR: Failed to allocate an I/O buffer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
loadinfo->buflen = CONFIG_MODULE_BUFFERSIZE;
|
||||
loadinfo->buflen = CONFIG_LIBC_MODLIB_BUFFERSIZE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ELF_ALIGN_MASK ((1 << CONFIG_MODULE_ALIGN_LOG2) - 1)
|
||||
#define ELF_ALIGN_MASK ((1 << CONFIG_LIBC_MODLIB_ALIGN_LOG2) - 1)
|
||||
#define ELF_ALIGNUP(a) (((unsigned long)(a) + ELF_ALIGN_MASK) & ~ELF_ALIGN_MASK)
|
||||
#define ELF_ALIGNDOWN(a) ((unsigned long)(a) & ~ELF_ALIGN_MASK)
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ int rmmod(FAR void *handle)
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
#if CONFIG_MODULE_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_MODLIB_MAXDEPEND > 0
|
||||
/* Refuse to remove any module that other modules may depend upon. */
|
||||
|
||||
if (modp->dependents > 0)
|
||||
@@ -152,7 +152,7 @@ int rmmod(FAR void *handle)
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
#if CONFIG_MODULE_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_MODLIB_MAXDEPEND > 0
|
||||
/* Eliminate any dependencies that this module has on other modules */
|
||||
|
||||
(void)mod_undepend(modp);
|
||||
|
||||
@@ -147,7 +147,7 @@ static inline int mod_sectname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
|
||||
/* No.. then we have to read more */
|
||||
|
||||
ret = mod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
|
||||
ret = mod_reallocbuffer(loadinfo, CONFIG_LIBC_MODLIB_BUFFERINCR);
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: mod_reallocbuffer failed: %d\n", ret);
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
|
||||
/* Amount to reallocate buffer when buffer is full */
|
||||
|
||||
#ifndef CONFIG_MODULE_BUFFERINCR
|
||||
# define CONFIG_MODULE_BUFFERINCR 32
|
||||
#ifndef CONFIG_LIBC_MODLIB_BUFFERINCR
|
||||
# define CONFIG_LIBC_MODLIB_BUFFERINCR 32
|
||||
#endif
|
||||
|
||||
/* Return values search for exported modules */
|
||||
@@ -159,7 +159,7 @@ static int mod_symname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
|
||||
/* No.. then we have to read more */
|
||||
|
||||
ret = mod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
|
||||
ret = mod_reallocbuffer(loadinfo, CONFIG_LIBC_MODLIB_BUFFERINCR);
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: mod_reallocbuffer failed: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user