From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 324D23858D39 for ; Wed, 10 Apr 2024 02:19:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 324D23858D39 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 324D23858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712715557; cv=none; b=TW/kmA73mOKb4/g3w4MiZnVim+igzahBMIQsp389/Z0rEE8S4P0kEXjYbJM88nC6A9HuZeucShiJg7YzhueOLAkb4dVrqo5LLjOtfhUxtPgMtjFaII3yr3ZiZgTFQc1RdPM03fjxrLv7+DuSv3tKdvgEoC08nnFy8MBqs8IN9AY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712715557; c=relaxed/simple; bh=YGJ0W6+Hc4mAhrUUgWxN+1L3ceQ5wYlXPl00TnFNA14=; h=DKIM-Signature:Date:Message-ID:From:To:Subject; b=vrTQ1gOFJviFvqQrTUxXc82RxUbpT3UnpdSntqIASkBdW38egjxR0ymMlF7T9YeT+Anq+Wrh5/NgGIukJg5Tf48BuTH/5TcU01U4RzePcGtn4zSyc2nDUxn8Zsu8F6X+Ngfi5X9tfwF2d3DRemHBPrUvbtyETfM0vem/LETZFow= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5e42b4bbfa4so3931744a12.1 for ; Tue, 09 Apr 2024 19:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712715555; x=1713320355; darn=gcc.gnu.org; h=in-reply-to:subject:to:from:message-id:date:from:to:cc:subject:date :message-id:reply-to; bh=z0E+yo2Y4yQaVP7kK+DFWMPD40ge8+TrTkkOmOZCbqo=; b=FKibWpJLSlE5WEk8bGeOkOb1KZULYuXO2d1ZSuZEXvBbRy7fabacSFObz6lAbwcpKN n7drH2+sMG2EebzmBmDTO36BYu5Oa87FhJLPDc290O7fLo9fAr7yr5l1G0Pe8wbwr09d W4RpPpDCvGU8wKGJ1cBQCnsQ2UahrxwA+BQuUmze3vLRHlFR3JgOwQPi0DRurptnuvCB gSwpxdqKpbjb9rFOOVMYqcuDt6Cz5yIjKrpiMf3ee+sV6qxa29eiqxY5M6Y16ASYgrYy g0RGwBFGbBoC4lLE0koNqb88lbYnj8x45awB6aFIzzWELh4mwHLGbjLZkbk7DdCu/cUm Wmmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712715555; x=1713320355; h=in-reply-to:subject:to:from:message-id:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=z0E+yo2Y4yQaVP7kK+DFWMPD40ge8+TrTkkOmOZCbqo=; b=dnxz/HC1shPaNf86x8jSZYqpV6TTcGwiOLaivTnJ/SBviRmgx0STH5T3mS7f9+uW05 mzK6H98VLoUDnLZOqUfIrd0rH0TGiFyh7O9E4U6vRRhFCO27EWqxuqmIh8SyxM9NQ6qZ KRzNREjM5yOX4n1bZi7AzfPPWWrMKlbCZnQaFQGJZNpHdsF/SARSC71jWsWm5q2dSkP0 g1nHmqi95e2I+g7+EyFxFxh1iFExyRUlTIzyx5QuP+aUSFisWOXLURhBJ08DnBkrdlYQ ZePIXIyqiIq2c+3mwVHt9m70qHNSqZ/98RXwwioyYfmpmRhW3ivUGIW68BUZYFx50Hoc lZAA== X-Gm-Message-State: AOJu0Yz89McmrBF9fMG+9TYGR1dy5wSibCmZQS7QX0OfRki8+7Vcpkne JdsDiaJq7rV00vKgIDSPiTK0EnNv+fziM/RTRKoMuJnraTFe7TCXoJGw3LOX X-Google-Smtp-Source: AGHT+IFcQs5emy0O21RH8Gy32jt2N3u3pWEG8ryJrLTkO9tpFP/0lvGVzAwrZnewzdrLoY/22BC3rg== X-Received: by 2002:a17:902:a384:b0:1e4:3386:349f with SMTP id x4-20020a170902a38400b001e43386349fmr1533903pla.51.1712715554771; Tue, 09 Apr 2024 19:19:14 -0700 (PDT) Received: from localhost ([138.117.155.58]) by smtp.gmail.com with ESMTPSA id i5-20020a170902c94500b001e2a7fb6e01sm1123406pla.44.2024.04.09.19.19.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 19:19:14 -0700 (PDT) Date: Tue, 09 Apr 2024 23:19:16 -0300 Message-ID: <6a50378aee7b82c8d0769a631b398d09@gmail.com> From: Matheus Afonso Martins Moreira To: gcc@gcc.gnu.org Subject: [RFC] Linux system call builtins In-Reply-To: <941dc5f2-b524-4cd0-a518-ae2ffc9d2488@free.fr> X-Spam-Status: No, score=-1.3 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: > I see systems making it more difficult for code to make syscalls, > not easier. That's true. I think it's because other systems can afford to keep that ABI unstable. Since Linux is an independently developed kernel, it _must_ be possible to target the kernel directly with no user space component in-between. Someone might write a freestanding program with nothing but system calls and boot Linux directly into it. This feature also makes it ideal for other programming languages. On every other operating system, you need to link to some C library. On Linux, that library is not actually necessary due to stable ABIs. Rust programmers could conceivably recreate the entire Linux userspace in Rust given enough time and effort. I created a programming language based entirely around that concept, a lisp variant which uses nothing but system calls and provides a system-call primitive to lisp code. It's still in its infancy due to my limited free time but it's a fact that with system calls it could do anything, it could mount disks. > I also think that this could be misleading. I don't see how. The __builtin_ prefix makes it clear that it's a compiler feature rather than a libc function. > There are sometimes subtle differences between the > syscall interface and the interface exported by libc. Yes. The C libraries seem to have some kind of cancellation mechanism built right into it, for example. Using the system calls directly eliminates them. This lets other languages build their own mechanisms.