public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: GNU C Library <libc-alpha@sourceware.org>
Subject: Is __ptr_t needed?
Date: Tue, 28 Sep 2021 11:38:33 +0100	[thread overview]
Message-ID: <CACb0b4nYL=dzHwu1+csmiXye=pGQugstzHwjOqCkNJgc-qDYYg@mail.gmail.com> (raw)

<bits/cdefs.h> says:

/* This is not a typedef so `const __ptr_t' does the right thing.  */
#define __ptr_t void *

But nothing in glibc headers ever use that macro. I see only three
uses in glibc sources, two of them are comments, and none actually use
const __ptr_t:

sysdeps/mach/hurd/i386/trampoline.c:  uc->uc_stack.ss_sp = (__ptr_t)
sc->sc_uesp;
sysdeps/powerpc/powerpc64/le/power10/memcpy.S:/* __ptr_t [r3] memcpy
(__ptr_t dst [r3], __ptr_t src [r4], size_t len [r5]);
sysdeps/powerpc/powerpc64/multiarch/memcpy-power8-cached.S:/* __ptr_t
[r3] memcpy (__ptr_t dst [r3], __ptr_t src [r4], size_t len [r5]);


Defining this as a macro means that libstdc++ can't use that name,
e.g. for something like:

namespace std { namespace__detail {
  template<typename _Tp>
    using __ptr_t = typename add_pointer<_Tp>::type;
}}

My attempts to squirrel it away in an internal namespace and using a
reserved name fail, because macros laugh at namespaces and crush them
beneath their clumsy feet.

This isn't the end of the world (I can pick another name, or use
#pragma push_macro/pop_macro) but could __ptr_t simply be removed, or
at least changed to a typedef? If any glibc sources do need to use it
for a non-modifiable pointer to void then '__ptr_t const' does the
right thing.

Defining a macro that is barely used seems unnecessary, even if it
does use a reserved name.


             reply	other threads:[~2021-09-28 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 10:38 Jonathan Wakely [this message]
2021-09-28 11:22 ` Andreas Schwab
2021-09-28 11:31   ` Jonathan Wakely

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='CACb0b4nYL=dzHwu1+csmiXye=pGQugstzHwjOqCkNJgc-qDYYg@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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).