gs: avoid stupid shifts by casting to uint64_t

This commit is contained in:
cinap_lenrek 2019-05-03 21:10:01 +02:00
parent 2994fccbe1
commit 5f5caa6733
6 changed files with 19 additions and 20 deletions

View file

@ -62,7 +62,7 @@ mem_full_alpha_device("image40", 40, 0, mem_open,
/* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, color)\
byte a = (byte)(color >> 32);\
byte a = (byte)((uint64_t)color >> 32);\
byte b = (byte)((uint)color >> 24);\
byte c = (byte)((uint)color >> 16);\
byte d = (byte)((uint)color >> 8);\

View file

@ -62,8 +62,8 @@ mem_full_alpha_device("image48", 48, 0, mem_open,
/* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, f, color)\
byte a = (byte)(color >> 40);\
byte b = (byte)(color >> 32);\
byte a = (byte)((uint64_t)color >> 40);\
byte b = (byte)((uint64_t)color >> 32);\
byte c = (byte)((uint)color >> 24);\
byte d = (byte)((uint)color >> 16);\
byte e = (byte)((uint)color >> 8);\

View file

@ -62,9 +62,9 @@ mem_full_alpha_device("image56", 56, 0, mem_open,
/* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, f, g, color)\
byte a = (byte)(color >> 48);\
byte b = (byte)(color >> 40);\
byte c = (byte)(color >> 32);\
byte a = (byte)((uint64_t)color >> 48);\
byte b = (byte)((uint64_t)color >> 40);\
byte c = (byte)((uint64_t)color >> 32);\
byte d = (byte)((uint)color >> 24);\
byte e = (byte)((uint)color >> 16);\
byte f = (byte)((uint)color >> 8);\

View file

@ -67,13 +67,13 @@ mem_full_alpha_device("image64", 64, 0, mem_open,
#if arch_is_big_endian
/* Unpack a color into 32 bit chunks. */
# define declare_unpack_color(abcd, efgh, color)\
bits32 abcd = (bits32)((color) >> 32);\
bits32 abcd = (bits32)((uint64_t)(color) >> 32);\
bits32 efgh = (bits32)(color)
#else
/* Unpack a color into 32 bit chunks. */
# define declare_unpack_color(abcd, efgh, color)\
bits32 abcd = (bits32)((0x000000ff & ((color) >> 56)) |\
(0x0000ff00 & ((color) >> 40)) |\
bits32 abcd = (bits32)((0x000000ff & ((uint64_t)(color) >> 56)) |\
(0x0000ff00 & ((uint64_t)(color) >> 40)) |\
(0x00ff0000 & ((color) >> 24)) |\
(0xff000000 & ((color) >> 8)));\
bits32 efgh = (bits32)((0x000000ff & ((color) >> 24)) |\

View file

@ -233,7 +233,7 @@ gx_dc_ht_colored_write(
if (num_comps > 8 * sizeof(uint)) {
tmp_mask = (uint)plane_mask;
req_size += enc_u_sizew(tmp_mask);
tmp_mask = (uint)(plane_mask >> (8 * sizeof(uint)));
tmp_mask = (uint)((uint64_t)plane_mask >> (8 * sizeof(uint)));
req_size += enc_u_sizew(tmp_mask);
} else {
tmp_mask = (uint)plane_mask;
@ -298,7 +298,7 @@ gx_dc_ht_colored_write(
if (num_comps > 8 * sizeof(uint)) {
tmp_mask = (uint)plane_mask;
enc_u_putw(tmp_mask, pdata);
tmp_mask = (uint)(plane_mask >> (8 * sizeof(uint)));
tmp_mask = (uint)((uint64_t)plane_mask >> (8 * sizeof(uint)));
enc_u_putw(tmp_mask, pdata);
} else {
tmp_mask = (uint)plane_mask;
@ -418,17 +418,16 @@ gx_dc_ht_colored_read(
if (size < 1)
return_error(gs_error_rangecheck);
if (num_comps > 8 * sizeof(uint)) {
enc_u_getw(tmp_mask, pdata);
plane_mask = (gx_color_index)tmp_mask;
enc_u_getw(tmp_mask, pdata);
plane_mask = (gx_color_index)tmp_mask << (8 * sizeof(uint));
plane_mask = (gx_color_index)((uint64_t)tmp_mask << (8 * sizeof(uint)));
} else {
enc_u_getw(tmp_mask, pdata);
plane_mask = (gx_color_index)tmp_mask;
}
devc.colors.colored.plane_mask = plane_mask;
devc.colors.colored.plane_mask = plane_mask;
for (i = 0; i < num_comps; i++, plane_mask >>= 1) {
if ((plane_mask & 0x1) != 0) {
if (size - (pdata - pdata_start) < 1)
@ -437,7 +436,7 @@ gx_dc_ht_colored_read(
} else
devc.colors.colored.c_level[i] = 0;
}
size -= pdata - pdata_start;
size -= pdata - pdata_start;
}
if ((flag_bits & dc_ht_colored_alpha_is_max) != 0)

View file

@ -559,16 +559,16 @@ in: /* Initialize for a new page. */
/* For cases with an even number of bytes */
case 8:
data = *cbp++;
delta = ((gx_color_index)
((data & 0xf0) << 4) + (data & 0x0f)) << 48;
delta = (gx_color_index)(((uint64_t)
((data & 0xf0) << 4) + (data & 0x0f)) << 48);
case 6:
data = *cbp++;
delta |= ((gx_color_index)
((data & 0xf0) << 4) + (data & 0x0f)) << 32;
delta |= (gx_color_index)(((uint64_t)
(((data & 0xf0) << 4) + (data & 0x0f))) << 32);
case 4:
data = *cbp++;
delta |= ((gx_color_index)
((data & 0xf0) << 4) + (data & 0x0f)) << 16;
(((data & 0xf0) << 4) + (data & 0x0f))) << 16;
case 2:
data = *cbp++;
delta |= ((gx_color_index)