From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 4385E3858D20 for ; Mon, 8 Apr 2024 09:58:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4385E3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4385E3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712570317; cv=none; b=VNVfU+wUpNH658MOMtPMpp3IbzlvlR8L23kpOd7Fa+IDyjNFJnHJVxEknIKZCi0j/BQTTSPLz7h5Y8Fe+BEdEiNYhyzHMi981rqcCitYldLERetJImgUQz6RnGelaVXafY8uFNA4bIefzPiY9P4g8fQuHuk9WZFSMfmbPJyCGeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712570317; c=relaxed/simple; bh=wpjEhOtrvIWbwsQNgTDz9XfdhRH5yk+yhlDYofQ7WwY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=o7PWA4TkV9UZ+MAb7MQpVhA4mGOmDZzCl+fSkfeTigaQPhYR4ZRxewyGjZc+s2zGukzH5RG0awDGitmgcT3GxObD+odzYjiUF3Prp3AP+NpxEjO/4JKnlufVxOFlSWcxO6ffbj7bm/BdVrzEUEtAvlVaLE6IahpMnq3E8Nh6eVg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a519e04b142so377499866b.3 for ; Mon, 08 Apr 2024 02:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712570312; x=1713175112; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rg7yOrOA0iPFdZ4aC3BJxIO6lEBLzTZaAQJ9qddzGT8=; b=Ri+iQ/q8hGxR/GdsoM0A70R9WXs3+kDI7mp1vifz3mVayiDe7opkjZA4s5T9CjwC0f uHmq1NLbiSzIUOX/y5Oma3/6icaz3ayki+54UnvyjCQ88JGdAJaLnuu2FHxqknrMS4bI Ig7dPLmE/TyE60D8X9depi6Lq1+M3KJnO11YSsXFaZ3mK7O5IijCltDwgBpqwZtAp1sF iCt3hsUVMhYQZkYxmqaKPt80jXoL+DbRckteiVa0JtZRb629yY36vBM/FqqPi1vu4VTg YUZQdJidnAKU0bxyKbwwz1DpOxLLGXUs1sen8j3tALAn6VdmvD0RISUi7X9ZaLSZqOL0 78SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712570312; x=1713175112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rg7yOrOA0iPFdZ4aC3BJxIO6lEBLzTZaAQJ9qddzGT8=; b=bA4Ahi306aqHOA9sIVhBPnjR+k5GhR2QIqHHmHR3LBzB0eHWq6Ej6GZno0JzsLsfpA 3+f7/gYJashhniEzh9/1YVqmwMDrouoDAkypPyTC9hXCH+Fa5GhADvppVcMGxm43BWmv Dq+2MD2w44fcBIn3zYdL4VtQagiUbrKSawMsCOd/THy0xPRYkkyroL8ysJ9T3tQ0Qm+A 59tqkW6Gu4xIclPoj6JXM72PisiHUfef3vYb897GW9WmN2kdJ63MxOWHr33DyLcBqua8 stthuNcl9IVXWpEIELepejCQLNPNVAEAnzgH/q9NZETIQcK1lc0nuoJfxdOsFvFUo6WC qp4A== X-Gm-Message-State: AOJu0YzWiH9zYIDFP87GnMFEEOTocBIwMstMEee7wpBQK477f0svoRbr v8sDttG+LA6sXsNcaAynibQdp3zefMfBLnLmcpE3R3Sv337NXoyf0dxYn+mQ5GXGK+T0JMQe8PM W7EuDPfHZO5SC20IKqb/zFF+tg5oTRnj0 X-Google-Smtp-Source: AGHT+IGMk1YeBK01fTlrfbN1Im8L9ua2huGt6/Qy4xZ0RlA4d2NA90blEChQ0jkzXjRdqoWr+2GRrS7bUhsFP8KDD0k= X-Received: by 2002:a17:907:3d9e:b0:a51:abd8:7eee with SMTP id he30-20020a1709073d9e00b00a51abd87eeemr6863146ejc.46.1712570311682; Mon, 08 Apr 2024 02:58:31 -0700 (PDT) MIME-Version: 1.0 References: <2d2f1e405361d2b36dd513e3fabd1fe0@gmail.com> In-Reply-To: <2d2f1e405361d2b36dd513e3fabd1fe0@gmail.com> From: Jonathan Wakely Date: Mon, 8 Apr 2024 10:58:20 +0100 Message-ID: Subject: Re: [RFC] Linux system call builtins To: Matheus Afonso Martins Moreira Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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_linux_system_call_1(long n, long _1) > __builtin_linux_system_call_2(long n, long _1, long _2) > /* More definitions, all the way up to 6 arguments */ What's the advantage of the _1, _2 etc. forms? The compiler knows how many arguments you're passing, why can't there just be one built-in handling all cases? > > + It doesn't make sense for libraries to support it > > There are libraries out there that provide > system call functionality. The various libcs do. > However they usually don't support the full set > of Linux system calls. Using certain system calls > could invalidate global state in these libraries > which leads to them not being supported. Clone is > the quintessential example. So I think libraries > are not the proper place for this functionality. Your proposal doesn't seem to actually address the problem. If using the clone syscall causes problems for glibc by not giving glibc a chance to set up TLS etc for the new thread, how does making it easier to use the clone syscall help?