mcst-linux-kernel/patches-2024.06.26/gperftools-2.10/0001-Add-basic-e2k-patch-ca...

142 lines
6.7 KiB
Diff

Link:
Subject: Add basic e2k patch: cache 64b, syscall support
Bug: 146136
diff -Naur a/src/base/basictypes.h b/src/base/basictypes.h
--- a/src/base/basictypes.h 2023-07-05 16:08:45.436267776 +0000
+++ b/src/base/basictypes.h 2023-07-05 16:08:07.643612610 +0000
@@ -371,6 +371,8 @@
#if defined(HAVE___ATTRIBUTE__)
# if (defined(__i386__) || defined(__x86_64__))
# define CACHELINE_ALIGNED __attribute__((aligned(64)))
+# elif (defined(__e2k__))
+# define CACHELINE_ALIGNED __attribute__((aligned(64)))
# elif (defined(__PPC__) || defined(__PPC64__))
# define CACHELINE_ALIGNED __attribute__((aligned(16)))
# elif (defined(__arm__))
diff -Naur a/src/base/linux_syscall_support.h b/src/base/linux_syscall_support.h
--- a/src/base/linux_syscall_support.h 2023-07-05 16:08:54.900431845 +0000
+++ b/src/base/linux_syscall_support.h 2023-07-05 16:12:33.184215968 +0000
@@ -134,7 +134,7 @@
* s390, s390x, riscv64, and loongarch64 on Linux.
* Porting to other related platforms should not be difficult.
*/
-#if (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
+#if (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__e2k__) || \
defined(__mips__) || defined(__mips64) || defined(__mips64el__) || defined(__PPC__) || \
defined(__aarch64__) || defined(__s390__) || defined(__riscv)) || defined(__loongarch64) \
&& (defined(__linux))
@@ -168,7 +168,9 @@
/* Include definitions of the ABI currently in use. */
#include <sgidefs.h>
#endif
-
+#ifdef __e2k__
+#include <sys/syscall.h>
+#endif
#endif
/* As glibc often provides subtly incompatible data structures (and implicit
@@ -2386,6 +2388,60 @@
}
LSS_RETURN(int, __res);
}
+ #elif defined(__e2k__)
+ #undef _syscall0
+ #define _syscall0(type,name) \
+ type LSS_NAME(name)() { \
+ type ret; \
+ ret = syscall(__NR_##name); \
+ return ret; \
+ }
+ #undef _syscall1
+ #define _syscall1(type,name,type1,arg1) \
+ type LSS_NAME(name)(type1 arg1) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1); \
+ return ret; \
+ }
+ #undef _syscall2
+ #define _syscall2(type,name,type1,arg1,type2,arg2) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1, arg2); \
+ return ret; \
+ }
+ #undef _syscall3
+ #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1, arg2, arg3); \
+ return ret; \
+ }
+ #undef _syscall4
+ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1, arg2, arg3, arg4); \
+ return ret; \
+ }
+ #undef _syscall5
+ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5); \
+ return ret; \
+ }
+ #undef _syscall6
+ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ type ret; \
+ ret = (type)syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
+ return ret; \
+ }
#elif defined(__s390__)
#undef LSS_REG
#define LSS_REG(r, a) register unsigned long __r##r __asm__("r"#r) = (unsigned long) a
@@ -2954,7 +3010,18 @@
return 0;
}
}
-
+#ifdef __e2k__
+ #define __NR__sigaction __NR_sigaction
+ #define __NR__sigprocmask __NR_sigprocmask
+ LSS_INLINE _syscall2(int, fstat64, int, f,
+ struct kernel_stat64 *, b)
+ LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
+ loff_t *, res, uint, wh)
+ LSS_INLINE _syscall6(void*, mmap, void*, s,
+ size_t, l, int, p,
+ int, f, int, d,
+ off_t, o)
+#endif
#if defined(__i386__) || \
defined(__arm__) || \
(defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \
diff -Naur a/src/malloc_hook_mmap_linux.h b/src/malloc_hook_mmap_linux.h
--- a/src/malloc_hook_mmap_linux.h 2023-07-05 16:09:17.692826969 +0000
+++ b/src/malloc_hook_mmap_linux.h 2023-07-05 16:08:07.639612542 +0000
@@ -72,6 +72,17 @@
#define MALLOC_HOOK_HAVE_DO_MMAP64 1
+#elif defined(__e2k__)
+
+static inline void* do_mmap64(void *start, size_t length,
+ int prot, int flags,
+ int fd, off64_t offset) __THROW {
+ return (void*)syscall(SYS_mmap, start, length, prot, flags, fd, offset);
+}
+
+#define MALLOC_HOOK_HAVE_DO_MMAP64 1
+
+
#elif defined(__i386__) || defined(__PPC__) || defined(__mips__) || \
defined(__arm__)