From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: brobecker@adacore.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] convert a host address to a string
Date: Wed, 07 Jan 2009 16:17:00 -0000 [thread overview]
Message-ID: <200901071616.n07GGXtu029119@brahms.sibelius.xs4all.nl> (raw)
In-Reply-To: <20090107121908.GH1751@adacore.com> (message from Joel Brobecker on Wed, 7 Jan 2009 16:19:08 +0400)
> Date: Wed, 7 Jan 2009 16:19:08 +0400
> From: Joel Brobecker <brobecker@adacore.com>
>
> The host_address_to_string function converts the host address to
> a string using sprintf after having converted the address to an
> unsigned long.
>
> Unfortunately for us, on x86_64-windows, unsigned long is not big
> enough to hold an address. My initial approach was to detect this case
> by using a configure check which defines HOST_IS_LLP64 if sizeof (void*)
> is 8 while sizeof (long) is 4.
>
> Mark's reaction was that we should be able to use something more elegant.
> One of the things we could do, perhaps, is use %p, which is mentioned by
> the comment inside the function. I checked the C90 draft, and %p is
> definitely mentioned, so I suspect it's fine to use it assuming we
> require C90. The problem is, are we going to break the build on some
> targets if we do?
Probably not, but there's a problem with %p. While it is specified by
C90 and almost certainly implemented in the C library of all systems
we care about, it is implemented how exactly the pointer will be
printed. On OpenBSD and Linux it is something like 0xNNNNNNNN, but
Solaris generates NNNNNNNN (without the initial 0x). That's
undesirable I think.
An option would be to use the strategy used by phex_nz() to print host
addresses. Or we could use PRINTF_HAS_LONG_LONG, and always use %llx
if it's available.
I'd really like to avoid introducing another macro dealing with
type-size issues if possible. I especially dislike HOST_IS_LLP64
since I fear its existence encourages people to write unportable code.
next prev parent reply other threads:[~2009-01-07 16:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 12:19 Joel Brobecker
2009-01-07 16:17 ` Mark Kettenis [this message]
2009-01-08 10:19 ` Joel Brobecker
2009-01-08 10:25 ` Kai Tietz
2009-01-08 10:48 ` Joel Brobecker
2009-01-08 11:02 ` Kai Tietz
2009-01-08 11:25 ` Joel Brobecker
2009-01-08 11:31 ` Kai Tietz
2009-01-08 12:49 ` Mark Kettenis
2009-01-08 12:54 ` Joel Brobecker
2009-01-08 13:04 ` Kai Tietz
2009-01-08 13:12 ` Mark Kettenis
2009-01-08 13:26 ` Mark Kettenis
2009-01-08 13:35 ` Kai Tietz
2009-01-08 13:42 ` Joel Brobecker
2009-01-08 14:04 ` Kai Tietz
2009-01-08 16:18 ` Mark Kettenis
2009-01-08 16:23 ` Kai Tietz
2009-01-09 9:57 ` Joel Brobecker
2009-01-09 10:05 ` Kai Tietz
2009-01-09 13:12 ` Joel Brobecker
2009-01-09 14:28 ` Kai Tietz
2009-01-10 7:12 ` Joel Brobecker
2009-01-10 13:31 ` Kai Tietz
2009-01-10 13:34 ` Kai Tietz
2009-01-10 13:58 ` Mark Kettenis
2009-01-10 14:04 ` Mark Kettenis
2009-01-10 14:15 ` Kai Tietz
2009-01-10 14:22 ` Mark Kettenis
2009-01-10 14:25 ` Kai Tietz
2009-01-11 13:31 ` Joel Brobecker
2009-01-11 13:53 ` Mark Kettenis
2009-01-13 12:09 ` Joel Brobecker
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=200901071616.n07GGXtu029119@brahms.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=brobecker@adacore.com \
--cc=gdb-patches@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