Redefine signal for architecture mips (#40513)
authorSUN Guoyun <40024232+sunny868@users.noreply.github.com>
Mon, 10 Aug 2020 03:20:04 +0000 (11:20 +0800)
committerGitHub <noreply@github.com>
Mon, 10 Aug 2020 03:20:04 +0000 (20:20 -0700)
define SIGSTOP 19 is just ok for architecture x86、arm、s390、powerpc and so on.
but others architecture has different values.

Co-authored-by: Sunguoyun <sunguoyun@loongson.cn>
Co-authored-by: hev <wangrui@loongson.cn>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
src/libraries/Native/Unix/CMakeLists.txt
src/libraries/Native/Unix/System.Native/pal_process.c
src/libraries/Native/Unix/System.Native/pal_process.h

index 3168c7e..a4f8970 100644 (file)
@@ -64,6 +64,9 @@ elseif (CLR_CMAKE_TARGET_ARCH_WASM)
 elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
     add_definitions(-DTARGET_64BIT=1)
     add_definitions(-DTARGET_ARM64)
+elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
+    add_definitions(-DTARGET_64BIT=1)
+    add_definitions(-DTARGET_MIPS64)
 elseif (CLR_CMAKE_TARGET_ARCH_ARM)
     add_definitions(-DTARGET_32BIT=1)
     add_definitions(-DTARGET_ARM)
index 6d86efe..44cb59d 100644 (file)
@@ -28,8 +28,6 @@
 #include <sched.h>
 #endif
 
-// Validate that our Signals enum values are correct for the platform
-c_static_assert(PAL_SIGKILL == SIGKILL);
 
 // Validate that our SysLogPriority values are correct for the platform
 c_static_assert(PAL_LOG_EMERG == LOG_EMERG);
@@ -653,6 +651,26 @@ int32_t SystemNative_SetRLimit(RLimitResources resourceType, const RLimit* limit
 
 int32_t SystemNative_Kill(int32_t pid, int32_t signal)
 {
+    switch (signal)
+    {
+        case PAL_NONE:
+             signal = 0;
+             break;
+
+        case PAL_SIGKILL:
+             signal = SIGKILL;
+             break;
+
+        case PAL_SIGSTOP:
+             signal = SIGSTOP;
+             break;
+
+        default:
+             assert_msg(false, "Unknown signal", signal);
+             errno = EINVAL;
+             return -1;
+    }
+
     return kill(pid, signal);
 }
 
index 92eaf66..49d5b85 100644 (file)
@@ -72,7 +72,9 @@ typedef enum
 
 typedef enum
 {
+    PAL_NONE = 0,
     PAL_SIGKILL = 9, /* kill the specified process */
+    PAL_SIGSTOP = 19,
 } Signals;
 
 /**