FreeBSD: make adjustments for the standalone environment

In FreeBSD, there are three compile environments that are supported:
user land, the kernel and the bootloader / standalone. Adjust the
headers to compile in the standalone environment. Limit kernel-only
items from view when _STANDALONE is defined.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Warner Losh <imp@FreeBSD.org>
Closes #10998
This commit is contained in:
Warner Losh
2020-10-13 22:05:49 -06:00
committed by GitHub
parent 57dc5d42b1
commit b302185a92
20 changed files with 102 additions and 34 deletions
+4 -4
View File
@@ -62,7 +62,7 @@ typedef enum {
DATA_TYPE_UINT8,
DATA_TYPE_BOOLEAN_ARRAY,
DATA_TYPE_INT8_ARRAY,
#if !defined(_KERNEL)
#if !defined(_KERNEL) && !defined(_STANDALONE)
DATA_TYPE_UINT8_ARRAY,
DATA_TYPE_DOUBLE
#else
@@ -191,7 +191,7 @@ int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t);
int nvlist_add_string_array(nvlist_t *, const char *, char *const *, uint_t);
int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t);
#if !defined(_KERNEL)
#if !defined(_KERNEL) && !defined(_STANDALONE)
int nvlist_add_double(nvlist_t *, const char *, double);
#endif
@@ -228,7 +228,7 @@ int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
nvlist_t ***, uint_t *);
int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *);
int nvlist_lookup_pairs(nvlist_t *, int, ...);
#if !defined(_KERNEL)
#if !defined(_KERNEL) && !defined(_STANDALONE)
int nvlist_lookup_double(nvlist_t *, const char *, double *);
#endif
@@ -269,7 +269,7 @@ int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *);
int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
#if !defined(_KERNEL)
#if !defined(_KERNEL) && !defined(_STANDALONE)
int nvpair_value_double(nvpair_t *, double *);
#endif
+11 -3
View File
@@ -32,7 +32,15 @@
extern "C" {
#endif
#ifdef __KERNEL__
/*
* This code compiles in three different contexts. When __KERNEL__ is defined,
* the code uses "unix-like" kernel interfaces. When _STANDALONE is defined, the
* code is running in a reduced capacity environment of the boot loader which is
* generally a subset of both POSIX and kernel interfaces (with a few unique
* interfaces too). When neither are defined, it's in a userland POSIX or
* similar environment.
*/
#if defined(__KERNEL__) || defined(_STANDALONE)
#include <sys/note.h>
#include <sys/types.h>
#include <sys/atomic.h>
@@ -65,7 +73,7 @@ extern "C" {
#include <sys/procfs_list.h>
#include <sys/mod.h>
#include <sys/zfs_context_os.h>
#else /* _KERNEL */
#else /* _KERNEL || _STANDALONE */
#define _SYS_MUTEX_H
#define _SYS_RWLOCK_H
@@ -759,7 +767,7 @@ extern int kmem_cache_reap_active(void);
#define __init
#define __exit
#endif /* _KERNEL */
#endif /* _KERNEL || _STANDALONE */
#ifdef __cplusplus
};