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

Side by Side Diff: firmware/lib/utility.c

Issue 3186024: Fix utility.c to compile on MSVC. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | firmware/version.c » ('j') | 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 * Utility functions that need to be built as part of the firmware. 5 * Utility functions that need to be built as part of the firmware.
6 */ 6 */
7 7
8 #include "sysincludes.h"
8 #include "utility.h" 9 #include "utility.h"
9 10
10 void* Memset(void* d, const uint8_t c, uint64_t n) { 11 void* Memset(void* d, const uint8_t c, uint64_t n) {
11 uint8_t* dest = d; /* the only way to keep both cl and gcc happy */ 12 uint8_t* dest = d; /* the only way to keep both cl and gcc happy */
12 while (n--) { 13 while (n--) {
13 *dest++ = c; 14 *dest++ = c;
14 } 15 }
15 return dest; 16 return dest;
16 } 17 }
17 18
18 int SafeMemcmp(const void* s1, const void* s2, size_t n) { 19 int SafeMemcmp(const void* s1, const void* s2, size_t n) {
20 const unsigned char* us1 = s1;
21 const unsigned char* us2 = s2;
19 int result = 0; 22 int result = 0;
23
20 if (0 == n) 24 if (0 == n)
21 return 1; 25 return 1;
22 26
23 const unsigned char* us1 = s1;
24 const unsigned char* us2 = s2;
25 /* Code snippet without data-dependent branch due to 27 /* Code snippet without data-dependent branch due to
26 * Nate Lawson (nate@root.org) of Root Labs. */ 28 * Nate Lawson (nate@root.org) of Root Labs. */
27 while (n--) 29 while (n--)
28 result |= *us1++ ^ *us2++; 30 result |= *us1++ ^ *us2++;
29 31
30 return result != 0; 32 return result != 0;
31 } 33 }
OLDNEW
« no previous file with comments | « no previous file | firmware/version.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698