From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 4A02E3858D34 for ; Thu, 2 Jul 2020 20:44:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4A02E3858D34 Received: by mail-qv1-xf42.google.com with SMTP id t7so13331948qvl.8 for ; Thu, 02 Jul 2020 13:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:from:autocrypt:subject:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BcQd96ppMn7dztaGwU0+z1DKZ5qV0CqedD66hT6xJVI=; b=Jrj1NyPnY88dC8BhP9qfsLwB4v25GARQWQyDsWLb1PYt1kTU+4Ba7G+hAePatza9xp chmE8ZGF+CSyQpBDIOyr+3U4A4veXV8FTKUusLmCXCCTPqQ3riiLBLI6LHMWhRkZGfYu 6+XC5Mv1U54RZmOJsu+h6ki/BNRi1KM5jRWljz558ijDOSH9yeIqbDFgyW1viO5P0uoA hfyKpVxASdJA8Dh6YPP8FGuw0v3cZqNQclKtkF4azVcIZv3GdCynCt2hH4h+84UH+6rk SpcSFPIrpk+gHV3xYhPSwSh4wcjhoZVi03bg4Ds4HYg4vsBoeuV8AWCUoZJc9dtJPw14 rZKw== X-Gm-Message-State: AOAM531Ngy4EebVe5ZA1vjsUcQ0c3b8kId3DkEOwKKMzE7siooEkNZpB Yh1w7mMQxheEtWGFSBarZJYoq8wGVOs= X-Google-Smtp-Source: ABdhPJyRHKvft6Tcxd07zkrE/W8lg+/ADjoHjlpxGiaFp2vyAbVw2AHtV70hRy+CCMLV3Y9Q7gUAYA== X-Received: by 2002:a0c:e008:: with SMTP id j8mr28863250qvk.87.1593722676074; Thu, 02 Jul 2020 13:44:36 -0700 (PDT) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id k2sm9397921qkf.127.2020.07.02.13.44.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jul 2020 13:44:35 -0700 (PDT) To: libc-alpha@sourceware.org References: <20200615201441.31820-1-vgupta@synopsys.com> <20200615201441.31820-9-vgupta@synopsys.com> From: Adhemerval Zanella Autocrypt: addr=adhemerval.zanella@linaro.org; prefer-encrypt=mutual; keydata= mQINBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqaflUBw4hB/bEME40QsrVzWZ5Nq 8kxkEczZzAOKkkvv4pRVLlLn/zDtFXhlcvQRJ3yFMGqzBjofucOrmdYkOGo0uCaoJKPT186L NWp53SACXguFJpnw4ODI64ziInzXQs/rUJqrFoVIlrPDmNv/LUv1OVPKz20ETjgfpg8MNwG6 iMizMefCl+RbtXbIEZ3TE/IaDT/jcOirjv96lBKrc/pAL0h/O71Kwbbp43fimW80GhjiaN2y WGByepnkAVP7FyNarhdDpJhoDmUk9yfwNuIuESaCQtfd3vgKKuo6grcKZ8bHy7IXX1XJj2X/ BgRVhVgMHAnDPFIkXtP+SiarkUaLjGzCz7XkUn4XAGDskBNfbizFqYUQCaL2FdbW3DeZqNIa nSzKAZK7Dm9+0VVSRZXP89w71Y7JUV56xL/PlOE+YKKFdEw+gQjQi0e+DZILAtFjJLoCrkEX w4LluMhYX/X8XP6/C3xW0yOZhvHYyn72sV4yJ1uyc/qz3OY32CRy+bwPzAMAkhdwcORA3JPb kPTlimhQqVgvca8m+MQ/JFZ6D+K7QPyvEv7bQ7M+IzFmTkOCwCJ3xqOD6GjX3aphk8Sr0dq3 4Awlf5xFDAG8dn8Uuutb7naGBd/fEv6t8dfkNyzj6yvc4jpVxwARAQABtElBZGhlbWVydmFs IFphbmVsbGEgTmV0dG8gKExpbmFybyBWUE4gS2V5KSA8YWRoZW1lcnZhbC56YW5lbGxhQGxp bmFyby5vcmc+iQI3BBM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2d4+m/qO6+ cFTAceXmIoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG Subject: Re: [PATCH v7 08/13] ARC: Linux ABI Message-ID: <22bb51af-602a-f2ea-3ae5-4cd1392bc18f@linaro.org> Date: Thu, 2 Jul 2020 17:44:32 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200615201441.31820-9-vgupta@synopsys.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 20:44:40 -0000 On 15/06/2020 17:14, Vineet Gupta via Libc-alpha wrote: > --- LGTM with soem nits regarding indentation. Reviewed-by: Adhemerval Zanella > sysdeps/arc/nptl/pthreaddef.h | 32 +++++++ > sysdeps/unix/sysv/linux/arc/bits/procfs.h | 35 +++++++ > .../sysv/linux/arc/bits/types/__sigset_t.h | 12 +++ > sysdeps/unix/sysv/linux/arc/getcontext.S | 64 +++++++++++++ > sysdeps/unix/sysv/linux/arc/makecontext.c | 73 ++++++++++++++ > sysdeps/unix/sysv/linux/arc/setcontext.S | 93 ++++++++++++++++++ > sysdeps/unix/sysv/linux/arc/sigcontextinfo.h | 28 ++++++ > sysdeps/unix/sysv/linux/arc/swapcontext.S | 94 +++++++++++++++++++ > sysdeps/unix/sysv/linux/arc/sys/cachectl.h | 35 +++++++ > sysdeps/unix/sysv/linux/arc/sys/ucontext.h | 57 +++++++++++ > sysdeps/unix/sysv/linux/arc/sys/user.h | 31 ++++++ > sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 25 +++++ > sysdeps/unix/sysv/linux/arc/ucontext_i.sym | 20 ++++ > 13 files changed, 599 insertions(+) > create mode 100644 sysdeps/arc/nptl/pthreaddef.h > create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h > create mode 100644 sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h > create mode 100644 sysdeps/unix/sysv/linux/arc/getcontext.S > create mode 100644 sysdeps/unix/sysv/linux/arc/makecontext.c > create mode 100644 sysdeps/unix/sysv/linux/arc/setcontext.S > create mode 100644 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h > create mode 100644 sysdeps/unix/sysv/linux/arc/swapcontext.S > create mode 100644 sysdeps/unix/sysv/linux/arc/sys/cachectl.h > create mode 100644 sysdeps/unix/sysv/linux/arc/sys/ucontext.h > create mode 100644 sysdeps/unix/sysv/linux/arc/sys/user.h > create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext-macros.h > create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext_i.sym > > diff --git a/sysdeps/arc/nptl/pthreaddef.h b/sysdeps/arc/nptl/pthreaddef.h > new file mode 100644 > index 000000000000..5c2b752becad > --- /dev/null > +++ b/sysdeps/arc/nptl/pthreaddef.h > @@ -0,0 +1,32 @@ > +/* pthread machine parameter definitions, ARC version. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +/* Default stack size. */ > +#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024) > + > +/* Required stack pointer alignment at beginning. */ > +#define STACK_ALIGN 4 > + > +/* Minimal stack size after allocating thread descriptor and guard size. */ > +#define MINIMAL_REST_STACK 2048 > + > +/* Alignment requirement for TCB. */ > +#define TCB_ALIGNMENT 4 > + > +/* Location of current stack frame. */ > +#define CURRENT_STACK_FRAME __builtin_frame_address (0) Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/bits/procfs.h b/sysdeps/unix/sysv/linux/arc/bits/procfs.h > new file mode 100644 > index 000000000000..9fabca2c4747 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/bits/procfs.h > @@ -0,0 +1,35 @@ > +/* Types for registers for sys/procfs.h. ARC version. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#ifndef _SYS_PROCFS_H > +# error "Never include directly; use instead." > +#endif > + > +#include > + > +/* And the whole bunch of them. We could have used `struct > + user_regs' directly in the typedef, but tradition says that > + the register set is an array, which does have some peculiar > + semantics, so leave it that way. */ > +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t)) > + > +typedef unsigned long int elf_greg_t; > +typedef unsigned long int elf_gregset_t[ELF_NGREG]; > + > +/* There's no seperate floating point reg file in ARCv2. */ > +typedef struct { } elf_fpregset_t; Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h b/sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h > new file mode 100644 > index 000000000000..795638a30bd3 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h > @@ -0,0 +1,12 @@ > +/* Architecture-specific __sigset_t definition. ARC version. */ > +#ifndef ____sigset_t_defined > +#define ____sigset_t_defined > + > +/* Linux asm-generic syscall ABI expects sigset_t to hold 64 signals. */ > +#define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long int))) > +typedef struct > +{ > + unsigned long int __val[_SIGSET_NWORDS]; > +} __sigset_t; > + > +#endif. Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/getcontext.S b/sysdeps/unix/sysv/linux/arc/getcontext.S > new file mode 100644 > index 000000000000..486cc622efa5 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/getcontext.S > @@ -0,0 +1,64 @@ > +/* Save current context for ARC. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#include "ucontext-macros.h" > + > +/* int getcontext (ucontext_t *ucp) > + Save machine context in @ucp and return 0 on success, -1 on error > + - saves callee saved registers only > + - layout mandated by uncontext_t:uc_mcontext (hence different from setjmp). */ > + > +ENTRY (__getcontext) > + > + /* Callee saved registers. */ > + add r2, r0, UCONTEXT_MCONTEXT > + STR (r13, r2, 37) > + STR (r14, r2, 36) > + STR (r15, r2, 35) > + STR (r16, r2, 34) > + STR (r17, r2, 33) > + STR (r18, r2, 32) > + STR (r19, r2, 31) > + STR (r20, r2, 30) > + STR (r21, r2, 29) > + STR (r22, r2, 28) > + STR (r23, r2, 27) > + STR (r24, r2, 26) > + > + STR (blink, r2, 7) > + STR (fp, r2, 8) > + STR (gp, r2, 9) > + STR (sp, r2, 23) > + > + /* Save 0 in r0 placeholder to return 0 when this @ucp activated. */ > + mov r9, 0 > + STR (r9, r2, 22) > + > + /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8). */ > + mov r3, _NSIG8 > + add r2, r0, UCONTEXT_SIGMASK > + mov r1, 0 > + mov r0, SIG_BLOCK > + mov r8, __NR_rt_sigprocmask > + ARC_TRAP_INSN > + brhi r0, -1024, L (call_syscall_err) > + j.d [blink] > + mov r0, 0 /* Success, error handled in .Lcall_syscall_err. */ > + > +PSEUDO_END (__getcontext) > +weak_alias (__getcontext, getcontext) Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/makecontext.c b/sysdeps/unix/sysv/linux/arc/makecontext.c > new file mode 100644 > index 000000000000..5ded1ad3e274 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/makecontext.c > @@ -0,0 +1,73 @@ > +/* Create new context for ARC. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > +#include > + > +void > +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) > +{ > + extern void __startcontext (void) attribute_hidden; > + unsigned long int sp, *r; > + va_list vl; > + int i, reg_args, stack_args; > + > + sp = ((unsigned long int) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~7; > + > + ucp->uc_mcontext.__sp = sp; > + ucp->uc_mcontext.__fp = 0; > + > + /* __startcontext is sort of trampoline to invoke @func > + From setcontext pov, the resume address is __startcontext, > + set it up in BLINK place holder. */ > + > + ucp->uc_mcontext.__blink = (unsigned long int) &__startcontext; > + > + /* __startcontext passed 2 types of args > + - args to @func setup in canonical r0-r7 > + - @func and next function in r14,r15. */ > + > + ucp->uc_mcontext.__r14 = (unsigned long int) func; > + ucp->uc_mcontext.__r15 = (unsigned long int) ucp->uc_link; > + > + r = &ucp->uc_mcontext.__r0; > + > + va_start (vl, argc); > + > + reg_args = argc > 8 ? 8 : argc; > + for (i = 0; i < reg_args; i++) > + *r-- = va_arg (vl, unsigned long int); > + > + stack_args = argc - reg_args; > + > + if (__glibc_unlikely (stack_args > 0)) > + { > + sp -= stack_args * sizeof (unsigned long int); > + ucp->uc_mcontext.__sp = sp; > + r = (unsigned long int *) sp; > + > + for (i = 0; i < stack_args; i++) > + *r++ = va_arg (vl, unsigned long int); > + } > + > + va_end (vl); > +} > + > +weak_alias (__makecontext, makecontext) Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S b/sysdeps/unix/sysv/linux/arc/setcontext.S > new file mode 100644 > index 000000000000..56a362f8371f > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/setcontext.S > @@ -0,0 +1,93 @@ > +/* Set current context for ARC. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#include "ucontext-macros.h" > + > +/* int setcontext (const ucontext_t *ucp) > + - Restores the machine context in @ucp and resumes execution > + (doesn't return to caller). */ > + > +ENTRY (__setcontext) > + > + mov r9, r0 /* Stash @ucp across syscall. */ > + > + /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8). */ > + mov r3, _NSIG8 > + mov r2, 0 > + add r1, r0, UCONTEXT_SIGMASK > + mov r0, SIG_SETMASK > + mov r8, __NR_rt_sigprocmask > + ARC_TRAP_INSN > + brhi r0, -1024, L (call_syscall_err) > + > + /* Restore scratch/arg regs for makecontext case. */ > + add r9, r9, UCONTEXT_MCONTEXT > + LDR (r0, r9, 22) > + LDR (r1, r9, 21) > + LDR (r2, r9, 20) > + LDR (r3, r9, 19) > + LDR (r4, r9, 18) > + LDR (r5, r9, 17) > + LDR (r6, r9, 16) > + LDR (r7, r9, 15) > + > + /* Restore callee saved registers. */ > + LDR (r13, r9, 37) > + LDR (r14, r9, 36) > + LDR (r15, r9, 35) > + LDR (r16, r9, 34) > + LDR (r17, r9, 33) > + LDR (r18, r9, 32) > + LDR (r19, r9, 31) > + LDR (r20, r9, 30) > + LDR (r21, r9, 29) > + LDR (r22, r9, 28) > + LDR (r23, r9, 27) > + LDR (r24, r9, 26) > + > + LDR (blink, r9, 7) > + LDR (fp, r9, 8) > + LDR (gp, r9, 9) > + LDR (sp, r9, 23) > + > + j [blink] > + > +PSEUDO_END (__setcontext) > +weak_alias (__setcontext, setcontext) > + > + > +/* Helper for activating makecontext created context > + - r14 has @func, r15 has uc_link. */ > + > +ENTRY (__startcontext) > + > + .cfi_label .Ldummy > + cfi_undefined (blink) > + > + /* Call user @func, loaded in r14 by setcontext. */ > + jl [r14] > + > + /* If uc_link (r15) call setcontext with that. */ > + mov r0, r15 > + breq r0, 0, 1f > + > + bl __setcontext > +1: > + /* Exit with status 0. */ > + b HIDDEN_JUMPTARGET(exit) > +END (__startcontext) Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/sigcontextinfo.h b/sysdeps/unix/sysv/linux/arc/sigcontextinfo.h > new file mode 100644 > index 000000000000..c674da7b8f1f > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/sigcontextinfo.h > @@ -0,0 +1,28 @@ > +/* ARC definitions for signal handling calling conventions. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef _SIGCONTEXTINFO_H > +#define _SIGCONTEXTINFO_H > + > +static inline uintptr_t > +sigcontext_get_pc (const ucontext_t *ctx) > +{ > + return ctx->uc_mcontext.__ret; > +} > + > +#endif Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/swapcontext.S b/sysdeps/unix/sysv/linux/arc/swapcontext.S > new file mode 100644 > index 000000000000..3da072da3de3 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/swapcontext.S > @@ -0,0 +1,94 @@ > +/* Save and set current context for ARC. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#include "ucontext-macros.h" > + > +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp). */ > + > +ENTRY (__swapcontext) > + > + /* Save context into @oucp pointed to by r0. */ > + > + add r2, r0, UCONTEXT_MCONTEXT > + STR (r13, r2, 37) > + STR (r14, r2, 36) > + STR (r15, r2, 35) > + STR (r16, r2, 34) > + STR (r17, r2, 33) > + STR (r18, r2, 32) > + STR (r19, r2, 31) > + STR (r20, r2, 30) > + STR (r21, r2, 29) > + STR (r22, r2, 28) > + STR (r23, r2, 27) > + STR (r24, r2, 26) > + > + STR (blink, r2, 7) > + STR (fp, r2, 8) > + STR (gp, r2, 9) > + STR (sp, r2, 23) > + > + /* Save 0 in r0 placeholder to return 0 when @oucp activated. */ > + mov r9, 0 > + STR (r9, r2, 22) > + > + /* Load context from @ucp. */ > + > + mov r9, r1 /* Safekeep @ucp across syscall. */ > + > + /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */ > + mov r3, _NSIG8 > + add r2, r0, UCONTEXT_SIGMASK > + add r1, r1, UCONTEXT_SIGMASK > + mov r0, SIG_SETMASK > + mov r8, __NR_rt_sigprocmask > + ARC_TRAP_INSN > + brhi r0, -1024, L (call_syscall_err) > + > + add r9, r9, UCONTEXT_MCONTEXT > + LDR (r0, r9, 22) > + LDR (r1, r9, 21) > + LDR (r2, r9, 20) > + LDR (r3, r9, 19) > + LDR (r4, r9, 18) > + LDR (r5, r9, 17) > + LDR (r6, r9, 16) > + LDR (r7, r9, 15) > + > + LDR (r13, r9, 37) > + LDR (r14, r9, 36) > + LDR (r15, r9, 35) > + LDR (r16, r9, 34) > + LDR (r17, r9, 33) > + LDR (r18, r9, 32) > + LDR (r19, r9, 31) > + LDR (r20, r9, 30) > + LDR (r21, r9, 29) > + LDR (r22, r9, 28) > + LDR (r23, r9, 27) > + LDR (r24, r9, 26) > + > + LDR (blink, r9, 7) > + LDR (fp, r9, 8) > + LDR (gp, r9, 9) > + LDR (sp, r9, 23) > + > + j [blink] > + > +PSEUDO_END (__swapcontext) > +weak_alias (__swapcontext, swapcontext) Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/sys/cachectl.h b/sysdeps/unix/sysv/linux/arc/sys/cachectl.h > new file mode 100644 > index 000000000000..b98c81aa2b3d > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/sys/cachectl.h > @@ -0,0 +1,35 @@ > +/* cacheflush - flush contents of instruction and/or data cache. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#ifndef _SYS_CACHECTL_H > +#define _SYS_CACHECTL_H 1 > + > +#include > + > +/* Get the kernel definition for the op bits. */ > +#include > + > +__BEGIN_DECLS > + > +#ifdef __USE_MISC > +extern int cacheflush (void *__addr, const int __nbytes, const int __op) __THROW; > +#endif > + > +__END_DECLS > + > +#endif Ok (althoug the const int is not really required here). > diff --git a/sysdeps/unix/sysv/linux/arc/sys/ucontext.h b/sysdeps/unix/sysv/linux/arc/sys/ucontext.h > new file mode 100644 > index 000000000000..d7a9374d0201 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/sys/ucontext.h > @@ -0,0 +1,57 @@ > +/* struct ucontext definition, ARC version. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +/* System V/ARC ABI compliant context switching support. */ > + > +#ifndef _SYS_UCONTEXT_H > +#define _SYS_UCONTEXT_H 1 > + > +#include > + > +#include > +#include > + > +typedef struct > + { > + unsigned long int __pad; > + unsigned long int __bta; > + unsigned long int __lp_start, __lp_end, __lp_count; > + unsigned long int __status32, __ret, __blink; > + unsigned long int __fp, __gp; > + unsigned long int __r12, __r11, __r10, __r9, __r8, __r7; > + unsigned long int __r6, __r5, __r4, __r3, __r2, __r1, __r0; > + unsigned long int __sp; > + unsigned long int __r26; > + unsigned long int __r25, __r24, __r23, __r22, __r21, __r20; > + unsigned long int __r19, __r18, __r17, __r16, __r15, __r14, __r13; > + unsigned long int __efa; > + unsigned long int __stop_pc; > + unsigned long int __r30, __r58, __r59; > + } mcontext_t; > + > +/* Userlevel context. */ > +typedef struct ucontext_t > + { > + unsigned long int __uc_flags; > + struct ucontext_t *uc_link; > + stack_t uc_stack; > + mcontext_t uc_mcontext; > + sigset_t uc_sigmask; > + } ucontext_t; > + > +#endif The indentation is not really following the GNU guidelines here. > diff --git a/sysdeps/unix/sysv/linux/arc/sys/user.h b/sysdeps/unix/sysv/linux/arc/sys/user.h > new file mode 100644 > index 000000000000..3f867d78f9d4 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/sys/user.h > @@ -0,0 +1,31 @@ > +/* ptrace register data format definitions. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef _SYS_USER_H > +#define _SYS_USER_H 1 > + > +/* Struct user_regs_struct is exported by kernel header > + However apps like strace also expect a struct user, so it's better to > + have a dummy implementation. */ > +#include > + > +struct user { > + int dummy; > +}; > + > +#endif Same as before. > diff --git a/sysdeps/unix/sysv/linux/arc/ucontext-macros.h b/sysdeps/unix/sysv/linux/arc/ucontext-macros.h > new file mode 100644 > index 000000000000..891a5e71f2da > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/ucontext-macros.h > @@ -0,0 +1,25 @@ > +/* Macros for ucontext routines, ARC version. > + Copyright (C) 2020 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#ifndef _LINUX_ARC_UCONTEXT_MACROS_H > +#define _LINUX_ARC_UCONTEXT_MACROS_H > + > +#include > +#include "ucontext_i.h" > + > +#endif Ok. > diff --git a/sysdeps/unix/sysv/linux/arc/ucontext_i.sym b/sysdeps/unix/sysv/linux/arc/ucontext_i.sym > new file mode 100644 > index 000000000000..d84e92f9f543 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/arc/ucontext_i.sym > @@ -0,0 +1,20 @@ > +#include > +#include > +#include > +#include > + > +SIG_BLOCK > +SIG_SETMASK > + > +-- sizeof(sigset_t) expected by kernel: see comment in ARC sigaction.c for details > +_NSIG8 (_NSIG / 8) > + > +-- Offsets of the fields in the ucontext_t structure. > +#define ucontext(member) offsetof (ucontext_t, member) > + > +UCONTEXT_FLAGS ucontext (__uc_flags) > +UCONTEXT_LINK ucontext (uc_link) > +UCONTEXT_STACK ucontext (uc_stack) > +UCONTEXT_MCONTEXT ucontext (uc_mcontext) > +UCONTEXT_SIGMASK ucontext (uc_sigmask) > +UCONTEXT_SIZE sizeof (ucontext_t) > Ok.