From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58299 invoked by alias); 26 Oct 2016 20:07:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 58289 invoked by uid 89); 26 Oct 2016 20:07:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Wed, 26 Oct 2016 20:07:00 -0000 From: Joseph Myers To: Steve Ellcey CC: , Subject: Re: [PATCH] Define wordsize.h macros everywhere In-Reply-To: <1477506839.26691.5.camel@caviumnetworks.com> Message-ID: References: <1477506839.26691.5.camel@caviumnetworks.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1152306461-1662176749-1477512415=:29499" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2016-10/txt/msg00477.txt.bz2 ---1152306461-1662176749-1477512415=:29499 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Content-length: 2345 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 and . 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 ---1152306461-1662176749-1477512415=:29499--