Incorporate address environment interfaces in binfmt/ logic

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5443 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-12-19 17:54:26 +00:00
parent 8ae8d43ae2
commit 56a6504618
30 changed files with 1225 additions and 104 deletions
+37 -2
View File
@@ -86,8 +86,23 @@
static inline void exec_dtors(FAR const struct binary_s *binp)
{
binfmt_dtor_t *dtor = binp->dtors;
#ifdef CONFIG_ADDRENV
hw_addrenv_t oldenv;
int ret;
#endif
int i;
/* Instantiate the address enviroment containing the destructors */
#ifdef CONFIG_ADDRENV
ret = up_addrenv_select(binp->addrenv, &oldenv);
if (ret < 0)
{
bdbg("up_addrenv_select() failed: %d\n", ret);
return ret;
}
#endif
/* Execute each destructor */
for (i = 0; i < binp->ndtors; i++)
@@ -97,6 +112,14 @@ static inline void exec_dtors(FAR const struct binary_s *binp)
(*dtor)();
dtor++;
}
/* Restore the address enviroment */
#ifdef CONFIG_ADDRENV
return up_addrenv_restore(oldenv);
#else
return OK;
#endif
}
#endif
@@ -125,15 +148,23 @@ static inline void exec_dtors(FAR const struct binary_s *binp)
int unload_module(FAR const struct binary_s *binp)
{
#ifdef CONFIG_BINFMT_CONSTRUCTORS
int ret;
#endif
int i;
if (binp)
{
/* Execute C++ desctructors */
#ifdef CONFIG_BINFMT_CONSTRUCTORS
exec_dtors(binp);
ret = exec_dtors(binp);
if (ret < 0)
{
bdbg("exec_ctors() failed: %d\n", ret);
set_errno(-ret);
return ERROR;
}
#endif
/* Unmap mapped address spaces */
@@ -155,6 +186,10 @@ int unload_module(FAR const struct binary_s *binp)
free(binp->alloc[i]);
}
}
/* Notice that the address environment is not destroyed. This should
* happen automatically when the task exits.
*/
}
return OK;