Prevent warnings due to long long constants

This commit is contained in:
Ulrich Drepper 2011-12-23 13:52:59 -05:00
parent bbe315ea36
commit 67371b5666
6 changed files with 124 additions and 90 deletions

View File

@ -1,3 +1,11 @@
2011-12-23 Ulrich Drepper <drepper@gmail.com>
* bits/byteswap.h: Protect long long constants with __extension__.
* sysdeps/i386/bits/byteswap.h: Likewise.
* sysdeps/ia64/bits/byteswap.h: Likewise.
* sysdeps/s390/bits/byteswap.h: Likewise.
* sysdeps/x86_64/bits/byteswap.h: Likewise.
2011-12-23 Liubov Dmitrieva <liubov.dmitrieva@gmail.com> 2011-12-23 Liubov Dmitrieva <liubov.dmitrieva@gmail.com>
[BZ #13540] [BZ #13540]

View File

@ -1,5 +1,6 @@
/* Macros to swap the order of bytes in integer values. /* Macros to swap the order of bytes in integer values.
Copyright (C) 1997,1998,2000-2002,2005,2008 Free Software Foundation, Inc. Copyright (C) 1997,1998,2000-2002,2005,2008,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -60,20 +61,20 @@ __bswap_32 (unsigned int __bsx)
#if defined __GNUC__ && __GNUC__ >= 2 #if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */ /* Swap bytes in 64 bit value. */
# define __bswap_constant_64(x) \ # define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ull) >> 56) \ (__extension__ ((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \ | (((x) & 0x00ff000000000000ull) >> 40) \
| (((x) & 0x0000ff0000000000ull) >> 24) \ | (((x) & 0x0000ff0000000000ull) >> 24) \
| (((x) & 0x000000ff00000000ull) >> 8) \ | (((x) & 0x000000ff00000000ull) >> 8) \
| (((x) & 0x00000000ff000000ull) << 8) \ | (((x) & 0x00000000ff000000ull) << 8) \
| (((x) & 0x0000000000ff0000ull) << 24) \ | (((x) & 0x0000000000ff0000ull) << 24) \
| (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56)) | (((x) & 0x00000000000000ffull) << 56)))
# define __bswap_64(x) \ # define __bswap_64(x) \
(__extension__ \ (__extension__ \
({ union { __extension__ unsigned long long int __ll; \ ({ union { __extension__ unsigned long long int __ll; \
unsigned int __l[2]; } __w, __r; \ unsigned int __l[2]; } __w, __r; \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__r.__ll = __bswap_constant_64 (x); \ __r.__ll = __bswap_constant_64 (x); \
else \ else \
{ \ { \

View File

@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. /* Macros to swap the order of bytes in integer values.
Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008, 2010 Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -109,15 +109,15 @@ __bswap_32 (unsigned int __bsx)
#if defined __GNUC__ && __GNUC__ >= 2 #if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */ /* Swap bytes in 64 bit value. */
#define __bswap_constant_64(x) \ # define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ull) >> 56) \ (__extension__ ((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \ | (((x) & 0x00ff000000000000ull) >> 40) \
| (((x) & 0x0000ff0000000000ull) >> 24) \ | (((x) & 0x0000ff0000000000ull) >> 24) \
| (((x) & 0x000000ff00000000ull) >> 8) \ | (((x) & 0x000000ff00000000ull) >> 8) \
| (((x) & 0x00000000ff000000ull) << 8) \ | (((x) & 0x00000000ff000000ull) << 8) \
| (((x) & 0x0000000000ff0000ull) << 24) \ | (((x) & 0x0000000000ff0000ull) << 24) \
| (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56)) | (((x) & 0x00000000000000ffull) << 56)))
# define __bswap_64(x) \ # define __bswap_64(x) \
(__extension__ \ (__extension__ \

View File

@ -1,5 +1,6 @@
/* Macros to swap the order of bytes in integer values. /* Macros to swap the order of bytes in integer values.
Copyright (C) 1997,1998,2000,2002,2003,2008 Free Software Foundation, Inc. Copyright (C) 1997,1998,2000,2002,2003,2008,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -77,17 +78,17 @@ __bswap_32 (unsigned int __bsx)
/* Swap bytes in 64 bit value. */ /* Swap bytes in 64 bit value. */
#define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ul) >> 56) \
| (((x) & 0x00ff000000000000ul) >> 40) \
| (((x) & 0x0000ff0000000000ul) >> 24) \
| (((x) & 0x000000ff00000000ul) >> 8) \
| (((x) & 0x00000000ff000000ul) << 8) \
| (((x) & 0x0000000000ff0000ul) << 24) \
| (((x) & 0x000000000000ff00ul) << 40) \
| (((x) & 0x00000000000000fful) << 56))
#if defined __GNUC__ && __GNUC__ >= 2 #if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_constant_64(x) \
(__extension__ ((((x) & 0xff00000000000000ul) >> 56) \
| (((x) & 0x00ff000000000000ul) >> 40) \
| (((x) & 0x0000ff0000000000ul) >> 24) \
| (((x) & 0x000000ff00000000ul) >> 8) \
| (((x) & 0x00000000ff000000ul) << 8) \
| (((x) & 0x0000000000ff0000ul) << 24) \
| (((x) & 0x000000000000ff00ul) << 40) \
| (((x) & 0x00000000000000fful) << 56)))
# define __bswap_64(x) \ # define __bswap_64(x) \
(__extension__ \ (__extension__ \
({ register unsigned long int __v, __x = (x); \ ({ register unsigned long int __v, __x = (x); \
@ -97,9 +98,19 @@ __bswap_32 (unsigned int __bsx)
__asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \ __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \
: "=r" (__v) \ : "=r" (__v) \
: "r" ((unsigned long int) (__x))); \ : "r" ((unsigned long int) (__x))); \
__v; })) __v; }))
#else #else
# define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ul) >> 56) \
| (((x) & 0x00ff000000000000ul) >> 40) \
| (((x) & 0x0000ff0000000000ul) >> 24) \
| (((x) & 0x000000ff00000000ul) >> 8) \
| (((x) & 0x00000000ff000000ul) << 8) \
| (((x) & 0x0000000000ff0000ul) << 24) \
| (((x) & 0x000000000000ff00ul) << 40) \
| (((x) & 0x00000000000000fful) << 56))
static __inline unsigned long int static __inline unsigned long int
__bswap_64 (unsigned long int __bsx) __bswap_64 (unsigned long int __bsx)
{ {

View File

@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. s390 version. /* Macros to swap the order of bytes in integer values. s390 version.
Copyright (C) 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc. Copyright (C) 2000-2003, 2008, 2011 Free Software Foundation, Inc.
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -35,31 +35,31 @@
# if __WORDSIZE == 64 # if __WORDSIZE == 64
# define __bswap_16(x) \ # define __bswap_16(x) \
(__extension__ \ (__extension__ \
({ unsigned short int __v, __x = (x); \ ({ unsigned short int __v, __x = (x); \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__v = __bswap_constant_16 (__x); \ __v = __bswap_constant_16 (__x); \
else { \ else { \
unsigned short int __tmp = (unsigned short int) (__x); \ unsigned short int __tmp = (unsigned short int) (__x); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"lrvh %0,%1" \ "lrvh %0,%1" \
: "=&d" (__v) : "m" (__tmp) ); \ : "=&d" (__v) : "m" (__tmp) ); \
} \ } \
__v; })) __v; }))
# else # else
# define __bswap_16(x) \ # define __bswap_16(x) \
(__extension__ \ (__extension__ \
({ unsigned short int __v, __x = (x); \ ({ unsigned short int __v, __x = (x); \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__v = __bswap_constant_16 (__x); \ __v = __bswap_constant_16 (__x); \
else { \ else { \
unsigned short int __tmp = (unsigned short int) (__x); \ unsigned short int __tmp = (unsigned short int) (__x); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"sr %0,%0\n" \ "sr %0,%0\n" \
"la 1,%1\n" \ "la 1,%1\n" \
"icm %0,2,1(1)\n" \ "icm %0,2,1(1)\n" \
"ic %0,0(1)" \ "ic %0,0(1)" \
: "=&d" (__v) : "m" (__tmp) : "1"); \ : "=&d" (__v) : "m" (__tmp) : "1"); \
} \ } \
__v; })) __v; }))
# endif # endif
#else #else
@ -80,32 +80,32 @@ __bswap_16 (unsigned short int __bsx)
# if __WORDSIZE == 64 # if __WORDSIZE == 64
# define __bswap_32(x) \ # define __bswap_32(x) \
(__extension__ \ (__extension__ \
({ unsigned int __v, __x = (x); \ ({ unsigned int __v, __x = (x); \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__v = __bswap_constant_32 (__x); \ __v = __bswap_constant_32 (__x); \
else { \ else { \
unsigned int __tmp = (unsigned int) (__x); \ unsigned int __tmp = (unsigned int) (__x); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"lrv %0,%1" \ "lrv %0,%1" \
: "=&d" (__v) : "m" (__tmp)); \ : "=&d" (__v) : "m" (__tmp)); \
} \ } \
__v; })) __v; }))
# else # else
# define __bswap_32(x) \ # define __bswap_32(x) \
(__extension__ \ (__extension__ \
({ unsigned int __v, __x = (x); \ ({ unsigned int __v, __x = (x); \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__v = __bswap_constant_32 (__x); \ __v = __bswap_constant_32 (__x); \
else { \ else { \
unsigned int __tmp = (unsigned int) (__x); \ unsigned int __tmp = (unsigned int) (__x); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"la 1,%1\n" \ "la 1,%1\n" \
"icm %0,8,3(1)\n" \ "icm %0,8,3(1)\n" \
"icm %0,4,2(1)\n" \ "icm %0,4,2(1)\n" \
"icm %0,2,1(1)\n" \ "icm %0,2,1(1)\n" \
"ic %0,0(1)" \ "ic %0,0(1)" \
: "=&d" (__v) : "m" (__tmp) : "1"); \ : "=&d" (__v) : "m" (__tmp) : "1"); \
} \ } \
__v; })) __v; }))
# endif # endif
#else #else
@ -117,37 +117,51 @@ __bswap_32 (unsigned int __bsx)
#endif #endif
/* Swap bytes in 64 bit value. */ /* Swap bytes in 64 bit value. */
#define __bswap_constant_64(x) \
((((x)&0xff00000000000000) >> 56) | (((x)&0x00ff000000000000) >> 40) | \
(((x)&0x0000ff0000000000) >> 24) | (((x)&0x000000ff00000000) >> 8) | \
(((x)&0x00000000ff000000) << 8) | (((x)&0x0000000000ff0000) << 24) | \
(((x)&0x000000000000ff00) << 40) | (((x)&0x00000000000000ff) << 56))
#if defined __GNUC__ && __GNUC__ >= 2 #if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_constant_64(x) \
(__extension__ ((((x) & 0xff00000000000000ul) >> 56) \
| (((x) & 0x00ff000000000000ul) >> 40) \
| (((x) & 0x0000ff0000000000ul) >> 24) \
| (((x) & 0x000000ff00000000ul) >> 8) \
| (((x) & 0x00000000ff000000ul) << 8) \
| (((x) & 0x0000000000ff0000ul) << 24) \
| (((x) & 0x000000000000ff00ul) << 40) \
| (((x) & 0x00000000000000fful) << 56)))
# if __WORDSIZE == 64 # if __WORDSIZE == 64
# define __bswap_64(x) \ # define __bswap_64(x) \
(__extension__ \ (__extension__ \
({ unsigned long __w, __x = (x); \ ({ unsigned long __w, __x = (x); \
if (__builtin_constant_p (x)) \ if (__builtin_constant_p (x)) \
__w = __bswap_constant_64 (__x); \ __w = __bswap_constant_64 (__x); \
else { \ else { \
unsigned long __tmp = (unsigned long) (__x); \ unsigned long __tmp = (unsigned long) (__x); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"lrvg %0,%1" \ "lrvg %0,%1" \
: "=&d" (__w) : "m" (__tmp)); \ : "=&d" (__w) : "m" (__tmp)); \
} \ } \
__w; })) __w; }))
# else # else
# define __bswap_64(x) \ # define __bswap_64(x) \
__extension__ \ __extension__ \
({ union { unsigned long long int __ll; \ ({ union { unsigned long long int __ll; \
unsigned long int __l[2]; } __w, __r; \ unsigned long int __l[2]; } __w, __r; \
__w.__ll = (x); \ __w.__ll = (x); \
__r.__l[0] = __bswap_32 (__w.__l[1]); \ __r.__l[0] = __bswap_32 (__w.__l[1]); \
__r.__l[1] = __bswap_32 (__w.__l[0]); \ __r.__l[1] = __bswap_32 (__w.__l[0]); \
__r.__ll; }) __r.__ll; })
# endif # endif
#else #else
# define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ul) >> 56) \
| (((x) & 0x00ff000000000000ul) >> 40) \
| (((x) & 0x0000ff0000000000ul) >> 24) \
| (((x) & 0x000000ff00000000ul) >> 8) \
| (((x) & 0x00000000ff000000ul) << 8) \
| (((x) & 0x0000000000ff0000ul) << 24) \
| (((x) & 0x000000000000ff00ul) << 40) \
| (((x) & 0x00000000000000fful) << 56))
static __inline unsigned long long int static __inline unsigned long long int
__bswap_64 (unsigned long long int __bsx) __bswap_64 (unsigned long long int __bsx)
{ {

View File

@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. /* Macros to swap the order of bytes in integer values.
Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008, 2010 Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -99,14 +99,14 @@
#if defined __GNUC__ && __GNUC__ >= 2 #if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */ /* Swap bytes in 64 bit value. */
# define __bswap_constant_64(x) \ # define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ull) >> 56) \ (__extension__ ((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \ | (((x) & 0x00ff000000000000ull) >> 40) \
| (((x) & 0x0000ff0000000000ull) >> 24) \ | (((x) & 0x0000ff0000000000ull) >> 24) \
| (((x) & 0x000000ff00000000ull) >> 8) \ | (((x) & 0x000000ff00000000ull) >> 8) \
| (((x) & 0x00000000ff000000ull) << 8) \ | (((x) & 0x00000000ff000000ull) << 8) \
| (((x) & 0x0000000000ff0000ull) << 24) \ | (((x) & 0x0000000000ff0000ull) << 24) \
| (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56)) | (((x) & 0x00000000000000ffull) << 56)))
# if __WORDSIZE == 64 # if __WORDSIZE == 64
# define __bswap_64(x) \ # define __bswap_64(x) \