public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "Jonathan Wakely" <jwakely.gcc@gmail.com>,
	"Martin Liška" <mliska@suse.cz>,
	gcc@gcc.gnu.org, "GNU C Library" <libc-alpha@sourceware.org>
Subject: Re: Missing optimization: mempcpy(3) vs memcpy(3)
Date: Mon, 12 Dec 2022 18:15:18 +0100	[thread overview]
Message-ID: <00d9ee65-9d75-bc13-93a4-e16e80b31962@gmail.com> (raw)
In-Reply-To: <Y5dSV6oL7Uipp1QG@tucnak>


[-- Attachment #1.1: Type: text/plain, Size: 2147 bytes --]

Hi Jakub,

On 12/12/22 17:09, Jakub Jelinek wrote:
> On Mon, Dec 12, 2022 at 04:56:27PM +0100, Alejandro Colomar wrote:
>> "Names beginning with ‘str’, ‘mem’, or ‘wcs’ followed by a lowercase letter
>> are reserved for additional string and array functions. See String and Array
>> Utilities."
> 
> It is not that simple.
> mem*, str* and wcs* are just potentially reserved identifiers, they are only
> reserved if the implementation provided them.

To clarify:
While ISO C up to C17 had them fully reserved, ISO C23 will make them 
potentially reserved identifiers.  POSIX further fully reserves them again 
(maybe next POSIX aligns with C23 on that; I don't know).

>  And what we discuss here
> is how to reliably find out if it was an implementation that provided them,
> because in case of gcc the implementation is GCC and the C library and
> perhaps some other libraries too.
> gcc can be used with lots of different C libraries, and many don't implement
> mempcpy.

Well, if GCC can't know what the implementation provides, then we're in big 
trouble.  Me, being just a user-space programmer, only know of _GNU_SOURCE for 
determining if the function is available at compile-time.  :)

Any of the POSIX or ISO C feature_test_macro(7)s prior to C23 should also be 
enough to tell the compiler that mem* identifiers are reserved, and therefore 
possibly provided by libc.


mempcpy(3)                 Library Functions Manual                 mempcpy(3)

NAME
        mempcpy, wmempcpy  - copy memory area

LIBRARY
        Standard C library (libc, -lc)

SYNOPSIS
        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <string.h>

        void *mempcpy(void dest[restrict .n], const void src[restrict .n],
                      size_t n);

        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <wchar.h>

        wchar_t *wmempcpy(wchar_t dest[restrict .n],
                      const wchar_t src[restrict .n],
                      size_t n);



Cheers,

Alex


-- 
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-12-12 17:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09 17:11 Alejandro Colomar
2022-12-12 13:37 ` Martin Liška
2022-12-12 13:44   ` Alejandro Colomar
2022-12-12 13:56     ` Jakub Jelinek
2022-12-12 14:05       ` Alejandro Colomar
2022-12-12 14:48         ` Jonathan Wakely
2022-12-12 14:53           ` Jakub Jelinek
2022-12-12 15:56             ` Alejandro Colomar
2022-12-12 16:09               ` Jakub Jelinek
2022-12-12 17:15                 ` Alejandro Colomar [this message]
2022-12-12 17:42                 ` Jonathan Wakely
2022-12-12 14:34 Wilco Dijkstra
2022-12-12 14:57 ` Cristian Rodríguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00d9ee65-9d75-bc13-93a4-e16e80b31962@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).