move x32 sysinfo impl and syscall fixup code out of arch/x32/src
authorRich Felker <dalias@aerifal.cx>
Fri, 22 Jan 2016 03:39:07 +0000 (03:39 +0000)
committerRich Felker <dalias@aerifal.cx>
Fri, 22 Jan 2016 03:39:07 +0000 (03:39 +0000)
all such arch-specific translation units are being moved to
appropriate arch dirs under the main src tree.

arch/x32/src/syscall_cp_fixup.c [deleted file]
arch/x32/src/sysinfo.c [deleted file]
src/linux/x32/sysinfo.c [new file with mode: 0644]
src/linux/x32/sysinfo.s [deleted file]
src/thread/x32/syscall_cp_fixup.c [new file with mode: 0644]

diff --git a/arch/x32/src/syscall_cp_fixup.c b/arch/x32/src/syscall_cp_fixup.c
deleted file mode 100644 (file)
index b1f3a38..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#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);
-}
-
diff --git a/arch/x32/src/sysinfo.c b/arch/x32/src/sysinfo.c
deleted file mode 100644 (file)
index d1c1b14..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#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);
diff --git a/src/linux/x32/sysinfo.c b/src/linux/x32/sysinfo.c
new file mode 100644 (file)
index 0000000..d1c1b14
--- /dev/null
@@ -0,0 +1,50 @@
+#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);
diff --git a/src/linux/x32/sysinfo.s b/src/linux/x32/sysinfo.s
deleted file mode 100644 (file)
index 53d79db..0000000
+++ /dev/null
@@ -1 +0,0 @@
-# see arch/x32/src/sysinfo.c
diff --git a/src/thread/x32/syscall_cp_fixup.c b/src/thread/x32/syscall_cp_fixup.c
new file mode 100644 (file)
index 0000000..b1f3a38
--- /dev/null
@@ -0,0 +1,38 @@
+#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);
+}
+