aboutsummaryrefslogtreecommitdiff
path: root/include/dlfcn.h
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>2002-05-29 16:25:43 +0000
committerGarrett Wollman <wollman@FreeBSD.org>2002-05-29 16:25:43 +0000
commitdc12134a809939fbd6f035bb2c5e50c2854155eb (patch)
tree876b8b56f5abc5a10b03f80b310b2547dc76e4bc /include/dlfcn.h
parent1ec84e5051d3df7cc7cb8fcada3e09eb5bc16cb1 (diff)
Reorganize dlfcn.h slightly to separate out XSI and BSD interfaces.
Add new dlfunc() interface, which is a version of dlsym() with a return type that can be cast to a function pointer without turning your computer into a frog. Reviewed by: freebsd-standards
Notes
Notes: svn path=/head/; revision=97475
Diffstat (limited to 'include/dlfcn.h')
-rw-r--r--include/dlfcn.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/include/dlfcn.h b/include/dlfcn.h
index 13fd6845ffa5..38a38be07263 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -63,10 +63,31 @@ typedef struct dl_info {
void *dli_saddr; /* Address of nearest symbol */
} Dl_info;
+/*
+ * The actual type declared by this typedef is immaterial, provided that
+ * it is a function pointer. Its purpose is to provide a return type for
+ * dlfunc() which can be cast to a function pointer type without depending
+ * on behavior undefined by the C standard, which might trigger a compiler
+ * diagnostic. We intentionally declare a unique type signature to force
+ * a diagnostic should the application not cast the return value of dlfunc()
+ * appropriately.
+ */
+struct __dlfunc_arg {
+ int __dlfunc_dummy;
+};
+
+typedef void (*__dlfunc_t)(struct __dlfunc_arg);
+
__BEGIN_DECLS
-int dladdr(const void *, Dl_info *);
+/* XSI functions first */
int dlclose(void *);
const char *dlerror(void);
+void *dlopen(const char *, int);
+void *dlsym(void * /* __restrict */, const char * /* __restrict */);
+
+#if __BSD_VISIBLE
+int dladdr(const void *, Dl_info *);
+__dlfunc_t dlfunc(void * /* __restrict */, const char * /* __restrict */);
void dllockinit(void *_context,
void *(*_lock_create)(void *_context),
void (*_rlock_acquire)(void *_lock),
@@ -74,8 +95,7 @@ void dllockinit(void *_context,
void (*_lock_release)(void *_lock),
void (*_lock_destroy)(void *_lock),
void (*_context_destroy)(void *_context));
-void *dlopen(const char *, int);
-void *dlsym(void *, const char *);
+#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_DLFCN_H_ */