Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: source/libvpx/vpx_util/endian_inl.h

Issue 1292313007: Cherry pick MIPS build fix (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 Google Inc. All Rights Reserved. 1 // Copyright 2014 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // Endian related functions. 10 // Endian related functions.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // clang-3.3 and gcc-4.3 have builtin functions for swap32/swap64 56 // clang-3.3 and gcc-4.3 have builtin functions for swap32/swap64
57 #if LOCAL_GCC_PREREQ(4, 3) || LOCAL_CLANG_PREREQ(3, 3) 57 #if LOCAL_GCC_PREREQ(4, 3) || LOCAL_CLANG_PREREQ(3, 3)
58 #define HAVE_BUILTIN_BSWAP32 58 #define HAVE_BUILTIN_BSWAP32
59 #define HAVE_BUILTIN_BSWAP64 59 #define HAVE_BUILTIN_BSWAP64
60 #endif 60 #endif
61 // clang-3.3 and gcc-4.8 have a builtin function for swap16 61 // clang-3.3 and gcc-4.8 have a builtin function for swap16
62 #if LOCAL_GCC_PREREQ(4, 8) || LOCAL_CLANG_PREREQ(3, 3) 62 #if LOCAL_GCC_PREREQ(4, 8) || LOCAL_CLANG_PREREQ(3, 3)
63 #define HAVE_BUILTIN_BSWAP16 63 #define HAVE_BUILTIN_BSWAP16
64 #endif 64 #endif
65 65
66 #if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \
67 defined(__mips_isa_rev) && (__mips_isa_rev >= 2) && (__mips_isa_rev < 6)
68 #define VPX_USE_MIPS32_R2
69 #endif
70
66 static INLINE uint16_t BSwap16(uint16_t x) { 71 static INLINE uint16_t BSwap16(uint16_t x) {
67 #if defined(HAVE_BUILTIN_BSWAP16) 72 #if defined(HAVE_BUILTIN_BSWAP16)
68 return __builtin_bswap16(x); 73 return __builtin_bswap16(x);
69 #elif defined(_MSC_VER) 74 #elif defined(_MSC_VER)
70 return _byteswap_ushort(x); 75 return _byteswap_ushort(x);
71 #else 76 #else
72 // gcc will recognize a 'rorw $8, ...' here: 77 // gcc will recognize a 'rorw $8, ...' here:
73 return (x >> 8) | ((x & 0xff) << 8); 78 return (x >> 8) | ((x & 0xff) << 8);
74 #endif // HAVE_BUILTIN_BSWAP16 79 #endif // HAVE_BUILTIN_BSWAP16
75 } 80 }
76 81
77 static INLINE uint32_t BSwap32(uint32_t x) { 82 static INLINE uint32_t BSwap32(uint32_t x) {
78 #if HAVE_MIPS32 83 #if defined(VPX_USE_MIPS32_R2)
79 uint32_t ret; 84 uint32_t ret;
80 __asm__ volatile ( 85 __asm__ volatile (
81 "wsbh %[ret], %[x] \n\t" 86 "wsbh %[ret], %[x] \n\t"
82 "rotr %[ret], %[ret], 16 \n\t" 87 "rotr %[ret], %[ret], 16 \n\t"
83 : [ret]"=r"(ret) 88 : [ret]"=r"(ret)
84 : [x]"r"(x) 89 : [x]"r"(x)
85 ); 90 );
86 return ret; 91 return ret;
87 #elif defined(HAVE_BUILTIN_BSWAP32) 92 #elif defined(HAVE_BUILTIN_BSWAP32)
88 return __builtin_bswap32(x); 93 return __builtin_bswap32(x);
(...skipping 19 matching lines...) Expand all
108 return (uint64_t)_byteswap_uint64(x); 113 return (uint64_t)_byteswap_uint64(x);
109 #else // generic code for swapping 64-bit values (suggested by bdb@) 114 #else // generic code for swapping 64-bit values (suggested by bdb@)
110 x = ((x & 0xffffffff00000000ull) >> 32) | ((x & 0x00000000ffffffffull) << 32); 115 x = ((x & 0xffffffff00000000ull) >> 32) | ((x & 0x00000000ffffffffull) << 32);
111 x = ((x & 0xffff0000ffff0000ull) >> 16) | ((x & 0x0000ffff0000ffffull) << 16); 116 x = ((x & 0xffff0000ffff0000ull) >> 16) | ((x & 0x0000ffff0000ffffull) << 16);
112 x = ((x & 0xff00ff00ff00ff00ull) >> 8) | ((x & 0x00ff00ff00ff00ffull) << 8); 117 x = ((x & 0xff00ff00ff00ff00ull) >> 8) | ((x & 0x00ff00ff00ff00ffull) << 8);
113 return x; 118 return x;
114 #endif // HAVE_BUILTIN_BSWAP64 119 #endif // HAVE_BUILTIN_BSWAP64
115 } 120 }
116 121
117 #endif // VPX_UTIL_ENDIAN_INL_H_ 122 #endif // VPX_UTIL_ENDIAN_INL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698