Re: [RFC] Linux system call builtins

2024-04-10 Thread Paul Koning via Gcc
> On Apr 9, 2024, at 9:48 PM, Matheus Afonso Martins Moreira via Gcc > wrote: > > ... > MIPS calling conventions work like this: > >> mips/n32,64 a0 a1 a2 a3 a4 a5 >> mips/o32a0 a1 a2 a3 ... >> mips/o32args5-8 are passed on the stack Yes, for regular function calls, but at least in

Re: [RFC] Linux system call builtins

2024-04-10 Thread Szabolcs Nagy via Gcc
The 04/09/2024 23:59, Matheus Afonso Martins Moreira via Gcc wrote: > > and using raw syscalls outside of the single runtime the > > application is using is problematic (at least on linux). > > Why do you say they are problematic on Linux though? Please elaborate. because the portable c api layer

Re: [RFC] Linux system call builtins

2024-04-09 Thread Szabolcs Nagy via Gcc
The 04/08/2024 06:19, Matheus Afonso Martins Moreira via Gcc wrote: > __builtin_linux_system_call(long n, ...) ... > Calling these builtins will make GCC place all the parameters > in the correct registers for the system call, emit the appropriate > instruction for the target architecture and r

Re: [RFC] Linux system call builtins

2024-04-08 Thread Paul Floyd via Gcc
On 08-04-24 09:19, Matheus Afonso Martins Moreira via Gcc wrote: + It's becoming common Despite being specific to the Linux kernel, support for it is showing up in other systems. FreeBSD implements limited support[4] for Linux ABIs. Windows Subsystem fo

Re: [RFC] Linux system call builtins

2024-04-08 Thread Paul Koning via Gcc
> On Apr 8, 2024, at 4:01 PM, Paul Iannetta via Gcc wrote: > > On Mon, Apr 08, 2024 at 11:26:40AM -0700, Andrew Pinski wrote: >> On Mon, Apr 8, 2024 at 11:20 AM Paul Iannetta via Gcc >> wrote: >>> ... >> Also do you sign or zero extend a 32bit argument for LP64 targets? >> Right now it is no

Re: [RFC] Linux system call builtins

2024-04-08 Thread Paul Iannetta via Gcc
On Mon, Apr 08, 2024 at 11:26:40AM -0700, Andrew Pinski wrote: > On Mon, Apr 8, 2024 at 11:20 AM Paul Iannetta via Gcc wrote: > > > > Hi, > > > > On Mon, Apr 08, 2024 at 06:19:14AM -0300, Matheus Afonso Martins Moreira > > via Gcc wrote: > > > Hello! I'm a beginner when it comes to GCC developmen

Re: [RFC] Linux system call builtins

2024-04-08 Thread Andrew Pinski via Gcc
On Mon, Apr 8, 2024 at 11:20 AM Paul Iannetta via Gcc wrote: > > Hi, > > On Mon, Apr 08, 2024 at 06:19:14AM -0300, Matheus Afonso Martins Moreira via > Gcc wrote: > > Hello! I'm a beginner when it comes to GCC development. > > I want to learn how it works and start contributing. > > Decided to st

Re: [RFC] Linux system call builtins

2024-04-08 Thread Paul Iannetta via Gcc
Hi, On Mon, Apr 08, 2024 at 06:19:14AM -0300, Matheus Afonso Martins Moreira via Gcc wrote: > Hello! I'm a beginner when it comes to GCC development. > I want to learn how it works and start contributing. > Decided to start by implementing something relatively simple > but which would still be ve

Re: Re: [RFC] Linux system call builtins

2024-04-08 Thread Jonathan Wakely via Gcc
On Mon, 8 Apr 2024, 13:00 Matheus Afonso Martins Moreira via Gcc, < gcc@gcc.gnu.org> wrote: > > Compiler support for system calls help by eliminating the need for the > system call stub functions traditionally provided by these C libraries. > There's no need to link against the C libraries just fo

Re: Re: [RFC] Linux system call builtins

2024-04-08 Thread Matheus Afonso Martins Moreira via Gcc
> There is quite a bit of variance in how the kernel is entered. I assume you mean the vDSO. It is also documented and stable. https://www.kernel.org/doc/html/latest/admin-guide/abi-stable.html#vdso > Unless otherwise noted, the set of symbols with any given version > and the ABI of those symbol

Re: [RFC] Linux system call builtins

2024-04-08 Thread Alexander Monakov
On Mon, 8 Apr 2024, Florian Weimer wrote: > * Alexander Monakov: > > >> There is quite a bit of variance in how the kernel is entered. On > >> x86-64, one once popular mechanism is longer present in widely-used > >> kernels. > > > > I assume you're implicitly referencing the vsyscall mechanism

Re: Re: [RFC] Linux system call builtins

2024-04-08 Thread Matheus Afonso Martins Moreira via Gcc
> What's the advantage of the _1, _2 etc. forms? Now that you mention it... I don't believe there are any. > The compiler knows how many arguments you're passing, > why can't there just be one built-in handling all cases? You're right about that. When I started working on this I just mirrored t

Re: [RFC] Linux system call builtins

2024-04-08 Thread Florian Weimer via Gcc
* Alexander Monakov: > On Mon, 8 Apr 2024, Florian Weimer via Gcc wrote: > >> * Matheus Afonso Martins Moreira via Gcc: >> >> > + It's stable >> > >> > This is one of the things which makes Linux unique >> > in the operating system landscape: applications >> > can target

Re: [RFC] Linux system call builtins

2024-04-08 Thread Alexander Monakov
On Mon, 8 Apr 2024, Florian Weimer via Gcc wrote: > * Matheus Afonso Martins Moreira via Gcc: > > > + It's stable > > > > This is one of the things which makes Linux unique > > in the operating system landscape: applications > > can target the kernel directly. Unlike i

Re: [RFC] Linux system call builtins

2024-04-08 Thread Florian Weimer via Gcc
* Matheus Afonso Martins Moreira via Gcc: > + It's stable > > This is one of the things which makes Linux unique > in the operating system landscape: applications > can target the kernel directly. Unlike in virtually > every other operating system out there, the L

Re: [RFC] Linux system call builtins

2024-04-08 Thread Jonathan Wakely via Gcc
Hello, On Mon, 8 Apr 2024 at 10:20, Matheus Afonso Martins Moreira via Gcc wrote: > > I'd like to add GCC builtins for generating Linux system call > code for all architectures supported by Linux. > > They would look like this: > > __builtin_linux_system_call(long n, ...) > __builtin_linu