summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2004-06-13 20:51:02 +0000
committerhpa <hpa>2004-06-13 20:51:02 +0000
commit703d2d3523a3f073a5962418b753684c0e98397a (patch)
tree75e74ffdcd4f8a403984a0ab13090de15c20cbfe
parentdf9e0772322a6afa063789c007585938c4a7846d (diff)
downloadsyslinux-703d2d3523a3f073a5962418b753684c0e98397a.tar.gz
Fix attributes; do direct access on x86
-rw-r--r--syslxmod.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/syslxmod.c b/syslxmod.c
index 5d385e55..1713791f 100644
--- a/syslxmod.c
+++ b/syslxmod.c
@@ -55,15 +55,25 @@ enum bs_offsets {
/*
* Access functions for littleendian numbers, possibly misaligned.
*/
-static inline uint16_t get_16(unsigned char *p)
+static inline uint16_t get_16(const unsigned char *p)
{
+#if defined(__i386__) || defined(__x86_64__)
+ /* Littleendian and unaligned-capable */
+ return *(uint16_t *)p;
+#else
return (uint16_t)p[0] + ((uint16_t)p[1] << 8);
+#endif
}
-static inline uint32_t get_32(unsigned char *p)
+static inline uint32_t get_32(const unsigned char *p)
{
+#if defined(__i386__) || defined(__x86_64__)
+ /* Littleendian and unaligned-capable */
+ return *(uint32_t *)p;
+#else
return (uint32_t)p[0] + ((uint32_t)p[1] << 8) +
((uint32_t)p[2] << 16) + ((uint32_t)p[3] << 24);
+#endif
}
static inline void set_16(unsigned char *p, uint16_t v)