Index: contrib/xz/src/common/mythread.h =================================================================== --- contrib/xz/src/common/mythread.h +++ contrib/xz/src/common/mythread.h @@ -81,15 +81,19 @@ #if !(defined(_WIN32) && !defined(__CYGWIN__)) // Use sigprocmask() to set the signal mask in single-threaded programs. +#ifndef _KERNEL #include +#endif static inline void mythread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oset) { +#ifndef _KERNEL int ret = sigprocmask(how, set, oset); assert(ret == 0); (void)ret; +#endif } #endif Index: contrib/xz/src/common/sysdefs.h =================================================================== --- contrib/xz/src/common/sysdefs.h +++ contrib/xz/src/common/sysdefs.h @@ -16,6 +16,22 @@ #ifndef LZMA_SYSDEFS_H #define LZMA_SYSDEFS_H +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include + +#include + +#define assert(c, ...) if (!(c)) panic(__VA_ARGS__) +#define HAVE_CHECK_CRC64 1 +#define HAVE_VISIBILITY 1 +#define LZMA_MANUAL_HEADERS 1 +#else /* !_KERNEL */ + ////////////// // Includes // ////////////// @@ -176,6 +192,8 @@ # endif #endif +#endif /* _KERNEL */ + //////////// // Macros // //////////// Index: contrib/xz/src/common/tuklib_config.h =================================================================== --- contrib/xz/src/common/tuklib_config.h +++ contrib/xz/src/common/tuklib_config.h @@ -1,4 +1,4 @@ -#ifdef HAVE_CONFIG_H +#if defined(HAVE_CONFIG_H) || defined(_KERNEL) # include "sysdefs.h" #else # include Index: contrib/xz/src/liblzma/check/check.c =================================================================== --- contrib/xz/src/liblzma/check/check.c +++ contrib/xz/src/liblzma/check/check.c @@ -172,3 +172,11 @@ return; } + +#ifdef _KERNEL +uint32_t +lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) +{ + return (~crc32_raw(buf, size, ~crc)); +} +#endif Index: contrib/xz/src/liblzma/common/common.c =================================================================== --- contrib/xz/src/liblzma/common/common.c +++ contrib/xz/src/liblzma/common/common.c @@ -35,6 +35,13 @@ // Memory allocation // /////////////////////// +#ifdef _KERNEL +#include +#include + +static MALLOC_DEFINE(M_LZMA, "lzma", "lzma allocations"); +#endif + extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) lzma_alloc(size_t size, const lzma_allocator *allocator) { @@ -47,7 +54,11 @@ if (allocator != NULL && allocator->alloc != NULL) ptr = allocator->alloc(allocator->opaque, 1, size); else +#ifdef _KERNEL + ptr = malloc(size, M_LZMA, M_WAITOK); +#else ptr = malloc(size); +#endif return ptr; } @@ -67,7 +78,11 @@ if (ptr != NULL) memzero(ptr, size); } else { +#ifdef _KERNEL + ptr = malloc(size, M_LZMA, M_WAITOK | M_ZERO); +#else ptr = calloc(1, size); +#endif } return ptr; @@ -80,7 +95,11 @@ if (allocator != NULL && allocator->free != NULL) allocator->free(allocator->opaque, ptr); else +#ifdef _KERNEL + free(ptr, M_LZMA); +#else free(ptr); +#endif return; } Index: contrib/xz/src/liblzma/rangecoder/price_table.c =================================================================== --- contrib/xz/src/liblzma/rangecoder/price_table.c +++ contrib/xz/src/liblzma/rangecoder/price_table.c @@ -1,5 +1,6 @@ /* This file has been automatically generated by price_tablegen.c. */ +#include "sysdefs.h" #include "range_encoder.h" const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE] = { Index: sys/conf/files =================================================================== --- sys/conf/files +++ sys/conf/files @@ -4681,3 +4681,84 @@ xdr/xdr_mem.c optional krpc | nfslockd | nfscl | nfsd xdr/xdr_reference.c optional krpc | nfslockd | nfscl | nfsd xdr/xdr_sizeof.c optional krpc | nfslockd | nfscl | nfsd +# liblzma +# Disabled features: Redundant checksum algorithms, multithreading. +contrib/liblzma/check/check.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc32_fast.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc32_small.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc32_table.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc32_tablegen.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/check/crc64_fast.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc64_small.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/check/crc64_table.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/crc64_tablegen.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/check/sha256.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/alone_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/alone_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/auto_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_buffer_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_buffer_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_header_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_header_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/block_util.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/common.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/easy_buffer_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/easy_decoder_memusage.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/easy_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/easy_encoder_memusage.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/easy_preset.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/file_info.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_buffer_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_buffer_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_common.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_flags_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/filter_flags_encoder.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/common/hardware_cputhreads.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/hardware_physmem.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/index.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/index_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/index_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/index_hash.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/common/outqueue.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_buffer_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_buffer_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_encoder.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/common/stream_encoder_mt.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_flags_common.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_flags_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/stream_flags_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/vli_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/vli_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/common/vli_size.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/delta/delta_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/delta/delta_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/delta/delta_common.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lz/lz_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lz/lz_encoder_mf.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lz/lz_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/fastpos_table.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/lzma/fastpos_tablegen.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma_encoder_optimum_fast.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma_encoder_optimum_normal.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma_encoder_presets.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma2_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/lzma/lzma2_encoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/rangecoder/price_table.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/rangecoder/price_tablegen.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/simple/arm.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/simple/armthumb.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/simple/ia64.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/simple/powerpc.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/simple/simple_coder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/simple/simple_decoder.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/simple/simple_encoder.c standard compile-with ${LIBLZMA_C} +#contrib/liblzma/simple/sparc.c standard compile-with ${LIBLZMA_C} +contrib/liblzma/simple/x86.c standard compile-with ${LIBLZMA_C} +contrib/xz-common/tuklib_physmem.c standard compile-with ${LIBLZMA_C} Index: sys/conf/kern.pre.mk =================================================================== --- sys/conf/kern.pre.mk +++ sys/conf/kern.pre.mk @@ -109,6 +109,17 @@ # Optional linting. This can be overridden in /etc/make.conf. LINTFLAGS= ${LINTOBJKERNFLAGS} +LIBLZMA_C= ${CC} -c ${CFLAGS} ${WERROR} -Wno-cast-qual ${PROF} ${.IMPSRC} -DTUKLIB_SYMBOL_PREFIX=lzma_ \ + -I$S/contrib/liblzma \ + -I$S/contrib/liblzma/api \ + -I$S/contrib/liblzma/check \ + -I$S/contrib/liblzma/common \ + -I$S/contrib/liblzma/delta \ + -I$S/contrib/liblzma/lz \ + -I$S/contrib/liblzma/lzma \ + -I$S/contrib/liblzma/rangecoder \ + -I$S/contrib/liblzma/simple \ + -I$S/contrib/xz-common NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}