diff --git a/trunk/core/judge_client/judge_client.cc b/trunk/core/judge_client/judge_client.cc index babcbfced0f..d7c89818c2d 100644 --- a/trunk/core/judge_client/judge_client.cc +++ b/trunk/core/judge_client/judge_client.cc @@ -131,6 +131,28 @@ struct user_regs_struct { #endif +// https://github.com/torvalds/linux/blob/master/tools/include/nolibc/arch-loongarch.h +/* Syscalls for LoongArch : + * - stack is 16-byte aligned + * - syscall number is passed in a7 + * - arguments are in a0, a1, a2, a3, a4, a5 + * - the system call is performed by calling "syscall 0" + * - syscall return comes in a0 + * - the arguments are cast to long and assigned into the target + * registers which are then simply passed as registers to the asm code, + * so that we don't have to experience issues with register constraints. + */ +#ifdef __loongarch_lp64 // lonngarch64 龙芯的寄存器结构 + #define REG_ARG0 regs[4] // a0 (x4) + #define REG_ARG1 regs[5] // a1 (x5) + #define REG_ARG2 regs[6] // a2 (x6) + #define REG_ARG3 regs[7] // a3 (x7) + #define REG_ARG4 regs[8] // a4 (x8) + #define REG_ARG5 regs[9] // a5 (x9) + #define REG_SYSCALL regs[17] // a7 (x17) 系统调用号 + #define REG_RETVAL regs[4] // a0 (x4) 返回值存放 +#endif + #ifdef __i386 //32位x86寄存器 #define REG_SYSCALL orig_eax #define REG_RET eax @@ -1549,6 +1571,10 @@ int compile(int lang, char *work_dir) LIM.rlim_max = STD_MB << 12; LIM.rlim_cur = STD_MB << 12; #endif +#ifdef __loongarch_lp64 + LIM.rlim_max = STD_MB << 12; + LIM.rlim_cur = STD_MB << 12; +#endif #ifdef __arm__ LIM.rlim_max = STD_MB << 11; LIM.rlim_cur = STD_MB << 11; @@ -2139,6 +2165,10 @@ void copy_shell_runtime(char *work_dir) #endif +#ifdef __loongarch_lp64 + // +#endif + #ifdef __i386 execute_cmd("/bin/cp /lib/ld-linux* %s/lib/", work_dir); execute_cmd("/bin/cp -a /lib/i386-linux-gnu/ %s/lib/", work_dir); @@ -3317,6 +3347,10 @@ void watch_solution(pid_t pidApp, char *infile, int &ACflg, int spj, call_id=ptrace(PTRACE_GETREGS, pidCur, NULL, ®); call_id = ((unsigned int)reg.REG_SYSCALL) % call_array_size; #endif +#ifdef __loongarch_lp64 + ptrace(PTRACE_GETREGS, pidCur, NULL, ®); + call_id = ((unsigned int)reg.REG_SYSCALL) % call_array_size; +#endif #ifdef __x86_64__ ptrace(PTRACE_GETREGS, pidCur, NULL, ®); call_id = ((unsigned int)reg.REG_SYSCALL) % call_array_size; diff --git a/trunk/core/judge_client/okcalls.h b/trunk/core/judge_client/okcalls.h index de7e3c7cf24..e4f2d4b956b 100644 --- a/trunk/core/judge_client/okcalls.h +++ b/trunk/core/judge_client/okcalls.h @@ -60,3 +60,6 @@ #ifdef __mips__ #include "okcalls_mips.h" #endif +#ifdef __loongarch_lp64 + #include "okcalls_loongarch64.h" +#endif diff --git a/trunk/core/judge_client/okcalls_loongarch64.h b/trunk/core/judge_client/okcalls_loongarch64.h new file mode 100644 index 00000000000..6b491429c28 --- /dev/null +++ b/trunk/core/judge_client/okcalls_loongarch64.h @@ -0,0 +1,66 @@ +/* + * + * + * This file is part of HUSTOJ. + * + * HUSTOJ is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * HUSTOJ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HUSTOJ. if not, see . + */ + + // See: https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html + + #include + #define HOJ_MAX_LIMIT -1 + //C C++ + int LANG_CV[CALL_ARRAY_SIZE] = {0,1,27,48,56,62,63,64,72,78,80,94,104,112,134,135,160,184,200,214,216,220,221,248,152,301,344,136,120,8,40,232,328,440,424,472,360,24,456,504,296,168,376,382,392,511,280,488,88,312,264,408,0}; + //pascal + int LANG_PV[CALL_ARRAY_SIZE] = {29,63,64,78,94,112,134,163,220,511,0}; + //java + int LANG_JV[CALL_ARRAY_SIZE] = {48,56,57,63,78,79,80,94,96,98,99,112,134,135,163,172,179,214,215,220,222,226,511,0}; + //ruby + int LANG_RV[CALL_ARRAY_SIZE] = {0,0}; + //bash + int LANG_BV[CALL_ARRAY_SIZE] = {0,3,4,5,6,19,20,33,45,54,63,64,65,78,122,125,140,174,175,183,191,192,195,197,199,200,201,202,221,248,0}; + //python + int LANG_YV[CALL_ARRAY_SIZE] = {0,3,4,5,6,16,19,32,33,41,45,48,54,64,80,85,91,96,112,122,125,128,140,144,160,174,175,176,183,186,191,192,195,196,197,199,200,201,202,208,217,220,221,288,224,240,248,256,272,304,320,322,336,352,368,338,432,400,480,384,416,448,496,0}; + //php + int LANG_PHV[CALL_ARRAY_SIZE] = {0,0}; + //perl + int LANG_PLV[CALL_ARRAY_SIZE] = {0,0}; + //c-sharp + int LANG_CSV[CALL_ARRAY_SIZE] = {0,3,5,6,19,33,45,122,125,174,175,191,192,195,197,256,338,0}; + //objective-c + int LANG_OV[CALL_ARRAY_SIZE] = {0,0}; + //freebasic + int LANG_BASICV[CALL_ARRAY_SIZE] = {0,0}; + //scheme + int LANG_SV[CALL_ARRAY_SIZE] = {0,0}; + //lua + int LANG_LUAV[CALL_ARRAY_SIZE] = {0,0}; + //nodejs + int LANG_JSV[CALL_ARRAY_SIZE] = {0,0}; + //go-lang + int LANG_GOV[CALL_ARRAY_SIZE] = {0,0}; + //sqlite3 + int LANG_SQLV[CALL_ARRAY_SIZE] = {0,0}; + //fortran + int LANG_FV[CALL_ARRAY_SIZE] = {0,3,4,5,33,45,85,122,174,197,248,0}; + //matlib + int LANG_MV[CALL_ARRAY_SIZE] = {0,2,3,4,5,6,11,19,33,45,54,78,91,122,125,140,174,175,183,191,192,195,197,199,201,217,240,242,248,256,281,283,338,384,0}; + //cobol + int LANG_CBV[CALL_ARRAY_SIZE] = {0,2,3,4,5,6,11,19,33,45,54,78,91,122,125,140,174,175,183,191,192,195,197,199,201,217,240,242,248,256,281,283,338,384,0}; + //R + int LANG_RLV[CALL_ARRAY_SIZE]={0,11,0}; + //Scratch3 + int LANG_SB3V[CALL_ARRAY_SIZE]={0,11,0}; + int LANG_CJV[CALL_ARRAY_SIZE]={0,11,0}; \ No newline at end of file