From: Joseph Myers <joseph@codesourcery.com>
To: Steve Ellcey <sellcey@caviumnetworks.com>
Cc: <libc-alpha@sourceware.org>, <ynorov@caviumnetworks.com>
Subject: Re: [PATCH] Define wordsize.h macros everywhere
Date: Wed, 26 Oct 2016 20:07:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.20.1610261955560.29499@digraph.polyomino.org.uk> (raw)
In-Reply-To: <1477506839.26691.5.camel@caviumnetworks.com>
[-- Attachment #1: Type: text/plain, Size: 2417 bytes --]
On Wed, 26 Oct 2016, Steve Ellcey wrote:
> diff --git a/bits/wordsize.h b/bits/wordsize.h
> index 9ef0e85..2ebecd6 100644
> --- a/bits/wordsize.h
> +++ b/bits/wordsize.h
> @@ -1 +1,28 @@
> Â #error "This file must be written based on the data type sizes of the target"
> +
> +/* The following entries are a template for what defines should be in the
> +   wordsize.h header file for a target.  */
> +
> +/* Bits per word (size of CPU register).  */
> +#define __WORDSIZE
That's not an accurate description. It's definitely the size of long int
and pointers, even if registers are larger.
> +/* Set to the size of the f_fsid field in the statvfs and statvfs64 structs.
> +Â Â Â In most cases this is the same as __WORDSIZE but some 32 bit hosts may set
> +   it to 64.  */
> +#define __SYSCALL_WORDSIZE
If it's so specific to those syscalls, it doesn't belong in
bits/wordsize.h but in some header specific to those syscalls. Even the
*concept* of syscalls doesn't belong in bits/wordsize.h (remember there
are non-syscall ports such as Hurd).
> +/* Set to 1 if ssize_t is type 'unsigned long' instead of type 'unsigned int'
> +Â Â Â so that SIZE_MAX is defined as an unsigned long constant instead of an
> +   unsigned int constant.  Set to 0 if ssize_t is 'unsigned int'.  */
> +#define __WORDSIZE32_SIZE_ULONG
Is this about ssize_t as the comment says (twice), or size_t?
> +/* Set to 1 if ptrdiff_t is type 'long' instead of type 'int' so that
> +Â Â Â PTRDIFF_MIN and PTRDIFF_MAX are defined as long constants instead of
> +   int constants.  Set to 0 if ptrdiff_t is type 'int'.  */
> +#define __WORDSIZE32_PTRDIFF_LONG
For both these macros I think consensus is as Andreas said in
<https://sourceware.org/ml/libc-alpha/2016-07/msg00251.html> and
<https://sourceware.org/ml/libc-alpha/2016-07/msg00267.html>.
That is, they should only be defined if __WORDSIZE == 32. They should be
tested with #if not #ifdef, but all such tests should only be evaluated if
__WORDSIZE == 32, so that we get -Wundef errors if any such test gets
evaluated with __WORDSIZE == 64.
So the comments specifying the semantics of those macros should say that
they are only defined or used if __WORDSIZE == 32, and the headers should
only define them under that condition.
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2016-10-26 20:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 18:34 Steve Ellcey
2016-10-26 19:39 ` Steve Ellcey
2016-10-26 20:07 ` Joseph Myers [this message]
2016-10-27 18:45 ` Steve Ellcey
2016-10-27 20:16 ` Adhemerval Zanella
2016-10-28 16:07 ` Steve Ellcey
2016-11-03 20:41 ` Steve Ellcey
2016-11-04 8:16 ` Andreas Schwab
2016-11-10 14:28 ` Joseph Myers
2016-11-10 15:43 ` Steve Ellcey
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=alpine.DEB.2.20.1610261955560.29499@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=sellcey@caviumnetworks.com \
--cc=ynorov@caviumnetworks.com \
/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).