From 2e0488d4385a378cd1684d228a1753d6b25773a1 Mon Sep 17 00:00:00 2001 From: tsoome Date: Sat, 2 Nov 2019 21:02:54 +0000 Subject: [PATCH] r354253 did miss the fact that libzpool is built as fake kernel We build libzpool as kernel like, use _FAKE_KERNEL check to include kernel api in libzpool. --- cddl/lib/libzpool/Makefile | 2 ++ sys/cddl/contrib/opensolaris/common/lz4/lz4.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index f65042e7ea37..ae9f9a91a53f 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -65,6 +65,8 @@ CFLAGS+= -DWANTS_MUTEX_OWNED CFLAGS+= -I${SRCTOP}/lib/libpthread/thread CFLAGS+= -I${SRCTOP}/lib/libpthread/sys CFLAGS+= -I${SRCTOP}/lib/libthr/arch/${MACHINE_CPUARCH}/include +CFLAGS.lz4.o+= -D_FAKE_KERNEL +CFLAGS.lz4.pico+= -D_FAKE_KERNEL CFLAGS.gcc+= -fms-extensions LIBADD= md pthread z nvpair avl umem diff --git a/sys/cddl/contrib/opensolaris/common/lz4/lz4.c b/sys/cddl/contrib/opensolaris/common/lz4/lz4.c index 4b559d9b7206..3a875565f4b4 100644 --- a/sys/cddl/contrib/opensolaris/common/lz4/lz4.c +++ b/sys/cddl/contrib/opensolaris/common/lz4/lz4.c @@ -35,7 +35,7 @@ * Copyright (c) 2016 by Delphix. All rights reserved. */ -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) #include #elif defined(_STANDALONE) #include @@ -65,7 +65,7 @@ static int LZ4_compressCtx(void *ctx, const char *source, char *dest, static int LZ4_compress64kCtx(void *ctx, const char *source, char *dest, int isize, int osize); -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) static kmem_cache_t *lz4_ctx_cache; #endif @@ -91,7 +91,7 @@ lz4_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, * added to the compressed buffer and which, if unhandled, would * confuse the hell out of our decompression function. */ -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) *(uint32_t *)(void *)dest = BE_32(bufsiz); #else *(uint32_t *)(void *)dest = htonl(bufsiz); @@ -105,7 +105,7 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n __unused) { const char *src = s_start; -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) uint32_t bufsiz = BE_IN32(s_start); #else uint32_t bufsiz = htonl(*(uint32_t *)s_start); @@ -857,7 +857,7 @@ static int real_LZ4_compress(const char *source, char *dest, int isize, int osize) { #if HEAPMODE -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) void *ctx = kmem_cache_alloc(lz4_ctx_cache, KM_NOSLEEP); #else void *ctx = malloc(sizeof(struct refTables)); @@ -877,7 +877,7 @@ real_LZ4_compress(const char *source, char *dest, int isize, int osize) else result = LZ4_compressCtx(ctx, source, dest, isize, osize); -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) kmem_cache_free(lz4_ctx_cache, ctx); #else free(ctx); @@ -1031,7 +1031,7 @@ LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, return (int)(-(((const char *)ip) - source)); } -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) extern void lz4_init(void) { @@ -1050,4 +1050,4 @@ lz4_fini(void) kmem_cache_destroy(lz4_ctx_cache); #endif } -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */