+#endif // !TARGET_OS_SIMULATOR
+
+#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
+static void _check_development_kernel_impl(void)
+{
+ os_assert(development_kernel == S_UNKNOWN);
+ /*
+ * Whitelist values from SUPPORTED_KERNEL_CONFIGS.
+ */
+ char *osbuildconfig = NULL;
+ size_t osbuildconfig_sz = 0;
+ errno_t err = sysctlbyname_get_data_np("kern.osbuildconfig", (void **)&osbuildconfig, &osbuildconfig_sz);
+ if (err == 0) {
+ if (strcmp(osbuildconfig, "development") == 0 ||
+ strcmp(osbuildconfig, "debug") == 0 ||
+ strcmp(osbuildconfig, "profile") == 0 ||
+ strcmp(osbuildconfig, "kasan") == 0) {
+ development_kernel = S_YES;
+ }
+ }
+ free(osbuildconfig);
+
+ if (development_kernel == S_UNKNOWN) {
+ development_kernel = S_NO;
+ }
+}
+
+static bool _check_development_kernel(void)
+{
+ _initialize_status();
+
+ return status2bool(development_kernel);
+}
+#endif // TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
+
+static void _check_uses_ephemeral_storage_impl(void)
+{
+ if (_os_xbs_chrooted && is_ephemeral != S_UNKNOWN) {
+ return;
+ } else {
+ os_assert(is_ephemeral == S_UNKNOWN);
+ }
+
+ uint32_t buffer = 0;
+ size_t buffer_size = sizeof(buffer);
+
+ sysctlbyname("hw.ephemeral_storage", (void *)&buffer, &buffer_size, NULL, 0);
+
+ is_ephemeral = (buffer != 0) ? S_YES : S_NO;
+}
+
+static bool _check_uses_ephemeral_storage(void)
+{
+ _initialize_status();
+
+ return status2bool(is_ephemeral);
+}
+
+#if !TARGET_OS_SIMULATOR
+// internal upcall into libtrace
+extern bool
+_os_trace_basesystem_storage_available(void);
+
+static void
+_init_has_full_logging(void)
+{
+#if TARGET_OS_OSX
+ if (_check_base_system_content() &&
+ !_os_trace_basesystem_storage_available()) {
+ has_full_logging = S_NO;
+ return;
+ }
+#endif
+
+ has_full_logging = S_YES;
+}
+
+static bool _check_has_full_logging(void)
+{
+ _initialize_status();
+
+ return status2bool(has_full_logging);
+}
+#endif // !TARGET_OS_SIMULATOR
+
+static void _check_all_statuses(void)
+{
+#if !TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+ _check_internal_content_impl();
+#endif
+
+ _check_uses_ephemeral_storage_impl();
+
+#if !TARGET_OS_SIMULATOR
+ _check_can_has_debugger_impl();
+
+#if TARGET_OS_IPHONE
+ _check_system_version_plist_statuses_impl();
+ _check_development_kernel_impl();
+#else
+ _check_internal_diags_profile_impl();
+ _check_factory_content_impl();
+ _check_base_system_content_impl();
+ _check_darwinos_content_impl();
+#endif
+
+#endif // !TARGET_OS_SIMULUATOR
+
+ _parse_disabled_status(NULL);
+}
+
+static bool
+os_variant_has_full_logging(const char * __unused subsystem)
+{
+#if TARGET_OS_SIMULATOR
+ return true;
+#else
+ return _check_has_full_logging();
+#endif
+}
+
+static const variant_check_mapping _variant_map[] = {
+ {.variant = "AllowsInternalSecurityPolicies", .function = os_variant_allows_internal_security_policies},
+ {.variant = "HasFactoryContent", .function = os_variant_has_factory_content},
+ {.variant = "HasFullLogging", .function = os_variant_has_full_logging},
+ {.variant = "HasInternalContent", .function = os_variant_has_internal_content},
+ {.variant = "HasInternalDiagnostics", .function = os_variant_has_internal_diagnostics},
+ {.variant = "HasInternalUI", .function = os_variant_has_internal_ui},
+#if TARGET_OS_OSX
+ {.variant = "IsBaseSystem", .function = os_variant_is_basesystem},
+#endif
+ {.variant = "IsDarwinOS", .function = os_variant_is_darwinos},
+ {.variant = "IsRecovery", .function = os_variant_is_recovery},
+ {.variant = "UsesEphemeralStorage", .function = os_variant_uses_ephemeral_storage},
+ {.variant = NULL, .function = NULL}
+};