1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
5 * GNU Lesser General Public License version 2.1 or later.
13 /* Prepare for the case that `__builtin_expect' is not available. */
14 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
15 #define __builtin_expect(x, expected_value) (x)
18 # define likely(x) __builtin_expect((!!(x)),1)
21 # define unlikely(x) __builtin_expect((!!(x)),0)
23 #ifndef __LINUX_COMPILER_H
24 #define __LINUX_COMPILER_H
27 /* Pull in compiler and arch stuff */
30 #include <stddef.h> /* for ptrdiff_t */
32 #include <bits/fcntl.h>
33 #include <bits/wordsize.h>
34 /* Pull in the arch specific type information */
35 #include <sys/types.h>
36 /* Pull in the arch specific page size */
37 #include <bits/uClibc_page.h>
38 /* Pull in the ldso syscalls and string functions */
39 #ifndef __ARCH_HAS_NO_SHARED__
40 #include <dl-syscall.h>
41 #include <dl-string.h>
43 /* Now the ldso specific headers */
45 #ifdef __UCLIBC_HAS_TLS__
51 /* common align masks, if not specified by sysdep headers */
53 #define ADDR_ALIGN (_dl_pagesize - 1)
57 #define PAGE_ALIGN (~ADDR_ALIGN)
61 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
64 /* For INIT/FINI dependency sorting. */
65 struct init_fini_list {
66 struct init_fini_list *next;
67 struct elf_resolve *tpnt;
70 /* Global variables used within the shared library loader */
71 extern char *_dl_library_path; /* Where we look for libraries */
72 extern char *_dl_preload; /* Things to be loaded before the libs */
73 extern char *_dl_ldsopath; /* Where the shared lib loader was found */
74 extern const char *_dl_progname; /* The name of the executable being run */
75 extern size_t _dl_pagesize; /* Store the page size for use later */
76 #ifdef __LDSO_PRELINK_SUPPORT__
77 extern char *_dl_trace_prelink; /* Library for prelinking trace */
78 extern struct elf_resolve *_dl_trace_prelink_map; /* Library map for prelinking trace */
80 #define _dl_trace_prelink 0
83 #if defined(USE_TLS) && USE_TLS
84 extern void _dl_add_to_slotinfo (struct link_map *l);
85 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
89 void _dl_add_to_slotinfo (struct link_map *l);
90 void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
92 #ifdef __SUPPORT_LD_DEBUG__
93 extern char *_dl_debug;
94 extern char *_dl_debug_symbols;
95 extern char *_dl_debug_move;
96 extern char *_dl_debug_reloc;
97 extern char *_dl_debug_detail;
98 extern char *_dl_debug_nofixups;
99 extern char *_dl_debug_bindings;
100 extern int _dl_debug_file;
101 # define __dl_debug_dprint(fmt, args...) \
102 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
103 # define _dl_if_debug_dprint(fmt, args...) \
104 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
106 # define __dl_debug_dprint(fmt, args...) do {} while (0)
107 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
108 # define _dl_debug_file 2
109 #endif /* __SUPPORT_LD_DEBUG__ */
112 # ifdef __SUPPORT_LD_DEBUG__
113 # define _dl_assert(expr) \
116 __dl_debug_dprint("assert(%s)\n", #expr); \
121 # define _dl_assert(expr) ((void)0)
125 # define _dl_assert(expr) assert(expr)
128 #ifdef __SUPPORT_LD_DEBUG_EARLY__
129 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
131 # define _dl_debug_early(fmt, args...) do {} while (0)
132 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
135 #define NULL ((void *) 0)
138 extern void *_dl_malloc(size_t size);
139 extern void *_dl_calloc(size_t __nmemb, size_t __size);
140 extern void *_dl_realloc(void *__ptr, size_t __size);
141 extern void _dl_free(void *);
142 extern char *_dl_getenv(const char *symbol, char **envp);
143 extern void _dl_unsetenv(const char *symbol, char **envp);
144 extern char *_dl_strdup(const char *string);
145 extern void _dl_dprintf(int, const char *, ...);
147 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
148 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
150 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
151 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
154 extern void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
155 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
156 DL_GET_READY_TO_RUN_EXTRA_PARMS);
158 #ifdef HAVE_DL_INLINES_H
159 #include <dl-inlines.h>
162 #else /* __ARCH_HAS_NO_SHARED__ */
166 #endif /* _LDSO_H_ */