##// END OF EJS Templates
util.h: getbe32() and putbe32() use intrinsic function to improve performance...
Wei, Elson -
r19744:06badf7d default
parent child Browse files
Show More
@@ -151,6 +151,17 b' typedef unsigned __int64 uint64_t;'
151 #define inline __inline
151 #define inline __inline
152 #endif
152 #endif
153
153
154 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
155 static inline uint32_t getbe32(const char *c)
156 {
157 return _byteswap_ulong(*(uint32_t *)c);
158 }
159 #elif GCC_VERSION >= 403
160 static inline uint32_t getbe32(const char *c)
161 {
162 return __builtin_bswap32(*(uint32_t *)c);
163 }
164 #else
154 static inline uint32_t getbe32(const char *c)
165 static inline uint32_t getbe32(const char *c)
155 {
166 {
156 const unsigned char *d = (const unsigned char *)c;
167 const unsigned char *d = (const unsigned char *)c;
@@ -160,7 +171,21 b' static inline uint32_t getbe32(const cha'
160 (d[2] << 8) |
171 (d[2] << 8) |
161 (d[3]));
172 (d[3]));
162 }
173 }
174 #endif
163
175
176 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
177 static inline void putbe32(uint32_t x, char *c)
178 {
179 x = _byteswap_ulong(x);
180 *(uint32_t *)c = x;
181 }
182 #elif GCC_VERSION >= 403
183 static inline void putbe32(uint32_t x, char *c)
184 {
185 x = __builtin_bswap32(x);
186 *(uint32_t *)c = x;
187 }
188 #else
164 static inline void putbe32(uint32_t x, char *c)
189 static inline void putbe32(uint32_t x, char *c)
165 {
190 {
166 c[0] = (x >> 24) & 0xff;
191 c[0] = (x >> 24) & 0xff;
@@ -168,5 +193,6 b' static inline void putbe32(uint32_t x, c'
168 c[2] = (x >> 8) & 0xff;
193 c[2] = (x >> 8) & 0xff;
169 c[3] = (x) & 0xff;
194 c[3] = (x) & 0xff;
170 }
195 }
196 #endif
171
197
172 #endif /* _HG_UTIL_H_ */
198 #endif /* _HG_UTIL_H_ */
General Comments 0
You need to be logged in to leave comments. Login now