mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
Move the typesafe min() macro from xc_dom_decompress_unsafe_xz.c to xc_private.h, and complement it with an equivalent max() macro. Replace current users of type unsafe MIN()/MAX() macros, and remove their scattered definitions. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> CC: Ian Campbell <Ian.Campbell@citrix.com> CC: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
47 lines
870 B
C
47 lines
870 B
C
#include <stdio.h>
|
|
#include <endian.h>
|
|
#include <stdlib.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <inttypes.h>
|
|
|
|
#include "xg_private.h"
|
|
#include "xc_dom_decompress_unsafe.h"
|
|
|
|
// TODO
|
|
#define XZ_DEC_X86
|
|
|
|
typedef char bool_t;
|
|
typedef uint8_t u8;
|
|
typedef uint16_t u16;
|
|
typedef uint32_t u32;
|
|
typedef uint32_t __le32;
|
|
|
|
static inline u32 cpu_to_le32(const u32 v)
|
|
{
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
|
return (((v & 0x000000ffUL) << 24) |
|
|
((v & 0x0000ff00UL) << 8) |
|
|
((v & 0x00ff0000UL) >> 8) |
|
|
((v & 0xff000000UL) >> 24));
|
|
#else
|
|
return v;
|
|
#endif
|
|
}
|
|
|
|
static inline u32 le32_to_cpup(const u32 *p)
|
|
{
|
|
return cpu_to_le32(*p);
|
|
}
|
|
|
|
#define __force
|
|
#define always_inline
|
|
|
|
#include "../../xen/common/unxz.c"
|
|
|
|
int xc_try_xz_decode(
|
|
struct xc_dom_image *dom, void **blob, size_t *size)
|
|
{
|
|
return xc_dom_decompress_unsafe(unxz, dom, blob, size);
|
|
}
|