source: grub-pc/trunk/fuentes/grub-core/lib/xzembed/xz_config.h @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 3.8 KB
Line 
1/* xz_config.h - Private includes and definitions for userspace use */
2/*
3 *  GRUB  --  GRand Unified Bootloader
4 *  Copyright (C) 2010  Free Software Foundation, Inc.
5 *
6 *  GRUB is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  GRUB is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18 */
19/*
20 * This file is based on code from XZ embedded project
21 * http://tukaani.org/xz/embedded.html
22 */
23
24#ifndef XZ_CONFIG_H
25#define XZ_CONFIG_H
26
27/* Enable BCJ filter decoders. */
28
29#ifndef GRUB_EMBED_DECOMPRESSOR
30
31#define XZ_DEC_X86
32#define XZ_DEC_POWERPC
33#define XZ_DEC_IA64
34#define XZ_DEC_ARM
35#define XZ_DEC_ARMTHUMB
36#define XZ_DEC_SPARC
37
38#else
39
40#if defined(__i386__) || defined(__x86_64__)
41  #define XZ_DEC_X86
42#endif
43
44#ifdef __powerpc__
45  #define XZ_DEC_POWERPC
46#endif
47
48#ifdef __ia64__
49  #define XZ_DEC_IA64
50#endif
51
52#ifdef __arm__
53  #define XZ_DEC_ARM
54#endif
55
56#ifdef __arm__
57  #define XZ_DEC_ARMTHUMB
58#endif
59
60#ifdef __sparc__
61  #define XZ_DEC_SPARC
62#endif
63#endif
64
65#include "xz.h"
66#include <stdlib.h>
67
68#define kmalloc(size, flags) malloc(size)
69#define kfree(ptr) free(ptr)
70#define vmalloc(size) malloc(size)
71#define vfree(ptr) free(ptr)
72
73#define memeq(a, b, size) (memcmp(a, b, size) == 0)
74#define memzero(buf, size) memset(buf, 0, size)
75
76#define min(x, y) ((x) < (y) ? (x) : (y))
77#define min_t(type, x, y) min(x, y)
78
79/*
80 * Some functions have been marked with __always_inline to keep the
81 * performance reasonable even when the compiler is optimizing for
82 * small code size. You may be able to save a few bytes by #defining
83 * __always_inline to plain inline, but don't complain if the code
84 * becomes slow.
85 *
86 * NOTE: System headers on GNU/Linux may #define this macro already,
87 * so if you want to change it, it you need to #undef it first.
88 */
89#ifndef __always_inline
90#       ifdef __GNUC__
91#               define __always_inline \
92                        inline __attribute__((__always_inline__))
93#       else
94#               define __always_inline inline
95#       endif
96#endif
97
98/*
99 * Some functions are marked to never be inlined to reduce stack usage.
100 * If you don't care about stack usage, you may want to modify this so
101 * that noinline_for_stack is #defined to be empty even when using GCC.
102 * Doing so may save a few bytes in binary size.
103 */
104#ifndef noinline_for_stack
105#       ifdef __GNUC__
106#               define noinline_for_stack __attribute__((__noinline__))
107#       else
108#               define noinline_for_stack
109#       endif
110#endif
111
112/* Inline functions to access unaligned unsigned 32-bit integers */
113static inline uint32_t get_unaligned_le32(const uint8_t *buf)
114{
115        return (uint32_t)buf[0]
116                        | ((uint32_t)buf[1] << 8)
117                        | ((uint32_t)buf[2] << 16)
118                        | ((uint32_t)buf[3] << 24);
119}
120
121static inline uint32_t get_unaligned_be32(const uint8_t *buf)
122{
123        return (uint32_t)(buf[0] << 24)
124                        | ((uint32_t)buf[1] << 16)
125                        | ((uint32_t)buf[2] << 8)
126                        | (uint32_t)buf[3];
127}
128
129static inline void put_unaligned_le32(uint32_t val, uint8_t *buf)
130{
131        buf[0] = (uint8_t)val;
132        buf[1] = (uint8_t)(val >> 8);
133        buf[2] = (uint8_t)(val >> 16);
134        buf[3] = (uint8_t)(val >> 24);
135}
136
137static inline void put_unaligned_be32(uint32_t val, uint8_t *buf)
138{
139        buf[0] = (uint8_t)(val >> 24);
140        buf[1] = (uint8_t)(val >> 16);
141        buf[2] = (uint8_t)(val >> 8);
142        buf[3] = (uint8_t)val;
143}
144
145/*
146 * Use get_unaligned_le32() also for aligned access for simplicity. On
147 * little endian systems, #define get_le32(ptr) (*(const uint32_t *)(ptr))
148 * could save a few bytes in code size.
149 */
150#define get_le32 get_unaligned_le32
151
152#endif
Note: See TracBrowser for help on using the repository browser.