1 #include <sys/sysinfo.h>
4 #define klong long long
5 #define kulong unsigned long long
7 struct kernel_sysinfo {
23 int __lsysinfo(struct sysinfo *info)
25 struct kernel_sysinfo tmp;
26 int ret = syscall(SYS_sysinfo, &tmp);
27 if(ret == -1) return ret;
28 info->uptime = tmp.uptime;
29 info->loads[0] = tmp.loads[0];
30 info->loads[1] = tmp.loads[1];
31 info->loads[2] = tmp.loads[2];
33 kulong max = tmp.totalram | tmp.totalswap;
34 __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max));
35 shifts = shifts >= 32 ? shifts - 31 : 0;
36 info->totalram = tmp.totalram >> shifts;
37 info->freeram = tmp.freeram >> shifts;
38 info->sharedram = tmp.sharedram >> shifts;
39 info->bufferram = tmp.bufferram >> shifts;
40 info->totalswap = tmp.totalswap >> shifts;
41 info->freeswap = tmp.freeswap >> shifts;
42 info->procs = tmp.procs ;
43 info->totalhigh = tmp.totalhigh >> shifts;
44 info->freehigh = tmp.freehigh >> shifts;
45 info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts;
49 weak_alias(__lsysinfo, sysinfo);