13 main (int argc
, char **argv
, char **envp
)
21 char *platform0
= NULL
;
22 char *platform1
= NULL
;
24 // First try the "traditional" way.
25 while (*envp
++ != NULL
)
26 ; /* Skip, skip, skip... and after finding a NULL we have the auxv. */
28 for (auxv_p
= (ElfW(auxv_t
) *) envp
;
29 auxv_p
->a_type
!= AT_NULL
;
32 if (auxv_p
->a_type
== AT_ENTRY
)
33 entry0
= (void *) auxv_p
->a_un
.a_val
;
34 if (auxv_p
->a_type
== AT_PLATFORM
)
35 platform0
= strdup((char *) auxv_p
->a_un
.a_val
);
38 // Now the /proc way as often used in libraries.
39 int fd
= open("/proc/self/auxv", O_RDONLY
);
43 while (read(fd
, &auxv
, sizeof(auxv
)) == sizeof(auxv
))
45 if (auxv
.a_type
== AT_ENTRY
)
46 entry1
= (void *) auxv
.a_un
.a_val
;
47 if (auxv
.a_type
== AT_PLATFORM
)
48 platform1
= strdup((char *) auxv
.a_un
.a_val
);
52 if (entry0
== entry1
&& entry0
!= NULL
)
53 fprintf(stderr
, "entries OK\n");
55 if (strcmp (platform0
, platform1
) == 0)
56 fprintf(stderr
, "platform OK\n");