From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id A31C63858D39 for ; Tue, 19 Oct 2021 12:13:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A31C63858D39 Received: by mail-wm1-x330.google.com with SMTP id o24so4272560wms.0 for ; Tue, 19 Oct 2021 05:13:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=CCWUwvKYUX1Yom8UauUlHwHVhv2a1de3dTlfkBXHx2M=; b=tTlmLfT7oHa18J9RWhKSYLriG2wq55jqQg8X9hwV33Z0uTWAhTYHvPG2vLR3hJQcAi r+UvwNSOTlvwbfWaBritOEdzl+IudE0GNB3rMvbHuEAAbI+XORgr5pJk9KiJihJ1ZLaO EwloL4kOoV4eXeSQUAkFAiRZTfgYCZk4KUGO5wwAJdlCQQhSqPY3TuauVIKJWuY7nyUs AdHrGOUEmuKEkcnHM8fS9Cc2uvHKmX6De61zaF2bc1c34sULlm50LP0tQyyuMytpT6YS Ir/0qb1Q9iPIxl+iKCiYWuzV4+WV2aTNIjenNAr1O7RlFIGSus1Rt1/b9wNimv1NXdQz L14w== X-Gm-Message-State: AOAM531Rq7F4N6dxj9kgI5QPiLWgpSxVORAUrlz0x+6LpjN7w7wiy34R V+bvifk+qfoHMmqAC8sPP8o= X-Google-Smtp-Source: ABdhPJxTu4WQIWt8S2B9cXbIAl36bMJyiyqRDdY62tUR3yvflrm0hm12TGHCCItLzsxSXB8Yya4W8w== X-Received: by 2002:a1c:7911:: with SMTP id l17mr5746382wme.138.1634645593786; Tue, 19 Oct 2021 05:13:13 -0700 (PDT) Received: from nt-f071.wlcli.tugraz.at (nt-f071.wlcli.tugraz.at. [129.27.245.71]) by smtp.gmail.com with ESMTPSA id y191sm2504155wmc.36.2021.10.19.05.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 05:13:13 -0700 (PDT) Message-ID: Subject: Re: wide function pointer type From: Martin Uecker To: Florian Weimer Cc: Martin Uecker via Libffi-discuss , Anthony Green Date: Tue, 19 Oct 2021 14:13:12 +0200 In-Reply-To: <87o87lfhi3.fsf@oldenburg.str.redhat.com> References: <9362563f8803f575d00c03835d2897b3836a7645.camel@gmail.com> <857da973fe5bbb94a363114262b57d42b35cc1f6.camel@gmail.com> <87czo2hjiq.fsf@oldenburg.str.redhat.com> <8d2ddbb76479ce3ad7f99acb3f0b79a6a8d1440b.camel@gmail.com> <87bl3lgyha.fsf@oldenburg.str.redhat.com> <6a0299e6b3c47cddd88b24d569fca8aeb4717aeb.camel@gmail.com> <87o87lfhi3.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 12:13:16 -0000 Am Dienstag, den 19.10.2021, 12:15 +0200 schrieb Florian Weimer: > * Martin Uecker: > > > > For GCC's nested function extension, there are no ABI concerns > > > because the nested function definition and the thunk generation are > > > always built from the same translation unit. So GCC can just pick a > > > custom calling convention, similar to what it does for other local, > > > non-escaping functions. > > > > Yes, but there are many other languages that make use of the > > static chain. So it would be good to have a standardized ABI > > for this. > > What's the exact use case for this? These other languages do not > usually have stable ABIs that inter-operate across different > implementations. One (of several) use cases is for language interoperability. A common problem is to pass a function of a high-level language as a callback to an C API. This now often requires special boiler plate code for each case and there is no automatic way to do this. The fundamental problem is that the C type can not express that a data pointer belongs to a function pointer. void foo( void (cb1)(void* data, int a), void* data1, void* other_data); Here a human (and maybe also a machine) could guess that data1 belongs to cb1 but not other_data. But it is not clear and in more complicated cases even less so. void foo(void (_Wide cb1)(int a), void* other_data); With the new type that would be unambiguous (and wrappers could then often be created automatically). At least for the C API one would also expect ABI stability. Martin