+++ /dev/null
-#include <sys/syscall.h>
-
-__attribute__((__visibility__("hidden")))
-long __syscall_cp_internal(volatile void*, long long, long long, long long, long long,
- long long, long long, long long);
-
-struct __timespec { long long tv_sec; long tv_nsec; };
-struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
-#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
-#define __fixup(X) do { if(X) { \
- ts->tv_sec = __tsc(X)->tv_sec; \
- ts->tv_nsec = __tsc(X)->tv_nsec; \
- (X) = (unsigned long)ts; } } while(0)
-
-__attribute__((__visibility__("hidden")))
-long __syscall_cp_asm (volatile void * foo, long long n, long long a1, long long a2, long long a3,
- long long a4, long long a5, long long a6)
-{
- struct __timespec_kernel ts[1];
- switch (n) {
- case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6:
- __fixup(a5);
- break;
- case SYS_futex:
- if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */)
- __fixup(a4);
- break;
- case SYS_clock_nanosleep:
- case SYS_rt_sigtimedwait: case SYS_ppoll:
- __fixup(a3);
- break;
- case SYS_nanosleep:
- __fixup(a1);
- break;
- }
- return __syscall_cp_internal(foo, n, a1, a2, a3, a4, a5, a6);
-}
-
+++ /dev/null
-#include <sys/sysinfo.h>
-#include "syscall.h"
-#include "libc.h"
-
-#define klong long long
-#define kulong unsigned long long
-
-struct kernel_sysinfo {
- klong uptime;
- kulong loads[3];
- kulong totalram;
- kulong freeram;
- kulong sharedram;
- kulong bufferram;
- kulong totalswap;
- kulong freeswap;
- short procs;
- short pad;
- kulong totalhigh;
- kulong freehigh;
- unsigned mem_unit;
-};
-
-int __lsysinfo(struct sysinfo *info)
-{
- struct kernel_sysinfo tmp;
- int ret = syscall(SYS_sysinfo, &tmp);
- if(ret == -1) return ret;
- info->uptime = tmp.uptime;
- info->loads[0] = tmp.loads[0];
- info->loads[1] = tmp.loads[1];
- info->loads[2] = tmp.loads[2];
- kulong shifts;
- kulong max = tmp.totalram | tmp.totalswap;
- __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max));
- shifts = shifts >= 32 ? shifts - 31 : 0;
- info->totalram = tmp.totalram >> shifts;
- info->freeram = tmp.freeram >> shifts;
- info->sharedram = tmp.sharedram >> shifts;
- info->bufferram = tmp.bufferram >> shifts;
- info->totalswap = tmp.totalswap >> shifts;
- info->freeswap = tmp.freeswap >> shifts;
- info->procs = tmp.procs ;
- info->totalhigh = tmp.totalhigh >> shifts;
- info->freehigh = tmp.freehigh >> shifts;
- info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts;
- return ret;
-}
-
-weak_alias(__lsysinfo, sysinfo);
--- /dev/null
+#include <sys/sysinfo.h>
+#include "syscall.h"
+#include "libc.h"
+
+#define klong long long
+#define kulong unsigned long long
+
+struct kernel_sysinfo {
+ klong uptime;
+ kulong loads[3];
+ kulong totalram;
+ kulong freeram;
+ kulong sharedram;
+ kulong bufferram;
+ kulong totalswap;
+ kulong freeswap;
+ short procs;
+ short pad;
+ kulong totalhigh;
+ kulong freehigh;
+ unsigned mem_unit;
+};
+
+int __lsysinfo(struct sysinfo *info)
+{
+ struct kernel_sysinfo tmp;
+ int ret = syscall(SYS_sysinfo, &tmp);
+ if(ret == -1) return ret;
+ info->uptime = tmp.uptime;
+ info->loads[0] = tmp.loads[0];
+ info->loads[1] = tmp.loads[1];
+ info->loads[2] = tmp.loads[2];
+ kulong shifts;
+ kulong max = tmp.totalram | tmp.totalswap;
+ __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max));
+ shifts = shifts >= 32 ? shifts - 31 : 0;
+ info->totalram = tmp.totalram >> shifts;
+ info->freeram = tmp.freeram >> shifts;
+ info->sharedram = tmp.sharedram >> shifts;
+ info->bufferram = tmp.bufferram >> shifts;
+ info->totalswap = tmp.totalswap >> shifts;
+ info->freeswap = tmp.freeswap >> shifts;
+ info->procs = tmp.procs ;
+ info->totalhigh = tmp.totalhigh >> shifts;
+ info->freehigh = tmp.freehigh >> shifts;
+ info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts;
+ return ret;
+}
+
+weak_alias(__lsysinfo, sysinfo);
+++ /dev/null
-# see arch/x32/src/sysinfo.c
--- /dev/null
+#include <sys/syscall.h>
+
+__attribute__((__visibility__("hidden")))
+long __syscall_cp_internal(volatile void*, long long, long long, long long, long long,
+ long long, long long, long long);
+
+struct __timespec { long long tv_sec; long tv_nsec; };
+struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
+#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
+#define __fixup(X) do { if(X) { \
+ ts->tv_sec = __tsc(X)->tv_sec; \
+ ts->tv_nsec = __tsc(X)->tv_nsec; \
+ (X) = (unsigned long)ts; } } while(0)
+
+__attribute__((__visibility__("hidden")))
+long __syscall_cp_asm (volatile void * foo, long long n, long long a1, long long a2, long long a3,
+ long long a4, long long a5, long long a6)
+{
+ struct __timespec_kernel ts[1];
+ switch (n) {
+ case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6:
+ __fixup(a5);
+ break;
+ case SYS_futex:
+ if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */)
+ __fixup(a4);
+ break;
+ case SYS_clock_nanosleep:
+ case SYS_rt_sigtimedwait: case SYS_ppoll:
+ __fixup(a3);
+ break;
+ case SYS_nanosleep:
+ __fixup(a1);
+ break;
+ }
+ return __syscall_cp_internal(foo, n, a1, a2, a3, a4, a5, a6);
+}
+