From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8CE8D385843A for ; Tue, 23 Jan 2024 09:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CE8D385843A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8CE8D385843A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706001335; cv=none; b=X88qI3Odrx/Hm4QqW5w0gP/nvypcN801PCkQQ7lBolQ9mOf0QmWaGgWDG/fQJz5gvlTqrde+osyuRKCMyy6jRIgC9FygtbdSygPX5qEMQ6uQYXwkCjgaANulPR327S8FCNF/KSd1PLTU5Bp9aqqWYF9DJiRDlTv92qzAmFTAN+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706001335; c=relaxed/simple; bh=mS40fvd2yWD5ndtaGpCQWGE6/zHheK+XNpabIn5jYCg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=FLR5rQbxzbP7eWPIbGqbGGALblF7MbZTqieONwHwSkXE8K6Kj9ongm9PdpEAUlPHJBIxbYALVpoSzZ010zWCm2QHwXdVemwgD3RBG1CQTvhzLSnamXXW+lufKSHBKMj5zAttbUViDGigkDThvrG6UO1+1ulTfHscMeDwKW1TH3w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706001333; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=2/na6FbRKahS1IUbIxhbyXo9oM3uG3HkQMOxjbAzOyU=; b=Wbq+ph4naxslkJ4bIGYqSZTTxY/9n8HjNl6V2Z/Cng0opKLW6N0mvI2Lxeffl/fZwoMb/6 MpEfY3E+Lg56qGenbjlBwIXDasFsbVwSW+/LJvA1Razws6nzE1wMXDaksRYgOi/QQgFpO/ o9+WnXYIOHmSyLl1R9sXx8CLW35l9os= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-KOFETEt9NeOJ4twKg8LtgA-1; Tue, 23 Jan 2024 04:15:31 -0500 X-MC-Unique: KOFETEt9NeOJ4twKg8LtgA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14C2D185A781; Tue, 23 Jan 2024 09:15:31 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7D6340C1430; Tue, 23 Jan 2024 09:15:30 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 9C38FA80890; Tue, 23 Jan 2024 10:15:29 +0100 (CET) Date: Tue, 23 Jan 2024 10:15:29 +0100 From: Corinna Vinschen To: Mike Frysinger Cc: newlib@sourceware.org Subject: Re: [PATCH] [RFC] newlib: libc: start manual appendix to hold various ABI constants Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Mike Frysinger , newlib@sourceware.org References: <20231227072512.17179-1-vapier@gentoo.org> MIME-Version: 1.0 In-Reply-To: <20231227072512.17179-1-vapier@gentoo.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Dec 27 02:25, Mike Frysinger wrote: > The newlib errno values end up being exposed way beyond newlib itself, > so it can be helpful to have a reference of the names & values of them > all. When using a GNU stack, the errno values might be shared across > all of them without any translation layers. > > Consider: > * user's code > * GNU newlib (libc) > * GNU libgloss (OS bindings) > * GNU simulator (syscall handler) > > When the user program tries to open a file that doesn't exist, it will > call through newlib -> libgloss -> sim. How is the error code handled ? > The user program relies on newlib's ENOENT constant. If newlib & libgloss > don't agree on this value, then libgloss has to maintain a mapping of the > different constants {"EAGAIN", NEWLIB_EAGAIN, LIBGLOSS_EAGAIN}. No one > does this of course -- libgloss just uses newlib's values directly. If > libgloss & the OS don't agree on this value, then libgloss again has to > maintain a mapping of {"EAGAIN", NEWLIB_EAGAIN, OS_EAGAIN}. No one does > this with the GNU simulator -- it returns newlib's values directly. The > simulator definitely has to maintain a mapping of the target's EAGAIN > values and whatever OS it is running on. Having this be documented all > the way down is important so people writing simulator ports know what > values to use. > > People implementing a minimal bootloader environment can easily be in the > same boat -- they are trying to glue one world (e.g. Das U-Boot's machine > independent API runtime) with another world (e.g. libgloss), and that will > need to maintain the mapping of values in order for the programs to run > unmodified. > > Start an appendix in the libc manual to hold these constants. These pages > are automatically generated using the preprocessor and a script from the > GNU simulator project. If people are amenable to this direction, I can > port that script over to newlib & strip it down, and also add a few more > appendix chapters for other important ABI constants (e.g. signals). > --- > newlib/Makefile.in | 281 +++++----- > newlib/libc/errno/Makefile.inc | 3 + > newlib/libc/errno/constants.tex | 349 ++++++++++++ > newlib/libc/libc.texi | 26 + > newlib/libc/machine/cris/Makefile.inc | 3 + > newlib/libc/machine/cris/constants-errno.tex | 541 +++++++++++++++++++ > newlib/libc/machine/spu/Makefile.inc | 3 + > newlib/libc/machine/spu/constants-errno.tex | 517 ++++++++++++++++++ > 8 files changed, 1584 insertions(+), 139 deletions(-) > create mode 100644 newlib/libc/errno/constants.tex > create mode 100644 newlib/libc/machine/cris/constants-errno.tex > create mode 100644 newlib/libc/machine/spu/constants-errno.tex I like the idea in general. What I'm a bit put off by are the machine-specific lists. Ideally they should only contain those values which differ from the values defined upstream, that is, the values in newlib/libc/include/sys/errno.h. But I'd understand if that's too complicated. Corinna