summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c6
-rw-r--r--src/lisp.h1
-rw-r--r--src/print.c18
3 files changed, 23 insertions, 2 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 3855a33f254..f40ca931fa9 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -1098,6 +1098,12 @@ module_function_address (const struct Lisp_Module_Function *function)
return (module_funcptr) function->subr;
}
+void *
+module_function_data (const struct Lisp_Module_Function *function)
+{
+ return function->data;
+}
+
/* Helper functions. */
diff --git a/src/lisp.h b/src/lisp.h
index 9be7bfec5c0..e1bbb53ad49 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4245,6 +4245,7 @@ extern Lisp_Object module_function_documentation
(struct Lisp_Module_Function const *);
extern module_funcptr module_function_address
(struct Lisp_Module_Function const *);
+extern void *module_function_data (const struct Lisp_Module_Function *);
extern void module_finalize_function (const struct Lisp_Module_Function *);
extern void mark_modules (void);
extern void init_module_assertions (bool);
diff --git a/src/print.c b/src/print.c
index 425b0dc4ee3..b373aaf6551 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1796,7 +1796,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
case PVEC_MODULE_FUNCTION:
{
print_c_string ("#<module function ", printcharfun);
- module_funcptr ptr = module_function_address (XMODULE_FUNCTION (obj));
+ const struct Lisp_Module_Function *function = XMODULE_FUNCTION (obj);
+ module_funcptr ptr = module_function_address (function);
char const *file;
char const *symbol;
dynlib_addr (ptr, &file, &symbol);
@@ -1815,6 +1816,19 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
else
print_c_string (symbol, printcharfun);
+ void *data = module_function_data (function);
+ if (data != NULL)
+ {
+ uintptr_t ui = (uintptr_t) data;
+
+ /* In theory this assignment could lose info on pre-C99
+ hosts, but in practice it doesn't. */
+ uintmax_t up = ui;
+
+ int len = sprintf (buf, " with data 0x%"PRIxMAX, up);
+ strout (buf, len, len, printcharfun);
+ }
+
if (file != NULL)
{
print_c_string (" from ", printcharfun);
@@ -1838,7 +1852,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
{
char buf[max (sizeof "from..to..in " + 2 * INT_STRLEN_BOUND (EMACS_INT),
max (sizeof " . #" + INT_STRLEN_BOUND (intmax_t),
- max ((sizeof "at 0x"
+ max ((sizeof " with data 0x"
+ (sizeof (uintmax_t) * CHAR_BIT + 4 - 1) / 4),
40)))];
current_thread->stack_top = buf;