OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_BASE_MACROS_H_ | 5 #ifndef V8_BASE_MACROS_H_ |
6 #define V8_BASE_MACROS_H_ | 6 #define V8_BASE_MACROS_H_ |
7 | 7 |
8 #include "../../include/v8stdint.h" | 8 #include "include/v8stdint.h" |
9 | 9 |
10 | 10 |
11 // The expression OFFSET_OF(type, field) computes the byte-offset | 11 // The expression OFFSET_OF(type, field) computes the byte-offset |
12 // of the specified field relative to the containing type. This | 12 // of the specified field relative to the containing type. This |
13 // corresponds to 'offsetof' (in stddef.h), except that it doesn't | 13 // corresponds to 'offsetof' (in stddef.h), except that it doesn't |
14 // use 0 or NULL, which causes a problem with the compiler warnings | 14 // use 0 or NULL, which causes a problem with the compiler warnings |
15 // we have enabled (which is also why 'offsetof' doesn't seem to work). | 15 // we have enabled (which is also why 'offsetof' doesn't seem to work). |
16 // Here we simply use the non-zero value 4, which seems to work. | 16 // Here we simply use the non-zero value 4, which seems to work. |
17 #define OFFSET_OF(type, field) \ | 17 #define OFFSET_OF(type, field) \ |
18 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) | 18 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 #endif | 104 #endif |
105 | 105 |
106 | 106 |
107 // The USE(x) template is used to silence C++ compiler warnings | 107 // The USE(x) template is used to silence C++ compiler warnings |
108 // issued for (yet) unused variables (typically parameters). | 108 // issued for (yet) unused variables (typically parameters). |
109 template <typename T> | 109 template <typename T> |
110 inline void USE(T) { } | 110 inline void USE(T) { } |
111 | 111 |
112 #endif // V8_BASE_MACROS_H_ | 112 #endif // V8_BASE_MACROS_H_ |
OLD | NEW |