| OLD | NEW |
| 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_ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 /* Compare [n] bytes in [src1] and [src2] | 48 /* Compare [n] bytes in [src1] and [src2] |
| 49 * Returns an integer less than, equal to, or greater than zero if the first [n] | 49 * Returns an integer less than, equal to, or greater than zero if the first [n] |
| 50 * bytes of [src1] is found, respectively, to be less than, to match, or be | 50 * bytes of [src1] is found, respectively, to be less than, to match, or be |
| 51 * greater than the first n bytes of [src2]. */ | 51 * greater than the first n bytes of [src2]. */ |
| 52 int Memcmp(const void* src1, const void* src2, size_t n); | 52 int Memcmp(const void* src1, const void* src2, size_t n); |
| 53 | 53 |
| 54 /* Copy [n] bytes from [src] to [dest]. */ | 54 /* Copy [n] bytes from [src] to [dest]. */ |
| 55 void* Memcpy(void* dest, const void* src, uint64_t n); | 55 void* Memcpy(void* dest, const void* src, uint64_t n); |
| 56 | 56 |
| 57 |
| 58 /* Implementations of the functions below must be built as part of the firmware |
| 59 * and defined in lib/utility.c */ |
| 60 |
| 57 /* Set [n] bytes starting at [s] to [c]. */ | 61 /* Set [n] bytes starting at [s] to [c]. */ |
| 58 void* Memset(void *dest, const uint8_t c, uint64_t n); | 62 void* Memset(void *dest, const uint8_t c, uint64_t n); |
| 59 | 63 |
| 60 /* Compare [n] bytes starting at [s1] with [s2] and return 0 if they match, | 64 /* Compare [n] bytes starting at [s1] with [s2] and return 0 if they match, |
| 61 * 1 if they don't. Time taken to perform the comparison is only dependent on | 65 * 1 if they don't. Time taken to perform the comparison is only dependent on |
| 62 * [n] and not on the relationship of the match between [s1] and [s2]. | 66 * [n] and not on the relationship of the match between [s1] and [s2]. |
| 63 */ | 67 */ |
| 64 int SafeMemcmp(const void* s1, const void* s2, size_t n); | 68 int SafeMemcmp(const void* s1, const void* s2, size_t n); |
| 65 | 69 |
| 66 /* Ensure that only our stub implementations are used, not standard C */ | 70 /* Ensure that only our stub implementations are used, not standard C */ |
| 67 #ifndef _STUB_IMPLEMENTATION_ | 71 #ifndef _STUB_IMPLEMENTATION_ |
| 68 #define malloc _do_not_use_standard_malloc | 72 #define malloc _do_not_use_standard_malloc |
| 69 #define free _do_not_use_standard_free | 73 #define free _do_not_use_standard_free |
| 70 #define memcmp _do_not_use_standard_memcmp | 74 #define memcmp _do_not_use_standard_memcmp |
| 71 #define memcpy _do_not_use_standard_memcpy | 75 #define memcpy _do_not_use_standard_memcpy |
| 72 #define memset _do_not_use_standard_memset | 76 #define memset _do_not_use_standard_memset |
| 73 #endif | 77 #endif |
| 74 | 78 |
| 75 | |
| 76 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ | 79 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ |
| OLD | NEW |