Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: fusl/src/unistd/dup3.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #define _GNU_SOURCE 1 #define _GNU_SOURCE
2 #include <unistd.h> 2 #include <unistd.h>
3 #include <errno.h> 3 #include <errno.h>
4 #include <fcntl.h> 4 #include <fcntl.h>
5 #include "syscall.h" 5 #include "syscall.h"
6 #include "libc.h" 6 #include "libc.h"
7 7
8 int __dup3(int old, int new, int flags) 8 int __dup3(int old, int new, int flags) {
9 { 9 int r;
10 » int r;
11 #ifdef SYS_dup2 10 #ifdef SYS_dup2
12 » if (old==new) return __syscall_ret(-EINVAL); 11 if (old == new)
13 » if (flags & O_CLOEXEC) { 12 return __syscall_ret(-EINVAL);
14 » » while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); 13 if (flags & O_CLOEXEC) {
15 » » if (r!=-ENOSYS) return __syscall_ret(r); 14 while ((r = __syscall(SYS_dup3, old, new, flags)) == -EBUSY)
16 » } 15 ;
17 » while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); 16 if (r != -ENOSYS)
18 » if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC); 17 return __syscall_ret(r);
18 }
19 while ((r = __syscall(SYS_dup2, old, new)) == -EBUSY)
20 ;
21 if (flags & O_CLOEXEC)
22 __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
19 #else 23 #else
20 » while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); 24 while ((r = __syscall(SYS_dup3, old, new, flags)) == -EBUSY)
25 ;
21 #endif 26 #endif
22 » return __syscall_ret(r); 27 return __syscall_ret(r);
23 } 28 }
24 29
25 weak_alias(__dup3, dup3); 30 weak_alias(__dup3, dup3);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698