Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / libinstaller / syslxint.h
blob120026de5a691fea4bec23e2a390ed6e0497e974
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
13 #ifndef SYSLXINT_H
14 #define SYSLXINT_H
16 #include "syslinux.h"
19 * Access functions for littleendian numbers, possibly misaligned.
21 static inline uint8_t get_8(const unsigned char *p)
23 return *(const uint8_t *)p;
26 static inline uint16_t get_16(const unsigned char *p)
28 #if defined(__i386__) || defined(__x86_64__)
29 /* Littleendian and unaligned-capable */
30 return *(const uint16_t *)p;
31 #else
32 return (uint16_t)p[0] + ((uint16_t)p[1] << 8);
33 #endif
36 static inline uint32_t get_32(const unsigned char *p)
38 #if defined(__i386__) || defined(__x86_64__)
39 /* Littleendian and unaligned-capable */
40 return *(const uint32_t *)p;
41 #else
42 return (uint32_t)p[0] + ((uint32_t)p[1] << 8) +
43 ((uint32_t)p[2] << 16) + ((uint32_t)p[3] << 24);
44 #endif
47 static inline void set_16(unsigned char *p, uint16_t v)
49 #if defined(__i386__) || defined(__x86_64__)
50 /* Littleendian and unaligned-capable */
51 *(uint16_t *)p = v;
52 #else
53 p[0] = (v & 0xff);
54 p[1] = ((v >> 8) & 0xff);
55 #endif
58 static inline void set_32(unsigned char *p, uint32_t v)
60 #if defined(__i386__) || defined(__x86_64__)
61 /* Littleendian and unaligned-capable */
62 *(uint32_t *)p = v;
63 #else
64 p[0] = (v & 0xff);
65 p[1] = ((v >> 8) & 0xff);
66 p[2] = ((v >> 16) & 0xff);
67 p[3] = ((v >> 24) & 0xff);
68 #endif
71 #define SECTOR_SHIFT 9 /* 512-byte sectors */
72 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
74 #endif /* SYSLXINT_H */