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

Side by Side Diff: firmware/include/utility.h

Issue 3446025: Add performance macros; fix assert macro (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git
Patch Set: Fix missing #ifdef around assert macro Created 10 years, 2 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 | Annotate | Revision Log
« 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 (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS 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 5
6 /* Helper functions/wrappers for memory allocations, manipulation and 6 /* Helper functions/wrappers for memory allocations, manipulation and
7 * comparison. 7 * comparison.
8 */ 8 */
9 9
10 #ifndef VBOOT_REFERENCE_UTILITY_H_ 10 #ifndef VBOOT_REFERENCE_UTILITY_H_
11 #define VBOOT_REFERENCE_UTILITY_H_ 11 #define VBOOT_REFERENCE_UTILITY_H_
12 12
13 #include "sysincludes.h" 13 #include "sysincludes.h"
14 14
15 /* Debug and error output */ 15 /* Debug and error output */
16 #ifdef VBOOT_DEBUG 16 #ifdef VBOOT_DEBUG
17 #define VBDEBUG(params) debug params 17 #define VBDEBUG(params) debug params
18 #else 18 #else
19 #define VBDEBUG(params) 19 #define VBDEBUG(params)
20 #endif 20 #endif
21 21
22 #ifndef VBOOT_PERFORMANCE
23 /* Define performance macros as nothing. If you enable VBOOT_PERFORMANCE,
24 * you must define these macros in your platform's biosincludes.h.
25 *
26 * Intended usage for using a performance counter called 'foo':
27 *
28 * VBPERFSTART("foo")
29 * ...code to be tested...
30 * VBPERFEND("foo")
31 *
32 * Names should be <= 8 characters to be compatible with all platforms.
33 */
34 #define VBPERFSTART(name)
35 #define VBPERFEND(name)
36 #endif
37
22 /* Outputs an error message and quits. */ 38 /* Outputs an error message and quits. */
23 void error(const char *format, ...); 39 void error(const char* format, ...);
24 40
25 /* Outputs debug/warning messages. */ 41 /* Outputs debug/warning messages. */
26 void debug(const char *format, ...); 42 void debug(const char* format, ...);
27 43
44 #ifdef VBOOT_DEBUG
28 #define assert(expr) do { if (!(expr)) { \ 45 #define assert(expr) do { if (!(expr)) { \
29 error("assert fail: %s at %s:%d\n", \ 46 error("assert fail: %s at %s:%d\n", \
30 #expr, __FILE__, __LINE__); }} while(0) 47 #expr, __FILE__, __LINE__); }} while(0)
48 #else
49 #define assert(expr)
50 #endif
31 51
32 /* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and 52 /* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and
33 * [lsw] forming the most and least signficant 16-bit words. 53 * [lsw] forming the most and least signficant 16-bit words.
34 */ 54 */
35 #define CombineUint16Pair(msw,lsw) (((msw) << 16) | \ 55 #define CombineUint16Pair(msw,lsw) (((msw) << 16) | \
36 (((lsw)) & 0xFFFF)) 56 (((lsw)) & 0xFFFF))
37 /* Return the minimum of (a) or (b). */ 57 /* Return the minimum of (a) or (b). */
38 #define Min(a, b) (((a) < (b)) ? (a) : (b)) 58 #define Min(a, b) (((a) < (b)) ? (a) : (b))
39 59
40 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort 60 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort
(...skipping 29 matching lines...) Expand all
70 /* Ensure that only our stub implementations are used, not standard C */ 90 /* Ensure that only our stub implementations are used, not standard C */
71 #ifndef _STUB_IMPLEMENTATION_ 91 #ifndef _STUB_IMPLEMENTATION_
72 #define malloc _do_not_use_standard_malloc 92 #define malloc _do_not_use_standard_malloc
73 #define free _do_not_use_standard_free 93 #define free _do_not_use_standard_free
74 #define memcmp _do_not_use_standard_memcmp 94 #define memcmp _do_not_use_standard_memcmp
75 #define memcpy _do_not_use_standard_memcpy 95 #define memcpy _do_not_use_standard_memcpy
76 #define memset _do_not_use_standard_memset 96 #define memset _do_not_use_standard_memset
77 #endif 97 #endif
78 98
79 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ 99 #endif /* VBOOT_REFERENCE_UTILITY_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