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

Side by Side Diff: fusl/src/linux/prlimit.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 <sys/resource.h> 2 #include <sys/resource.h>
3 #include "syscall.h" 3 #include "syscall.h"
4 #include "libc.h" 4 #include "libc.h"
5 5
6 #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) 6 #define FIX(x) \
7 do { \
8 if ((x) >= SYSCALL_RLIM_INFINITY) \
9 (x) = RLIM_INFINITY; \
10 } while (0)
7 11
8 int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlim it *old_limit) 12 int prlimit(pid_t pid,
9 { 13 int resource,
10 » struct rlimit tmp; 14 const struct rlimit* new_limit,
11 » int r; 15 struct rlimit* old_limit) {
12 » if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { 16 struct rlimit tmp;
13 » » tmp = *new_limit; 17 int r;
14 » » FIX(tmp.rlim_cur); 18 if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
15 » » FIX(tmp.rlim_max); 19 tmp = *new_limit;
16 » » new_limit = &tmp; 20 FIX(tmp.rlim_cur);
17 » } 21 FIX(tmp.rlim_max);
18 » r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit); 22 new_limit = &tmp;
19 » if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { 23 }
20 » » FIX(old_limit->rlim_cur); 24 r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit);
21 » » FIX(old_limit->rlim_max); 25 if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
22 » } 26 FIX(old_limit->rlim_cur);
23 » return r; 27 FIX(old_limit->rlim_max);
28 }
29 return r;
24 } 30 }
25 31
26 #undef prlimit64 32 #undef prlimit64
27 LFS64(prlimit); 33 LFS64(prlimit);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698