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 * Stub implementations of utility functions which call their linux-specific | 5 * Stub implementations of utility functions which call their linux-specific |
6 * equivalents. | 6 * equivalents. |
7 */ | 7 */ |
8 | 8 |
9 #define _STUB_IMPLEMENTATION_ | 9 #define _STUB_IMPLEMENTATION_ |
10 #include "utility.h" | 10 #include "utility.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 void Free(void* ptr) { | 43 void Free(void* ptr) { |
44 free(ptr); | 44 free(ptr); |
45 } | 45 } |
46 | 46 |
47 int Memcmp(const void* src1, const void* src2, size_t n) { | 47 int Memcmp(const void* src1, const void* src2, size_t n) { |
48 return memcmp(src1, src2, n); | 48 return memcmp(src1, src2, n); |
49 } | 49 } |
50 | 50 |
51 void* Memcpy(void* dest, const void* src, size_t n) { | 51 void* Memcpy(void* dest, const void* src, uint64_t n) { |
52 return memcpy(dest, src, n); | 52 return memcpy(dest, src, (size_t)n); |
53 } | 53 } |
54 | 54 |
55 void* Memset(void* dest, const uint8_t c, size_t n) { | 55 void* Memset(void* d, const uint8_t c, uint64_t n) { |
| 56 uint8_t *dest = d; /* the only way to keep both cl and gcc happy */ |
56 while (n--) { | 57 while (n--) { |
57 *((uint8_t*)dest++) = c; | 58 *dest++ = c; |
58 } | 59 } |
59 return dest; | 60 return dest; |
60 } | 61 } |
61 | 62 |
62 int SafeMemcmp(const void* s1, const void* s2, size_t n) { | 63 int SafeMemcmp(const void* s1, const void* s2, size_t n) { |
63 int match = 0; | 64 int match = 0; |
64 const unsigned char* us1 = s1; | 65 const unsigned char* us1 = s1; |
65 const unsigned char* us2 = s2; | 66 const unsigned char* us2 = s2; |
66 while (n--) { | 67 while (n--) { |
67 if (*us1++ != *us2++) | 68 if (*us1++ != *us2++) |
68 match = 1; | 69 match = 1; |
69 } | 70 } |
70 | 71 |
71 return match; | 72 return match; |
72 } | 73 } |
OLD | NEW |