summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/fileio.h2
-rw-r--r--src/helper/types.h28
2 files changed, 16 insertions, 14 deletions
diff --git a/src/helper/fileio.h b/src/helper/fileio.h
index 55e6f323..5c0a88da 100644
--- a/src/helper/fileio.h
+++ b/src/helper/fileio.h
@@ -82,6 +82,8 @@ extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
extern int fileio_seek(fileio_t *fileio, u32 position);
extern int fileio_close(fileio_t *fileio);
extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type);
+extern int fileio_read_u32(fileio_t *fileio, u32 *data);
+extern int fileio_write_u32(fileio_t *fileio, u32 data);
#define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
#define ERROR_FILEIO_NOT_FOUND (-1201)
diff --git a/src/helper/types.h b/src/helper/types.h
index 69cb16a2..a68c301e 100644
--- a/src/helper/types.h
+++ b/src/helper/types.h
@@ -40,23 +40,23 @@ typedef unsigned long long u64;
#ifdef WORDS_BIGENDIAN /* big endian host */
-#define le_to_h_u32(x) (u32)(x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24)
-#define le_to_h_u16(x) (u16)(x[0] | x[1] << 8)
+#define le_to_h_u32(x) (u32)((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24)
+#define le_to_h_u16(x) (u16)((x)[0] | (x)[1] << 8)
#define be_to_h_u32(x) (*(u32*)(x))
#define be_to_h_u16(x) (*(u16*)(x))
#define h_u32_to_le(buf, val) \
do { \
- buf[3] = (val & 0xff000000) >> 24; \
- buf[2] = (val & 0x00ff0000) >> 16; \
- buf[1] = (val & 0x0000ff00) >> 8; \
- buf[0] = (val & 0x000000ff); \
+ (buf)[3] = ((val) & 0xff000000) >> 24; \
+ (buf)[2] = ((val) & 0x00ff0000) >> 16; \
+ (buf)[1] = ((val) & 0x0000ff00) >> 8; \
+ (buf)[0] = ((val) & 0x000000ff); \
} while (0)
#define h_u16_to_le(buf, val) \
do { \
- buf[0] = (val & 0xff000) >> 8; \
- buf[1] = (val & 0x00ff); \
+ (buf)[0] = ((val) & 0xff000) >> 8; \
+ (buf)[1] = ((val) & 0x00ff); \
} while (0)
#define h_u32_to_be(buf, val) do { *(u32*)(buf) = (val); } while (0)
@@ -73,16 +73,16 @@ typedef unsigned long long u64;
#define h_u32_to_be(buf, val) \
do { \
- buf[0] = (val & 0xff000000) >> 24; \
- buf[1] = (val & 0x00ff0000) >> 16; \
- buf[2] = (val & 0x0000ff00) >> 8; \
- buf[3] = (val & 0x000000ff); \
+ (buf)[0] = ((val) & 0xff000000) >> 24; \
+ (buf)[1] = ((val) & 0x00ff0000) >> 16; \
+ (buf)[2] = ((val) & 0x0000ff00) >> 8; \
+ (buf)[3] = ((val) & 0x000000ff); \
} while (0)
#define h_u16_to_be(buf, val) \
do { \
- buf[0] = (val & 0xff000) >> 8; \
- buf[1] = (val & 0x00ff); \
+ (buf)[0] = ((val) & 0xff000) >> 8; \
+ (buf)[1] = ((val) & 0x00ff); \
} while (0)
#endif