update from main archive 961126
[glibc.git] / sysdeps / unix / sysv / linux / init-first.h
blobdd4f85af9d18100b2ae9344b3815ca444adb87f3
1 /* The job of this fragment it to find argc and friends for INIT.
2 This is done in one of two ways: either in the stack context
3 of program start, or having dlopen pass them in. */
5 #define SYSDEP_CALL_INIT(NAME, INIT) \
6 void NAME (void *arg) \
7 { \
8 int argc; \
9 char **argv, **envp; \
10 /* The next variable is only here to work around a bug in gcc <= 2.7.2.1. \
11 If the address would be taken inside the expression the optimizer \
12 would try to be too smart and throws it away. Grrr. */ \
13 int *dummy_addr = &_dl_starting_up; \
15 __libc_multiple_libcs = dummy_addr && !_dl_starting_up; \
17 if (!__libc_multiple_libcs) \
18 { \
19 argc = (int) arg; \
20 argv = (char **) &arg + 1; \
21 envp = &argv[argc+1]; \
22 } \
23 else \
24 { \
25 argc = (int) arg; \
26 argv = ((char ***) &arg)[1]; \
27 envp = ((char ***) &arg)[2]; \
28 } \
30 INIT (argc, argv, envp); \