summaryrefslogtreecommitdiff
path: root/src/gnumake.h
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2023-05-07 16:51:12 -0400
committerPaul Smith <psmith@gnu.org>2023-05-14 18:26:35 -0400
commit1748e6641419e8a48f830caad072ed5b298577af (patch)
treea0650a8ee54b5ec4020a5b1277bd70cd903d4ac2 /src/gnumake.h
parent8e0e6c678f3cf1199751e3b097745531ceed34ed (diff)
downloadmake-git-1748e6641419e8a48f830caad072ed5b298577af.tar.gz
[SV 63219] Support an "unload" function for loaded objects
If a loaded object defines a symbol <object>_gmk_unload, assume it's a function and invoke it whenever the loaded object is unloaded. Original implementation by Dmitry Goncharov <dgoncharov@users.sf.net> * NEWS: Announce the change. * doc/make.texi: Describe the behavior. * src/gnumake.h: Add information to the comments. * src/makeint.h (unload_all): Declare a new function. * src/main.c (die): Invoke unload_all(). * src/load.c (unload_func_t): Declare a new type for unload. (struct load_list): Remember the unload symbol if it exists. (load_object): Move the parsing of the object name from load_file. Check for the _gmk_unload symbol and if found, remember it. (load_file): Allow load_object to do object filename parsing. (unload_file): Remove the load_list entry when unloading the object. (unload_all): Unload all the loaded objects. * tests/scripts/features/loadapi: Test the unload function.
Diffstat (limited to 'src/gnumake.h')
-rw-r--r--src/gnumake.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gnumake.h b/src/gnumake.h
index 3ebe6621..b448a3c1 100644
--- a/src/gnumake.h
+++ b/src/gnumake.h
@@ -35,7 +35,16 @@ typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
int <setup_fn> (unsigned int abi_version, const gmk_floc *flocp);
- The abi_version will be set to GMK_ABI_VERSION. */
+ The abi_version will be set to GMK_ABI_VERSION.
+
+ When an object is unloaded by GNU Make, an unload method will be invoked.
+ The name of the method is derived from the filename of the object, with
+ _gmk_unload appended. It has the signature:
+
+ void <object>_gmk_unload (void);
+
+ There will only be one unload method invoked regardless of the number of
+ setup methods within the object. */
#ifdef _WIN32
# ifdef GMK_BUILDING_MAKE