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