time.h: Add CLOCK_TAI
[uclibc-ng.git] / ldso / include / ldso.h
blobf19957d1db2d6353608cd1b3dd1c95a8fdb9d78a
1 /*
2 * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
4 * GNU Lesser General Public License version 2.1 or later.
5 */
7 #ifndef _LDSO_H
8 #define _LDSO_H
10 #include <features.h>
12 #ifdef __ARCH_USE_MMU__
13 # define _MAP_UNINITIALIZED 0
14 #else
15 # define _MAP_UNINITIALIZED MAP_UNINITIALIZED
16 #endif
18 /* Prepare for the case that `__builtin_expect' is not available. */
19 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
20 #define __builtin_expect(x, expected_value) (x)
21 #endif
22 #ifndef likely
23 # define likely(x) __builtin_expect((!!(x)),1)
24 #endif
25 #ifndef unlikely
26 # define unlikely(x) __builtin_expect((!!(x)),0)
27 #endif
28 #ifndef __LINUX_COMPILER_H
29 #define __LINUX_COMPILER_H
30 #endif
32 /* Pull in compiler and arch stuff */
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <stddef.h> /* for ptrdiff_t */
36 #include <stdbool.h>
37 #define _FCNTL_H
38 /* We need this if arch has only new syscalls defined */
39 #ifndef AT_FDCWD
40 #define AT_FDCWD -100
41 #endif /* AT_FDCWD */
42 #include <bits/fcntl.h>
43 #include <bits/wordsize.h>
44 /* Pull in the arch specific type information */
45 #include <sys/types.h>
46 /* Pull in the arch specific page size */
47 #include <bits/uClibc_page.h>
48 /* Pull in the MIN macro */
49 #include <sys/param.h>
50 /* Pull in the ldso syscalls and string functions */
51 #ifndef __ARCH_HAS_NO_SHARED__
52 #include <dl-syscall.h>
53 #include <dl-string.h>
54 /* Now the ldso specific headers */
55 #include <dl-elf.h>
56 #ifdef __UCLIBC_HAS_TLS__
57 /* Defines USE_TLS */
58 #include <tls.h>
59 #endif
60 #include <dl-hash.h>
62 /* common align masks, if not specified by sysdep headers */
63 #ifndef ADDR_ALIGN
64 #define ADDR_ALIGN (_dl_pagesize - 1)
65 #endif
67 #ifndef PAGE_ALIGN
68 #define PAGE_ALIGN (~ADDR_ALIGN)
69 #endif
71 #ifndef OFFS_ALIGN
72 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
73 #endif
75 /* For INIT/FINI dependency sorting. */
76 struct init_fini_list {
77 struct init_fini_list *next;
78 struct elf_resolve *tpnt;
81 /* Global variables used within the shared library loader */
82 extern char *_dl_library_path; /* Where we look for libraries */
83 extern char *_dl_preload; /* Things to be loaded before the libs */
84 #ifdef __LDSO_SEARCH_INTERP_PATH__
85 extern const char *_dl_ldsopath; /* Where the shared lib loader was found */
86 #endif
87 extern const char *_dl_progname; /* The name of the executable being run */
88 extern size_t _dl_pagesize; /* Store the page size for use later */
89 #ifdef __LDSO_PRELINK_SUPPORT__
90 extern char *_dl_trace_prelink; /* Library for prelinking trace */
91 extern struct elf_resolve *_dl_trace_prelink_map; /* Library map for prelinking trace */
92 #else
93 #define _dl_trace_prelink 0
94 #endif
95 #ifdef __DSBT__
96 extern void **_dl_ldso_dsbt;
97 #endif
99 #if defined(USE_TLS) && USE_TLS
100 extern void _dl_add_to_slotinfo (struct link_map *l);
101 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
102 #endif
104 #ifdef __SUPPORT_LD_DEBUG__
105 extern char *_dl_debug;
106 extern char *_dl_debug_symbols;
107 extern char *_dl_debug_move;
108 extern char *_dl_debug_reloc;
109 extern char *_dl_debug_detail;
110 extern char *_dl_debug_nofixups;
111 extern char *_dl_debug_bindings;
112 extern int _dl_debug_file;
113 # define __dl_debug_dprint(fmt, args...) \
114 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
115 # define _dl_if_debug_dprint(fmt, args...) \
116 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
117 #else
118 # define __dl_debug_dprint(fmt, args...) do {} while (0)
119 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
120 /* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
121 # define _dl_debug_file 2*/
122 #endif /* __SUPPORT_LD_DEBUG__ */
124 #ifdef IS_IN_rtld
125 # ifdef __SUPPORT_LD_DEBUG__
126 # define _dl_assert(expr) \
127 do { \
128 if (!(expr)) { \
129 __dl_debug_dprint("assert(%s)\n", #expr); \
130 _dl_exit(45); \
132 } while (0)
133 # else
134 # define _dl_assert(expr) ((void)0)
135 # endif
136 #else
137 # include <assert.h>
138 # define _dl_assert(expr) assert(expr)
139 #endif
141 #ifdef __SUPPORT_LD_DEBUG_EARLY__
142 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
143 #else
144 # define _dl_debug_early(fmt, args...) do {} while (0)
145 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
147 #ifndef NULL
148 #define NULL ((void *) 0)
149 #endif
151 extern void *_dl_malloc(size_t size);
152 extern void *_dl_calloc(size_t __nmemb, size_t __size);
153 extern void *_dl_realloc(void *__ptr, size_t __size);
154 extern void _dl_free(void *);
155 extern char *_dl_getenv(const char *symbol, char **envp);
156 extern void _dl_unsetenv(const char *symbol, char **envp);
157 #ifdef IS_IN_rtld
158 extern char *_dl_strdup(const char *string);
159 extern void _dl_dprintf(int, const char *, ...);
160 #else
161 # include <string.h>
162 # define _dl_strdup strdup
163 # include <stdio.h>
164 # ifdef __USE_GNU
165 # define _dl_dprintf dprintf
166 # else
167 # define _dl_dprintf(fd, fmt, args...) fprintf(stderr, fmt, ## args)
168 # endif
169 #endif
171 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
172 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
173 #endif
174 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
175 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
176 #endif
178 extern void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
179 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
180 DL_GET_READY_TO_RUN_EXTRA_PARMS);
182 #ifdef HAVE_DL_INLINES_H
183 #include <dl-inlines.h>
184 #endif
186 #else /* __ARCH_HAS_NO_SHARED__ */
187 #include <dl-defs.h>
188 #endif
190 #endif /* _LDSO_H */