From 5bae9f28100c12605be1a5852d04cdf973fd323c Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Wed, 17 May 2006 18:21:50 -0500 Subject: Switch to using standard types. This is userspace, not kernel. Signed-off-by: Josh Boyer --- include/mtd_swab.h | 24 +++++++++---------- jffs-dump.c | 68 +++++++++++++++++++++++++++--------------------------- mkfs.jffs.c | 64 +++++++++++++++++++++++++------------------------- rfddump.c | 10 ++++---- rfdformat.c | 2 +- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/include/mtd_swab.h b/include/mtd_swab.h index 05732a9..a5175da 100644 --- a/include/mtd_swab.h +++ b/include/mtd_swab.h @@ -4,26 +4,26 @@ #include #define swab16(x) \ - ((__u16)( \ - (((__u16)(x) & (__u16)0x00ffU) << 8) | \ - (((__u16)(x) & (__u16)0xff00U) >> 8) )) + ((uint16_t)( \ + (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(x) & (uint16_t)0xff00U) >> 8) )) #define swab32(x) \ - ((__u32)( \ - (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ - (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ - (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ - (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) + ((uint32_t)( \ + (((uint32_t)(x) & (__u32)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (__u32)0xff000000UL) >> 24) )) #if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); }) -#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); }) +#define cpu_to_le16(x) ({ uint16_t _x = x; swab16(_x); }) +#define cpu_to_le32(x) ({ uint32_t _x = x; swab32(_x); }) #define cpu_to_be16(x) (x) #define cpu_to_be32(x) (x) #else #define cpu_to_le16(x) (x) #define cpu_to_le32(x) (x) -#define cpu_to_be16(x) ({ __u16 _x = x; swab16(_x); }) -#define cpu_to_be32(x) ({ __u32 _x = x; swab32(_x); }) +#define cpu_to_be16(x) ({ uint16_t _x = x; swab16(_x); }) +#define cpu_to_be32(x) ({ uint32_t _x = x; swab32(_x); }) #endif #define le16_to_cpu(x) cpu_to_le16(x) #define be16_to_cpu(x) cpu_to_be16(x) diff --git a/jffs-dump.c b/jffs-dump.c index 0a8b7e5..771025e 100644 --- a/jffs-dump.c +++ b/jffs-dump.c @@ -27,7 +27,7 @@ /* How many padding bytes should be inserted between two chunks of data on the flash? */ #define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE \ - - ((__u32)(size) % JFFS_ALIGN_SIZE)) \ + - ((uint32_t)(size) % JFFS_ALIGN_SIZE)) \ % JFFS_ALIGN_SIZE) #define JFFS_EMPTY_BITMASK 0xffffffff @@ -38,28 +38,28 @@ struct jffs_raw_inode { - __u32 magic; /* A constant magic number. */ - __u32 ino; /* Inode number. */ - __u32 pino; /* Parent's inode number. */ - __u32 version; /* Version number. */ - __u32 mode; /* file_type, mode */ - __u16 uid; - __u16 gid; - __u32 atime; - __u32 mtime; - __u32 ctime; - __u32 offset; /* Where to begin to write. */ - __u32 dsize; /* Size of the file data. */ - __u32 rsize; /* How much are going to be replaced? */ - __u8 nsize; /* Name length. */ - __u8 nlink; /* Number of links. */ - __u8 spare : 6; /* For future use. */ - __u8 rename : 1; /* Is this a special rename? */ - __u8 deleted : 1; /* Has this file been deleted? */ - __u8 accurate; /* The inode is obsolete if accurate == 0. */ - __u32 dchksum; /* Checksum for the data. */ - __u16 nchksum; /* Checksum for the name. */ - __u16 chksum; /* Checksum for the raw_inode. */ + uint32_t magic; /* A constant magic number. */ + uint32_t ino; /* Inode number. */ + uint32_t pino; /* Parent's inode number. */ + uint32_t version; /* Version number. */ + uint32_t mode; /* file_type, mode */ + uint16_t uid; + uint16_t gid; + uint32_t atime; + uint32_t mtime; + uint32_t ctime; + uint32_t offset; /* Where to begin to write. */ + uint32_t dsize; /* Size of the file data. */ + uint32_t rsize; /* How much are going to be replaced? */ + uint8_t nsize; /* Name length. */ + uint8_t nlink; /* Number of links. */ + uint8_t spare : 6; /* For future use. */ + uint8_t rename : 1; /* Is this a special rename? */ + uint8_t deleted : 1; /* Has this file been deleted? */ + uint8_t accurate; /* The inode is obsolete if accurate == 0. */ + uint32_t dchksum; /* Checksum for the data. */ + uint16_t nchksum; /* Checksum for the name. */ + uint16_t chksum; /* Checksum for the raw_inode. */ }; @@ -80,7 +80,7 @@ int verbose = 0; #define ENDIAN_LITTLE 2 int endian = ENDIAN_HOST; -static __u32 jffs_checksum(void *data, int size); +static uint32_t jffs_checksum(void *data, int size); void jffs_print_trace(const char *path, int depth); int make_root_dir(FILE *fs, int first_ino, const char *root_dir_path, int depth); @@ -89,11 +89,11 @@ void read_data(struct jffs_file *f, const char *path, int offset); int mkfs(FILE *fs, const char *path, int ino, int parent, int depth); -static __u32 +static uint32_t jffs_checksum(void *data, int size) { - __u32 sum = 0; - __u8 *ptr = (__u8 *)data; + uint32_t sum = 0; + uint8_t *ptr = (uint8_t *)data; while (size-- > 0) { @@ -178,7 +178,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode) fprintf(stdout, "}\n"); } -static void write_val32(__u32 *adr, __u32 val) +static void write_val32(uint32_t *adr, uint32_t val) { switch(endian) { case ENDIAN_HOST: @@ -193,7 +193,7 @@ static void write_val32(__u32 *adr, __u32 val) } } -static void write_val16(__u16 *adr, __u16 val) +static void write_val16(uint16_t *adr, uint16_t val) { switch(endian) { case ENDIAN_HOST: @@ -208,9 +208,9 @@ static void write_val16(__u16 *adr, __u16 val) } } -static __u32 read_val32(__u32 *adr) +static uint32_t read_val32(uint32_t *adr) { - __u32 val; + uint32_t val; switch(endian) { case ENDIAN_HOST: @@ -226,9 +226,9 @@ static __u32 read_val32(__u32 *adr) return val; } -static __u16 read_val16(__u16 *adr) +static uint16_t read_val16(uint16_t *adr) { - __u16 val; + uint16_t val; switch(endian) { case ENDIAN_HOST: @@ -249,7 +249,7 @@ main(int argc, char **argv) { int fs; struct stat sb; - __u32 wordbuf; + uint32_t wordbuf; off_t pos = 0; off_t end; struct jffs_raw_inode ino; diff --git a/mkfs.jffs.c b/mkfs.jffs.c index 7e8de96..de6623a 100644 --- a/mkfs.jffs.c +++ b/mkfs.jffs.c @@ -32,34 +32,34 @@ static int MAX_CHUNK_SIZE = 32768; /* How many padding bytes should be inserted between two chunks of data on the flash? */ #define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE \ - - ((__u32)(size) % JFFS_ALIGN_SIZE)) \ + - ((uint32_t)(size) % JFFS_ALIGN_SIZE)) \ % JFFS_ALIGN_SIZE) struct jffs_raw_inode { - __u32 magic; /* A constant magic number. */ - __u32 ino; /* Inode number. */ - __u32 pino; /* Parent's inode number. */ - __u32 version; /* Version number. */ - __u32 mode; /* file_type, mode */ - __u16 uid; - __u16 gid; - __u32 atime; - __u32 mtime; - __u32 ctime; - __u32 offset; /* Where to begin to write. */ - __u32 dsize; /* Size of the file data. */ - __u32 rsize; /* How much are going to be replaced? */ - __u8 nsize; /* Name length. */ - __u8 nlink; /* Number of links. */ - __u8 spare : 6; /* For future use. */ - __u8 rename : 1; /* Is this a special rename? */ - __u8 deleted : 1; /* Has this file been deleted? */ - __u8 accurate; /* The inode is obsolete if accurate == 0. */ - __u32 dchksum; /* Checksum for the data. */ - __u16 nchksum; /* Checksum for the name. */ - __u16 chksum; /* Checksum for the raw_inode. */ + uint32_t magic; /* A constant magic number. */ + uint32_t ino; /* Inode number. */ + uint32_t pino; /* Parent's inode number. */ + uint32_t version; /* Version number. */ + uint32_t mode; /* file_type, mode */ + uint16_t uid; + uint16_t gid; + uint32_t atime; + uint32_t mtime; + uint32_t ctime; + uint32_t offset; /* Where to begin to write. */ + uint32_t dsize; /* Size of the file data. */ + uint32_t rsize; /* How much are going to be replaced? */ + uint8_t nsize; /* Name length. */ + uint8_t nlink; /* Number of links. */ + uint8_t spare : 6; /* For future use. */ + uint8_t rename : 1; /* Is this a special rename? */ + uint8_t deleted : 1; /* Has this file been deleted? */ + uint8_t accurate; /* The inode is obsolete if accurate == 0. */ + uint32_t dchksum; /* Checksum for the data. */ + uint16_t nchksum; /* Checksum for the name. */ + uint16_t chksum; /* Checksum for the raw_inode. */ }; @@ -80,7 +80,7 @@ int verbose = 0; #define ENDIAN_LITTLE 2 int endian = ENDIAN_HOST; -static __u32 jffs_checksum(void *data, int size); +static uint32_t jffs_checksum(void *data, int size); void jffs_print_trace(const char *path, int depth); int make_root_dir(FILE *fs, int first_ino, const char *root_dir_path, int depth); @@ -89,11 +89,11 @@ void read_data(struct jffs_file *f, const char *path, int offset); int mkfs(FILE *fs, const char *path, int ino, int parent, int depth); -static __u32 +static uint32_t jffs_checksum(void *data, int size) { - __u32 sum = 0; - __u8 *ptr = (__u8 *)data; + uint32_t sum = 0; + uint8_t *ptr = (uint8_t *)data; while (size-- > 0) { @@ -178,7 +178,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode) fprintf(stderr, "}\n"); } -static void write_val32(__u32 *adr, __u32 val) +static void write_val32(uint32_t *adr, uint32_t val) { switch(endian) { case ENDIAN_HOST: @@ -193,7 +193,7 @@ static void write_val32(__u32 *adr, __u32 val) } } -static void write_val16(__u16 *adr, __u16 val) +static void write_val16(uint16_t *adr, uint16_t val) { switch(endian) { case ENDIAN_HOST: @@ -208,9 +208,9 @@ static void write_val16(__u16 *adr, __u16 val) } } -static __u32 read_val32(__u32 *adr) +static uint32_t read_val32(uint32_t *adr) { - __u32 val = 0; + uint32_t val = 0; switch(endian) { case ENDIAN_HOST: @@ -316,7 +316,7 @@ write_file(struct jffs_file *f, FILE *fs, struct stat st) { if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) { - __u16 tmp; + uint16_t tmp; switch(endian) { case ENDIAN_HOST: diff --git a/rfddump.c b/rfddump.c index f5884ab..d939dbe 100644 --- a/rfddump.c +++ b/rfddump.c @@ -45,7 +45,7 @@ struct rfd { int header_sectors; int data_sectors; int header_size; - __u16 *header; + uint16_t *header; int sector_count; int *sector_map; const char *mtd_filename; @@ -146,7 +146,7 @@ int build_block_map(struct rfd *rfd, int fd, int block) sectors = 0; for (i=0; idata_sectors; i++) { - __u16 entry = le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]); + uint16_t entry = le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]); if (entry == SECTOR_FREE || entry == SECTOR_DELETED) continue; @@ -184,7 +184,7 @@ int main(int argc, char *argv[]) struct rfd rfd; int i, blocks_found; int out_fd = 0; - __u8 sector[512]; + uint8_t sector[512]; int blank, rc, cylinders; process_options(argc, argv, &rfd); @@ -240,13 +240,13 @@ int main(int argc, char *argv[]) rfd.header_sectors = ((HEADER_MAP_OFFSET + sectors_per_block) * - sizeof(__u16) + SECTOR_SIZE - 1) / SECTOR_SIZE; + sizeof(uint16_t) + SECTOR_SIZE - 1) / SECTOR_SIZE; rfd.data_sectors = sectors_per_block - rfd.header_sectors; cylinders = ((rfd.block_count - 1) * rfd.data_sectors - 1) / SECTORS_PER_TRACK; rfd.sector_count = cylinders * SECTORS_PER_TRACK; rfd.header_size = - (HEADER_MAP_OFFSET + rfd.data_sectors) * sizeof(__u16); + (HEADER_MAP_OFFSET + rfd.data_sectors) * sizeof(uint16_t); rfd.header = malloc(rfd.header_size); if (!rfd.header) { diff --git a/rfdformat.c b/rfdformat.c index ee84a21..dbe1229 100644 --- a/rfdformat.c +++ b/rfdformat.c @@ -90,7 +90,7 @@ void process_options(int argc, char *argv[], const char **mtd_filename) int main(int argc, char *argv[]) { - static const __u8 magic[] = { 0x93, 0x91 }; + static const uint8_t magic[] = { 0x93, 0x91 }; int fd, block_count, i; struct mtd_info_user mtd_info; char buf[512]; -- cgit v1.2.3