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

Side by Side Diff: third_party/WebKit/Source/wtf/Alignment.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « third_party/WebKit/Source/wtf/Alias.cpp ('k') | third_party/WebKit/Source/wtf/Allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 #else 36 #else
37 #error WTF_ALIGN macros need alignment control. 37 #error WTF_ALIGN macros need alignment control.
38 #endif 38 #endif
39 39
40 #if COMPILER(GCC) 40 #if COMPILER(GCC)
41 typedef char __attribute__((__may_alias__)) AlignedBufferChar; 41 typedef char __attribute__((__may_alias__)) AlignedBufferChar;
42 #else 42 #else
43 typedef char AlignedBufferChar; 43 typedef char AlignedBufferChar;
44 #endif 44 #endif
45 45
46 template <size_t size, size_t alignment> struct AlignedBuffer; 46 template <size_t size, size_t alignment>
47 template <size_t size> struct AlignedBuffer<size, 1> { AlignedBufferChar buffer[ size]; }; 47 struct AlignedBuffer;
48 template <size_t size> struct AlignedBuffer<size, 2> { WTF_ALIGNED(AlignedBuffer Char, buffer[size], 2); }; 48 template <size_t size>
49 template <size_t size> struct AlignedBuffer<size, 4> { WTF_ALIGNED(AlignedBuffer Char, buffer[size], 4); }; 49 struct AlignedBuffer<size, 1> { AlignedBufferChar buffer[size]; };
50 template <size_t size> struct AlignedBuffer<size, 8> { WTF_ALIGNED(AlignedBuffer Char, buffer[size], 8); }; 50 template <size_t size>
51 template <size_t size> struct AlignedBuffer<size, 16> { WTF_ALIGNED(AlignedBuffe rChar, buffer[size], 16); }; 51 struct AlignedBuffer<size, 2> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 2); };
52 template <size_t size> struct AlignedBuffer<size, 32> { WTF_ALIGNED(AlignedBuffe rChar, buffer[size], 32); }; 52 template <size_t size>
53 template <size_t size> struct AlignedBuffer<size, 64> { WTF_ALIGNED(AlignedBuffe rChar, buffer[size], 64); }; 53 struct AlignedBuffer<size, 4> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 4); };
54 template <size_t size>
55 struct AlignedBuffer<size, 8> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 8); };
56 template <size_t size>
57 struct AlignedBuffer<size, 16> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 16 ); };
58 template <size_t size>
59 struct AlignedBuffer<size, 32> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 32 ); };
60 template <size_t size>
61 struct AlignedBuffer<size, 64> { WTF_ALIGNED(AlignedBufferChar, buffer[size], 64 ); };
54 62
55 template <size_t size, size_t alignment> 63 template <size_t size, size_t alignment>
56 void swap(AlignedBuffer<size, alignment>& a, AlignedBuffer<size, alignment>& b) 64 void swap(AlignedBuffer<size, alignment>& a, AlignedBuffer<size, alignment>& b) {
57 { 65 for (size_t i = 0; i < size; ++i)
58 for (size_t i = 0; i < size; ++i) 66 std::swap(a.buffer[i], b.buffer[i]);
59 std::swap(a.buffer[i], b.buffer[i]);
60 } 67 }
61 68
62 template <uintptr_t mask> 69 template <uintptr_t mask>
63 inline bool isAlignedTo(const void* pointer) 70 inline bool isAlignedTo(const void* pointer) {
64 { 71 return !(reinterpret_cast<uintptr_t>(pointer) & mask);
65 return !(reinterpret_cast<uintptr_t>(pointer) & mask);
66 } 72 }
67 73
68 } // namespace WTF 74 } // namespace WTF
69 75
70 #endif // WTF_Alignment_h 76 #endif // WTF_Alignment_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Alias.cpp ('k') | third_party/WebKit/Source/wtf/Allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698