/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_TYPES_HEADER
#include <config.h>
#ifdef GRUB_UTIL
# ifdef WORDS_BIGENDIAN
# else
# endif
#else /* ! GRUB_UTIL */
# ifdef GRUB_TARGET_WORDS_BIGENDIAN
# else
# endif
#endif /* ! GRUB_UTIL */
# error "This architecture is not supported because sizeof(void *) != sizeof(long)"
#endif
# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8"
#endif
#ifndef GRUB_TARGET_WORDSIZE
# if GRUB_TARGET_SIZEOF_VOID_P == 4
# endif
#endif
/* Define various wide integers. */
typedef signed char grub_int8_t;
typedef short grub_int16_t;
typedef int grub_int32_t;
#if GRUB_CPU_SIZEOF_LONG == 8
typedef long grub_int64_t;
#else
typedef long long grub_int64_t;
#endif
typedef unsigned char grub_uint8_t;
typedef unsigned short grub_uint16_t;
typedef unsigned grub_uint32_t;
#if GRUB_CPU_SIZEOF_LONG == 8
typedef unsigned long grub_uint64_t;
typedef unsigned long long grub_uintptr_t;
typedef long long grub_intptr_t;
#else
typedef unsigned long long grub_uint64_t;
typedef unsigned long grub_uintptr_t;
typedef long grub_intptr_t;
#endif
/* Misc types. */
#if GRUB_TARGET_SIZEOF_VOID_P == 8
#else
#endif
#if GRUB_CPU_SIZEOF_VOID_P == 8
# if GRUB_CPU_SIZEOF_LONG == 8
# else
# endif
#else
#endif
#if GRUB_CPU_SIZEOF_LONG == 8
#else
#endif
#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)]
/* The type for representing a file offset. */
/* The type for representing a disk block address. */
/* Byte-orders. */
#define grub_swap_bytes16(x) \
({ \
grub_uint16_t _x = (x); \
})
#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24))
#define grub_swap_bytes64_compile_time(x) \
({ \
grub_uint64_t _x = (x); \
| (_x >> 56)); \
})
{
return __builtin_bswap32(x);
}
{
return __builtin_bswap64(x);
}
#else /* not gcc 4.3 or newer */
#define grub_swap_bytes32(x) \
({ \
grub_uint32_t _x = (x); \
| (_x >> 24)); \
})
#define grub_swap_bytes64(x) \
({ \
grub_uint64_t _x = (x); \
| (_x >> 56)); \
})
#endif /* not gcc 4.3 or newer */
#ifdef GRUB_CPU_WORDS_BIGENDIAN
#else /* ! WORDS_BIGENDIAN */
#endif /* ! WORDS_BIGENDIAN */
{
struct grub_unaligned_uint16_t
{
} __attribute__ ((packed));
= (const struct grub_unaligned_uint16_t *) ptr;
return dd->d;
}
{
struct grub_unaligned_uint16_t
{
} __attribute__ ((packed));
}
{
struct grub_unaligned_uint32_t
{
} __attribute__ ((packed));
= (const struct grub_unaligned_uint32_t *) ptr;
return dd->d;
}
{
struct grub_unaligned_uint32_t
{
} __attribute__ ((packed));
}
{
struct grub_unaligned_uint64_t
{
} __attribute__ ((packed));
= (const struct grub_unaligned_uint64_t *)ptr;
return dd->d;
}
#endif /* ! GRUB_TYPES_HEADER */