hush/archival/libunarchive/unxz/xz_config.h
Denys Vlasenko 602ce69afb unxz: new applet, complete with xzcat and xz -d aliases
function                                             old     new   delta
unpack_xz_stream_stdin                                 -    3953   +3953
lzma_main                                              -    2601   +2601
lzma_len                                               -     516    +516
dec_vli                                                -     165    +165
dict_repeat                                            -     103    +103
lzma_reset                                             -      98     +98
fill_temp                                              -      98     +98
crc32_validate                                         -      93     +93
xz_dec_reset                                           -      77     +77
unxz_main                                              -      77     +77
index_update                                           -      47     +47
xz_crc32                                               -      40     +40
packed_usage                                       27044   27060     +16
make_new_name_unxz                                     -      14     +14
applet_names                                        2240    2254     +14
applet_main                                         1312    1324     +12
applet_nameofs                                       656     662      +6
unpack_unxz                                            -       5      +5
send_tree                                            355     360      +5
applet_install_loc                                   164     166      +2
------------------------------------------------------------------------------
(add/remove: 15/0 grow/shrink: 6/0 up/down: 7942/0)          Total: 7942 bytes
   text    data     bss     dec     hex filename
 844032     453    6812  851297   cfd61 busybox_old
 852063     453    6812  859328   d1cc0 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-30 03:35:18 +02:00

120 lines
3.1 KiB
C

/*
* Private includes and definitions for userspace use of XZ Embedded
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/
#ifndef XZ_CONFIG_H
#define XZ_CONFIG_H
/* Uncomment as needed to enable BCJ filter decoders. */
/* #define XZ_DEC_X86 */
/* #define XZ_DEC_POWERPC */
/* #define XZ_DEC_IA64 */
/* #define XZ_DEC_ARM */
/* #define XZ_DEC_ARMTHUMB */
/* #define XZ_DEC_SPARC */
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "xz.h"
#define kmalloc(size, flags) malloc(size)
#define kfree(ptr) free(ptr)
#define vmalloc(size) malloc(size)
#define vfree(ptr) free(ptr)
#define memeq(a, b, size) (memcmp(a, b, size) == 0)
#define memzero(buf, size) memset(buf, 0, size)
#define min(x, y) ((x) < (y) ? (x) : (y))
#define min_t(type, x, y) min(x, y)
/*
* Some functions have been marked with __always_inline to keep the
* performance reasonable even when the compiler is optimizing for
* small code size. You may be able to save a few bytes by #defining
* __always_inline to plain inline, but don't complain if the code
* becomes slow.
*
* NOTE: System headers on GNU/Linux may #define this macro already,
* so if you want to change it, it you need to #undef it first.
*/
#ifndef __always_inline
# ifdef __GNUC__
# define __always_inline \
inline __attribute__((__always_inline__))
# else
# define __always_inline inline
# endif
#endif
/*
* Some functions are marked to never be inlined to reduce stack usage.
* If you don't care about stack usage, you may want to modify this so
* that noinline_for_stack is #defined to be empty even when using GCC.
* Doing so may save a few bytes in binary size.
*/
#ifndef noinline_for_stack
# ifdef __GNUC__
# define noinline_for_stack __attribute__((__noinline__))
# else
# define noinline_for_stack
# endif
#endif
/* Inline functions to access unaligned unsigned 32-bit integers */
#ifndef get_unaligned_le32
static inline uint32_t XZ_FUNC get_unaligned_le32(const uint8_t *buf)
{
return (uint32_t)buf[0]
| ((uint32_t)buf[1] << 8)
| ((uint32_t)buf[2] << 16)
| ((uint32_t)buf[3] << 24);
}
#endif
#ifndef get_unaligned_be32
static inline uint32_t XZ_FUNC get_unaligned_be32(const uint8_t *buf)
{
return (uint32_t)(buf[0] << 24)
| ((uint32_t)buf[1] << 16)
| ((uint32_t)buf[2] << 8)
| (uint32_t)buf[3];
}
#endif
#ifndef put_unaligned_le32
static inline void XZ_FUNC put_unaligned_le32(uint32_t val, uint8_t *buf)
{
buf[0] = (uint8_t)val;
buf[1] = (uint8_t)(val >> 8);
buf[2] = (uint8_t)(val >> 16);
buf[3] = (uint8_t)(val >> 24);
}
#endif
#ifndef put_unaligned_be32
static inline void XZ_FUNC put_unaligned_be32(uint32_t val, uint8_t *buf)
{
buf[0] = (uint8_t)(val >> 24);
buf[1] = (uint8_t)(val >> 16);
buf[2] = (uint8_t)(val >> 8);
buf[3] = (uint8_t)val;
}
#endif
/*
* Use get_unaligned_le32() also for aligned access for simplicity. On
* little endian systems, #define get_le32(ptr) (*(const uint32_t *)(ptr))
* could save a few bytes in code size.
*/
#define get_le32 get_unaligned_le32
#endif