autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: _XOPEN_SOURCE=500 breaks at least OSF1 V5.0 [Re: largefiles


From: Alexandre Oliva
Subject: Re: _XOPEN_SOURCE=500 breaks at least OSF1 V5.0 [Re: largefiles
Date: 16 Nov 2000 01:14:50 -0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

On Nov 15, 2000, Akim Demaille <address@hidden> wrote:

> int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];

I have a feeling this test must, somehow, be wrong.  If the intent is
to test whether off_t is at least 64-bits wide, I think it won't do it
on platforms that don't have a wide-enough integer type.  Besides, on
platforms whose `int' isn't 64-bits wide, it might overflow the int,
instead of using a wider type, causing the test to pass when it
shouldn't.

How about something along the lines of:

((((((((off_t)1) << 15) << 15) << 15) << 15) << 3) != 0) ? 1 : -1

or

((((((((off_t)1) << 15) << 15) << 15) << 15) << 3) != 0
 && (((((((off_t) 1) << 15) << 15) << 15) << 15) << 4) == 0) ? 1 : -1

Depending on whether we want the type to be at least 64-bits wide or
exactly 64-bits wide.  This test still isn't perfect; IIRC, the tests
invoke undefined behavior because the `1' gets to become the sign
bit.  Maybe we could get on by shifting by 62?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  address@hidden, redhat.com}
CS PhD student at IC-Unicamp        address@hidden, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me



reply via email to

[Prev in Thread] Current Thread [Next in Thread]