Re: RELEASE STOPPER? nonportable int64 constant s in pg_crc.c
От | ncm@zembu.com (Nathan Myers) |
---|---|
Тема | Re: RELEASE STOPPER? nonportable int64 constant s in pg_crc.c |
Дата | |
Msg-id | 20010324164632.A1530@store.zembu.com обсуждение исходный текст |
Ответ на | Re: AW: AW: Re: RELEASE STOPPER? nonportable int64 constant s in pg_crc.c (Ian Lance Taylor <ian@airs.com>) |
Список | pgsql-hackers |
On Sat, Mar 24, 2001 at 02:05:05PM -0800, Ian Lance Taylor wrote: > Tom Lane <tgl@sss.pgh.pa.us> writes: > > Ian Lance Taylor <ian@airs.com> writes: > > > A safe way to construct a long long constant is to do it using an > > > expression: > > > ((((uint64) 0xdeadbeef) << 32) | (uint64) 0xfeedface) > > > It's awkward, obviously, but it works with any compiler. > > > > An interesting example. That will work as intended if and only if the > > compiler regards 0xfeedface as unsigned ... > > True, for additional safety, do this: > ((((uint64) (unsigned long) 0xdeadbeef) << 32) | > (uint64) (unsigned long) 0xfeedface) For the paranoid, ((((uint64) 0xdead) << 48) | (((uint64) 0xbeef) << 32) | \ (((uint64) 0xfeed) << 16) | ((uint64) 0xface)) Or, better #define FRAG64(bits,shift) (((uint64)(bits)) << (shift)) #define LITERAL64(a,b,c,d) \ FRAG64(a,48) | FRAG64(b,32) |FRAG64(c,16) | FRAG64(d,0) LITERAL64(0xdead,0xbeef,0xfeed,0xface) That might be overkill for just a single literal... Nathan Myers ncm
В списке pgsql-hackers по дате отправления: