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 */
31 #include <bits/fcntl.h>
32 #include <bits/wordsize.h>
33 /* Pull in the arch specific type information */
34 #include <sys/types.h>
35 /* Pull in the arch specific page size */
36 #include <bits/uClibc_page.h>
37 /* Pull in the ldso syscalls and string functions */
38 #ifndef __ARCH_HAS_NO_SHARED__
39 #include <dl-syscall.h>
40 #include <dl-string.h>
42 /* Now the ldso specific headers */
44 #ifdef __UCLIBC_HAS_TLS__
50 /* common align masks, if not specified by sysdep headers */
52 #define ADDR_ALIGN (_dl_pagesize - 1)
56 #define PAGE_ALIGN (~ADDR_ALIGN)
60 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
63 /* For INIT/FINI dependency sorting. */
64 struct init_fini_list {
65 struct init_fini_list *next;
66 struct elf_resolve *tpnt;
69 /* Global variables used within the shared library loader */
70 extern char *_dl_library_path; /* Where we look for libraries */
71 extern char *_dl_preload; /* Things to be loaded before the libs */
72 extern char *_dl_ldsopath; /* Where the shared lib loader was found */
73 extern const char *_dl_progname; /* The name of the executable being run */
74 extern size_t _dl_pagesize; /* Store the page size for use later */
76 #if defined(USE_TLS) && USE_TLS
77 extern void _dl_add_to_slotinfo (struct link_map *l);
78 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
82 void _dl_add_to_slotinfo (struct link_map *l);
83 void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
85 #ifdef __SUPPORT_LD_DEBUG__
86 extern char *_dl_debug;
87 extern char *_dl_debug_symbols;
88 extern char *_dl_debug_move;
89 extern char *_dl_debug_reloc;
90 extern char *_dl_debug_detail;
91 extern char *_dl_debug_nofixups;
92 extern char *_dl_debug_bindings;
93 extern int _dl_debug_file;
94 # define __dl_debug_dprint(fmt, args...) \
95 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
96 # define _dl_if_debug_dprint(fmt, args...) \
97 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
99 # define __dl_debug_dprint(fmt, args...) do {} while (0)
100 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
101 # define _dl_debug_file 2
102 #endif /* __SUPPORT_LD_DEBUG__ */
105 # ifdef __SUPPORT_LD_DEBUG__
106 # define _dl_assert(expr) \
109 __dl_debug_dprint("assert(%s)\n", #expr); \
114 # define _dl_assert(expr) ((void)0)
118 # define _dl_assert(expr) assert(expr)
121 #ifdef __SUPPORT_LD_DEBUG_EARLY__
122 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
124 # define _dl_debug_early(fmt, args...) do {} while (0)
125 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
128 #define NULL ((void *) 0)
131 extern void *_dl_malloc(size_t size);
132 extern void *_dl_calloc(size_t __nmemb, size_t __size);
133 extern void *_dl_realloc(void *__ptr, size_t __size);
134 extern void _dl_free(void *);
135 extern char *_dl_getenv(const char *symbol, char **envp);
136 extern void _dl_unsetenv(const char *symbol, char **envp);
137 extern char *_dl_strdup(const char *string);
138 extern void _dl_dprintf(int, const char *, ...);
140 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
141 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
143 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
144 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
147 extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
148 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
149 DL_GET_READY_TO_RUN_EXTRA_PARMS);
151 #ifdef HAVE_DL_INLINES_H
152 #include <dl-inlines.h>
155 #else /* __ARCH_HAS_NO_SHARED__ */
159 #endif /* _LDSO_H_ */