aboutsummaryrefslogtreecommitdiffstats
path: root/libinstaller/syslxint.h
diff options
context:
space:
mode:
Diffstat (limited to 'libinstaller/syslxint.h')
-rw-r--r--libinstaller/syslxint.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h
index 3f50e32c..fc3932b2 100644
--- a/libinstaller/syslxint.h
+++ b/libinstaller/syslxint.h
@@ -20,16 +20,17 @@
*/
static inline uint8_t get_8(const uint8_t *p)
{
- return *(const uint8_t *)p;
+ return *p;
}
static inline uint16_t get_16(const uint16_t *p)
{
#if defined(__i386__) || defined(__x86_64__)
/* Littleendian and unaligned-capable */
- return *(const uint16_t *)p;
+ return *p;
#else
- return (uint16_t)p[0] + ((uint16_t)p[1] << 8);
+ const uint8_t *pp = (const uint8_t *)p;
+ return (uint16_t)pp[0] + ((uint16_t)pp[1] << 8);
#endif
}
@@ -37,21 +38,28 @@ static inline uint32_t get_32(const uint32_t *p)
{
#if defined(__i386__) || defined(__x86_64__)
/* Littleendian and unaligned-capable */
- return *(const uint32_t *)p;
+ return *p;
#else
- return (uint32_t)p[0] + ((uint32_t)p[1] << 8) +
- ((uint32_t)p[2] << 16) + ((uint32_t)p[3] << 24);
+ const uint8_t *pp = (const uint8_t *)p;
+ return (uint32_t)pp[0] + ((uint32_t)pp[1] << 8) +
+ ((uint32_t)pp[2] << 16) + ((uint32_t)pp[3] << 24);
#endif
}
+static inline void set_8(uint8_t *p, uint8_t v)
+{
+ *p = v;
+}
+
static inline void set_16(uint16_t *p, uint16_t v)
{
#if defined(__i386__) || defined(__x86_64__)
/* Littleendian and unaligned-capable */
*(uint16_t *)p = v;
#else
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
+ uint8_t *pp = (uint8_t *)p;
+ pp[0] = (v & 0xff);
+ pp[1] = ((v >> 8) & 0xff);
#endif
}
@@ -61,16 +69,14 @@ static inline void set_32(uint32_t *p, uint32_t v)
/* Littleendian and unaligned-capable */
*(uint32_t *)p = v;
#else
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
- p[2] = ((v >> 16) & 0xff);
- p[3] = ((v >> 24) & 0xff);
+ uint8_t *pp = (uint8_t *)p;
+ pp[0] = (v & 0xff);
+ pp[1] = ((v >> 8) & 0xff);
+ pp[2] = ((v >> 16) & 0xff);
+ pp[3] = ((v >> 24) & 0xff);
#endif
}
-#define SECTOR_SHIFT 9 /* 512-byte sectors */
-#define SECTOR_SIZE (1 << SECTOR_SHIFT)
-
#define LDLINUX_MAGIC 0x3eb202fe
/* Patch area for disk-based installers */