diff options
| author | H. Peter Anvin <hpa@zytor.com> | 2007-12-14 15:14:10 -0800 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2007-12-14 15:15:35 -0800 |
| commit | 660d3eac7782f63ae220ac4654e784f5dac1adc6 (patch) | |
| tree | 8dd318264df634b47e40772bafaa78be7fa87f7d /libinstaller/syslxint.h | |
| parent | d62997e81e0edfab8eb8cdcb026ccc61a7473e7e (diff) | |
| download | syslinux-3.60-pre4.tar.gz | |
Add missing libinstaller filessyslinux-3.60-pre4
Files missing from previous checkin, sigh.
Diffstat (limited to 'libinstaller/syslxint.h')
| -rw-r--r-- | libinstaller/syslxint.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h new file mode 100644 index 00000000..e296df1d --- /dev/null +++ b/libinstaller/syslxint.h @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +#ifndef SYSLXINT_H +#define SYSLXINT_H + +#include "syslinux.h" + +/* + * Access functions for littleendian numbers, possibly misaligned. + */ +static inline uint8_t get_8(const unsigned char *p) +{ + return *(const uint8_t *)p; +} + +static inline uint16_t get_16(const unsigned char *p) +{ +#if defined(__i386__) || defined(__x86_64__) + /* Littleendian and unaligned-capable */ + return *(const uint16_t *)p; +#else + return (uint16_t)p[0] + ((uint16_t)p[1] << 8); +#endif +} + +static inline uint32_t get_32(const unsigned char *p) +{ +#if defined(__i386__) || defined(__x86_64__) + /* Littleendian and unaligned-capable */ + return *(const 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) +{ +#if defined(__i386__) || defined(__x86_64__) + /* Littleendian and unaligned-capable */ + *(uint16_t *)p = v; +#else + p[0] = (v & 0xff); + p[1] = ((v >> 8) & 0xff); +#endif +} + +static inline void set_32(unsigned char *p, uint32_t v) +{ +#if defined(__i386__) || defined(__x86_64__) + /* 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); +#endif +} + +#define SECTOR_SHIFT 9 /* 512-byte sectors */ +#define SECTOR_SIZE (1 << SECTOR_SHIFT) + +#endif /* SYSLXINT_H */ |
