mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Use 'int' for 32 bit variables in host tools to better run on 64bit archs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8626 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b772a436fa
commit
dcc9a8a3d8
2 changed files with 58 additions and 58 deletions
|
@ -49,21 +49,21 @@
|
|||
struct Fileheader
|
||||
{
|
||||
unsigned short Type; /* signature - 'BM' */
|
||||
unsigned long Size; /* file size in bytes */
|
||||
unsigned int Size; /* file size in bytes */
|
||||
unsigned short Reserved1; /* 0 */
|
||||
unsigned short Reserved2; /* 0 */
|
||||
unsigned long OffBits; /* offset to bitmap */
|
||||
unsigned long StructSize; /* size of this struct (40) */
|
||||
unsigned long Width; /* bmap width in pixels */
|
||||
unsigned long Height; /* bmap height in pixels */
|
||||
unsigned int OffBits; /* offset to bitmap */
|
||||
unsigned int StructSize; /* size of this struct (40) */
|
||||
unsigned int Width; /* bmap width in pixels */
|
||||
unsigned int Height; /* bmap height in pixels */
|
||||
unsigned short Planes; /* num planes - always 1 */
|
||||
unsigned short BitCount; /* bits per pixel */
|
||||
unsigned long Compression; /* compression flag */
|
||||
unsigned long SizeImage; /* image size in bytes */
|
||||
long XPelsPerMeter; /* horz resolution */
|
||||
long YPelsPerMeter; /* vert resolution */
|
||||
unsigned long ClrUsed; /* 0 -> color table size */
|
||||
unsigned long ClrImportant; /* important color count */
|
||||
unsigned int Compression; /* compression flag */
|
||||
unsigned int SizeImage; /* image size in bytes */
|
||||
int XPelsPerMeter; /* horz resolution */
|
||||
int YPelsPerMeter; /* vert resolution */
|
||||
unsigned int ClrUsed; /* 0 -> color table size */
|
||||
unsigned int ClrImportant; /* important color count */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct RGBQUAD
|
||||
|
@ -80,7 +80,7 @@ short readshort(void* value)
|
|||
return bytes[0] | (bytes[1] << 8);
|
||||
}
|
||||
|
||||
int readlong(void* value)
|
||||
int readint(void* value)
|
||||
{
|
||||
unsigned char* bytes = (unsigned char*) value;
|
||||
return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
|
||||
|
@ -101,8 +101,8 @@ unsigned char brightness(struct RGBQUAD color)
|
|||
***************************************************************************/
|
||||
|
||||
int read_bmp_file(char* filename,
|
||||
long *get_width, /* in pixels */
|
||||
long *get_height, /* in pixels */
|
||||
int *get_width, /* in pixels */
|
||||
int *get_height, /* in pixels */
|
||||
struct RGBQUAD **bitmap)
|
||||
{
|
||||
struct Fileheader fh;
|
||||
|
@ -111,11 +111,11 @@ int read_bmp_file(char* filename,
|
|||
int fd = open(filename, O_RDONLY);
|
||||
unsigned short data;
|
||||
unsigned char *bmp;
|
||||
long width, height;
|
||||
long padded_width;
|
||||
long size;
|
||||
long row, col, i;
|
||||
long numcolors, compression;
|
||||
int width, height;
|
||||
int padded_width;
|
||||
int size;
|
||||
int row, col, i;
|
||||
int numcolors, compression;
|
||||
int depth;
|
||||
|
||||
if (fd == -1)
|
||||
|
@ -131,7 +131,7 @@ int read_bmp_file(char* filename,
|
|||
return 2;
|
||||
}
|
||||
|
||||
compression = readlong(&fh.Compression);
|
||||
compression = readint(&fh.Compression);
|
||||
|
||||
if (compression != 0)
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ int read_bmp_file(char* filename,
|
|||
|
||||
if (depth <= 8)
|
||||
{
|
||||
numcolors = readlong(&fh.ClrUsed);
|
||||
numcolors = readint(&fh.ClrUsed);
|
||||
if (numcolors == 0)
|
||||
numcolors = 1 << depth;
|
||||
|
||||
|
@ -157,8 +157,8 @@ int read_bmp_file(char* filename,
|
|||
}
|
||||
}
|
||||
|
||||
width = readlong(&fh.Width);
|
||||
height = readlong(&fh.Height);
|
||||
width = readint(&fh.Width);
|
||||
height = readint(&fh.Height);
|
||||
padded_width = (width * depth / 8 + 3) & ~3; /* aligned 4-bytes boundaries */
|
||||
|
||||
size = padded_width * height; /* read this many bytes */
|
||||
|
@ -172,13 +172,13 @@ int read_bmp_file(char* filename,
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (lseek(fd, (off_t)readlong(&fh.OffBits), SEEK_SET) < 0)
|
||||
if (lseek(fd, (off_t)readint(&fh.OffBits), SEEK_SET) < 0)
|
||||
{
|
||||
debugf("error - Can't seek to start of image data\n");
|
||||
close(fd);
|
||||
return 6;
|
||||
}
|
||||
if (read(fd, (unsigned char*)bmp, (long)size) != size)
|
||||
if (read(fd, (unsigned char*)bmp, (int)size) != size)
|
||||
{
|
||||
debugf("error - Can't read image\n");
|
||||
close(fd);
|
||||
|
@ -276,12 +276,12 @@ int read_bmp_file(char* filename,
|
|||
* destination formats
|
||||
****************************************************************************/
|
||||
|
||||
int transform_bitmap(const struct RGBQUAD *src, long width, long height,
|
||||
int format, unsigned short **dest, long *dst_width,
|
||||
long *dst_height)
|
||||
int transform_bitmap(const struct RGBQUAD *src, int width, int height,
|
||||
int format, unsigned short **dest, int *dst_width,
|
||||
int *dst_height)
|
||||
{
|
||||
long row, col;
|
||||
long dst_w, dst_h;
|
||||
int row, col;
|
||||
int dst_w, dst_h;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
|
@ -395,12 +395,12 @@ int transform_bitmap(const struct RGBQUAD *src, long width, long height,
|
|||
* some #define's
|
||||
****************************************************************************/
|
||||
|
||||
void generate_c_source(char *id, long width, long height,
|
||||
const unsigned short *t_bitmap, long t_width,
|
||||
long t_height, int format)
|
||||
void generate_c_source(char *id, int width, int height,
|
||||
const unsigned short *t_bitmap, int t_width,
|
||||
int t_height, int format)
|
||||
{
|
||||
FILE *f;
|
||||
long i, a;
|
||||
int i, a;
|
||||
|
||||
f = stdout;
|
||||
|
||||
|
@ -439,10 +439,10 @@ void generate_c_source(char *id, long width, long height,
|
|||
* Outputs an ascii picture of the bitmap
|
||||
****************************************************************************/
|
||||
|
||||
void generate_ascii(long width, long height, struct RGBQUAD *bitmap)
|
||||
void generate_ascii(int width, int height, struct RGBQUAD *bitmap)
|
||||
{
|
||||
FILE *f;
|
||||
long x, y;
|
||||
int x, y;
|
||||
|
||||
f = stdout;
|
||||
|
||||
|
@ -482,8 +482,8 @@ int main(int argc, char **argv)
|
|||
int format = 0;
|
||||
struct RGBQUAD *bitmap = NULL;
|
||||
unsigned short *t_bitmap = NULL;
|
||||
long width, height;
|
||||
long t_width, t_height;
|
||||
int width, height;
|
||||
int t_width, t_height;
|
||||
|
||||
|
||||
for (i = 1;i < argc;i++)
|
||||
|
|
|
@ -42,13 +42,13 @@ struct font {
|
|||
int firstchar; /* first character in bitmap*/
|
||||
int size; /* font size in glyphs*/
|
||||
bitmap_t* bits; /* 16-bit right-padded bitmap data*/
|
||||
unsigned long* offset; /* offsets into bitmap data*/
|
||||
unsigned int* offset; /* offsets into bitmap data*/
|
||||
unsigned char* width; /* character widths or NULL if fixed*/
|
||||
int defaultchar; /* default char (not glyph index)*/
|
||||
long bits_size; /* # words of bitmap_t bits*/
|
||||
int bits_size; /* # words of bitmap_t bits*/
|
||||
|
||||
/* unused by runtime system, read in by convbdf*/
|
||||
unsigned long* offrot; /* offsets into rotated bitmap data*/
|
||||
unsigned int* offrot; /* offsets into rotated bitmap data*/
|
||||
char * name; /* font name*/
|
||||
char * facename; /* facename of font*/
|
||||
char * copyright; /* copyright info for loadable fonts*/
|
||||
|
@ -435,8 +435,8 @@ int bdf_read_header(FILE *fp, struct font* pf)
|
|||
|
||||
/* allocate bits, offset, and width arrays*/
|
||||
pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA);
|
||||
pf->offset = (unsigned long *)malloc(pf->size * sizeof(unsigned long));
|
||||
pf->offrot = (unsigned long *)malloc(pf->size * sizeof(unsigned long));
|
||||
pf->offset = (unsigned int *)malloc(pf->size * sizeof(unsigned int));
|
||||
pf->offrot = (unsigned int *)malloc(pf->size * sizeof(unsigned int));
|
||||
pf->width = (unsigned char *)malloc(pf->size * sizeof(unsigned char));
|
||||
|
||||
if (!pf->bits || !pf->offset || !pf->offrot || !pf->width) {
|
||||
|
@ -451,14 +451,14 @@ int bdf_read_header(FILE *fp, struct font* pf)
|
|||
/* read bdf font bitmaps, return 0 on error*/
|
||||
int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
||||
{
|
||||
long ofs = 0;
|
||||
long ofr = 0;
|
||||
int ofs = 0;
|
||||
int ofr = 0;
|
||||
int maxwidth = 0;
|
||||
int i, k, encoding, width;
|
||||
int bbw, bbh, bbx, bby;
|
||||
int proportional = 0;
|
||||
int encodetable = 0;
|
||||
long l;
|
||||
int l;
|
||||
char buf[256];
|
||||
|
||||
/* reset file pointer*/
|
||||
|
@ -511,7 +511,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
|||
continue;
|
||||
|
||||
/* set bits offset in encode map*/
|
||||
if (pf->offset[encoding-pf->firstchar] != (unsigned long)-1) {
|
||||
if (pf->offset[encoding-pf->firstchar] != (unsigned int)-1) {
|
||||
fprintf(stderr, "Error: duplicate encoding for character %d (0x%02x), ignoring duplicate\n",
|
||||
encoding, encoding);
|
||||
continue;
|
||||
|
@ -589,7 +589,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
|||
for (i=0; i<pf->size; ++i) {
|
||||
int defchar = pf->defaultchar - pf->firstchar;
|
||||
|
||||
if (pf->offset[i] == (unsigned long)-1) {
|
||||
if (pf->offset[i] == (unsigned int)-1) {
|
||||
pf->offset[i] = pf->offset[defchar];
|
||||
pf->offrot[i] = pf->offrot[defchar];
|
||||
pf->width[i] = pf->width[defchar];
|
||||
|
@ -983,7 +983,7 @@ static int writeshort(FILE *fp, unsigned short s)
|
|||
return putc(s>>8, fp) != EOF;
|
||||
}
|
||||
|
||||
static int writelong(FILE *fp, unsigned long l)
|
||||
static int writeint(FILE *fp, unsigned int l)
|
||||
{
|
||||
putc(l, fp);
|
||||
putc(l>>8, fp);
|
||||
|
@ -1041,14 +1041,14 @@ int gen_fnt_file(struct font* pf, char *path)
|
|||
writeshort(ofp, pf->height);
|
||||
writeshort(ofp, pf->ascent);
|
||||
writeshort(ofp, 0);
|
||||
writelong(ofp, pf->firstchar);
|
||||
writelong(ofp, pf->defaultchar);
|
||||
writelong(ofp, pf->size);
|
||||
writeint(ofp, pf->firstchar);
|
||||
writeint(ofp, pf->defaultchar);
|
||||
writeint(ofp, pf->size);
|
||||
|
||||
/* variable font data sizes*/
|
||||
writelong(ofp, pf->bits_size); /* # words of bitmap_t*/
|
||||
writelong(ofp, pf->offset? pf->size: 0); /* # longs of offset*/
|
||||
writelong(ofp, pf->width? pf->size: 0); /* # bytes of width*/
|
||||
writeint(ofp, pf->bits_size); /* # words of bitmap_t*/
|
||||
writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset*/
|
||||
writeint(ofp, pf->width? pf->size: 0); /* # bytes of width*/
|
||||
/* variable font data*/
|
||||
#ifdef ROTATE
|
||||
for (i=0; i<pf->size; ++i)
|
||||
|
@ -1083,7 +1083,7 @@ int gen_fnt_file(struct font* pf, char *path)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* bitmap offset is large then 64K, use unsigned long for offset */
|
||||
/* bitmap offset is large then 64K, use unsigned int for offset */
|
||||
while (ftell(ofp) & 3)
|
||||
writebyte(ofp, 0); /* pad to 32-bit boundary*/
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ int gen_fnt_file(struct font* pf, char *path)
|
|||
if ( pf->bits_size < 0xFFDB )
|
||||
writeshort(ofp, pf->offrot[i]);
|
||||
else
|
||||
writelong(ofp, pf->offrot[i]);
|
||||
writeint(ofp, pf->offrot[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ int gen_fnt_file(struct font* pf, char *path)
|
|||
|
||||
if (pf->offset)
|
||||
for (i=0; i<pf->size; ++i)
|
||||
writelong(ofp, pf->offset[i]);
|
||||
writeint(ofp, pf->offset[i]);
|
||||
|
||||
if (pf->width)
|
||||
for (i=0; i<pf->size; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue