fix fesetenv(FE_DFL_ENV) on mips
[musl] / src / env / __libc_start_main.c
index d7ec3ab..10e5590 100644 (file)
@@ -1,6 +1,7 @@
 #include <elf.h>
 #include <poll.h>
 #include <fcntl.h>
+#include <signal.h>
 #include "syscall.h"
 #include "atomic.h"
 #include "libc.h"
@@ -22,6 +23,9 @@ weak_alias(dummy1, __init_ssp);
 extern size_t __hwcap, __sysinfo;
 extern char *__progname, *__progname_full;
 
+#ifndef SHARED
+static
+#endif
 void __init_libc(char **envp, char *pn)
 {
        size_t i, *auxv, aux[AUX_CNT] = { 0 };
@@ -45,9 +49,13 @@ void __init_libc(char **envp, char *pn)
                && !aux[AT_SECURE]) return;
 
        struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
+#ifdef SYS_poll
        __syscall(SYS_poll, pfd, 3, 0);
+#else
+       __syscall(SYS_ppoll, pfd, 3, &(struct timespec){0}, 0, _NSIG/8);
+#endif
        for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
-               if (__syscall(SYS_open, "/dev/null", O_RDWR|O_LARGEFILE)<0)
+               if (__sys_open("/dev/null", O_RDWR)<0)
                        a_crash();
        libc.secure = 1;
 }
@@ -64,7 +72,7 @@ int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
                (*(void (**)())a)();
 #endif
 
-       /* Pass control to to application */
+       /* Pass control to the application */
        exit(main(argc, argv, envp));
        return 0;
 }