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. */ /* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, color)\ #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 b = (byte)((uint)color >> 24);\
byte c = (byte)((uint)color >> 16);\ byte c = (byte)((uint)color >> 16);\
byte d = (byte)((uint)color >> 8);\ 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. */ /* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, f, color)\ #define declare_unpack_color(a, b, c, d, e, f, color)\
byte a = (byte)(color >> 40);\ byte a = (byte)((uint64_t)color >> 40);\
byte b = (byte)(color >> 32);\ byte b = (byte)((uint64_t)color >> 32);\
byte c = (byte)((uint)color >> 24);\ byte c = (byte)((uint)color >> 24);\
byte d = (byte)((uint)color >> 16);\ byte d = (byte)((uint)color >> 16);\
byte e = (byte)((uint)color >> 8);\ 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. */ /* Unpack a color into its bytes. */
#define declare_unpack_color(a, b, c, d, e, f, g, color)\ #define declare_unpack_color(a, b, c, d, e, f, g, color)\
byte a = (byte)(color >> 48);\ byte a = (byte)((uint64_t)color >> 48);\
byte b = (byte)(color >> 40);\ byte b = (byte)((uint64_t)color >> 40);\
byte c = (byte)(color >> 32);\ byte c = (byte)((uint64_t)color >> 32);\
byte d = (byte)((uint)color >> 24);\ byte d = (byte)((uint)color >> 24);\
byte e = (byte)((uint)color >> 16);\ byte e = (byte)((uint)color >> 16);\
byte f = (byte)((uint)color >> 8);\ 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 #if arch_is_big_endian
/* Unpack a color into 32 bit chunks. */ /* Unpack a color into 32 bit chunks. */
# define declare_unpack_color(abcd, efgh, color)\ # define declare_unpack_color(abcd, efgh, color)\
bits32 abcd = (bits32)((color) >> 32);\ bits32 abcd = (bits32)((uint64_t)(color) >> 32);\
bits32 efgh = (bits32)(color) bits32 efgh = (bits32)(color)
#else #else
/* Unpack a color into 32 bit chunks. */ /* Unpack a color into 32 bit chunks. */
# define declare_unpack_color(abcd, efgh, color)\ # define declare_unpack_color(abcd, efgh, color)\
bits32 abcd = (bits32)((0x000000ff & ((color) >> 56)) |\ bits32 abcd = (bits32)((0x000000ff & ((uint64_t)(color) >> 56)) |\
(0x0000ff00 & ((color) >> 40)) |\ (0x0000ff00 & ((uint64_t)(color) >> 40)) |\
(0x00ff0000 & ((color) >> 24)) |\ (0x00ff0000 & ((color) >> 24)) |\
(0xff000000 & ((color) >> 8)));\ (0xff000000 & ((color) >> 8)));\
bits32 efgh = (bits32)((0x000000ff & ((color) >> 24)) |\ bits32 efgh = (bits32)((0x000000ff & ((color) >> 24)) |\

View file

@ -233,7 +233,7 @@ gx_dc_ht_colored_write(
if (num_comps > 8 * sizeof(uint)) { if (num_comps > 8 * sizeof(uint)) {
tmp_mask = (uint)plane_mask; tmp_mask = (uint)plane_mask;
req_size += enc_u_sizew(tmp_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); req_size += enc_u_sizew(tmp_mask);
} else { } else {
tmp_mask = (uint)plane_mask; tmp_mask = (uint)plane_mask;
@ -298,7 +298,7 @@ gx_dc_ht_colored_write(
if (num_comps > 8 * sizeof(uint)) { if (num_comps > 8 * sizeof(uint)) {
tmp_mask = (uint)plane_mask; tmp_mask = (uint)plane_mask;
enc_u_putw(tmp_mask, pdata); 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); enc_u_putw(tmp_mask, pdata);
} else { } else {
tmp_mask = (uint)plane_mask; tmp_mask = (uint)plane_mask;
@ -418,12 +418,11 @@ gx_dc_ht_colored_read(
if (size < 1) if (size < 1)
return_error(gs_error_rangecheck); return_error(gs_error_rangecheck);
if (num_comps > 8 * sizeof(uint)) { if (num_comps > 8 * sizeof(uint)) {
enc_u_getw(tmp_mask, pdata); enc_u_getw(tmp_mask, pdata);
plane_mask = (gx_color_index)tmp_mask; plane_mask = (gx_color_index)tmp_mask;
enc_u_getw(tmp_mask, pdata); 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 { } else {
enc_u_getw(tmp_mask, pdata); enc_u_getw(tmp_mask, pdata);
plane_mask = (gx_color_index)tmp_mask; plane_mask = (gx_color_index)tmp_mask;

View file

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