From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com
[IPv6:2a00:1450:4864:20::341])
by sourceware.org (Postfix) with ESMTPS id 37386398BC04
for ; Thu, 1 Oct 2020 16:55:08 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 37386398BC04
Received: by mail-wm1-x341.google.com with SMTP id 13so150820wmf.0
for ; Thu, 01 Oct 2020 09:55:08 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:subject:to:cc:references:from:message-id:date
:user-agent:mime-version:in-reply-to:content-language
:content-transfer-encoding;
bh=6thW6uIzKo0AKUx3z1dt90fnAdUCuGiPlcRQ/kj9HnY=;
b=D8Kz6gYrWRZbVijc3OzoBT2JKbnNBPGJdzYFi5/ekvKuAAVM9ps0zY/ZaWLAlaNOyV
9QzjQvQD0UzSVYaZpLQFo7z7u7P8N/oUuVsfau+IRycGBoi6fJ6mhk6J6SW7dj6b+YW/
OWaoxgdM/vEgIMYaJNmIZ1yvSXDfagUOP2CQJORiB6VFObdW/AT4p1rx4gFWzV6Dom3O
icIrPkA6LakzKRPs2iG1abeKjYyTUjumUotO3OeK6sX5FMRFNgb13AXtVhkbrnvlIqb3
A90vLygbGtwjQdjInfiF1cdAwW7+07VWebYgsG7LHW0zf+y2Q2jUF0mXW/k3q+mmQ+re
mFaQ==
X-Gm-Message-State: AOAM530cKENPtcwQePKMApHJ5in0ZqCKr9fWJJFhQ0URNRzkksZrv8cC
E+1mL+J4vJAGQQI0NKYZ57ttyx5sbZDD0w==
X-Google-Smtp-Source: ABdhPJynBwL8B/dPnbv/POOgme/EYgQ8xb2q9YNIKii1u4FdsmU899H5MSVGe6Nc3+BzGOiOrDfrNg==
X-Received: by 2002:a05:600c:215:: with SMTP id
21mr921762wmi.105.1601571306836;
Thu, 01 Oct 2020 09:55:06 -0700 (PDT)
Received: from [192.168.1.143] ([170.253.60.68])
by smtp.gmail.com with ESMTPSA id n2sm858530wma.29.2020.10.01.09.55.05
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Thu, 01 Oct 2020 09:55:06 -0700 (PDT)
Subject: Re: [PATCH v2 1/2] system_data_types.7: Add 'void *'
To: "Michael Kerrisk (man-pages)"
Cc: linux-man@vger.kernel.org, gcc@gcc.gnu.org, libc-alpha@sourceware.org
References: <41affebd-3354-9420-0048-bffd14535e95@gmail.com>
<20201001154946.104626-2-colomar.6.4.3@gmail.com>
From: Alejandro Colomar
Message-ID: <41ab7ed9-3ce0-f8ad-38f4-c4bbeca138f8@gmail.com>
Date: Thu, 1 Oct 2020 18:55:04 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
MIME-Version: 1.0
In-Reply-To:
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT,
FREEMAIL_FROM, 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: Thu, 01 Oct 2020 16:55:09 -0000
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.
]]