OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 | 7 |
8 /* | 8 /* |
9 * NaCl Safety Macro Definitions | 9 * NaCl Safety Macro Definitions |
10 */ | 10 */ |
11 #ifndef NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ | 11 #ifndef NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ |
12 #define NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ 1 | 12 #define NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ 1 |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 | 16 |
| 17 #define NACL_TO_STRING_INTERNAL(v) #v |
| 18 #define NACL_TO_STRING(v) NACL_TO_STRING_INTERNAL(v) |
| 19 |
17 /***************************************************************************** | 20 /***************************************************************************** |
18 * Safety macros * | 21 * Safety macros * |
19 *****************************************************************************/ | 22 *****************************************************************************/ |
20 | 23 |
21 #define NACL_ARRAY_SIZE_UNSAFE(arr) ((sizeof arr)/sizeof arr[0]) | 24 #define NACL_ARRAY_SIZE_UNSAFE(arr) ((sizeof arr)/sizeof arr[0]) |
22 | 25 |
23 /* | 26 /* |
24 * ASSERT_IS_ARRAY(arr) generates a somewhat opaque compile-time | 27 * ASSERT_IS_ARRAY(arr) generates a somewhat opaque compile-time |
25 * error if arr is a non-array pointer. This protects against | 28 * error if arr is a non-array pointer. This protects against |
26 * situations where one writes code like: | 29 * situations where one writes code like: |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 NACL_ASSERT_SAME_SIZE(Dest, Source); | 361 NACL_ASSERT_SAME_SIZE(Dest, Source); |
359 | 362 |
360 Dest dest; | 363 Dest dest; |
361 memcpy(&dest, &source, sizeof(dest)); | 364 memcpy(&dest, &source, sizeof(dest)); |
362 return dest; | 365 return dest; |
363 } | 366 } |
364 | 367 |
365 #endif /* __cplusplus */ | 368 #endif /* __cplusplus */ |
366 | 369 |
367 #endif /* NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ */ | 370 #endif /* NATIVE_CLIENT_SRC_INCLUDE_NACL_MACROS_H_ */ |
OLD | NEW |