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

Side by Side Diff: fusl/src/linux/x32/sysinfo.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 #include <sys/sysinfo.h> 1 #include <sys/sysinfo.h>
2 #include "syscall.h" 2 #include "syscall.h"
3 #include "libc.h" 3 #include "libc.h"
4 4
5 #define klong long long 5 #define klong long long
6 #define kulong unsigned long long 6 #define kulong unsigned long long
7 7
8 struct kernel_sysinfo { 8 struct kernel_sysinfo {
9 » klong uptime; 9 klong uptime;
10 » kulong loads[3]; 10 kulong loads[3];
11 » kulong totalram; 11 kulong totalram;
12 » kulong freeram; 12 kulong freeram;
13 » kulong sharedram; 13 kulong sharedram;
14 » kulong bufferram; 14 kulong bufferram;
15 » kulong totalswap; 15 kulong totalswap;
16 » kulong freeswap; 16 kulong freeswap;
17 » short procs; 17 short procs;
18 » short pad; 18 short pad;
19 » kulong totalhigh; 19 kulong totalhigh;
20 » kulong freehigh; 20 kulong freehigh;
21 » unsigned mem_unit; 21 unsigned mem_unit;
22 }; 22 };
23 23
24 int __lsysinfo(struct sysinfo *info) 24 int __lsysinfo(struct sysinfo* info) {
25 { 25 struct kernel_sysinfo tmp;
26 » struct kernel_sysinfo tmp; 26 int ret = syscall(SYS_sysinfo, &tmp);
27 » int ret = syscall(SYS_sysinfo, &tmp); 27 if (ret == -1)
28 » if(ret == -1) return ret; 28 return ret;
29 » info->uptime = tmp.uptime; 29 info->uptime = tmp.uptime;
30 » info->loads[0] = tmp.loads[0]; 30 info->loads[0] = tmp.loads[0];
31 » info->loads[1] = tmp.loads[1]; 31 info->loads[1] = tmp.loads[1];
32 » info->loads[2] = tmp.loads[2]; 32 info->loads[2] = tmp.loads[2];
33 » kulong shifts; 33 kulong shifts;
34 » kulong max = tmp.totalram | tmp.totalswap; 34 kulong max = tmp.totalram | tmp.totalswap;
35 » __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max)); 35 __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max));
36 » shifts = shifts >= 32 ? shifts - 31 : 0; 36 shifts = shifts >= 32 ? shifts - 31 : 0;
37 » info->totalram = tmp.totalram >> shifts; 37 info->totalram = tmp.totalram >> shifts;
38 » info->freeram = tmp.freeram >> shifts; 38 info->freeram = tmp.freeram >> shifts;
39 » info->sharedram = tmp.sharedram >> shifts; 39 info->sharedram = tmp.sharedram >> shifts;
40 » info->bufferram = tmp.bufferram >> shifts; 40 info->bufferram = tmp.bufferram >> shifts;
41 » info->totalswap = tmp.totalswap >> shifts; 41 info->totalswap = tmp.totalswap >> shifts;
42 » info->freeswap = tmp.freeswap >> shifts; 42 info->freeswap = tmp.freeswap >> shifts;
43 » info->procs = tmp.procs ; 43 info->procs = tmp.procs;
44 » info->totalhigh = tmp.totalhigh >> shifts; 44 info->totalhigh = tmp.totalhigh >> shifts;
45 » info->freehigh = tmp.freehigh >> shifts; 45 info->freehigh = tmp.freehigh >> shifts;
46 » info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts; 46 info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts;
47 » return ret; 47 return ret;
48 } 48 }
49 49
50 weak_alias(__lsysinfo, sysinfo); 50 weak_alias(__lsysinfo, sysinfo);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698