forked from len0rd/rockbox
Fix dangerous casts
On Windows 64-bit, the size of long is 32-bit, thus any pointer to long cast is not valid. In any case, one should use intptr_t and ptrdiff_t when casting to integers. This commit attempts to fix all instances reported by GCC. When relevant, I replaced code by the macros PTR_ADD, ALIGN_UP from system.h Change-Id: I2273b0e8465d3c4689824717ed5afa5ed238a2dc
This commit is contained in:
parent
1245c5fe61
commit
d7871914ac
27 changed files with 69 additions and 66 deletions
|
@ -2493,7 +2493,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
||||||
skin_buffer = wps_buffer;
|
skin_buffer = wps_buffer;
|
||||||
wps_buffer = (char*)buf;
|
wps_buffer = (char*)buf;
|
||||||
}
|
}
|
||||||
skin_buffer = (void *)(((unsigned long)skin_buffer + 3) & ~3);
|
skin_buffer = ALIGN_UP(skin_buffer, 4); /* align on 4-byte boundary */
|
||||||
buffersize -= 3;
|
buffersize -= 3;
|
||||||
#ifdef HAVE_BACKDROP_IMAGE
|
#ifdef HAVE_BACKDROP_IMAGE
|
||||||
backdrop_filename = "-";
|
backdrop_filename = "-";
|
||||||
|
|
|
@ -215,7 +215,7 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters,
|
||||||
count++;
|
count++;
|
||||||
if (next)
|
if (next)
|
||||||
{
|
{
|
||||||
pos = buf_size - ((long)next - (long)buf) - 1;
|
pos = buf_size - ((intptr_t)next - (intptr_t)buf) - 1;
|
||||||
memmove(buf, next, pos);
|
memmove(buf, next, pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -2082,7 +2082,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line)
|
||||||
S_sfx[indexnum].priority = (int)value;
|
S_sfx[indexnum].priority = (int)value;
|
||||||
else
|
else
|
||||||
if (!strcasecmp(key,deh_sfxinfo[3])) // Zero 1
|
if (!strcasecmp(key,deh_sfxinfo[3])) // Zero 1
|
||||||
S_sfx[indexnum].link = (sfxinfo_t *)((long) value);
|
S_sfx[indexnum].link = (sfxinfo_t *)((intptr_t) value);
|
||||||
else
|
else
|
||||||
if (!strcasecmp(key,deh_sfxinfo[4])) // Zero 2
|
if (!strcasecmp(key,deh_sfxinfo[4])) // Zero 2
|
||||||
S_sfx[indexnum].pitch = (int)value;
|
S_sfx[indexnum].pitch = (int)value;
|
||||||
|
@ -2091,7 +2091,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line)
|
||||||
S_sfx[indexnum].volume = (int)value;
|
S_sfx[indexnum].volume = (int)value;
|
||||||
else
|
else
|
||||||
if (!strcasecmp(key,deh_sfxinfo[6])) // Zero 4
|
if (!strcasecmp(key,deh_sfxinfo[6])) // Zero 4
|
||||||
S_sfx[indexnum].data = (void *) ((long) value); // killough 5/3/98: changed cast
|
S_sfx[indexnum].data = (void *) ((intptr_t) value); // killough 5/3/98: changed cast
|
||||||
else
|
else
|
||||||
if (!strcasecmp(key,deh_sfxinfo[7])) // Neg. One 1
|
if (!strcasecmp(key,deh_sfxinfo[7])) // Neg. One 1
|
||||||
S_sfx[indexnum].usefulness = (int)value;
|
S_sfx[indexnum].usefulness = (int)value;
|
||||||
|
|
|
@ -807,7 +807,7 @@ void D_DoomMainSetup(void)
|
||||||
// for statistics driver
|
// for statistics driver
|
||||||
extern void* statcopy;
|
extern void* statcopy;
|
||||||
|
|
||||||
statcopy = (void*)(long)atoi(myargv[p+1]);
|
statcopy = (void*)(intptr_t)atoi(myargv[p+1]);
|
||||||
printf ("External statistics registered.\n");
|
printf ("External statistics registered.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ byte *save_p;
|
||||||
|
|
||||||
// Pads save_p to a 4-byte boundary
|
// Pads save_p to a 4-byte boundary
|
||||||
// so that the load/save works on SGI&Gecko.
|
// so that the load/save works on SGI&Gecko.
|
||||||
#define PADSAVEP() do { save_p += (4 - ((unsigned long) save_p & 3)) & 3; } while (0)
|
#define PADSAVEP() do { save_p += (4 - ((intptr_t) save_p & 3)) & 3; } while (0)
|
||||||
//
|
//
|
||||||
// P_ArchivePlayers
|
// P_ArchivePlayers
|
||||||
//
|
//
|
||||||
|
@ -95,7 +95,7 @@ void P_UnArchivePlayers (void)
|
||||||
for (j=0 ; j<NUMPSPRITES ; j++)
|
for (j=0 ; j<NUMPSPRITES ; j++)
|
||||||
if (players[i]. psprites[j].state)
|
if (players[i]. psprites[j].state)
|
||||||
players[i]. psprites[j].state =
|
players[i]. psprites[j].state =
|
||||||
&states[ (unsigned long)players[i].psprites[j].state ];
|
&states[ (intptr_t)players[i].psprites[j].state ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ void P_ThinkerToIndex(void)
|
||||||
number_of_thinkers = 0;
|
number_of_thinkers = 0;
|
||||||
for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
|
for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
|
||||||
if (th->function == P_MobjThinker)
|
if (th->function == P_MobjThinker)
|
||||||
th->prev = (thinker_t *)(long)(++number_of_thinkers);
|
th->prev = (thinker_t *)(intptr_t)(++number_of_thinkers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// phares 9/13/98: Moved this code outside of P_ArchiveThinkers so the
|
// phares 9/13/98: Moved this code outside of P_ArchiveThinkers so the
|
||||||
|
@ -448,10 +448,10 @@ void P_UnArchiveThinkers (void)
|
||||||
PADSAVEP();
|
PADSAVEP();
|
||||||
memcpy (mobj, save_p, sizeof(mobj_t));
|
memcpy (mobj, save_p, sizeof(mobj_t));
|
||||||
save_p += sizeof(mobj_t);
|
save_p += sizeof(mobj_t);
|
||||||
mobj->state = states + (unsigned long) mobj->state;
|
mobj->state = states + (intptr_t) mobj->state;
|
||||||
|
|
||||||
if (mobj->player)
|
if (mobj->player)
|
||||||
(mobj->player = &players[(unsigned long) mobj->player - 1]) -> mo = mobj;
|
(mobj->player = &players[(intptr_t) mobj->player - 1]) -> mo = mobj;
|
||||||
|
|
||||||
P_SetThingPosition (mobj);
|
P_SetThingPosition (mobj);
|
||||||
mobj->info = &mobjinfo[mobj->type];
|
mobj->info = &mobjinfo[mobj->type];
|
||||||
|
@ -770,7 +770,7 @@ void P_UnArchiveSpecials (void)
|
||||||
ceiling_t *ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL);
|
ceiling_t *ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL);
|
||||||
memcpy (ceiling, save_p, sizeof(*ceiling));
|
memcpy (ceiling, save_p, sizeof(*ceiling));
|
||||||
save_p += sizeof(*ceiling);
|
save_p += sizeof(*ceiling);
|
||||||
ceiling->sector = §ors[(unsigned long)ceiling->sector];
|
ceiling->sector = §ors[(intptr_t)ceiling->sector];
|
||||||
ceiling->sector->ceilingdata = ceiling; //jff 2/22/98
|
ceiling->sector->ceilingdata = ceiling; //jff 2/22/98
|
||||||
|
|
||||||
if (ceiling->thinker.function)
|
if (ceiling->thinker.function)
|
||||||
|
@ -787,10 +787,10 @@ void P_UnArchiveSpecials (void)
|
||||||
vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);
|
vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);
|
||||||
memcpy (door, save_p, sizeof(*door));
|
memcpy (door, save_p, sizeof(*door));
|
||||||
save_p += sizeof(*door);
|
save_p += sizeof(*door);
|
||||||
door->sector = §ors[(unsigned long)door->sector];
|
door->sector = §ors[(intptr_t)door->sector];
|
||||||
|
|
||||||
//jff 1/31/98 unarchive line remembered by door as well
|
//jff 1/31/98 unarchive line remembered by door as well
|
||||||
door->line = (long)door->line!=-1? &lines[(unsigned long)door->line] : NULL;
|
door->line = (intptr_t)door->line!=-1? &lines[(intptr_t)door->line] : NULL;
|
||||||
|
|
||||||
door->sector->ceilingdata = door; //jff 2/22/98
|
door->sector->ceilingdata = door; //jff 2/22/98
|
||||||
door->thinker.function = T_VerticalDoor;
|
door->thinker.function = T_VerticalDoor;
|
||||||
|
@ -804,7 +804,7 @@ void P_UnArchiveSpecials (void)
|
||||||
floormove_t *floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL);
|
floormove_t *floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL);
|
||||||
memcpy (floor, save_p, sizeof(*floor));
|
memcpy (floor, save_p, sizeof(*floor));
|
||||||
save_p += sizeof(*floor);
|
save_p += sizeof(*floor);
|
||||||
floor->sector = §ors[(unsigned long)floor->sector];
|
floor->sector = §ors[(intptr_t)floor->sector];
|
||||||
floor->sector->floordata = floor; //jff 2/22/98
|
floor->sector->floordata = floor; //jff 2/22/98
|
||||||
floor->thinker.function = T_MoveFloor;
|
floor->thinker.function = T_MoveFloor;
|
||||||
P_AddThinker (&floor->thinker);
|
P_AddThinker (&floor->thinker);
|
||||||
|
@ -817,7 +817,7 @@ void P_UnArchiveSpecials (void)
|
||||||
plat_t *plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL);
|
plat_t *plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL);
|
||||||
memcpy (plat, save_p, sizeof(*plat));
|
memcpy (plat, save_p, sizeof(*plat));
|
||||||
save_p += sizeof(*plat);
|
save_p += sizeof(*plat);
|
||||||
plat->sector = §ors[(unsigned long)plat->sector];
|
plat->sector = §ors[(intptr_t)plat->sector];
|
||||||
plat->sector->floordata = plat; //jff 2/22/98
|
plat->sector->floordata = plat; //jff 2/22/98
|
||||||
|
|
||||||
if (plat->thinker.function)
|
if (plat->thinker.function)
|
||||||
|
@ -834,7 +834,7 @@ void P_UnArchiveSpecials (void)
|
||||||
lightflash_t *flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL);
|
lightflash_t *flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL);
|
||||||
memcpy (flash, save_p, sizeof(*flash));
|
memcpy (flash, save_p, sizeof(*flash));
|
||||||
save_p += sizeof(*flash);
|
save_p += sizeof(*flash);
|
||||||
flash->sector = §ors[(unsigned long)flash->sector];
|
flash->sector = §ors[(intptr_t)flash->sector];
|
||||||
flash->thinker.function = T_LightFlash;
|
flash->thinker.function = T_LightFlash;
|
||||||
P_AddThinker (&flash->thinker);
|
P_AddThinker (&flash->thinker);
|
||||||
break;
|
break;
|
||||||
|
@ -846,7 +846,7 @@ void P_UnArchiveSpecials (void)
|
||||||
strobe_t *strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL);
|
strobe_t *strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL);
|
||||||
memcpy (strobe, save_p, sizeof(*strobe));
|
memcpy (strobe, save_p, sizeof(*strobe));
|
||||||
save_p += sizeof(*strobe);
|
save_p += sizeof(*strobe);
|
||||||
strobe->sector = §ors[(unsigned long)strobe->sector];
|
strobe->sector = §ors[(intptr_t)strobe->sector];
|
||||||
strobe->thinker.function = T_StrobeFlash;
|
strobe->thinker.function = T_StrobeFlash;
|
||||||
P_AddThinker (&strobe->thinker);
|
P_AddThinker (&strobe->thinker);
|
||||||
break;
|
break;
|
||||||
|
@ -858,7 +858,7 @@ void P_UnArchiveSpecials (void)
|
||||||
glow_t *glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL);
|
glow_t *glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL);
|
||||||
memcpy (glow, save_p, sizeof(*glow));
|
memcpy (glow, save_p, sizeof(*glow));
|
||||||
save_p += sizeof(*glow);
|
save_p += sizeof(*glow);
|
||||||
glow->sector = §ors[(unsigned long)glow->sector];
|
glow->sector = §ors[(intptr_t)glow->sector];
|
||||||
glow->thinker.function = T_Glow;
|
glow->thinker.function = T_Glow;
|
||||||
P_AddThinker (&glow->thinker);
|
P_AddThinker (&glow->thinker);
|
||||||
break;
|
break;
|
||||||
|
@ -870,7 +870,7 @@ void P_UnArchiveSpecials (void)
|
||||||
fireflicker_t *flicker = Z_Malloc (sizeof(*flicker), PU_LEVEL, NULL);
|
fireflicker_t *flicker = Z_Malloc (sizeof(*flicker), PU_LEVEL, NULL);
|
||||||
memcpy (flicker, save_p, sizeof(*flicker));
|
memcpy (flicker, save_p, sizeof(*flicker));
|
||||||
save_p += sizeof(*flicker);
|
save_p += sizeof(*flicker);
|
||||||
flicker->sector = §ors[(unsigned long)flicker->sector];
|
flicker->sector = §ors[(intptr_t)flicker->sector];
|
||||||
flicker->thinker.function = T_FireFlicker;
|
flicker->thinker.function = T_FireFlicker;
|
||||||
P_AddThinker (&flicker->thinker);
|
P_AddThinker (&flicker->thinker);
|
||||||
break;
|
break;
|
||||||
|
@ -883,7 +883,7 @@ void P_UnArchiveSpecials (void)
|
||||||
elevator_t *elevator = Z_Malloc (sizeof(*elevator), PU_LEVEL, NULL);
|
elevator_t *elevator = Z_Malloc (sizeof(*elevator), PU_LEVEL, NULL);
|
||||||
memcpy (elevator, save_p, sizeof(*elevator));
|
memcpy (elevator, save_p, sizeof(*elevator));
|
||||||
save_p += sizeof(*elevator);
|
save_p += sizeof(*elevator);
|
||||||
elevator->sector = §ors[(unsigned long)elevator->sector];
|
elevator->sector = §ors[(intptr_t)elevator->sector];
|
||||||
elevator->sector->floordata = elevator; //jff 2/22/98
|
elevator->sector->floordata = elevator; //jff 2/22/98
|
||||||
elevator->sector->ceilingdata = elevator; //jff 2/22/98
|
elevator->sector->ceilingdata = elevator; //jff 2/22/98
|
||||||
elevator->thinker.function = T_MoveElevator;
|
elevator->thinker.function = T_MoveElevator;
|
||||||
|
|
|
@ -252,8 +252,8 @@ void Z_Init(void)
|
||||||
|
|
||||||
// Align on cache boundary
|
// Align on cache boundary
|
||||||
|
|
||||||
zone = (memblock_t *) ((unsigned long)zonebase + CACHE_ALIGN -
|
zone = (memblock_t *) ((intptr_t)zonebase + CACHE_ALIGN -
|
||||||
((unsigned long)zonebase & (CACHE_ALIGN-1)));
|
((intptr_t)zonebase & (CACHE_ALIGN-1)));
|
||||||
|
|
||||||
rover = zone; // Rover points to base of zone mem
|
rover = zone; // Rover points to base of zone mem
|
||||||
zone->next = zone->prev = zone; // Single node
|
zone->next = zone->prev = zone; // Single node
|
||||||
|
|
|
@ -73,7 +73,7 @@ void metadata_summary (void)
|
||||||
void *
|
void *
|
||||||
align_buffer (void *buffer, size_t * buffer_size)
|
align_buffer (void *buffer, size_t * buffer_size)
|
||||||
{
|
{
|
||||||
unsigned int wasted = (-(long) buffer) & 3;
|
unsigned int wasted = (-(intptr_t) buffer) & 3;
|
||||||
|
|
||||||
if (!buffer || !buffer_size)
|
if (!buffer || !buffer_size)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ align_buffer (void *buffer, size_t * buffer_size)
|
||||||
|
|
||||||
*buffer_size -= wasted;
|
*buffer_size -= wasted;
|
||||||
|
|
||||||
return (void *) (((char *) buffer) + wasted);
|
return PTR_ADD(buffer, wasted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ static const char* get_next_line(const char *text, struct view_info *info)
|
||||||
w = 1;
|
w = 1;
|
||||||
#else
|
#else
|
||||||
unsigned short ch;
|
unsigned short ch;
|
||||||
n = ((long)rb->utf8decode(ptr, &ch) - (long)ptr);
|
n = ((intptr_t)rb->utf8decode(ptr, &ch) - (intptr_t)ptr);
|
||||||
if (rb->is_diacritic(ch, NULL))
|
if (rb->is_diacritic(ch, NULL))
|
||||||
w = 0;
|
w = 0;
|
||||||
else
|
else
|
||||||
|
|
|
@ -41,13 +41,14 @@ QUICKREF
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "_ansi.h"
|
#include "_ansi.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/*SUPPRESS 560*/
|
/*SUPPRESS 560*/
|
||||||
/*SUPPRESS 530*/
|
/*SUPPRESS 530*/
|
||||||
|
|
||||||
/* Nonzero if either X or Y is not aligned on a "long" boundary. */
|
/* Nonzero if either X or Y is not aligned on a "long" boundary. */
|
||||||
#define ROCKBOX_UNALIGNED(X, Y) \
|
#define ROCKBOX_UNALIGNED(X, Y) \
|
||||||
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
|
(((uintptr_t)X & (sizeof (long) - 1)) | ((uintptr_t)Y & (sizeof (long) - 1)))
|
||||||
|
|
||||||
#if LONG_MAX == 2147483647L
|
#if LONG_MAX == 2147483647L
|
||||||
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
|
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
|
||||||
|
|
|
@ -545,7 +545,7 @@ static struct lrc_brpos *calc_brpos(struct lrc_line *lrc_line, int i)
|
||||||
c = rb->utf8seek(cr.str, 1);
|
c = rb->utf8seek(cr.str, 1);
|
||||||
w = 1;
|
w = 1;
|
||||||
#else
|
#else
|
||||||
c = ((long)rb->utf8decode(cr.str, &ch) - (long)cr.str);
|
c = ((intptr_t)rb->utf8decode(cr.str, &ch) - (intptr_t)cr.str);
|
||||||
if (rb->is_diacritic(ch, NULL))
|
if (rb->is_diacritic(ch, NULL))
|
||||||
w = 0;
|
w = 0;
|
||||||
else
|
else
|
||||||
|
@ -885,7 +885,7 @@ static bool parse_lrc_line(char *line, off_t file_offset)
|
||||||
lrc_line->time_start = (time/10)*10;
|
lrc_line->time_start = (time/10)*10;
|
||||||
lrc_line->old_time_start = lrc_line->time_start;
|
lrc_line->old_time_start = lrc_line->time_start;
|
||||||
add_lrc_line(lrc_line, NULL);
|
add_lrc_line(lrc_line, NULL);
|
||||||
file_offset += (long)tagend - (long)str;
|
file_offset += (intptr_t)tagend - (intptr_t)str;
|
||||||
str = tagend;
|
str = tagend;
|
||||||
}
|
}
|
||||||
if (!first_lrc_line)
|
if (!first_lrc_line)
|
||||||
|
@ -908,7 +908,7 @@ static bool parse_lrc_line(char *line, off_t file_offset)
|
||||||
if (!tagend) break;
|
if (!tagend) break;
|
||||||
*tagend = 0;
|
*tagend = 0;
|
||||||
time = get_time_value(tagstart+1, false,
|
time = get_time_value(tagstart+1, false,
|
||||||
file_offset + ((long)tagstart - (long)str));
|
file_offset + ((intptr_t)tagstart - (intptr_t)str));
|
||||||
*tagend++ = '>';
|
*tagend++ = '>';
|
||||||
if (time < 0)
|
if (time < 0)
|
||||||
{
|
{
|
||||||
|
@ -923,7 +923,7 @@ static bool parse_lrc_line(char *line, off_t file_offset)
|
||||||
return false;
|
return false;
|
||||||
nword++;
|
nword++;
|
||||||
}
|
}
|
||||||
file_offset += (long)tagend - (long)str;
|
file_offset += (intptr_t)tagend - (intptr_t)str;
|
||||||
tagstart = str = tagend;
|
tagstart = str = tagend;
|
||||||
time_start = time;
|
time_start = time;
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1159,7 @@ static int unsynchronize(char* tag, int len, bool *ff_found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ff_found) *ff_found = _ff_found;
|
if(ff_found) *ff_found = _ff_found;
|
||||||
return (long)wp - (long)tag;
|
return (intptr_t)wp - (intptr_t)tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_unsynched(int fd, void *buf, int len, bool *ff_found)
|
static int read_unsynched(int fd, void *buf, int len, bool *ff_found)
|
||||||
|
@ -1471,7 +1471,7 @@ static void parse_id3v2(int fd)
|
||||||
utf_decode = rb->utf16BEdecode;
|
utf_decode = rb->utf16BEdecode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bytesread -= (long)p - (long)tag;
|
bytesread -= (intptr_t)p - (intptr_t)tag;
|
||||||
tag = p;
|
tag = p;
|
||||||
|
|
||||||
while ( bytesread > 0
|
while ( bytesread > 0
|
||||||
|
@ -1529,7 +1529,7 @@ static void parse_id3v2(int fd)
|
||||||
lrc_line->old_time_start = -1;
|
lrc_line->old_time_start = -1;
|
||||||
if(is_crlf) p += chsiz;
|
if(is_crlf) p += chsiz;
|
||||||
}
|
}
|
||||||
bytesread -= (long)p - (long)tag;
|
bytesread -= (intptr_t)p - (intptr_t)tag;
|
||||||
tag = p;
|
tag = p;
|
||||||
if(!add_lrc_line(lrc_line, utf8line))
|
if(!add_lrc_line(lrc_line, utf8line))
|
||||||
break;
|
break;
|
||||||
|
@ -2922,7 +2922,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lrc_buffer = rb->plugin_get_buffer(&lrc_buffer_size);
|
lrc_buffer = rb->plugin_get_buffer(&lrc_buffer_size);
|
||||||
lrc_buffer = (void *)(((long)lrc_buffer+3)&~3); /* 4 bytes aligned */
|
lrc_buffer = ALIGN_UP(lrc_buffer, 4); /* 4 bytes aligned */
|
||||||
lrc_buffer_size = (lrc_buffer_size - 4)&~3;
|
lrc_buffer_size = (lrc_buffer_size - 4)&~3;
|
||||||
|
|
||||||
reset_current_data();
|
reset_current_data();
|
||||||
|
|
|
@ -703,7 +703,7 @@ extern int Voice_Stopped_internal(SBYTE);
|
||||||
|
|
||||||
/*========== SIMD mixing helper functions =============*/
|
/*========== SIMD mixing helper functions =============*/
|
||||||
|
|
||||||
#define IS_ALIGNED_16(ptr) (!(((int)(ptr)) & 15))
|
#define IS_ALIGNED_16(ptr) (!(((intptr_t)(ptr)) & 15))
|
||||||
|
|
||||||
/* Altivec helper function */
|
/* Altivec helper function */
|
||||||
#if defined HAVE_ALTIVEC
|
#if defined HAVE_ALTIVEC
|
||||||
|
|
|
@ -1547,7 +1547,7 @@ static int load_game( void )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
retval = 0; /* Assume good case */
|
retval = 0; /* Assume good case */
|
||||||
if( ( rb->lseek( fd, -sizeof( int ), SEEK_END ) == -((ssize_t)sizeof( int ))-1 )
|
if( ( rb->lseek( fd, -(off_t)sizeof( int ), SEEK_END ) == -((ssize_t)sizeof( int ))-1 )
|
||||||
|| ( rb->read( fd, &checksum, sizeof( int ) ) < ((ssize_t)sizeof( int )) )
|
|| ( rb->read( fd, &checksum, sizeof( int ) ) < ((ssize_t)sizeof( int )) )
|
||||||
|| ( rb->lseek( fd, 0, SEEK_SET ) == -1 )
|
|| ( rb->lseek( fd, 0, SEEK_SET ) == -1 )
|
||||||
|| save_read( fd, &cur_card, sizeof( int ), &checksum )
|
|| save_read( fd, &cur_card, sizeof( int ), &checksum )
|
||||||
|
|
|
@ -362,7 +362,7 @@ static void read_compressed_data(SNFILE *fp, byte *start, unsigned size,
|
||||||
GET_DATA(ch);
|
GET_DATA(ch);
|
||||||
if(p + times > end) {
|
if(p + times > end) {
|
||||||
put_msg("Warning: Repeat parameter too large in snapshot");
|
put_msg("Warning: Repeat parameter too large in snapshot");
|
||||||
times = (int) ((long) end - (long) p);
|
times = (int) ((intptr_t) end - (intptr_t) p);
|
||||||
}
|
}
|
||||||
for(j = 0; j < times; j++) *p++ = ch;
|
for(j = 0; j < times; j++) *p++ = ch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ static struct tzxblock tzxb[NUMBLOCKID] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define PTRDIFF(pe, ps) ((int) (((long) (pe) - (long) (ps)) / sizeof(*pe)))
|
#define PTRDIFF(pe, ps) pe - ps
|
||||||
|
|
||||||
static char tzxheader[] = {'Z','X','T','a','p','e','!',0x1A};
|
static char tzxheader[] = {'Z','X','T','a','p','e','!',0x1A};
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ static byte *a64kmalloc(int num64ksegs)
|
||||||
/*exit(1);*/
|
/*exit(1);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return (byte *) (( (long) bigmem & ~((long) 0xFFFF)) + 0x10000);
|
return (byte *) (( (intptr_t) bigmem & ~((intptr_t) 0xFFFF)) + 0x10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ static void kbd_inschar(struct edit_state *state, unsigned short ch)
|
||||||
|
|
||||||
len = strlen(state->text);
|
len = strlen(state->text);
|
||||||
utf8 = utf8encode(ch, tmp);
|
utf8 = utf8encode(ch, tmp);
|
||||||
j = (long)utf8 - (long)tmp;
|
j = (intptr_t)utf8 - (intptr_t)tmp;
|
||||||
|
|
||||||
if (len + j < state->buflen)
|
if (len + j < state->buflen)
|
||||||
{
|
{
|
||||||
|
|
|
@ -930,7 +930,7 @@ inline static bool str_oneof(const char *str, const char *list)
|
||||||
while (*list)
|
while (*list)
|
||||||
{
|
{
|
||||||
sep = strchr(list, '|');
|
sep = strchr(list, '|');
|
||||||
l = sep ? (long)sep - (long)list : (int)strlen(list);
|
l = sep ? (intptr_t)sep - (intptr_t)list : (int)strlen(list);
|
||||||
if ((l==len) && !strncasecmp(str, list, len))
|
if ((l==len) && !strncasecmp(str, list, len))
|
||||||
return true;
|
return true;
|
||||||
list += sep ? l + 1 : l;
|
list += sep ? l + 1 : l;
|
||||||
|
@ -2362,7 +2362,7 @@ static bool build_numeric_indices(struct tagcache_header *h, int tmpfd)
|
||||||
/* Avoid processing this entry again. */
|
/* Avoid processing this entry again. */
|
||||||
idx.flag |= FLAG_RESURRECTED;
|
idx.flag |= FLAG_RESURRECTED;
|
||||||
|
|
||||||
lseek(masterfd, -sizeof(struct index_entry), SEEK_CUR);
|
lseek(masterfd, -(off_t)sizeof(struct index_entry), SEEK_CUR);
|
||||||
if (ecwrite_index_entry(masterfd, &idx) != sizeof(struct index_entry))
|
if (ecwrite_index_entry(masterfd, &idx) != sizeof(struct index_entry))
|
||||||
{
|
{
|
||||||
logf("masterfd writeback fail #1");
|
logf("masterfd writeback fail #1");
|
||||||
|
@ -3432,7 +3432,7 @@ static int parse_changelog_line(int line_n, char *buf, void *parameters)
|
||||||
struct index_entry idx;
|
struct index_entry idx;
|
||||||
char tag_data[TAG_MAXLEN+32];
|
char tag_data[TAG_MAXLEN+32];
|
||||||
int idx_id;
|
int idx_id;
|
||||||
long masterfd = (long)parameters;
|
long masterfd = (long)(intptr_t)parameters;
|
||||||
const int import_tags[] = { tag_playcount, tag_rating, tag_playtime,
|
const int import_tags[] = { tag_playcount, tag_rating, tag_playtime,
|
||||||
tag_lastplayed, tag_commitid, tag_lastelapsed,
|
tag_lastplayed, tag_commitid, tag_lastelapsed,
|
||||||
tag_lastoffset };
|
tag_lastoffset };
|
||||||
|
@ -3526,7 +3526,7 @@ bool tagcache_import_changelog(void)
|
||||||
|
|
||||||
filenametag_fd = open_tag_fd(&tch, tag_filename, false);
|
filenametag_fd = open_tag_fd(&tch, tag_filename, false);
|
||||||
|
|
||||||
fast_readline(clfd, buf, sizeof buf, (long *)masterfd,
|
fast_readline(clfd, buf, sizeof buf, (void *)(intptr_t)masterfd,
|
||||||
parse_changelog_line);
|
parse_changelog_line);
|
||||||
|
|
||||||
close(clfd);
|
close(clfd);
|
||||||
|
@ -3665,7 +3665,7 @@ static bool delete_entry(long idx_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
myidx.flag |= FLAG_DELETED;
|
myidx.flag |= FLAG_DELETED;
|
||||||
lseek(masterfd, -sizeof(struct index_entry), SEEK_CUR);
|
lseek(masterfd, -(off_t)sizeof(struct index_entry), SEEK_CUR);
|
||||||
if (ecwrite_index_entry(masterfd, &myidx) != sizeof(struct index_entry))
|
if (ecwrite_index_entry(masterfd, &myidx) != sizeof(struct index_entry))
|
||||||
{
|
{
|
||||||
logf("delete_entry(): write_error #1");
|
logf("delete_entry(): write_error #1");
|
||||||
|
|
|
@ -20,9 +20,10 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "string-extra.h" /* memset16() */
|
#include "string-extra.h" /* memset16() */
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define LBLOCKSIZE (sizeof(long)/2)
|
#define LBLOCKSIZE (sizeof(long)/2)
|
||||||
#define ROCKBOX_UNALIGNED(X) ((long)X & (sizeof(long) - 1))
|
#define ROCKBOX_UNALIGNED(X) ((uintptr_t)X & (sizeof(long) - 1))
|
||||||
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
|
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
|
||||||
|
|
||||||
void memset16(void *dst, int val, size_t len)
|
void memset16(void *dst, int val, size_t len)
|
||||||
|
|
|
@ -94,7 +94,7 @@ void lcd_clear_viewport(void)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
|
memcpy(dst, PTR_ADD(dst, lcd_backdrop_offset),
|
||||||
len * sizeof(fb_data));
|
len * sizeof(fb_data));
|
||||||
dst += step;
|
dst += step;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ static void ICODE_ATTR clearpixel(fb_data *address)
|
||||||
|
|
||||||
static void ICODE_ATTR clearimgpixel(fb_data *address)
|
static void ICODE_ATTR clearimgpixel(fb_data *address)
|
||||||
{
|
{
|
||||||
*address = *(fb_data *)((long)address + lcd_backdrop_offset);
|
*address = *PTR_ADD(address, lcd_backdrop_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ICODE_ATTR flippixel(fb_data *address)
|
static void ICODE_ATTR flippixel(fb_data *address)
|
||||||
|
@ -244,7 +244,7 @@ void lcd_fillrect(int x, int y, int width, int height)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_COPY:
|
case OPT_COPY:
|
||||||
memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
|
memcpy(dst, PTR_ADD(dst, lcd_backdrop_offset),
|
||||||
len * sizeof(fb_data));
|
len * sizeof(fb_data));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!(data & 0x01))
|
if (!(data & 0x01))
|
||||||
*dst = *(fb_data *)((long)dst + bo);
|
*dst = *PTR_ADD(dst, bo);
|
||||||
|
|
||||||
dst += ROW_INC;
|
dst += ROW_INC;
|
||||||
UPDATE_SRC;
|
UPDATE_SRC;
|
||||||
|
@ -435,7 +435,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*dst = (data & 0x01) ? fg
|
*dst = (data & 0x01) ? fg
|
||||||
: *(fb_data *)((long)dst + bo);
|
: *PTR_ADD(dst, bo);
|
||||||
dst += ROW_INC;
|
dst += ROW_INC;
|
||||||
UPDATE_SRC;
|
UPDATE_SRC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ void lcd_hline(int x1, int x2, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_COPY:
|
case OPT_COPY:
|
||||||
memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
|
memcpy(dst, PTR_ADD(dst, lcd_backdrop_offset),
|
||||||
width * sizeof(fb_data));
|
width * sizeof(fb_data));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ void lcd_set_backdrop(fb_data* backdrop)
|
||||||
lcd_backdrop = backdrop;
|
lcd_backdrop = backdrop;
|
||||||
if (backdrop)
|
if (backdrop)
|
||||||
{
|
{
|
||||||
lcd_backdrop_offset = (long)backdrop - (long)lcd_framebuffer;
|
lcd_backdrop_offset = (intptr_t)backdrop - (intptr_t)lcd_framebuffer;
|
||||||
lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop;
|
lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -418,7 +418,7 @@ void queue_post(struct event_queue *q, long id, intptr_t data)
|
||||||
wr = q->write++ & QUEUE_LENGTH_MASK;
|
wr = q->write++ & QUEUE_LENGTH_MASK;
|
||||||
|
|
||||||
KERNEL_ASSERT((q->write - q->read) <= QUEUE_LENGTH,
|
KERNEL_ASSERT((q->write - q->read) <= QUEUE_LENGTH,
|
||||||
"queue_post ovf q=%08lX", (long)q);
|
"queue_post ovf q=%p", q);
|
||||||
|
|
||||||
q->events[wr].id = id;
|
q->events[wr].id = id;
|
||||||
q->events[wr].data = data;
|
q->events[wr].data = data;
|
||||||
|
@ -450,7 +450,7 @@ intptr_t queue_send(struct event_queue *q, long id, intptr_t data)
|
||||||
wr = q->write++ & QUEUE_LENGTH_MASK;
|
wr = q->write++ & QUEUE_LENGTH_MASK;
|
||||||
|
|
||||||
KERNEL_ASSERT((q->write - q->read) <= QUEUE_LENGTH,
|
KERNEL_ASSERT((q->write - q->read) <= QUEUE_LENGTH,
|
||||||
"queue_send ovf q=%08lX", (long)q);
|
"queue_send ovf q=%p", q);
|
||||||
|
|
||||||
q->events[wr].id = id;
|
q->events[wr].id = id;
|
||||||
q->events[wr].data = data;
|
q->events[wr].data = data;
|
||||||
|
|
|
@ -251,7 +251,7 @@ int os_opendirfd(const char *osdirname)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Convert OS handle to fd; the fd now owns it */
|
/* Convert OS handle to fd; the fd now owns it */
|
||||||
int osfd = _open_osfhandle((long)h, O_RDONLY);
|
int osfd = _open_osfhandle((intptr_t)h, O_RDONLY);
|
||||||
if (osfd >= 0)
|
if (osfd >= 0)
|
||||||
return osfd;
|
return osfd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
|
||||||
{
|
{
|
||||||
int align;
|
int align;
|
||||||
|
|
||||||
align = (long)buf & 3;
|
align = (intptr_t)buf & 3;
|
||||||
state->buffer_start = (uint32_t *) (buf - align);
|
state->buffer_start = (uint32_t *) (buf - align);
|
||||||
state->bits_left = 0;
|
state->bits_left = 0;
|
||||||
state->current_word = 0;
|
state->current_word = 0;
|
||||||
|
|
|
@ -293,7 +293,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
|
||||||
if(b->endbyte < b->storage - 8) {
|
if(b->endbyte < b->storage - 8) {
|
||||||
ogg_uint32_t *ptr;
|
ogg_uint32_t *ptr;
|
||||||
unsigned long bit, bitend;
|
unsigned long bit, bitend;
|
||||||
unsigned long adr;
|
intptr_t adr;
|
||||||
ogg_uint32_t cache = 0;
|
ogg_uint32_t cache = 0;
|
||||||
int cachesize = 0;
|
int cachesize = 0;
|
||||||
const unsigned int cachemask = (1<<book->dec_firsttablen)-1;
|
const unsigned int cachemask = (1<<book->dec_firsttablen)-1;
|
||||||
|
@ -303,7 +303,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
|
||||||
const ogg_uint32_t *book_codelist = book->codelist;
|
const ogg_uint32_t *book_codelist = book->codelist;
|
||||||
const char *book_dec_codelengths = book->dec_codelengths;
|
const char *book_dec_codelengths = book->dec_codelengths;
|
||||||
|
|
||||||
adr = (unsigned long)b->ptr;
|
adr = (intptr_t)b->ptr;
|
||||||
bit = (adr&3)*8+b->endbit;
|
bit = (adr&3)*8+b->endbit;
|
||||||
ptr = (ogg_uint32_t*)(adr&~3);
|
ptr = (ogg_uint32_t*)(adr&~3);
|
||||||
bitend = ((adr&3)+(b->storage-b->endbyte))*8;
|
bitend = ((adr&3)+(b->storage-b->endbyte))*8;
|
||||||
|
@ -334,7 +334,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
|
||||||
cache >>= l;
|
cache >>= l;
|
||||||
}
|
}
|
||||||
|
|
||||||
adr=(unsigned long)b->ptr;
|
adr=(intptr_t)b->ptr;
|
||||||
bit-=(adr&3)*8+cachesize;
|
bit-=(adr&3)*8+cachesize;
|
||||||
b->endbyte+=bit/8;
|
b->endbyte+=bit/8;
|
||||||
b->ptr+=bit/8;
|
b->ptr+=bit/8;
|
||||||
|
|
|
@ -191,7 +191,7 @@ static int unsynchronize(char* tag, int len, bool *ff_found)
|
||||||
wp++;
|
wp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (long)wp - (long)tag;
|
return (intptr_t)wp - (intptr_t)tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unsynchronize_frame(char* tag, int len)
|
static int unsynchronize_frame(char* tag, int len)
|
||||||
|
@ -562,7 +562,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
|
||||||
(*len)--;
|
(*len)--;
|
||||||
utf8 = iso_decode(str, utf8, -1, *len);
|
utf8 = iso_decode(str, utf8, -1, *len);
|
||||||
*utf8 = 0;
|
*utf8 = 0;
|
||||||
*len = (unsigned long)utf8 - (unsigned long)utf8buf;
|
*len = (intptr_t)utf8 - (intptr_t)utf8buf;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x01: /* Unicode with or without BOM */
|
case 0x01: /* Unicode with or without BOM */
|
||||||
|
@ -619,7 +619,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
|
||||||
default: /* Plain old string */
|
default: /* Plain old string */
|
||||||
utf8 = iso_decode(str, utf8, -1, *len);
|
utf8 = iso_decode(str, utf8, -1, *len);
|
||||||
*utf8 = 0;
|
*utf8 = 0;
|
||||||
*len = (unsigned long)utf8 - (unsigned long)utf8buf;
|
*len = (intptr_t)utf8 - (intptr_t)utf8buf;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef TLSF_USE_LOCKS
|
#ifndef TLSF_USE_LOCKS
|
||||||
#define TLSF_USE_LOCKS (0)
|
#define TLSF_USE_LOCKS (0)
|
||||||
|
@ -462,7 +463,7 @@ size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((unsigned long) mem_pool & PTR_MASK)) {
|
if (((intptr_t) mem_pool & PTR_MASK)) {
|
||||||
ERROR_MSG("init_memory_pool (): mem_pool must be aligned to a word\n");
|
ERROR_MSG("init_memory_pool (): mem_pool must be aligned to a word\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -522,7 +523,7 @@ size_t add_new_area(void *area, size_t area_size, void *mem_pool)
|
||||||
lb1 = ptr->end;
|
lb1 = ptr->end;
|
||||||
|
|
||||||
/* Merging the new area with the next physically contigous one */
|
/* Merging the new area with the next physically contigous one */
|
||||||
if ((unsigned long) ib1 == (unsigned long) lb0 + BHDR_OVERHEAD) {
|
if ((uintptr_t) ib1 == (uintptr_t) lb0 + BHDR_OVERHEAD) {
|
||||||
if (tlsf->area_head == ptr) {
|
if (tlsf->area_head == ptr) {
|
||||||
tlsf->area_head = ptr->next;
|
tlsf->area_head = ptr->next;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
|
@ -543,7 +544,7 @@ size_t add_new_area(void *area, size_t area_size, void *mem_pool)
|
||||||
|
|
||||||
/* Merging the new area with the previous physically contigous
|
/* Merging the new area with the previous physically contigous
|
||||||
one */
|
one */
|
||||||
if ((unsigned long) lb1->ptr.buffer == (unsigned long) ib0) {
|
if ((intptr_t) lb1->ptr.buffer == (intptr_t) ib0) {
|
||||||
if (tlsf->area_head == ptr) {
|
if (tlsf->area_head == ptr) {
|
||||||
tlsf->area_head = ptr->next;
|
tlsf->area_head = ptr->next;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue