]>
Commit | Line | Data |
---|---|---|
12788f63 MT |
1 | commit 69da074d7adfab7b57004a0dea9403a928e310a5 |
2 | Author: Ulrich Drepper <drepper@gmail.com> | |
3 | Date: Wed Nov 10 02:38:35 2010 -0500 | |
4 | ||
5 | Fix warnings in __bswap_16. | |
6 | ||
7 | diff --git a/sysdeps/i386/bits/byteswap.h b/sysdeps/i386/bits/byteswap.h | |
8 | index 1f3fc5e..c246ae8 100644 | |
9 | --- a/sysdeps/i386/bits/byteswap.h | |
10 | +++ b/sysdeps/i386/bits/byteswap.h | |
11 | @@ -1,5 +1,5 @@ | |
12 | /* Macros to swap the order of bytes in integer values. | |
13 | - Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008 | |
14 | + Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008, 2010 | |
15 | Free Software Foundation, Inc. | |
16 | This file is part of the GNU C Library. | |
17 | ||
18 | @@ -27,26 +27,27 @@ | |
19 | ||
20 | /* Swap bytes in 16 bit value. */ | |
21 | #define __bswap_constant_16(x) \ | |
22 | - ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) | |
23 | + ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) | |
24 | ||
25 | #ifdef __GNUC__ | |
26 | # if __GNUC__ >= 2 | |
27 | # define __bswap_16(x) \ | |
28 | (__extension__ \ | |
29 | - ({ register unsigned short int __v, __x = (x); \ | |
30 | + ({ register unsigned short int __v, __x = (unsigned short int) (x); \ | |
31 | if (__builtin_constant_p (__x)) \ | |
32 | __v = __bswap_constant_16 (__x); \ | |
33 | else \ | |
34 | __asm__ ("rorw $8, %w0" \ | |
35 | : "=r" (__v) \ | |
36 | - : "0" (__x) \ | |
37 | - : "cc"); \ | |
38 | + : "0" (__x) \ | |
39 | + : "cc"); \ | |
40 | __v; })) | |
41 | # else | |
42 | /* This is better than nothing. */ | |
43 | # define __bswap_16(x) \ | |
44 | (__extension__ \ | |
45 | - ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); })) | |
46 | + ({ register unsigned short int __x = (unsigned short int) (x); \ | |
47 | + __bswap_constant_16 (__x); })) | |
48 | # endif | |
49 | #else | |
50 | static __inline unsigned short int | |
51 | @@ -122,7 +123,7 @@ __bswap_32 (unsigned int __bsx) | |
52 | (__extension__ \ | |
53 | ({ union { __extension__ unsigned long long int __ll; \ | |
54 | unsigned long int __l[2]; } __w, __r; \ | |
55 | - if (__builtin_constant_p (x)) \ | |
56 | + if (__builtin_constant_p (x)) \ | |
57 | __r.__ll = __bswap_constant_64 (x); \ | |
58 | else \ | |
59 | { \ | |
60 | diff --git a/sysdeps/x86_64/bits/byteswap.h b/sysdeps/x86_64/bits/byteswap.h | |
61 | index 08b38e8..e350fb8 100644 | |
62 | --- a/sysdeps/x86_64/bits/byteswap.h | |
63 | +++ b/sysdeps/x86_64/bits/byteswap.h | |
64 | @@ -1,5 +1,5 @@ | |
65 | /* Macros to swap the order of bytes in integer values. | |
66 | - Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008 | |
67 | + Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008, 2010 | |
68 | Free Software Foundation, Inc. | |
69 | This file is part of the GNU C Library. | |
70 | ||
71 | @@ -29,12 +29,12 @@ | |
72 | ||
73 | /* Swap bytes in 16 bit value. */ | |
74 | #define __bswap_constant_16(x) \ | |
75 | - ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) | |
76 | + ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) | |
77 | ||
78 | #if defined __GNUC__ && __GNUC__ >= 2 | |
79 | # define __bswap_16(x) \ | |
80 | (__extension__ \ | |
81 | - ({ register unsigned short int __v, __x = (x); \ | |
82 | + ({ register unsigned short int __v, __x = (unsigned short int) (x); \ | |
83 | if (__builtin_constant_p (__x)) \ | |
84 | __v = __bswap_constant_16 (__x); \ | |
85 | else \ | |
86 | @@ -47,7 +47,8 @@ | |
87 | /* This is better than nothing. */ | |
88 | # define __bswap_16(x) \ | |
89 | (__extension__ \ | |
90 | - ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); })) | |
91 | + ({ register unsigned short int __x = (unsigned short int) (x); \ | |
92 | + __bswap_constant_16 (__x); })) | |
93 | #endif | |
94 | ||
95 | ||
96 | @@ -120,16 +121,16 @@ | |
97 | # define __bswap_64(x) \ | |
98 | (__extension__ \ | |
99 | ({ union { __extension__ unsigned long long int __ll; \ | |
100 | - unsigned int __l[2]; } __w, __r; \ | |
101 | - if (__builtin_constant_p (x)) \ | |
102 | - __r.__ll = __bswap_constant_64 (x); \ | |
103 | - else \ | |
104 | - { \ | |
105 | - __w.__ll = (x); \ | |
106 | - __r.__l[0] = __bswap_32 (__w.__l[1]); \ | |
107 | - __r.__l[1] = __bswap_32 (__w.__l[0]); \ | |
108 | - } \ | |
109 | - __r.__ll; })) | |
110 | + unsigned int __l[2]; } __w, __r; \ | |
111 | + if (__builtin_constant_p (x)) \ | |
112 | + __r.__ll = __bswap_constant_64 (x); \ | |
113 | + else \ | |
114 | + { \ | |
115 | + __w.__ll = (x); \ | |
116 | + __r.__l[0] = __bswap_32 (__w.__l[1]); \ | |
117 | + __r.__l[1] = __bswap_32 (__w.__l[0]); \ | |
118 | + } \ | |
119 | + __r.__ll; })) | |
120 | # endif | |
121 | #endif | |
122 |