git: a61eb269dec4 - stable/13 - stand: Fix inclusion of sys/blake3.h

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 22:10:48 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a61eb269dec47797752ff651924ac030d7754816

commit a61eb269dec47797752ff651924ac030d7754816
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-07-08 23:34:53 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-01-24 21:49:23 +0000

    stand: Fix inclusion of sys/blake3.h
    
    sys/blake3.h is not safe to include in a standalone environment. It
    assumes, unwisely, that there's only kernel or userland. The userland
    choice is bad due to imperfections in how we handle stdlib.h in this
    environment (we wind up including the host's stdlib.h, it expects a
    standard FreeBSD setup which the gymnastics we've done to create a
    OpenSolaris/Illumos-like environment interfere with). Thankfully, in
    this case we can just pretend to be the kernel for a little bit by
    defining _KERNEL and the undefing it after we exit.
    
    Sponsored by:           Netflix
    Reviewed by:            kevans
    Differential Revision:  https://reviews.freebsd.org/D35750
    
    (cherry picked from commit b0a337d501927d12098891131341a7736a9125ee)
---
 stand/libsa/zfs/spl/sys/blake3.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/stand/libsa/zfs/spl/sys/blake3.h b/stand/libsa/zfs/spl/sys/blake3.h
new file mode 100644
index 000000000000..aa2d3b7e55cc
--- /dev/null
+++ b/stand/libsa/zfs/spl/sys/blake3.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2022, Netflix, Inc
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+/*
+ * Gross and ugly hack to cope with upstream's sys/blake3.h not being standalone
+ * safe.
+ */
+#define _KERNEL
+
+#include_next <sys/blake3.h>
+
+#undef _KERNEL