2 * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
4 * GNU Lesser General Public License version 2.1 or later.
12 #ifdef __ARCH_USE_MMU__
13 # define _MAP_UNINITIALIZED 0
15 # define _MAP_UNINITIALIZED MAP_UNINITIALIZED
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)
23 # define likely(x) __builtin_expect((!!(x)),1)
26 # define unlikely(x) __builtin_expect((!!(x)),0)
28 #ifndef __LINUX_COMPILER_H
29 #define __LINUX_COMPILER_H
32 /* Pull in compiler and arch stuff */
35 #include <stddef.h> /* for ptrdiff_t */
38 /* We need this if arch has only new syscalls defined */
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 #if !defined(__ARCH_HAS_NO_SHARED__) || !defined(__ARCH_HAS_NO_LDSO__)
52 #include <dl-syscall.h>
53 #include <dl-string.h>
54 /* Now the ldso specific headers */
56 #ifdef __UCLIBC_HAS_TLS__
62 /* common align masks, if not specified by sysdep headers */
64 #define ADDR_ALIGN (_dl_pagesize - 1)
68 #define PAGE_ALIGN (~ADDR_ALIGN)
72 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
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 */
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 */
93 #define _dl_trace_prelink 0
96 extern void **_dl_ldso_dsbt
;
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);
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 char *_dl_debug_vdso
;
113 extern int _dl_debug_file
;
114 # define __dl_debug_dprint(fmt, args...) \
115 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
116 # define _dl_if_debug_dprint(fmt, args...) \
117 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
119 # define __dl_debug_dprint(fmt, args...) do {} while (0)
120 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
121 /* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
122 # define _dl_debug_file 2*/
123 #endif /* __SUPPORT_LD_DEBUG__ */
126 # ifdef __SUPPORT_LD_DEBUG__
127 # define _dl_assert(expr) \
130 __dl_debug_dprint("assert(%s)\n", #expr); \
135 # define _dl_assert(expr) ((void)0)
139 # define _dl_assert(expr) assert(expr)
142 #ifdef __SUPPORT_LD_DEBUG_EARLY__
143 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
145 # define _dl_debug_early(fmt, args...) do {} while (0)
146 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
149 #define NULL ((void *) 0)
153 extern void *_dl_malloc(size_t size
);
154 extern void *_dl_calloc(size_t __nmemb
, size_t __size
);
155 extern void *_dl_realloc(void *__ptr
, size_t __size
);
156 extern void _dl_free(void *);
157 extern char *_dl_getenv(const char *symbol
, char **envp
);
158 extern void _dl_unsetenv(const char *symbol
, char **envp
);
160 extern char *_dl_strdup(const char *string
);
161 extern void _dl_dprintf(int, const char *, ...);
164 # define _dl_strdup strdup
167 # define _dl_dprintf dprintf
169 # define _dl_dprintf(fd, fmt, args...) fprintf(stderr, fmt, ## args)
173 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
174 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
176 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
177 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
180 extern void *_dl_get_ready_to_run(struct elf_resolve
*tpnt
, DL_LOADADDR_TYPE load_addr
,
181 char **envp
, char **argv
182 DL_GET_READY_TO_RUN_EXTRA_PARMS
);
184 #ifdef HAVE_DL_INLINES_H
185 #include <dl-inlines.h>
188 #else /* __ARCH_HAS_NO_SHARED__ */
194 #define AUX_MAX_AT_ID 40
195 extern ElfW(auxv_t
) _dl_auxvt
[AUX_MAX_AT_ID
];
197 void load_vdso( uint32_t sys_info_ehdr
, char **envp
);
199 #ifdef __VDSO_SUPPORT__
200 extern void* _dl__vdso_gettimeofday
;