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

Side by Side Diff: crosstest/mem_intrin.cpp

Issue 389683003: Remove memcpy test workaround for name mangling substitutions. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 5 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 | « crosstest/mem_intrin.h ('k') | crosstest/mem_intrin_main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Simple sanity test of memcpy, memmove, and memset intrinsics. 2 * Simple sanity test of memcpy, memmove, and memset intrinsics.
3 * (fixed length buffers, variable length buffers, etc.) 3 * (fixed length buffers, variable length buffers, etc.)
4 */ 4 */
5 5
6 #include <stdint.h> /* cstdint requires -std=c++0x or higher */ 6 #include <stdint.h> /* cstdint requires -std=c++0x or higher */
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "mem_intrin.h" 10 #include "mem_intrin.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 #define NWORDS 32 43 #define NWORDS 32
44 #define BYTE_LENGTH (NWORDS * sizeof(elem_t)) 44 #define BYTE_LENGTH (NWORDS * sizeof(elem_t))
45 45
46 int memcpy_test_fixed_len(uint8_t init) { 46 int memcpy_test_fixed_len(uint8_t init) {
47 elem_t buf[NWORDS]; 47 elem_t buf[NWORDS];
48 elem_t buf2[NWORDS]; 48 elem_t buf2[NWORDS];
49 reset_buf((uint8_t *)buf, init, BYTE_LENGTH); 49 reset_buf((uint8_t *)buf, init, BYTE_LENGTH);
50 memcpy((void *)buf2, (void *)buf, BYTE_LENGTH); 50 memcpy((void *)buf2, (void *)buf, BYTE_LENGTH);
51 return fletcher_checksum((uint8_t*)buf2, BYTE_LENGTH); 51 return fletcher_checksum((uint8_t *)buf2, BYTE_LENGTH);
52 } 52 }
53 53
54 int memmove_test_fixed_len(uint8_t init) { 54 int memmove_test_fixed_len(uint8_t init) {
55 elem_t buf[NWORDS]; 55 elem_t buf[NWORDS];
56 reset_buf((uint8_t *)buf, init, BYTE_LENGTH); 56 reset_buf((uint8_t *)buf, init, BYTE_LENGTH);
57 memmove((void *)(buf + 4), (void *)buf, BYTE_LENGTH - (4 * sizeof(elem_t))); 57 memmove((void *)(buf + 4), (void *)buf, BYTE_LENGTH - (4 * sizeof(elem_t)));
58 return fletcher_checksum((uint8_t*)buf + 4, BYTE_LENGTH - 4); 58 return fletcher_checksum((uint8_t *)buf + 4, BYTE_LENGTH - 4);
59 } 59 }
60 60
61 int memset_test_fixed_len(uint8_t init) { 61 int memset_test_fixed_len(uint8_t init) {
62 elem_t buf[NWORDS]; 62 elem_t buf[NWORDS];
63 memset((void *)buf, init, BYTE_LENGTH); 63 memset((void *)buf, init, BYTE_LENGTH);
64 return fletcher_checksum((uint8_t*)buf, BYTE_LENGTH); 64 return fletcher_checksum((uint8_t *)buf, BYTE_LENGTH);
65 } 65 }
66 66
67 int memcpy_test(uint8_t *buf, void *buf2, uint8_t init, size_t length) { 67 int memcpy_test(uint8_t *buf, uint8_t *buf2, uint8_t init, size_t length) {
68 reset_buf(buf, init, length); 68 reset_buf(buf, init, length);
69 memcpy(buf2, (void *)buf, length); 69 memcpy((void *)buf2, (void *)buf, length);
70 return fletcher_checksum((uint8_t *)buf2, length); 70 return fletcher_checksum(buf2, length);
71 } 71 }
72 72
73 int memmove_test(uint8_t *buf, void *buf2, uint8_t init, size_t length) { 73 int memmove_test(uint8_t *buf, uint8_t *buf2, uint8_t init, size_t length) {
74 int sum1; 74 int sum1;
75 int sum2; 75 int sum2;
76 const int overlap_bytes = 4 * sizeof(elem_t); 76 const int overlap_bytes = 4 * sizeof(elem_t);
77 if (length <= overlap_bytes) 77 if (length <= overlap_bytes)
78 return 0; 78 return 0;
79 uint8_t *overlap_buf = buf + overlap_bytes; 79 uint8_t *overlap_buf = buf + overlap_bytes;
80 size_t reduced_length = length - overlap_bytes; 80 size_t reduced_length = length - overlap_bytes;
81 reset_buf(buf, init, length); 81 reset_buf(buf, init, length);
82 82
83 /* Test w/ overlap. */ 83 /* Test w/ overlap. */
84 memmove((void *)overlap_buf, (void *)buf, reduced_length); 84 memmove((void *)overlap_buf, (void *)buf, reduced_length);
85 sum1 = fletcher_checksum(overlap_buf, reduced_length); 85 sum1 = fletcher_checksum(overlap_buf, reduced_length);
86 /* Test w/out overlap. */ 86 /* Test w/out overlap. */
87 memmove(buf2, (void *)buf, length); 87 memmove((void *)buf2, (void *)buf, length);
88 sum2 = fletcher_checksum((uint8_t *)buf2, length); 88 sum2 = fletcher_checksum(buf2, length);
89 return sum1 + sum2; 89 return sum1 + sum2;
90 } 90 }
91 91
92 int memset_test(uint8_t *buf, void *buf2, uint8_t init, size_t length) { 92 int memset_test(uint8_t *buf, uint8_t *buf2, uint8_t init, size_t length) {
93 memset((void *)buf, init, length); 93 memset((void *)buf, init, length);
94 memset(buf2, init + 4, length); 94 memset((void *)buf2, init + 4, length);
95 return fletcher_checksum(buf, length) + 95 return fletcher_checksum(buf, length) + fletcher_checksum(buf2, length);
96 fletcher_checksum((uint8_t *)buf2, length);
97 } 96 }
OLDNEW
« no previous file with comments | « crosstest/mem_intrin.h ('k') | crosstest/mem_intrin_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698