hurd: XFAIL appearance of sched_param and sched_priority from <sys/types.h>
[glibc.git] / include / dlfcn.h
blob12ef913e1965d57117e76fdcdb1bd14d9c35ce07
1 #ifndef _DLFCN_H
2 #include <dlfcn/dlfcn.h>
3 #ifndef _ISOMAC
4 #include <link.h> /* For ElfW. */
5 #include <stdbool.h>
7 /* Internally used flag. */
8 #define __RTLD_DLOPEN 0x80000000
9 #define __RTLD_SPROF 0x40000000
10 #define __RTLD_OPENEXEC 0x20000000
11 #define __RTLD_CALLMAP 0x10000000
12 #define __RTLD_AUDIT 0x08000000
13 #define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
14 #define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */
16 #define __LM_ID_CALLER -2
18 #ifdef SHARED
19 /* Locally stored program arguments. */
20 extern int __dlfcn_argc attribute_hidden;
21 extern char **__dlfcn_argv attribute_hidden;
22 #else
23 /* These variables are defined and initialized in the startup code. */
24 extern int __libc_argc attribute_hidden;
25 extern char **__libc_argv attribute_hidden;
27 # define __dlfcn_argc __libc_argc
28 # define __dlfcn_argv __libc_argv
29 #endif
32 /* Now define the internal interfaces. */
34 #define __libc_dlopen(name) \
35 __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
36 extern void *__libc_dlopen_mode (const char *__name, int __mode);
37 extern void *__libc_dlsym (void *__map, const char *__name);
38 extern void *__libc_dlvsym (void *map, const char *name, const char *version);
39 extern int __libc_dlclose (void *__map);
40 libc_hidden_proto (__libc_dlopen_mode)
41 libc_hidden_proto (__libc_dlsym)
42 libc_hidden_proto (__libc_dlvsym)
43 libc_hidden_proto (__libc_dlclose)
45 /* Locate shared object containing the given address. */
46 #ifdef ElfW
47 extern int _dl_addr (const void *address, Dl_info *info,
48 struct link_map **mapp, const ElfW(Sym) **symbolp);
49 libc_hidden_proto (_dl_addr)
50 #endif
52 struct link_map;
54 /* Close an object previously opened by _dl_open. */
55 extern void _dl_close (void *map) attribute_hidden;
56 /* Same as above, but without locking and safety checks for user
57 provided map arguments. */
58 extern void _dl_close_worker (struct link_map *map, bool force)
59 attribute_hidden;
61 /* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
62 RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
63 the symbol value, which may be NULL. */
64 extern void *_dl_sym (void *handle, const char *name, void *who);
66 /* Look up version VERSION of symbol NAME in shared object HANDLE
67 (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
68 function, for RTLD_NEXT. Returns the symbol value, which may be
69 NULL. */
70 extern void *_dl_vsym (void *handle, const char *name, const char *version,
71 void *who);
73 /* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
74 _dl_catch_error. Returns zero for success, nonzero for failure; and
75 arranges for `dlerror' to return the error details.
76 ARGS is passed as argument to OPERATE. */
77 extern int _dlerror_run (void (*operate) (void *), void *args)
78 attribute_hidden;
80 #ifdef SHARED
81 # define DL_CALLER_DECL /* Nothing */
82 # define DL_CALLER RETURN_ADDRESS (0)
83 #else
84 # define DL_CALLER_DECL , void *dl_caller
85 # define DL_CALLER dl_caller
86 #endif
88 struct dlfcn_hook
90 void *(*dlopen) (const char *file, int mode, void *dl_caller);
91 int (*dlclose) (void *handle);
92 void *(*dlsym) (void *handle, const char *name, void *dl_caller);
93 void *(*dlvsym) (void *handle, const char *name, const char *version,
94 void *dl_caller);
95 char *(*dlerror) (void);
96 int (*dladdr) (const void *address, Dl_info *info);
97 int (*dladdr1) (const void *address, Dl_info *info,
98 void **extra_info, int flags);
99 int (*dlinfo) (void *handle, int request, void *arg, void *dl_caller);
100 void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
101 void *pad[4];
104 extern struct dlfcn_hook *_dlfcn_hook;
105 libdl_hidden_proto (_dlfcn_hook)
107 extern void *__dlopen (const char *file, int mode DL_CALLER_DECL)
108 attribute_hidden;
109 extern void *__dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL)
110 attribute_hidden;
111 extern int __dlclose (void *handle)
112 attribute_hidden;
113 extern void *__dlsym (void *handle, const char *name DL_CALLER_DECL)
114 attribute_hidden;
115 extern void *__dlvsym (void *handle, const char *name, const char *version
116 DL_CALLER_DECL)
117 attribute_hidden;
118 extern char *__dlerror (void)
119 attribute_hidden;
120 extern int __dladdr (const void *address, Dl_info *info)
121 attribute_hidden;
122 extern int __dladdr1 (const void *address, Dl_info *info,
123 void **extra_info, int flags)
124 attribute_hidden;
125 extern int __dlinfo (void *handle, int request, void *arg DL_CALLER_DECL)
126 attribute_hidden;
128 #ifndef SHARED
129 struct link_map;
130 extern void * __libc_dlsym_private (struct link_map *map, const char *name)
131 attribute_hidden;
132 extern void __libc_register_dl_open_hook (struct link_map *map)
133 attribute_hidden;
134 extern void __libc_register_dlfcn_hook (struct link_map *map)
135 attribute_hidden;
136 #endif
137 #endif
139 #endif