diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-02-08 13:05:37 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-02-08 13:05:37 +0000 |
commit | dcc9a8a3d8171d1f7df22a405764f7b9c194c88f (patch) | |
tree | f644cddad58b5b19ad31376afdecebe7d616dc2b /tools | |
parent | b772a436fa1a14accf19395e1e68c92bd16e4521 (diff) | |
download | rockbox-dcc9a8a3d8171d1f7df22a405764f7b9c194c88f.tar.gz rockbox-dcc9a8a3d8171d1f7df22a405764f7b9c194c88f.zip |
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
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bmp2rb.c | 76 | ||||
-rw-r--r-- | tools/convbdf.c | 40 |
2 files changed, 58 insertions, 58 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c index f7b92d0e6e..61c0268c49 100644 --- a/tools/bmp2rb.c +++ b/tools/bmp2rb.c | |||
@@ -49,21 +49,21 @@ | |||
49 | struct Fileheader | 49 | struct Fileheader |
50 | { | 50 | { |
51 | unsigned short Type; /* signature - 'BM' */ | 51 | unsigned short Type; /* signature - 'BM' */ |
52 | unsigned long Size; /* file size in bytes */ | 52 | unsigned int Size; /* file size in bytes */ |
53 | unsigned short Reserved1; /* 0 */ | 53 | unsigned short Reserved1; /* 0 */ |
54 | unsigned short Reserved2; /* 0 */ | 54 | unsigned short Reserved2; /* 0 */ |
55 | unsigned long OffBits; /* offset to bitmap */ | 55 | unsigned int OffBits; /* offset to bitmap */ |
56 | unsigned long StructSize; /* size of this struct (40) */ | 56 | unsigned int StructSize; /* size of this struct (40) */ |
57 | unsigned long Width; /* bmap width in pixels */ | 57 | unsigned int Width; /* bmap width in pixels */ |
58 | unsigned long Height; /* bmap height in pixels */ | 58 | unsigned int Height; /* bmap height in pixels */ |
59 | unsigned short Planes; /* num planes - always 1 */ | 59 | unsigned short Planes; /* num planes - always 1 */ |
60 | unsigned short BitCount; /* bits per pixel */ | 60 | unsigned short BitCount; /* bits per pixel */ |
61 | unsigned long Compression; /* compression flag */ | 61 | unsigned int Compression; /* compression flag */ |
62 | unsigned long SizeImage; /* image size in bytes */ | 62 | unsigned int SizeImage; /* image size in bytes */ |
63 | long XPelsPerMeter; /* horz resolution */ | 63 | int XPelsPerMeter; /* horz resolution */ |
64 | long YPelsPerMeter; /* vert resolution */ | 64 | int YPelsPerMeter; /* vert resolution */ |
65 | unsigned long ClrUsed; /* 0 -> color table size */ | 65 | unsigned int ClrUsed; /* 0 -> color table size */ |
66 | unsigned long ClrImportant; /* important color count */ | 66 | unsigned int ClrImportant; /* important color count */ |
67 | } STRUCT_PACKED; | 67 | } STRUCT_PACKED; |
68 | 68 | ||
69 | struct RGBQUAD | 69 | struct RGBQUAD |
@@ -80,7 +80,7 @@ short readshort(void* value) | |||
80 | return bytes[0] | (bytes[1] << 8); | 80 | return bytes[0] | (bytes[1] << 8); |
81 | } | 81 | } |
82 | 82 | ||
83 | int readlong(void* value) | 83 | int readint(void* value) |
84 | { | 84 | { |
85 | unsigned char* bytes = (unsigned char*) value; | 85 | unsigned char* bytes = (unsigned char*) value; |
86 | return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); | 86 | return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); |
@@ -101,8 +101,8 @@ unsigned char brightness(struct RGBQUAD color) | |||
101 | ***************************************************************************/ | 101 | ***************************************************************************/ |
102 | 102 | ||
103 | int read_bmp_file(char* filename, | 103 | int read_bmp_file(char* filename, |
104 | long *get_width, /* in pixels */ | 104 | int *get_width, /* in pixels */ |
105 | long *get_height, /* in pixels */ | 105 | int *get_height, /* in pixels */ |
106 | struct RGBQUAD **bitmap) | 106 | struct RGBQUAD **bitmap) |
107 | { | 107 | { |
108 | struct Fileheader fh; | 108 | struct Fileheader fh; |
@@ -111,11 +111,11 @@ int read_bmp_file(char* filename, | |||
111 | int fd = open(filename, O_RDONLY); | 111 | int fd = open(filename, O_RDONLY); |
112 | unsigned short data; | 112 | unsigned short data; |
113 | unsigned char *bmp; | 113 | unsigned char *bmp; |
114 | long width, height; | 114 | int width, height; |
115 | long padded_width; | 115 | int padded_width; |
116 | long size; | 116 | int size; |
117 | long row, col, i; | 117 | int row, col, i; |
118 | long numcolors, compression; | 118 | int numcolors, compression; |
119 | int depth; | 119 | int depth; |
120 | 120 | ||
121 | if (fd == -1) | 121 | if (fd == -1) |
@@ -131,7 +131,7 @@ int read_bmp_file(char* filename, | |||
131 | return 2; | 131 | return 2; |
132 | } | 132 | } |
133 | 133 | ||
134 | compression = readlong(&fh.Compression); | 134 | compression = readint(&fh.Compression); |
135 | 135 | ||
136 | if (compression != 0) | 136 | if (compression != 0) |
137 | { | 137 | { |
@@ -144,7 +144,7 @@ int read_bmp_file(char* filename, | |||
144 | 144 | ||
145 | if (depth <= 8) | 145 | if (depth <= 8) |
146 | { | 146 | { |
147 | numcolors = readlong(&fh.ClrUsed); | 147 | numcolors = readint(&fh.ClrUsed); |
148 | if (numcolors == 0) | 148 | if (numcolors == 0) |
149 | numcolors = 1 << depth; | 149 | numcolors = 1 << depth; |
150 | 150 | ||
@@ -157,8 +157,8 @@ int read_bmp_file(char* filename, | |||
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | width = readlong(&fh.Width); | 160 | width = readint(&fh.Width); |
161 | height = readlong(&fh.Height); | 161 | height = readint(&fh.Height); |
162 | padded_width = (width * depth / 8 + 3) & ~3; /* aligned 4-bytes boundaries */ | 162 | padded_width = (width * depth / 8 + 3) & ~3; /* aligned 4-bytes boundaries */ |
163 | 163 | ||
164 | size = padded_width * height; /* read this many bytes */ | 164 | size = padded_width * height; /* read this many bytes */ |
@@ -172,13 +172,13 @@ int read_bmp_file(char* filename, | |||
172 | return 5; | 172 | return 5; |
173 | } | 173 | } |
174 | 174 | ||
175 | if (lseek(fd, (off_t)readlong(&fh.OffBits), SEEK_SET) < 0) | 175 | if (lseek(fd, (off_t)readint(&fh.OffBits), SEEK_SET) < 0) |
176 | { | 176 | { |
177 | debugf("error - Can't seek to start of image data\n"); | 177 | debugf("error - Can't seek to start of image data\n"); |
178 | close(fd); | 178 | close(fd); |
179 | return 6; | 179 | return 6; |
180 | } | 180 | } |
181 | if (read(fd, (unsigned char*)bmp, (long)size) != size) | 181 | if (read(fd, (unsigned char*)bmp, (int)size) != size) |
182 | { | 182 | { |
183 | debugf("error - Can't read image\n"); | 183 | debugf("error - Can't read image\n"); |
184 | close(fd); | 184 | close(fd); |
@@ -276,12 +276,12 @@ int read_bmp_file(char* filename, | |||
276 | * destination formats | 276 | * destination formats |
277 | ****************************************************************************/ | 277 | ****************************************************************************/ |
278 | 278 | ||
279 | int transform_bitmap(const struct RGBQUAD *src, long width, long height, | 279 | int transform_bitmap(const struct RGBQUAD *src, int width, int height, |
280 | int format, unsigned short **dest, long *dst_width, | 280 | int format, unsigned short **dest, int *dst_width, |
281 | long *dst_height) | 281 | int *dst_height) |
282 | { | 282 | { |
283 | long row, col; | 283 | int row, col; |
284 | long dst_w, dst_h; | 284 | int dst_w, dst_h; |
285 | 285 | ||
286 | switch (format) | 286 | switch (format) |
287 | { | 287 | { |
@@ -395,12 +395,12 @@ int transform_bitmap(const struct RGBQUAD *src, long width, long height, | |||
395 | * some #define's | 395 | * some #define's |
396 | ****************************************************************************/ | 396 | ****************************************************************************/ |
397 | 397 | ||
398 | void generate_c_source(char *id, long width, long height, | 398 | void generate_c_source(char *id, int width, int height, |
399 | const unsigned short *t_bitmap, long t_width, | 399 | const unsigned short *t_bitmap, int t_width, |
400 | long t_height, int format) | 400 | int t_height, int format) |
401 | { | 401 | { |
402 | FILE *f; | 402 | FILE *f; |
403 | long i, a; | 403 | int i, a; |
404 | 404 | ||
405 | f = stdout; | 405 | f = stdout; |
406 | 406 | ||
@@ -439,10 +439,10 @@ void generate_c_source(char *id, long width, long height, | |||
439 | * Outputs an ascii picture of the bitmap | 439 | * Outputs an ascii picture of the bitmap |
440 | ****************************************************************************/ | 440 | ****************************************************************************/ |
441 | 441 | ||
442 | void generate_ascii(long width, long height, struct RGBQUAD *bitmap) | 442 | void generate_ascii(int width, int height, struct RGBQUAD *bitmap) |
443 | { | 443 | { |
444 | FILE *f; | 444 | FILE *f; |
445 | long x, y; | 445 | int x, y; |
446 | 446 | ||
447 | f = stdout; | 447 | f = stdout; |
448 | 448 | ||
@@ -482,8 +482,8 @@ int main(int argc, char **argv) | |||
482 | int format = 0; | 482 | int format = 0; |
483 | struct RGBQUAD *bitmap = NULL; | 483 | struct RGBQUAD *bitmap = NULL; |
484 | unsigned short *t_bitmap = NULL; | 484 | unsigned short *t_bitmap = NULL; |
485 | long width, height; | 485 | int width, height; |
486 | long t_width, t_height; | 486 | int t_width, t_height; |
487 | 487 | ||
488 | 488 | ||
489 | for (i = 1;i < argc;i++) | 489 | for (i = 1;i < argc;i++) |
diff --git a/tools/convbdf.c b/tools/convbdf.c index 141b46f55f..be746c6683 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c | |||
@@ -42,13 +42,13 @@ struct font { | |||
42 | int firstchar; /* first character in bitmap*/ | 42 | int firstchar; /* first character in bitmap*/ |
43 | int size; /* font size in glyphs*/ | 43 | int size; /* font size in glyphs*/ |
44 | bitmap_t* bits; /* 16-bit right-padded bitmap data*/ | 44 | bitmap_t* bits; /* 16-bit right-padded bitmap data*/ |
45 | unsigned long* offset; /* offsets into bitmap data*/ | 45 | unsigned int* offset; /* offsets into bitmap data*/ |
46 | unsigned char* width; /* character widths or NULL if fixed*/ | 46 | unsigned char* width; /* character widths or NULL if fixed*/ |
47 | int defaultchar; /* default char (not glyph index)*/ | 47 | int defaultchar; /* default char (not glyph index)*/ |
48 | long bits_size; /* # words of bitmap_t bits*/ | 48 | int bits_size; /* # words of bitmap_t bits*/ |
49 | 49 | ||
50 | /* unused by runtime system, read in by convbdf*/ | 50 | /* unused by runtime system, read in by convbdf*/ |
51 | unsigned long* offrot; /* offsets into rotated bitmap data*/ | 51 | unsigned int* offrot; /* offsets into rotated bitmap data*/ |
52 | char * name; /* font name*/ | 52 | char * name; /* font name*/ |
53 | char * facename; /* facename of font*/ | 53 | char * facename; /* facename of font*/ |
54 | char * copyright; /* copyright info for loadable fonts*/ | 54 | char * copyright; /* copyright info for loadable fonts*/ |
@@ -435,8 +435,8 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
435 | 435 | ||
436 | /* allocate bits, offset, and width arrays*/ | 436 | /* allocate bits, offset, and width arrays*/ |
437 | pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA); | 437 | pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA); |
438 | pf->offset = (unsigned long *)malloc(pf->size * sizeof(unsigned long)); | 438 | pf->offset = (unsigned int *)malloc(pf->size * sizeof(unsigned int)); |
439 | pf->offrot = (unsigned long *)malloc(pf->size * sizeof(unsigned long)); | 439 | pf->offrot = (unsigned int *)malloc(pf->size * sizeof(unsigned int)); |
440 | pf->width = (unsigned char *)malloc(pf->size * sizeof(unsigned char)); | 440 | pf->width = (unsigned char *)malloc(pf->size * sizeof(unsigned char)); |
441 | 441 | ||
442 | if (!pf->bits || !pf->offset || !pf->offrot || !pf->width) { | 442 | if (!pf->bits || !pf->offset || !pf->offrot || !pf->width) { |
@@ -451,14 +451,14 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
451 | /* read bdf font bitmaps, return 0 on error*/ | 451 | /* read bdf font bitmaps, return 0 on error*/ |
452 | int bdf_read_bitmaps(FILE *fp, struct font* pf) | 452 | int bdf_read_bitmaps(FILE *fp, struct font* pf) |
453 | { | 453 | { |
454 | long ofs = 0; | 454 | int ofs = 0; |
455 | long ofr = 0; | 455 | int ofr = 0; |
456 | int maxwidth = 0; | 456 | int maxwidth = 0; |
457 | int i, k, encoding, width; | 457 | int i, k, encoding, width; |
458 | int bbw, bbh, bbx, bby; | 458 | int bbw, bbh, bbx, bby; |
459 | int proportional = 0; | 459 | int proportional = 0; |
460 | int encodetable = 0; | 460 | int encodetable = 0; |
461 | long l; | 461 | int l; |
462 | char buf[256]; | 462 | char buf[256]; |
463 | 463 | ||
464 | /* reset file pointer*/ | 464 | /* reset file pointer*/ |
@@ -511,7 +511,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
511 | continue; | 511 | continue; |
512 | 512 | ||
513 | /* set bits offset in encode map*/ | 513 | /* set bits offset in encode map*/ |
514 | if (pf->offset[encoding-pf->firstchar] != (unsigned long)-1) { | 514 | if (pf->offset[encoding-pf->firstchar] != (unsigned int)-1) { |
515 | fprintf(stderr, "Error: duplicate encoding for character %d (0x%02x), ignoring duplicate\n", | 515 | fprintf(stderr, "Error: duplicate encoding for character %d (0x%02x), ignoring duplicate\n", |
516 | encoding, encoding); | 516 | encoding, encoding); |
517 | continue; | 517 | continue; |
@@ -589,7 +589,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
589 | for (i=0; i<pf->size; ++i) { | 589 | for (i=0; i<pf->size; ++i) { |
590 | int defchar = pf->defaultchar - pf->firstchar; | 590 | int defchar = pf->defaultchar - pf->firstchar; |
591 | 591 | ||
592 | if (pf->offset[i] == (unsigned long)-1) { | 592 | if (pf->offset[i] == (unsigned int)-1) { |
593 | pf->offset[i] = pf->offset[defchar]; | 593 | pf->offset[i] = pf->offset[defchar]; |
594 | pf->offrot[i] = pf->offrot[defchar]; | 594 | pf->offrot[i] = pf->offrot[defchar]; |
595 | pf->width[i] = pf->width[defchar]; | 595 | pf->width[i] = pf->width[defchar]; |
@@ -983,7 +983,7 @@ static int writeshort(FILE *fp, unsigned short s) | |||
983 | return putc(s>>8, fp) != EOF; | 983 | return putc(s>>8, fp) != EOF; |
984 | } | 984 | } |
985 | 985 | ||
986 | static int writelong(FILE *fp, unsigned long l) | 986 | static int writeint(FILE *fp, unsigned int l) |
987 | { | 987 | { |
988 | putc(l, fp); | 988 | putc(l, fp); |
989 | putc(l>>8, fp); | 989 | putc(l>>8, fp); |
@@ -1041,14 +1041,14 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1041 | writeshort(ofp, pf->height); | 1041 | writeshort(ofp, pf->height); |
1042 | writeshort(ofp, pf->ascent); | 1042 | writeshort(ofp, pf->ascent); |
1043 | writeshort(ofp, 0); | 1043 | writeshort(ofp, 0); |
1044 | writelong(ofp, pf->firstchar); | 1044 | writeint(ofp, pf->firstchar); |
1045 | writelong(ofp, pf->defaultchar); | 1045 | writeint(ofp, pf->defaultchar); |
1046 | writelong(ofp, pf->size); | 1046 | writeint(ofp, pf->size); |
1047 | 1047 | ||
1048 | /* variable font data sizes*/ | 1048 | /* variable font data sizes*/ |
1049 | writelong(ofp, pf->bits_size); /* # words of bitmap_t*/ | 1049 | writeint(ofp, pf->bits_size); /* # words of bitmap_t*/ |
1050 | writelong(ofp, pf->offset? pf->size: 0); /* # longs of offset*/ | 1050 | writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset*/ |
1051 | writelong(ofp, pf->width? pf->size: 0); /* # bytes of width*/ | 1051 | writeint(ofp, pf->width? pf->size: 0); /* # bytes of width*/ |
1052 | /* variable font data*/ | 1052 | /* variable font data*/ |
1053 | #ifdef ROTATE | 1053 | #ifdef ROTATE |
1054 | for (i=0; i<pf->size; ++i) | 1054 | for (i=0; i<pf->size; ++i) |
@@ -1083,7 +1083,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1083 | } | 1083 | } |
1084 | else | 1084 | else |
1085 | { | 1085 | { |
1086 | /* bitmap offset is large then 64K, use unsigned long for offset */ | 1086 | /* bitmap offset is large then 64K, use unsigned int for offset */ |
1087 | while (ftell(ofp) & 3) | 1087 | while (ftell(ofp) & 3) |
1088 | writebyte(ofp, 0); /* pad to 32-bit boundary*/ | 1088 | writebyte(ofp, 0); /* pad to 32-bit boundary*/ |
1089 | } | 1089 | } |
@@ -1095,7 +1095,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1095 | if ( pf->bits_size < 0xFFDB ) | 1095 | if ( pf->bits_size < 0xFFDB ) |
1096 | writeshort(ofp, pf->offrot[i]); | 1096 | writeshort(ofp, pf->offrot[i]); |
1097 | else | 1097 | else |
1098 | writelong(ofp, pf->offrot[i]); | 1098 | writeint(ofp, pf->offrot[i]); |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | 1101 | ||
@@ -1110,7 +1110,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1110 | 1110 | ||
1111 | if (pf->offset) | 1111 | if (pf->offset) |
1112 | for (i=0; i<pf->size; ++i) | 1112 | for (i=0; i<pf->size; ++i) |
1113 | writelong(ofp, pf->offset[i]); | 1113 | writeint(ofp, pf->offset[i]); |
1114 | 1114 | ||
1115 | if (pf->width) | 1115 | if (pf->width) |
1116 | for (i=0; i<pf->size; ++i) | 1116 | for (i=0; i<pf->size; ++i) |