time.h: Add CLOCK_TAI
[uclibc-ng.git] / ldso / include / ldsodefs.h
blob9ae645c6011fce3df09dfb6176fe31426f722504
1 #ifndef _LDSODEFS_H
2 #define _LDSODEFS_H 1
4 #include <bits/kernel-features.h>
6 #include <features.h>
7 #include <tls.h>
9 #ifdef __mips__
10 /* The MIPS ABI specifies that the dynamic section has to be read-only. */
12 #define DL_RO_DYN_SECTION 1
14 /* TODO: Import in 64-bit relocations from glibc. */
15 #endif
17 #ifndef SHARED
18 # define EXTERN extern
19 #else
20 # ifdef IS_IN_rtld
21 # define EXTERN
22 # else
23 # define EXTERN extern
24 # endif
25 #endif
27 /* Non-shared code has no support for multiple namespaces. */
28 #ifdef SHARED
29 # define DL_NNS 16
30 #else
31 # define DL_NNS 1
32 #endif
34 #define GL(x) _##x
35 #define GLRO(x) _##x
37 /* Variable pointing to the end of the stack (or close to it). This value
38 must be constant over the runtime of the application. Some programs
39 might use the variable which results in copy relocations on some
40 platforms. But this does not matter, ld.so can always use the local
41 copy. */
42 extern void *__libc_stack_end;
44 /* Determine next available module ID. */
45 extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden;
47 /* Calculate offset of the TLS blocks in the static TLS block. */
48 extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden;
50 /* Set up the data structures for TLS, when they were not set up at startup.
51 Returns nonzero on malloc failure.
52 This is called from _dl_map_object_from_fd or by libpthread. */
53 extern int _dl_tls_setup (void) internal_function;
54 rtld_hidden_proto (_dl_tls_setup)
56 /* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */
57 extern void *_dl_allocate_tls (void *mem) internal_function;
59 /* Get size and alignment requirements of the static TLS block. */
60 extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
61 internal_function;
63 extern void _dl_allocate_static_tls (struct link_map *map)
64 internal_function attribute_hidden;
65 extern int _dl_try_allocate_static_tls (struct link_map* map)
66 internal_function attribute_hidden;
68 /* Taken from glibc/elf/dl-reloc.c */
69 #define CHECK_STATIC_TLS(sym_map) \
70 do { \
71 if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET, 0)) \
72 _dl_allocate_static_tls (sym_map); \
73 } while (0)
74 #define TRY_STATIC_TLS(sym_map) \
75 (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1) \
76 || _dl_try_allocate_static_tls (sym_map) == 0)
78 /* These are internal entry points to the two halves of _dl_allocate_tls,
79 only used within rtld.c itself at startup time. */
80 extern void *_dl_allocate_tls_storage (void)
81 internal_function attribute_hidden;
82 extern void *_dl_allocate_tls_init (void *) internal_function;
84 /* Deallocate memory allocated with _dl_allocate_tls. */
85 extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
87 extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden;
89 /* Highest dtv index currently needed. */
90 EXTERN size_t _dl_tls_max_dtv_idx;
91 /* Flag signalling whether there are gaps in the module ID allocation. */
92 EXTERN bool _dl_tls_dtv_gaps;
93 /* Information about the dtv slots. */
94 EXTERN struct dtv_slotinfo_list
96 size_t len;
97 struct dtv_slotinfo_list *next;
98 struct dtv_slotinfo
100 size_t gen;
101 bool is_static;
102 struct link_map *map;
103 } slotinfo[0];
104 } *_dl_tls_dtv_slotinfo_list;
105 /* Number of modules in the static TLS block. */
106 EXTERN size_t _dl_tls_static_nelem;
107 /* Size of the static TLS block. */
108 EXTERN size_t _dl_tls_static_size;
109 /* Size actually allocated in the static TLS block. */
110 EXTERN size_t _dl_tls_static_used;
111 /* Alignment requirement of the static TLS block. */
112 EXTERN size_t _dl_tls_static_align;
113 /* Function pointer for catching TLS errors. */
114 #if 1 /* def _LIBC_REENTRANT */
115 EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const));
116 #endif
118 /* Number of additional entries in the slotinfo array of each slotinfo
119 list element. A large number makes it almost certain take we never
120 have to iterate beyond the first element in the slotinfo list. */
121 # define TLS_SLOTINFO_SURPLUS (62)
123 /* Number of additional slots in the dtv allocated. */
124 # define DTV_SURPLUS (14)
126 /* Initial dtv of the main thread, not allocated with normal malloc. */
127 EXTERN void *_dl_initial_dtv;
128 /* Generation counter for the dtv. */
129 EXTERN size_t _dl_tls_generation;
131 EXTERN void (*_dl_init_static_tls) (struct link_map *);
133 /* We have the auxiliary vector. */
134 #define HAVE_AUX_VECTOR
136 /* We can assume that the kernel always provides the AT_UID, AT_EUID,
137 AT_GID, and AT_EGID values in the auxiliary vector from 2.4.0 or so on. */
138 #if __ASSUME_AT_XID
139 # define HAVE_AUX_XID
140 #endif
142 /* We can assume that the kernel always provides the AT_SECURE value
143 in the auxiliary vector from 2.5.74 or so on. */
144 #if __ASSUME_AT_SECURE
145 # define HAVE_AUX_SECURE
146 #endif
148 /* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
149 up the page size information. */
150 #if __ASSUME_AT_PAGESIZE
151 # define HAVE_AUX_PAGESIZE
152 #endif
154 #endif