From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by sourceware.org (Postfix) with ESMTPS id 97103398D009 for ; Fri, 2 Oct 2020 11:54:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 97103398D009 Received: by mail-wm1-x343.google.com with SMTP id x23so1379579wmi.3 for ; Fri, 02 Oct 2020 04:54:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lENRZqPCREonwvx5veevDl3CTPX9Kt98I7Izc9hU0TU=; b=ADgKABSpNwXWu3jN44uak8RR5qN/GLOWpO+twWwDaVu0ADNgCD5UWdkpOT+kbTlgEM uhgzXAq3rYyQgHLk30GHqbZvpDJiSuVnRln2fiIwV9lv6GY7+qlac5MNjN/j2Qp0pyuv N8OC6/j8A0mAIVQhkI92gOK8Lgwo0lvBuN1XQTkTNhuZ485SRz6pakGNTF4/KNZSCUaI I6BKANisqhNWzb0eDXSek0T0VMGMmL/UByhZ87yan/yU5Hede8FUDKfoijYGR1yNAJPS bFRA9StBCADw7HrrHq8dyda+t5HKebbgv7ha9lFdAHKLywmTD/JRf4QIpCe/o71dyE9L dY1A== X-Gm-Message-State: AOAM532tbjDji4wmD5klRsluf3hu3odm4IXXYOr5gkcunz+0FanVLu3i qRnpg6avxc9hu7UMJXTIvuDB1qEF2W4= X-Google-Smtp-Source: ABdhPJz1oQB62XyEtdRi2ypHw5G96+vGAZWmtw4T8Br4NPirlEwsizYGjwXUDpjNAQpDE64sijyX4A== X-Received: by 2002:a1c:9a0c:: with SMTP id c12mr2541515wme.85.1601639645085; Fri, 02 Oct 2020 04:54:05 -0700 (PDT) Received: from ?IPv6:2001:a61:2479:6801:d8fe:4132:9f23:7e8f? ([2001:a61:2479:6801:d8fe:4132:9f23:7e8f]) by smtp.gmail.com with ESMTPSA id j10sm1567926wrn.2.2020.10.02.04.54.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Oct 2020 04:54:04 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, gcc@gcc.gnu.org, libc-alpha@sourceware.org Subject: Re: [PATCH v2 1/2] system_data_types.7: Add 'void *' To: Alejandro Colomar References: <41affebd-3354-9420-0048-bffd14535e95@gmail.com> <20201001154946.104626-2-colomar.6.4.3@gmail.com> <41ab7ed9-3ce0-f8ad-38f4-c4bbeca138f8@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: <51fd9c8d-9030-775f-8c35-f5e41bab4c0e@gmail.com> Date: Fri, 2 Oct 2020 13:54:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <41ab7ed9-3ce0-f8ad-38f4-c4bbeca138f8@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2020 11:54:08 -0000 Hi Alex, On 10/1/20 6:55 PM, Alejandro Colomar wrote: > > > On 2020-10-01 18:38, Michael Kerrisk (man-pages) wrote: >> Hi Alex, >> >>> +According to the C language standard, >>> +a pointer to any object type may be converted to a pointer to >>> +.I void >>> +and back. >>> +POSIX further requires that any pointer, >>> +including pointers to functions, >>> +may be converted to a pointer to >>> +.I void >>> +and back. >> I know you are correct about POSIX, but which part of the >> standard did you find this information in? The only >> reference that I find in POSIX is the dlsym() spec. Is it >> covered also somewhere else in the standrd? >> >> Thanks, >> >> Michael >> > > Hi Michael, > > I've bean searching, and dlsym is the only one: > > ________ > > user@debian:~/Desktop/src/Standards/susv4-2018$ grep -rn "pointer to a > function" > functions/regfree.html:530:"undefined" means that the action > by the application is an error, of similar severity to passing a bad > pointer to a function.

> functions/dlsym.html:138:

Note that conversion from a void * > pointer to a function pointer as in:

> functions/regcomp.html:530:"undefined" means that the action > by the application is an error, of similar severity to passing a bad > pointer to a function.

> functions/regexec.html:530:"undefined" means that the action > by the application is an error, of similar severity to passing a bad > pointer to a function.

> functions/V2_chap02.html:3039:

There are three types of action that > can be associated with a signal: SIG_DFL, SIG_IGN, or a pointer to a > function. Initially, > functions/regerror.html:530:"undefined" means that the action > by the application is an error, of similar severity to passing a bad > pointer to a function.

> user@debian:~/Desktop/src/Standards/susv4-2018$ grep -rn "function pointer" > basedefs/glob.h.html:165:"../functions/glob.html">glob() > prototype definition by removing the restrict qualifier from the > function pointer > xrat/V4_xsh_chap02.html:114:when the application requires it; for > example, if its address is to be stored in a function pointer variable.

> functions/dlsym.html:138:

Note that conversion from a void * > pointer to a function pointer as in:

> user@debian:~/Desktop/src/Standards/susv4-2018$ grep -rn "pointer to > function" > functions/dlsym.html:73:converted from type pointer to function to type > pointer to void; otherwise, dlsym() shall return the > address of the > user@debian:~/Desktop/src/Standards/susv4-2018$ > > From those, the only one that documents this is functions/dlsym. > The rest is noise. > > The most explicit paragraph in dlsym is the following: > > [[ > Note that conversion from a void * pointer to a function pointer as in: > > fptr = (int (*)(int))dlsym(handle, "my_function"); > > is not defined by the ISO C standard. > This standard requires this conversion to work correctly > on conforming implementations. > ]] Okay -- so, one more thing for a revised (squashed) patch. I think you better say that that POSIX requirements exists only since POS0X.1-2008 Technical Corrigendum 1 (2013). Thanks, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/