support linux kernel apis (new archs) with old syscalls removed
[musl] / src / unistd / dup3.c
index 1f7134b..0eb6caf 100644 (file)
@@ -8,6 +8,7 @@
 int __dup3(int old, int new, int flags)
 {
        int r;
+#ifdef SYS_dup2
        if (old==new) return __syscall_ret(-EINVAL);
        if (flags & O_CLOEXEC) {
                while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
@@ -15,6 +16,9 @@ int __dup3(int old, int new, int flags)
        }
        while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
        if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
+#else
+       while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
+#endif
        return __syscall_ret(r);
 }