Commit d0fb9df5 authored by Manuel Stoeckl's avatar Manuel Stoeckl
Browse files

Fix some little-endian-only patterns

parent c2c88893
Pipeline #58518 passed with stages
in 2 minutes and 50 seconds
......@@ -61,8 +61,8 @@ size_t run_interval_diff_C(const int diff_window_size,
clear_exit = true;
break;
}
size_t last_header = dc++;
diff[last_header] = (uint64_t)((i - 1) * 2);
uint32_t *ctrl_blocks = (uint32_t *)&diff[dc++];
ctrl_blocks[0] = (uint32_t)((i - 1) * 2);
diff[dc++] = changed_val;
base[i - 1] = changed_val;
// changed_val != base_val, difference occurs at early
......@@ -80,7 +80,7 @@ size_t run_interval_diff_C(const int diff_window_size,
nskip *= (base_val == changed_val);
}
dc -= nskip;
diff[last_header] |= (uint64_t)((i - nskip) * 2) << 32;
ctrl_blocks[1] = (uint32_t)((i - nskip) * 2);
/* our sentinel, at worst, causes overcopy by one. this
* is fine
*/
......
......@@ -1404,31 +1404,33 @@ int main_interface_loop(int chanfd, int progfd, int linkfd,
/* It's possible, but very very unlikely, that waypipe gets closed
* while Wayland protocol messages are being written to the program
* and the most recent message was only partially written. */
if (!display_side) {
if (chan_msg.proto_write.zone_start !=
chan_msg.proto_write.zone_end) {
wp_debug("Final write to %s was incomplete, %d/%d",
progdesc,
chan_msg.proto_write.zone_start,
chan_msg.proto_write.zone_end);
}
exit_code = ERR_FATAL;
if (chan_msg.proto_write.zone_start != chan_msg.proto_write.zone_end) {
wp_debug("Final write to %s was incomplete, %d/%d", progdesc,
chan_msg.proto_write.zone_start,
chan_msg.proto_write.zone_end);
}
if (!display_side && progfd != -1) {
if (exit_code == ERR_FATAL) {
/* wl_display@1, code 3: waypipe internal error */
uint32_t fatal_msg[11] = {0x1, 44u << 16, 0x1, 3, 23,
0x70796177, 0x20657069, 0x65746e69,
0x6c616e72, 0x72726520, 0x0000726f};
uint32_t fatal_msg[11] = {0x1, 44u << 16, 0x1, 3, 23, 0,
0, 0, 0, 0, 0};
memcpy(fatal_msg + 5, "waypipe internal error", 23);
if (write(progfd, &fatal_msg, sizeof(fatal_msg)) ==
-1) {
wp_error("Failed to send waypipe error notification");
wp_error("Failed to send waypipe error notification: %s",
strerror(errno));
}
} else if (exit_code == ERR_NOMEM) {
/* wl_display@1, code 2: no memory */
uint32_t nomem_msg[8] = {0x1, 32u << 16, 0x1, 2, 10,
0x6d206f6e, 0x726f6d65, 0x00000079};
uint32_t nomem_msg[8] = {
0x1, 32u << 16, 0x1, 2, 10, 0, 0};
memcpy(nomem_msg + 5, "no memory", 10);
if (write(progfd, &nomem_msg, sizeof(nomem_msg)) ==
-1) {
wp_error("Failed to send OOM notification");
wp_error("Failed to send OOM notification: %s",
strerror(errno));
}
}
}
......
......@@ -98,6 +98,19 @@ struct wire_test {
int nwords;
};
static inline uint32_t pack_u32(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3)
{
union {
uint8_t s[4];
uint32_t v;
} u;
u.s[0] = a0;
u.s[1] = a1;
u.s[2] = a2;
u.s[3] = a3;
return u.v;
}
log_handler_func_t log_funcs[2] = {test_log_handler, test_log_handler};
int main(int argc, char **argv)
{
......@@ -126,25 +139,46 @@ int main(int argc, char **argv)
struct wire_test tests[] = {
{call_xtype_req_blue, &intf_xtype.funcs[0][0], {7771},
{8, 0x61626162, 0x00616263, 4441,
yobj.obj_id, 3331, 4442,
xobj.obj_id, 0, 4443},
{8, pack_u32(0x62, 0x61, 0x62, 0x61),
pack_u32(0x63, 0x62,
0x61,
0),
4441, yobj.obj_id, 3331,
4442, xobj.obj_id, 0,
4443},
1, 10},
{call_xtype_evt_yellow, &intf_xtype.funcs[1][0], {0},
{4441}, 0, 1},
{call_ytype_req_green, &intf_ytype.funcs[0][0], {7771},
{4441, 4, 0x00616562, 0, 5, 0x63626263,
0x99999900, xobj.obj_id,
8, 0x80818081,
0x99999990},
{4441, 4, pack_u32(0x62, 0x65, 0x61, 0),
0, 5,
pack_u32(0x63, 0x62,
0x62,
0x63),
pack_u32(0, 0x99, 0x99,
0x99),
xobj.obj_id, 8,
pack_u32(0x81, 0x80,
0x81,
0x80),
pack_u32(0x90, 0x99,
0x99,
0x99)},
1, 11},
{call_ytype_evt_red, &intf_ytype.funcs[1][0],
{8881, 8882, 8883},
{7770, 33330, 7771, 33331, 33332, 7773,
33333, 44440, 6,
0x62616362, 0x99990061,
3, 0x11808080, 99990, 0,
yobj.obj_id,
pack_u32(0x62, 0x63,
0x61,
0x62),
pack_u32(0x61, 0, 0x99,
0x99),
3,
pack_u32(0x80, 0x80,
0x80,
0x11),
99990, 0, yobj.obj_id,
xobj.obj_id},
3, 17}};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment