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

Side by Side Diff: sky/engine/wtf/ByteSwap.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef WTF_ByteSwap_h 31 #ifndef WTF_ByteSwap_h
32 #define WTF_ByteSwap_h 32 #define WTF_ByteSwap_h
33 33
34 #include "wtf/CPU.h" 34 #include "wtf/CPU.h"
35 #include "wtf/Compiler.h" 35 #include "wtf/Compiler.h"
36 36
37 #include <stdint.h> 37 #include <stdint.h>
38 38
39 #if COMPILER(MSVC)
40 #include <stdlib.h>
41 #endif
42
39 namespace WTF { 43 namespace WTF {
40 44
41 inline uint32_t wswap32(uint32_t x) { return ((x & 0xffff0000) >> 16) | ((x & 0x 0000ffff) << 16); } 45 inline uint32_t wswap32(uint32_t x) { return ((x & 0xffff0000) >> 16) | ((x & 0x 0000ffff) << 16); }
42 46
47 #if COMPILER(MSVC)
48
49 ALWAYS_INLINE uint64_t bswap64(uint64_t x) { return _byteswap_uint64(x); }
50 ALWAYS_INLINE uint32_t bswap32(uint32_t x) { return _byteswap_ulong(x); }
51 ALWAYS_INLINE uint16_t bswap16(uint16_t x) { return _byteswap_ushort(x); }
52
53 #else
54
43 ALWAYS_INLINE uint64_t bswap64(uint64_t x) { return __builtin_bswap64(x); } 55 ALWAYS_INLINE uint64_t bswap64(uint64_t x) { return __builtin_bswap64(x); }
44 ALWAYS_INLINE uint32_t bswap32(uint32_t x) { return __builtin_bswap32(x); } 56 ALWAYS_INLINE uint32_t bswap32(uint32_t x) { return __builtin_bswap32(x); }
45 // GCC 4.6 lacks __builtin_bswap16. Newer versions have it but we support 4.6. 57 // GCC 4.6 lacks __builtin_bswap16. Newer versions have it but we support 4.6.
46 #if COMPILER(CLANG) 58 #if COMPILER(CLANG)
47 ALWAYS_INLINE uint16_t bswap16(uint16_t x) { return __builtin_bswap16(x); } 59 ALWAYS_INLINE uint16_t bswap16(uint16_t x) { return __builtin_bswap16(x); }
48 #else 60 #else
49 inline uint16_t bswap16(uint16_t x) { return ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8); } 61 inline uint16_t bswap16(uint16_t x) { return ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8); }
50 #endif 62 #endif
51 63
64 #endif
65
52 #if CPU(64BIT) 66 #if CPU(64BIT)
53 67
54 ALWAYS_INLINE size_t bswapuintptrt(size_t x) { return bswap64(x); } 68 ALWAYS_INLINE size_t bswapuintptrt(size_t x) { return bswap64(x); }
55 69
56 #else 70 #else
57 71
58 ALWAYS_INLINE size_t bswapuintptrt(size_t x) { return bswap32(x); } 72 ALWAYS_INLINE size_t bswapuintptrt(size_t x) { return bswap32(x); }
59 73
60 #endif 74 #endif
61 75
62 } // namespace WTF 76 } // namespace WTF
63 77
64 #endif // WTF_ByteSwap_h 78 #endif // WTF_ByteSwap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698