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

Side by Side Diff: src/platform/vboot_reference/common/include/utility.h

Issue 1729006: Add helper functions and files for gpt tests. (Closed)
Patch Set: fix for code review Created 10 years, 8 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
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_
(...skipping 22 matching lines...) Expand all
33 #define Min(a, b) (((a) < (b)) ? (a) : (b)) 33 #define Min(a, b) (((a) < (b)) ? (a) : (b))
34 34
35 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort 35 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort
36 * on error. 36 * on error.
37 */ 37 */
38 void* Malloc(size_t size); 38 void* Malloc(size_t size);
39 39
40 /* Free memory pointed by [ptr] previously allocated by Malloc(). */ 40 /* Free memory pointed by [ptr] previously allocated by Malloc(). */
41 void Free(void* ptr); 41 void Free(void* ptr);
42 42
43 /* Compare [n] bytes in [src1] and [src2]
44 * Returns an integer less than, equal to, or greater than zero if the first [n]
45 * bytes of [src1] is found, respectively, to be less than, to match, or be
46 * greater than the first n bytes of [src2]. */
47 int Memcmp(const void* src1, const void* src2, size_t n);
48
43 /* Copy [n] bytes from [src] to [dest]. */ 49 /* Copy [n] bytes from [src] to [dest]. */
44 void* Memcpy(void* dest, const void* src, size_t n); 50 void* Memcpy(void* dest, const void* src, size_t n);
45 51
46 /* Set [n] bytes starting at [s] to [c]. */ 52 /* Set [n] bytes starting at [s] to [c]. */
47 void* Memset(void *dest, const uint8_t c, size_t n); 53 void* Memset(void *dest, const uint8_t c, size_t n);
48 54
49 /* Compare [n] bytes starting at [s1] with [s2] and return 0 if they match, 55 /* Compare [n] bytes starting at [s1] with [s2] and return 0 if they match,
50 * 1 if they don't. Time taken to perform the comparison is only dependent on 56 * 1 if they don't. Time taken to perform the comparison is only dependent on
51 * [n] and not on the relationship of the match between [s1] and [s2]. 57 * [n] and not on the relationship of the match between [s1] and [s2].
52 */ 58 */
(...skipping 20 matching lines...) Expand all
73 * data from [src] into the buffer encapsulated in state [state]. 79 * data from [src] into the buffer encapsulated in state [state].
74 * On success, return [src] and update [state]. 80 * On success, return [src] and update [state].
75 * On failure, return NULL, set remaining_len in state to -1. 81 * On failure, return NULL, set remaining_len in state to -1.
76 * 82 *
77 * Useful for iterating through a structure to populate a binary blob. After the 83 * Useful for iterating through a structure to populate a binary blob. After the
78 * first failure (buffer overrun), successive calls will always fail. 84 * first failure (buffer overrun), successive calls will always fail.
79 */ 85 */
80 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, uint64_t len); 86 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, uint64_t len);
81 87
82 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ 88 #endif /* VBOOT_REFERENCE_UTILITY_H_ */
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/cgptlib/tests/cgpt_test.c ('k') | src/platform/vboot_reference/common/utility_stub.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698