6 #include "../../../none/tests/s390x/opcodes.h"
8 /* Define various input buffers. */
10 /* U+0000 to U+d7ff: Result is 2 bytes for each uint32_t
11 U+dc00 to U+ffff: Result is 2 bytes for each uint32_t */
12 uint32_t pattern2
[] = {
13 0x0000, 0xd7ff, /* corner cases */
14 0xdc00, 0xffff, /* corner cases */
15 0xabba, 0xf00d, 0xd00f, 0x1234 /* misc */
18 /* U+00010000 to U+0010ffff: Result is 4 bytes for each uint32_t */
19 uint32_t pattern4
[] = {
20 0x00010000, 0x0010ffff, /* corner cases */
21 0x00010123, 0x00023456, 0x000789ab, 0x00100000 /* misc */
25 do_cu42(uint16_t *dst
, uint64_t dst_len
, uint32_t *src
, uint64_t src_len
)
27 /* build up the register pairs */
28 register uint32_t *source
asm("4") = src
;
29 register uint64_t source_len
asm("5") = src_len
;
30 register uint16_t *dest
asm("2") = dst
;
31 register uint64_t dest_len
asm("3") = dst_len
;
35 : "+d"(dest
), "+d"(source
), "+d"(source_len
), "+d"(dest_len
)
42 /*------------------------------------------------------------*/
43 /* Write to a too small buffer */
44 /*------------------------------------------------------------*/
46 /* Write 2 bytes into buffer of length 1 */
47 do_cu42(malloc(1), 10, pattern2
, 4); // complaint (2 bytes)
49 /* Write 2 bytes into buffer of length 2 */
50 do_cu42(malloc(2), 10, pattern2
, 4); // no complaint
52 /* Write 4 bytes into buffer of length 1 */
53 do_cu42(malloc(1), 10, pattern4
, 4); // complaint (4 bytes)
55 /* Write 4 bytes into buffer of length 2 */
56 do_cu42(malloc(2), 10, pattern4
, 4); // complaint (4 bytes)
58 /* Write 4 bytes into buffer of length 3 */
59 do_cu42(malloc(3), 10, pattern4
, 4); // complaint (4 bytes)
61 /* Write 4 bytes into buffer of length 4 */
62 do_cu42(malloc(4), 10, pattern4
, 4); // no complaint
64 /*------------------------------------------------------------*/
65 /* Read uninitialised data */
66 /*------------------------------------------------------------*/
70 /* Input buffer is completely uninitialised */
72 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // complaint
74 /* Read 4 bytes from input buffer. First byte is uninitialised */
76 input
[1] = input
[2] = input
[3] = 0x0;
77 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // complaint
79 /* Read 4 bytes from input buffer. Second byte is uninitialised */
81 input
[0] = input
[2] = input
[3] = 0x0;
82 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // complaint
84 /* Read 4 bytes from input buffer. Third byte is uninitialised */
86 input
[0] = input
[1] = input
[3] = 0x0;
87 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // complaint
89 /* Read 4 bytes from input buffer. Fourth byte is uninitialised */
91 input
[0] = input
[1] = input
[2] = 0x0;
92 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // complaint
94 /* Read 4 bytes from input buffer. All bytes are initialised */
97 do_cu42(buf
, sizeof buf
, (void *)input
, 4); // no complaint
99 /* Read 8 bytes from input buffer. This iterates once. In the 1st
100 iteration all input bytes are initialised in the 2nd iteration all
101 input bytes are uninitialised. */
104 do_cu42(buf
, sizeof buf
, (void *)input
, 8); // complaint
108 // do_cu42(NULL, 10, pattern1, sizeof pattern1); // complaint