[fuchsia] Update Fuchsia SDK
This CL manually updates the contents of the Fuchsia SDK to revision
ae90dd3a8c242e4f043f587bc1c612341d1d7a7a of fuchsia.git.
BYPASS_INCLUSIVE_LANGUAGE_REASON=Will fix upstream
Change-Id: I1347406e7699173d2ec785dfd44c94bde5d4e5ee
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..3b0b4d0
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,11 @@
+# This is the list of Fuchsia Authors.
+
+# Names should be added to this file as one of
+# Organization's name
+# Individual's name <submission email address>
+# Individual's name <submission email address> <email2> <emailN>
+
+Google Inc.
+The Chromium Authors
+The Chromium OS Authors
+The Go Authors
diff --git a/Android.bp.UNUSED b/Android.bp.UNUSED
deleted file mode 100644
index 9c321eb..0000000
--- a/Android.bp.UNUSED
+++ /dev/null
@@ -1,872 +0,0 @@
-// DO NOT EDIT! This file was generated by
-// ../../fuchsia/scripts/gen_sdk_bp.py.
-// Any changes made to this file will be discarded.
-
-cc_defaults {
- name: "fuchsia_cc_defaults",
- c_std: "c11",
- cflags: ["-Wno-unused-parameter"],
- relative_install_path: "fuchsia",
-
- // Only enable on fuchsia.
- enabled: false,
- target: {
- fuchsia: {
- enabled: true,
- }
- },
-}
-
-cc_library {
- name: "libfuchsia.bluetooth.gatt",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.bluetooth.gatt"],
- fidl_hdrs: ["fuchsia.bluetooth.gatt"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.bluetooth"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.bluetooth"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.bluetooth.gatt",
- srcs: ["fidl/fuchsia.bluetooth.gatt/client.fidl","fidl/fuchsia.bluetooth.gatt/server.fidl","fidl/fuchsia.bluetooth.gatt/types.fidl"],
- deps: ["fuchsia.bluetooth"],
-}
-
-cc_library {
- name: "libfuchsia.bluetooth.le",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.bluetooth.le"],
- fidl_hdrs: ["fuchsia.bluetooth.le"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.bluetooth.gatt","libfuchsia.bluetooth"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.bluetooth.gatt","libfuchsia.bluetooth"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.bluetooth.le",
- srcs: ["fidl/fuchsia.bluetooth.le/central.fidl","fidl/fuchsia.bluetooth.le/peripheral.fidl","fidl/fuchsia.bluetooth.le/types.fidl"],
- deps: ["fuchsia.bluetooth.gatt","fuchsia.bluetooth"],
-}
-
-cc_library {
- name: "libfuchsia.bluetooth",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.bluetooth"],
- fidl_hdrs: ["fuchsia.bluetooth"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.bluetooth",
- srcs: ["fidl/fuchsia.bluetooth/status.fidl","fidl/fuchsia.bluetooth/nullables.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.developer.tiles",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.developer.tiles"],
- fidl_hdrs: ["fuchsia.developer.tiles"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.app","libfuchsia.sys","libfuchsia.mem","libfuchsia.math"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.app","libfuchsia.sys","libfuchsia.mem","libfuchsia.math"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.developer.tiles",
- srcs: ["fidl/fuchsia.developer.tiles/tiles.fidl"],
- deps: ["fuchsia.ui.app","fuchsia.sys","fuchsia.mem","fuchsia.math"],
-}
-
-cc_library {
- name: "libfuchsia.fonts",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.fonts"],
- fidl_hdrs: ["fuchsia.fonts"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.fonts",
- srcs: ["fidl/fuchsia.fonts/font_provider.fidl"],
- deps: ["fuchsia.mem"],
-}
-
-cc_library {
- name: "libfuchsia.images",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.images"],
- fidl_hdrs: ["fuchsia.images"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.images",
- srcs: ["fidl/fuchsia.images/encoded_image.fidl","fidl/fuchsia.images/image_info.fidl","fidl/fuchsia.images/image_pipe.fidl","fidl/fuchsia.images/memory_type.fidl","fidl/fuchsia.images/presentation_info.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.io",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.io"],
- fidl_hdrs: ["fuchsia.io"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.io",
- srcs: ["fidl/fuchsia.io/io.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.ldsvc",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ldsvc"],
- fidl_hdrs: ["fuchsia.ldsvc"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ldsvc",
- srcs: ["fidl/fuchsia.ldsvc/ldsvc.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.logger",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.logger"],
- fidl_hdrs: ["fuchsia.logger"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.logger",
- srcs: ["fidl/fuchsia.logger/logger.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.math",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.math"],
- fidl_hdrs: ["fuchsia.math"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.math",
- srcs: ["fidl/fuchsia.math/math.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.media",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.media"],
- fidl_hdrs: ["fuchsia.media"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.media",
- srcs: ["fidl/fuchsia.media/audio.fidl","fidl/fuchsia.media/audio_capturer.fidl","fidl/fuchsia.media/audio_device_enumerator.fidl","fidl/fuchsia.media/audio_renderer.fidl","fidl/fuchsia.media/gain_control.fidl","fidl/fuchsia.media/stream.fidl","fidl/fuchsia.media/stream_type.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.mediacodec",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.mediacodec"],
- fidl_hdrs: ["fuchsia.mediacodec"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.mediacodec",
- srcs: ["fidl/fuchsia.mediacodec/codec_common.fidl","fidl/fuchsia.mediacodec/codec_factory.fidl","fidl/fuchsia.mediacodec/codec.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.mem",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.mem"],
- fidl_hdrs: ["fuchsia.mem"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.mem",
- srcs: ["fidl/fuchsia.mem/buffer.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.net.http",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.net.http"],
- fidl_hdrs: ["fuchsia.net.http"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.net.http",
- srcs: ["fidl/fuchsia.net.http/client.fidl"],
- deps: ["fuchsia.mem"],
-}
-
-cc_library {
- name: "libfuchsia.net.oldhttp",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.net.oldhttp"],
- fidl_hdrs: ["fuchsia.net.oldhttp"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.netstack","libzircon.ethernet","libfuchsia.net","libfuchsia.mem"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.netstack","libzircon.ethernet","libfuchsia.net","libfuchsia.mem"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.net.oldhttp",
- srcs: ["fidl/fuchsia.net.oldhttp/http_error.fidl","fidl/fuchsia.net.oldhttp/http_header.fidl","fidl/fuchsia.net.oldhttp/http_service.fidl","fidl/fuchsia.net.oldhttp/url_body.fidl","fidl/fuchsia.net.oldhttp/url_loader.fidl","fidl/fuchsia.net.oldhttp/url_request.fidl","fidl/fuchsia.net.oldhttp/url_response.fidl"],
- deps: ["fuchsia.netstack","zircon.ethernet","fuchsia.net","fuchsia.mem"],
-}
-
-cc_library {
- name: "libfuchsia.net",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.net"],
- fidl_hdrs: ["fuchsia.net"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.net",
- srcs: ["fidl/fuchsia.net/connectivity.fidl","fidl/fuchsia.net/net.fidl","fidl/fuchsia.net/socket.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.netstack",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.netstack"],
- fidl_hdrs: ["fuchsia.netstack"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libzircon.ethernet","libfuchsia.net"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libzircon.ethernet","libfuchsia.net"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.netstack",
- srcs: ["fidl/fuchsia.netstack/netstack.fidl"],
- deps: ["zircon.ethernet","fuchsia.net"],
-}
-
-cc_library {
- name: "libfuchsia.process",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.process"],
- fidl_hdrs: ["fuchsia.process"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ldsvc","libfuchsia.io"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ldsvc","libfuchsia.io"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.process",
- srcs: ["fidl/fuchsia.process/launcher.fidl","fidl/fuchsia.process/resolver.fidl"],
- deps: ["fuchsia.ldsvc","fuchsia.io"],
-}
-
-cc_library {
- name: "libfuchsia.simplecamera",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.simplecamera"],
- fidl_hdrs: ["fuchsia.simplecamera"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.images"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.images"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.simplecamera",
- srcs: ["fidl/fuchsia.simplecamera/simple_camera.fidl"],
- deps: ["fuchsia.images"],
-}
-
-cc_library {
- name: "libfuchsia.sys",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.sys"],
- fidl_hdrs: ["fuchsia.sys"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.sys",
- srcs: ["fidl/fuchsia.sys/component_controller.fidl","fidl/fuchsia.sys/environment.fidl","fidl/fuchsia.sys/environment_controller.fidl","fidl/fuchsia.sys/flat_namespace.fidl","fidl/fuchsia.sys/job_provider.fidl","fidl/fuchsia.sys/launcher.fidl","fidl/fuchsia.sys/loader.fidl","fidl/fuchsia.sys/runner.fidl","fidl/fuchsia.sys/service_provider.fidl"],
- deps: ["fuchsia.mem"],
-}
-
-cc_library {
- name: "libfuchsia.sysinfo",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.sysinfo"],
- fidl_hdrs: ["fuchsia.sysinfo"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.sysinfo",
- srcs: ["fidl/fuchsia.sysinfo/sysinfo.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.ui.app",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.app"],
- fidl_hdrs: ["fuchsia.ui.app"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.sys","libfuchsia.mem"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.sys","libfuchsia.mem"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.app",
- srcs: ["fidl/fuchsia.ui.app/view_provider.fidl"],
- deps: ["fuchsia.sys","fuchsia.mem"],
-}
-
-cc_library {
- name: "libfuchsia.ui.gfx",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.gfx"],
- fidl_hdrs: ["fuchsia.ui.gfx"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.math","libfuchsia.images"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.math","libfuchsia.images"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.gfx",
- srcs: ["fidl/fuchsia.ui.gfx/commands.fidl","fidl/fuchsia.ui.gfx/display_info.fidl","fidl/fuchsia.ui.gfx/events.fidl","fidl/fuchsia.ui.gfx/hit.fidl","fidl/fuchsia.ui.gfx/nodes.fidl","fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl","fidl/fuchsia.ui.gfx/renderer.fidl","fidl/fuchsia.ui.gfx/resources.fidl","fidl/fuchsia.ui.gfx/shapes.fidl","fidl/fuchsia.ui.gfx/types.fidl"],
- deps: ["fuchsia.mem","fuchsia.math","fuchsia.images"],
-}
-
-cc_library {
- name: "libfuchsia.ui.input",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.input"],
- fidl_hdrs: ["fuchsia.ui.input"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.input",
- srcs: ["fidl/fuchsia.ui.input/commands.fidl","fidl/fuchsia.ui.input/ime_service.fidl","fidl/fuchsia.ui.input/input_connection.fidl","fidl/fuchsia.ui.input/input_device_registry.fidl","fidl/fuchsia.ui.input/input_dispatcher.fidl","fidl/fuchsia.ui.input/input_event_constants.fidl","fidl/fuchsia.ui.input/input_events.fidl","fidl/fuchsia.ui.input/input_reports.fidl","fidl/fuchsia.ui.input/text_editing.fidl","fidl/fuchsia.ui.input/text_input.fidl","fidl/fuchsia.ui.input/usages.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.ui.policy",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.policy"],
- fidl_hdrs: ["fuchsia.ui.policy"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.viewsv1token","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.mem","libfuchsia.math","libfuchsia.images"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.viewsv1token","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.mem","libfuchsia.math","libfuchsia.images"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.policy",
- srcs: ["fidl/fuchsia.ui.policy/display_usage.fidl","fidl/fuchsia.ui.policy/presentation.fidl","fidl/fuchsia.ui.policy/presenter.fidl"],
- deps: ["fuchsia.ui.viewsv1token","fuchsia.ui.input","fuchsia.ui.gfx","fuchsia.mem","fuchsia.math","fuchsia.images"],
-}
-
-cc_library {
- name: "libfuchsia.ui.scenic",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.scenic"],
- fidl_hdrs: ["fuchsia.ui.scenic"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.ui.views","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.math","libfuchsia.images","libfuchsia.sys","libfuchsia.ui.vectorial"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.ui.views","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.math","libfuchsia.images","libfuchsia.sys","libfuchsia.ui.vectorial"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.scenic",
- srcs: ["fidl/fuchsia.ui.scenic/commands.fidl","fidl/fuchsia.ui.scenic/events.fidl","fidl/fuchsia.ui.scenic/scenic.fidl","fidl/fuchsia.ui.scenic/session.fidl"],
- deps: ["fuchsia.mem","fuchsia.ui.views","fuchsia.ui.input","fuchsia.ui.gfx","fuchsia.math","fuchsia.images","fuchsia.sys","fuchsia.ui.vectorial"],
-}
-
-cc_library {
- name: "libfuchsia.ui.vectorial",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.vectorial"],
- fidl_hdrs: ["fuchsia.ui.vectorial"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.vectorial",
- srcs: ["fidl/fuchsia.ui.vectorial/commands.fidl","fidl/fuchsia.ui.vectorial/events.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.ui.views",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.views"],
- fidl_hdrs: ["fuchsia.ui.views"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.mem","libfuchsia.math","libfuchsia.images","libfuchsia.sys"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.mem","libfuchsia.math","libfuchsia.images","libfuchsia.sys"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.views",
- srcs: ["fidl/fuchsia.ui.views/commands.fidl","fidl/fuchsia.ui.views/events.fidl"],
- deps: ["fuchsia.ui.input","fuchsia.ui.gfx","fuchsia.mem","fuchsia.math","fuchsia.images","fuchsia.sys"],
-}
-
-cc_library {
- name: "libfuchsia.ui.viewsv1",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.viewsv1"],
- fidl_hdrs: ["fuchsia.ui.viewsv1"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.ui.viewsv1token","libfuchsia.ui.scenic","libfuchsia.ui.views","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.math","libfuchsia.images","libfuchsia.sys","libfuchsia.ui.vectorial"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.mem","libfuchsia.ui.viewsv1token","libfuchsia.ui.scenic","libfuchsia.ui.views","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.math","libfuchsia.images","libfuchsia.sys","libfuchsia.ui.vectorial"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.viewsv1",
- srcs: ["fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl","fidl/fuchsia.ui.viewsv1/view_containers.fidl","fidl/fuchsia.ui.viewsv1/view_manager.fidl","fidl/fuchsia.ui.viewsv1/view_properties.fidl","fidl/fuchsia.ui.viewsv1/view_provider.fidl","fidl/fuchsia.ui.viewsv1/view_snapshot.fidl","fidl/fuchsia.ui.viewsv1/view_tree_token.fidl","fidl/fuchsia.ui.viewsv1/view_trees.fidl","fidl/fuchsia.ui.viewsv1/views.fidl"],
- deps: ["fuchsia.mem","fuchsia.ui.viewsv1token","fuchsia.ui.scenic","fuchsia.ui.views","fuchsia.ui.input","fuchsia.ui.gfx","fuchsia.math","fuchsia.images","fuchsia.sys","fuchsia.ui.vectorial"],
-}
-
-cc_library {
- name: "libfuchsia.ui.viewsv1token",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.ui.viewsv1token"],
- fidl_hdrs: ["fuchsia.ui.viewsv1token"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.ui.viewsv1token",
- srcs: ["fidl/fuchsia.ui.viewsv1token/view_token.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.wlan.minstrel",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.wlan.minstrel"],
- fidl_hdrs: ["fuchsia.wlan.minstrel"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.wlan.minstrel",
- srcs: ["fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libfuchsia.wlan.mlme",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.wlan.mlme"],
- fidl_hdrs: ["fuchsia.wlan.mlme"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.wlan.minstrel","libfuchsia.wlan.stats"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.wlan.minstrel","libfuchsia.wlan.stats"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.wlan.mlme",
- srcs: ["fidl/fuchsia.wlan.mlme/wlan_mlme.fidl","fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl"],
- deps: ["fuchsia.wlan.minstrel","fuchsia.wlan.stats"],
-}
-
-cc_library {
- name: "libfuchsia.wlan.service",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.wlan.service"],
- fidl_hdrs: ["fuchsia.wlan.service"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.wlan.stats","libfuchsia.wlan.mlme","libfuchsia.wlan.minstrel"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default","libfuchsia.wlan.stats","libfuchsia.wlan.mlme","libfuchsia.wlan.minstrel"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.wlan.service",
- srcs: ["fidl/fuchsia.wlan.service/wlan_service.fidl"],
- deps: ["fuchsia.wlan.stats","fuchsia.wlan.mlme","fuchsia.wlan.minstrel"],
-}
-
-cc_library {
- name: "libfuchsia.wlan.stats",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["fuchsia.wlan.stats"],
- fidl_hdrs: ["fuchsia.wlan.stats"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "fuchsia.wlan.stats",
- srcs: ["fidl/fuchsia.wlan.stats/wlan_stats.fidl"],
- deps: [],
-}
-
-cc_library {
- name: "libzircon.ethernet",
- defaults: ["fuchsia_cc_defaults"],
- fidl_srcs: ["zircon.ethernet"],
- fidl_hdrs: ["zircon.ethernet"],
- shared_libs: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
- export_shared_lib_headers: ["libfidl","libfidl_cpp_sync","libzx","libfit","libfidl-async","libasync","libfidl_cpp_base","libfidl_cpp","libasync-default"],
-}
-
-fidl_gen_cc {
- name: "zircon.ethernet",
- srcs: ["fidl/zircon.ethernet/ethernet.fidl"],
- deps: [],
-}
-
-cc_prebuilt_library_shared {
- name: "libasync-default",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libasync-default.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libasync-default.so"],
- },
- },
- export_include_dirs: ["pkg/async-default/include"]
-}
-
-cc_library {
- name: "libasync-loop-cpp",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/async-loop-cpp/loop_wrapper.cpp"],
- local_include_dirs: ["pkg/async-loop-cpp/include"],
- export_include_dirs: ["pkg/async-loop-cpp/include"],
- shared_libs: ["libzx","libasync-loop","libasync-default","libasync"],
- export_shared_lib_headers: ["libzx","libasync-loop","libasync-default","libasync"],
-}
-
-cc_library {
- name: "libasync-loop",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/async-loop/loop.c"],
- local_include_dirs: ["pkg/async-loop/include"],
- export_include_dirs: ["pkg/async-loop/include"],
- shared_libs: ["libasync-default","libasync"],
- export_shared_lib_headers: ["libasync-default","libasync"],
-}
-
-cc_library {
- name: "libasync",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/async/ops.c"],
- local_include_dirs: ["pkg/async/include"],
- export_include_dirs: ["pkg/async/include"],
- shared_libs: [],
- export_shared_lib_headers: [],
-}
-
-cc_prebuilt_library_shared {
- name: "libfdio",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libfdio.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libfdio.so"],
- },
- },
- export_include_dirs: ["pkg/fdio/include"]
-}
-
-cc_library {
- name: "libfidl-async",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fidl-async/bind.c"],
- local_include_dirs: ["pkg/fidl-async/include"],
- export_include_dirs: ["pkg/fidl-async/include"],
- shared_libs: ["libfidl","libasync"],
- export_shared_lib_headers: ["libfidl","libasync"],
-}
-
-cc_library {
- name: "libfidl",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fidl/builder.cpp","pkg/fidl/decoding.cpp","pkg/fidl/encoding.cpp","pkg/fidl/epitaph.c","pkg/fidl/formatting.cpp","pkg/fidl/handle_closing.cpp","pkg/fidl/message.cpp","pkg/fidl/message_buffer.cpp","pkg/fidl/message_builder.cpp","pkg/fidl/transport.cpp","pkg/fidl/validating.cpp"],
- local_include_dirs: ["pkg/fidl/include"],
- export_include_dirs: ["pkg/fidl/include"],
- shared_libs: [],
- export_shared_lib_headers: [],
-}
-
-cc_library {
- name: "libfidl_cpp",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fidl_cpp/internal/message_handler.cc","pkg/fidl_cpp/internal/message_reader.cc","pkg/fidl_cpp/internal/pending_response.cc","pkg/fidl_cpp/internal/proxy.cc","pkg/fidl_cpp/internal/proxy_controller.cc","pkg/fidl_cpp/internal/stub.cc","pkg/fidl_cpp/internal/stub_controller.cc","pkg/fidl_cpp/internal/weak_stub_controller.cc"],
- local_include_dirs: ["pkg/fidl_cpp/include"],
- export_include_dirs: ["pkg/fidl_cpp/include"],
- shared_libs: ["libzx","libfit","libfidl-async","libfidl","libasync","libasync-default","libfidl_cpp_sync","libfidl_cpp_base"],
- export_shared_lib_headers: ["libzx","libfit","libfidl-async","libfidl","libasync","libasync-default","libfidl_cpp_sync","libfidl_cpp_base"],
-}
-
-cc_library {
- name: "libfidl_cpp_base",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fidl_cpp_base/clone.cc","pkg/fidl_cpp_base/coding_traits.cc","pkg/fidl_cpp_base/decoder.cc","pkg/fidl_cpp_base/encoder.cc","pkg/fidl_cpp_base/internal/logging.cc","pkg/fidl_cpp_base/string.cc"],
- local_include_dirs: ["pkg/fidl_cpp_base/include"],
- export_include_dirs: ["pkg/fidl_cpp_base/include"],
- shared_libs: ["libzx","libfidl-async","libfidl","libasync","libfit"],
- export_shared_lib_headers: ["libzx","libfidl-async","libfidl","libasync","libfit"],
-}
-
-cc_library {
- name: "libfidl_cpp_sync",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fidl_cpp_sync/internal/synchronous_proxy.cc"],
- local_include_dirs: ["pkg/fidl_cpp_sync/include"],
- export_include_dirs: ["pkg/fidl_cpp_sync/include"],
- shared_libs: ["libzx","libfit","libfidl-async","libfidl","libasync","libfidl_cpp_base"],
- export_shared_lib_headers: ["libzx","libfit","libfidl-async","libfidl","libasync","libfidl_cpp_base"],
-}
-
-cc_library {
- name: "libfit",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/fit/promise.cpp","pkg/fit/scheduler.cpp","pkg/fit/sequencer.cpp","pkg/fit/single_threaded_executor.cpp"],
- local_include_dirs: ["pkg/fit/include"],
- export_include_dirs: ["pkg/fit/include"],
- shared_libs: [],
- export_shared_lib_headers: [],
-}
-
-cc_library {
- name: "libimages_cpp",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/images_cpp/images.cc"],
- local_include_dirs: ["pkg/images_cpp/include"],
- export_include_dirs: ["pkg/images_cpp/include"],
- shared_libs: ["libfuchsia.images"],
- export_shared_lib_headers: [],
-}
-
-cc_prebuilt_library_shared {
- name: "libmemfs",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libmemfs.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libmemfs.so"],
- },
- },
- export_include_dirs: ["pkg/memfs/include"]
-}
-
-cc_library {
- name: "libscenic_cpp",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/scenic_cpp/commands.cc","pkg/scenic_cpp/host_image_cycler.cc","pkg/scenic_cpp/host_memory.cc","pkg/scenic_cpp/resources.cc","pkg/scenic_cpp/session.cc"],
- local_include_dirs: ["pkg/scenic_cpp/include"],
- export_include_dirs: ["pkg/scenic_cpp/include"],
- shared_libs: ["libfuchsia.ui.scenic","libfuchsia.mem","libfuchsia.ui.views","libfuchsia.ui.input","libfuchsia.ui.gfx","libfuchsia.math","libfuchsia.images","libfuchsia.sys","libfuchsia.ui.vectorial","libzx","libfit","libimages_cpp","libfidl_cpp","libfidl-async","libfidl","libasync","libasync-default","libfidl_cpp_sync","libfidl_cpp_base"],
- export_shared_lib_headers: ["libzx","libfit","libimages_cpp","libfuchsia.images","libfidl_cpp","libfidl-async","libfidl","libasync","libasync-default","libfidl_cpp_sync","libfidl_cpp_base"],
-}
-
-cc_prebuilt_library_shared {
- name: "libsvc",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libsvc.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libsvc.so"],
- },
- },
- export_include_dirs: ["pkg/svc/include"]
-}
-
-cc_prebuilt_library_static {
- name: "libsync_fuchsia",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/lib/libsync.a"],
- },
- arm64: {
- srcs: ["arch/arm64/lib/libsync.a"],
- },
- },
- export_include_dirs: ["pkg/sync/include"]
-}
-
-cc_prebuilt_library_shared {
- name: "libsyslog",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libsyslog.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libsyslog.so"],
- },
- },
- export_include_dirs: ["pkg/syslog/include"]
-}
-
-cc_prebuilt_library_shared {
- name: "libtrace-engine",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libtrace-engine.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libtrace-engine.so"],
- },
- },
- export_include_dirs: []
-}
-
-cc_prebuilt_library_shared {
- name: "libvulkan_fuchsia",
- defaults: ["fuchsia_cc_defaults"],
- arch: {
- x86_64: {
- srcs: ["arch/x64/dist/libvulkan.so"],
- },
- arm64: {
- srcs: ["arch/arm64/dist/libvulkan.so"],
- },
- },
- export_include_dirs: []
-}
-
-cc_library {
- name: "libzx",
- defaults: ["fuchsia_cc_defaults"],
- srcs: ["pkg/zx/bti.cpp","pkg/zx/channel.cpp","pkg/zx/debuglog.cpp","pkg/zx/event.cpp","pkg/zx/eventpair.cpp","pkg/zx/fifo.cpp","pkg/zx/guest.cpp","pkg/zx/interrupt.cpp","pkg/zx/iommu.cpp","pkg/zx/job.cpp","pkg/zx/log.cpp","pkg/zx/port.cpp","pkg/zx/process.cpp","pkg/zx/profile.cpp","pkg/zx/resource.cpp","pkg/zx/socket.cpp","pkg/zx/thread.cpp","pkg/zx/timer.cpp","pkg/zx/vcpu.cpp","pkg/zx/vmar.cpp","pkg/zx/vmo.cpp"],
- local_include_dirs: ["pkg/zx/include"],
- export_include_dirs: ["pkg/zx/include"],
- shared_libs: [],
- export_shared_lib_headers: [],
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_bootserver",
- srcs: ["tools/bootserver"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_far",
- srcs: ["tools/far"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_fidl-format",
- srcs: ["tools/fidl-format"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_fidlc",
- srcs: ["tools/fidlc"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_fidlgen",
- srcs: ["tools/fidlgen"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_fvm",
- srcs: ["tools/fvm"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_loglistener",
- srcs: ["tools/loglistener"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_merkleroot",
- srcs: ["tools/merkleroot"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_minfs",
- srcs: ["tools/minfs"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_netaddr",
- srcs: ["tools/netaddr"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_netcp",
- srcs: ["tools/netcp"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_netls",
- srcs: ["tools/netls"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_netruncmd",
- srcs: ["tools/netruncmd"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_pm",
- srcs: ["tools/pm"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_zbi",
- srcs: ["tools/zbi"],
- host_supported: true,
-}
-
-cc_prebuilt_binary {
- name: "fuchsia_zxdb",
- srcs: ["tools/zxdb"],
- host_supported: true,
-}
-
diff --git a/COPYRIGHT.musl b/COPYRIGHT.musl
new file mode 100644
index 0000000..faebed7
--- /dev/null
+++ b/COPYRIGHT.musl
@@ -0,0 +1,129 @@
+musl as a whole is licensed under the following standard MIT license:
+
+----------------------------------------------------------------------
+Copyright © 2005-2014 Rich Felker, et al.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+----------------------------------------------------------------------
+
+Authors/contributors include:
+
+Alex Dowad
+Alexander Monakov
+Anthony G. Basile
+Arvid Picciani
+Bobby Bingham
+Boris Brezillon
+Brent Cook
+Chris Spiegel
+Clément Vasseur
+Daniel Micay
+Denys Vlasenko
+Emil Renner Berthing
+Felix Fietkau
+Felix Janda
+Gianluca Anzolin
+Hauke Mehrtens
+Hiltjo Posthuma
+Isaac Dunham
+Jaydeep Patil
+Jens Gustedt
+Jeremy Huntwork
+Jo-Philipp Wich
+Joakim Sindholt
+John Spencer
+Josiah Worcester
+Justin Cormack
+Khem Raj
+Kylie McClain
+Luca Barbato
+Luka Perkov
+M Farkas-Dyck (Strake)
+Mahesh Bodapati
+Michael Forney
+Natanael Copa
+Nicholas J. Kain
+orc
+Pascal Cuoq
+Petr Hosek
+Pierre Carrier
+Rich Felker
+Richard Pennington
+Shiz
+sin
+Solar Designer
+Stefan Kristiansson
+Szabolcs Nagy
+Timo Teräs
+Trutz Behn
+Valentin Ochs
+William Haddon
+
+Portions of this software are derived from third-party works licensed
+under terms compatible with the above MIT license:
+
+Much of the math library code (third_party/math/* and
+third_party/complex/*, and third_party/include/libm.h) is
+Copyright © 1993,2004 Sun Microsystems or
+Copyright © 2003-2011 David Schultz or
+Copyright © 2003-2009 Steven G. Kargl or
+Copyright © 2003-2009 Bruce D. Evans or
+Copyright © 2008 Stephen L. Moshier
+and labelled as such in comments in the individual source files. All
+have been licensed under extremely permissive terms.
+
+The smoothsort implementation (third_party/smoothsort/qsort.c) is
+Copyright © 2011 Valentin Ochs and is licensed under an MIT-style
+license.
+
+The x86_64 files in third_party/arch were written by Nicholas J. Kain
+and is licensed under the standard MIT terms.
+
+All other files which have no copyright comments are original works
+produced specifically for use as part of this library, written either
+by Rich Felker, the main author of the library, or by one or more
+contibutors listed above. Details on authorship of individual files
+can be found in the git version control history of the project. The
+omission of copyright and license comments in each file is in the
+interest of source tree size.
+
+In addition, permission is hereby granted for all public header files
+(include/* and arch/*/bits/*) and crt files intended to be linked into
+applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
+the copyright notice and permission notice otherwise required by the
+license, and to use these files without any requirement of
+attribution. These files include substantial contributions from:
+
+Bobby Bingham
+John Spencer
+Nicholas J. Kain
+Rich Felker
+Richard Pennington
+Stefan Kristiansson
+Szabolcs Nagy
+
+all of whom have explicitly granted such permission.
+
+This file previously contained text expressing a belief that most of
+the files covered by the above exception were sufficiently trivial not
+to be subject to copyright, resulting in confusion over whether it
+negated the permissions granted in the license. In the spirit of
+permissive licensing, and of not having licensing issues being an
+obstacle to adoption, that text has been removed.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..87f152c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+Copyright 2019 The Fuchsia Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/PATENTS b/PATENTS
new file mode 100644
index 0000000..2746e78
--- /dev/null
+++ b/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Fuchsia project.
+
+Google hereby grants to you a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this
+section) patent license to make, have made, use, offer to sell, sell,
+import, transfer, and otherwise run, modify and propagate the contents
+of this implementation of Fuchsia, where such license applies only to
+those patent claims, both currently owned by Google and acquired in
+the future, licensable by Google that are necessarily infringed by
+this implementation. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute
+or order or agree to the institution of patent litigation or any other
+patent enforcement activity against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that this
+implementation of Fuchsia constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of
+Fuchsia shall terminate as of the date such litigation is filed.
diff --git a/README.md b/README.md
index b63aee1..4c4c077 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,115 @@
-Fuchsia SDK without the following packages that were removed to save space:
-- zxdb
-- images
+# Fuchsia Integrator Development Kit (IDK)
+
+This archive contains the Fuchsia Integrator Development Kit (IDK),
+which is a small set of Fuchsia-specific libraries and tools required to start
+building and running programs for Fuchsia.
+
+The Fuchsia IDK is not suitable for immediate consumption.
+It does not contain any reference to toolchains or build systems, and in fact
+does not require any specific instance of these.
+While this might be viewed as a drawback, this is actually a feature, an
+integral part of a layered approach to building a fully-functional SDK.
+Even though it is not tied to a particular build system, the IDK contains
+metadata that may be used to produce support for a large variety of build
+systems, thereby producing various SDK distributions.
+Having the IDK cleanly separated from these various distributions allows
+for very flexible release schemes and iteration cycles.
+
+Most developers who wish to build something for Fuchsia should not need to
+deal directly with the IDK.
+They will instead consume a transformed version of it, for instance within the
+development environment and ecosystem supporting a given language runtime.
+Maintainers of development environments who wish to add support for Fuchsia are
+the main audience for the IDK.
+See [the section below](#ingestion) for a description of how to process this
+SDK.
+
+As such, the Fuchsia IDK is the representation of the Fuchsia platform developers'
+contract with other developers who work with Fuchsia.
+While that contract is absolutely necessary, as this IDK contains the very bits
+that are unique to Fuchsia, it is not sufficient and will be complemented by
+other "contracts".
+The Fuchsia IDK is mirroring the Fuchsia platform in that respect: highly
+composable and extensible, with a clear separation of concerns.
+
+## Structure
+
+From this point on, the root of the IDK archive will be referred to as `//`.
+
+### Metadata
+
+Metadata is present throughout this IDK in the form of JSON files.
+Every element in this IDK has its own metadata file: for example, a FIDL library
+`//fidl/fuchsia.foobar` has its metadata encoded in
+`//fidl/fuchsia.foobar/meta.json`.
+
+Every metadata file follows a JSON schema available under `//meta/schemas`: for
+example, a FIDL library's metadata file conforms to
+`//meta/schemas/fidl_library.json`.
+Schemas act as the documentation for the metadata and may be used to facilitate
+the IDK ingestion process.
+
+### Documentation
+
+General documentation is available under [`//docs`](docs/README.md).
+Some individual IDK elements will also provide documentation directly under the
+path where they are hosted in the SDK.
+
+### Target prebuilts
+
+Target prebuilts are hosted under `//arch/<architecture>`.
+This includes a full-fledged sysroot for each available architecture.
+
+### Source libraries
+
+The IDK contains sources for a large number of FIDL libraries (under
+`//fidl`) as well as a few C/C++ libraries (under `//pkg`).
+
+### Host tools
+
+Multiple host-side tools can be found under `//tools`.
+This includes tools for building programs, deploying to a device, debugging,
+etc...
+Some information about how to use these tools can be found under `//docs`.
+
+### Images
+
+`//device` contains metadata describing device configurations matching a given
+version of the IDK.
+This metadata contains pointers to images that can be flashed onto said devices.
+
+
+## Ingestion
+
+This section describes the process of consuming the IDK and turning
+it into a SDK that is specific to a development environment so it can be used
+directly by developers.
+
+The main entry point for the ingestion process is a file at
+`//meta/manifest.json`.
+As with every metadata file in the SDK, the manifest follows a JSON schema which
+is included under `//meta/schemas/manifest.json`.
+
+This file contains a list of all the elements included in this IDK, represented
+by the path to their respective metadata file.
+Each element file is guaranteed to contain a top-level `type` attribute, which
+may be used to apply different treatments to different element types, e.g.
+generating a build file for a FIDL library vs. just moving a host tool to a
+convenient location in the final development environment.
+
+The existence of the various metadata files as well as the exhaustiveness of
+their contents should make it so that the ingestion process may be fully
+automated.
+JSON schemas may even be used to generate code representing the metadata
+containers and let the ingestion program handle idiomatic data structures
+instead of raw JSON representations.
+
+The metadata schemas will evolve over time.
+In order to allow consumers of that metadata to adjust to schema changes, the
+main metadata file contains a property named `schema_version` which is an opaque
+version identifier for these schemas.
+This version identifier will be modified every time the metadata schemas evolve
+in a way that requires the attention of a developer.
+IDK consumers may record the version identifier of the metadata they used to last
+ingest an IDK and compare that version identifier to next SDK's version
+identifier in order to detect when developer action may be required.
diff --git a/arch/arm64/dist/libVkLayer_core_validation.so b/arch/arm64/dist/libVkLayer_core_validation.so
deleted file mode 100755
index 5369287..0000000
--- a/arch/arm64/dist/libVkLayer_core_validation.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libVkLayer_image_pipe_swapchain.so b/arch/arm64/dist/libVkLayer_image_pipe_swapchain.so
deleted file mode 100755
index bdd188d..0000000
--- a/arch/arm64/dist/libVkLayer_image_pipe_swapchain.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libVkLayer_object_tracker.so b/arch/arm64/dist/libVkLayer_object_tracker.so
deleted file mode 100755
index 59ff73b..0000000
--- a/arch/arm64/dist/libVkLayer_object_tracker.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libVkLayer_parameter_validation.so b/arch/arm64/dist/libVkLayer_parameter_validation.so
deleted file mode 100755
index 82c7711..0000000
--- a/arch/arm64/dist/libVkLayer_parameter_validation.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libVkLayer_threading.so b/arch/arm64/dist/libVkLayer_threading.so
deleted file mode 100755
index b763406..0000000
--- a/arch/arm64/dist/libVkLayer_threading.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libVkLayer_unique_objects.so b/arch/arm64/dist/libVkLayer_unique_objects.so
deleted file mode 100755
index 263c719..0000000
--- a/arch/arm64/dist/libVkLayer_unique_objects.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libasync-default.so b/arch/arm64/dist/libasync-default.so
deleted file mode 100755
index c85b195..0000000
--- a/arch/arm64/dist/libasync-default.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libfdio.so b/arch/arm64/dist/libfdio.so
index 1b2841f..dad0003 100755
--- a/arch/arm64/dist/libfdio.so
+++ b/arch/arm64/dist/libfdio.so
Binary files differ
diff --git a/arch/arm64/dist/libmemfs.so b/arch/arm64/dist/libmemfs.so
deleted file mode 100755
index 3b1aa06..0000000
--- a/arch/arm64/dist/libmemfs.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libsvc.so b/arch/arm64/dist/libsvc.so
deleted file mode 100755
index 3cb0539..0000000
--- a/arch/arm64/dist/libsvc.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libsyslog.so b/arch/arm64/dist/libsyslog.so
deleted file mode 100755
index 495e797..0000000
--- a/arch/arm64/dist/libsyslog.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libtrace-engine.so b/arch/arm64/dist/libtrace-engine.so
deleted file mode 100755
index 8ebaf73..0000000
--- a/arch/arm64/dist/libtrace-engine.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/dist/libvulkan.so b/arch/arm64/dist/libvulkan.so
deleted file mode 100755
index edd5b26..0000000
--- a/arch/arm64/dist/libvulkan.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libasync-default.so b/arch/arm64/lib/libasync-default.so
deleted file mode 100755
index 48caaf4..0000000
--- a/arch/arm64/lib/libasync-default.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libfdio.so b/arch/arm64/lib/libfdio.so
index 7d0bf9f..dad0003 100755
--- a/arch/arm64/lib/libfdio.so
+++ b/arch/arm64/lib/libfdio.so
Binary files differ
diff --git a/arch/arm64/lib/libmemfs.so b/arch/arm64/lib/libmemfs.so
deleted file mode 100755
index 170585e..0000000
--- a/arch/arm64/lib/libmemfs.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libsvc.so b/arch/arm64/lib/libsvc.so
deleted file mode 100755
index 3cb0539..0000000
--- a/arch/arm64/lib/libsvc.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libsync.a b/arch/arm64/lib/libsync.a
index caaf384..630b753 100644
--- a/arch/arm64/lib/libsync.a
+++ b/arch/arm64/lib/libsync.a
Binary files differ
diff --git a/arch/arm64/lib/libsyslog.so b/arch/arm64/lib/libsyslog.so
deleted file mode 100755
index 1c2f5c8..0000000
--- a/arch/arm64/lib/libsyslog.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libtrace-engine.so b/arch/arm64/lib/libtrace-engine.so
deleted file mode 100755
index f661692..0000000
--- a/arch/arm64/lib/libtrace-engine.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/lib/libvulkan.so b/arch/arm64/lib/libvulkan.so
deleted file mode 100755
index edd5b26..0000000
--- a/arch/arm64/lib/libvulkan.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/sysroot/debug/libc.so b/arch/arm64/sysroot/debug/libc.so
deleted file mode 100755
index 0bcdcd2..0000000
--- a/arch/arm64/sysroot/debug/libc.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/sysroot/debug/libzircon.so b/arch/arm64/sysroot/debug/libzircon.so
deleted file mode 100755
index 5f4f11a..0000000
--- a/arch/arm64/sysroot/debug/libzircon.so
+++ /dev/null
Binary files differ
diff --git a/arch/arm64/sysroot/dist/lib/asan-ubsan/ld.so.1 b/arch/arm64/sysroot/dist/lib/asan-ubsan/ld.so.1
new file mode 100755
index 0000000..f3600b9
--- /dev/null
+++ b/arch/arm64/sysroot/dist/lib/asan-ubsan/ld.so.1
Binary files differ
diff --git a/arch/arm64/sysroot/dist/lib/asan/ld.so.1 b/arch/arm64/sysroot/dist/lib/asan/ld.so.1
new file mode 100755
index 0000000..826b5a2
--- /dev/null
+++ b/arch/arm64/sysroot/dist/lib/asan/ld.so.1
Binary files differ
diff --git a/arch/arm64/sysroot/dist/lib/ld.so.1 b/arch/arm64/sysroot/dist/lib/ld.so.1
index c414eff..15145aa 100755
--- a/arch/arm64/sysroot/dist/lib/ld.so.1
+++ b/arch/arm64/sysroot/dist/lib/ld.so.1
Binary files differ
diff --git a/arch/arm64/sysroot/include/alloca.h b/arch/arm64/sysroot/include/alloca.h
index c1679dd..7deb5b9 100644
--- a/arch/arm64/sysroot/include/alloca.h
+++ b/arch/arm64/sysroot/include/alloca.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ALLOCA_H_
+#define SYSROOT_ALLOCA_H_
#ifdef __cplusplus
extern "C" {
@@ -16,3 +17,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ALLOCA_H_
diff --git a/arch/arm64/sysroot/include/ar.h b/arch/arm64/sysroot/include/ar.h
index d20348b..d0d4176 100644
--- a/arch/arm64/sysroot/include/ar.h
+++ b/arch/arm64/sysroot/include/ar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_AR_H_
+#define SYSROOT_AR_H_
#ifdef __cplusplus
extern "C" {
@@ -9,14 +10,16 @@
#define ARFMAG "`\n"
struct ar_hdr {
- char ar_name[16];
- char ar_date[12];
- char ar_uid[6], ar_gid[6];
- char ar_mode[8];
- char ar_size[10];
- char ar_fmag[2];
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6], ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_AR_H_
diff --git a/arch/arm64/sysroot/include/arpa/ftp.h b/arch/arm64/sysroot/include/arpa/ftp.h
index e1b66d3..7d86bec 100644
--- a/arch/arm64/sysroot/include/arpa/ftp.h
+++ b/arch/arm64/sysroot/include/arpa/ftp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_FTP_H_
+#define SYSROOT_ARPA_FTP_H_
#define PRELIM 1
#define COMPLETE 2
@@ -32,3 +33,5 @@
char* typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local"};
char* formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control"};
#endif
+
+#endif // SYSROOT_ARPA_FTP_H_
diff --git a/arch/arm64/sysroot/include/arpa/inet.h b/arch/arm64/sysroot/include/arpa/inet.h
index cfb02ea..4fa0af5 100644
--- a/arch/arm64/sysroot/include/arpa/inet.h
+++ b/arch/arm64/sysroot/include/arpa/inet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_INET_H_
+#define SYSROOT_ARPA_INET_H_
#ifdef __cplusplus
extern "C" {
@@ -31,3 +32,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ARPA_INET_H_
diff --git a/arch/arm64/sysroot/include/arpa/nameser.h b/arch/arm64/sysroot/include/arpa/nameser.h
index 9218a58..734d205 100644
--- a/arch/arm64/sysroot/include/arpa/nameser.h
+++ b/arch/arm64/sysroot/include/arpa/nameser.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_NAMESER_H_
+#define SYSROOT_ARPA_NAMESER_H_
#ifdef __cplusplus
extern "C" {
@@ -25,27 +26,27 @@
#define NS_DEFAULTPORT 53
typedef enum __ns_sect {
- ns_s_qd = 0,
- ns_s_zn = 0,
- ns_s_an = 1,
- ns_s_pr = 1,
- ns_s_ns = 2,
- ns_s_ud = 2,
- ns_s_ar = 3,
- ns_s_max = 4
+ ns_s_qd = 0,
+ ns_s_zn = 0,
+ ns_s_an = 1,
+ ns_s_pr = 1,
+ ns_s_ns = 2,
+ ns_s_ud = 2,
+ ns_s_ar = 3,
+ ns_s_max = 4
} ns_sect;
typedef struct __ns_msg {
- const unsigned char *_msg, *_eom;
- uint16_t _id, _flags, _counts[ns_s_max];
- const unsigned char* _sections[ns_s_max];
- ns_sect _sect;
- int _rrnum;
- const unsigned char* _msg_ptr;
+ const unsigned char *_msg, *_eom;
+ uint16_t _id, _flags, _counts[ns_s_max];
+ const unsigned char* _sections[ns_s_max];
+ ns_sect _sect;
+ int _rrnum;
+ const unsigned char* _msg_ptr;
} ns_msg;
struct _ns_flagdata {
- int mask, shift;
+ int mask, shift;
};
extern const struct _ns_flagdata _ns_flagdata[];
@@ -55,15 +56,15 @@
#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
#define ns_msg_getflag(handle, flag) \
- (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
+ (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
typedef struct __ns_rr {
- char name[NS_MAXDNAME];
- uint16_t type;
- uint16_t rr_class;
- uint32_t ttl;
- uint16_t rdlength;
- const unsigned char* rdata;
+ char name[NS_MAXDNAME];
+ uint16_t type;
+ uint16_t rr_class;
+ uint32_t ttl;
+ uint16_t rdlength;
+ const unsigned char* rdata;
} ns_rr;
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
@@ -74,66 +75,66 @@
#define ns_rr_rdata(rr) ((rr).rdata + 0)
typedef enum __ns_flag {
- ns_f_qr,
- ns_f_opcode,
- ns_f_aa,
- ns_f_tc,
- ns_f_rd,
- ns_f_ra,
- ns_f_z,
- ns_f_ad,
- ns_f_cd,
- ns_f_rcode,
- ns_f_max
+ ns_f_qr,
+ ns_f_opcode,
+ ns_f_aa,
+ ns_f_tc,
+ ns_f_rd,
+ ns_f_ra,
+ ns_f_z,
+ ns_f_ad,
+ ns_f_cd,
+ ns_f_rcode,
+ ns_f_max
} ns_flag;
typedef enum __ns_opcode {
- ns_o_query = 0,
- ns_o_iquery = 1,
- ns_o_status = 2,
- ns_o_notify = 4,
- ns_o_update = 5,
- ns_o_max = 6
+ ns_o_query = 0,
+ ns_o_iquery = 1,
+ ns_o_status = 2,
+ ns_o_notify = 4,
+ ns_o_update = 5,
+ ns_o_max = 6
} ns_opcode;
typedef enum __ns_rcode {
- ns_r_noerror = 0,
- ns_r_formerr = 1,
- ns_r_servfail = 2,
- ns_r_nxdomain = 3,
- ns_r_notimpl = 4,
- ns_r_refused = 5,
- ns_r_yxdomain = 6,
- ns_r_yxrrset = 7,
- ns_r_nxrrset = 8,
- ns_r_notauth = 9,
- ns_r_notzone = 10,
- ns_r_max = 11,
- ns_r_badvers = 16,
- ns_r_badsig = 16,
- ns_r_badkey = 17,
- ns_r_badtime = 18
+ ns_r_noerror = 0,
+ ns_r_formerr = 1,
+ ns_r_servfail = 2,
+ ns_r_nxdomain = 3,
+ ns_r_notimpl = 4,
+ ns_r_refused = 5,
+ ns_r_yxdomain = 6,
+ ns_r_yxrrset = 7,
+ ns_r_nxrrset = 8,
+ ns_r_notauth = 9,
+ ns_r_notzone = 10,
+ ns_r_max = 11,
+ ns_r_badvers = 16,
+ ns_r_badsig = 16,
+ ns_r_badkey = 17,
+ ns_r_badtime = 18
} ns_rcode;
typedef enum __ns_update_operation {
- ns_uop_delete = 0,
- ns_uop_add = 1,
- ns_uop_max = 2
+ ns_uop_delete = 0,
+ ns_uop_add = 1,
+ ns_uop_max = 2
} ns_update_operation;
struct ns_tsig_key {
- char name[NS_MAXDNAME], alg[NS_MAXDNAME];
- unsigned char* data;
- int len;
+ char name[NS_MAXDNAME], alg[NS_MAXDNAME];
+ unsigned char* data;
+ int len;
};
typedef struct ns_tsig_key ns_tsig_key;
struct ns_tcp_tsig_state {
- int counter;
- struct dst_key* key;
- void* ctx;
- unsigned char sig[NS_PACKETSZ];
- int siglen;
+ int counter;
+ struct dst_key* key;
+ void* ctx;
+ unsigned char sig[NS_PACKETSZ];
+ int siglen;
};
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
@@ -146,58 +147,58 @@
#define NS_TSIG_ERROR_FORMERR -12
typedef enum __ns_type {
- ns_t_invalid = 0,
- ns_t_a = 1,
- ns_t_ns = 2,
- ns_t_md = 3,
- ns_t_mf = 4,
- ns_t_cname = 5,
- ns_t_soa = 6,
- ns_t_mb = 7,
- ns_t_mg = 8,
- ns_t_mr = 9,
- ns_t_null = 10,
- ns_t_wks = 11,
- ns_t_ptr = 12,
- ns_t_hinfo = 13,
- ns_t_minfo = 14,
- ns_t_mx = 15,
- ns_t_txt = 16,
- ns_t_rp = 17,
- ns_t_afsdb = 18,
- ns_t_x25 = 19,
- ns_t_isdn = 20,
- ns_t_rt = 21,
- ns_t_nsap = 22,
- ns_t_nsap_ptr = 23,
- ns_t_sig = 24,
- ns_t_key = 25,
- ns_t_px = 26,
- ns_t_gpos = 27,
- ns_t_aaaa = 28,
- ns_t_loc = 29,
- ns_t_nxt = 30,
- ns_t_eid = 31,
- ns_t_nimloc = 32,
- ns_t_srv = 33,
- ns_t_atma = 34,
- ns_t_naptr = 35,
- ns_t_kx = 36,
- ns_t_cert = 37,
- ns_t_a6 = 38,
- ns_t_dname = 39,
- ns_t_sink = 40,
- ns_t_opt = 41,
- ns_t_apl = 42,
- ns_t_tkey = 249,
- ns_t_tsig = 250,
- ns_t_ixfr = 251,
- ns_t_axfr = 252,
- ns_t_mailb = 253,
- ns_t_maila = 254,
- ns_t_any = 255,
- ns_t_zxfr = 256,
- ns_t_max = 65536
+ ns_t_invalid = 0,
+ ns_t_a = 1,
+ ns_t_ns = 2,
+ ns_t_md = 3,
+ ns_t_mf = 4,
+ ns_t_cname = 5,
+ ns_t_soa = 6,
+ ns_t_mb = 7,
+ ns_t_mg = 8,
+ ns_t_mr = 9,
+ ns_t_null = 10,
+ ns_t_wks = 11,
+ ns_t_ptr = 12,
+ ns_t_hinfo = 13,
+ ns_t_minfo = 14,
+ ns_t_mx = 15,
+ ns_t_txt = 16,
+ ns_t_rp = 17,
+ ns_t_afsdb = 18,
+ ns_t_x25 = 19,
+ ns_t_isdn = 20,
+ ns_t_rt = 21,
+ ns_t_nsap = 22,
+ ns_t_nsap_ptr = 23,
+ ns_t_sig = 24,
+ ns_t_key = 25,
+ ns_t_px = 26,
+ ns_t_gpos = 27,
+ ns_t_aaaa = 28,
+ ns_t_loc = 29,
+ ns_t_nxt = 30,
+ ns_t_eid = 31,
+ ns_t_nimloc = 32,
+ ns_t_srv = 33,
+ ns_t_atma = 34,
+ ns_t_naptr = 35,
+ ns_t_kx = 36,
+ ns_t_cert = 37,
+ ns_t_a6 = 38,
+ ns_t_dname = 39,
+ ns_t_sink = 40,
+ ns_t_opt = 41,
+ ns_t_apl = 42,
+ ns_t_tkey = 249,
+ ns_t_tsig = 250,
+ ns_t_ixfr = 251,
+ ns_t_axfr = 252,
+ ns_t_mailb = 253,
+ ns_t_maila = 254,
+ ns_t_any = 255,
+ ns_t_zxfr = 256,
+ ns_t_max = 65536
} ns_type;
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || (t) == ns_t_mailb || (t) == ns_t_maila)
@@ -207,29 +208,29 @@
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || (t) == ns_t_zxfr)
typedef enum __ns_class {
- ns_c_invalid = 0,
- ns_c_in = 1,
- ns_c_2 = 2,
- ns_c_chaos = 3,
- ns_c_hs = 4,
- ns_c_none = 254,
- ns_c_any = 255,
- ns_c_max = 65536
+ ns_c_invalid = 0,
+ ns_c_in = 1,
+ ns_c_2 = 2,
+ ns_c_chaos = 3,
+ ns_c_hs = 4,
+ ns_c_none = 254,
+ ns_c_any = 255,
+ ns_c_max = 65536
} ns_class;
typedef enum __ns_key_types {
- ns_kt_rsa = 1,
- ns_kt_dh = 2,
- ns_kt_dsa = 3,
- ns_kt_private = 254
+ ns_kt_rsa = 1,
+ ns_kt_dh = 2,
+ ns_kt_dsa = 3,
+ ns_kt_private = 254
} ns_key_types;
typedef enum __ns_cert_types {
- cert_t_pkix = 1,
- cert_t_spki = 2,
- cert_t_pgp = 3,
- cert_t_url = 253,
- cert_t_oid = 254
+ cert_t_pkix = 1,
+ cert_t_spki = 2,
+ cert_t_pgp = 3,
+ cert_t_url = 253,
+ cert_t_oid = 254
} ns_cert_types;
#define NS_KEY_TYPEMASK 0xC000
@@ -253,9 +254,9 @@
#define NS_KEY_RESERVED10 0x0020
#define NS_KEY_RESERVED11 0x0010
#define NS_KEY_SIGNATORYMASK 0x000F
-#define NS_KEY_RESERVED_BITMASK \
- (NS_KEY_RESERVED2 | NS_KEY_RESERVED4 | NS_KEY_RESERVED5 | NS_KEY_RESERVED8 | \
- NS_KEY_RESERVED9 | NS_KEY_RESERVED10 | NS_KEY_RESERVED11)
+#define NS_KEY_RESERVED_BITMASK \
+ (NS_KEY_RESERVED2 | NS_KEY_RESERVED4 | NS_KEY_RESERVED5 | NS_KEY_RESERVED8 | NS_KEY_RESERVED9 | \
+ NS_KEY_RESERVED10 | NS_KEY_RESERVED11)
#define NS_KEY_RESERVED_BITMASK2 0xFFFF
#define NS_ALG_MD5RSA 1
#define NS_ALG_DH 2
@@ -317,34 +318,34 @@
#define __BIND 19950621
typedef struct {
- unsigned id : 16;
+ unsigned id : 16;
#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned qr : 1;
- unsigned opcode : 4;
- unsigned aa : 1;
- unsigned tc : 1;
- unsigned rd : 1;
- unsigned ra : 1;
- unsigned unused : 1;
- unsigned ad : 1;
- unsigned cd : 1;
- unsigned rcode : 4;
+ unsigned qr : 1;
+ unsigned opcode : 4;
+ unsigned aa : 1;
+ unsigned tc : 1;
+ unsigned rd : 1;
+ unsigned ra : 1;
+ unsigned unused : 1;
+ unsigned ad : 1;
+ unsigned cd : 1;
+ unsigned rcode : 4;
#else
- unsigned rd : 1;
- unsigned tc : 1;
- unsigned aa : 1;
- unsigned opcode : 4;
- unsigned qr : 1;
- unsigned rcode : 4;
- unsigned cd : 1;
- unsigned ad : 1;
- unsigned unused : 1;
- unsigned ra : 1;
+ unsigned rd : 1;
+ unsigned tc : 1;
+ unsigned aa : 1;
+ unsigned opcode : 4;
+ unsigned qr : 1;
+ unsigned rcode : 4;
+ unsigned cd : 1;
+ unsigned ad : 1;
+ unsigned unused : 1;
+ unsigned ra : 1;
#endif
- unsigned qdcount : 16;
- unsigned ancount : 16;
- unsigned nscount : 16;
- unsigned arcount : 16;
+ unsigned qdcount : 16;
+ unsigned ancount : 16;
+ unsigned nscount : 16;
+ unsigned arcount : 16;
} HEADER;
#define PACKETSZ NS_PACKETSZ
@@ -446,3 +447,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ARPA_NAMESER_H_
diff --git a/arch/arm64/sysroot/include/arpa/telnet.h b/arch/arm64/sysroot/include/arpa/telnet.h
index d6880cf..2da3eda 100644
--- a/arch/arm64/sysroot/include/arpa/telnet.h
+++ b/arch/arm64/sysroot/include/arpa/telnet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_TELNET_H_
+#define SYSROOT_ARPA_TELNET_H_
#define IAC 255
#define DONT 254
@@ -23,10 +24,9 @@
#define SYNCH 242
-#define telcmds \
- ((char[][6]){ \
- "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", \
- "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0})
+#define telcmds \
+ ((char[][6]){"EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", \
+ "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0})
#define TELCMD_FIRST xEOF
#define TELCMD_LAST IAC
@@ -176,9 +176,9 @@
#define NSLC 18
-#define SLC_NAMELIST \
- "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#define SLC_NAMELIST \
+ "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
#ifdef SLC_NAMES
char* slc_names[] = {SLC_NAMELIST};
#else
@@ -256,11 +256,14 @@
#ifdef ENCRYPT_NAMES
char* encrypt_names[] = {
- "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START",
+ "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START",
"REQUEST-END", "ENC-KEYID", "DEC-KEYID", 0,
};
char* enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64", 0,
+ "ANY",
+ "DES_CFB64",
+ "DES_OFB64",
+ 0,
};
#else
extern char* encrypt_names[];
@@ -272,3 +275,5 @@
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
+
+#endif // SYSROOT_ARPA_TELNET_H_
diff --git a/arch/arm64/sysroot/include/arpa/tftp.h b/arch/arm64/sysroot/include/arpa/tftp.h
index 3a76d2f..e091368 100644
--- a/arch/arm64/sysroot/include/arpa/tftp.h
+++ b/arch/arm64/sysroot/include/arpa/tftp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_TFTP_H_
+#define SYSROOT_ARPA_TFTP_H_
#define SEGSIZE 512
#define RRQ 01
@@ -7,13 +8,13 @@
#define ACK 04
#define ERROR 05
struct tftphdr {
- short th_opcode;
- union {
- unsigned short tu_block;
- short tu_code;
- char tu_stuff[1];
- } th_u;
- char th_data[1];
+ short th_opcode;
+ union {
+ unsigned short tu_block;
+ short tu_code;
+ char tu_stuff[1];
+ } th_u;
+ char th_data[1];
};
#define th_block th_u.tu_block
#define th_code th_u.tu_code
@@ -27,3 +28,5 @@
#define EBADID 5
#define EEXISTS 6
#define ENOUSER 7
+
+#endif // SYSROOT_ARPA_TFTP_H_
diff --git a/arch/arm64/sysroot/include/bits/aarch64/fenv.h b/arch/arm64/sysroot/include/bits/aarch64/fenv.h
index 6bb1f56..a370540 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/fenv.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/fenv.h
@@ -12,8 +12,8 @@
typedef unsigned int fexcept_t;
typedef struct {
- unsigned int __fpcr;
- unsigned int __fpsr;
+ unsigned int __fpcr;
+ unsigned int __fpsr;
} fenv_t;
#define FE_DFL_ENV ((const fenv_t*)-1)
diff --git a/arch/arm64/sysroot/include/bits/aarch64/float.h b/arch/arm64/sysroot/include/bits/aarch64/float.h
deleted file mode 100644
index 719c790..0000000
--- a/arch/arm64/sysroot/include/bits/aarch64/float.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#define FLT_EVAL_METHOD 0
-
-#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
-#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
-#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
-#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
-
-#define LDBL_MANT_DIG 113
-#define LDBL_MIN_EXP (-16381)
-#define LDBL_MAX_EXP 16384
-
-#define LDBL_DIG 33
-#define LDBL_MIN_10_EXP (-4931)
-#define LDBL_MAX_10_EXP 4932
-
-#define DECIMAL_DIG 36
diff --git a/arch/arm64/sysroot/include/bits/aarch64/ioctl.h b/arch/arm64/sysroot/include/bits/aarch64/ioctl.h
index f963024..40835ba 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/ioctl.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/ioctl.h
@@ -94,10 +94,10 @@
#define TIOCSER_TEMT 0x01
struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
};
#define TIOCM_LE 0x001
diff --git a/arch/arm64/sysroot/include/bits/aarch64/ipc.h b/arch/arm64/sysroot/include/bits/aarch64/ipc.h
index df2ed2b..26161a2 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/ipc.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/ipc.h
@@ -1,14 +1,14 @@
struct ipc_perm {
- key_t __ipc_perm_key;
- uid_t uid;
- gid_t gid;
- uid_t cuid;
- gid_t cgid;
- mode_t mode;
- unsigned short __ipc_perm_seq;
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ unsigned short __ipc_perm_seq;
- unsigned long __pad1;
- unsigned long __pad2;
+ unsigned long __pad1;
+ unsigned long __pad2;
};
#define IPC_64 0
diff --git a/arch/arm64/sysroot/include/bits/aarch64/setjmp.h b/arch/arm64/sysroot/include/bits/aarch64/setjmp.h
index e3db976..c37aeb8 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/setjmp.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/setjmp.h
@@ -1 +1 @@
-typedef unsigned long long int __jmp_buf[22];
+typedef unsigned long long int __jmp_buf[23];
diff --git a/arch/arm64/sysroot/include/bits/aarch64/signal.h b/arch/arm64/sysroot/include/bits/aarch64/signal.h
index 766d3f9..64e57f3 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/signal.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/signal.h
@@ -11,49 +11,51 @@
typedef unsigned long gregset_t[34];
typedef struct {
- long double vregs[32];
- unsigned int fpsr;
- unsigned int fpcr;
+ long double vregs[32];
+ unsigned int fpsr;
+ unsigned int fpcr;
} fpregset_t;
typedef struct sigcontext {
- unsigned long fault_address;
- unsigned long regs[31];
- unsigned long sp, pc, pstate;
- long double __reserved[256];
+ unsigned long fault_address;
+ unsigned long regs[31];
+ unsigned long sp, pc, pstate;
+ long double __reserved[256];
} mcontext_t;
#define FPSIMD_MAGIC 0x46508001
#define ESR_MAGIC 0x45535201
struct _aarch64_ctx {
- unsigned int magic;
- unsigned int size;
+ unsigned int magic;
+ unsigned int size;
};
struct fpsimd_context {
- struct _aarch64_ctx head;
- unsigned int fpsr;
- unsigned int fpcr;
- long double vregs[32];
+ struct _aarch64_ctx head;
+ unsigned int fpsr;
+ unsigned int fpcr;
+ long double vregs[32];
};
struct esr_context {
- struct _aarch64_ctx head;
- unsigned long esr;
+ struct _aarch64_ctx head;
+ unsigned long esr;
};
#else
-typedef struct { long double __regs[18 + 256]; } mcontext_t;
+typedef struct {
+ long double __regs[18 + 256];
+} mcontext_t;
#endif
struct sigaltstack {
- void* ss_sp;
- int ss_flags;
- size_t ss_size;
+ void* ss_sp;
+ int ss_flags;
+ size_t ss_size;
};
typedef struct __ucontext {
- unsigned long uc_flags;
- struct ucontext* uc_link;
- stack_t uc_stack;
- sigset_t uc_sigmask;
- mcontext_t uc_mcontext;
+ unsigned long uc_flags;
+ struct ucontext* uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
} ucontext_t;
#define SA_NOCLDSTOP 1
diff --git a/arch/arm64/sysroot/include/bits/aarch64/stat.h b/arch/arm64/sysroot/include/bits/aarch64/stat.h
index 0fe7e69..02102fa 100644
--- a/arch/arm64/sysroot/include/bits/aarch64/stat.h
+++ b/arch/arm64/sysroot/include/bits/aarch64/stat.h
@@ -1,18 +1,18 @@
struct stat {
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- unsigned long __pad;
- off_t st_size;
- blksize_t st_blksize;
- int __pad2;
- blkcnt_t st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned __unused[2];
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ unsigned long __pad;
+ off_t st_size;
+ blksize_t st_blksize;
+ int __pad2;
+ blkcnt_t st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned __unused1[2];
};
diff --git a/arch/arm64/sysroot/include/bits/alltypes.h b/arch/arm64/sysroot/include/bits/alltypes.h
index 21fcb7f..95da44c 100644
--- a/arch/arm64/sysroot/include/bits/alltypes.h
+++ b/arch/arm64/sysroot/include/bits/alltypes.h
@@ -193,8 +193,8 @@
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
typedef struct {
- long long __ll;
- long double __ld;
+ long long __ll;
+ long double __ld;
} max_align_t;
#define __DEFINED_max_align_t
#endif
@@ -310,24 +310,24 @@
#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
struct iovec {
- void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
#define __DEFINED_struct_iovec
#endif
#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
struct timeval {
- time_t tv_sec;
- suseconds_t tv_usec;
+ time_t tv_sec;
+ suseconds_t tv_usec;
};
#define __DEFINED_struct_timeval
#endif
#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
struct timespec {
- time_t tv_sec;
- long tv_nsec;
+ time_t tv_sec;
+ long tv_nsec;
};
#define __DEFINED_struct_timespec
#endif
@@ -373,7 +373,9 @@
#endif
#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
-typedef struct __sigset_t { unsigned long __bits[128 / sizeof(long)]; } sigset_t;
+typedef struct __sigset_t {
+ unsigned long __bits[128 / sizeof(long)];
+} sigset_t;
#define __DEFINED_sigset_t
#endif
@@ -398,22 +400,30 @@
#endif
#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
-typedef struct { unsigned __attr; } pthread_mutexattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_mutexattr_t;
#define __DEFINED_pthread_mutexattr_t
#endif
#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
-typedef struct { unsigned __attr; } pthread_condattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_condattr_t;
#define __DEFINED_pthread_condattr_t
#endif
#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
-typedef struct { unsigned __attr; } pthread_barrierattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_barrierattr_t;
#define __DEFINED_pthread_barrierattr_t
#endif
#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
-typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+typedef struct {
+ unsigned __attr[2];
+} pthread_rwlockattr_t;
#define __DEFINED_pthread_rwlockattr_t
#endif
@@ -432,31 +442,35 @@
#endif
#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
-typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
+typedef struct __mbstate_t {
+ unsigned __opaque1, __opaque2;
+} mbstate_t;
#define __DEFINED_mbstate_t
#endif
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
typedef struct {
- const char* __name;
- int __c11;
- size_t _a_stacksize;
- size_t _a_guardsize;
- void* _a_stackaddr;
- int _a_detach;
- int _a_sched;
- int _a_policy;
- int _a_prio;
+ const char* __name;
+ int __c11;
+ size_t _a_stacksize;
+ size_t _a_guardsize;
+ void* _a_stackaddr;
+ int _a_detach;
+ int _a_sched;
+ int _a_policy;
+ int _a_prio;
} pthread_attr_t;
#define __DEFINED_pthread_attr_t
#endif
#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
typedef struct {
- int _m_type;
- __C11_ATOMIC(int) _m_lock;
- __C11_ATOMIC(int) _m_waiters;
- int _m_count;
+ unsigned _m_attr;
+ __C11_ATOMIC(int)
+ _m_lock;
+ __C11_ATOMIC(int)
+ _m_waiters;
+ int _m_count;
} pthread_mutex_t;
#define __DEFINED_pthread_mutex_t
#endif
@@ -467,55 +481,64 @@
__attribute__((__capability__("mutex")))
#endif
{
- int __i[1];
+ int __i[1];
} mtx_t;
#define __DEFINED_mtx_t
#endif
#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
typedef struct {
- void* _c_head;
- int _c_clock;
- void* _c_tail;
- __C11_ATOMIC(int) _c_lock;
+ void* _c_head;
+ int _c_clock;
+ void* _c_tail;
+ __C11_ATOMIC(int)
+ _c_lock;
} pthread_cond_t;
#define __DEFINED_pthread_cond_t
#endif
#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
typedef struct {
- void* _c_head;
- int _c_clock;
- void* _c_tail;
- __C11_ATOMIC(int) _c_lock;
+ void* _c_head;
+ int _c_clock;
+ void* _c_tail;
+ __C11_ATOMIC(int) _c_lock;
} cnd_t;
#define __DEFINED_cnd_t
#endif
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
typedef struct {
- __C11_ATOMIC(int) _rw_lock;
- __C11_ATOMIC(int) _rw_waiters;
+ __C11_ATOMIC(int)
+ _rw_lock;
+ __C11_ATOMIC(int)
+ _rw_waiters;
} pthread_rwlock_t;
#define __DEFINED_pthread_rwlock_t
#endif
#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
typedef struct {
- __C11_ATOMIC(int) _b_lock;
- __C11_ATOMIC(int) _b_waiters;
- unsigned int _b_limit;
- __C11_ATOMIC(int) _b_count;
- __C11_ATOMIC(int) _b_waiters2;
- void* _b_inst;
+ __C11_ATOMIC(int)
+ _b_lock;
+ __C11_ATOMIC(int)
+ _b_waiters;
+ unsigned int _b_limit;
+ __C11_ATOMIC(int)
+ _b_count;
+ __C11_ATOMIC(int)
+ _b_waiters2;
+ void* _b_inst;
} pthread_barrier_t;
#define __DEFINED_pthread_barrier_t
#endif
#if defined(__NEED_sem_t) && !defined(__DEFINED_sem_t)
typedef struct {
- __C11_ATOMIC(int) _s_value;
- __C11_ATOMIC(int) _s_waiters;
+ __C11_ATOMIC(int)
+ _s_value;
+ __C11_ATOMIC(int)
+ _s_waiters;
} sem_t;
#define __DEFINED_sem_t
#endif
diff --git a/arch/arm64/sysroot/include/bits/float.h b/arch/arm64/sysroot/include/bits/float.h
deleted file mode 100644
index 45354da..0000000
--- a/arch/arm64/sysroot/include/bits/float.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#if defined(__x86_64__)
-#include "x86_64/float.h"
-#elif defined(__aarch64__)
-#include "aarch64/float.h"
-#else
-#error Unsupported architecture!
-#endif
diff --git a/arch/arm64/sysroot/include/bits/msg.h b/arch/arm64/sysroot/include/bits/msg.h
index 9b3f7e5..1c8034b 100644
--- a/arch/arm64/sysroot/include/bits/msg.h
+++ b/arch/arm64/sysroot/include/bits/msg.h
@@ -1,12 +1,12 @@
struct msqid_ds {
- struct ipc_perm msg_perm;
- time_t msg_stime;
- time_t msg_rtime;
- time_t msg_ctime;
- unsigned long msg_cbytes;
- msgqnum_t msg_qnum;
- msglen_t msg_qbytes;
- pid_t msg_lspid;
- pid_t msg_lrpid;
- unsigned long __unused[2];
+ struct ipc_perm msg_perm;
+ time_t msg_stime;
+ time_t msg_rtime;
+ time_t msg_ctime;
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
};
diff --git a/arch/arm64/sysroot/include/bits/null.h b/arch/arm64/sysroot/include/bits/null.h
index 1788e0c..76e7b77 100644
--- a/arch/arm64/sysroot/include/bits/null.h
+++ b/arch/arm64/sysroot/include/bits/null.h
@@ -4,9 +4,12 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
-#pragma once
+#ifndef SYSROOT_BITS_NULL_H_
+#define SYSROOT_BITS_NULL_H_
// The compiler's <stddef.h> defines NULL without defining anything
// else if __need_NULL is defined first.
#define __need_NULL
#include <stddef.h>
+
+#endif // SYSROOT_BITS_NULL_H_
diff --git a/arch/arm64/sysroot/include/bits/sem.h b/arch/arm64/sysroot/include/bits/sem.h
index d7aa74b..db4102f 100644
--- a/arch/arm64/sysroot/include/bits/sem.h
+++ b/arch/arm64/sysroot/include/bits/sem.h
@@ -1,14 +1,14 @@
struct semid_ds {
- struct ipc_perm sem_perm;
- time_t sem_otime;
- time_t sem_ctime;
+ struct ipc_perm sem_perm;
+ time_t sem_otime;
+ time_t sem_ctime;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned short sem_nsems;
- char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
+ unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
#else
- char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
- unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
+ unsigned short sem_nsems;
#endif
- time_t __unused3;
- time_t __unused4;
+ time_t __unused3;
+ time_t __unused4;
};
diff --git a/arch/arm64/sysroot/include/bits/shm.h b/arch/arm64/sysroot/include/bits/shm.h
index 8bb1c74..a3b9dcc 100644
--- a/arch/arm64/sysroot/include/bits/shm.h
+++ b/arch/arm64/sysroot/include/bits/shm.h
@@ -1,24 +1,24 @@
#define SHMLBA 4096
struct shmid_ds {
- struct ipc_perm shm_perm;
- size_t shm_segsz;
- time_t shm_atime;
- time_t shm_dtime;
- time_t shm_ctime;
- pid_t shm_cpid;
- pid_t shm_lpid;
- unsigned long shm_nattch;
- unsigned long __pad1;
- unsigned long __pad2;
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+ time_t shm_dtime;
+ time_t shm_ctime;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+ unsigned long __pad1;
+ unsigned long __pad2;
};
struct shminfo {
- unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+ unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
};
struct shm_info {
- int __used_ids;
- unsigned long shm_tot, shm_rss, shm_swp;
- unsigned long __swap_attempts, __swap_successes;
+ int __used_ids;
+ unsigned long shm_tot, shm_rss, shm_swp;
+ unsigned long __swap_attempts, __swap_successes;
};
diff --git a/arch/arm64/sysroot/include/bits/socket.h b/arch/arm64/sysroot/include/bits/socket.h
index aad18bf..1127d5b 100644
--- a/arch/arm64/sysroot/include/bits/socket.h
+++ b/arch/arm64/sysroot/include/bits/socket.h
@@ -1,33 +1,33 @@
#include <endian.h>
struct msghdr {
- void* msg_name;
- socklen_t msg_namelen;
- struct iovec* msg_iov;
+ void* msg_name;
+ socklen_t msg_namelen;
+ struct iovec* msg_iov;
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad1, msg_iovlen;
+ int __pad1, msg_iovlen;
#else
- int msg_iovlen, __pad1;
+ int msg_iovlen, __pad1;
#endif
- void* msg_control;
+ void* msg_control;
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad2;
- socklen_t msg_controllen;
+ int __pad2;
+ socklen_t msg_controllen;
#else
- socklen_t msg_controllen;
- int __pad2;
+ socklen_t msg_controllen;
+ int __pad2;
#endif
- int msg_flags;
+ int msg_flags;
};
struct cmsghdr {
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad1;
- socklen_t cmsg_len;
+ int __pad1;
+ socklen_t cmsg_len;
#else
- socklen_t cmsg_len;
- int __pad1;
+ socklen_t cmsg_len;
+ int __pad1;
#endif
- int cmsg_level;
- int cmsg_type;
+ int cmsg_level;
+ int cmsg_type;
};
diff --git a/arch/arm64/sysroot/include/bits/statfs.h b/arch/arm64/sysroot/include/bits/statfs.h
index 656aa8d..ef2bbe3 100644
--- a/arch/arm64/sysroot/include/bits/statfs.h
+++ b/arch/arm64/sysroot/include/bits/statfs.h
@@ -1,7 +1,7 @@
struct statfs {
- unsigned long f_type, f_bsize;
- fsblkcnt_t f_blocks, f_bfree, f_bavail;
- fsfilcnt_t f_files, f_ffree;
- fsid_t f_fsid;
- unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
+ unsigned long f_type, f_bsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree;
+ fsid_t f_fsid;
+ unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
};
diff --git a/arch/arm64/sysroot/include/bits/termios.h b/arch/arm64/sysroot/include/bits/termios.h
index 1a06f76..d9a7359 100644
--- a/arch/arm64/sysroot/include/bits/termios.h
+++ b/arch/arm64/sysroot/include/bits/termios.h
@@ -1,12 +1,12 @@
struct termios {
- tcflag_t c_iflag;
- tcflag_t c_oflag;
- tcflag_t c_cflag;
- tcflag_t c_lflag;
- cc_t c_line;
- cc_t c_cc[NCCS];
- speed_t __c_ispeed;
- speed_t __c_ospeed;
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t __c_ispeed;
+ speed_t __c_ospeed;
};
#define VINTR 0
diff --git a/arch/arm64/sysroot/include/bits/x86_64/fenv.h b/arch/arm64/sysroot/include/bits/x86_64/fenv.h
index 5cea203..32e7dbf 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/fenv.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/fenv.h
@@ -15,20 +15,20 @@
typedef unsigned short fexcept_t;
typedef struct {
- unsigned short __control_word;
- unsigned short __unused1;
- unsigned short __status_word;
- unsigned short __unused2;
- unsigned short __tags;
- unsigned short __unused3;
- unsigned int __eip;
- unsigned short __cs_selector;
- unsigned int __opcode : 11;
- unsigned int __unused4 : 5;
- unsigned int __data_offset;
- unsigned short __data_selector;
- unsigned short __unused5;
- unsigned int __mxcsr;
+ unsigned short __control_word;
+ unsigned short __unused1;
+ unsigned short __status_word;
+ unsigned short __unused2;
+ unsigned short __tags;
+ unsigned short __unused3;
+ unsigned int __eip;
+ unsigned short __cs_selector;
+ unsigned int __opcode : 11;
+ unsigned int __unused4 : 5;
+ unsigned int __data_offset;
+ unsigned short __data_selector;
+ unsigned short __unused5;
+ unsigned int __mxcsr;
} fenv_t;
#define FE_DFL_ENV ((const fenv_t*)-1)
diff --git a/arch/arm64/sysroot/include/bits/x86_64/float.h b/arch/arm64/sysroot/include/bits/x86_64/float.h
deleted file mode 100644
index f935e34..0000000
--- a/arch/arm64/sysroot/include/bits/x86_64/float.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifdef __FLT_EVAL_METHOD__
-#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#else
-#define FLT_EVAL_METHOD 0
-#endif
-
-#define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
-#define LDBL_MIN 3.3621031431120935063e-4932L
-#define LDBL_MAX 1.1897314953572317650e+4932L
-#define LDBL_EPSILON 1.0842021724855044340e-19L
-
-#define LDBL_MANT_DIG 64
-#define LDBL_MIN_EXP (-16381)
-#define LDBL_MAX_EXP 16384
-
-#define LDBL_DIG 18
-#define LDBL_MIN_10_EXP (-4931)
-#define LDBL_MAX_10_EXP 4932
-
-#define DECIMAL_DIG 21
diff --git a/arch/arm64/sysroot/include/bits/x86_64/io.h b/arch/arm64/sysroot/include/bits/x86_64/io.h
index bbfb2e6..7234422 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/io.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/io.h
@@ -1,77 +1,53 @@
static __inline void outb(unsigned char __val, unsigned short __port) {
- __asm__ volatile("outb %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outb %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline void outw(unsigned short __val, unsigned short __port) {
- __asm__ volatile("outw %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outw %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline void outl(unsigned int __val, unsigned short __port) {
- __asm__ volatile("outl %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outl %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline unsigned char inb(unsigned short __port) {
- unsigned char __val;
- __asm__ volatile("inb %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned char __val;
+ __asm__ volatile("inb %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline unsigned short inw(unsigned short __port) {
- unsigned short __val;
- __asm__ volatile("inw %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned short __val;
+ __asm__ volatile("inw %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline unsigned int inl(unsigned short __port) {
- unsigned int __val;
- __asm__ volatile("inl %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned int __val;
+ __asm__ volatile("inl %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline void outsb(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsb"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void outsw(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsw"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void outsl(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsl"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insb(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insb"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insw(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insw"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insl(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insl"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
diff --git a/arch/arm64/sysroot/include/bits/x86_64/ioctl.h b/arch/arm64/sysroot/include/bits/x86_64/ioctl.h
index 66525bf..bc8d16a 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/ioctl.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/ioctl.h
@@ -88,10 +88,10 @@
#define TIOCSER_TEMT 0x01
struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
};
#define TIOCM_LE 0x001
diff --git a/arch/arm64/sysroot/include/bits/x86_64/ipc.h b/arch/arm64/sysroot/include/bits/x86_64/ipc.h
index b563143..c66f9ed 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/ipc.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/ipc.h
@@ -1,13 +1,13 @@
struct ipc_perm {
- key_t __ipc_perm_key;
- uid_t uid;
- gid_t gid;
- uid_t cuid;
- gid_t cgid;
- mode_t mode;
- int __ipc_perm_seq;
- long __pad1;
- long __pad2;
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ int __ipc_perm_seq;
+ long __pad1;
+ long __pad2;
};
#define IPC_64 0
diff --git a/arch/arm64/sysroot/include/bits/x86_64/signal.h b/arch/arm64/sysroot/include/bits/x86_64/signal.h
index 529bbc4..26095e9 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/signal.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/signal.h
@@ -35,47 +35,49 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef long long greg_t, gregset_t[23];
typedef struct _fpstate {
- unsigned short cwd, swd, ftw, fop;
- unsigned long long rip, rdp;
- unsigned mxcsr, mxcr_mask;
- struct {
- unsigned short significand[4], exponent, padding[3];
- } _st[8];
- struct {
- unsigned element[4];
- } _xmm[16];
- unsigned padding[24];
+ unsigned short cwd, swd, ftw, fop;
+ unsigned long long rip, rdp;
+ unsigned mxcsr, mxcr_mask;
+ struct {
+ unsigned short significand[4], exponent, padding[3];
+ } _st[8];
+ struct {
+ unsigned element[4];
+ } _xmm[16];
+ unsigned padding[24];
} * fpregset_t;
struct sigcontext {
- unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
- unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
- unsigned short cs, gs, fs, __pad0;
- unsigned long err, trapno, oldmask, cr2;
- struct _fpstate* fpstate;
- unsigned long __reserved1[8];
+ unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
+ unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
+ unsigned short cs, gs, fs, __pad0;
+ unsigned long err, trapno, oldmask, cr2;
+ struct _fpstate* fpstate;
+ unsigned long __reserved1[8];
};
typedef struct {
- gregset_t gregs;
- fpregset_t fpregs;
- unsigned long long __reserved1[8];
+ gregset_t gregs;
+ fpregset_t fpregs;
+ unsigned long long __reserved1[8];
} mcontext_t;
#else
-typedef struct { unsigned long __space[32]; } mcontext_t;
+typedef struct {
+ unsigned long __space[32];
+} mcontext_t;
#endif
struct sigaltstack {
- void* ss_sp;
- int ss_flags;
- size_t ss_size;
+ void* ss_sp;
+ int ss_flags;
+ size_t ss_size;
};
typedef struct __ucontext {
- unsigned long uc_flags;
- struct __ucontext* uc_link;
- stack_t uc_stack;
- mcontext_t uc_mcontext;
- sigset_t uc_sigmask;
- unsigned long __fpregs_mem[64];
+ unsigned long uc_flags;
+ struct __ucontext* uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+ unsigned long __fpregs_mem[64];
} ucontext_t;
#define SA_NOCLDSTOP 1
diff --git a/arch/arm64/sysroot/include/bits/x86_64/stat.h b/arch/arm64/sysroot/include/bits/x86_64/stat.h
index d3b3447..9533ce5 100644
--- a/arch/arm64/sysroot/include/bits/x86_64/stat.h
+++ b/arch/arm64/sysroot/include/bits/x86_64/stat.h
@@ -2,21 +2,21 @@
* by the corresponding correctly-sized userspace types. */
struct stat {
- dev_t st_dev;
- ino_t st_ino;
- nlink_t st_nlink;
+ dev_t st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
- mode_t st_mode;
- uid_t st_uid;
- gid_t st_gid;
- unsigned int __pad0;
- dev_t st_rdev;
- off_t st_size;
- blksize_t st_blksize;
- blkcnt_t st_blocks;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned int __pad0;
+ dev_t st_rdev;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- long __unused[3];
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused1[3];
};
diff --git a/arch/arm64/sysroot/include/byteswap.h b/arch/arm64/sysroot/include/byteswap.h
index 6350775..54d1c36 100644
--- a/arch/arm64/sysroot/include/byteswap.h
+++ b/arch/arm64/sysroot/include/byteswap.h
@@ -1,21 +1,21 @@
-#pragma once
+#ifndef SYSROOT_BYTESWAP_H_
+#define SYSROOT_BYTESWAP_H_
#include <features.h>
#include <stdint.h>
-static __inline uint16_t __bswap_16(uint16_t __x) {
- return __x << 8 | __x >> 8;
-}
+static __inline uint16_t __bswap_16(uint16_t __x) { return (uint16_t)(__x << 8 | __x >> 8); }
static __inline uint32_t __bswap_32(uint32_t __x) {
- return __x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) |
- __x << 24;
+ return __x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24;
}
static __inline uint64_t __bswap_64(uint64_t __x) {
- return ((uint64_t)__bswap_32(__x)) << 32 | __bswap_32(__x >> 32);
+ return ((uint64_t)__bswap_32((uint32_t)__x)) << 32 | __bswap_32((uint32_t)(__x >> 32));
}
#define bswap_16(x) __bswap_16(x)
#define bswap_32(x) __bswap_32(x)
#define bswap_64(x) __bswap_64(x)
+
+#endif // SYSROOT_BYTESWAP_H_
diff --git a/arch/arm64/sysroot/include/complex.h b/arch/arm64/sysroot/include/complex.h
index 9761553..c4bb294 100644
--- a/arch/arm64/sysroot/include/complex.h
+++ b/arch/arm64/sysroot/include/complex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_COMPLEX_H_
+#define SYSROOT_COMPLEX_H_
#ifdef __cplusplus
extern "C" {
@@ -101,12 +102,12 @@
long double creall(long double complex);
#ifndef __cplusplus
-#define __CIMAG(x, t) \
- (+(union { \
- _Complex t __z; \
- t __xy[2]; \
- }){(_Complex t)(x)} \
- .__xy[1])
+#define __CIMAG(x, t) \
+ (+(union { \
+ _Complex t __z; \
+ t __xy[2]; \
+ }){(_Complex t)(x)} \
+ .__xy[1])
#define creal(x) ((double)(x))
#define crealf(x) ((float)(x))
@@ -133,3 +134,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_COMPLEX_H_
diff --git a/arch/arm64/sysroot/include/cpio.h b/arch/arm64/sysroot/include/cpio.h
index f921413..21d069e 100644
--- a/arch/arm64/sysroot/include/cpio.h
+++ b/arch/arm64/sysroot/include/cpio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_CPIO_H_
+#define SYSROOT_CPIO_H_
#define MAGIC "070707"
@@ -24,3 +25,5 @@
#define C_ISLNK 0120000
#define C_ISCTG 0110000
#define C_ISREG 0100000
+
+#endif // SYSROOT_CPIO_H_
diff --git a/arch/arm64/sysroot/include/crypt.h b/arch/arm64/sysroot/include/crypt.h
deleted file mode 100644
index 029698c..0000000
--- a/arch/arm64/sysroot/include/crypt.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct crypt_data {
- int initialized;
- char __buf[256];
-};
-
-char* crypt(const char*, const char*);
-char* crypt_r(const char*, const char*, struct crypt_data*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/arm64/sysroot/include/ctype.h b/arch/arm64/sysroot/include/ctype.h
index f4cd85b..12be80d 100644
--- a/arch/arm64/sysroot/include/ctype.h
+++ b/arch/arm64/sysroot/include/ctype.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_CTYPE_H_
+#define SYSROOT_CTYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -22,9 +23,7 @@
int toupper(int);
#ifndef __cplusplus
-static __inline int __isspace(int _c) {
- return _c == ' ' || (unsigned)_c - '\t' < 5;
-}
+static __inline int __isspace(int _c) { return _c == ' ' || (unsigned)_c - '\t' < 5; }
#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a) | 32) - 'a') < 26)
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a) - '0') < 10)
@@ -49,3 +48,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_CTYPE_H_
diff --git a/arch/arm64/sysroot/include/dirent.h b/arch/arm64/sysroot/include/dirent.h
index 0c463c4..4542825 100644
--- a/arch/arm64/sysroot/include/dirent.h
+++ b/arch/arm64/sysroot/include/dirent.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_DIRENT_H_
+#define SYSROOT_DIRENT_H_
#ifdef __cplusplus
extern "C" {
@@ -17,11 +18,11 @@
typedef struct __dirstream DIR;
struct dirent {
- ino_t d_ino;
- off_t d_off;
- unsigned short d_reclen;
- unsigned char d_type;
- char d_name[256];
+ ino_t d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
};
#define d_fileno d_ino
@@ -62,3 +63,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_DIRENT_H_
diff --git a/arch/arm64/sysroot/include/dlfcn.h b/arch/arm64/sysroot/include/dlfcn.h
index 04cc834..ff069c9 100644
--- a/arch/arm64/sysroot/include/dlfcn.h
+++ b/arch/arm64/sysroot/include/dlfcn.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_DLFCN_H_
+#define SYSROOT_DLFCN_H_
#ifdef __cplusplus
extern "C" {
@@ -25,10 +26,10 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef struct {
- const char* dli_fname;
- void* dli_fbase;
- const char* dli_sname;
- void* dli_saddr;
+ const char* dli_fname;
+ void* dli_fbase;
+ const char* dli_sname;
+ void* dli_saddr;
} Dl_info;
int dladdr(const void*, Dl_info*);
int dlinfo(void*, int, void*);
@@ -37,3 +38,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_DLFCN_H_
diff --git a/arch/arm64/sysroot/include/elf.h b/arch/arm64/sysroot/include/elf.h
index a5efbda..88a35f0 100644
--- a/arch/arm64/sysroot/include/elf.h
+++ b/arch/arm64/sysroot/include/elf.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ELF_H_
+#define SYSROOT_ELF_H_
#ifdef __cplusplus
extern "C" {
@@ -34,37 +35,37 @@
#define EI_NIDENT (16)
typedef struct {
- unsigned char e_ident[EI_NIDENT];
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry;
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
- Elf32_Half e_shstrndx;
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
} Elf32_Ehdr;
typedef struct {
- unsigned char e_ident[EI_NIDENT];
- Elf64_Half e_type;
- Elf64_Half e_machine;
- Elf64_Word e_version;
- Elf64_Addr e_entry;
- Elf64_Off e_phoff;
- Elf64_Off e_shoff;
- Elf64_Word e_flags;
- Elf64_Half e_ehsize;
- Elf64_Half e_phentsize;
- Elf64_Half e_phnum;
- Elf64_Half e_shentsize;
- Elf64_Half e_shnum;
- Elf64_Half e_shstrndx;
+ unsigned char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
} Elf64_Ehdr;
#define EI_MAG0 0
@@ -217,29 +218,29 @@
#define EV_NUM 2
typedef struct {
- Elf32_Word sh_name;
- Elf32_Word sh_type;
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
} Elf32_Shdr;
typedef struct {
- Elf64_Word sh_name;
- Elf64_Word sh_type;
- Elf64_Xword sh_flags;
- Elf64_Addr sh_addr;
- Elf64_Off sh_offset;
- Elf64_Xword sh_size;
- Elf64_Word sh_link;
- Elf64_Word sh_info;
- Elf64_Xword sh_addralign;
- Elf64_Xword sh_entsize;
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
} Elf64_Shdr;
#define SHN_UNDEF 0
@@ -313,31 +314,31 @@
#define GRP_COMDAT 0x1
typedef struct {
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Section st_shndx;
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Section st_shndx;
} Elf32_Sym;
typedef struct {
- Elf64_Word st_name;
- unsigned char st_info;
- unsigned char st_other;
- Elf64_Section st_shndx;
- Elf64_Addr st_value;
- Elf64_Xword st_size;
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Section st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
} Elf64_Sym;
typedef struct {
- Elf32_Half si_boundto;
- Elf32_Half si_flags;
+ Elf32_Half si_boundto;
+ Elf32_Half si_flags;
} Elf32_Syminfo;
typedef struct {
- Elf64_Half si_boundto;
- Elf64_Half si_flags;
+ Elf64_Half si_boundto;
+ Elf64_Half si_flags;
} Elf64_Syminfo;
#define SYMINFO_BT_SELF 0xffff
@@ -396,25 +397,25 @@
#define STV_PROTECTED 3
typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
} Elf32_Rel;
typedef struct {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
} Elf64_Rel;
typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
} Elf32_Rela;
typedef struct {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
- Elf64_Sxword r_addend;
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+ Elf64_Sxword r_addend;
} Elf64_Rela;
#define ELF32_R_SYM(val) ((val) >> 8)
@@ -426,25 +427,25 @@
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type))
typedef struct {
- Elf32_Word p_type;
- Elf32_Off p_offset;
- Elf32_Addr p_vaddr;
- Elf32_Addr p_paddr;
- Elf32_Word p_filesz;
- Elf32_Word p_memsz;
- Elf32_Word p_flags;
- Elf32_Word p_align;
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
} Elf32_Phdr;
typedef struct {
- Elf64_Word p_type;
- Elf64_Word p_flags;
- Elf64_Off p_offset;
- Elf64_Addr p_vaddr;
- Elf64_Addr p_paddr;
- Elf64_Xword p_filesz;
- Elf64_Xword p_memsz;
- Elf64_Xword p_align;
+ Elf64_Word p_type;
+ Elf64_Word p_flags;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Addr p_paddr;
+ Elf64_Xword p_filesz;
+ Elf64_Xword p_memsz;
+ Elf64_Xword p_align;
} Elf64_Phdr;
#define PT_NULL 0
@@ -520,19 +521,19 @@
#define NT_VERSION 1
typedef struct {
- Elf32_Sword d_tag;
- union {
- Elf32_Word d_val;
- Elf32_Addr d_ptr;
- } d_un;
+ Elf32_Sword d_tag;
+ union {
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
} Elf32_Dyn;
typedef struct {
- Elf64_Sxword d_tag;
- union {
- Elf64_Xword d_val;
- Elf64_Addr d_ptr;
- } d_un;
+ Elf64_Sxword d_tag;
+ union {
+ Elf64_Xword d_val;
+ Elf64_Addr d_ptr;
+ } d_un;
} Elf64_Dyn;
#define DT_NULL 0
@@ -672,23 +673,23 @@
#define DF_P1_GROUPPERM 0x00000002
typedef struct {
- Elf32_Half vd_version;
- Elf32_Half vd_flags;
- Elf32_Half vd_ndx;
- Elf32_Half vd_cnt;
- Elf32_Word vd_hash;
- Elf32_Word vd_aux;
- Elf32_Word vd_next;
+ Elf32_Half vd_version;
+ Elf32_Half vd_flags;
+ Elf32_Half vd_ndx;
+ Elf32_Half vd_cnt;
+ Elf32_Word vd_hash;
+ Elf32_Word vd_aux;
+ Elf32_Word vd_next;
} Elf32_Verdef;
typedef struct {
- Elf64_Half vd_version;
- Elf64_Half vd_flags;
- Elf64_Half vd_ndx;
- Elf64_Half vd_cnt;
- Elf64_Word vd_hash;
- Elf64_Word vd_aux;
- Elf64_Word vd_next;
+ Elf64_Half vd_version;
+ Elf64_Half vd_flags;
+ Elf64_Half vd_ndx;
+ Elf64_Half vd_cnt;
+ Elf64_Word vd_hash;
+ Elf64_Word vd_aux;
+ Elf64_Word vd_next;
} Elf64_Verdef;
#define VER_DEF_NONE 0
@@ -704,29 +705,29 @@
#define VER_NDX_ELIMINATE 0xff01
typedef struct {
- Elf32_Word vda_name;
- Elf32_Word vda_next;
+ Elf32_Word vda_name;
+ Elf32_Word vda_next;
} Elf32_Verdaux;
typedef struct {
- Elf64_Word vda_name;
- Elf64_Word vda_next;
+ Elf64_Word vda_name;
+ Elf64_Word vda_next;
} Elf64_Verdaux;
typedef struct {
- Elf32_Half vn_version;
- Elf32_Half vn_cnt;
- Elf32_Word vn_file;
- Elf32_Word vn_aux;
- Elf32_Word vn_next;
+ Elf32_Half vn_version;
+ Elf32_Half vn_cnt;
+ Elf32_Word vn_file;
+ Elf32_Word vn_aux;
+ Elf32_Word vn_next;
} Elf32_Verneed;
typedef struct {
- Elf64_Half vn_version;
- Elf64_Half vn_cnt;
- Elf64_Word vn_file;
- Elf64_Word vn_aux;
- Elf64_Word vn_next;
+ Elf64_Half vn_version;
+ Elf64_Half vn_cnt;
+ Elf64_Word vn_file;
+ Elf64_Word vn_aux;
+ Elf64_Word vn_next;
} Elf64_Verneed;
#define VER_NEED_NONE 0
@@ -734,35 +735,35 @@
#define VER_NEED_NUM 2
typedef struct {
- Elf32_Word vna_hash;
- Elf32_Half vna_flags;
- Elf32_Half vna_other;
- Elf32_Word vna_name;
- Elf32_Word vna_next;
+ Elf32_Word vna_hash;
+ Elf32_Half vna_flags;
+ Elf32_Half vna_other;
+ Elf32_Word vna_name;
+ Elf32_Word vna_next;
} Elf32_Vernaux;
typedef struct {
- Elf64_Word vna_hash;
- Elf64_Half vna_flags;
- Elf64_Half vna_other;
- Elf64_Word vna_name;
- Elf64_Word vna_next;
+ Elf64_Word vna_hash;
+ Elf64_Half vna_flags;
+ Elf64_Half vna_other;
+ Elf64_Word vna_name;
+ Elf64_Word vna_next;
} Elf64_Vernaux;
#define VER_FLG_WEAK 0x2
typedef struct {
- uint32_t a_type;
- union {
- uint32_t a_val;
- } a_un;
+ uint32_t a_type;
+ union {
+ uint32_t a_val;
+ } a_un;
} Elf32_auxv_t;
typedef struct {
- uint64_t a_type;
- union {
- uint64_t a_val;
- } a_un;
+ uint64_t a_type;
+ union {
+ uint64_t a_val;
+ } a_un;
} Elf64_auxv_t;
#define AT_NULL 0
@@ -812,15 +813,15 @@
#define AT_L3_CACHESHAPE 37
typedef struct {
- Elf32_Word n_namesz;
- Elf32_Word n_descsz;
- Elf32_Word n_type;
+ Elf32_Word n_namesz;
+ Elf32_Word n_descsz;
+ Elf32_Word n_type;
} Elf32_Nhdr;
typedef struct {
- Elf64_Word n_namesz;
- Elf64_Word n_descsz;
- Elf64_Word n_type;
+ Elf64_Word n_namesz;
+ Elf64_Word n_descsz;
+ Elf64_Word n_type;
} Elf64_Nhdr;
#define ELF_NOTE_SOLARIS "SUNW Solaris"
@@ -841,19 +842,19 @@
#define NT_GNU_GOLD_VERSION 4
typedef struct {
- Elf32_Xword m_value;
- Elf32_Word m_info;
- Elf32_Word m_poffset;
- Elf32_Half m_repeat;
- Elf32_Half m_stride;
+ Elf32_Xword m_value;
+ Elf32_Word m_info;
+ Elf32_Word m_poffset;
+ Elf32_Half m_repeat;
+ Elf32_Half m_stride;
} Elf32_Move;
typedef struct {
- Elf64_Xword m_value;
- Elf64_Xword m_info;
- Elf64_Xword m_poffset;
- Elf64_Half m_repeat;
- Elf64_Half m_stride;
+ Elf64_Xword m_value;
+ Elf64_Xword m_info;
+ Elf64_Xword m_poffset;
+ Elf64_Half m_repeat;
+ Elf64_Half m_stride;
} Elf64_Move;
#define ELF32_M_SYM(info) ((info) >> 8)
@@ -1138,29 +1139,29 @@
#define STB_MIPS_SPLIT_COMMON 13
typedef union {
- struct {
- Elf32_Word gt_current_g_value;
- Elf32_Word gt_unused;
- } gt_header;
- struct {
- Elf32_Word gt_g_value;
- Elf32_Word gt_bytes;
- } gt_entry;
+ struct {
+ Elf32_Word gt_current_g_value;
+ Elf32_Word gt_unused;
+ } gt_header;
+ struct {
+ Elf32_Word gt_g_value;
+ Elf32_Word gt_bytes;
+ } gt_entry;
} Elf32_gptab;
typedef struct {
- Elf32_Word ri_gprmask;
- Elf32_Word ri_cprmask[4];
- Elf32_Sword ri_gp_value;
+ Elf32_Word ri_gprmask;
+ Elf32_Word ri_cprmask[4];
+ Elf32_Sword ri_gp_value;
} Elf32_RegInfo;
typedef struct {
- unsigned char kind;
+ unsigned char kind;
- unsigned char size;
- Elf32_Section section;
+ unsigned char size;
+ Elf32_Section section;
- Elf32_Word info;
+ Elf32_Word info;
} Elf_Options;
#define ODK_NULL 0
@@ -1197,8 +1198,8 @@
#define OPAD_SYMBOL 0x4
typedef struct {
- Elf32_Word hwp_flags1;
- Elf32_Word hwp_flags2;
+ Elf32_Word hwp_flags1;
+ Elf32_Word hwp_flags2;
} Elf_Options_Hw;
#define OHWA0_R4KEOP_CHECKED 0x00000001
@@ -1341,19 +1342,19 @@
#define RHF_RLD_ORDER_SAFE (1 << 14)
typedef struct {
- Elf32_Word l_name;
- Elf32_Word l_time_stamp;
- Elf32_Word l_checksum;
- Elf32_Word l_version;
- Elf32_Word l_flags;
+ Elf32_Word l_name;
+ Elf32_Word l_time_stamp;
+ Elf32_Word l_checksum;
+ Elf32_Word l_version;
+ Elf32_Word l_flags;
} Elf32_Lib;
typedef struct {
- Elf64_Word l_name;
- Elf64_Word l_time_stamp;
- Elf64_Word l_checksum;
- Elf64_Word l_version;
- Elf64_Word l_flags;
+ Elf64_Word l_name;
+ Elf64_Word l_time_stamp;
+ Elf64_Word l_checksum;
+ Elf64_Word l_version;
+ Elf64_Word l_flags;
} Elf64_Lib;
#define LL_NONE 0
@@ -2580,3 +2581,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ELF_H_
diff --git a/arch/arm64/sysroot/include/endian.h b/arch/arm64/sysroot/include/endian.h
index 499f985..5ca6625 100644
--- a/arch/arm64/sysroot/include/endian.h
+++ b/arch/arm64/sysroot/include/endian.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ENDIAN_H_
+#define SYSROOT_ENDIAN_H_
#include <features.h>
@@ -21,16 +22,14 @@
#include <stdint.h>
-static __inline uint16_t __bswap16(uint16_t __x) {
- return (uint16_t)(__x << 8 | __x >> 8);
-}
+static __inline uint16_t __bswap16(uint16_t __x) { return (uint16_t)(__x << 8 | __x >> 8); }
static __inline uint32_t __bswap32(uint32_t __x) {
- return (uint32_t)(__x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24);
+ return (uint32_t)(__x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24);
}
static __inline uint64_t __bswap64(uint64_t __x) {
- return ((uint64_t)__bswap32((uint32_t)__x)) << 32 | (uint64_t)__bswap32((uint32_t)(__x >> 32));
+ return ((uint64_t)__bswap32((uint32_t)__x)) << 32 | (uint64_t)__bswap32((uint32_t)(__x >> 32));
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -74,3 +73,5 @@
#endif
#endif
+
+#endif // SYSROOT_ENDIAN_H_
diff --git a/arch/arm64/sysroot/include/err.h b/arch/arm64/sysroot/include/err.h
index 3ed5f7f..29842fe 100644
--- a/arch/arm64/sysroot/include/err.h
+++ b/arch/arm64/sysroot/include/err.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ERR_H_
+#define SYSROOT_ERR_H_
#include <features.h>
#include <stdarg.h>
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ERR_H_
diff --git a/arch/arm64/sysroot/include/errno.h b/arch/arm64/sysroot/include/errno.h
index 4d3b968..af13f58 100644
--- a/arch/arm64/sysroot/include/errno.h
+++ b/arch/arm64/sysroot/include/errno.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ERRNO_H_
+#define SYSROOT_ERRNO_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ERRNO_H_
diff --git a/arch/arm64/sysroot/include/fcntl.h b/arch/arm64/sysroot/include/fcntl.h
index f045529..e5e47bd 100644
--- a/arch/arm64/sysroot/include/fcntl.h
+++ b/arch/arm64/sysroot/include/fcntl.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FCNTL_H_
+#define SYSROOT_FCNTL_H_
#ifdef __cplusplus
extern "C" {
@@ -19,11 +20,11 @@
#include <bits/alltypes.h>
struct flock {
- short l_type;
- short l_whence;
- off_t l_start;
- off_t l_len;
- pid_t l_pid;
+ short l_type;
+ short l_whence;
+ off_t l_start;
+ off_t l_len;
+ pid_t l_pid;
};
int creat(const char*, mode_t);
@@ -54,7 +55,6 @@
#ifdef _ALL_SOURCE
#define O_NOREMOTE 0x00200000
#define O_ADMIN 0x00000004
-#define O_PIPELINE 0x80000000
#endif
// Flags which do not align with ZXIO_FS_*
@@ -195,8 +195,8 @@
#define F_OWNER_PGRP 2
#define F_OWNER_GID 2
struct f_owner_ex {
- int type;
- pid_t pid;
+ int type;
+ pid_t pid;
};
#define FALLOC_FL_KEEP_SIZE 1
#define FALLOC_FL_PUNCH_HOLE 2
@@ -220,3 +220,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FCNTL_H_
diff --git a/arch/arm64/sysroot/include/features.h b/arch/arm64/sysroot/include/features.h
index 7bd75ad..1520efb 100644
--- a/arch/arm64/sysroot/include/features.h
+++ b/arch/arm64/sysroot/include/features.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FEATURES_H_
+#define SYSROOT_FEATURES_H_
#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
@@ -30,3 +31,5 @@
#else
#define _Noreturn
#endif
+
+#endif // SYSROOT_FEATURES_H_
diff --git a/arch/arm64/sysroot/include/fenv.h b/arch/arm64/sysroot/include/fenv.h
index 42508ac..391f59f 100644
--- a/arch/arm64/sysroot/include/fenv.h
+++ b/arch/arm64/sysroot/include/fenv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FENV_H_
+#define SYSROOT_FENV_H_
#ifdef __cplusplus
extern "C" {
@@ -23,3 +24,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FENV_H_
diff --git a/arch/arm64/sysroot/include/float.h b/arch/arm64/sysroot/include/float.h
deleted file mode 100644
index 691c4fc..0000000
--- a/arch/arm64/sysroot/include/float.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int __flt_rounds(void);
-#define FLT_ROUNDS (__flt_rounds())
-
-#define FLT_RADIX 2
-
-#define FLT_TRUE_MIN 1.40129846432481707092e-45F
-#define FLT_MIN 1.17549435082228750797e-38F
-#define FLT_MAX 3.40282346638528859812e+38F
-#define FLT_EPSILON 1.1920928955078125e-07F
-
-#define FLT_MANT_DIG 24
-#define FLT_MIN_EXP (-125)
-#define FLT_MAX_EXP 128
-#define FLT_HAS_SUBNORM 1
-
-#define FLT_DIG 6
-#define FLT_DECIMAL_DIG 9
-#define FLT_MIN_10_EXP (-37)
-#define FLT_MAX_10_EXP 38
-
-#define DBL_TRUE_MIN 4.94065645841246544177e-324
-#define DBL_MIN 2.22507385850720138309e-308
-#define DBL_MAX 1.79769313486231570815e+308
-#define DBL_EPSILON 2.22044604925031308085e-16
-
-#define DBL_MANT_DIG 53
-#define DBL_MIN_EXP (-1021)
-#define DBL_MAX_EXP 1024
-#define DBL_HAS_SUBNORM 1
-
-#define DBL_DIG 15
-#define DBL_DECIMAL_DIG 17
-#define DBL_MIN_10_EXP (-307)
-#define DBL_MAX_10_EXP 308
-
-#define LDBL_HAS_SUBNORM 1
-#define LDBL_DECIMAL_DIG DECIMAL_DIG
-
-#include <bits/float.h>
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/arm64/sysroot/include/fmtmsg.h b/arch/arm64/sysroot/include/fmtmsg.h
index e6b0923..51abcc5 100644
--- a/arch/arm64/sysroot/include/fmtmsg.h
+++ b/arch/arm64/sysroot/include/fmtmsg.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FMTMSG_H_
+#define SYSROOT_FMTMSG_H_
#ifdef __cplusplus
extern "C" {
@@ -42,3 +43,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FMTMSG_H_
diff --git a/arch/arm64/sysroot/include/fnmatch.h b/arch/arm64/sysroot/include/fnmatch.h
index ea277a4..2e0f6cc 100644
--- a/arch/arm64/sysroot/include/fnmatch.h
+++ b/arch/arm64/sysroot/include/fnmatch.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FNMATCH_H_
+#define SYSROOT_FNMATCH_H_
#ifdef __cplusplus
extern "C" {
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FNMATCH_H_
diff --git a/arch/arm64/sysroot/include/ftw.h b/arch/arm64/sysroot/include/ftw.h
deleted file mode 100644
index 1c282aa..0000000
--- a/arch/arm64/sysroot/include/ftw.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <features.h>
-#include <sys/stat.h>
-
-#define FTW_F 1
-#define FTW_D 2
-#define FTW_DNR 3
-#define FTW_NS 4
-#define FTW_SL 5
-#define FTW_DP 6
-#define FTW_SLN 7
-
-#define FTW_PHYS 1
-#define FTW_MOUNT 2
-#define FTW_CHDIR 4
-#define FTW_DEPTH 8
-
-struct FTW {
- int base;
- int level;
-};
-
-int ftw(const char*, int (*)(const char*, const struct stat*, int), int);
-int nftw(const char*, int (*)(const char*, const struct stat*, int, struct FTW*), int, int);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/arm64/sysroot/include/getopt.h b/arch/arm64/sysroot/include/getopt.h
index 8019e90..bcc632d 100644
--- a/arch/arm64/sysroot/include/getopt.h
+++ b/arch/arm64/sysroot/include/getopt.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GETOPT_H_
+#define SYSROOT_GETOPT_H_
#ifdef __cplusplus
extern "C" {
@@ -9,10 +10,10 @@
extern int optind, opterr, optopt, optreset;
struct option {
- const char* name;
- int has_arg;
- int* flag;
- int val;
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
};
int getopt_long(int, char* const*, const char*, const struct option*, int*);
@@ -25,3 +26,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GETOPT_H_
diff --git a/arch/arm64/sysroot/include/glob.h b/arch/arm64/sysroot/include/glob.h
index 580ffe1..98ff3f6 100644
--- a/arch/arm64/sysroot/include/glob.h
+++ b/arch/arm64/sysroot/include/glob.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GLOB_H_
+#define SYSROOT_GLOB_H_
#ifdef __cplusplus
extern "C" {
@@ -11,11 +12,11 @@
#include <bits/alltypes.h>
typedef struct {
- size_t gl_pathc;
- char** gl_pathv;
- size_t gl_offs;
- int __dummy1;
- void* __dummy2[5];
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ int __dummy1;
+ void* __dummy2[5];
} glob_t;
int glob(const char* __restrict, int, int (*)(const char*, int), glob_t* __restrict);
@@ -38,3 +39,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GLOB_H_
diff --git a/arch/arm64/sysroot/include/grp.h b/arch/arm64/sysroot/include/grp.h
index 5e0dd0a..4cfdd08 100644
--- a/arch/arm64/sysroot/include/grp.h
+++ b/arch/arm64/sysroot/include/grp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GRP_H_
+#define SYSROOT_GRP_H_
#ifdef __cplusplus
extern "C" {
@@ -16,10 +17,10 @@
#include <bits/alltypes.h>
struct group {
- char* gr_name;
- char* gr_passwd;
- gid_t gr_gid;
- char** gr_mem;
+ char* gr_name;
+ char* gr_passwd;
+ gid_t gr_gid;
+ char** gr_mem;
};
struct group* getgrgid(gid_t);
@@ -46,3 +47,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GRP_H_
diff --git a/arch/arm64/sysroot/include/iconv.h b/arch/arm64/sysroot/include/iconv.h
index 4fee288..c0c056b 100644
--- a/arch/arm64/sysroot/include/iconv.h
+++ b/arch/arm64/sysroot/include/iconv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ICONV_H_
+#define SYSROOT_ICONV_H_
#ifdef __cplusplus
extern "C" {
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ICONV_H_
diff --git a/arch/arm64/sysroot/include/ifaddrs.h b/arch/arm64/sysroot/include/ifaddrs.h
index 912a2b6..908945e 100644
--- a/arch/arm64/sysroot/include/ifaddrs.h
+++ b/arch/arm64/sysroot/include/ifaddrs.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_IFADDRS_H_
+#define SYSROOT_IFADDRS_H_
#ifdef __cplusplus
extern "C" {
@@ -9,16 +10,16 @@
#include <sys/socket.h>
struct ifaddrs {
- struct ifaddrs* ifa_next;
- char* ifa_name;
- unsigned ifa_flags;
- struct sockaddr* ifa_addr;
- struct sockaddr* ifa_netmask;
- union {
- struct sockaddr* ifu_broadaddr;
- struct sockaddr* ifu_dstaddr;
- } ifa_ifu;
- void* ifa_data;
+ struct ifaddrs* ifa_next;
+ char* ifa_name;
+ unsigned ifa_flags;
+ struct sockaddr* ifa_addr;
+ struct sockaddr* ifa_netmask;
+ union {
+ struct sockaddr* ifu_broadaddr;
+ struct sockaddr* ifu_dstaddr;
+ } ifa_ifu;
+ void* ifa_data;
};
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_IFADDRS_H_
diff --git a/arch/arm64/sysroot/include/inttypes.h b/arch/arm64/sysroot/include/inttypes.h
index db1b4d3..43bf604 100644
--- a/arch/arm64/sysroot/include/inttypes.h
+++ b/arch/arm64/sysroot/include/inttypes.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_INTTYPES_H_
+#define SYSROOT_INTTYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -9,7 +10,9 @@
#define __NEED_wchar_t
#include <bits/alltypes.h>
-typedef struct { intmax_t quot, rem; } imaxdiv_t;
+typedef struct {
+ intmax_t quot, rem;
+} imaxdiv_t;
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
@@ -138,7 +141,6 @@
#endif
-
#define PRId8 __INT8_FMTd__
#define PRId16 __INT16_FMTd__
#define PRId32 __INT32_FMTd__
@@ -350,3 +352,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_INTTYPES_H_
diff --git a/arch/arm64/sysroot/include/iso646.h b/arch/arm64/sysroot/include/iso646.h
index 59e7e16..8b7dda8 100644
--- a/arch/arm64/sysroot/include/iso646.h
+++ b/arch/arm64/sysroot/include/iso646.h
@@ -1,13 +1,14 @@
-#pragma once
+#ifndef SYSROOT_ISO646_H_
+#define SYSROOT_ISO646_H_
#ifndef __cplusplus
-#define and&&
+#define and &&
#define and_eq &=
-#define bitand&
+#define bitand &
#define bitor |
-#define compl~
-#define not!
+#define compl ~
+#define not !
#define not_eq !=
#define or ||
#define or_eq |=
@@ -15,3 +16,5 @@
#define xor_eq ^=
#endif
+
+#endif // SYSROOT_ISO646_H_
diff --git a/arch/arm64/sysroot/include/langinfo.h b/arch/arm64/sysroot/include/langinfo.h
index 0ee81bb..a14fcfd 100644
--- a/arch/arm64/sysroot/include/langinfo.h
+++ b/arch/arm64/sysroot/include/langinfo.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LANGINFO_H_
+#define SYSROOT_LANGINFO_H_
#ifdef __cplusplus
extern "C" {
@@ -87,3 +88,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LANGINFO_H_
diff --git a/arch/arm64/sysroot/include/libgen.h b/arch/arm64/sysroot/include/libgen.h
index 546dce0..f7f79b6 100644
--- a/arch/arm64/sysroot/include/libgen.h
+++ b/arch/arm64/sysroot/include/libgen.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LIBGEN_H_
+#define SYSROOT_LIBGEN_H_
#ifdef __cplusplus
extern "C" {
@@ -10,3 +11,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LIBGEN_H_
diff --git a/arch/arm64/sysroot/include/limits.h b/arch/arm64/sysroot/include/limits.h
index 290ef73..cf60386 100644
--- a/arch/arm64/sysroot/include/limits.h
+++ b/arch/arm64/sysroot/include/limits.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LIMITS_H_
+#define SYSROOT_LIMITS_H_
#include <features.h>
@@ -48,7 +49,6 @@
#define PATH_MAX 4096
#define NZERO 20
#define NGROUPS_MAX 32
-#define ARG_MAX 131072
#define IOV_MAX 1024
#define SYMLOOP_MAX 40
#define WORD_BIT 32
@@ -149,3 +149,5 @@
#define _XOPEN_IOV_MAX 16
#define _XOPEN_NAME_MAX 255
#define _XOPEN_PATH_MAX 1024
+
+#endif // SYSROOT_LIMITS_H_
diff --git a/arch/arm64/sysroot/include/link.h b/arch/arm64/sysroot/include/link.h
index 657e9a0..78ebd48 100644
--- a/arch/arm64/sysroot/include/link.h
+++ b/arch/arm64/sysroot/include/link.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LINK_H_
+#define SYSROOT_LINK_H_
#ifdef __cplusplus
extern "C" {
@@ -15,31 +16,40 @@
typedef uint32_t Elf_Symndx;
struct dl_phdr_info {
- ElfW(Addr) dlpi_addr;
- const char* dlpi_name;
- const ElfW(Phdr) * dlpi_phdr;
- ElfW(Half) dlpi_phnum;
- unsigned long long int dlpi_adds;
- unsigned long long int dlpi_subs;
- size_t dlpi_tls_modid;
- void* dlpi_tls_data;
+ ElfW(Addr) dlpi_addr;
+ const char* dlpi_name;
+ const ElfW(Phdr) * dlpi_phdr;
+ ElfW(Half) dlpi_phnum;
+ unsigned long long int dlpi_adds;
+ unsigned long long int dlpi_subs;
+ size_t dlpi_tls_modid;
+ void* dlpi_tls_data;
};
struct link_map {
- ElfW(Addr) l_addr;
- char* l_name;
- ElfW(Dyn) * l_ld;
- struct link_map *l_next, *l_prev;
+ ElfW(Addr) l_addr;
+ char* l_name;
+ ElfW(Dyn) * l_ld;
+ struct link_map *l_next, *l_prev;
};
struct r_debug {
- int r_version;
- struct link_map* r_map;
- ElfW(Addr) r_brk;
- enum { RT_CONSISTENT,
- RT_ADD,
- RT_DELETE } r_state;
- ElfW(Addr) r_ldbase;
+ int r_version;
+ struct link_map* r_map;
+ ElfW(Addr) r_brk;
+
+ /* This is the address of a function internal to the run-time linker
+ that triggers a debug trap. This function will always be called
+ when the linker begins to map in a library or unmap it, and again
+ when the mapping change is complete.
+
+ The debugger can compare the address of a sw exception to this value
+ to determine whether the debug trap was triggered by the run-time
+ linker. */
+ ElfW(Addr) r_brk_on_load;
+
+ enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
+ ElfW(Addr) r_ldbase;
};
int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
@@ -47,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LINK_H_
diff --git a/arch/arm64/sysroot/include/locale.h b/arch/arm64/sysroot/include/locale.h
index 44f8d0b..ce78a02 100644
--- a/arch/arm64/sysroot/include/locale.h
+++ b/arch/arm64/sysroot/include/locale.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_LOCALE_H_
+#define SYSROOT_LOCALE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define LC_CTYPE 0
@@ -16,31 +18,31 @@
#define LC_ALL 6
struct lconv {
- char* decimal_point;
- char* thousands_sep;
- char* grouping;
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
- char* int_curr_symbol;
- char* currency_symbol;
- char* mon_decimal_point;
- char* mon_thousands_sep;
- char* mon_grouping;
- char* positive_sign;
- char* negative_sign;
- char int_frac_digits;
- char frac_digits;
- char p_cs_precedes;
- char p_sep_by_space;
- char n_cs_precedes;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_p_cs_precedes;
- char int_p_sep_by_space;
- char int_n_cs_precedes;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_p_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_cs_precedes;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
};
char* setlocale(int, const char*);
@@ -73,3 +75,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LOCALE_H_
diff --git a/arch/arm64/sysroot/include/malloc.h b/arch/arm64/sysroot/include/malloc.h
index d057b89..6abb854 100644
--- a/arch/arm64/sysroot/include/malloc.h
+++ b/arch/arm64/sysroot/include/malloc.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MALLOC_H_
+#define SYSROOT_MALLOC_H_
#ifdef __cplusplus
extern "C" {
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MALLOC_H_
diff --git a/arch/arm64/sysroot/include/math.h b/arch/arm64/sysroot/include/math.h
index a32ec07..089c266 100644
--- a/arch/arm64/sysroot/include/math.h
+++ b/arch/arm64/sysroot/include/math.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MATH_H_
+#define SYSROOT_MATH_H_
#ifdef __cplusplus
extern "C" {
@@ -40,67 +41,63 @@
int __fpclassifyl(long double);
static __inline unsigned __FLOAT_BITS(float __f) {
- union {
- float __f;
- unsigned __i;
- } __u;
- __u.__f = __f;
- return __u.__i;
+ union {
+ float __f;
+ unsigned __i;
+ } __u;
+ __u.__f = __f;
+ return __u.__i;
}
static __inline unsigned long long __DOUBLE_BITS(double __f) {
- union {
- double __f;
- unsigned long long __i;
- } __u;
- __u.__f = __f;
- return __u.__i;
+ union {
+ double __f;
+ unsigned long long __i;
+ } __u;
+ __u.__f = __f;
+ return __u.__i;
}
-#define fpclassify(x) \
- (sizeof(x) == sizeof(float) ? __fpclassifyf(x) : sizeof(x) == sizeof(double) \
- ? __fpclassify(x) \
- : __fpclassifyl(x))
+#define fpclassify(x) \
+ (sizeof(x) == sizeof(float) ? __fpclassifyf(x) \
+ : sizeof(x) == sizeof(double) ? __fpclassify(x) : __fpclassifyl(x))
-#define isinf(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) == 0x7ffULL << 52 \
- : __fpclassifyl(x) == FP_INFINITE)
+#define isinf(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) == 0x7ffULL << 52 \
+ : __fpclassifyl(x) == FP_INFINITE)
-#define isnan(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) > 0x7ffULL << 52 \
- : __fpclassifyl(x) == FP_NAN)
+#define isnan(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) > 0x7ffULL << 52 \
+ : __fpclassifyl(x) == FP_NAN)
-#define isnormal(x) \
- (sizeof(x) == sizeof(float) \
- ? ((__FLOAT_BITS(x) + 0x00800000) & 0x7fffffff) >= 0x01000000 \
- : sizeof(x) == sizeof(double) \
- ? ((__DOUBLE_BITS(x) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53 \
- : __fpclassifyl(x) == FP_NORMAL)
+#define isnormal(x) \
+ (sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x) + 0x00800000) & 0x7fffffff) >= 0x01000000 \
+ : sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x) + (1ULL << 52)) & \
+ -1ULL >> 1) >= 1ULL << 53 \
+ : __fpclassifyl(x) == FP_NORMAL)
-#define isfinite(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) < 0x7ffULL << 52 \
- : __fpclassifyl(x) > FP_INFINITE)
+#define isfinite(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) < 0x7ffULL << 52 \
+ : __fpclassifyl(x) > FP_INFINITE)
int __signbit(double);
int __signbitf(float);
int __signbitl(long double);
-#define signbit(x) \
- (sizeof(x) == sizeof(float) \
- ? (int)(__FLOAT_BITS(x) >> 31) \
- : sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x) >> 63) : __signbitl(x))
+#define signbit(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (int)(__FLOAT_BITS(x) >> 31) \
+ : sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x) >> 63) : __signbitl(x))
#define isunordered(x, y) __builtin_isunordered(x, y)
-#define __ISREL_DEF(rel, op, type) \
- static __inline int __is##rel(type __x, type __y) { \
- return !isunordered(__x, __y) && __x op __y; \
- }
+#define __ISREL_DEF(rel, op, type) \
+ static __inline int __is##rel(type __x, type __y) { return !isunordered(__x, __y) && __x op __y; }
__ISREL_DEF(lessf, <, float_t)
__ISREL_DEF(less, <, double_t)
@@ -429,3 +426,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MATH_H_
diff --git a/arch/arm64/sysroot/include/monetary.h b/arch/arm64/sysroot/include/monetary.h
index b6081b9..d1955fa 100644
--- a/arch/arm64/sysroot/include/monetary.h
+++ b/arch/arm64/sysroot/include/monetary.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MONETARY_H_
+#define SYSROOT_MONETARY_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MONETARY_H_
diff --git a/arch/arm64/sysroot/include/net/ethernet.h b/arch/arm64/sysroot/include/net/ethernet.h
index 41dab8b..9cee87d 100644
--- a/arch/arm64/sysroot/include/net/ethernet.h
+++ b/arch/arm64/sysroot/include/net/ethernet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_ETHERNET_H_
+#define SYSROOT_NET_ETHERNET_H_
#ifdef __cplusplus
extern "C" {
@@ -9,13 +10,13 @@
#include <sys/types.h>
struct ether_addr {
- uint8_t ether_addr_octet[ETH_ALEN];
+ uint8_t ether_addr_octet[ETH_ALEN];
};
struct ether_header {
- uint8_t ether_dhost[ETH_ALEN];
- uint8_t ether_shost[ETH_ALEN];
- uint16_t ether_type;
+ uint8_t ether_dhost[ETH_ALEN];
+ uint8_t ether_shost[ETH_ALEN];
+ uint16_t ether_type;
};
#define ETHERTYPE_PUP 0x0200
@@ -48,3 +49,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_ETHERNET_H_
diff --git a/arch/arm64/sysroot/include/net/if.h b/arch/arm64/sysroot/include/net/if.h
index 687175b..e97c3ee 100644
--- a/arch/arm64/sysroot/include/net/if.h
+++ b/arch/arm64/sysroot/include/net/if.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_IF_H_
+#define SYSROOT_NET_IF_H_
#ifdef __cplusplus
extern "C" {
@@ -9,8 +10,8 @@
#define IF_NAMESIZE 16
struct if_nameindex {
- unsigned int if_index;
- char* if_name;
+ unsigned int if_index;
+ char* if_name;
};
unsigned int if_nametoindex(const char*);
@@ -41,53 +42,53 @@
#define IFF_LOWER_UP 0x10000
#define IFF_DORMANT 0x20000
#define IFF_ECHO 0x40000
-#define IFF_VOLATILE \
- (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST | IFF_ECHO | IFF_MASTER | IFF_SLAVE | \
- IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)
+#define IFF_VOLATILE \
+ (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST | IFF_ECHO | IFF_MASTER | IFF_SLAVE | \
+ IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)
struct ifaddr {
- struct sockaddr ifa_addr;
- union {
- struct sockaddr ifu_broadaddr;
- struct sockaddr ifu_dstaddr;
- } ifa_ifu;
- struct iface* ifa_ifp;
- struct ifaddr* ifa_next;
+ struct sockaddr ifa_addr;
+ union {
+ struct sockaddr ifu_broadaddr;
+ struct sockaddr ifu_dstaddr;
+ } ifa_ifu;
+ struct iface* ifa_ifp;
+ struct ifaddr* ifa_next;
};
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
struct ifmap {
- unsigned long int mem_start;
- unsigned long int mem_end;
- unsigned short int base_addr;
- unsigned char irq;
- unsigned char dma;
- unsigned char port;
+ unsigned long int mem_start;
+ unsigned long int mem_end;
+ unsigned short int base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
};
#define IFHWADDRLEN 6
#define IFNAMSIZ IF_NAMESIZE
struct ifreq {
- union {
- char ifrn_name[IFNAMSIZ];
- } ifr_ifrn;
- union {
- struct sockaddr ifru_addr;
- struct sockaddr ifru_dstaddr;
- struct sockaddr ifru_broadaddr;
- struct sockaddr ifru_netmask;
- struct sockaddr ifru_hwaddr;
- short int ifru_flags;
- int ifru_ivalue;
- int ifru_mtu;
- struct ifmap ifru_map;
- char ifru_slave[IFNAMSIZ];
- char ifru_newname[IFNAMSIZ];
- void* ifru_data;
- } ifr_ifru;
+ union {
+ char ifrn_name[IFNAMSIZ];
+ } ifr_ifrn;
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short int ifru_flags;
+ int ifru_ivalue;
+ int ifru_mtu;
+ struct ifmap ifru_map;
+ char ifru_slave[IFNAMSIZ];
+ char ifru_newname[IFNAMSIZ];
+ void* ifru_data;
+ } ifr_ifru;
};
#define ifr_name ifr_ifrn.ifrn_name
@@ -111,11 +112,11 @@
#define _IOT_ifreq_int _IOT(_IOTS(char), IFNAMSIZ, _IOTS(int), 1, 0, 0)
struct ifconf {
- int ifc_len;
- union {
- void* ifcu_buf;
- struct ifreq* ifcu_req;
- } ifc_ifcu;
+ int ifc_len;
+ union {
+ void* ifcu_buf;
+ struct ifreq* ifcu_req;
+ } ifc_ifcu;
};
#define ifc_buf ifc_ifcu.ifcu_buf
@@ -127,3 +128,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_IF_H_
diff --git a/arch/arm64/sysroot/include/net/if_arp.h b/arch/arm64/sysroot/include/net/if_arp.h
index 6da9341..40b902d 100644
--- a/arch/arm64/sysroot/include/net/if_arp.h
+++ b/arch/arm64/sysroot/include/net/if_arp.h
@@ -1,6 +1,7 @@
/* Nonstandard header */
-#pragma once
+#ifndef SYSROOT_NET_IF_ARP_H_
+#define SYSROOT_NET_IF_ARP_H_
#ifdef __cplusplus
extern "C" {
@@ -21,11 +22,11 @@
#define ARPOP_NAK 10
struct arphdr {
- uint16_t ar_hrd;
- uint16_t ar_pro;
- uint8_t ar_hln;
- uint8_t ar_pln;
- uint16_t ar_op;
+ uint16_t ar_hrd;
+ uint16_t ar_pro;
+ uint8_t ar_hln;
+ uint8_t ar_pln;
+ uint16_t ar_op;
};
#define ARPHRD_NETROM 0
@@ -96,18 +97,18 @@
#define ARPHRD_NONE 0xFFFE
struct arpreq {
- struct sockaddr arp_pa;
- struct sockaddr arp_ha;
- int arp_flags;
- struct sockaddr arp_netmask;
- char arp_dev[16];
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
+ char arp_dev[16];
};
struct arpreq_old {
- struct sockaddr arp_pa;
- struct sockaddr arp_ha;
- int arp_flags;
- struct sockaddr arp_netmask;
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
};
#define ATF_COM 0x02
@@ -123,14 +124,16 @@
#define ARPD_FLUSH 0x03
struct arpd_request {
- unsigned short req;
- uint32_t ip;
- unsigned long dev;
- unsigned long stamp;
- unsigned long updated;
- unsigned char ha[MAX_ADDR_LEN];
+ unsigned short req;
+ uint32_t ip;
+ unsigned long dev;
+ unsigned long stamp;
+ unsigned long updated;
+ unsigned char ha[MAX_ADDR_LEN];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_IF_ARP_H_
diff --git a/arch/arm64/sysroot/include/net/route.h b/arch/arm64/sysroot/include/net/route.h
index 5d2d3d0..dc5960b 100644
--- a/arch/arm64/sysroot/include/net/route.h
+++ b/arch/arm64/sysroot/include/net/route.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_ROUTE_H_
+#define SYSROOT_NET_ROUTE_H_
#ifdef __cplusplus
extern "C" {
@@ -10,36 +11,36 @@
#include <sys/types.h>
struct rtentry {
- unsigned long int rt_pad1;
- struct sockaddr rt_dst;
- struct sockaddr rt_gateway;
- struct sockaddr rt_genmask;
- unsigned short int rt_flags;
- short int rt_pad2;
- unsigned long int rt_pad3;
- unsigned char rt_tos;
- unsigned char rt_class;
- short int rt_pad4[sizeof(long) / 2 - 1];
- short int rt_metric;
- char* rt_dev;
- unsigned long int rt_mtu;
- unsigned long int rt_window;
- unsigned short int rt_irtt;
+ unsigned long int rt_pad1;
+ struct sockaddr rt_dst;
+ struct sockaddr rt_gateway;
+ struct sockaddr rt_genmask;
+ unsigned short int rt_flags;
+ short int rt_pad2;
+ unsigned long int rt_pad3;
+ unsigned char rt_tos;
+ unsigned char rt_class;
+ short int rt_pad4[sizeof(long) / 2 - 1];
+ short int rt_metric;
+ char* rt_dev;
+ unsigned long int rt_mtu;
+ unsigned long int rt_window;
+ unsigned short int rt_irtt;
};
#define rt_mss rt_mtu
struct in6_rtmsg {
- struct in6_addr rtmsg_dst;
- struct in6_addr rtmsg_src;
- struct in6_addr rtmsg_gateway;
- uint32_t rtmsg_type;
- uint16_t rtmsg_dst_len;
- uint16_t rtmsg_src_len;
- uint32_t rtmsg_metric;
- unsigned long int rtmsg_info;
- uint32_t rtmsg_flags;
- int rtmsg_ifindex;
+ struct in6_addr rtmsg_dst;
+ struct in6_addr rtmsg_src;
+ struct in6_addr rtmsg_gateway;
+ uint32_t rtmsg_type;
+ uint16_t rtmsg_dst_len;
+ uint16_t rtmsg_src_len;
+ uint32_t rtmsg_metric;
+ unsigned long int rtmsg_info;
+ uint32_t rtmsg_flags;
+ int rtmsg_ifindex;
};
#define RTF_UP 0x0001
@@ -114,3 +115,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_ROUTE_H_
diff --git a/arch/arm64/sysroot/include/netdb.h b/arch/arm64/sysroot/include/netdb.h
index 5b8ab72..d5bb5ef 100644
--- a/arch/arm64/sysroot/include/netdb.h
+++ b/arch/arm64/sysroot/include/netdb.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETDB_H_
+#define SYSROOT_NETDB_H_
#ifdef __cplusplus
extern "C" {
@@ -13,14 +14,14 @@
#endif
struct addrinfo {
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- socklen_t ai_addrlen;
- struct sockaddr* ai_addr;
- char* ai_canonname;
- struct addrinfo* ai_next;
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ socklen_t ai_addrlen;
+ struct sockaddr* ai_addr;
+ char* ai_canonname;
+ struct addrinfo* ai_next;
};
#define IPPORT_RESERVED 1024
@@ -61,32 +62,32 @@
/* Legacy functions follow (marked OBsolete in SUS) */
struct netent {
- char* n_name;
- char** n_aliases;
- int n_addrtype;
- uint32_t n_net;
+ char* n_name;
+ char** n_aliases;
+ int n_addrtype;
+ uint32_t n_net;
};
struct hostent {
- char* h_name;
- char** h_aliases;
- int h_addrtype;
- int h_length;
- char** h_addr_list;
+ char* h_name;
+ char** h_aliases;
+ int h_addrtype;
+ int h_length;
+ char** h_addr_list;
};
#define h_addr h_addr_list[0]
struct servent {
- char* s_name;
- char** s_aliases;
- int s_port;
- char* s_proto;
+ char* s_name;
+ char** s_aliases;
+ int s_port;
+ char* s_proto;
};
struct protoent {
- char* p_name;
- char** p_aliases;
- int p_proto;
+ char* p_name;
+ char** p_aliases;
+ int p_proto;
};
void sethostent(int);
@@ -150,3 +151,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETDB_H_
diff --git a/arch/arm64/sysroot/include/netinet/ether.h b/arch/arm64/sysroot/include/netinet/ether.h
index 0a65077..74668fb 100644
--- a/arch/arm64/sysroot/include/netinet/ether.h
+++ b/arch/arm64/sysroot/include/netinet/ether.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_ETHER_H_
+#define SYSROOT_NETINET_ETHER_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_ETHER_H_
diff --git a/arch/arm64/sysroot/include/netinet/icmp6.h b/arch/arm64/sysroot/include/netinet/icmp6.h
index 9a50bcd..dde64cb 100644
--- a/arch/arm64/sysroot/include/netinet/icmp6.h
+++ b/arch/arm64/sysroot/include/netinet/icmp6.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_ICMP6_H_
+#define SYSROOT_NETINET_ICMP6_H_
#ifdef __cplusplus
extern "C" {
@@ -17,18 +18,18 @@
#define ICMP6_FILTER_PASSONLY 4
struct icmp6_filter {
- uint32_t icmp6_filt[8];
+ uint32_t icmp6_filt[8];
};
struct icmp6_hdr {
- uint8_t icmp6_type;
- uint8_t icmp6_code;
- uint16_t icmp6_cksum;
- union {
- uint32_t icmp6_un_data32[1];
- uint16_t icmp6_un_data16[2];
- uint8_t icmp6_un_data8[4];
- } icmp6_dataun;
+ uint8_t icmp6_type;
+ uint8_t icmp6_code;
+ uint16_t icmp6_cksum;
+ union {
+ uint32_t icmp6_un_data32[1];
+ uint16_t icmp6_un_data16[2];
+ uint8_t icmp6_un_data8[4];
+ } icmp6_dataun;
};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
@@ -67,16 +68,16 @@
#define ICMP6_PARAMPROB_OPTION 2
#define ICMP6_FILTER_WILLPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) == 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) == 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) != 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) != 0)
#define ICMP6_FILTER_SETPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type)&31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type)&31))))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type)&31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type)&31))))
#define ICMP6_FILTER_SETPASSALL(filterp) memset(filterp, 0, sizeof(struct icmp6_filter));
@@ -89,7 +90,7 @@
#define ND_REDIRECT 137
struct nd_router_solicit {
- struct icmp6_hdr nd_rs_hdr;
+ struct icmp6_hdr nd_rs_hdr;
};
#define nd_rs_type nd_rs_hdr.icmp6_type
@@ -98,9 +99,9 @@
#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
struct nd_router_advert {
- struct icmp6_hdr nd_ra_hdr;
- uint32_t nd_ra_reachable;
- uint32_t nd_ra_retransmit;
+ struct icmp6_hdr nd_ra_hdr;
+ uint32_t nd_ra_reachable;
+ uint32_t nd_ra_retransmit;
};
#define nd_ra_type nd_ra_hdr.icmp6_type
@@ -114,8 +115,8 @@
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit {
- struct icmp6_hdr nd_ns_hdr;
- struct in6_addr nd_ns_target;
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target;
};
#define nd_ns_type nd_ns_hdr.icmp6_type
@@ -124,8 +125,8 @@
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
struct nd_neighbor_advert {
- struct icmp6_hdr nd_na_hdr;
- struct in6_addr nd_na_target;
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target;
};
#define nd_na_type nd_na_hdr.icmp6_type
@@ -143,9 +144,9 @@
#endif
struct nd_redirect {
- struct icmp6_hdr nd_rd_hdr;
- struct in6_addr nd_rd_target;
- struct in6_addr nd_rd_dst;
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target;
+ struct in6_addr nd_rd_dst;
};
#define nd_rd_type nd_rd_hdr.icmp6_type
@@ -154,8 +155,8 @@
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
struct nd_opt_hdr {
- uint8_t nd_opt_type;
- uint8_t nd_opt_len;
+ uint8_t nd_opt_type;
+ uint8_t nd_opt_len;
};
#define ND_OPT_SOURCE_LINKADDR 1
@@ -167,14 +168,14 @@
#define ND_OPT_HOME_AGENT_INFO 8
struct nd_opt_prefix_info {
- uint8_t nd_opt_pi_type;
- uint8_t nd_opt_pi_len;
- uint8_t nd_opt_pi_prefix_len;
- uint8_t nd_opt_pi_flags_reserved;
- uint32_t nd_opt_pi_valid_time;
- uint32_t nd_opt_pi_preferred_time;
- uint32_t nd_opt_pi_reserved2;
- struct in6_addr nd_opt_pi_prefix;
+ uint8_t nd_opt_pi_type;
+ uint8_t nd_opt_pi_len;
+ uint8_t nd_opt_pi_prefix_len;
+ uint8_t nd_opt_pi_flags_reserved;
+ uint32_t nd_opt_pi_valid_time;
+ uint32_t nd_opt_pi_preferred_time;
+ uint32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
};
#define ND_OPT_PI_FLAG_ONLINK 0x80
@@ -182,22 +183,22 @@
#define ND_OPT_PI_FLAG_RADDR 0x20
struct nd_opt_rd_hdr {
- uint8_t nd_opt_rh_type;
- uint8_t nd_opt_rh_len;
- uint16_t nd_opt_rh_reserved1;
- uint32_t nd_opt_rh_reserved2;
+ uint8_t nd_opt_rh_type;
+ uint8_t nd_opt_rh_len;
+ uint16_t nd_opt_rh_reserved1;
+ uint32_t nd_opt_rh_reserved2;
};
struct nd_opt_mtu {
- uint8_t nd_opt_mtu_type;
- uint8_t nd_opt_mtu_len;
- uint16_t nd_opt_mtu_reserved;
- uint32_t nd_opt_mtu_mtu;
+ uint8_t nd_opt_mtu_type;
+ uint8_t nd_opt_mtu_len;
+ uint16_t nd_opt_mtu_reserved;
+ uint32_t nd_opt_mtu_mtu;
};
struct mld_hdr {
- struct icmp6_hdr mld_icmp6_hdr;
- struct in6_addr mld_addr;
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr;
};
#define mld_type mld_icmp6_hdr.icmp6_type
@@ -209,11 +210,11 @@
#define ICMP6_ROUTER_RENUMBERING 138
struct icmp6_router_renum {
- struct icmp6_hdr rr_hdr;
- uint8_t rr_segnum;
- uint8_t rr_flags;
- uint16_t rr_maxdelay;
- uint32_t rr_reserved;
+ struct icmp6_hdr rr_hdr;
+ uint8_t rr_segnum;
+ uint8_t rr_flags;
+ uint16_t rr_maxdelay;
+ uint32_t rr_reserved;
};
#define rr_type rr_hdr.icmp6_type
@@ -228,14 +229,14 @@
#define ICMP6_RR_FLAGS_PREVDONE 0x08
struct rr_pco_match {
- uint8_t rpm_code;
- uint8_t rpm_len;
- uint8_t rpm_ordinal;
- uint8_t rpm_matchlen;
- uint8_t rpm_minlen;
- uint8_t rpm_maxlen;
- uint16_t rpm_reserved;
- struct in6_addr rpm_prefix;
+ uint8_t rpm_code;
+ uint8_t rpm_len;
+ uint8_t rpm_ordinal;
+ uint8_t rpm_matchlen;
+ uint8_t rpm_minlen;
+ uint8_t rpm_maxlen;
+ uint16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
};
#define RPM_PCO_ADD 1
@@ -243,14 +244,14 @@
#define RPM_PCO_SETGLOBAL 3
struct rr_pco_use {
- uint8_t rpu_uselen;
- uint8_t rpu_keeplen;
- uint8_t rpu_ramask;
- uint8_t rpu_raflags;
- uint32_t rpu_vltime;
- uint32_t rpu_pltime;
- uint32_t rpu_flags;
- struct in6_addr rpu_prefix;
+ uint8_t rpu_uselen;
+ uint8_t rpu_keeplen;
+ uint8_t rpu_ramask;
+ uint8_t rpu_raflags;
+ uint32_t rpu_vltime;
+ uint32_t rpu_pltime;
+ uint32_t rpu_flags;
+ struct in6_addr rpu_prefix;
};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
@@ -265,11 +266,11 @@
#endif
struct rr_result {
- uint16_t rrr_flags;
- uint8_t rrr_ordinal;
- uint8_t rrr_matchedlen;
- uint32_t rrr_ifid;
- struct in6_addr rrr_prefix;
+ uint16_t rrr_flags;
+ uint8_t rrr_ordinal;
+ uint8_t rrr_matchedlen;
+ uint32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -281,20 +282,22 @@
#endif
struct nd_opt_adv_interval {
- uint8_t nd_opt_adv_interval_type;
- uint8_t nd_opt_adv_interval_len;
- uint16_t nd_opt_adv_interval_reserved;
- uint32_t nd_opt_adv_interval_ival;
+ uint8_t nd_opt_adv_interval_type;
+ uint8_t nd_opt_adv_interval_len;
+ uint16_t nd_opt_adv_interval_reserved;
+ uint32_t nd_opt_adv_interval_ival;
};
struct nd_opt_home_agent_info {
- uint8_t nd_opt_home_agent_info_type;
- uint8_t nd_opt_home_agent_info_len;
- uint16_t nd_opt_home_agent_info_reserved;
- uint16_t nd_opt_home_agent_info_preference;
- uint16_t nd_opt_home_agent_info_lifetime;
+ uint8_t nd_opt_home_agent_info_type;
+ uint8_t nd_opt_home_agent_info_len;
+ uint16_t nd_opt_home_agent_info_reserved;
+ uint16_t nd_opt_home_agent_info_preference;
+ uint16_t nd_opt_home_agent_info_lifetime;
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_ICMP6_H_
diff --git a/arch/arm64/sysroot/include/netinet/if_ether.h b/arch/arm64/sysroot/include/netinet/if_ether.h
index ee7d38e..f826e96 100644
--- a/arch/arm64/sysroot/include/netinet/if_ether.h
+++ b/arch/arm64/sysroot/include/netinet/if_ether.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IF_ETHER_H_
+#define SYSROOT_NETINET_IF_ETHER_H_
#include <stdint.h>
#include <sys/types.h>
@@ -93,20 +94,20 @@
#define ETH_P_CAIF 0x00F7
struct ethhdr {
- uint8_t h_dest[ETH_ALEN];
- uint8_t h_source[ETH_ALEN];
- uint16_t h_proto;
+ uint8_t h_dest[ETH_ALEN];
+ uint8_t h_source[ETH_ALEN];
+ uint16_t h_proto;
};
#include <net/ethernet.h>
#include <net/if_arp.h>
struct ether_arp {
- struct arphdr ea_hdr;
- uint8_t arp_sha[ETH_ALEN];
- uint8_t arp_spa[4];
- uint8_t arp_tha[ETH_ALEN];
- uint8_t arp_tpa[4];
+ struct arphdr ea_hdr;
+ uint8_t arp_sha[ETH_ALEN];
+ uint8_t arp_spa[4];
+ uint8_t arp_tha[ETH_ALEN];
+ uint8_t arp_tpa[4];
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
@@ -114,12 +115,14 @@
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
-#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
- do { \
- (enaddr)[0] = 0x01; \
- (enaddr)[1] = 0x00; \
- (enaddr)[2] = 0x5e; \
- (enaddr)[3] = ((uint8_t*)ipaddr)[1] & 0x7f; \
- (enaddr)[4] = ((uint8_t*)ipaddr)[2]; \
- (enaddr)[5] = ((uint8_t*)ipaddr)[3]; \
- } while (0)
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+ do { \
+ (enaddr)[0] = 0x01; \
+ (enaddr)[1] = 0x00; \
+ (enaddr)[2] = 0x5e; \
+ (enaddr)[3] = ((uint8_t*)ipaddr)[1] & 0x7f; \
+ (enaddr)[4] = ((uint8_t*)ipaddr)[2]; \
+ (enaddr)[5] = ((uint8_t*)ipaddr)[3]; \
+ } while (0)
+
+#endif // SYSROOT_NETINET_IF_ETHER_H_
diff --git a/arch/arm64/sysroot/include/netinet/igmp.h b/arch/arm64/sysroot/include/netinet/igmp.h
index a59a1cc..99eb989 100644
--- a/arch/arm64/sysroot/include/netinet/igmp.h
+++ b/arch/arm64/sysroot/include/netinet/igmp.h
@@ -1,13 +1,14 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IGMP_H_
+#define SYSROOT_NETINET_IGMP_H_
#include <netinet/in.h>
#include <stdint.h>
struct igmp {
- uint8_t igmp_type;
- uint8_t igmp_code;
- uint16_t igmp_cksum;
- struct in_addr igmp_group;
+ uint8_t igmp_type;
+ uint8_t igmp_code;
+ uint16_t igmp_cksum;
+ struct in_addr igmp_group;
};
#define IGMP_MINLEN 8
@@ -40,3 +41,5 @@
#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
+
+#endif // SYSROOT_NETINET_IGMP_H_
diff --git a/arch/arm64/sysroot/include/netinet/in.h b/arch/arm64/sysroot/include/netinet/in.h
index e626a93..6d18e44 100644
--- a/arch/arm64/sysroot/include/netinet/in.h
+++ b/arch/arm64/sysroot/include/netinet/in.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IN_H_
+#define SYSROOT_NETINET_IN_H_
#ifdef __cplusplus
extern "C" {
@@ -11,38 +12,38 @@
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
struct in_addr {
- in_addr_t s_addr;
+ in_addr_t s_addr;
};
struct sockaddr_in {
- sa_family_t sin_family;
- in_port_t sin_port;
- struct in_addr sin_addr;
- uint8_t sin_zero[8];
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t sin_zero[8];
};
struct in6_addr {
- union {
- uint8_t __s6_addr[16];
- uint16_t __s6_addr16[8];
- uint32_t __s6_addr32[4];
- } __in6_union;
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
};
#define s6_addr __in6_union.__s6_addr
#define s6_addr16 __in6_union.__s6_addr16
#define s6_addr32 __in6_union.__s6_addr32
struct sockaddr_in6 {
- sa_family_t sin6_family;
- in_port_t sin6_port;
- uint32_t sin6_flowinfo;
- struct in6_addr sin6_addr;
- uint32_t sin6_scope_id;
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
};
struct ipv6_mreq {
- struct in6_addr ipv6mr_multiaddr;
- unsigned ipv6mr_interface;
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
};
#define INADDR_ANY ((in_addr_t)0x00000000)
@@ -55,18 +56,18 @@
#define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002)
#define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff)
-#define IN6ADDR_ANY_INIT \
- { \
- { \
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } \
- } \
- }
-#define IN6ADDR_LOOPBACK_INIT \
- { \
- { \
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } \
- } \
- }
+#define IN6ADDR_ANY_INIT \
+ { \
+ { \
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } \
+ } \
+ }
+#define IN6ADDR_LOOPBACK_INIT \
+ { \
+ { \
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } \
+ } \
+ }
extern const struct in6_addr in6addr_any, in6addr_loopback;
@@ -114,46 +115,46 @@
#define IPPROTO_RAW 255
#define IPPROTO_MAX 256
-#define IN6_IS_ADDR_UNSPECIFIED(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint32_t*)(a))[3] == 0)
+#define IN6_IS_ADDR_UNSPECIFIED(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint32_t*)(a))[3] == 0)
-#define IN6_IS_ADDR_LOOPBACK(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint8_t*)(a))[12] == 0 && ((uint8_t*)(a))[13] == 0 && ((uint8_t*)(a))[14] == 0 && \
- ((uint8_t*)(a))[15] == 1)
+#define IN6_IS_ADDR_LOOPBACK(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint8_t*)(a))[12] == 0 && ((uint8_t*)(a))[13] == 0 && ((uint8_t*)(a))[14] == 0 && \
+ ((uint8_t*)(a))[15] == 1)
#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t*)(a))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(a) \
- ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0x80)
+ ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0x80)
#define IN6_IS_ADDR_SITELOCAL(a) \
- ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0xc0)
+ ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0xc0)
-#define IN6_IS_ADDR_V4MAPPED(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint8_t*)(a))[8] == 0 && \
- ((uint8_t*)(a))[9] == 0 && ((uint8_t*)(a))[10] == 0xff && ((uint8_t*)(a))[11] == 0xff)
+#define IN6_IS_ADDR_V4MAPPED(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint8_t*)(a))[8] == 0 && \
+ ((uint8_t*)(a))[9] == 0 && ((uint8_t*)(a))[10] == 0xff && ((uint8_t*)(a))[11] == 0xff)
-#define IN6_IS_ADDR_V4COMPAT(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint8_t*)(a))[15] > 1)
+#define IN6_IS_ADDR_V4COMPAT(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint8_t*)(a))[15] > 1)
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x1))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x2))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x5))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(a) (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0xe))
#define __ARE_4_EQUAL(a, b) \
- (!((0 [a] - 0 [b]) | (1 [a] - 1 [b]) | (2 [a] - 2 [b]) | (3 [a] - 3 [b])))
+ (!((0 [a] - 0 [b]) | (1 [a] - 1 [b]) | (2 [a] - 2 [b]) | (3 [a] - 3 [b])))
#define IN6_ARE_ADDR_EQUAL(a, b) __ARE_4_EQUAL((const uint32_t*)(a), (const uint32_t*)(b))
#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
@@ -230,8 +231,8 @@
#define IP_MAX_MEMBERSHIPS 20
struct ip_opts {
- struct in_addr ip_dst;
- char ip_opts[40];
+ struct in_addr ip_dst;
+ char ip_opts[40];
};
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -248,68 +249,68 @@
#define MCAST_INCLUDE 1
struct ip_mreq {
- struct in_addr imr_multiaddr;
- struct in_addr imr_interface;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
};
struct ip_mreqn {
- struct in_addr imr_multiaddr;
- struct in_addr imr_address;
- int imr_ifindex;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
};
struct ip_mreq_source {
- struct in_addr imr_multiaddr;
- struct in_addr imr_interface;
- struct in_addr imr_sourceaddr;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+ struct in_addr imr_sourceaddr;
};
struct ip_msfilter {
- struct in_addr imsf_multiaddr;
- struct in_addr imsf_interface;
- uint32_t imsf_fmode;
- uint32_t imsf_numsrc;
- struct in_addr imsf_slist[1];
+ struct in_addr imsf_multiaddr;
+ struct in_addr imsf_interface;
+ uint32_t imsf_fmode;
+ uint32_t imsf_numsrc;
+ struct in_addr imsf_slist[1];
};
#define IP_MSFILTER_SIZE(numsrc) \
- (sizeof(struct ip_msfilter) - sizeof(struct in_addr) + (numsrc) * sizeof(struct in_addr))
+ (sizeof(struct ip_msfilter) - sizeof(struct in_addr) + (numsrc) * sizeof(struct in_addr))
struct group_req {
- uint32_t gr_interface;
- struct sockaddr_storage gr_group;
+ uint32_t gr_interface;
+ struct sockaddr_storage gr_group;
};
struct group_source_req {
- uint32_t gsr_interface;
- struct sockaddr_storage gsr_group;
- struct sockaddr_storage gsr_source;
+ uint32_t gsr_interface;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
};
struct group_filter {
- uint32_t gf_interface;
- struct sockaddr_storage gf_group;
- uint32_t gf_fmode;
- uint32_t gf_numsrc;
- struct sockaddr_storage gf_slist[1];
+ uint32_t gf_interface;
+ struct sockaddr_storage gf_group;
+ uint32_t gf_fmode;
+ uint32_t gf_numsrc;
+ struct sockaddr_storage gf_slist[1];
};
-#define GROUP_FILTER_SIZE(numsrc) \
- (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) + \
- (numsrc) * sizeof(struct sockaddr_storage))
+#define GROUP_FILTER_SIZE(numsrc) \
+ (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) + \
+ (numsrc) * sizeof(struct sockaddr_storage))
struct in_pktinfo {
- int ipi_ifindex;
- struct in_addr ipi_spec_dst;
- struct in_addr ipi_addr;
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
};
struct in6_pktinfo {
- struct in6_addr ipi6_addr;
- unsigned ipi6_ifindex;
+ struct in6_addr ipi6_addr;
+ unsigned ipi6_ifindex;
};
struct ip6_mtuinfo {
- struct sockaddr_in6 ip6m_addr;
- uint32_t ip6m_mtu;
+ struct sockaddr_in6 ip6m_addr;
+ uint32_t ip6m_mtu;
};
#endif
@@ -392,3 +393,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IN_H_
diff --git a/arch/arm64/sysroot/include/netinet/in_systm.h b/arch/arm64/sysroot/include/netinet/in_systm.h
index ea7ed91..8e688ab 100644
--- a/arch/arm64/sysroot/include/netinet/in_systm.h
+++ b/arch/arm64/sysroot/include/netinet/in_systm.h
@@ -1,6 +1,9 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IN_SYSTM_H_
+#define SYSROOT_NETINET_IN_SYSTM_H_
#include <stdint.h>
typedef uint16_t n_short;
typedef uint32_t n_long, n_time;
+
+#endif // SYSROOT_NETINET_IN_SYSTM_H_
diff --git a/arch/arm64/sysroot/include/netinet/ip.h b/arch/arm64/sysroot/include/netinet/ip.h
index 1c0978a..c795ef0 100644
--- a/arch/arm64/sysroot/include/netinet/ip.h
+++ b/arch/arm64/sysroot/include/netinet/ip.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP_H_
+#define SYSROOT_NETINET_IP_H_
#ifdef __cplusplus
extern "C" {
@@ -9,53 +10,53 @@
#include <stdint.h>
struct timestamp {
- uint8_t len;
- uint8_t ptr;
+ uint8_t len;
+ uint8_t ptr;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int flags : 4;
- unsigned int overflow : 4;
+ unsigned int flags : 4;
+ unsigned int overflow : 4;
#else
- unsigned int overflow : 4;
- unsigned int flags : 4;
+ unsigned int overflow : 4;
+ unsigned int flags : 4;
#endif
- uint32_t data[9];
+ uint32_t data[9];
};
struct iphdr {
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ihl : 4;
- unsigned int version : 4;
+ unsigned int ihl : 4;
+ unsigned int version : 4;
#else
- unsigned int version : 4;
- unsigned int ihl : 4;
+ unsigned int version : 4;
+ unsigned int ihl : 4;
#endif
- uint8_t tos;
- uint16_t tot_len;
- uint16_t id;
- uint16_t frag_off;
- uint8_t ttl;
- uint8_t protocol;
- uint16_t check;
- uint32_t saddr;
- uint32_t daddr;
+ uint8_t tos;
+ uint16_t tot_len;
+ uint16_t id;
+ uint16_t frag_off;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t check;
+ uint32_t saddr;
+ uint32_t daddr;
};
struct ip {
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ip_hl : 4;
- unsigned int ip_v : 4;
+ unsigned int ip_hl : 4;
+ unsigned int ip_v : 4;
#else
- unsigned int ip_v : 4;
- unsigned int ip_hl : 4;
+ unsigned int ip_v : 4;
+ unsigned int ip_hl : 4;
#endif
- uint8_t ip_tos;
- uint16_t ip_len;
- uint16_t ip_id;
- uint16_t ip_off;
- uint8_t ip_ttl;
- uint8_t ip_p;
- uint16_t ip_sum;
- struct in_addr ip_src, ip_dst;
+ uint8_t ip_tos;
+ uint16_t ip_len;
+ uint16_t ip_id;
+ uint16_t ip_off;
+ uint8_t ip_ttl;
+ uint8_t ip_p;
+ uint16_t ip_sum;
+ struct in_addr ip_src, ip_dst;
};
#define IP_RF 0x8000
@@ -64,17 +65,17 @@
#define IP_OFFMASK 0x1fff
struct ip_timestamp {
- uint8_t ipt_code;
- uint8_t ipt_len;
- uint8_t ipt_ptr;
+ uint8_t ipt_code;
+ uint8_t ipt_len;
+ uint8_t ipt_ptr;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ipt_flg : 4;
- unsigned int ipt_oflw : 4;
+ unsigned int ipt_flg : 4;
+ unsigned int ipt_oflw : 4;
#else
- unsigned int ipt_oflw : 4;
- unsigned int ipt_flg : 4;
+ unsigned int ipt_oflw : 4;
+ unsigned int ipt_flg : 4;
#endif
- uint32_t data[9];
+ uint32_t data[9];
};
#define IPVERSION 4
@@ -193,3 +194,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP_H_
diff --git a/arch/arm64/sysroot/include/netinet/ip6.h b/arch/arm64/sysroot/include/netinet/ip6.h
index e809200..45f1c68 100644
--- a/arch/arm64/sysroot/include/netinet/ip6.h
+++ b/arch/arm64/sysroot/include/netinet/ip6.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP6_H_
+#define SYSROOT_NETINET_IP6_H_
#ifdef __cplusplus
extern "C" {
@@ -9,17 +10,17 @@
#include <stdint.h>
struct ip6_hdr {
- union {
- struct ip6_hdrctl {
- uint32_t ip6_un1_flow;
- uint16_t ip6_un1_plen;
- uint8_t ip6_un1_nxt;
- uint8_t ip6_un1_hlim;
- } ip6_un1;
- uint8_t ip6_un2_vfc;
- } ip6_ctlun;
- struct in6_addr ip6_src;
- struct in6_addr ip6_dst;
+ union {
+ struct ip6_hdrctl {
+ uint32_t ip6_un1_flow;
+ uint16_t ip6_un1_plen;
+ uint8_t ip6_un1_nxt;
+ uint8_t ip6_un1_hlim;
+ } ip6_un1;
+ uint8_t ip6_un2_vfc;
+ } ip6_ctlun;
+ struct in6_addr ip6_src;
+ struct in6_addr ip6_dst;
};
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
@@ -30,42 +31,42 @@
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
struct ip6_ext {
- uint8_t ip6e_nxt;
- uint8_t ip6e_len;
+ uint8_t ip6e_nxt;
+ uint8_t ip6e_len;
};
struct ip6_hbh {
- uint8_t ip6h_nxt;
- uint8_t ip6h_len;
+ uint8_t ip6h_nxt;
+ uint8_t ip6h_len;
};
struct ip6_dest {
- uint8_t ip6d_nxt;
- uint8_t ip6d_len;
+ uint8_t ip6d_nxt;
+ uint8_t ip6d_len;
};
struct ip6_rthdr {
- uint8_t ip6r_nxt;
- uint8_t ip6r_len;
- uint8_t ip6r_type;
- uint8_t ip6r_segleft;
+ uint8_t ip6r_nxt;
+ uint8_t ip6r_len;
+ uint8_t ip6r_type;
+ uint8_t ip6r_segleft;
};
struct ip6_rthdr0 {
- uint8_t ip6r0_nxt;
- uint8_t ip6r0_len;
- uint8_t ip6r0_type;
- uint8_t ip6r0_segleft;
- uint8_t ip6r0_reserved;
- uint8_t ip6r0_slmap[3];
- struct in6_addr ip6r0_addr[];
+ uint8_t ip6r0_nxt;
+ uint8_t ip6r0_len;
+ uint8_t ip6r0_type;
+ uint8_t ip6r0_segleft;
+ uint8_t ip6r0_reserved;
+ uint8_t ip6r0_slmap[3];
+ struct in6_addr ip6r0_addr[];
};
struct ip6_frag {
- uint8_t ip6f_nxt;
- uint8_t ip6f_reserved;
- uint16_t ip6f_offlg;
- uint32_t ip6f_ident;
+ uint8_t ip6f_nxt;
+ uint8_t ip6f_reserved;
+ uint16_t ip6f_offlg;
+ uint32_t ip6f_ident;
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -79,8 +80,8 @@
#endif
struct ip6_opt {
- uint8_t ip6o_type;
- uint8_t ip6o_len;
+ uint8_t ip6o_type;
+ uint8_t ip6o_len;
};
#define IP6OPT_TYPE(o) ((o)&0xc0)
@@ -99,29 +100,29 @@
#define IP6OPT_ROUTER_ALERT 0x05
struct ip6_opt_jumbo {
- uint8_t ip6oj_type;
- uint8_t ip6oj_len;
- uint8_t ip6oj_jumbo_len[4];
+ uint8_t ip6oj_type;
+ uint8_t ip6oj_len;
+ uint8_t ip6oj_jumbo_len[4];
};
#define IP6OPT_JUMBO_LEN 6
struct ip6_opt_nsap {
- uint8_t ip6on_type;
- uint8_t ip6on_len;
- uint8_t ip6on_src_nsap_len;
- uint8_t ip6on_dst_nsap_len;
+ uint8_t ip6on_type;
+ uint8_t ip6on_len;
+ uint8_t ip6on_src_nsap_len;
+ uint8_t ip6on_dst_nsap_len;
};
struct ip6_opt_tunnel {
- uint8_t ip6ot_type;
- uint8_t ip6ot_len;
- uint8_t ip6ot_encap_limit;
+ uint8_t ip6ot_type;
+ uint8_t ip6ot_len;
+ uint8_t ip6ot_encap_limit;
};
struct ip6_opt_router {
- uint8_t ip6or_type;
- uint8_t ip6or_len;
- uint8_t ip6or_value[2];
+ uint8_t ip6or_type;
+ uint8_t ip6or_len;
+ uint8_t ip6or_value[2];
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -137,3 +138,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP6_H_
diff --git a/arch/arm64/sysroot/include/netinet/ip_icmp.h b/arch/arm64/sysroot/include/netinet/ip_icmp.h
index 4c1c322..c239456 100644
--- a/arch/arm64/sysroot/include/netinet/ip_icmp.h
+++ b/arch/arm64/sysroot/include/netinet/ip_icmp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP_ICMP_H_
+#define SYSROOT_NETINET_IP_ICMP_H_
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -9,20 +10,20 @@
#endif
struct icmphdr {
- uint8_t type;
- uint8_t code;
- uint16_t checksum;
- union {
- struct {
- uint16_t id;
- uint16_t sequence;
- } echo;
- uint32_t gateway;
- struct {
- uint16_t __unused;
- uint16_t mtu;
- } frag;
- } un;
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ union {
+ struct {
+ uint16_t id;
+ uint16_t sequence;
+ } echo;
+ uint32_t gateway;
+ struct {
+ uint16_t __unused;
+ uint16_t mtu;
+ } frag;
+ } un;
};
#define ICMP_ECHOREPLY 0
@@ -67,47 +68,47 @@
#define ICMP_EXC_FRAGTIME 1
struct icmp_ra_addr {
- uint32_t ira_addr;
- uint32_t ira_preference;
+ uint32_t ira_addr;
+ uint32_t ira_preference;
};
struct icmp {
- uint8_t icmp_type;
- uint8_t icmp_code;
- uint16_t icmp_cksum;
- union {
- uint8_t ih_pptr;
- struct in_addr ih_gwaddr;
- struct ih_idseq {
- uint16_t icd_id;
- uint16_t icd_seq;
- } ih_idseq;
- uint32_t ih_void;
+ uint8_t icmp_type;
+ uint8_t icmp_code;
+ uint16_t icmp_cksum;
+ union {
+ uint8_t ih_pptr;
+ struct in_addr ih_gwaddr;
+ struct ih_idseq {
+ uint16_t icd_id;
+ uint16_t icd_seq;
+ } ih_idseq;
+ uint32_t ih_void;
- struct ih_pmtu {
- uint16_t ipm_void;
- uint16_t ipm_nextmtu;
- } ih_pmtu;
+ struct ih_pmtu {
+ uint16_t ipm_void;
+ uint16_t ipm_nextmtu;
+ } ih_pmtu;
- struct ih_rtradv {
- uint8_t irt_num_addrs;
- uint8_t irt_wpa;
- uint16_t irt_lifetime;
- } ih_rtradv;
- } icmp_hun;
- union {
- struct {
- uint32_t its_otime;
- uint32_t its_rtime;
- uint32_t its_ttime;
- } id_ts;
- struct {
- struct ip idi_ip;
- } id_ip;
- struct icmp_ra_addr id_radv;
- uint32_t id_mask;
- uint8_t id_data[1];
- } icmp_dun;
+ struct ih_rtradv {
+ uint8_t irt_num_addrs;
+ uint8_t irt_wpa;
+ uint16_t irt_lifetime;
+ } ih_rtradv;
+ } icmp_hun;
+ union {
+ struct {
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
+ } id_ts;
+ struct {
+ struct ip idi_ip;
+ } id_ip;
+ struct icmp_ra_addr id_radv;
+ uint32_t id_mask;
+ uint8_t id_data[1];
+ } icmp_dun;
};
#define icmp_pptr icmp_hun.ih_pptr
@@ -175,12 +176,14 @@
#define ICMP_PARAMPROB_OPTABSENT 1
-#define ICMP_INFOTYPE(type) \
- ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || (type) == ICMP_ROUTERADVERT || \
- (type) == ICMP_ROUTERSOLICIT || (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
- (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || (type) == ICMP_MASKREQ || \
- (type) == ICMP_MASKREPLY)
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || (type) == ICMP_ROUTERADVERT || \
+ (type) == ICMP_ROUTERSOLICIT || (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || (type) == ICMP_MASKREQ || \
+ (type) == ICMP_MASKREPLY)
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP_ICMP_H_
diff --git a/arch/arm64/sysroot/include/netinet/tcp.h b/arch/arm64/sysroot/include/netinet/tcp.h
index 9274ba5..e892dd2 100644
--- a/arch/arm64/sysroot/include/netinet/tcp.h
+++ b/arch/arm64/sysroot/include/netinet/tcp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_TCP_H_
+#define SYSROOT_NETINET_TCP_H_
#include <features.h>
@@ -74,62 +75,61 @@
struct tcphdr {
#ifdef _GNU_SOURCE
#ifdef __GNUC__
- __extension__
+ __extension__
#endif
- union {
- struct {
-
- uint16_t source;
- uint16_t dest;
- uint32_t seq;
- uint32_t ack_seq;
+ union {
+ struct {
+ uint16_t source;
+ uint16_t dest;
+ uint32_t seq;
+ uint32_t ack_seq;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint16_t res1 : 4;
- uint16_t doff : 4;
- uint16_t fin : 1;
- uint16_t syn : 1;
- uint16_t rst : 1;
- uint16_t psh : 1;
- uint16_t ack : 1;
- uint16_t urg : 1;
- uint16_t res2 : 2;
+ uint16_t res1 : 4;
+ uint16_t doff : 4;
+ uint16_t fin : 1;
+ uint16_t syn : 1;
+ uint16_t rst : 1;
+ uint16_t psh : 1;
+ uint16_t ack : 1;
+ uint16_t urg : 1;
+ uint16_t res2 : 2;
#else
- uint16_t doff : 4;
- uint16_t res1 : 4;
- uint16_t res2 : 2;
- uint16_t urg : 1;
- uint16_t ack : 1;
- uint16_t psh : 1;
- uint16_t rst : 1;
- uint16_t syn : 1;
- uint16_t fin : 1;
+ uint16_t doff : 4;
+ uint16_t res1 : 4;
+ uint16_t res2 : 2;
+ uint16_t urg : 1;
+ uint16_t ack : 1;
+ uint16_t psh : 1;
+ uint16_t rst : 1;
+ uint16_t syn : 1;
+ uint16_t fin : 1;
#endif
- uint16_t window;
- uint16_t check;
- uint16_t urg_ptr;
- };
- struct {
+ uint16_t window;
+ uint16_t check;
+ uint16_t urg_ptr;
+ };
+ struct {
#endif
- uint16_t th_sport;
- uint16_t th_dport;
- uint32_t th_seq;
- uint32_t th_ack;
+ uint16_t th_sport;
+ uint16_t th_dport;
+ uint32_t th_seq;
+ uint32_t th_ack;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t th_x2 : 4;
- uint8_t th_off : 4;
+ uint8_t th_x2 : 4;
+ uint8_t th_off : 4;
#else
- uint8_t th_off : 4;
- uint8_t th_x2 : 4;
+ uint8_t th_off : 4;
+ uint8_t th_x2 : 4;
#endif
- uint8_t th_flags;
- uint16_t th_win;
- uint16_t th_sum;
- uint16_t th_urp;
+ uint8_t th_flags;
+ uint16_t th_win;
+ uint16_t th_sum;
+ uint16_t th_urp;
#ifdef _GNU_SOURCE
- };
};
+ };
#endif
};
#endif
@@ -147,53 +147,55 @@
#define TCP_CA_Loss 4
struct tcp_info {
- uint8_t tcpi_state;
- uint8_t tcpi_ca_state;
- uint8_t tcpi_retransmits;
- uint8_t tcpi_probes;
- uint8_t tcpi_backoff;
- uint8_t tcpi_options;
- uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
- uint32_t tcpi_rto;
- uint32_t tcpi_ato;
- uint32_t tcpi_snd_mss;
- uint32_t tcpi_rcv_mss;
- uint32_t tcpi_unacked;
- uint32_t tcpi_sacked;
- uint32_t tcpi_lost;
- uint32_t tcpi_retrans;
- uint32_t tcpi_fackets;
- uint32_t tcpi_last_data_sent;
- uint32_t tcpi_last_ack_sent;
- uint32_t tcpi_last_data_recv;
- uint32_t tcpi_last_ack_recv;
- uint32_t tcpi_pmtu;
- uint32_t tcpi_rcv_ssthresh;
- uint32_t tcpi_rtt;
- uint32_t tcpi_rttvar;
- uint32_t tcpi_snd_ssthresh;
- uint32_t tcpi_snd_cwnd;
- uint32_t tcpi_advmss;
- uint32_t tcpi_reordering;
- uint32_t tcpi_rcv_rtt;
- uint32_t tcpi_rcv_space;
- uint32_t tcpi_total_retrans;
- uint64_t tcpi_pacing_rate;
- uint64_t tcpi_max_pacing_rate;
- uint64_t tcpi_bytes_acked;
- uint64_t tcpi_bytes_received;
- uint32_t tcpi_segs_out;
- uint32_t tcpi_segs_in;
+ uint8_t tcpi_state;
+ uint8_t tcpi_ca_state;
+ uint8_t tcpi_retransmits;
+ uint8_t tcpi_probes;
+ uint8_t tcpi_backoff;
+ uint8_t tcpi_options;
+ uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
+ uint32_t tcpi_rto;
+ uint32_t tcpi_ato;
+ uint32_t tcpi_snd_mss;
+ uint32_t tcpi_rcv_mss;
+ uint32_t tcpi_unacked;
+ uint32_t tcpi_sacked;
+ uint32_t tcpi_lost;
+ uint32_t tcpi_retrans;
+ uint32_t tcpi_fackets;
+ uint32_t tcpi_last_data_sent;
+ uint32_t tcpi_last_ack_sent;
+ uint32_t tcpi_last_data_recv;
+ uint32_t tcpi_last_ack_recv;
+ uint32_t tcpi_pmtu;
+ uint32_t tcpi_rcv_ssthresh;
+ uint32_t tcpi_rtt;
+ uint32_t tcpi_rttvar;
+ uint32_t tcpi_snd_ssthresh;
+ uint32_t tcpi_snd_cwnd;
+ uint32_t tcpi_advmss;
+ uint32_t tcpi_reordering;
+ uint32_t tcpi_rcv_rtt;
+ uint32_t tcpi_rcv_space;
+ uint32_t tcpi_total_retrans;
+ uint64_t tcpi_pacing_rate;
+ uint64_t tcpi_max_pacing_rate;
+ uint64_t tcpi_bytes_acked;
+ uint64_t tcpi_bytes_received;
+ uint32_t tcpi_segs_out;
+ uint32_t tcpi_segs_in;
};
#define TCP_MD5SIG_MAXKEYLEN 80
struct tcp_md5sig {
- struct sockaddr_storage tcpm_addr;
- uint16_t __tcpm_pad1;
- uint16_t tcpm_keylen;
- uint32_t __tcpm_pad2;
- uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
+ struct sockaddr_storage tcpm_addr;
+ uint16_t __tcpm_pad1;
+ uint16_t tcpm_keylen;
+ uint32_t __tcpm_pad2;
+ uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
};
#endif
+
+#endif // SYSROOT_NETINET_TCP_H_
diff --git a/arch/arm64/sysroot/include/netinet/udp.h b/arch/arm64/sysroot/include/netinet/udp.h
index ddde1c7..1a0fba7 100644
--- a/arch/arm64/sysroot/include/netinet/udp.h
+++ b/arch/arm64/sysroot/include/netinet/udp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_UDP_H_
+#define SYSROOT_NETINET_UDP_H_
#ifdef __cplusplus
extern "C" {
@@ -15,10 +16,10 @@
#endif
struct udphdr {
- uint16_t uh_sport;
- uint16_t uh_dport;
- uint16_t uh_ulen;
- uint16_t uh_sum;
+ uint16_t uh_sport;
+ uint16_t uh_dport;
+ uint16_t uh_ulen;
+ uint16_t uh_sum;
};
#define UDP_CORK 1
@@ -33,3 +34,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_UDP_H_
diff --git a/arch/arm64/sysroot/include/netpacket/packet.h b/arch/arm64/sysroot/include/netpacket/packet.h
index 3e35676..3066046 100644
--- a/arch/arm64/sysroot/include/netpacket/packet.h
+++ b/arch/arm64/sysroot/include/netpacket/packet.h
@@ -1,21 +1,22 @@
-#pragma once
+#ifndef SYSROOT_NETPACKET_PACKET_H_
+#define SYSROOT_NETPACKET_PACKET_H_
#ifdef __cplusplus
extern "C" {
#endif
struct sockaddr_ll {
- unsigned short sll_family, sll_protocol;
- int sll_ifindex;
- unsigned short sll_hatype;
- unsigned char sll_pkttype, sll_halen;
- unsigned char sll_addr[8];
+ unsigned short sll_family, sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype, sll_halen;
+ unsigned char sll_addr[8];
};
struct packet_mreq {
- int mr_ifindex;
- unsigned short int mr_type, mr_alen;
- unsigned char mr_address[8];
+ int mr_ifindex;
+ unsigned short int mr_type, mr_alen;
+ unsigned char mr_address[8];
};
#define PACKET_HOST 0
@@ -56,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETPACKET_PACKET_H_
diff --git a/arch/arm64/sysroot/include/nl_types.h b/arch/arm64/sysroot/include/nl_types.h
index 570224d..e30f86e 100644
--- a/arch/arm64/sysroot/include/nl_types.h
+++ b/arch/arm64/sysroot/include/nl_types.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NL_TYPES_H_
+#define SYSROOT_NL_TYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NL_TYPES_H_
diff --git a/arch/arm64/sysroot/include/paths.h b/arch/arm64/sysroot/include/paths.h
index 36b6127..0ff06aa 100644
--- a/arch/arm64/sysroot/include/paths.h
+++ b/arch/arm64/sysroot/include/paths.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PATHS_H_
+#define SYSROOT_PATHS_H_
#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin"
@@ -23,3 +24,5 @@
#define _PATH_VARDB "/var/lib/misc/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
+
+#endif // SYSROOT_PATHS_H_
diff --git a/arch/arm64/sysroot/include/poll.h b/arch/arm64/sysroot/include/poll.h
index d8b3726..4c7c800 100644
--- a/arch/arm64/sysroot/include/poll.h
+++ b/arch/arm64/sysroot/include/poll.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_POLL_H_
+#define SYSROOT_POLL_H_
#ifdef __cplusplus
extern "C" {
@@ -28,9 +29,9 @@
typedef unsigned long nfds_t;
struct pollfd {
- int fd;
- short events;
- short revents;
+ int fd;
+ short events;
+ short revents;
};
int poll(struct pollfd*, nfds_t, int);
@@ -46,3 +47,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_POLL_H_
diff --git a/arch/arm64/sysroot/include/pthread.h b/arch/arm64/sysroot/include/pthread.h
index 07576e5..d4b9f00 100644
--- a/arch/arm64/sysroot/include/pthread.h
+++ b/arch/arm64/sysroot/include/pthread.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PTHREAD_H_
+#define SYSROOT_PTHREAD_H_
#ifdef __cplusplus
extern "C" {
@@ -25,11 +26,11 @@
#define __NEED_pthread_once_t
#define __NEED_size_t
-#include <bits/alltypes.h>
-
#include <sched.h>
#include <time.h>
+#include <bits/alltypes.h>
+
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
@@ -54,11 +55,11 @@
#define PTHREAD_PROCESS_PRIVATE 0
#define PTHREAD_MUTEX_INITIALIZER \
- {}
+ {}
#define PTHREAD_RWLOCK_INITIALIZER \
- {}
+ {}
#define PTHREAD_COND_INITIALIZER \
- {}
+ {}
#define PTHREAD_ONCE_INIT 0
#define PTHREAD_CANCEL_ENABLE 0
@@ -147,8 +148,9 @@
int pthread_attr_getdetachstate(const pthread_attr_t*, int*);
int pthread_attr_setdetachstate(pthread_attr_t*, int);
int pthread_attr_getstack(const pthread_attr_t* __restrict, void** __restrict, size_t* __restrict);
-int pthread_attr_setstack(pthread_attr_t*, void*, size_t)
- __attribute__((__deprecated__("pthread_attr_setstack is not available in Fuchsia; perhaps pthread_attr_setstacksize and/or pthread_attr_setguardsize is sufficient for your needs?")));
+int pthread_attr_setstack(pthread_attr_t*, void*, size_t) __attribute__((__deprecated__(
+ "pthread_attr_setstack is not available in Fuchsia; perhaps pthread_attr_setstacksize and/or "
+ "pthread_attr_setguardsize is sufficient for your needs?")));
int pthread_attr_getschedparam(const pthread_attr_t* __restrict, struct sched_param* __restrict);
int pthread_attr_setschedparam(pthread_attr_t* __restrict, const struct sched_param* __restrict);
@@ -194,3 +196,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_PTHREAD_H_
diff --git a/arch/arm64/sysroot/include/pty.h b/arch/arm64/sysroot/include/pty.h
deleted file mode 100644
index 943a6a8..0000000
--- a/arch/arm64/sysroot/include/pty.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/ioctl.h>
-#include <termios.h>
-
-int openpty(int*, int*, char*, const struct termios*, const struct winsize*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/arm64/sysroot/include/pwd.h b/arch/arm64/sysroot/include/pwd.h
index 1d63e72..213eefa 100644
--- a/arch/arm64/sysroot/include/pwd.h
+++ b/arch/arm64/sysroot/include/pwd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PWD_H_
+#define SYSROOT_PWD_H_
#ifdef __cplusplus
extern "C" {
@@ -17,13 +18,13 @@
#include <bits/alltypes.h>
struct passwd {
- char* pw_name;
- char* pw_passwd;
- uid_t pw_uid;
- gid_t pw_gid;
- char* pw_gecos;
- char* pw_dir;
- char* pw_shell;
+ char* pw_name;
+ char* pw_passwd;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char* pw_gecos;
+ char* pw_dir;
+ char* pw_shell;
};
void setpwent(void);
@@ -43,3 +44,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_PWD_H_
diff --git a/arch/arm64/sysroot/include/regex.h b/arch/arm64/sysroot/include/regex.h
index 70c4613..53fac22 100644
--- a/arch/arm64/sysroot/include/regex.h
+++ b/arch/arm64/sysroot/include/regex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_REGEX_H_
+#define SYSROOT_REGEX_H_
#ifdef __cplusplus
extern "C" {
@@ -12,15 +13,15 @@
#include <bits/alltypes.h>
typedef struct re_pattern_buffer {
- size_t re_nsub;
- void *__opaque, *__padding[4];
- size_t __nsub2;
- char __padding2;
+ size_t re_nsub;
+ void *__opaque, *__padding[4];
+ size_t __nsub2;
+ char __padding2;
} regex_t;
typedef struct {
- regoff_t rm_so;
- regoff_t rm_eo;
+ regoff_t rm_so;
+ regoff_t rm_eo;
} regmatch_t;
#define REG_EXTENDED 1
@@ -57,3 +58,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_REGEX_H_
diff --git a/arch/arm64/sysroot/include/resolv.h b/arch/arm64/sysroot/include/resolv.h
index 7efcd49..a90e0e8 100644
--- a/arch/arm64/sysroot/include/resolv.h
+++ b/arch/arm64/sysroot/include/resolv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_RESOLV_H_
+#define SYSROOT_RESOLV_H_
#include <arpa/nameser.h>
#include <netinet/in.h>
@@ -23,41 +24,41 @@
/* unused; purely for broken apps */
typedef struct __res_state {
- int retrans;
- int retry;
- unsigned long options;
- int nscount;
- struct sockaddr_in nsaddr_list[MAXNS];
+ int retrans;
+ int retry;
+ unsigned long options;
+ int nscount;
+ struct sockaddr_in nsaddr_list[MAXNS];
#define nsaddr nsaddr_list[0]
- unsigned short id;
- char* dnsrch[MAXDNSRCH + 1];
- char defdname[256];
- unsigned long pfcode;
- unsigned ndots : 4;
- unsigned nsort : 4;
- unsigned ipv6_unavail : 1;
- unsigned unused : 23;
+ unsigned short id;
+ char* dnsrch[MAXDNSRCH + 1];
+ char defdname[256];
+ unsigned long pfcode;
+ unsigned ndots : 4;
+ unsigned nsort : 4;
+ unsigned ipv6_unavail : 1;
+ unsigned unused : 23;
+ struct {
+ struct in_addr addr;
+ uint32_t mask;
+ } sort_list[MAXRESOLVSORT];
+ void* qhook;
+ void* rhook;
+ int res_h_errno;
+ int _vcsock;
+ unsigned _flags;
+ union {
+ char pad[52];
struct {
- struct in_addr addr;
- uint32_t mask;
- } sort_list[MAXRESOLVSORT];
- void* qhook;
- void* rhook;
- int res_h_errno;
- int _vcsock;
- unsigned _flags;
- union {
- char pad[52];
- struct {
- uint16_t nscount;
- uint16_t nsmap[MAXNS];
- int nssocks[MAXNS];
- uint16_t nscount6;
- uint16_t nsinit;
- struct sockaddr_in6* nsaddrs[MAXNS];
- unsigned int _initstamp[2];
- } _ext;
- } _u;
+ uint16_t nscount;
+ uint16_t nsmap[MAXNS];
+ int nssocks[MAXNS];
+ uint16_t nscount6;
+ uint16_t nsinit;
+ struct sockaddr_in6* nsaddrs[MAXNS];
+ unsigned int _initstamp[2];
+ } _ext;
+ } _u;
} * res_state;
#define __RES 19991006
@@ -67,9 +68,9 @@
#endif
struct res_sym {
- int number;
- char* name;
- char* humanname;
+ int number;
+ char* name;
+ char* humanname;
};
#define RES_F_VC 0x00000001
@@ -138,3 +139,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_RESOLV_H_
diff --git a/arch/arm64/sysroot/include/sched.h b/arch/arm64/sysroot/include/sched.h
index f77dff7..ac06166 100644
--- a/arch/arm64/sysroot/include/sched.h
+++ b/arch/arm64/sysroot/include/sched.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SCHED_H_
+#define SYSROOT_SCHED_H_
#ifdef __cplusplus
extern "C" {
@@ -17,11 +18,11 @@
#include <bits/alltypes.h>
struct sched_param {
- int sched_priority;
- int sched_ss_low_priority;
- struct timespec sched_ss_repl_period;
- struct timespec sched_ss_init_budget;
- int sched_ss_max_repl;
+ int sched_priority;
+ int sched_ss_low_priority;
+ struct timespec sched_ss_repl_period;
+ struct timespec sched_ss_init_budget;
+ int sched_ss_max_repl;
};
int sched_get_priority_max(int);
@@ -47,28 +48,30 @@
void* calloc(size_t, size_t);
void free(void*);
-typedef struct cpu_set_t { unsigned long __bits[128 / sizeof(long)]; } cpu_set_t;
+typedef struct cpu_set_t {
+ unsigned long __bits[128 / sizeof(long)];
+} cpu_set_t;
int __sched_cpucount(size_t, const cpu_set_t*);
int sched_getcpu(void);
int sched_getaffinity(pid_t, size_t, cpu_set_t*);
int sched_setaffinity(pid_t, size_t, const cpu_set_t*);
#define __CPU_op_S(i, size, set, op) \
- ((i) / 8U >= (size) \
- ? 0 \
- : ((set)->__bits[(i) / 8 / sizeof(long)] op(1UL << ((i) % (8 * sizeof(long))))))
+ ((i) / 8U >= (size) \
+ ? 0 \
+ : ((set)->__bits[(i) / 8 / sizeof(long)] op(1UL << ((i) % (8 * sizeof(long))))))
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &= ~)
#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
-#define __CPU_op_func_S(func, op) \
- static __inline void __CPU_##func##_S(size_t __size, cpu_set_t* __dest, \
- const cpu_set_t* __src1, const cpu_set_t* __src2) { \
- size_t __i; \
- for (__i = 0; __i < __size / sizeof(long); __i++) \
- __dest->__bits[__i] = __src1->__bits[__i] op __src2->__bits[__i]; \
- }
+#define __CPU_op_func_S(func, op) \
+ static __inline void __CPU_##func##_S(size_t __size, cpu_set_t* __dest, const cpu_set_t* __src1, \
+ const cpu_set_t* __src2) { \
+ size_t __i; \
+ for (__i = 0; __i < __size / sizeof(long); __i++) \
+ __dest->__bits[__i] = __src1->__bits[__i] op __src2->__bits[__i]; \
+ }
__CPU_op_func_S(AND, &) __CPU_op_func_S(OR, |) __CPU_op_func_S(XOR, ^)
@@ -80,9 +83,9 @@
#define CPU_ZERO_S(size, set) memset(set, 0, size)
#define CPU_EQUAL_S(size, set1, set2) (!memcmp(set1, set2, size))
-#define CPU_ALLOC_SIZE(n) \
- (sizeof(long) * ((n) / (8 * sizeof(long)) + \
- ((n) % (8 * sizeof(long)) + 8 * sizeof(long) - 1) / (8 * sizeof(long))))
+#define CPU_ALLOC_SIZE(n) \
+ (sizeof(long) * ((n) / (8 * sizeof(long)) + \
+ ((n) % (8 * sizeof(long)) + 8 * sizeof(long) - 1) / (8 * sizeof(long))))
#define CPU_ALLOC(n) ((cpu_set_t*)calloc(1, CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)
@@ -103,3 +106,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SCHED_H_
diff --git a/arch/arm64/sysroot/include/search.h b/arch/arm64/sysroot/include/search.h
index eb50439..5348eab 100644
--- a/arch/arm64/sysroot/include/search.h
+++ b/arch/arm64/sysroot/include/search.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SEARCH_H_
+#define SYSROOT_SEARCH_H_
#ifdef __cplusplus
extern "C" {
@@ -9,16 +10,12 @@
#define __NEED_size_t
#include <bits/alltypes.h>
-typedef enum { FIND,
- ENTER } ACTION;
-typedef enum { preorder,
- postorder,
- endorder,
- leaf } VISIT;
+typedef enum { FIND, ENTER } ACTION;
+typedef enum { preorder, postorder, endorder, leaf } VISIT;
typedef struct entry {
- char* key;
- void* data;
+ char* key;
+ void* data;
} ENTRY;
int hcreate(size_t);
@@ -27,9 +24,9 @@
#ifdef _GNU_SOURCE
struct hsearch_data {
- struct __tab* __tab;
- unsigned int __unused1;
- unsigned int __unused2;
+ struct __tab* __tab;
+ unsigned int __unused1;
+ unsigned int __unused2;
};
int hcreate_r(size_t, struct hsearch_data*);
@@ -50,8 +47,8 @@
#ifdef _GNU_SOURCE
struct qelem {
- struct qelem *q_forw, *q_back;
- char q_data[1];
+ struct qelem *q_forw, *q_back;
+ char q_data[1];
};
void tdestroy(void*, void (*)(void*));
@@ -60,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SEARCH_H_
diff --git a/arch/arm64/sysroot/include/semaphore.h b/arch/arm64/sysroot/include/semaphore.h
index e4bf7a8..d9e996e 100644
--- a/arch/arm64/sysroot/include/semaphore.h
+++ b/arch/arm64/sysroot/include/semaphore.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SEMAPHORE_H_
+#define SYSROOT_SEMAPHORE_H_
#ifdef __cplusplus
extern "C" {
@@ -9,10 +10,10 @@
#define __NEED_sem_t
#define __NEED_time_t
#define __NEED_struct_timespec
-#include <bits/alltypes.h>
-
#include <fcntl.h>
+#include <bits/alltypes.h>
+
#define SEM_FAILED ((sem_t*)0)
int sem_close(sem_t*);
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SEMAPHORE_H_
diff --git a/arch/arm64/sysroot/include/setjmp.h b/arch/arm64/sysroot/include/setjmp.h
index eaceeca..65971b7 100644
--- a/arch/arm64/sysroot/include/setjmp.h
+++ b/arch/arm64/sysroot/include/setjmp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SETJMP_H_
+#define SYSROOT_SETJMP_H_
#ifdef __cplusplus
extern "C" {
@@ -9,9 +10,9 @@
#include <bits/setjmp.h>
typedef struct __jmp_buf_tag {
- __jmp_buf __jb;
- unsigned long __fl;
- unsigned long __ss[128 / sizeof(long)];
+ __jmp_buf __jb;
+ unsigned long __fl;
+ unsigned long __ss[128 / sizeof(long)];
} jmp_buf[1];
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
@@ -34,3 +35,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SETJMP_H_
diff --git a/arch/arm64/sysroot/include/signal.h b/arch/arm64/sysroot/include/signal.h
index b26c9b0..594cf80 100644
--- a/arch/arm64/sysroot/include/signal.h
+++ b/arch/arm64/sysroot/include/signal.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SIGNAL_H_
+#define SYSROOT_SIGNAL_H_
#ifdef __cplusplus
extern "C" {
@@ -86,55 +87,55 @@
#define CLD_CONTINUED 6
union sigval {
- int sival_int;
- void* sival_ptr;
+ int sival_int;
+ void* sival_ptr;
};
typedef struct {
#ifdef __SI_SWAP_ERRNO_CODE
- int si_signo, si_code, si_errno;
+ int si_signo, si_code, si_errno;
#else
- int si_signo, si_errno, si_code;
+ int si_signo, si_errno, si_code;
#endif
- union {
- char __pad[128 - 2 * sizeof(int) - sizeof(long)];
+ union {
+ char __pad[128 - 2 * sizeof(int) - sizeof(long)];
+ struct {
+ union {
struct {
- union {
- struct {
- pid_t si_pid;
- uid_t si_uid;
- } __piduid;
- struct {
- int si_timerid;
- int si_overrun;
- } __timer;
- } __first;
- union {
- union sigval si_value;
- struct {
- int si_status;
- clock_t si_utime, si_stime;
- } __sigchld;
- } __second;
- } __si_common;
+ pid_t si_pid;
+ uid_t si_uid;
+ } __piduid;
struct {
- void* si_addr;
- short si_addr_lsb;
- struct {
- void* si_lower;
- void* si_upper;
- } __addr_bnd;
- } __sigfault;
+ int si_timerid;
+ int si_overrun;
+ } __timer;
+ } __first;
+ union {
+ union sigval si_value;
struct {
- long si_band;
- int si_fd;
- } __sigpoll;
- struct {
- void* si_call_addr;
- int si_syscall;
- unsigned si_arch;
- } __sigsys;
- } __si_fields;
+ int si_status;
+ clock_t si_utime, si_stime;
+ } __sigchld;
+ } __second;
+ } __si_common;
+ struct {
+ void* si_addr;
+ short si_addr_lsb;
+ struct {
+ void* si_lower;
+ void* si_upper;
+ } __addr_bnd;
+ } __sigfault;
+ struct {
+ long si_band;
+ int si_fd;
+ } __sigpoll;
+ struct {
+ void* si_call_addr;
+ int si_syscall;
+ unsigned si_arch;
+ } __sigsys;
+ } __si_fields;
} siginfo_t;
#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
@@ -157,24 +158,24 @@
#define si_arch __si_fields.__sigsys.si_arch
struct sigaction {
- union {
- void (*sa_handler)(int);
- void (*sa_sigaction)(int, siginfo_t*, void*);
- } __sa_handler;
- sigset_t sa_mask;
- int sa_flags;
- void (*sa_restorer)(void);
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t*, void*);
+ } __sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
};
#define sa_handler __sa_handler.sa_handler
#define sa_sigaction __sa_handler.sa_sigaction
struct sigevent {
- union sigval sigev_value;
- int sigev_signo;
- int sigev_notify;
- void (*sigev_notify_function)(union sigval);
- pthread_attr_t* sigev_notify_attributes;
- char __pad[56 - 3 * sizeof(long)];
+ union sigval sigev_value;
+ int sigev_signo;
+ int sigev_notify;
+ void (*sigev_notify_function)(union sigval);
+ pthread_attr_t* sigev_notify_attributes;
+ char __pad[56 - 3 * sizeof(long)];
};
#define SIGEV_SIGNAL 0
@@ -258,3 +259,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SIGNAL_H_
diff --git a/arch/arm64/sysroot/include/spawn.h b/arch/arm64/sysroot/include/spawn.h
index 74710cb..1c70bb2 100644
--- a/arch/arm64/sysroot/include/spawn.h
+++ b/arch/arm64/sysroot/include/spawn.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SPAWN_H_
+#define SYSROOT_SPAWN_H_
#ifdef __cplusplus
extern "C" {
@@ -22,16 +23,16 @@
#define POSIX_SPAWN_SETSCHEDULER 32
typedef struct {
- int __flags;
- pid_t __pgrp;
- sigset_t __def, __mask;
- int __prio, __pol, __pad[16];
+ int __flags;
+ pid_t __pgrp;
+ sigset_t __def, __mask;
+ int __prio, __pol, __pad[16];
} posix_spawnattr_t;
typedef struct {
- int __pad0[2];
- void* __actions;
- int __pad[16];
+ int __pad0[2];
+ void* __actions;
+ int __pad[16];
} posix_spawn_file_actions_t;
int posix_spawn(pid_t* __restrict, const char* __restrict, const posix_spawn_file_actions_t*,
@@ -74,3 +75,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SPAWN_H_
diff --git a/arch/arm64/sysroot/include/stdio.h b/arch/arm64/sysroot/include/stdio.h
index fde69be..c08aba0 100644
--- a/arch/arm64/sysroot/include/stdio.h
+++ b/arch/arm64/sysroot/include/stdio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STDIO_H_
+#define SYSROOT_STDIO_H_
#ifdef __cplusplus
extern "C" {
@@ -44,8 +45,8 @@
#define L_tmpnam 20
typedef union _G_fpos64_t {
- char __opaque[16];
- double __align;
+ char __opaque[16];
+ double __align;
} fpos_t;
extern FILE* const stdin;
@@ -180,3 +181,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STDIO_H_
diff --git a/arch/arm64/sysroot/include/stdlib.h b/arch/arm64/sysroot/include/stdlib.h
index 0c29b16..862c83f 100644
--- a/arch/arm64/sysroot/include/stdlib.h
+++ b/arch/arm64/sysroot/include/stdlib.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_STDLIB_H_
+#define SYSROOT_STDLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -53,9 +55,15 @@
long labs(long);
long long llabs(long long);
-typedef struct { int quot, rem; } div_t;
-typedef struct { long quot, rem; } ldiv_t;
-typedef struct { long long quot, rem; } lldiv_t;
+typedef struct {
+ int quot, rem;
+} div_t;
+typedef struct {
+ long quot, rem;
+} ldiv_t;
+typedef struct {
+ long long quot, rem;
+} lldiv_t;
div_t div(int, int);
ldiv_t ldiv(long, long);
@@ -110,7 +118,6 @@
int grantpt(int);
int unlockpt(int);
char* ptsname(int);
-char* l64a(long);
long a64l(const char*);
void setkey(const char*);
double drand48(void);
@@ -146,3 +153,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STDLIB_H_
diff --git a/arch/arm64/sysroot/include/stdnoreturn.h b/arch/arm64/sysroot/include/stdnoreturn.h
deleted file mode 100644
index 574bcca..0000000
--- a/arch/arm64/sysroot/include/stdnoreturn.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#ifndef __cplusplus
-#include <features.h>
-#define noreturn _Noreturn
-#endif
diff --git a/arch/arm64/sysroot/include/string.h b/arch/arm64/sysroot/include/string.h
index d7ea6bb..0265b57 100644
--- a/arch/arm64/sysroot/include/string.h
+++ b/arch/arm64/sysroot/include/string.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_STRING_H_
+#define SYSROOT_STRING_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -84,3 +86,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STRING_H_
diff --git a/arch/arm64/sysroot/include/strings.h b/arch/arm64/sysroot/include/strings.h
index 343f31a..eb703d1 100644
--- a/arch/arm64/sysroot/include/strings.h
+++ b/arch/arm64/sysroot/include/strings.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STRINGS_H_
+#define SYSROOT_STRINGS_H_
#ifdef __cplusplus
extern "C" {
@@ -33,3 +34,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STRINGS_H_
diff --git a/arch/arm64/sysroot/include/stropts.h b/arch/arm64/sysroot/include/stropts.h
index c2e6b7f..92eb968 100644
--- a/arch/arm64/sysroot/include/stropts.h
+++ b/arch/arm64/sysroot/include/stropts.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STROPTS_H_
+#define SYSROOT_STROPTS_H_
#ifdef __cplusplus
extern "C" {
@@ -81,51 +82,51 @@
#define MOREDATA 2
struct bandinfo {
- unsigned char bi_pri;
- int bi_flag;
+ unsigned char bi_pri;
+ int bi_flag;
};
struct strbuf {
- int maxlen;
- int len;
- char* buf;
+ int maxlen;
+ int len;
+ char* buf;
};
struct strpeek {
- struct strbuf ctlbuf;
- struct strbuf databuf;
- unsigned flags;
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
};
struct strfdinsert {
- struct strbuf ctlbuf;
- struct strbuf databuf;
- unsigned flags;
- int fildes;
- int offset;
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
+ int fildes;
+ int offset;
};
struct strioctl {
- int ic_cmd;
- int ic_timout;
- int ic_len;
- char* ic_dp;
+ int ic_cmd;
+ int ic_timout;
+ int ic_len;
+ char* ic_dp;
};
struct strrecvfd {
- int fd;
- int uid;
- int gid;
- char __fill[8];
+ int fd;
+ int uid;
+ int gid;
+ char __fill[8];
};
struct str_mlist {
- char l_name[FMNAMESZ + 1];
+ char l_name[FMNAMESZ + 1];
};
struct str_list {
- int sl_nmods;
- struct str_mlist* sl_modlist;
+ int sl_nmods;
+ struct str_mlist* sl_modlist;
};
int isastream(int);
@@ -134,3 +135,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STROPTS_H_
diff --git a/arch/arm64/sysroot/include/sys/acct.h b/arch/arm64/sysroot/include/sys/acct.h
index be32528..8561ad0 100644
--- a/arch/arm64/sysroot/include/sys/acct.h
+++ b/arch/arm64/sysroot/include/sys/acct.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_ACCT_H_
+#define SYSROOT_SYS_ACCT_H_
#ifdef __cplusplus
extern "C" {
@@ -14,45 +15,45 @@
typedef uint16_t comp_t;
struct acct {
- char ac_flag;
- uint16_t ac_uid;
- uint16_t ac_gid;
- uint16_t ac_tty;
- uint32_t ac_btime;
- comp_t ac_utime;
- comp_t ac_stime;
- comp_t ac_etime;
- comp_t ac_mem;
- comp_t ac_io;
- comp_t ac_rw;
- comp_t ac_minflt;
- comp_t ac_majflt;
- comp_t ac_swaps;
- uint32_t ac_exitcode;
- char ac_comm[ACCT_COMM + 1];
- char ac_pad[10];
+ char ac_flag;
+ uint16_t ac_uid;
+ uint16_t ac_gid;
+ uint16_t ac_tty;
+ uint32_t ac_btime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_etime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ uint32_t ac_exitcode;
+ char ac_comm[ACCT_COMM + 1];
+ char ac_pad[10];
};
struct acct_v3 {
- char ac_flag;
- char ac_version;
- uint16_t ac_tty;
- uint32_t ac_exitcode;
- uint32_t ac_uid;
- uint32_t ac_gid;
- uint32_t ac_pid;
- uint32_t ac_ppid;
- uint32_t ac_btime;
- float ac_etime;
- comp_t ac_utime;
- comp_t ac_stime;
- comp_t ac_mem;
- comp_t ac_io;
- comp_t ac_rw;
- comp_t ac_minflt;
- comp_t ac_majflt;
- comp_t ac_swaps;
- char ac_comm[ACCT_COMM];
+ char ac_flag;
+ char ac_version;
+ uint16_t ac_tty;
+ uint32_t ac_exitcode;
+ uint32_t ac_uid;
+ uint32_t ac_gid;
+ uint32_t ac_pid;
+ uint32_t ac_ppid;
+ uint32_t ac_btime;
+ float ac_etime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ char ac_comm[ACCT_COMM];
};
#define AFORK 1
@@ -67,3 +68,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_ACCT_H_
diff --git a/arch/arm64/sysroot/include/sys/auxv.h b/arch/arm64/sysroot/include/sys/auxv.h
index 72d5de9..61ddea0 100644
--- a/arch/arm64/sysroot/include/sys/auxv.h
+++ b/arch/arm64/sysroot/include/sys/auxv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_AUXV_H_
+#define SYSROOT_SYS_AUXV_H_
#ifdef __cplusplus
extern "C" {
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_AUXV_H_
diff --git a/arch/arm64/sysroot/include/sys/eventfd.h b/arch/arm64/sysroot/include/sys/eventfd.h
index c22369e..4259bac 100644
--- a/arch/arm64/sysroot/include/sys/eventfd.h
+++ b/arch/arm64/sysroot/include/sys/eventfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_EVENTFD_H_
+#define SYSROOT_SYS_EVENTFD_H_
#ifdef __cplusplus
extern "C" {
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_EVENTFD_H_
diff --git a/arch/arm64/sysroot/include/sys/file.h b/arch/arm64/sysroot/include/sys/file.h
index c32fcb8..fe17290 100644
--- a/arch/arm64/sysroot/include/sys/file.h
+++ b/arch/arm64/sysroot/include/sys/file.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_FILE_H_
+#define SYSROOT_SYS_FILE_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_FILE_H_
diff --git a/arch/arm64/sysroot/include/sys/fsuid.h b/arch/arm64/sysroot/include/sys/fsuid.h
index 29ea02b..a9f654c 100644
--- a/arch/arm64/sysroot/include/sys/fsuid.h
+++ b/arch/arm64/sysroot/include/sys/fsuid.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_FSUID_H_
+#define SYSROOT_SYS_FSUID_H_
#ifdef __cplusplus
extern "C" {
@@ -15,3 +16,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_FSUID_H_
diff --git a/arch/arm64/sysroot/include/sys/io.h b/arch/arm64/sysroot/include/sys/io.h
index f5013a2..89617e5 100644
--- a/arch/arm64/sysroot/include/sys/io.h
+++ b/arch/arm64/sysroot/include/sys/io.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IO_H_
+#define SYSROOT_SYS_IO_H_
#ifdef __cplusplus
extern "C" {
@@ -14,3 +15,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IO_H_
diff --git a/arch/arm64/sysroot/include/sys/ioctl.h b/arch/arm64/sysroot/include/sys/ioctl.h
index c782d2e..ad22a3b 100644
--- a/arch/arm64/sysroot/include/sys/ioctl.h
+++ b/arch/arm64/sysroot/include/sys/ioctl.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IOCTL_H_
+#define SYSROOT_SYS_IOCTL_H_
#ifdef __cplusplus
extern "C" {
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IOCTL_H_
diff --git a/arch/arm64/sysroot/include/sys/ipc.h b/arch/arm64/sysroot/include/sys/ipc.h
index a3a380c..5d019f4 100644
--- a/arch/arm64/sysroot/include/sys/ipc.h
+++ b/arch/arm64/sysroot/include/sys/ipc.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IPC_H_
+#define SYSROOT_SYS_IPC_H_
#ifdef __cplusplus
extern "C" {
@@ -39,3 +40,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IPC_H_
diff --git a/arch/arm64/sysroot/include/sys/klog.h b/arch/arm64/sysroot/include/sys/klog.h
index ccde5e8..b182302 100644
--- a/arch/arm64/sysroot/include/sys/klog.h
+++ b/arch/arm64/sysroot/include/sys/klog.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_KLOG_H_
+#define SYSROOT_SYS_KLOG_H_
#ifdef __cplusplus
extern "C" {
@@ -9,3 +10,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_KLOG_H_
diff --git a/arch/arm64/sysroot/include/sys/mman.h b/arch/arm64/sysroot/include/sys/mman.h
index c5ff3bf..7a913ae 100644
--- a/arch/arm64/sysroot/include/sys/mman.h
+++ b/arch/arm64/sysroot/include/sys/mman.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MMAN_H_
+#define SYSROOT_SYS_MMAN_H_
#ifdef __cplusplus
extern "C" {
@@ -29,6 +30,7 @@
#define MAP_NONBLOCK 0x10000
#define MAP_STACK 0x20000
#define MAP_HUGETLB 0x40000
+#define MAP_JIT 0x80000
#define MAP_FILE 0
#define PROT_NONE 0
@@ -96,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MMAN_H_
diff --git a/arch/arm64/sysroot/include/sys/mount.h b/arch/arm64/sysroot/include/sys/mount.h
index 9d3394b..53181ea 100644
--- a/arch/arm64/sysroot/include/sys/mount.h
+++ b/arch/arm64/sysroot/include/sys/mount.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MOUNT_H_
+#define SYSROOT_SYS_MOUNT_H_
#ifdef __cplusplus
extern "C" {
@@ -68,3 +69,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MOUNT_H_
diff --git a/arch/arm64/sysroot/include/sys/msg.h b/arch/arm64/sysroot/include/sys/msg.h
index 6d08dad..be0114b 100644
--- a/arch/arm64/sysroot/include/sys/msg.h
+++ b/arch/arm64/sysroot/include/sys/msg.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MSG_H_
+#define SYSROOT_SYS_MSG_H_
#ifdef __cplusplus
extern "C" {
@@ -28,8 +29,8 @@
#define MSG_INFO 12
struct msginfo {
- int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
- unsigned short msgseg;
+ int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
+ unsigned short msgseg;
};
int msgctl(int, int, struct msqid_ds*);
@@ -39,11 +40,13 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
struct msgbuf {
- long mtype;
- char mtext[1];
+ long mtype;
+ char mtext[1];
};
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MSG_H_
diff --git a/arch/arm64/sysroot/include/sys/mtio.h b/arch/arm64/sysroot/include/sys/mtio.h
index 2f4cf9a..3d9f753 100644
--- a/arch/arm64/sysroot/include/sys/mtio.h
+++ b/arch/arm64/sysroot/include/sys/mtio.h
@@ -1,11 +1,12 @@
-#pragma once
+#ifndef SYSROOT_SYS_MTIO_H_
+#define SYSROOT_SYS_MTIO_H_
#include <sys/ioctl.h>
#include <sys/types.h>
struct mtop {
- short mt_op;
- int mt_count;
+ short mt_op;
+ int mt_count;
};
#define _IOT_mtop _IOT(_IOTS(short), 1, _IOTS(int), 1, 0, 0)
@@ -47,13 +48,13 @@
#define MTMKPART 34
struct mtget {
- long mt_type;
- long mt_resid;
- long mt_dsreg;
- long mt_gstat;
- long mt_erreg;
- int mt_fileno;
- int mt_blkno;
+ long mt_type;
+ long mt_resid;
+ long mt_dsreg;
+ long mt_gstat;
+ long mt_erreg;
+ int mt_fileno;
+ int mt_blkno;
};
#define MT_ISUNKNOWN 0x01
@@ -78,53 +79,51 @@
#define MT_ISFTAPE_FLAG 0x800000
struct mt_tape_info {
- long t_type;
- char* t_name;
+ long t_type;
+ char* t_name;
};
#define MT_TAPE_INFO \
- { \
- {MT_ISUNKNOWN, "Unknown type of tape device"}, \
- {MT_ISQIC02, "Generic QIC-02 tape streamer"}, {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
- {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, {MT_ISCMSJ500, "CMS Jumbo 500"}, \
- {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
- {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
- {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
- {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
- {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
- {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
- {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
- {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
- {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
- {MT_ISSCSI2, "Generic SCSI-2 tape"}, { \
- 0, 0 \
- } \
- }
+ { \
+ {MT_ISUNKNOWN, "Unknown type of tape device"}, {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
+ {MT_ISWT5150, "Wangtek 5150, QIC-150"}, {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
+ {MT_ISCMSJ500, "CMS Jumbo 500"}, {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
+ {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
+ {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
+ {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
+ {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
+ {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
+ {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
+ {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
+ {MT_ISSCSI2, "Generic SCSI-2 tape"}, { \
+ 0, 0 \
+ } \
+ }
struct mtpos {
- long mt_blkno;
+ long mt_blkno;
};
struct mtconfiginfo {
- long mt_type;
- long ifc_type;
- unsigned short irqnr;
- unsigned short dmanr;
- unsigned short port;
- unsigned long debug;
- unsigned have_dens : 1;
- unsigned have_bsf : 1;
- unsigned have_fsr : 1;
- unsigned have_bsr : 1;
- unsigned have_eod : 1;
- unsigned have_seek : 1;
- unsigned have_tell : 1;
- unsigned have_ras1 : 1;
- unsigned have_ras2 : 1;
- unsigned have_ras3 : 1;
- unsigned have_qfa : 1;
- unsigned pad1 : 5;
- char reserved[10];
+ long mt_type;
+ long ifc_type;
+ unsigned short irqnr;
+ unsigned short dmanr;
+ unsigned short port;
+ unsigned long debug;
+ unsigned have_dens : 1;
+ unsigned have_bsf : 1;
+ unsigned have_fsr : 1;
+ unsigned have_bsr : 1;
+ unsigned have_eod : 1;
+ unsigned have_seek : 1;
+ unsigned have_tell : 1;
+ unsigned have_ras1 : 1;
+ unsigned have_ras2 : 1;
+ unsigned have_ras3 : 1;
+ unsigned have_qfa : 1;
+ unsigned pad1 : 5;
+ char reserved[10];
};
#define MTIOCTOP _IOW('m', 1, struct mtop)
@@ -180,3 +179,5 @@
#ifndef DEFTAPE
#define DEFTAPE "/dev/tape"
#endif
+
+#endif // SYSROOT_SYS_MTIO_H_
diff --git a/arch/arm64/sysroot/include/sys/param.h b/arch/arm64/sysroot/include/sys/param.h
index 64989a4..301bba7 100644
--- a/arch/arm64/sysroot/include/sys/param.h
+++ b/arch/arm64/sysroot/include/sys/param.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_PARAM_H_
+#define SYSROOT_SYS_PARAM_H_
#define MAXSYMLINKS 20
#define MAXHOSTNAMELEN 64
@@ -29,3 +30,5 @@
#include <endian.h>
#include <limits.h>
+
+#endif // SYSROOT_SYS_PARAM_H_
diff --git a/arch/arm64/sysroot/include/sys/personality.h b/arch/arm64/sysroot/include/sys/personality.h
index 3da0e20..b32d1eb 100644
--- a/arch/arm64/sysroot/include/sys/personality.h
+++ b/arch/arm64/sysroot/include/sys/personality.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_PERSONALITY_H_
+#define SYSROOT_SYS_PERSONALITY_H_
#ifdef __cplusplus
extern "C" {
@@ -42,3 +43,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_PERSONALITY_H_
diff --git a/arch/arm64/sysroot/include/sys/quota.h b/arch/arm64/sysroot/include/sys/quota.h
index ae2e194..aec5dc9 100644
--- a/arch/arm64/sysroot/include/sys/quota.h
+++ b/arch/arm64/sysroot/include/sys/quota.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_QUOTA_H_
+#define SYSROOT_SYS_QUOTA_H_
#ifdef __cplusplus
extern "C" {
@@ -57,15 +58,15 @@
#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
struct dqblk {
- uint64_t dqb_bhardlimit;
- uint64_t dqb_bsoftlimit;
- uint64_t dqb_curspace;
- uint64_t dqb_ihardlimit;
- uint64_t dqb_isoftlimit;
- uint64_t dqb_curinodes;
- uint64_t dqb_btime;
- uint64_t dqb_itime;
- uint32_t dqb_valid;
+ uint64_t dqb_bhardlimit;
+ uint64_t dqb_bsoftlimit;
+ uint64_t dqb_curspace;
+ uint64_t dqb_ihardlimit;
+ uint64_t dqb_isoftlimit;
+ uint64_t dqb_curinodes;
+ uint64_t dqb_btime;
+ uint64_t dqb_itime;
+ uint32_t dqb_valid;
};
#define dq_bhardlimit dq_dqb.dqb_bhardlimit
@@ -86,10 +87,10 @@
#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
struct dqinfo {
- uint64_t dqi_bgrace;
- uint64_t dqi_igrace;
- uint32_t dqi_flags;
- uint32_t dqi_valid;
+ uint64_t dqi_bgrace;
+ uint64_t dqi_igrace;
+ uint32_t dqi_flags;
+ uint32_t dqi_valid;
};
int quotactl(int, const char*, int, char*);
@@ -97,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_QUOTA_H_
diff --git a/arch/arm64/sysroot/include/sys/random.h b/arch/arm64/sysroot/include/sys/random.h
index 080c3b4..258201d 100644
--- a/arch/arm64/sysroot/include/sys/random.h
+++ b/arch/arm64/sysroot/include/sys/random.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_RANDOM_H_
+#define SYSROOT_SYS_RANDOM_H_
#include <stddef.h>
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_RANDOM_H_
diff --git a/arch/arm64/sysroot/include/sys/reboot.h b/arch/arm64/sysroot/include/sys/reboot.h
index f28375d..a83629c 100644
--- a/arch/arm64/sysroot/include/sys/reboot.h
+++ b/arch/arm64/sysroot/include/sys/reboot.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_REBOOT_H_
+#define SYSROOT_SYS_REBOOT_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_REBOOT_H_
diff --git a/arch/arm64/sysroot/include/sys/reg.h b/arch/arm64/sysroot/include/sys/reg.h
index 22a9caa..0f37ffe 100644
--- a/arch/arm64/sysroot/include/sys/reg.h
+++ b/arch/arm64/sysroot/include/sys/reg.h
@@ -1,6 +1,9 @@
-#pragma once
+#ifndef SYSROOT_SYS_REG_H_
+#define SYSROOT_SYS_REG_H_
#include <limits.h>
#include <unistd.h>
#include <bits/reg.h>
+
+#endif // SYSROOT_SYS_REG_H_
diff --git a/arch/arm64/sysroot/include/sys/select.h b/arch/arm64/sysroot/include/sys/select.h
index 25197d8..5d4fd7d 100644
--- a/arch/arm64/sysroot/include/sys/select.h
+++ b/arch/arm64/sysroot/include/sys/select.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SELECT_H_
+#define SYSROOT_SYS_SELECT_H_
#ifdef __cplusplus
extern "C" {
@@ -19,21 +20,23 @@
typedef unsigned long fd_mask;
-typedef struct { unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)]; } fd_set;
+typedef struct {
+ unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
+} fd_set;
-#define FD_ZERO(s) \
- do { \
- int __i; \
- unsigned long* __b = (s)->fds_bits; \
- for (__i = sizeof(fd_set) / sizeof(long); __i; __i--) \
- *__b++ = 0; \
- } while (0)
+#define FD_ZERO(s) \
+ do { \
+ int __i; \
+ unsigned long* __b = (s)->fds_bits; \
+ for (__i = sizeof(fd_set) / sizeof(long); __i; __i--) \
+ *__b++ = 0; \
+ } while (0)
#define FD_SET(d, s) \
- ((s)->fds_bits[(d) / (8 * sizeof(long))] |= (1UL << ((d) % (8 * sizeof(long)))))
+ ((s)->fds_bits[(d) / (8 * sizeof(long))] |= (1UL << ((d) % (8 * sizeof(long)))))
#define FD_CLR(d, s) \
- ((s)->fds_bits[(d) / (8 * sizeof(long))] &= ~(1UL << ((d) % (8 * sizeof(long)))))
+ ((s)->fds_bits[(d) / (8 * sizeof(long))] &= ~(1UL << ((d) % (8 * sizeof(long)))))
#define FD_ISSET(d, s) \
- !!((s)->fds_bits[(d) / (8 * sizeof(long))] & (1UL << ((d) % (8 * sizeof(long)))))
+ !!((s)->fds_bits[(d) / (8 * sizeof(long))] & (1UL << ((d) % (8 * sizeof(long)))))
int select(int, fd_set* __restrict, fd_set* __restrict, fd_set* __restrict,
struct timeval* __restrict);
@@ -47,3 +50,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SELECT_H_
diff --git a/arch/arm64/sysroot/include/sys/sem.h b/arch/arm64/sysroot/include/sys/sem.h
index 864161f..a4330af 100644
--- a/arch/arm64/sysroot/include/sys/sem.h
+++ b/arch/arm64/sysroot/include/sys/sem.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SEM_H_
+#define SYSROOT_SYS_SEM_H_
#ifdef __cplusplus
extern "C" {
@@ -12,10 +13,10 @@
#ifdef _GNU_SOURCE
#define __NEED_struct_timespec
#endif
-#include <bits/alltypes.h>
-
#include <sys/ipc.h>
+#include <bits/alltypes.h>
+
#define SEM_UNDO 0x1000
#define GETPID 11
#define GETVAL 12
@@ -35,22 +36,22 @@
#define SEM_INFO 19
struct seminfo {
- int semmap;
- int semmni;
- int semmns;
- int semmnu;
- int semmsl;
- int semopm;
- int semume;
- int semusz;
- int semvzx;
- int semaem;
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvzx;
+ int semaem;
};
struct sembuf {
- unsigned short sem_num;
- short sem_op;
- short sem_flg;
+ unsigned short sem_num;
+ short sem_op;
+ short sem_flg;
};
int semctl(int, int, int, ...);
@@ -64,3 +65,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SEM_H_
diff --git a/arch/arm64/sysroot/include/sys/sendfile.h b/arch/arm64/sysroot/include/sys/sendfile.h
deleted file mode 100644
index 1c94a6b..0000000
--- a/arch/arm64/sysroot/include/sys/sendfile.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <features.h>
-#include <unistd.h>
-
-ssize_t sendfile(int, int, off_t*, size_t);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/arm64/sysroot/include/sys/shm.h b/arch/arm64/sysroot/include/sys/shm.h
index b4780d6..55b4389 100644
--- a/arch/arm64/sysroot/include/sys/shm.h
+++ b/arch/arm64/sysroot/include/sys/shm.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SHM_H_
+#define SYSROOT_SYS_SHM_H_
#ifdef __cplusplus
extern "C" {
@@ -10,10 +11,10 @@
#define __NEED_size_t
#define __NEED_pid_t
-#include <bits/alltypes.h>
-
#include <sys/ipc.h>
+#include <bits/alltypes.h>
+
#ifdef _GNU_SOURCE
#define __used_ids used_ids
#define __swap_attempts swap_attempts
@@ -49,3 +50,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SHM_H_
diff --git a/arch/arm64/sysroot/include/sys/signalfd.h b/arch/arm64/sysroot/include/sys/signalfd.h
index 832cc78..46a5489 100644
--- a/arch/arm64/sysroot/include/sys/signalfd.h
+++ b/arch/arm64/sysroot/include/sys/signalfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SIGNALFD_H_
+#define SYSROOT_SYS_SIGNALFD_H_
#ifdef __cplusplus
extern "C" {
@@ -17,26 +18,28 @@
int signalfd(int, const sigset_t*, int);
struct signalfd_siginfo {
- uint32_t ssi_signo;
- int32_t ssi_errno;
- int32_t ssi_code;
- uint32_t ssi_pid;
- uint32_t ssi_uid;
- int32_t ssi_fd;
- uint32_t ssi_tid;
- uint32_t ssi_band;
- uint32_t ssi_overrun;
- uint32_t ssi_trapno;
- int32_t ssi_status;
- int32_t ssi_int;
- uint64_t ssi_ptr;
- uint64_t ssi_utime;
- uint64_t ssi_stime;
- uint64_t ssi_addr;
- uint16_t ssi_addr_lsb;
- uint8_t pad[128 - 12 * 4 - 4 * 8 - 2];
+ uint32_t ssi_signo;
+ int32_t ssi_errno;
+ int32_t ssi_code;
+ uint32_t ssi_pid;
+ uint32_t ssi_uid;
+ int32_t ssi_fd;
+ uint32_t ssi_tid;
+ uint32_t ssi_band;
+ uint32_t ssi_overrun;
+ uint32_t ssi_trapno;
+ int32_t ssi_status;
+ int32_t ssi_int;
+ uint64_t ssi_ptr;
+ uint64_t ssi_utime;
+ uint64_t ssi_stime;
+ uint64_t ssi_addr;
+ uint16_t ssi_addr_lsb;
+ uint8_t pad[128 - 12 * 4 - 4 * 8 - 2];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SIGNALFD_H_
diff --git a/arch/arm64/sysroot/include/sys/socket.h b/arch/arm64/sysroot/include/sys/socket.h
index 10167be..7f68e6e 100644
--- a/arch/arm64/sysroot/include/sys/socket.h
+++ b/arch/arm64/sysroot/include/sys/socket.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SOCKET_H_
+#define SYSROOT_SYS_SOCKET_H_
#ifdef __cplusplus
extern "C" {
@@ -16,19 +17,18 @@
#define __NEED_struct_iovec
#include <bits/alltypes.h>
-
#include <bits/socket.h>
#ifdef _GNU_SOURCE
struct ucred {
- pid_t pid;
- uid_t uid;
- gid_t gid;
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
};
struct mmsghdr {
- struct msghdr msg_hdr;
- unsigned int msg_len;
+ struct msghdr msg_hdr;
+ unsigned int msg_len;
};
struct timespec;
@@ -38,8 +38,8 @@
#endif
struct linger {
- int l_onoff;
- int l_linger;
+ int l_onoff;
+ int l_linger;
};
#define SHUT_RD 0
@@ -260,16 +260,15 @@
#define __MHDR_END(mhdr) ((unsigned char*)(mhdr)->msg_control + (mhdr)->msg_controllen)
#define CMSG_DATA(cmsg) ((unsigned char*)(((struct cmsghdr*)(cmsg)) + 1))
-#define CMSG_NXTHDR(mhdr, cmsg) \
- ((cmsg)->cmsg_len < sizeof(struct cmsghdr) \
- ? (struct cmsghdr*)0 \
- : (__CMSG_NEXT(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) \
- ? (struct cmsghdr*)0 \
- : ((struct cmsghdr*)__CMSG_NEXT(cmsg))))
-#define CMSG_FIRSTHDR(mhdr) \
- ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \
- ? (struct cmsghdr*)(mhdr)->msg_control \
- : (struct cmsghdr*)0)
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ ((cmsg)->cmsg_len < sizeof(struct cmsghdr) \
+ ? (struct cmsghdr*)0 \
+ : (__CMSG_NEXT(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) \
+ ? (struct cmsghdr*)0 \
+ : ((struct cmsghdr*)__CMSG_NEXT(cmsg))))
+#define CMSG_FIRSTHDR(mhdr) \
+ ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? (struct cmsghdr*)(mhdr)->msg_control \
+ : (struct cmsghdr*)0)
#define CMSG_ALIGN(len) (((len) + sizeof(size_t) - 1) & (size_t) ~(sizeof(size_t) - 1))
#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
@@ -279,14 +278,14 @@
#define SCM_CREDENTIALS 0x02
struct sockaddr {
- sa_family_t sa_family;
- char sa_data[14];
+ sa_family_t sa_family;
+ char sa_data[14];
};
struct sockaddr_storage {
- sa_family_t ss_family;
- unsigned long __ss_align;
- char __ss_padding[128 - 2 * sizeof(unsigned long)];
+ sa_family_t ss_family;
+ unsigned long __ss_align;
+ char __ss_padding[128 - 2 * sizeof(unsigned long)];
};
int socket(int, int, int);
@@ -319,3 +318,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SOCKET_H_
diff --git a/arch/arm64/sysroot/include/sys/stat.h b/arch/arm64/sysroot/include/sys/stat.h
index 2be2ff5..d58e26c 100644
--- a/arch/arm64/sysroot/include/sys/stat.h
+++ b/arch/arm64/sysroot/include/sys/stat.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_STAT_H_
+#define SYSROOT_SYS_STAT_H_
#ifdef __cplusplus
extern "C" {
@@ -19,7 +20,6 @@
#define __NEED_struct_timespec
#include <bits/alltypes.h>
-
#include <bits/stat.h>
#define st_atime st_atim.tv_sec
@@ -98,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STAT_H_
diff --git a/arch/arm64/sysroot/include/sys/statfs.h b/arch/arm64/sysroot/include/sys/statfs.h
index c2a3d41..1459181 100644
--- a/arch/arm64/sysroot/include/sys/statfs.h
+++ b/arch/arm64/sysroot/include/sys/statfs.h
@@ -1,14 +1,16 @@
-#pragma once
+#ifndef SYSROOT_SYS_STATFS_H_
+#define SYSROOT_SYS_STATFS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <sys/statvfs.h>
-typedef struct __fsid_t { int __val[2]; } fsid_t;
+typedef struct __fsid_t {
+ int __val[2];
+} fsid_t;
#include <bits/statfs.h>
@@ -18,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STATFS_H_
diff --git a/arch/arm64/sysroot/include/sys/statvfs.h b/arch/arm64/sysroot/include/sys/statvfs.h
index 6031e66..0423246 100644
--- a/arch/arm64/sysroot/include/sys/statvfs.h
+++ b/arch/arm64/sysroot/include/sys/statvfs.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_STATVFS_H_
+#define SYSROOT_SYS_STATVFS_H_
#ifdef __cplusplus
extern "C" {
@@ -8,23 +9,23 @@
#define __NEED_fsblkcnt_t
#define __NEED_fsfilcnt_t
-#include <bits/alltypes.h>
-
#include <endian.h>
+#include <bits/alltypes.h>
+
struct statvfs {
- unsigned long f_bsize, f_frsize;
- fsblkcnt_t f_blocks, f_bfree, f_bavail;
- fsfilcnt_t f_files, f_ffree, f_favail;
+ unsigned long f_bsize, f_frsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree, f_favail;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned long f_fsid;
- unsigned : 8 * (2 * sizeof(int) - sizeof(long));
+ unsigned long f_fsid;
+ unsigned : 8 * (2 * sizeof(int) - sizeof(long));
#else
- unsigned : 8 * (2 * sizeof(int) - sizeof(long));
- unsigned long f_fsid;
+ unsigned : 8 * (2 * sizeof(int) - sizeof(long));
+ unsigned long f_fsid;
#endif
- unsigned long f_flag, f_namemax;
- int __reserved[6];
+ unsigned long f_flag, f_namemax;
+ int __reserved[6];
};
int statvfs(const char* __restrict, struct statvfs* __restrict);
@@ -45,3 +46,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STATVFS_H_
diff --git a/arch/arm64/sysroot/include/sys/swap.h b/arch/arm64/sysroot/include/sys/swap.h
index e9d516d..6420606 100644
--- a/arch/arm64/sysroot/include/sys/swap.h
+++ b/arch/arm64/sysroot/include/sys/swap.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SWAP_H_
+#define SYSROOT_SYS_SWAP_H_
#ifdef __cplusplus
extern "C" {
@@ -15,3 +16,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SWAP_H_
diff --git a/arch/arm64/sysroot/include/sys/time.h b/arch/arm64/sysroot/include/sys/time.h
index 81c410a..a9476c7 100644
--- a/arch/arm64/sysroot/include/sys/time.h
+++ b/arch/arm64/sysroot/include/sys/time.h
@@ -1,11 +1,11 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIME_H_
+#define SYSROOT_SYS_TIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <sys/select.h>
int gettimeofday(struct timeval* __restrict, void* __restrict);
@@ -17,8 +17,8 @@
#define ITIMER_PROF 2
struct itimerval {
- struct timeval it_interval;
- struct timeval it_value;
+ struct timeval it_interval;
+ struct timeval it_value;
};
int getitimer(int, struct itimerval*);
@@ -29,8 +29,8 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
+ int tz_minuteswest;
+ int tz_dsttime;
};
int futimes(int, const struct timeval[2]);
int futimesat(int, const char*, const struct timeval[2]);
@@ -40,24 +40,26 @@
#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
#define timercmp(s, t, op) \
- ((s)->tv_sec == (t)->tv_sec ? (s)->tv_usec op(t)->tv_usec : (s)->tv_sec op(t)->tv_sec)
-#define timeradd(s, t, a) \
- (void)((a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
- ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
- ((a)->tv_usec -= 1000000, (a)->tv_sec++))
-#define timersub(s, t, a) \
- (void)((a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
- ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
- ((a)->tv_usec += 1000000, (a)->tv_sec--))
+ ((s)->tv_sec == (t)->tv_sec ? (s)->tv_usec op(t)->tv_usec : (s)->tv_sec op(t)->tv_sec)
+#define timeradd(s, t, a) \
+ (void)((a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
+ ((a)->tv_usec -= 1000000, (a)->tv_sec++))
+#define timersub(s, t, a) \
+ (void)((a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
+ ((a)->tv_usec += 1000000, (a)->tv_sec--))
#endif
#if defined(_GNU_SOURCE)
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
- ((ts)->tv_sec = (tv)->tv_sec, (ts)->tv_nsec = (tv)->tv_usec * 1000, (void)0)
+ ((ts)->tv_sec = (tv)->tv_sec, (ts)->tv_nsec = (tv)->tv_usec * 1000, (void)0)
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
- ((tv)->tv_sec = (ts)->tv_sec, (tv)->tv_usec = (ts)->tv_nsec / 1000, (void)0)
+ ((tv)->tv_sec = (ts)->tv_sec, (tv)->tv_usec = (ts)->tv_nsec / 1000, (void)0)
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIME_H_
diff --git a/arch/arm64/sysroot/include/sys/timeb.h b/arch/arm64/sysroot/include/sys/timeb.h
index 560158b..bbb7e34 100644
--- a/arch/arm64/sysroot/include/sys/timeb.h
+++ b/arch/arm64/sysroot/include/sys/timeb.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMEB_H_
+#define SYSROOT_SYS_TIMEB_H_
#ifdef __cplusplus
extern "C" {
@@ -9,9 +10,9 @@
#include <bits/alltypes.h>
struct timeb {
- time_t time;
- unsigned short millitm;
- short timezone, dstflag;
+ time_t time;
+ unsigned short millitm;
+ short timezone, dstflag;
};
int ftime(struct timeb*);
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMEB_H_
diff --git a/arch/arm64/sysroot/include/sys/timerfd.h b/arch/arm64/sysroot/include/sys/timerfd.h
index c6b52b3..499a938 100644
--- a/arch/arm64/sysroot/include/sys/timerfd.h
+++ b/arch/arm64/sysroot/include/sys/timerfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMERFD_H_
+#define SYSROOT_SYS_TIMERFD_H_
#ifdef __cplusplus
extern "C" {
@@ -21,3 +22,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMERFD_H_
diff --git a/arch/arm64/sysroot/include/sys/times.h b/arch/arm64/sysroot/include/sys/times.h
index d573297..ec5d3d6 100644
--- a/arch/arm64/sysroot/include/sys/times.h
+++ b/arch/arm64/sysroot/include/sys/times.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMES_H_
+#define SYSROOT_SYS_TIMES_H_
#ifdef __cplusplus
extern "C" {
@@ -8,10 +9,10 @@
#include <bits/alltypes.h>
struct tms {
- clock_t tms_utime;
- clock_t tms_stime;
- clock_t tms_cutime;
- clock_t tms_cstime;
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
};
clock_t times(struct tms*);
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMES_H_
diff --git a/arch/arm64/sysroot/include/sys/timex.h b/arch/arm64/sysroot/include/sys/timex.h
index 8aa166e..9981c93 100644
--- a/arch/arm64/sysroot/include/sys/timex.h
+++ b/arch/arm64/sysroot/include/sys/timex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMEX_H_
+#define SYSROOT_SYS_TIMEX_H_
#ifdef __cplusplus
extern "C" {
@@ -6,26 +7,26 @@
#define __NEED_clockid_t
-#include <bits/alltypes.h>
-
#include <sys/time.h>
+#include <bits/alltypes.h>
+
struct ntptimeval {
- struct timeval time;
- long maxerror, esterror;
+ struct timeval time;
+ long maxerror, esterror;
};
struct timex {
- unsigned modes;
- long offset, freq, maxerror, esterror;
- int status;
- long constant, precision, tolerance;
- struct timeval time;
- long tick, ppsfreq, jitter;
- int shift;
- long stabil, jitcnt, calcnt, errcnt, stbcnt;
- int tai;
- int __padding[11];
+ unsigned modes;
+ long offset, freq, maxerror, esterror;
+ int status;
+ long constant, precision, tolerance;
+ struct timeval time;
+ long tick, ppsfreq, jitter;
+ int shift;
+ long stabil, jitcnt, calcnt, errcnt, stbcnt;
+ int tai;
+ int __padding[11];
};
#define ADJ_OFFSET 0x0001
@@ -74,9 +75,9 @@
#define STA_MODE 0x4000
#define STA_CLK 0x8000
-#define STA_RONLY \
- (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR | STA_CLOCKERR | STA_NANO | \
- STA_MODE | STA_CLK)
+#define STA_RONLY \
+ (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR | STA_CLOCKERR | STA_NANO | \
+ STA_MODE | STA_CLK)
#define TIME_OK 0
#define TIME_INS 1
@@ -94,3 +95,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMEX_H_
diff --git a/arch/arm64/sysroot/include/sys/ttydefaults.h b/arch/arm64/sysroot/include/sys/ttydefaults.h
index 742e3a9..e4994fe 100644
--- a/arch/arm64/sysroot/include/sys/ttydefaults.h
+++ b/arch/arm64/sysroot/include/sys/ttydefaults.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TTYDEFAULTS_H_
+#define SYSROOT_SYS_TTYDEFAULTS_H_
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
@@ -34,3 +35,5 @@
#define CBRK CEOL
#define CRPRNT CREPRINT
#define CFLUSH CDISCARD
+
+#endif // SYSROOT_SYS_TTYDEFAULTS_H_
diff --git a/arch/arm64/sysroot/include/sys/types.h b/arch/arm64/sysroot/include/sys/types.h
index b1c2a27..ea195a0 100644
--- a/arch/arm64/sysroot/include/sys/types.h
+++ b/arch/arm64/sysroot/include/sys/types.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TYPES_H_
+#define SYSROOT_SYS_TYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -71,3 +72,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TYPES_H_
diff --git a/arch/arm64/sysroot/include/sys/uio.h b/arch/arm64/sysroot/include/sys/uio.h
index e9f7b5d..4762083 100644
--- a/arch/arm64/sysroot/include/sys/uio.h
+++ b/arch/arm64/sysroot/include/sys/uio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_UIO_H_
+#define SYSROOT_SYS_UIO_H_
#ifdef __cplusplus
extern "C" {
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UIO_H_
diff --git a/arch/arm64/sysroot/include/sys/un.h b/arch/arm64/sysroot/include/sys/un.h
index 52bebd4..425c801 100644
--- a/arch/arm64/sysroot/include/sys/un.h
+++ b/arch/arm64/sysroot/include/sys/un.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_UN_H_
+#define SYSROOT_SYS_UN_H_
#ifdef __cplusplus
extern "C" {
@@ -14,8 +15,8 @@
#include <bits/alltypes.h>
struct sockaddr_un {
- sa_family_t sun_family;
- char sun_path[108];
+ sa_family_t sun_family;
+ char sun_path[108];
};
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -26,3 +27,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UN_H_
diff --git a/arch/arm64/sysroot/include/sys/utsname.h b/arch/arm64/sysroot/include/sys/utsname.h
index 0333c82..5d5fee1 100644
--- a/arch/arm64/sysroot/include/sys/utsname.h
+++ b/arch/arm64/sysroot/include/sys/utsname.h
@@ -1,21 +1,23 @@
-#pragma once
+#ifndef SYSROOT_SYS_UTSNAME_H_
+#define SYSROOT_SYS_UTSNAME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+#include <limits.h>
struct utsname {
- char sysname[65];
- char nodename[65];
- char release[65];
- char version[65];
- char machine[65];
+ char sysname[65];
+ char nodename[HOST_NAME_MAX + 1];
+ char release[65];
+ char version[65];
+ char machine[65];
#ifdef _GNU_SOURCE
- char domainname[65];
+ char domainname[65];
#else
- char __domainname[65];
+ char __domainname[65];
#endif
};
@@ -24,3 +26,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UTSNAME_H_
diff --git a/arch/arm64/sysroot/include/sys/wait.h b/arch/arm64/sysroot/include/sys/wait.h
index f31bb8e..3b33520 100644
--- a/arch/arm64/sysroot/include/sys/wait.h
+++ b/arch/arm64/sysroot/include/sys/wait.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_WAIT_H_
+#define SYSROOT_SYS_WAIT_H_
#ifdef __cplusplus
extern "C" {
@@ -10,9 +11,7 @@
#define __NEED_id_t
#include <bits/alltypes.h>
-typedef enum { P_ALL = 0,
- P_PID = 1,
- P_PGID = 2 } idtype_t;
+typedef enum { P_ALL = 0, P_PID = 1, P_PGID = 2 } idtype_t;
pid_t wait(int*);
pid_t waitpid(pid_t, int*, int);
@@ -43,3 +42,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_WAIT_H_
diff --git a/arch/arm64/sysroot/include/sysexits.h b/arch/arm64/sysroot/include/sysexits.h
index 82f672a..ca2782d 100644
--- a/arch/arm64/sysroot/include/sysexits.h
+++ b/arch/arm64/sysroot/include/sysexits.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYSEXITS_H_
+#define SYSROOT_SYSEXITS_H_
#define EX_OK 0
#define EX__BASE 64
@@ -18,3 +19,5 @@
#define EX_NOPERM 77
#define EX_CONFIG 78
#define EX__MAX 78
+
+#endif // SYSROOT_SYSEXITS_H_
diff --git a/arch/arm64/sysroot/include/syslog.h b/arch/arm64/sysroot/include/syslog.h
index 76fdce7..dcb09e3 100644
--- a/arch/arm64/sysroot/include/syslog.h
+++ b/arch/arm64/sysroot/include/syslog.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYSLOG_H_
+#define SYSROOT_SYSLOG_H_
#ifdef __cplusplus
extern "C" {
@@ -69,50 +70,52 @@
#define INTERNAL_NOPRI 0x10
#define INTERNAL_MARK (LOG_NFACILITIES << 3)
typedef struct {
- char* c_name;
- int c_val;
+ char* c_name;
+ int c_val;
} CODE;
-#define prioritynames \
- ((CODE*)(const CODE[]){{"alert", LOG_ALERT}, \
- {"crit", LOG_CRIT}, \
- {"debug", LOG_DEBUG}, \
- {"emerg", LOG_EMERG}, \
- {"err", LOG_ERR}, \
- {"error", LOG_ERR}, \
- {"info", LOG_INFO}, \
- {"none", INTERNAL_NOPRI}, \
- {"notice", LOG_NOTICE}, \
- {"panic", LOG_EMERG}, \
- {"warn", LOG_WARNING}, \
- {"warning", LOG_WARNING}, \
- {0, -1}})
-#define facilitynames \
- ((CODE*)(const CODE[]){{"auth", LOG_AUTH}, \
- {"authpriv", LOG_AUTHPRIV}, \
- {"cron", LOG_CRON}, \
- {"daemon", LOG_DAEMON}, \
- {"ftp", LOG_FTP}, \
- {"kern", LOG_KERN}, \
- {"lpr", LOG_LPR}, \
- {"mail", LOG_MAIL}, \
- {"mark", INTERNAL_MARK}, \
- {"news", LOG_NEWS}, \
- {"security", LOG_AUTH}, \
- {"syslog", LOG_SYSLOG}, \
- {"user", LOG_USER}, \
- {"uucp", LOG_UUCP}, \
- {"local0", LOG_LOCAL0}, \
- {"local1", LOG_LOCAL1}, \
- {"local2", LOG_LOCAL2}, \
- {"local3", LOG_LOCAL3}, \
- {"local4", LOG_LOCAL4}, \
- {"local5", LOG_LOCAL5}, \
- {"local6", LOG_LOCAL6}, \
- {"local7", LOG_LOCAL7}, \
- {0, -1}})
+#define prioritynames \
+ ((CODE*)(const CODE[]){{"alert", LOG_ALERT}, \
+ {"crit", LOG_CRIT}, \
+ {"debug", LOG_DEBUG}, \
+ {"emerg", LOG_EMERG}, \
+ {"err", LOG_ERR}, \
+ {"error", LOG_ERR}, \
+ {"info", LOG_INFO}, \
+ {"none", INTERNAL_NOPRI}, \
+ {"notice", LOG_NOTICE}, \
+ {"panic", LOG_EMERG}, \
+ {"warn", LOG_WARNING}, \
+ {"warning", LOG_WARNING}, \
+ {0, -1}})
+#define facilitynames \
+ ((CODE*)(const CODE[]){{"auth", LOG_AUTH}, \
+ {"authpriv", LOG_AUTHPRIV}, \
+ {"cron", LOG_CRON}, \
+ {"daemon", LOG_DAEMON}, \
+ {"ftp", LOG_FTP}, \
+ {"kern", LOG_KERN}, \
+ {"lpr", LOG_LPR}, \
+ {"mail", LOG_MAIL}, \
+ {"mark", INTERNAL_MARK}, \
+ {"news", LOG_NEWS}, \
+ {"security", LOG_AUTH}, \
+ {"syslog", LOG_SYSLOG}, \
+ {"user", LOG_USER}, \
+ {"uucp", LOG_UUCP}, \
+ {"local0", LOG_LOCAL0}, \
+ {"local1", LOG_LOCAL1}, \
+ {"local2", LOG_LOCAL2}, \
+ {"local3", LOG_LOCAL3}, \
+ {"local4", LOG_LOCAL4}, \
+ {"local5", LOG_LOCAL5}, \
+ {"local6", LOG_LOCAL6}, \
+ {"local7", LOG_LOCAL7}, \
+ {0, -1}})
#endif
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYSLOG_H_
diff --git a/arch/arm64/sysroot/include/tar.h b/arch/arm64/sysroot/include/tar.h
index 7703c2b..2dcb983 100644
--- a/arch/arm64/sysroot/include/tar.h
+++ b/arch/arm64/sysroot/include/tar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_TAR_H_
+#define SYSROOT_TAR_H_
#define TSUID 04000
#define TSGID 02000
@@ -28,3 +29,5 @@
#define TVERSION "00"
#define TVERSLEN 2
+
+#endif // SYSROOT_TAR_H_
diff --git a/arch/arm64/sysroot/include/termios.h b/arch/arm64/sysroot/include/termios.h
index 65c9d66..4ccfe13 100644
--- a/arch/arm64/sysroot/include/termios.h
+++ b/arch/arm64/sysroot/include/termios.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_TERMIOS_H_
+#define SYSROOT_TERMIOS_H_
#ifdef __cplusplus
extern "C" {
@@ -41,3 +42,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_TERMIOS_H_
diff --git a/arch/arm64/sysroot/include/threads.h b/arch/arm64/sysroot/include/threads.h
index 8711302..480a6f7 100644
--- a/arch/arm64/sysroot/include/threads.h
+++ b/arch/arm64/sysroot/include/threads.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_THREADS_H_
+#define SYSROOT_THREADS_H_
#include <features.h>
#include <time.h>
@@ -24,26 +25,26 @@
#define TSS_DTOR_ITERATIONS 4
enum {
- thrd_success = 0,
- thrd_busy = 1,
- thrd_error = 2,
- thrd_nomem = 3,
- thrd_timedout = 4,
+ thrd_success = 0,
+ thrd_busy = 1,
+ thrd_error = 2,
+ thrd_nomem = 3,
+ thrd_timedout = 4,
};
// These are bitfield values; initialize with e.g. (mtx_plain|mtx_timed).
// mtx_recursive is not implemented.
enum {
- mtx_plain = 0,
- mtx_recursive = 1,
- mtx_timed = 2,
+ mtx_plain = 0,
+ mtx_recursive = 1,
+ mtx_timed = 2,
};
#ifdef _ALL_SOURCE
#define MTX_INIT \
- {}
+ {}
#define CND_INIT \
- {}
+ {}
#endif
#define ONCE_FLAG_INIT 0
@@ -76,14 +77,14 @@
#ifdef __clang__
__attribute__((__acquire_capability__(__m)))
#endif
-;
+ ;
int mtx_timedlock(mtx_t* __restrict, const struct timespec* __restrict);
int mtx_trylock(mtx_t*);
int mtx_unlock(mtx_t* __m)
#ifdef __clang__
__attribute__((__release_capability__(__m)))
#endif
-;
+ ;
int cnd_init(cnd_t*);
void cnd_destroy(cnd_t*);
@@ -103,3 +104,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_THREADS_H_
diff --git a/arch/arm64/sysroot/include/time.h b/arch/arm64/sysroot/include/time.h
index c20b7db..b81da45 100644
--- a/arch/arm64/sysroot/include/time.h
+++ b/arch/arm64/sysroot/include/time.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_TIME_H_
+#define SYSROOT_TIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -27,17 +29,17 @@
#endif
struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long __tm_gmtoff;
- const char* __tm_zone;
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ long __tm_gmtoff;
+ const char* __tm_zone;
};
clock_t clock(void);
@@ -66,8 +68,8 @@
void tzset(void);
struct itimerspec {
- struct timespec it_interval;
- struct timespec it_value;
+ struct timespec it_interval;
+ struct timespec it_value;
};
#define CLOCK_REALTIME 0
@@ -118,3 +120,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_TIME_H_
diff --git a/arch/arm64/sysroot/include/uchar.h b/arch/arm64/sysroot/include/uchar.h
index 73e5e5a..79cda7c 100644
--- a/arch/arm64/sysroot/include/uchar.h
+++ b/arch/arm64/sysroot/include/uchar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_UCHAR_H_
+#define SYSROOT_UCHAR_H_
#ifdef __cplusplus
extern "C" {
@@ -10,9 +11,10 @@
#define __NEED_mbstate_t
#define __NEED_size_t
-#include <bits/alltypes.h>
#include <features.h>
+#include <bits/alltypes.h>
+
size_t c16rtomb(char* __restrict, char16_t, mbstate_t* __restrict);
size_t mbrtoc16(char16_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict);
@@ -22,3 +24,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UCHAR_H_
diff --git a/arch/arm64/sysroot/include/ucontext.h b/arch/arm64/sysroot/include/ucontext.h
index 930bb71..ccd910f 100644
--- a/arch/arm64/sysroot/include/ucontext.h
+++ b/arch/arm64/sysroot/include/ucontext.h
@@ -1,11 +1,11 @@
-#pragma once
+#ifndef SYSROOT_UCONTEXT_H_
+#define SYSROOT_UCONTEXT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <signal.h>
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -22,3 +22,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UCONTEXT_H_
diff --git a/arch/arm64/sysroot/include/unistd.h b/arch/arm64/sysroot/include/unistd.h
index 4f91876..e400030 100644
--- a/arch/arm64/sysroot/include/unistd.h
+++ b/arch/arm64/sysroot/include/unistd.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_UNISTD_H_
+#define SYSROOT_UNISTD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define STDIN_FILENO 0
@@ -134,8 +136,6 @@
void sync(void);
int syncfs(int);
pid_t setpgrp(void);
-char* crypt(const char*, const char*);
-void encrypt(char*, int);
void swab(const void* __restrict, void* __restrict, ssize_t);
#endif
@@ -432,3 +432,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UNISTD_H_
diff --git a/arch/arm64/sysroot/include/utime.h b/arch/arm64/sysroot/include/utime.h
index 25e0ff7..b4368aa 100644
--- a/arch/arm64/sysroot/include/utime.h
+++ b/arch/arm64/sysroot/include/utime.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_UTIME_H_
+#define SYSROOT_UTIME_H_
#ifdef __cplusplus
extern "C" {
@@ -9,8 +10,8 @@
#include <bits/alltypes.h>
struct utimbuf {
- time_t actime;
- time_t modtime;
+ time_t actime;
+ time_t modtime;
};
int utime(const char*, const struct utimbuf*);
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UTIME_H_
diff --git a/arch/arm64/sysroot/include/values.h b/arch/arm64/sysroot/include/values.h
index a139dca..0862584 100644
--- a/arch/arm64/sysroot/include/values.h
+++ b/arch/arm64/sysroot/include/values.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_VALUES_H_
+#define SYSROOT_VALUES_H_
#include <limits.h>
@@ -34,3 +35,5 @@
#define FMAXEXP FLT_MAX_EXP
#define BITSPERBYTE CHAR_BIT
+
+#endif // SYSROOT_VALUES_H_
diff --git a/arch/arm64/sysroot/include/wchar.h b/arch/arm64/sysroot/include/wchar.h
index 5578085..aaa7e9e 100644
--- a/arch/arm64/sysroot/include/wchar.h
+++ b/arch/arm64/sysroot/include/wchar.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_WCHAR_H_
+#define SYSROOT_WCHAR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_FILE
@@ -32,13 +34,13 @@
#ifndef WCHAR_MIN
#if defined(__WCHAR_MIN__)
#define WCHAR_MIN __WCHAR_MIN__
-#else // defined(__WCHAR_MIN__)
+#else // defined(__WCHAR_MIN__)
#if defined(__WCHAR_UNSIGNED__)
#define WCHAR_MIN (L'\0' + 0)
#else
#define WCHAR_MIN (-WCHAR_MAX - 1)
-#endif // defined (__WCHAR_UNSIGNED)
-#endif // defined(__WCHAR_MIN__)
+#endif // defined (__WCHAR_UNSIGNED)
+#endif // defined(__WCHAR_MIN__)
#endif
#undef WEOF
@@ -179,3 +181,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WCHAR_H_
diff --git a/arch/arm64/sysroot/include/wctype.h b/arch/arm64/sysroot/include/wctype.h
index 8c86840..5a04bb8 100644
--- a/arch/arm64/sysroot/include/wctype.h
+++ b/arch/arm64/sysroot/include/wctype.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_WCTYPE_H_
+#define SYSROOT_WCTYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -55,3 +56,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WCTYPE_H_
diff --git a/arch/arm64/sysroot/include/wordexp.h b/arch/arm64/sysroot/include/wordexp.h
index 26f8646..dd6caa0 100644
--- a/arch/arm64/sysroot/include/wordexp.h
+++ b/arch/arm64/sysroot/include/wordexp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_WORDEXP_H_
+#define SYSROOT_WORDEXP_H_
#ifdef __cplusplus
extern "C" {
@@ -18,9 +19,9 @@
#define WRDE_UNDEF 32
typedef struct {
- size_t we_wordc;
- char** we_wordv;
- size_t we_offs;
+ size_t we_wordc;
+ char** we_wordv;
+ size_t we_offs;
} wordexp_t;
#define WRDE_NOSYS -1
@@ -36,3 +37,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WORDEXP_H_
diff --git a/arch/arm64/sysroot/include/zircon/assert.h b/arch/arm64/sysroot/include/zircon/assert.h
index 6175321..d53115d 100644
--- a/arch/arm64/sysroot/include/zircon/assert.h
+++ b/arch/arm64/sysroot/include/zircon/assert.h
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_ASSERT_
-#define ZIRCON_ASSERT_
+#ifndef SYSROOT_ZIRCON_ASSERT_
+#define SYSROOT_ZIRCON_ASSERT_
+
+// For a description of which asserts are enabled at which debug levels, see the documentation for
+// GN build argument |assert_level|.
#ifdef _KERNEL
#include <assert.h>
@@ -16,61 +19,69 @@
#define ZX_DEBUG_ASSERT_MSG_COND(args...) DEBUG_ASSERT_MSG_COND(args)
#define ZX_DEBUG_ASSERT_IMPLEMENTED DEBUG_ASSERT_IMPLEMENTED
-#ifdef ZX_DEBUGLEVEL
-#undef ZX_DEBUGLEVEL
-#endif
-#define ZX_DEBUGLEVEL LK_DEBUGLEVEL
-
-#else // #ifdef _KERNEL
-
-#include <stdio.h> // for printf
-#include <stdlib.h> // for abort
+#else // #ifdef _KERNEL
#include <zircon/compiler.h>
-#define ZX_PANIC(fmt, ...) \
- do { \
- printf(fmt, ##__VA_ARGS__); \
- abort(); \
- } while (0)
+__BEGIN_CDECLS
+void __zx_panic(const char* format, ...) __NO_RETURN __PRINTFLIKE(1, 2);
+__END_CDECLS
-#define ZX_ASSERT(x) \
- do { \
- if (unlikely(!(x))) { \
- ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
- } \
- } while (0)
+#define ZX_PANIC(fmt, ...) __zx_panic((fmt), ##__VA_ARGS__)
-#define ZX_ASSERT_MSG(x, msg, msgargs...) \
- do { \
- if (unlikely(!(x))) { \
- ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n" msg "\n", \
- __FILE__, __LINE__, #x, ##msgargs); \
- } \
- } while (0)
+// Assert that |x| is true, else panic.
+//
+// ZX_ASSERT is always enabled and |x| will be evaluated regardless of any build arguments.
+#define ZX_ASSERT(x) \
+ do { \
+ if (unlikely(!(x))) { \
+ ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
+ } \
+ } while (0)
-// conditionally implement DEBUG_ASSERT based on ZX_DEBUGLEVEL in kernel space
-// user space does not currently implement DEBUG_ASSERT
-#ifdef ZX_DEBUGLEVEL
-#define ZX_DEBUG_ASSERT_IMPLEMENTED (ZX_DEBUGLEVEL > 1)
+// Assert that |x| is true, else panic with the given message.
+//
+// ZX_ASSERT_MSG is always enabled and |x| will be evaluated regardless of any build arguments.
+#define ZX_ASSERT_MSG(x, msg, msgargs...) \
+ do { \
+ if (unlikely(!(x))) { \
+ ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n" msg "\n", __FILE__, __LINE__, #x, ##msgargs); \
+ } \
+ } while (0)
+
+// Conditionally implement ZX_DEBUG_ASSERT based on ZX_ASSERT_LEVEL.
+#ifdef ZX_ASSERT_LEVEL
+
+// ZX_DEBUG_ASSERT_IMPLEMENTED is intended to be used to conditionalize code that is logically part
+// of a debug assert. It's useful for performing complex consistency checks that are difficult to
+// work into a ZX_DEBUG_ASSERT statement.
+#define ZX_DEBUG_ASSERT_IMPLEMENTED (ZX_ASSERT_LEVEL > 1)
#else
#define ZX_DEBUG_ASSERT_IMPLEMENTED 0
#endif
-#define ZX_DEBUG_ASSERT(x) \
- do { \
- if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
- ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
- } \
- } while (0)
+// Assert that |x| is true, else panic.
+//
+// Depending on build arguments, ZX_DEBUG_ASSERT may or may not be enabled. When disabled, |x| will
+// not be evaluated.
+#define ZX_DEBUG_ASSERT(x) \
+ do { \
+ if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
+ ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
+ } \
+ } while (0)
-#define ZX_DEBUG_ASSERT_MSG(x, msg, msgargs...) \
- do { \
- if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
- ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n" msg "\n", \
- __FILE__, __LINE__, #x, ##msgargs); \
- } \
- } while (0)
+// Assert that |x| is true, else panic with the given message.
+//
+// Depending on build arguments, ZX_DEBUG_ASSERT_MSG may or may not be enabled. When disabled, |x|
+// will not be evaluated.
+#define ZX_DEBUG_ASSERT_MSG(x, msg, msgargs...) \
+ do { \
+ if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
+ ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n" msg "\n", __FILE__, __LINE__, #x, \
+ ##msgargs); \
+ } \
+ } while (0)
// implement _COND versions of ZX_DEBUG_ASSERT which only emit the body if
// ZX_DEBUG_ASSERT_IMPLEMENTED is set
@@ -78,9 +89,13 @@
#define ZX_DEBUG_ASSERT_COND(x) ZX_DEBUG_ASSERT(x)
#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) ZX_DEBUG_ASSERT_MSG(x, msg, msgargs)
#else
-#define ZX_DEBUG_ASSERT_COND(x) do { } while (0)
-#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) do { } while (0)
+#define ZX_DEBUG_ASSERT_COND(x) \
+ do { \
+ } while (0)
+#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) \
+ do { \
+ } while (0)
#endif
-#endif // #ifdef _KERNEL
+#endif // #ifdef _KERNEL
-#endif // ZIRCON_ASSERT_
+#endif // SYSROOT_ZIRCON_ASSERT_
diff --git a/arch/arm64/sysroot/include/zircon/boot/bootdata.h b/arch/arm64/sysroot/include/zircon/boot/bootdata.h
deleted file mode 100644
index d49b9b1..0000000
--- a/arch/arm64/sysroot/include/zircon/boot/bootdata.h
+++ /dev/null
@@ -1,317 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#ifndef __ASSEMBLER__
-#include <zircon/compiler.h>
-#include <stdbool.h>
-#include <stdint.h>
-#endif
-
-// lsw of sha256("bootdata")
-#define BOOTDATA_MAGIC (0x868cf7e6)
-
-// lsw of sha256("bootitem")
-#define BOOTITEM_MAGIC (0xb5781729)
-
-// Round n up to the next 8 byte boundary
-#define BOOTDATA_ALIGN(n) (((n) + 7) & (~7))
-
-#define BOOTITEM_NO_CRC32 (0x4a87e8d6)
-
-// This flag is required.
-#define BOOTDATA_FLAG_V2 (0x00010000)
-
-// Bootdata items with the CRC32 flag must have a valid crc32.
-// Otherwise their crc32 field must contain BOOTITEM_NO_CRC32
-#define BOOTDATA_FLAG_CRC32 (0x00020000)
-
-// Bootdata types that have least significant byte set to 'm'
-// are reserved for driver metadata
-#define BOOTDATA_KIND_METADATA (0x0000006D)
-#define BOOTDATA_KIND_MASK (0x000000FF)
-
-// Containers are used to wrap a set of bootdata items
-// written to a file or partition. The "length" is the
-// length of the set of following bootdata items. The
-// "extra" is the value BOOTDATA_MAGIC and "flags" is
-// set to 0.
-#define BOOTDATA_CONTAINER (0x544f4f42) // BOOT
-
-// BOOTFS images. The "extra" field is the decompressed
-// size of the image, if compressed, otherwise the same
-// as the "length" field.
-#define BOOTDATA_BOOTFS_BOOT (0x42534642) // BFSB
-#define BOOTDATA_BOOTFS_SYSTEM (0x53534642) // BFSS
-#define BOOTDATA_BOOTFS_DISCARD (0x58534642) // BFSX
-
-#define BOOTDATA_BOOTFS_MASK (0x00FFFFFF)
-#define BOOTDATA_BOOTFS_TYPE (0x00534642) // BFS\0
-
-// Virtual disk images. The header fields and compression protocol
-// are the same as for the BOOTFS types, but the payload before
-// compression is a raw disk image rather than BOOTFS format.
-#define BOOTDATA_RAMDISK (0x4b534452) // RDSK
-
-// A Zircon Kernel Image
-// Content: bootdata_kernel_t
-#define BOOTDATA_KERNEL (0x4c4e524b) // KRNL
-
-// A Zircon Partition Map
-// Content: bootdata_partition_map_t
-// The bootdata_t.extra field is used as a board specific index
-// to specify which device the partition map applies to.
-#define BOOTDATA_PARTITION_MAP (0x5452506D) // mPRT
-
-// MAC Address for Ethernet, Wifi, Bluetooth, etc.
-// Content: uint8_t[] (variable length based on type of MAC address)
-// The bootdata_t.extra field is used as a board specific index
-// to specify which device the MAC address applies to.
-#define BOOTDATA_MAC_ADDRESS (0x43414D6D) // mMAC
-
-// Flag indicating that the bootfs is compressed.
-#define BOOTDATA_BOOTFS_FLAG_COMPRESSED (1 << 0)
-
-
-// These items are for passing from bootloader to kernel
-
-// Kernel Command Line String
-// Content: uint8_t[]
-#define BOOTDATA_CMDLINE (0x4c444d43) // CMDL
-
-// ACPI Root Table Pointer
-// Content: uint64_t phys addr
-#define BOOTDATA_ACPI_RSDP (0x50445352) // RSDP
-
-// SMBIOS entry point pointer
-// Content: uint64_t phys addr
-#define BOOTDATA_SMBIOS (0x49424d53) // SMBI
-
-// Framebuffer Parameters
-// Content: bootdata_swfb_t
-#define BOOTDATA_FRAMEBUFFER (0x42465753) // SWFB
-
-// Debug Serial Port
-// Content: bootdata_uart_t
-#define BOOTDATA_DEBUG_UART (0x54524155) // UART
-
-// Platform ID Information
-// Content: bootdata_platform_id_t
-#define BOOTDATA_PLATFORM_ID (0x44494C50) // PLID
-
-// Memory which will persist across warm boots
-// Content bootdata_lastlog_nvram_t
-#define BOOTDATA_LASTLOG_NVRAM (0x4c4c564e) // NVLL
-
-// This reflects a typo we need to support for a while
-#define BOOTDATA_LASTLOG_NVRAM2 (0x4c4c5643) // CVLL
-
-// E820 Memory Table
-// Content: e820entry[]
-#define BOOTDATA_E820_TABLE (0x30323845) // E820
-
-// EFI Memory Map
-// Content: a uint64_t entrysz followed by a set of
-// efi_memory_descriptor aligned on entrysz
-#define BOOTDATA_EFI_MEMORY_MAP (0x4d494645) // EFIM
-
-// EFI System Table
-// Content: a uint64_t physical address of the table
-#define BOOTDATA_EFI_SYSTEM_TABLE (0x53494645) // EFIS
-
-// Last crashlog
-// Content: ascii/utf8 log data from previous boot
-#define BOOTDATA_LAST_CRASHLOG (0x4d4f4f42) // BOOM
-
-// CPU configuration
-// Content: bootdata_cpu_config_t
-#define BOOTDATA_CPU_CONFIG (0x43555043) // CPUC
-
-// Memory configuration
-// Content: one or more of bootdata_mem_range_t (count determined by bootdata_t length)
-#define BOOTDATA_MEM_CONFIG (0x434D454D) // MEMC
-
-// Kernel driver configuration
-// Content: driver specific struct, with type determined by bootdata "extra" field
-#define BOOTDATA_KERNEL_DRIVER (0x5652444B) // KDRV
-
-#define BOOTDATA_IGNORE (0x50494b53) // SKIP
-
-#ifndef __ASSEMBLER__
-__BEGIN_CDECLS;
-
-// BootData header, describing the type and size of data
-// used to initialize the system. All fields are little-endian.
-//
-// BootData headers in a stream must be 8-byte-aligned.
-//
-// The length field specifies the actual payload length
-// and does not include the size of padding.
-typedef struct {
- // Boot data type
- uint32_t type;
-
- // Size of the payload following this header
- uint32_t length;
-
- // type-specific extra data
- // For CONTAINER this is MAGIC.
- // For BOOTFS this is the decompressed size.
- uint32_t extra;
-
- // Flags for the boot data. See flag descriptions for each type.
- uint32_t flags;
-
- // For future expansion. Set to 0.
- uint32_t reserved0;
- uint32_t reserved1;
-
- // Must be BOOTITEM_MAGIC
- uint32_t magic;
-
- // Must be the CRC32 of payload if FLAG_CRC32 is set,
- // otherwise must be BOOTITEM_NO_CRC32
- uint32_t crc32;
-} bootdata_t;
-
-typedef struct {
- uint64_t base; // physical base addr
- uint32_t width;
- uint32_t height;
- uint32_t stride;
- uint32_t format;
-} bootdata_swfb_t;
-
-typedef struct {
- uint64_t entry64;
- uint64_t reserved;
-} bootdata_kernel_t;
-
-#define BOOTDATA_PART_NAME_LEN 32
-#define BOOTDATA_PART_GUID_LEN 16
-
-typedef struct {
- uint8_t type_guid[BOOTDATA_PART_GUID_LEN];
- uint8_t uniq_guid[BOOTDATA_PART_GUID_LEN];
- uint64_t first_block;
- uint64_t last_block;
- uint64_t flags;
- char name[BOOTDATA_PART_NAME_LEN];
-} bootdata_partition_t;
-
-typedef struct {
- uint64_t block_count;
- uint64_t block_size;
- uint32_t partition_count;
- uint32_t reserved;
- char guid[BOOTDATA_PART_GUID_LEN];
- bootdata_partition_t partitions[];
-} bootdata_partition_map_t;
-
-typedef struct {
- uint64_t base;
- uint64_t length;
-} bootdata_nvram_t;
-
-#define BOOTDATA_UART_NONE 0
-#define BOOTDATA_UART_PC_PORT 1
-#define BOOTDATA_UART_PC_MMIO 2
-typedef struct {
- uint64_t base;
- uint32_t type;
- uint32_t irq;
-} bootdata_uart_t;
-
-typedef struct {
- uint32_t vid;
- uint32_t pid;
- char board_name[32];
-} bootdata_platform_id_t;
-
-typedef struct {
- uint32_t cpu_count; // number of CPU cores in the cluster
- uint32_t type; // for future use
- uint32_t flags; // for future use
- uint32_t reserved;
-} bootdata_cpu_cluster_t;
-
-typedef struct {
- uint32_t cluster_count;
- uint32_t reserved[3];
- bootdata_cpu_cluster_t clusters[];
-} bootdata_cpu_config_t;
-
-#define BOOTDATA_MEM_RANGE_RAM 1
-#define BOOTDATA_MEM_RANGE_PERIPHERAL 2
-#define BOOTDATA_MEM_RANGE_RESERVED 3
-typedef struct {
- uint64_t paddr;
- uint64_t length;
- uint32_t type;
- uint32_t reserved;
-} bootdata_mem_range_t;
-
-/* EFI Variable for Crash Log */
-#define ZIRCON_VENDOR_GUID \
- {0x82305eb2, 0xd39e, 0x4575, {0xa0, 0xc8, 0x6c, 0x20, 0x72, 0xd0, 0x84, 0x4c}}
-#define ZIRCON_CRASHLOG_EFIVAR \
- { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 };
-#define ZIRCON_CRASHLOG_EFIATTR \
- (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
-
-__END_CDECLS;
-
-
-// BOOTFS is a trivial "filesystem" format
-//
-// It consists of a bootfs_header_t
-//
-// Followed by a series of bootfs_entry_t's of:
-// name length (32bit le)
-// data size (32bit le)
-// data offset (32bit le)
-// namedata (namelength bytes, includes \0)
-//
-// - data offsets must be page aligned (multiple of 4096)
-// - entries start on uint32 boundaries
-
-//lsw of sha256("bootfs")
-#define BOOTFS_MAGIC (0xa56d3ff9)
-
-#define BOOTFS_PAGE_SIZE (4096)
-#define BOOTFS_PAGE_ALIGN(size) \
- (((size) + BOOTFS_PAGE_SIZE - 1) & -BOOTFS_PAGE_SIZE)
-
-#define BOOTFS_MAX_NAME_LEN 256
-
-typedef struct bootfs_header {
- // magic value BOOTFS_MAGIC
- uint32_t magic;
-
- // total size of all bootfs_entry_t's
- // does not include the size of the bootfs_header_t
- uint32_t dirsize;
-
- // 0, 0
- uint32_t reserved0;
- uint32_t reserved1;
-} bootfs_header_t;
-
-typedef struct bootfs_entry {
- uint32_t name_len;
- uint32_t data_len;
- uint32_t data_off;
- char name[];
-} bootfs_entry_t;
-
-#define BOOTFS_ALIGN(nlen) (((nlen) + 3) & (~3))
-#define BOOTFS_RECSIZE(entry) \
- (sizeof(bootfs_entry_t) + BOOTFS_ALIGN(entry->name_len))
-
-static inline bool bootdata_is_metadata(uint32_t type) {
- return ((type & BOOTDATA_KIND_MASK) == BOOTDATA_KIND_METADATA);
-}
-
-#endif
diff --git a/arch/arm64/sysroot/include/zircon/boot/bootfs.h b/arch/arm64/sysroot/include/zircon/boot/bootfs.h
new file mode 100644
index 0000000..8cc2644
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/boot/bootfs.h
@@ -0,0 +1,66 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_BOOT_BOOTFS_H_
+#define SYSROOT_ZIRCON_BOOT_BOOTFS_H_
+
+#include <stdint.h>
+
+// The payload (after decompression) of an item in BOOTFS format consists
+// of separate "file" images that are each aligned to ZBI_BOOTFS_PAGE_SIZE
+// bytes from the beginning of the item payload. The first "file" consists
+// of a zbi_bootfs_header_t followed by directory entries.
+#define ZBI_BOOTFS_PAGE_SIZE (4096u)
+
+#define ZBI_BOOTFS_PAGE_ALIGN(size) \
+ (((size) + ZBI_BOOTFS_PAGE_SIZE - 1) & ~(ZBI_BOOTFS_PAGE_SIZE - 1))
+
+typedef struct {
+ // Must be ZBI_BOOTFS_MAGIC.
+ uint32_t magic;
+
+ // Size in bytes of all the directory entries.
+ // Does not include the size of the zbi_bootfs_header_t.
+ uint32_t dirsize;
+
+ // Reserved for future use. Set to 0.
+ uint32_t reserved0;
+ uint32_t reserved1;
+} zbi_bootfs_header_t;
+
+// LSW of sha256("bootfs")
+#define ZBI_BOOTFS_MAGIC (0xa56d3ff9)
+
+// Each directory entry holds a pathname and gives the offset and size
+// of the contents of the file by that name.
+typedef struct {
+ // Length of the name[] field at the end. This length includes the
+ // NUL terminator, which must be present, but does not include any
+ // alignment padding required before the next directory entry.
+ uint32_t name_len;
+
+ // Length of the file in bytes. This is an exact size that is not
+ // rounded, though the file is always padded with zeros up to a
+ // multiple of ZBI_BOOTFS_PAGE_SIZE.
+ uint32_t data_len;
+
+ // Offset from the beginning of the payload (zbi_bootfs_header_t) to
+ // the file's data. This must be a multiple of ZBI_BOOTFS_PAGE_SIZE.
+ uint32_t data_off;
+
+ // Pathname of the file, a UTF-8 string. This must include a NUL
+ // terminator at the end. It must not begin with a '/', but it may
+ // contain '/' separators for subdirectories.
+ char name[];
+} zbi_bootfs_dirent_t;
+
+// Each directory entry has a variable size of [16,268] bytes that
+// must be a multiple of 4 bytes.
+#define ZBI_BOOTFS_DIRENT_SIZE(name_len) \
+ ((sizeof(zbi_bootfs_dirent_t) + (name_len) + 3) & -(size_t)4)
+
+// zbi_bootfs_dirent_t.name_len must be > 1 and <= ZBI_BOOTFS_MAX_NAME_LEN.
+#define ZBI_BOOTFS_MAX_NAME_LEN (256)
+
+#endif // SYSROOT_ZIRCON_BOOT_BOOTFS_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/crash-reason.h b/arch/arm64/sysroot/include/zircon/boot/crash-reason.h
new file mode 100644
index 0000000..f626fac
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/boot/crash-reason.h
@@ -0,0 +1,59 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
+#define SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
+
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+// 0 is reserved for "Invalid". It will never be used by a functioning
+// crash-logger.
+#define ZIRCON_CRASH_REASON_INVALID ((uint32_t)0)
+
+// "Unknown" indicates that the system does not know the reason for a recent
+// crash. The primary use of this reason is to be something which can be left
+// in the crashlog in case the system spontaneously reboots without a chance to
+// gracefully finalize the log, perhaps because of something like a hardware
+// watchdog timer.
+#define ZIRCON_CRASH_REASON_UNKNOWN ((uint32_t)1)
+
+// "No Crash" indicates that the system deliberately rebooted in an
+// orderly fashion. No crash occurred.
+#define ZIRCON_CRASH_REASON_NO_CRASH ((uint32_t)2)
+
+// "OOM" indicates a crash triggered by the system because of an unrecoverable
+// out-of-memory situation.
+#define ZIRCON_CRASH_REASON_OOM ((uint32_t)3)
+
+// "Panic" indicates a crash triggered by the system because of an unrecoverable
+// kernel panic situation.
+#define ZIRCON_CRASH_REASON_PANIC ((uint32_t)4)
+
+// "Software watchdog" indicates a crash triggered by a kernel level software
+// watchdog construct. Note that this is distinct from a hardware based WDT.
+// If the system reboots because of a hardware watchdog, it will have no chance
+// to record the reboot reason, and the crashlog will indicate "unknown". The
+// HW reboot reason may be known, but only if the bootloader reports it to us.
+#define ZIRCON_CRASH_REASON_SOFTWARE_WATCHDOG ((uint32_t)5)
+
+#ifndef __ASSEMBLER__
+#if !__cplusplus
+typedef uint32_t zircon_crash_reason_t;
+#else // !__cplusplus
+enum class ZirconCrashReason : uint32_t {
+ Invalid = ZIRCON_CRASH_REASON_INVALID,
+ Unknown = ZIRCON_CRASH_REASON_UNKNOWN,
+ NoCrash = ZIRCON_CRASH_REASON_NO_CRASH,
+ Oom = ZIRCON_CRASH_REASON_OOM,
+ Panic = ZIRCON_CRASH_REASON_PANIC,
+ SoftwareWatchdog = ZIRCON_CRASH_REASON_SOFTWARE_WATCHDOG,
+};
+
+// Using alias to maintain compatibility with APIs meant to be used by both C and C++.
+using zircon_crash_reason_t = ZirconCrashReason;
+#endif // !__cplusplus
+#endif // __ASSEMBLER__
+
+#endif // SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/driver-config.h b/arch/arm64/sysroot/include/zircon/boot/driver-config.h
index 4913ae1..7f72fca 100644
--- a/arch/arm64/sysroot/include/zircon/boot/driver-config.h
+++ b/arch/arm64/sysroot/include/zircon/boot/driver-config.h
@@ -2,87 +2,162 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
+#define SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
-#include <zircon/compiler.h>
#include <stdint.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
-// BOOTDATA_KERNEL_DRIVER bootdata types
-#define KDRV_ARM_PSCI 0x49435350 // 'PSCI'
-#define KDRV_ARM_GIC_V2 0x32434947 // 'GIC2'
-#define KDRV_ARM_GIC_V3 0x33434947 // 'GIC3'
-#define KDRV_ARM_GENERIC_TIMER 0x4D495441 // 'ATIM'
-#define KDRV_PL011_UART 0x55304C50 // 'PL0U'
-#define KDRV_AMLOGIC_UART 0x554C4D41 // 'AMLU'
-#define KDRV_NXP_IMX_UART 0x55584D49 // 'IMXU'
-#define KDRV_MT8167_UART 0x5538544D // 'MT8U'
-#define KDRV_HISILICON_POWER 0x4F505348 // 'HSPO'
-#define KDRV_AMLOGIC_HDCP 0x484C4D41 // 'AMLH'
+// ZBI_TYPE_KERNEL_DRIVER item types (for zbi_header_t.extra)
+#define KDRV_ARM_PSCI 0x49435350 // 'PSCI'
+#define KDRV_ARM_GIC_V2 0x32434947 // 'GIC2'
+#define KDRV_ARM_GIC_V3 0x33434947 // 'GIC3'
+#define KDRV_ARM_GENERIC_TIMER 0x4D495441 // 'ATIM'
+#define KDRV_PL011_UART 0x55304C50 // 'PL0U'
+#define KDRV_AMLOGIC_UART 0x554C4D41 // 'AMLU'
+#define KDRV_NXP_IMX_UART 0x55584D49 // 'IMXU'
+#define KDRV_MT8167_UART 0x5538544D // 'MT8U'
+#define KDRV_AMLOGIC_HDCP 0x484C4D41 // 'AMLH'
+#define KDRV_MSM_UART 0x554D534D // 'MSMU'
+#define KDRV_MSM_POWER 1347244877 // 'MSMP'
+#define KDRV_DW8250_UART 0x44573855 // 'DW8U'
+#define KDRV_AS370_POWER 0x50303733 // '370P'
+#define KDRV_AMLOGIC_RNG 0x484C4D52 // 'AMLR'
+#define KDRV_GENERIC_32BIT_WATCHDOG 0x32334457 // 'WD32'
+#define KDRV_I8250_PIO_UART 0x30353238 // '8250'
+#define KDRV_I8250_MMIO_UART 0x4d353238 // '825M'
-// kernel driver struct that can be used for simple drivers
-// used by KDRV_PL011_UART, KDRV_AMLOGIC_UART and KDRV_NXP_IMX_UART
+// Kernel driver struct that can be used for simple drivers.
+// Used by KDRV_PL011_UART, KDRV_AMLOGIC_UART, KDRV_NXP_IMX_UART,
+// and KDRV_I8250_MMIO_UART.
typedef struct {
- uint64_t mmio_phys;
- uint32_t irq;
+ uint64_t mmio_phys;
+ uint32_t irq;
} dcfg_simple_t;
+// Used by KDRV_I8250_PIO_UART.
+typedef struct {
+ uint16_t base;
+ uint32_t irq;
+} dcfg_simple_pio_t;
+
// for KDRV_MT8167_UART
typedef struct {
- uint64_t soc_mmio_phys;
- uint64_t uart_mmio_phys;
- uint32_t irq;
+ uint64_t soc_mmio_phys;
+ uint64_t uart_mmio_phys;
+ uint32_t irq;
} dcfg_soc_uart_t;
// for KDRV_ARM_PSCI
typedef struct {
- bool use_hvc;
- uint64_t shutdown_args[3];
- uint64_t reboot_args[3];
- uint64_t reboot_bootloader_args[3];
- uint64_t reboot_recovery_args[3];
+ bool use_hvc;
+ uint64_t shutdown_args[3];
+ uint64_t reboot_args[3];
+ uint64_t reboot_bootloader_args[3];
+ uint64_t reboot_recovery_args[3];
} dcfg_arm_psci_driver_t;
+typedef struct {
+ uint64_t soc_imem_phys;
+ uint64_t soc_imem_offset;
+} dcfg_msm_power_driver_t;
+
// for KDRV_ARM_GIC_V2
typedef struct {
- uint64_t mmio_phys;
- uint64_t msi_frame_phys;
- uint64_t gicd_offset;
- uint64_t gicc_offset;
- uint64_t gich_offset;
- uint64_t gicv_offset;
- uint32_t ipi_base;
- bool optional;
- bool use_msi;
+ uint64_t mmio_phys;
+ uint64_t msi_frame_phys;
+ uint64_t gicd_offset;
+ uint64_t gicc_offset;
+ uint64_t gich_offset;
+ uint64_t gicv_offset;
+ uint32_t ipi_base;
+ bool optional;
+ bool use_msi;
} dcfg_arm_gicv2_driver_t;
// for KDRV_ARM_GIC_V3
typedef struct {
- uint64_t mmio_phys;
- uint64_t gicd_offset;
- uint64_t gicr_offset;
- uint64_t gicr_stride;
- uint64_t mx8_gpr_phys;
- uint32_t ipi_base;
- bool optional;
+ uint64_t mmio_phys;
+ uint64_t gicd_offset;
+ uint64_t gicr_offset;
+ uint64_t gicr_stride;
+ uint64_t mx8_gpr_phys;
+ uint32_t ipi_base;
+ bool optional;
} dcfg_arm_gicv3_driver_t;
// for KDRV_ARM_GENERIC_TIMER
typedef struct {
- uint32_t irq_phys;
- uint32_t irq_virt;
- uint32_t irq_sphys;
- uint32_t freq_override;
+ uint32_t irq_phys;
+ uint32_t irq_virt;
+ uint32_t irq_sphys;
+ uint32_t freq_override;
} dcfg_arm_generic_timer_driver_t;
-// for KDRV_HISILICON_POWER
-typedef struct {
- uint64_t sctrl_phys;
- uint64_t pmu_phys;
-} dcfg_hisilicon_power_driver_t;
-
// for KDRV_AMLOGIC_HDCP
typedef struct {
- uint64_t preset_phys;
- uint64_t hiu_phys;
- uint64_t hdmitx_phys;
+ uint64_t preset_phys;
+ uint64_t hiu_phys;
+ uint64_t hdmitx_phys;
} dcfg_amlogic_hdcp_driver_t;
+
+// for KDRV_AMLOGIC_RNG
+typedef struct {
+ uint64_t rng_data_phys;
+ uint64_t rng_status_phys;
+ uint64_t rng_refresh_interval_usec;
+} dcfg_amlogic_rng_driver_t;
+
+// Defines a register write action for a generic kernel watchdog driver. An
+// action consists of the following steps.
+//
+// 1) Read from the register located a physical address |addr|
+// 2) Clear all of the bits in the value which was read using the |clr_mask|
+// 3) Set all of the bits in the value using the |set_mask|
+// 4) Write this value back to the address located at addr.
+//
+typedef struct {
+ uint64_t addr;
+ uint32_t clr_mask;
+ uint32_t set_mask;
+} dcfg_generic_32bit_watchdog_action_t;
+
+#define KDRV_GENERIC_32BIT_WATCHDOG_FLAG_ENABLED ((uint32_t)0x00000001)
+#define KDRV_GENERIC_32BIT_WATCHDOG_MIN_PERIOD ZX_MSEC(1)
+
+// Definitions of actions which may be taken by a generic 32 bit watchdog timer
+// kernel driver which may be passed by a bootloader. Field definitions are as
+// follows.
+//
+// |pet_action|
+// The address and masks needed to "pet" (aka, dismiss) a hardware watchdog timer.
+//
+// |enable_action|
+// The address and masks needed to enable a hardware watchdog timer. If enable
+// is an unsupported operation, the addr of the |enable_action| shall be zero.
+//
+// |disable_action|
+// The address and masks needed to disable a hardware watchdog timer. If
+// disable is an unsupported operation, the addr of the |disable_action| shall
+// be zero.
+//
+// |watchdog_period_nsec|
+// The period of the watchdog timer given in nanoseconds. When enabled, the
+// watchdog timer driver must pet the watch dog at least this often. The value
+// must be at least 1 mSec, typically much larger (on the order of a second or
+// two)
+//
+// |flags|
+// Storage for additional flags. Currently, only one flag is defined,
+// "FLAG_ENABLED". When this flag is set, it indicates that the watchdog timer
+// was left enabled by the bootloader at startup.
+typedef struct {
+ dcfg_generic_32bit_watchdog_action_t pet_action;
+ dcfg_generic_32bit_watchdog_action_t enable_action;
+ dcfg_generic_32bit_watchdog_action_t disable_action;
+ zx_duration_t watchdog_period_nsec;
+ uint32_t flags;
+} dcfg_generic_32bit_watchdog_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/e820.h b/arch/arm64/sysroot/include/zircon/boot/e820.h
index fb8c340..f0f98f0 100644
--- a/arch/arm64/sysroot/include/zircon/boot/e820.h
+++ b/arch/arm64/sysroot/include/zircon/boot/e820.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_E820_H_
+#define SYSROOT_ZIRCON_BOOT_E820_H_
#include <stdint.h>
#include <zircon/compiler.h>
@@ -14,7 +15,9 @@
#define E820_UNUSABLE 5
typedef struct e820entry {
- uint64_t addr;
- uint64_t size;
- uint32_t type;
+ uint64_t addr;
+ uint64_t size;
+ uint32_t type;
} __PACKED e820entry_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_E820_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/image.h b/arch/arm64/sysroot/include/zircon/boot/image.h
index de2411e..28663b6 100644
--- a/arch/arm64/sysroot/include/zircon/boot/image.h
+++ b/arch/arm64/sysroot/include/zircon/boot/image.h
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_IMAGE_H_
+#define SYSROOT_ZIRCON_BOOT_IMAGE_H_
+
+// This file contains assembly code that cannot be clang formatted.
+// clang-format off
#ifndef __ASSEMBLER__
#include <stdint.h>
#endif
+
// Zircon Boot Image format (ZBI).
//
// A Zircon Boot Image consists of a container header followed by boot
@@ -108,6 +113,7 @@
macro(ZBI_TYPE_DISCARD, "DISCARD", ".bin") \
macro(ZBI_TYPE_STORAGE_RAMDISK, "RAMDISK", ".bin") \
macro(ZBI_TYPE_STORAGE_BOOTFS, "BOOTFS", ".bin") \
+ macro(ZBI_TYPE_STORAGE_BOOTFS_FACTORY, "BOOTFS_FACTORY", ".bin") \
macro(ZBI_TYPE_CMDLINE, "CMDLINE", ".txt") \
macro(ZBI_TYPE_CRASHLOG, "CRASHLOG", ".bin") \
macro(ZBI_TYPE_NVRAM, "NVRAM", ".bin") \
@@ -121,12 +127,17 @@
macro(ZBI_TYPE_EFI_MEMORY_MAP, "EFI_MEMORY_MAP", ".bin") \
macro(ZBI_TYPE_EFI_SYSTEM_TABLE, "EFI_SYSTEM_TABLE", ".bin") \
macro(ZBI_TYPE_E820_TABLE, "E820_TABLE", ".bin") \
- macro(ZBI_TYPE_DEBUG_UART, "DEBUG_UART", ".bin") \
macro(ZBI_TYPE_FRAMEBUFFER, "FRAMEBUFFER", ".bin") \
macro(ZBI_TYPE_DRV_MAC_ADDRESS, "DRV_MAC_ADDRESS", ".bin") \
macro(ZBI_TYPE_DRV_PARTITION_MAP, "DRV_PARTITION_MAP", ".bin") \
- macro(ZBI_TYPE_BOOT_CONFIG, "BOOT_CONFIG", ".bin") \
- macro(ZBI_TYPE_BOOT_VERSION, "BOOT_VERSION", ".bin")
+ macro(ZBI_TYPE_DRV_BOARD_PRIVATE, "DRV_BOARD_PRIVATE", ".bin") \
+ macro(ZBI_TYPE_DRV_BOARD_INFO, "DRV_BOARD_INFO", ".bin") \
+ macro(ZBI_TYPE_IMAGE_ARGS, "IMAGE_ARGS", ".txt") \
+ macro(ZBI_TYPE_BOOT_VERSION, "BOOT_VERSION", ".bin") \
+ macro(ZBI_TYPE_HW_REBOOT_REASON, "HW_REBOOT_REASON", ".bin") \
+ macro(ZBI_TYPE_SERIAL_NUMBER, "SERIAL_NUMBER", ".txt") \
+ macro(ZBI_TYPE_BOOTLOADER_FILE, "BOOTLOADER_FILE", ".bin") \
+ macro(ZBI_TYPE_DEVICETREE, "DEVICETREE", ".dtb")
// Each ZBI starts with a container header.
// length: Total size of the image after this header.
@@ -197,12 +208,12 @@
// The kernel assumes it was loaded at a fixed physical address of
// 0x100000 (1MB). zbi_kernel_t.entry is the absolute physical address
// of the PC location where the kernel will start.
-// TODO(SEC-31): Perhaps this will change??
+// TODO(fxbug.dev/24762): Perhaps this will change??
// The processor is in 64-bit mode with direct virtual to physical
// mapping covering the physical memory where the kernel and
-// bootloader-constructed ZBI were loaded, which must be below 4GB.
-// The %rsi register (or %esi, since the high 32 bits must be zero)
-// holds the physical address of the bootloader-constructed ZBI.
+// bootloader-constructed ZBI were loaded.
+// The %rsi register holds the physical address of the
+// bootloader-constructed ZBI.
// All other registers are unspecified.
//
// ARM64
@@ -257,12 +268,29 @@
// The interpretation of the payload (after possible decompression) is
// indicated by the specific zbi_header_t.type value.
//
-// If ZBI_FLAG_STORAGE_COMPRESSED is set in zbi_header_t.flags, then the
-// payload is compressed with LZ4 and zbi_header_t.extra gives the exact
-// size of the decompressed payload. If ZBI_FLAG_STORAGE_COMPRESSED is
-// not set, then zbi_header_t.extra matches zbi_header_t.length.
+// **Note:** The ZBI_TYPE_STORAGE_* types are not a long-term stable ABI.
+// - Items of these types are always packed for a specific version of the
+// kernel and userland boot services, often in the same build that compiles
+// the kernel.
+// - These item types are **not** expected to be synthesized or
+// examined by boot loaders.
+// - New versions of the `zbi` tool will usually retain the ability to
+// read old formats and non-default switches to write old formats, for
+// diagnostic use.
//
-// TODO(mcgrathr): Document or point to the details of the LZ4 header format.
+// The zbi_header_t.extra field always gives the exact size of the
+// original, uncompressed payload. That equals zbi_header_t.length when
+// the payload is not compressed. If ZBI_FLAG_STORAGE_COMPRESSED is set in
+// zbi_header_t.flags, then the payload is compressed.
+//
+// **Note:** Magic-number and header bytes at the start of the compressed
+// payload indicate the compression algorithm and parameters. The set of
+// compression formats is not a long-term stable ABI.
+// - Zircon [userboot](../../../../docs/userboot.md) and core services
+// do the decompression. A given kernel build's `userboot` will usually
+// only support one particular compression format.
+// - The `zbi` tool will usually retain the ability to compress and
+// decompress for old formats, and can be used to convert between formats.
#define ZBI_FLAG_STORAGE_COMPRESSED (0x00000001)
// A virtual disk image. This is meant to be treated as if it were a
@@ -270,72 +298,14 @@
// the storage device, in whatever format that might be.
#define ZBI_TYPE_STORAGE_RAMDISK (0x4b534452) // RDSK
-// The /boot filesystem in BOOTFS format, specified below.
+// The /boot filesystem in BOOTFS format, specified in <zircon/boot/bootfs.h>.
// A complete ZBI must have exactly one ZBI_TYPE_STORAGE_BOOTFS item.
// Zircon [userboot](../../../../docs/userboot.md) handles the contents
// of this filesystem.
#define ZBI_TYPE_STORAGE_BOOTFS (0x42534642) // BFSB
-// The payload (after decompression) of an item in BOOTFS format consists
-// of separate "file" images that are each aligned to ZBI_BOOTFS_PAGE_SIZE
-// bytes from the beginning of the item payload. The first "file" consists
-// of a zbi_bootfs_header_t followed by directory entries.
-#define ZBI_BOOTFS_PAGE_SIZE (4096u)
-
-#define ZBI_BOOTFS_PAGE_ALIGN(size) \
- (((size) + ZBI_BOOTFS_PAGE_SIZE - 1) & -ZBI_BOOTFS_PAGE_SIZE)
-
-#ifndef __ASSEMBLER__
-typedef struct {
- // Must be ZBI_BOOTFS_MAGIC.
- uint32_t magic;
-
- // Size in bytes of all the directory entries.
- // Does not include the size of the zbi_bootfs_header_t.
- uint32_t dirsize;
-
- // Reserved for future use. Set to 0.
- uint32_t reserved0;
- uint32_t reserved1;
-} zbi_bootfs_header_t;
-#endif
-
-// LSW of sha256("bootfs")
-#define ZBI_BOOTFS_MAGIC (0xa56d3ff9)
-
-// Each directory entry holds a pathname and gives the offset and size
-// of the contents of the file by that name.
-#ifndef __ASSEMBLER__
-typedef struct {
- // Length of the name[] field at the end. This length includes the
- // NUL terminator, which must be present, but does not include any
- // alignment padding required before the next directory entry.
- uint32_t name_len;
-
- // Length of the file in bytes. This is an exact size that is not
- // rounded, though the file is always padded with zeros up to a
- // multiple of ZBI_BOOTFS_PAGE_SIZE.
- uint32_t data_len;
-
- // Offset from the beginning of the payload (zbi_bootfs_header_t) to
- // the file's data. This must be a multiple of ZBI_BOOTFS_PAGE_SIZE.
- uint32_t data_off;
-
- // Pathname of the file, a UTF-8 string. This must include a NUL
- // terminator at the end. It must not begin with a '/', but it may
- // contain '/' separators for subdirectories.
- char name[];
-} zbi_bootfs_dirent_t;
-#endif
-
-// Each directory entry has a variable size of [16,268] bytes that
-// must be a multiple of 4 bytes.
-#define ZBI_BOOTFS_DIRENT_SIZE(name_len) \
- ((sizeof(zbi_bootfs_dirent_t) + (name_len) + 3) & -(size_t)4)
-
-// zbi_bootfs_dirent_t.name_len must be > 1 and <= ZBI_BOOTFS_MAX_NAME_LEN.
-#define ZBI_BOOTFS_MAX_NAME_LEN (256)
-
+// Device-specific factory data, stored in BOOTFS format, specified below.
+#define ZBI_TYPE_STORAGE_BOOTFS_FACTORY (0x46534642) // BFSF
// The remaining types are used to communicate information from the boot
// loader to the kernel. Usually these are synthesized in memory by the
@@ -380,6 +350,14 @@
} zbi_platform_id_t;
#endif
+#define ZBI_TYPE_DRV_BOARD_INFO (0x4953426D) // mBSI
+// Board-specific information.
+#ifndef __ASSEMBLER__
+typedef struct {
+ uint32_t revision;
+} zbi_board_info_t;
+#endif
+
// CPU configuration, a zbi_cpu_config_t header followed by one or more
// zbi_cpu_cluster_t entries. zbi_header_t.length must equal
// zbi_cpu_config_t.cluster_count * sizeof(zbi_cpu_cluster_t).
@@ -447,7 +425,9 @@
} zbi_topology_arm_info_t;
typedef struct {
- uint32_t apic_id;
+ // Indexes here correspond to the logical_ids index for the thread.
+ uint32_t apic_ids[ZBI_MAX_SMT];
+ uint32_t apic_id_count;
} zbi_topology_x86_info_t;
typedef struct {
@@ -467,14 +447,33 @@
} zbi_topology_processor_t;
typedef struct {
- // Relative performance level of this processor in the system, with 0
- // representing the lowest performance.
- // For example on a two cluster ARM big.LITTLE system 0 would be the little
- // cores and 1 would represent the big cores.
+ // Relative performance level of this processor in the system. The value is
+ // interpreted as the performance of this processor relative to the maximum
+ // performance processor in the system. No specific values are required for
+ // the performance level, only that the following relationship holds:
+ //
+ // Pmax is the value of performance_class for the maximum performance
+ // processor in the system, operating at its maximum operating point.
+ //
+ // P is the value of performance_class for this processor, operating at
+ // its maximum operating point.
+ //
+ // R is the performance ratio of this processor to the maximum performance
+ // processor in the system in the range (0.0, 1.0].
+ //
+ // R = (P + 1) / (Pmax + 1)
+ //
+ // If accuracy is limited, choose a conservative value that slightly under-
+ // estimates the performance of lower-performance processors.
uint8_t performance_class;
} zbi_topology_cluster_t;
typedef struct {
+ // Unique id of this cache node. No other semantics are assumed.
+ uint32_t cache_id;
+} zbi_topology_cache_t;
+
+typedef struct {
// Starting and ending memory addresses of this numa region.
uint64_t start_address;
uint64_t end_address;
@@ -499,6 +498,7 @@
zbi_topology_processor_t processor;
zbi_topology_cluster_t cluster;
zbi_topology_numa_region_t numa_region;
+ zbi_topology_cache_t cache;
} entity;
} zbi_topology_node_t;
@@ -544,29 +544,18 @@
#define ZIRCON_VENDOR_GUID \
{0x82305eb2, 0xd39e, 0x4575, {0xa0, 0xc8, 0x6c, 0x20, 0x72, 0xd0, 0x84, 0x4c}}
#define ZIRCON_CRASHLOG_EFIVAR \
- { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 };
+ { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 }
#define ZIRCON_CRASHLOG_EFIATTR \
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
-// Debug serial port, a zbi_uart_t entry.
-#define ZBI_TYPE_DEBUG_UART (0x54524155) // UART
-#ifndef __ASSEMBLER__
-typedef struct {
- uint64_t base;
- uint32_t type;
- uint32_t irq;
-} zbi_uart_t;
-#endif
-#define ZBI_UART_NONE (0)
-#define ZBI_UART_PC_PORT (1)
-#define ZBI_UART_PC_MMIO (2)
-
// Framebuffer parameters, a zbi_swfb_t entry.
#define ZBI_TYPE_FRAMEBUFFER (0x42465753) // SWFB
-// A copy of the boot configuration stored as a kvstore
-// within the sysconfig partition.
-#define ZBI_TYPE_BOOT_CONFIG (0x47464342) // BCFG
+// The image arguments, data is a trivial text format of one "key=value" per line
+// with leading whitespace stripped and "#" comment lines and blank lines ignored.
+// It is processed by bootsvc and parsed args are shared to others via Arguments service.
+// TODO: the format can be streamlined after the /config/devmgr compat support is removed.
+#define ZBI_TYPE_IMAGE_ARGS (0x47524149) // IARG
// A copy of the boot version stored within the sysconfig
// partition
@@ -602,6 +591,10 @@
#define ZBI_TYPE_DRV_PARTITION_MAP (0x5452506D) // mPRT
#define ZBI_PARTITION_NAME_LEN (32)
#define ZBI_PARTITION_GUID_LEN (16)
+
+// Private information for the board driver.
+#define ZBI_TYPE_DRV_BOARD_PRIVATE (0x524F426D) // mBOR
+
#ifndef __ASSEMBLER__
typedef struct {
// GUID specifying the format and use of data stored in the partition.
@@ -639,3 +632,50 @@
zbi_partition_t partitions[];
} zbi_partition_map_t;
#endif
+
+
+#define ZBI_TYPE_HW_REBOOT_REASON (0x42525748) // HWRB
+
+#define ZBI_HW_REBOOT_UNDEFINED ((uint32_t)0)
+#define ZBI_HW_REBOOT_COLD ((uint32_t)1)
+#define ZBI_HW_REBOOT_WARM ((uint32_t)2)
+#define ZBI_HW_REBOOT_BROWNOUT ((uint32_t)3)
+#define ZBI_HW_REBOOT_WATCHDOG ((uint32_t)4)
+
+#ifndef __ASSEMBLER__
+#ifndef __cplusplus
+typedef uint32_t zbi_hw_reboot_reason_t;
+#else
+enum class ZbiHwRebootReason : uint32_t {
+ Undefined = ZBI_HW_REBOOT_UNDEFINED,
+ Cold = ZBI_HW_REBOOT_COLD,
+ Warm = ZBI_HW_REBOOT_WARM,
+ Brownout = ZBI_HW_REBOOT_BROWNOUT,
+ Watchdog = ZBI_HW_REBOOT_WATCHDOG,
+};
+using zbi_hw_reboot_reason_t = ZbiHwRebootReason;
+#endif // __cplusplus
+#endif // __ASSEMBLER__
+
+// The serial number, an unterminated ASCII string of printable non-whitespace
+// characters with length zbi_header_t.length.
+#define ZBI_TYPE_SERIAL_NUMBER (0x4e4c5253) // SRLN
+
+// This type specifies a binary file passed in by the bootloader.
+// The first byte specifies the length of the filename without a NUL terminator.
+// The filename starts on the second byte.
+// The file contents are located immediately after the filename.
+//
+// Layout: | name_len | name | payload
+// ^(1 byte) ^(name_len bytes) ^(length of file)
+#define ZBI_TYPE_BOOTLOADER_FILE (0x4C465442) // BTFL
+
+// The devicetree blob from the legacy boot loader, if any. This is used only
+// for diagnostic and development purposes. Zircon kernel and driver
+// configuration is entirely driven by specific ZBI items from the boot
+// loader. The boot shims for legacy boot loaders pass the raw devicetree
+// along for development purposes, but extract information from it to populate
+// specific ZBI items such as ZBI_TYPE_KERNEL_DRIVER et al.
+#define ZBI_TYPE_DEVICETREE (0xd00dfeed)
+
+#endif // SYSROOT_ZIRCON_BOOT_IMAGE_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/multiboot.h b/arch/arm64/sysroot/include/zircon/boot/multiboot.h
index 0076832..85cf0a6 100644
--- a/arch/arm64/sysroot/include/zircon/boot/multiboot.h
+++ b/arch/arm64/sysroot/include/zircon/boot/multiboot.h
@@ -1,23 +1,22 @@
-// Copyright 2016 The Fuchsia Authors
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Copyright (c) 2009 Corey Tabaka
-//
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file or at
-// https://opensource.org/licenses/MIT
-#ifndef __PLATFORM_MULTIBOOT_H
-#define __PLATFORM_MULTIBOOT_H
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_MULTIBOOT_H_
+#define SYSROOT_ZIRCON_MULTIBOOT_H_
/* magic number for multiboot header */
-#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
// Flags for multiboot header:
// 0x00000002: Boot loader should provide memory map.
// 0x00010000: *_addr fields in multiboot_header_t are used.
-#define MULTIBOOT_HEADER_FLAGS 0x00010002
+#define MULTIBOOT_HEADER_FLAGS 0x00010002
/* magic number passed by multiboot-compliant boot loaders */
-#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
+#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
#ifndef __ASSEMBLER__
@@ -25,52 +24,52 @@
/* multiboot header */
typedef struct multiboot_header {
- uint32_t magic;
- uint32_t flags;
- uint32_t checksum;
- uint32_t header_addr;
- uint32_t load_addr;
- uint32_t load_end_addr;
- uint32_t bss_end_addr;
- uint32_t entry_addr;
+ uint32_t magic;
+ uint32_t flags;
+ uint32_t checksum;
+ uint32_t header_addr;
+ uint32_t load_addr;
+ uint32_t load_end_addr;
+ uint32_t bss_end_addr;
+ uint32_t entry_addr;
} multiboot_header_t;
/* symbol table for a.out */
typedef struct aout_symbol_table {
- uint32_t tabsize;
- uint32_t strsize;
- uint32_t addr;
- uint32_t reserved;
+ uint32_t tabsize;
+ uint32_t strsize;
+ uint32_t addr;
+ uint32_t reserved;
} aout_symbol_table_t;
/* section header table for ELF */
typedef struct elf_section_header_table {
- uint32_t num;
- uint32_t size;
- uint32_t addr;
- uint32_t shndx;
+ uint32_t num;
+ uint32_t size;
+ uint32_t addr;
+ uint32_t shndx;
} elf_section_header_table_t;
/* multiboot info */
typedef struct multiboot_info {
- uint32_t flags;
- uint32_t mem_lower;
- uint32_t mem_upper;
- uint32_t boot_device;
- uint32_t cmdline;
- uint32_t mods_count;
- uint32_t mods_addr;
- union {
- aout_symbol_table_t aout_sym;
- elf_section_header_table_t elf_sec;
- } u;
- uint32_t mmap_length;
- uint32_t mmap_addr;
- uint32_t drives_length;
- uint32_t drives_addr;
- uint32_t config_table;
- uint32_t boot_loader_name;
- uint32_t apm_table;
+ uint32_t flags;
+ uint32_t mem_lower;
+ uint32_t mem_upper;
+ uint32_t boot_device;
+ uint32_t cmdline;
+ uint32_t mods_count;
+ uint32_t mods_addr;
+ union {
+ aout_symbol_table_t aout_sym;
+ elf_section_header_table_t elf_sec;
+ } u;
+ uint32_t mmap_length;
+ uint32_t mmap_addr;
+ uint32_t drives_length;
+ uint32_t drives_addr;
+ uint32_t config_table;
+ uint32_t boot_loader_name;
+ uint32_t apm_table;
} multiboot_info_t;
#define MB_INFO_MEM_SIZE 0x001
@@ -88,20 +87,20 @@
/* module structure */
typedef struct module {
- uint32_t mod_start;
- uint32_t mod_end;
- uint32_t string;
- uint32_t reserved;
+ uint32_t mod_start;
+ uint32_t mod_end;
+ uint32_t string;
+ uint32_t reserved;
} module_t;
/* memory map - be careful that the offset 0 is base_addr_low without size */
typedef struct memory_map {
- uint32_t size;
- uint32_t base_addr_low;
- uint32_t base_addr_high;
- uint32_t length_low;
- uint32_t length_high;
- uint32_t type;
+ uint32_t size;
+ uint32_t base_addr_low;
+ uint32_t base_addr_high;
+ uint32_t length_low;
+ uint32_t length_high;
+ uint32_t type;
} memory_map_t;
/* memory map entry types */
@@ -112,4 +111,4 @@
#endif
-#endif
+#endif // SYSROOT_ZIRCON_BOOT_MULTIBOOT_
diff --git a/arch/arm64/sysroot/include/zircon/boot/netboot.h b/arch/arm64/sysroot/include/zircon/boot/netboot.h
index 25973c6..1586352 100644
--- a/arch/arm64/sysroot/include/zircon/boot/netboot.h
+++ b/arch/arm64/sysroot/include/zircon/boot/netboot.h
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_NETBOOT_H_
+#define SYSROOT_ZIRCON_BOOT_NETBOOT_H_
#include <stddef.h>
#include <stdint.h>
+#include <zircon/types.h>
// clang-format off
-#define BOOTLOADER_VERSION "0.7.13"
+#define BOOTLOADER_VERSION "0.7.22"
#define NB_MAGIC 0xAA774217
#define NB_DEBUGLOG_MAGIC 0xAEAE1123
@@ -34,6 +36,7 @@
#define NB_CLOSE 10 // arg=0
#define NB_LAST_DATA 11 // arg=offset, data=data
#define NB_REBOOT 12 // arg=0
+#define NB_GET_ADVERT 13 // arg=0
#define NB_ACK 0 // arg=0 or -err, NB_READ: data=data
#define NB_FILE_RECEIVED 0x70000001 // arg=size
@@ -62,10 +65,17 @@
#define NB_FVM_FILENAME NB_IMAGE_PREFIX NB_FVM_HOST_FILENAME
#define NB_BOOTLOADER_HOST_FILENAME "bootloader.img"
#define NB_BOOTLOADER_FILENAME NB_IMAGE_PREFIX NB_BOOTLOADER_HOST_FILENAME
-#define NB_EFI_HOST_FILENAME "efi.img"
-#define NB_EFI_FILENAME NB_IMAGE_PREFIX NB_EFI_HOST_FILENAME
-#define NB_KERNC_HOST_FILENAME "kernc.img"
-#define NB_KERNC_FILENAME NB_IMAGE_PREFIX NB_KERNC_HOST_FILENAME
+// Firmware images are slightly different, as they have an optional type suffix:
+// firmware_ <- type = "" (the default)
+// firmware_foo <- type = "foo"
+#define NB_FIRMWARE_HOST_FILENAME_PREFIX "firmware_"
+#define NB_FIRMWARE_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWARE_HOST_FILENAME_PREFIX
+#define NB_FIRMWAREA_HOST_FILENAME_PREFIX "firmwarea_"
+#define NB_FIRMWAREA_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWAREA_HOST_FILENAME_PREFIX
+#define NB_FIRMWAREB_HOST_FILENAME_PREFIX "firmwareb_"
+#define NB_FIRMWAREB_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWAREB_HOST_FILENAME_PREFIX
+#define NB_FIRMWARER_HOST_FILENAME_PREFIX "firmwarer_"
+#define NB_FIRMWARER_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWARER_HOST_FILENAME_PREFIX
#define NB_ZIRCONA_HOST_FILENAME "zircona.img"
#define NB_ZIRCONA_FILENAME NB_IMAGE_PREFIX NB_ZIRCONA_HOST_FILENAME
#define NB_ZIRCONB_HOST_FILENAME "zirconb.img"
@@ -76,8 +86,36 @@
#define NB_VBMETAA_FILENAME NB_IMAGE_PREFIX NB_VBMETAA_HOST_FILENAME
#define NB_VBMETAB_HOST_FILENAME "vbmetab.img"
#define NB_VBMETAB_FILENAME NB_IMAGE_PREFIX NB_VBMETAB_HOST_FILENAME
+#define NB_VBMETAR_HOST_FILENAME "vbmetar.img"
+#define NB_VBMETAR_FILENAME NB_IMAGE_PREFIX NB_VBMETAR_HOST_FILENAME
#define NB_SSHAUTH_HOST_FILENAME "authorized_keys"
#define NB_SSHAUTH_FILENAME NB_IMAGE_PREFIX NB_SSHAUTH_HOST_FILENAME
+#define NB_BOARD_NAME_HOST_FILENAME "board_name"
+#define NB_BOARD_NAME_FILENAME NB_IMAGE_PREFIX NB_BOARD_NAME_HOST_FILENAME
+#define NB_BOARD_REVISION_HOST_FILENAME "board_revision"
+#define NB_BOARD_REVISION_FILENAME NB_IMAGE_PREFIX NB_BOARD_REVISION_HOST_FILENAME
+#define NB_BOARD_INFO_HOST_FILENAME "board_info"
+#define NB_BOARD_INFO_FILENAME NB_IMAGE_PREFIX NB_BOARD_INFO_HOST_FILENAME
+#define NB_INIT_PARTITION_TABLES_HOST_FILENAME "init_partition_tables"
+#define NB_INIT_PARTITION_TABLES_FILENAME NB_IMAGE_PREFIX NB_INIT_PARTITION_TABLES_HOST_FILENAME
+#define NB_WIPE_PARTITION_TABLES_HOST_FILENAME "wipe_partition_tables"
+#define NB_WIPE_PARTITION_TABLES_FILENAME NB_IMAGE_PREFIX NB_WIPE_PARTITION_TABLES_HOST_FILENAME
+
+// Should match paver FIDL definition.
+// Length does not include the '\0' terminator, so when allocating a character
+// buffer to hold the type use (NB_FIRMWARE_TYPE_MAX_LENGTH + 1).
+#define NB_FIRMWARE_TYPE_MAX_LENGTH 256
+
+typedef struct board_info {
+ char board_name[ZX_MAX_NAME_LEN];
+ uint32_t board_revision;
+ uint8_t mac_address[8];
+} board_info_t;
+
+typedef struct modify_partition_table_info {
+ // Path of block device to initialize or wipe.
+ char block_device_path[ZX_MAX_NAME_LEN + 1];
+} modify_partition_table_info_t;
typedef struct nbmsg_t {
uint32_t magic;
@@ -114,3 +152,5 @@
char nodename[MAX_NODENAME_LENGTH];
char data[MAX_LOG_DATA];
} logpacket_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_NETBOOT_H_
diff --git a/arch/arm64/sysroot/include/zircon/boot/sysconfig.h b/arch/arm64/sysroot/include/zircon/boot/sysconfig.h
index fe59efa..1f7d49b 100644
--- a/arch/arm64/sysroot/include/zircon/boot/sysconfig.h
+++ b/arch/arm64/sysroot/include/zircon/boot/sysconfig.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
+#define SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
// Zircon sysconfig partition format
//
@@ -19,8 +20,10 @@
// If present, this overrides boot-default, and the bootloader
// deletes this section after use.
-#define ZX_SYSCONFIG_KVSTORE_SIZE 32768
-#define ZX_SYSCONFIG_VERSION_A_OFFSET (0 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_VERSION_B_OFFSET (1 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_BOOT_DEFAULT_OFFSET (2 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_BOOT_ONESHOT_OFFSET (3 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_KVSTORE_SIZE 32768
+#define ZX_SYSCONFIG_VERSION_A_OFFSET (0 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_VERSION_B_OFFSET (1 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_BOOT_DEFAULT_OFFSET (2 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_BOOT_ONESHOT_OFFSET (3 * ZX_SYSCONFIG_KVSTORE_SIZE)
+
+#endif // SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
diff --git a/arch/arm64/sysroot/include/zircon/compiler.h b/arch/arm64/sysroot/include/zircon/compiler.h
index fb3bb42..ce2bcea 100644
--- a/arch/arm64/sysroot/include/zircon/compiler.h
+++ b/arch/arm64/sysroot/include/zircon/compiler.h
@@ -2,7 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_COMPILER_H_
+#define SYSROOT_ZIRCON_COMPILER_H_
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(x) 0
+#endif
#ifndef __ASSEMBLER__
@@ -10,14 +19,14 @@
#error "Unrecognized compiler!"
#endif
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
#define __UNUSED __attribute__((__unused__))
#define __USED __attribute__((__used__))
#define __PACKED __attribute__((packed))
#define __ALIGNED(x) __attribute__((aligned(x)))
-#define __PRINTFLIKE(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))
-#define __SCANFLIKE(__fmt,__varargs) __attribute__((__format__ (__scanf__, __fmt, __varargs)))
+#define __PRINTFLIKE(__fmt, __varargs) __attribute__((__format__(__printf__, __fmt, __varargs)))
+#define __SCANFLIKE(__fmt, __varargs) __attribute__((__format__(__scanf__, __fmt, __varargs)))
#define __SECTION(x) __attribute__((__section__(x)))
#define __PURE __attribute__((__pure__))
#define __CONST __attribute__((__const__))
@@ -39,18 +48,21 @@
#define __LEAF_FN __attribute__((__leaf__))
#define __OPTIMIZE(x) __attribute__((__optimize__(x)))
#define __EXTERNALLY_VISIBLE __attribute__((__externally_visible__))
-#define __THREAD_ANNOTATION(x)
#define __NO_SAFESTACK
+#define __THREAD_ANNOTATION(x)
#else
#define __LEAF_FN
#define __OPTIMIZE(x)
#define __EXTERNALLY_VISIBLE
+// The thread safety annotations are frequently used with C++ standard library
+// types in userspace, so only enable the annotations if we know that the C++
+// standard library types are annotated or if we're in kernel code.
+#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) || defined(_KERNEL)
#define __THREAD_ANNOTATION(x) __attribute__((x))
-#define __NO_SAFESTACK __attribute__((__no_sanitize__("safe-stack")))
-#endif
-
-#ifndef __has_feature
-#define __has_feature(x) 0
+#else
+#define __THREAD_ANNOTATION(x)
+#endif // _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+#define __NO_SAFESTACK __attribute__((__no_sanitize__("safe-stack", "shadow-call-stack")))
#endif
#define __ALWAYS_INLINE __attribute__((__always_inline__))
@@ -60,19 +72,51 @@
#define __UNREACHABLE __builtin_unreachable()
#define __WEAK_ALIAS(x) __attribute__((__weak__, __alias__(x)))
#define __ALIAS(x) __attribute__((__alias__(x)))
-#define __EXPORT __attribute__ ((__visibility__("default")))
-#define __LOCAL __attribute__ ((__visibility__("hidden")))
+#define __EXPORT __attribute__((__visibility__("default")))
+#define __LOCAL __attribute__((__visibility__("hidden")))
#define __THREAD __thread
#define __offsetof(type, field) __builtin_offsetof(type, field)
+// Only define __NO_UNIQUE_ADDRESS for C++, since it doesn't make sense in C.
+#ifdef __cplusplus
+#if __has_cpp_attribute(no_unique_address)
+#define __NO_UNIQUE_ADDRESS [[no_unique_address]]
+#else
+#define __NO_UNIQUE_ADDRESS
+#endif
+#endif // ifdef __cplusplus
+
#if defined(__cplusplus) && __cplusplus >= 201703L
#define __FALLTHROUGH [[fallthrough]]
#elif defined(__cplusplus) && defined(__clang__)
#define __FALLTHROUGH [[clang::fallthrough]]
-#elif __GNUC__ >= 7
+// The GNU style attribute is supported by Clang for C code, but __GNUC__ for
+// clang right now is 4.
+#elif __GNUC__ >= 7 || (!defined(__cplusplus) && defined(__clang__))
#define __FALLTHROUGH __attribute__((__fallthrough__))
#else
-#define __FALLTHROUGH do {} while (0)
+#define __FALLTHROUGH \
+ do { \
+ } while (0)
+#endif
+
+// C++17 onwards supports [[nodiscard]] on a constructor, warning if
+// a temporary object is created without a name. Such objects would be
+// immediately destroyed again, while the user's expectation might be
+// that it would last the scope.
+//
+// We could ideally just use [[nodiscard]] (or __WARN_UNUSED_RESULT)
+// directly, except GCC < 10.0 has a bug preventing it from being used
+// on constructors. __WARN_UNUSED_CONSTRUCTOR allows us to tag
+// constructors in supported compilers, and is simply ignored in older
+// compilers.
+#if defined(__cplusplus)
+// Clang and GCC versions >= 10.0 support [[nodiscard]] on constructors.
+#if __cplusplus >= 201703L && (defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 10)))
+#define __WARN_UNUSED_CONSTRUCTOR [[nodiscard]]
+#else
+#define __WARN_UNUSED_CONSTRUCTOR
+#endif
#endif
// Publicly exposed thread annotation macros. These have a long and ugly name to
@@ -80,12 +124,17 @@
#define __TA_CAPABILITY(x) __THREAD_ANNOTATION(__capability__(x))
#define __TA_GUARDED(x) __THREAD_ANNOTATION(__guarded_by__(x))
#define __TA_ACQUIRE(...) __THREAD_ANNOTATION(__acquire_capability__(__VA_ARGS__))
+#define __TA_ACQUIRE_SHARED(...) __THREAD_ANNOTATION(__acquire_shared_capability__(__VA_ARGS__))
#define __TA_TRY_ACQUIRE(...) __THREAD_ANNOTATION(__try_acquire_capability__(__VA_ARGS__))
#define __TA_ACQUIRED_BEFORE(...) __THREAD_ANNOTATION(__acquired_before__(__VA_ARGS__))
#define __TA_ACQUIRED_AFTER(...) __THREAD_ANNOTATION(__acquired_after__(__VA_ARGS__))
#define __TA_RELEASE(...) __THREAD_ANNOTATION(__release_capability__(__VA_ARGS__))
+#define __TA_RELEASE_SHARED(...) __THREAD_ANNOTATION(__release_shared_capability__(__VA_ARGS__))
#define __TA_REQUIRES(...) __THREAD_ANNOTATION(__requires_capability__(__VA_ARGS__))
+#define __TA_REQUIRES_SHARED(...) __THREAD_ANNOTATION(__requires_shared_capability__(__VA_ARGS__))
#define __TA_EXCLUDES(...) __THREAD_ANNOTATION(__locks_excluded__(__VA_ARGS__))
+#define __TA_ASSERT(...) __THREAD_ANNOTATION(__assert_capability__(__VA_ARGS__))
+#define __TA_ASSERT_SHARED(...) __THREAD_ANNOTATION(__assert_shared_capability__(__VA_ARGS__))
#define __TA_RETURN_CAPABILITY(x) __THREAD_ANNOTATION(__lock_returned__(x))
#define __TA_SCOPED_CAPABILITY __THREAD_ANNOTATION(__scoped_lockable__)
#define __TA_NO_THREAD_SAFETY_ANALYSIS __THREAD_ANNOTATION(__no_thread_safety_analysis__)
@@ -103,8 +152,8 @@
/* CPP header guards */
#ifdef __cplusplus
-#define __BEGIN_CDECLS extern "C" {
-#define __END_CDECLS }
+#define __BEGIN_CDECLS extern "C" {
+#define __END_CDECLS }
#else
#define __BEGIN_CDECLS
#define __END_CDECLS
@@ -120,3 +169,23 @@
#define add_overflow(a, b, c) __builtin_add_overflow(a, b, c)
#define sub_overflow(a, b, c) __builtin_sub_overflow(a, b, c)
#define mul_overflow(a, b, c) __builtin_mul_overflow(a, b, c)
+
+// A workaround to help static analyzer identify assertion failures
+#if defined(__clang__)
+#define __ANALYZER_CREATE_SINK __attribute__((analyzer_noreturn))
+#else
+#define __ANALYZER_CREATE_SINK // no-op
+#endif
+
+// Lifetime analysis
+#ifndef __OWNER
+#ifdef __clang__
+#define __OWNER(x) [[gsl::Owner(x)]]
+#define __POINTER(x) [[gsl::Pointer(x)]]
+#else
+#define __OWNER(x)
+#define __POINTER(x)
+#endif
+#endif
+
+#endif // SYSROOT_ZIRCON_COMPILER_H_
diff --git a/arch/arm64/sysroot/include/zircon/device/audio.h b/arch/arm64/sysroot/include/zircon/device/audio.h
new file mode 100644
index 0000000..01b966e
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/device/audio.h
@@ -0,0 +1,467 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_DEVICE_AUDIO_H_
+#define SYSROOT_ZIRCON_DEVICE_AUDIO_H_
+
+#include <sys/types.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+#include <cassert>
+#include <cstdio>
+
+// When communicating with an Audio driver using zx_channel_call, do not use
+// the AUDIO_INVALID_TRANSACTION_ID as your message's transaction ID. It is
+// reserved for async notifications sent from the driver to the application.
+#define AUDIO_INVALID_TRANSACTION_ID ((zx_txid_t)0)
+
+__BEGIN_CDECLS
+
+typedef uint32_t audio_cmd_t;
+
+// Commands sent on the stream channel
+#define AUDIO_STREAM_CMD_GET_FORMATS ((audio_cmd_t)0x1000)
+#define AUDIO_STREAM_CMD_SET_FORMAT ((audio_cmd_t)0x1001)
+#define AUDIO_STREAM_CMD_GET_GAIN ((audio_cmd_t)0x1002)
+#define AUDIO_STREAM_CMD_SET_GAIN ((audio_cmd_t)0x1003)
+#define AUDIO_STREAM_CMD_PLUG_DETECT ((audio_cmd_t)0x1004)
+#define AUDIO_STREAM_CMD_GET_UNIQUE_ID ((audio_cmd_t)0x1005)
+#define AUDIO_STREAM_CMD_GET_STRING ((audio_cmd_t)0x1006)
+#define AUDIO_STREAM_CMD_GET_CLOCK_DOMAIN ((audio_cmd_t)0x1007)
+
+// Async notifications sent on the stream channel.
+#define AUDIO_STREAM_PLUG_DETECT_NOTIFY ((audio_cmd_t)0x2000)
+
+// Commands sent on the ring buffer channel
+#define AUDIO_RB_CMD_GET_FIFO_DEPTH ((audio_cmd_t)0x3000)
+#define AUDIO_RB_CMD_GET_BUFFER ((audio_cmd_t)0x3001)
+#define AUDIO_RB_CMD_START ((audio_cmd_t)0x3002)
+#define AUDIO_RB_CMD_STOP ((audio_cmd_t)0x3003)
+
+// Async notifications sent on the ring buffer channel.
+#define AUDIO_RB_POSITION_NOTIFY ((audio_cmd_t)0x4000)
+
+// Flags used to modify commands.
+// The NO_ACK flag can be used with the SET_GAIN and PLUG_DETECT commands.
+#define AUDIO_FLAG_NO_ACK ((audio_cmd_t)0x80000000)
+
+typedef struct audio_cmd_hdr {
+ zx_txid_t transaction_id;
+ audio_cmd_t cmd;
+} audio_cmd_hdr_t;
+
+static_assert(sizeof(audio_cmd_hdr_t) == 8,
+ "audio_cmd_hdr_t should be 8 bytes! "
+ "If sizeof(zx_txid_t has changed from 4 to 8, "
+ "consider repacking the structs in audio.h");
+
+// audio_sample_format_t
+//
+// Bitfield which describes audio sample format as they reside in memory.
+//
+typedef uint32_t audio_sample_format_t;
+#define AUDIO_SAMPLE_FORMAT_BITSTREAM ((audio_sample_format_t)(1u << 0))
+#define AUDIO_SAMPLE_FORMAT_8BIT ((audio_sample_format_t)(1u << 1))
+#define AUDIO_SAMPLE_FORMAT_16BIT ((audio_sample_format_t)(1u << 2))
+#define AUDIO_SAMPLE_FORMAT_20BIT_PACKED ((audio_sample_format_t)(1u << 4))
+#define AUDIO_SAMPLE_FORMAT_24BIT_PACKED ((audio_sample_format_t)(1u << 5))
+#define AUDIO_SAMPLE_FORMAT_20BIT_IN32 ((audio_sample_format_t)(1u << 6))
+#define AUDIO_SAMPLE_FORMAT_24BIT_IN32 ((audio_sample_format_t)(1u << 7))
+#define AUDIO_SAMPLE_FORMAT_32BIT ((audio_sample_format_t)(1u << 8))
+#define AUDIO_SAMPLE_FORMAT_32BIT_FLOAT ((audio_sample_format_t)(1u << 9))
+#define AUDIO_SAMPLE_FORMAT_FLAG_UNSIGNED ((audio_sample_format_t)(1u << 30))
+#define AUDIO_SAMPLE_FORMAT_FLAG_INVERT_ENDIAN ((audio_sample_format_t)(1u << 31))
+#define AUDIO_SAMPLE_FORMAT_FLAG_MASK \
+ ((audio_sample_format_t)(AUDIO_SAMPLE_FORMAT_FLAG_UNSIGNED | \
+ AUDIO_SAMPLE_FORMAT_FLAG_INVERT_ENDIAN))
+
+// audio_stream_format_range_t
+//
+// A structure used along with the AUDIO_STREAM_CMD_GET_FORMATS command in order
+// to describe the formats supported by an audio stream.
+#define ASF_RANGE_FLAG_FPS_CONTINUOUS ((uint16_t)(1u << 0))
+#define ASF_RANGE_FLAG_FPS_48000_FAMILY ((uint16_t)(1u << 1))
+#define ASF_RANGE_FLAG_FPS_44100_FAMILY ((uint16_t)(1u << 2))
+typedef struct audio_stream_format_range {
+ audio_sample_format_t sample_formats;
+ uint32_t min_frames_per_second;
+ uint32_t max_frames_per_second;
+ uint8_t min_channels;
+ uint8_t max_channels;
+ uint16_t flags;
+} __PACKED audio_stream_format_range_t;
+
+static_assert(sizeof(audio_stream_format_range_t) == 16,
+ "audio_stream_format_range_t should be 16 bytes!");
+
+// audio_set_gain_flags_t
+//
+// Flags used by the AUDIO_STREAM_CMD_SET_GAIN message.
+//
+typedef uint32_t audio_set_gain_flags_t;
+#define AUDIO_SGF_MUTE_VALID \
+ ((audio_set_gain_flags_t)0x1) // Whether or not the mute flag is valid.
+#define AUDIO_SGF_AGC_VALID ((audio_set_gain_flags_t)0x2) // Whether or not the agc flag is valid.
+#define AUDIO_SGF_GAIN_VALID \
+ ((audio_set_gain_flags_t)0x4) // Whether or not the gain float is valid.
+#define AUDIO_SGF_MUTE ((audio_set_gain_flags_t)0x40000000) // Whether or not to mute the stream.
+#define AUDIO_SGF_AGC \
+ ((audio_set_gain_flags_t)0x80000000) // Whether or not enable AGC for the stream.
+
+// audio_pd_flags_t
+//
+// Flags used by AUDIO_STREAM_CMD_PLUG_DETECT commands to enable or disable
+// asynchronous plug detect notifications.
+//
+typedef uint32_t audio_pd_flags_t;
+#define AUDIO_PDF_NONE ((audio_pd_flags_t)0)
+#define AUDIO_PDF_ENABLE_NOTIFICATIONS ((audio_pd_flags_t)0x40000000)
+#define AUDIO_PDF_DISABLE_NOTIFICATIONS ((audio_pd_flags_t)0x80000000)
+
+// audio_pd_notify_flags_t
+//
+// Flags used by responses to the AUDIO_STREAM_CMD_PLUG_DETECT
+// message, and by AUDIO_STREAM_PLUG_DETECT_NOTIFY messages.
+//
+typedef uint32_t audio_pd_notify_flags_t;
+#define AUDIO_PDNF_HARDWIRED \
+ ((audio_pd_notify_flags_t)0x1) // Stream is hardwired (will always be plugged in)
+#define AUDIO_PDNF_CAN_NOTIFY \
+ ((audio_pd_notify_flags_t)0x2) // Stream is able to notify of plug state changes.
+#define AUDIO_PDNF_PLUGGED ((audio_pd_notify_flags_t)0x80000000) // Stream is currently plugged in.
+
+// AUDIO_STREAM_CMD_GET_FORMATS
+//
+// Must not be used with the NO_ACK flag.
+#define AUDIO_STREAM_CMD_GET_FORMATS_MAX_RANGES_PER_RESPONSE (15u)
+typedef struct audio_stream_cmd_get_formats_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_formats_req_t;
+
+// TODO(johngro) : Figure out if zx_txid_t is ever going to go up to 8 bytes or
+// not. If it is, just remove the _pad field below. If not, either keep it as
+// a _pad field, or repurpose it for some flags of some form. Right now, we use
+// it to make sure that format_ranges is aligned to a 16 byte boundary.
+typedef struct audio_stream_cmd_get_formats_resp {
+ audio_cmd_hdr_t hdr;
+ uint32_t _pad;
+ uint16_t format_range_count;
+ uint16_t first_format_range_ndx;
+ audio_stream_format_range_t format_ranges[AUDIO_STREAM_CMD_GET_FORMATS_MAX_RANGES_PER_RESPONSE];
+} audio_stream_cmd_get_formats_resp_t;
+
+static_assert(sizeof(audio_stream_cmd_get_formats_resp_t) == 256,
+ "audio_stream_cmd_get_formats_resp_t must be 256 bytes");
+
+#define AUDIO_SET_FORMAT_REQ_BITMASK_DISABLED ((uint64_t)0)
+
+// AUDIO_STREAM_CMD_SET_FORMAT
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_set_format_req {
+ audio_cmd_hdr_t hdr;
+ uint32_t frames_per_second;
+ audio_sample_format_t sample_format;
+ uint16_t channels;
+ uint64_t channels_to_use_bitmask;
+} audio_stream_cmd_set_format_req_t;
+
+typedef struct audio_stream_cmd_set_format_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint64_t external_delay_nsec;
+
+ // Note: Upon success, a channel used to control the audio buffer will also
+ // be returned.
+} audio_stream_cmd_set_format_resp_t;
+
+// AUDIO_STREAM_CMD_GET_GAIN
+//
+// Request that a gain notification be sent with the current details of the
+// streams current gain settings as well as gain setting capabilities.
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_get_gain_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_gain_req_t;
+
+typedef struct audio_stream_cmd_get_gain_resp {
+ // TODO(johngro) : Is there value in exposing the gain step to the level
+ // above the lowest level stream interface, or should we have all drivers
+ // behave as if they have continuous control at all times?
+ audio_cmd_hdr_t hdr;
+
+ bool cur_mute; // True if the stream is currently muted.
+ bool cur_agc; // True if the stream has AGC currently enabled.
+ float cur_gain; // The current setting gain of the stream in dB
+
+ bool can_mute; // True if the stream is capable of muting
+ bool can_agc; // True if the stream has support for AGC
+ float min_gain; // The minimum valid gain setting, in dB
+ float max_gain; // The maximum valid gain setting, in dB
+ float gain_step; // The smallest valid gain increment, counted from the minimum gain.
+} audio_stream_cmd_get_gain_resp_t;
+
+// AUDIO_STREAM_CMD_SET_GAIN
+//
+// Request that a stream change its gain settings to most closely match those
+// requested. Gain values for Valid requests will be rounded to the nearest
+// gain step. For example, if a stream can control its gain on the range from
+// -60.0 to 0.0 dB, a request to set the gain to -33.3 dB will result in a gain
+// of -33.5 being applied.
+//
+// Gain change requests outside of the capabilities of the stream's
+// amplifier will be rejected with a result of ZX_ERR_INVALID_ARGS. Using the
+// previous example, requests for gains of -65.0 or +3dB would be rejected.
+// Similarly, If an amplifier is capable of gain control but cannot mute, a
+// request to mute will be rejected.
+//
+// TODO(johngro) : Is this the correct behavior? Should we just apply sensible
+// limits instead? IOW - If the user requests a gain of -1000 dB, should we
+// just set the gain to -60dB? Likewise, if they request mute but the amplifier
+// has no hard mute feature, should we just set the gain to the minimum
+// permitted gain?
+//
+// May be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_set_gain_req {
+ audio_cmd_hdr_t hdr;
+ audio_set_gain_flags_t flags;
+ float gain;
+} audio_stream_cmd_set_gain_req_t;
+
+typedef struct audio_stream_cmd_set_gain_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ // The current gain settings observed immediately after processing the set
+ // gain request.
+ bool cur_mute;
+ bool cur_agc;
+ float cur_gain;
+} audio_stream_cmd_set_gain_resp_t;
+
+// AUDIO_STREAM_CMD_PLUG_DETECT
+//
+// Trigger a plug detect operation and/or enable/disable asynchronous plug
+// detect notifications.
+//
+// May be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_plug_detect_req {
+ audio_cmd_hdr_t hdr;
+ audio_pd_flags_t flags; // Options used to enable or disable notifications
+} audio_stream_cmd_plug_detect_req_t;
+
+typedef struct audio_stream_cmd_plug_detect_resp {
+ audio_cmd_hdr_t hdr;
+ audio_pd_notify_flags_t flags; // The current plug state and capabilities
+ zx_time_t plug_state_time; // The time of the plug state last change.
+} audio_stream_cmd_plug_detect_resp_t;
+
+// AUDIO_STREAM_PLUG_DETECT_NOTIFY
+//
+// Message asynchronously in response to a plug state change to clients who have
+// registered for plug state notifications.
+//
+// Note: Solicited and unsolicited plug detect messages currently use the same
+// structure and contain the same information. The difference between the two
+// is that Solicited messages, use AUDIO_STREAM_CMD_PLUG_DETECT as the value of
+// the `cmd` field of their header and the transaction ID of the request sent by
+// the client. Unsolicited messages use AUDIO_STREAM_PLUG_DETECT_NOTIFY as the
+// value value of the `cmd` field of their header, and
+// AUDIO_INVALID_TRANSACTION_ID for their transaction ID.
+typedef audio_stream_cmd_plug_detect_resp_t audio_stream_plug_detect_notify_t;
+
+// AUDIO_STREAM_CMD_GET_UNIQUE_ID
+//
+// Fetch a globally unique, but persistent ID for the stream.
+//
+// Drivers should make every effort to return as unique an identifier as
+// possible for each stream that they publish. This ID must not change between
+// boots. When available, using a globally unique device serial number is
+// strongly encouraged. Other possible sources of unique-ness include a
+// driver's physical connection path, driver binding information, manufacturer
+// calibration data, and so on.
+//
+// Note: a small number of hardcoded unique ID has been provided for built-in
+// devices. Platform drivers for systems with hardwired audio devices may use
+// these unique IDs as appropriate to signal which audio streams represent the
+// built-in devices for the system. Drivers for hot-pluggable audio devices
+// should *never* use these identifiers.
+//
+// Even given this, higher level code should *not* depend on these identifiers
+// being perfectly unique, and should be prepared to take steps to de-dupe
+// identifiers when needed.
+typedef struct audio_stream_cmd_get_unique_id_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_unique_id_req_t;
+
+typedef struct audio_stream_unique_id {
+ uint8_t data[16];
+} audio_stream_unique_id_t;
+
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_SPEAKERS \
+ { \
+ .data = { 0x01, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_HEADPHONE_JACK \
+ { \
+ .data = { 0x02, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_MICROPHONE \
+ { \
+ .data = { 0x03, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_HEADSET_JACK \
+ { \
+ .data = { 0x04, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_BT \
+ { \
+ .data = { 0x05, 0x00 } \
+ }
+
+typedef struct audio_stream_cmd_get_unique_id_resp {
+ audio_cmd_hdr_t hdr;
+ audio_stream_unique_id_t unique_id;
+} audio_stream_cmd_get_unique_id_resp_t;
+
+// AUDIO_STREAM_CMD_GET_STRING
+//
+// Fetch the specified string from a device's static string table. Strings
+// returned by the device driver...
+//
+// ++ Must be encoded using UTF8
+// ++ May contain embedded NULLs
+// ++ May not be NULL terminated
+//
+// Drivers are encouraged to NULL terminate all of their strings whenever
+// possible, but are not required to do so if the response buffer is too small.
+//
+typedef uint32_t audio_stream_string_id_t;
+#define AUDIO_STREAM_STR_ID_MANUFACTURER ((audio_stream_string_id_t)0x80000000)
+#define AUDIO_STREAM_STR_ID_PRODUCT ((audio_stream_string_id_t)0x80000001)
+
+typedef struct audio_stream_cmd_get_string_req {
+ audio_cmd_hdr_t hdr;
+ audio_stream_string_id_t id;
+} audio_stream_cmd_get_string_req_t;
+
+typedef struct audio_stream_cmd_get_string_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ audio_stream_string_id_t id;
+ uint32_t strlen;
+ uint8_t str[256 - sizeof(audio_cmd_hdr_t) - (3 * sizeof(uint32_t))];
+} audio_stream_cmd_get_string_resp_t;
+
+static_assert(sizeof(audio_stream_cmd_get_string_resp_t) == 256,
+ "audio_stream_cmd_get_string_resp_t must be exactly 256 bytes");
+
+// AUDIO_STREAM_CMD_GET_CLOCK_DOMAIN
+//
+// Fetch the hardware clock domain for this device.
+// On products containing audio devices that are not locked to the local system clock, the board
+// driver will provide a clock tree entry to the audio driver at driver startup time. From that,
+// the audio driver can extract the clock domain and provide it to the sender, upon receiving this
+// command. This domain value is all that the sender needs, in order to locate controls for that
+// clock domain in the clock tree and trim that clock domain's rate.
+// On products containing audio devices that are locked to the local system monotonic clock, a clock
+// domain value of 0 should be returned.
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_get_clock_domain_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_clock_domain_req_t;
+
+typedef struct audio_stream_cmd_get_clock_domain_resp {
+ audio_cmd_hdr_t hdr;
+ int32_t clock_domain;
+} audio_stream_cmd_get_clock_domain_resp_t;
+
+//
+// Ring-buffer commands
+//
+
+// AUDIO_RB_CMD_GET_FIFO_DEPTH
+//
+// TODO(johngro) : Is calling this "FIFO" depth appropriate? Should it be some
+// direction neutral form of something like "max-read-ahead-amount" or something
+// instead?
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_rb_cmd_get_fifo_depth_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_get_fifo_depth_req_t;
+
+typedef struct audio_rb_cmd_get_fifo_depth_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+
+ // A representation (in bytes) of how far ahead audio hardware may read
+ // into the stream (in the case of output) or may hold onto audio before
+ // writing it to memory (in the case of input).
+ uint32_t fifo_depth;
+} audio_rb_cmd_get_fifo_depth_resp_t;
+
+// AUDIO_RB_CMD_GET_BUFFER
+typedef struct audio_rb_cmd_get_buffer_req {
+ audio_cmd_hdr_t hdr;
+
+ uint32_t min_ring_buffer_frames;
+ uint32_t notifications_per_ring;
+} audio_rb_cmd_get_buffer_req_t;
+
+typedef struct audio_rb_cmd_get_buffer_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint32_t num_ring_buffer_frames;
+
+ // NOTE: If result == ZX_OK, a VMO handle representing the ring buffer to
+ // be used will be returned as well. Clients may map this buffer with
+ // read-write permissions in the case of an output stream, or read-only
+ // permissions in the case of an input stream. The size of the VMO
+ // indicates where the wrap point of the ring (in bytes) is located in the
+ // VMO. This size *must* always be an integral number of audio frames.
+ //
+ // TODO(johngro) : Should we provide some indication of whether or not this
+ // memory is being used directly for HW DMA and may need explicit cache
+ // flushing/invalidation?
+} audio_rb_cmd_get_buffer_resp_t;
+
+// AUDIO_RB_CMD_START
+typedef struct audio_rb_cmd_start_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_start_req_t;
+
+typedef struct audio_rb_cmd_start_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint64_t start_time;
+} audio_rb_cmd_start_resp_t;
+
+// AUDIO_RB_CMD_STOP
+typedef struct audio_rb_cmd_stop_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_stop_req_t;
+
+typedef struct audio_rb_cmd_stop_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+} audio_rb_cmd_stop_resp_t;
+
+// AUDIO_RB_POSITION_NOTIFY
+typedef struct audio_rb_position_notify {
+ audio_cmd_hdr_t hdr;
+
+ // The time, per system monotonic clock, of the below byte position.
+ zx_time_t monotonic_time;
+
+ // The current position (in bytes) of the driver/hardware's read (output) or
+ // write (input) pointer in the ring buffer.
+ uint32_t ring_buffer_pos;
+} audio_rb_position_notify_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_DEVICE_AUDIO_H_
diff --git a/arch/arm64/sysroot/include/zircon/device/ioctl-wrapper.h b/arch/arm64/sysroot/include/zircon/device/ioctl-wrapper.h
deleted file mode 100644
index 81a1286..0000000
--- a/arch/arm64/sysroot/include/zircon/device/ioctl-wrapper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <zircon/compiler.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-__BEGIN_CDECLS
-
-extern ssize_t fdio_ioctl(int fd, int op, const void* in_buf, size_t in_len, void* out_buf, size_t out_len);
-
-#define IOCTL_WRAPPER(name, op) \
-static inline ssize_t name(int fd) { \
- return fdio_ioctl(fd, op, NULL, 0, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_IN(name, op, type) \
-static inline ssize_t name(int fd, const type* in) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_VARIN(name, op, type) \
-static inline ssize_t name(int fd, const type* in, size_t in_len) { \
- return fdio_ioctl(fd, op, in, in_len, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_OUT(name, op, type) \
-static inline ssize_t name(int fd, type* out) { \
- return fdio_ioctl(fd, op, NULL, 0, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_VAROUT(name, op, type) \
-static inline ssize_t name(int fd, type* out, size_t out_len) { \
- return fdio_ioctl(fd, op, NULL, 0, out, out_len); \
-}
-
-#define IOCTL_WRAPPER_INOUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, outtype* out) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_VARIN_OUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, size_t in_len, outtype* out) { \
- return fdio_ioctl(fd, op, in, in_len, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_IN_VAROUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, outtype* out, size_t out_len) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, out, out_len); \
-}
-
-#define IOCTL_WRAPPER_VARIN_VAROUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, size_t in_len, outtype* out, size_t out_len) { \
- return fdio_ioctl(fd, op, in, in_len, out, out_len); \
-}
-
-__END_CDECLS
diff --git a/arch/arm64/sysroot/include/zircon/device/ioctl.h b/arch/arm64/sysroot/include/zircon/device/ioctl.h
deleted file mode 100644
index 7df5529..0000000
--- a/arch/arm64/sysroot/include/zircon/device/ioctl.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-// DEFAULT ioctls accept and received byte[] data
-// the particular ioctl may define more specific structures
-#define IOCTL_KIND_DEFAULT 0x0
-
-// GET_HANDLE ioctls accept plain data and return
-// a single handle, optionally followed by plain data
-#define IOCTL_KIND_GET_HANDLE 0x1
-
-// GET_TWO_HANDLES ioctls accept plain data and return
-// two handles, optionally followed by plain data
-#define IOCTL_KIND_GET_TWO_HANDLES 0x2
-
-// GET_THREE_HANDLES ioctls accept plain data and return
-// three handles, optionally followed by plain data
-#define IOCTL_KIND_GET_THREE_HANDLES 0x4
-
-// SET_HANDLE ioctls accept a handle, and optionally
-// plain data afterwards.
-#define IOCTL_KIND_SET_HANDLE 0x3
-
-// SET_TWO_HANDLES ioctls accepts two handles, and
-// optionally plain data afterwards.
-#define IOCTL_KIND_SET_TWO_HANDLES 0x5
-
-// core device/vfs ioctl families
-#define IOCTL_FAMILY_RESERVED 0x00
-#define IOCTL_FAMILY_DEVICE 0x01
-#define IOCTL_FAMILY_VFS 0x02
-#define IOCTL_FAMILY_DMCTL 0x03
-#define IOCTL_FAMILY_TEST 0x04
-
-// device protocol families
-#define IOCTL_FAMILY_CONSOLE 0x10
-#define IOCTL_FAMILY_INPUT 0x11
-// 0x12 unused
-#define IOCTL_FAMILY_BLOCK 0x13
-#define IOCTL_FAMILY_I2C 0x14
-#define IOCTL_FAMILY_USB_DEVICE 0x16
-#define IOCTL_FAMILY_HID 0x17
-// 0x18 unused
-#define IOCTL_FAMILY_AUDIO 0x19
-#define IOCTL_FAMILY_MIDI 0x1A
-#define IOCTL_FAMILY_KTRACE 0x1B
-#define IOCTL_FAMILY_BT_HCI 0x1C
-#define IOCTL_FAMILY_SYSINFO 0x1D
-// 0x1E unused
-#define IOCTL_FAMILY_RTC 0x1F // ioctls for RTC
-#define IOCTL_FAMILY_ETH 0x20
-#define IOCTL_FAMILY_INSNTRACE 0x21 // ioctls for instruction tracing
-#define IOCTL_FAMILY_RAMDISK 0x22
-#define IOCTL_FAMILY_SDMMC 0x23
-#define IOCTL_FAMILY_WLAN 0x24
-#define IOCTL_FAMILY_PTY 0x25
-#define IOCTL_FAMILY_NETCONFIG 0x26
-#define IOCTL_FAMILY_ETHERTAP 0x27
-#define IOCTL_FAMILY_USB_PERIPHERAL 0x28
-#define IOCTL_FAMILY_USB_VIRT_BUS 0x29
-#define IOCTL_FAMILY_CPUPERF 0x2A
-#define IOCTL_FAMILY_POWER 0x30
-#define IOCTL_FAMILY_THERMAL 0x31
-#define IOCTL_FAMILY_CAMERA 0x32
-#define IOCTL_FAMILY_BT_HOST 0x33
-#define IOCTL_FAMILY_WLANPHY 0x34
-#define IOCTL_FAMILY_SERIAL 0x35
-#define IOCTL_FAMILY_WLANTAP 0x36
-#define IOCTL_FAMILY_DISPLAY_CONTROLLER 0x37
-#define IOCTL_FAMILY_DEBUG 0x38
-#define IOCTL_FAMILY_AUDIO_CODEC 0x39
-#define IOCTL_FAMILY_BACKLIGHT 0x3A
-#define IOCTL_FAMILY_NAND_TEST 0x3B
-#define IOCTL_FAMILY_TEE 0x3C
-#define IOCTL_FAMILY_SKIP_BLOCK 0x3D
-#define IOCTL_FAMILY_USB_TEST 0x3E
-#define IOCTL_FAMILY_CLK 0x3F
-// 0x40 unused.
-#define IOCTL_FAMILY_QMI 0x41
-
-// IOCTL constructor
-// --K-FFNN
-#define IOCTL(kind, family, number) \
- ((((kind) & 0xF) << 20) | (((family) & 0xFF) << 8) | ((number) & 0xFF))
-
-// IOCTL accessors
-#define IOCTL_KIND(n) (((n) >> 20) & 0xF)
-#define IOCTL_FAMILY(n) (((n) >> 8) & 0xFF)
-#define IOCTL_NUMBER(n) ((n) & 0xFF)
diff --git a/arch/arm64/sysroot/include/zircon/device/ramdisk.h b/arch/arm64/sysroot/include/zircon/device/ramdisk.h
deleted file mode 100644
index dac72b9..0000000
--- a/arch/arm64/sysroot/include/zircon/device/ramdisk.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <limits.h>
-#include <zircon/boot/image.h>
-#include <zircon/device/ioctl.h>
-#include <zircon/device/ioctl-wrapper.h>
-#include <zircon/types.h>
-
-#define IOCTL_RAMDISK_CONFIG \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 1)
-#define IOCTL_RAMDISK_CONFIG_VMO \
- IOCTL(IOCTL_KIND_SET_HANDLE, IOCTL_FAMILY_RAMDISK, 4)
-#define IOCTL_RAMDISK_UNLINK \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 2)
-#define IOCTL_RAMDISK_SET_FLAGS \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 3)
-#define IOCTL_RAMDISK_WAKE_UP \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 4)
-#define IOCTL_RAMDISK_SLEEP_AFTER \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 5)
-#define IOCTL_RAMDISK_GET_BLK_COUNTS \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 6)
-
-// Ramdisk-specific flags
-#define RAMDISK_FLAG_RESUME_ON_WAKE 0xFF000001
-
-typedef struct ramdisk_ioctl_config {
- uint64_t blk_size;
- uint64_t blk_count;
- uint8_t type_guid[ZBI_PARTITION_GUID_LEN];
-} ramdisk_ioctl_config_t;
-
-typedef struct ramdisk_ioctl_config_response {
- char name[NAME_MAX + 1];
-} ramdisk_ioctl_config_response_t;
-
-typedef struct ramdisk_blk_counts {
- uint64_t received;
- uint64_t successful;
- uint64_t failed;
-} ramdisk_blk_counts_t;
-
-// ssize_t ioctl_ramdisk_config(int fd, const ramdisk_ioctl_config_t* in,
-// ramdisk_ioctl_config_response_t* out);
-IOCTL_WRAPPER_INOUT(ioctl_ramdisk_config, IOCTL_RAMDISK_CONFIG, ramdisk_ioctl_config_t,
- ramdisk_ioctl_config_response_t);
-
-// ssize_t ioctl_ramdisk_config_vmo(int fd, const zx_handle_t* in,
-// ramdisk_ioctl_config_response_t* out);
-IOCTL_WRAPPER_INOUT(ioctl_ramdisk_config_vmo, IOCTL_RAMDISK_CONFIG_VMO,
- zx_handle_t, ramdisk_ioctl_config_response_t);
-
-// ssize_t ioctl_ramdisk_unlink(int fd);
-IOCTL_WRAPPER(ioctl_ramdisk_unlink, IOCTL_RAMDISK_UNLINK);
-
-// ssize_t ioctl_ramdisk_set_flags(int fd, uint32_t* in);
-// The flags to set match block_info_t.flags. This is intended to simulate the behavior
-// of other block devices, so it should be used only for tests.
-IOCTL_WRAPPER_IN(ioctl_ramdisk_set_flags, IOCTL_RAMDISK_SET_FLAGS, uint32_t);
-
-// ssize_t ioctl_ramdisk_wake_up(int fd);
-// "Wakes" the ramdisk, if it was sleeping.
-// Transactions are no longer expected to fail after this point, and the ramdisk will not sleep
-// again until the next call to SLEEP_AFTER.
-// This will reset the current transaction count.
-IOCTL_WRAPPER(ioctl_ramdisk_wake_up, IOCTL_RAMDISK_WAKE_UP);
-
-// ssize_t ioctl_ramdisk_sleep_after(int fd, uint64_t* in);
-// Tell the ramdisk to "sleep" after |in| blocks have been written successfully.
-// After this point, all incoming transactions will fail.
-// This will reset the current block count.
-// NOTE! Use caution with RAMDISK_FLAG_RESUME_ON_WAKE set; sleeping with this flags will cause I/O
-// to block indefinitely until another call invokes |ioctl_ramdisk_wake_up|.
-IOCTL_WRAPPER_IN(ioctl_ramdisk_sleep_after, IOCTL_RAMDISK_SLEEP_AFTER, uint64_t);
-
-// ssize_t ioctl_ramdisk_get_blk_counts(int fd, ramdisk_blk_counts_t* out);
-// Retrieve the number of received, successful, and failed block writes since the last call to
-// sleep/wake.
-IOCTL_WRAPPER_OUT(ioctl_ramdisk_get_blk_counts, IOCTL_RAMDISK_GET_BLK_COUNTS, ramdisk_blk_counts_t);
diff --git a/arch/arm64/sysroot/include/zircon/dlfcn.h b/arch/arm64/sysroot/include/zircon/dlfcn.h
index af4a62b..f37e9be 100644
--- a/arch/arm64/sysroot/include/zircon/dlfcn.h
+++ b/arch/arm64/sysroot/include/zircon/dlfcn.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_DLFCN_H_
+#define SYSROOT_ZIRCON_DLFCN_H_
#include <dlfcn.h>
#include <zircon/compiler.h>
@@ -30,3 +31,5 @@
zx_status_t dl_clone_loader_service(zx_handle_t* out);
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_DLFCN_H_
diff --git a/arch/arm64/sysroot/include/zircon/driver/binding.h b/arch/arm64/sysroot/include/zircon/driver/binding.h
deleted file mode 100644
index 7c05026..0000000
--- a/arch/arm64/sysroot/include/zircon/driver/binding.h
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <assert.h>
-#include <zircon/compiler.h>
-#include <stdalign.h>
-#include <stddef.h>
-#include <stdint.h>
-
-__BEGIN_CDECLS;
-
-// COAABBBB VVVVVVVV Condition Opcode paramA paramB Value
-
-#define OP_ABORT 0x0 // if (cond) return no-match
-#define OP_MATCH 0x1 // if (cond) return match
-#define OP_GOTO 0x2 // if (cond) advance to next LABEL(paramA)
-#define OP_SET 0x3 // if (cond) flags |= paramA
-#define OP_CLEAR 0x4 // if (cond) flags &= (~paramA)
-#define OP_LABEL 0x5 // no-op, labels line with paramA
-
-#define COND_AL 0x0 // true
-#define COND_EQ 0x1 // bind(paramB) == Value
-#define COND_NE 0x2 // bind(paramB) != Value
-#define COND_GT 0x3 // bind(paramB) > Value
-#define COND_LT 0x4 // bind(paramB) < Value
-#define COND_GE 0x5 // bind(paramB) >= Value
-#define COND_LE 0x6 // bind(paramB) <= Value
-#define COND_MASK 0x7 // (bind(paramB) & Value) != 0
-#define COND_BITS 0x8 // (bind(paramB) & Value) == Value
-
-// branches are forward-only
-// branches always go to the first matching LABEL
-// branches that cannot find a matching LABEL are treated as ABORTs
-// there is an implied unconditional ABORT after the last instruction
-// flags are initially zero, may be set/cleared with SET/CLEAR
-// flags may be tested by comparison against BIND_FLAGS
-
-#define BINDINST(c,o,a,b,v) \
- { (((c)&0xF)<<28)|(((o)&0xF)<<24)|(((a)&0xFF)<<16)|((b)&0xFFFF),(v) }
-
-#define BINDINST_CC(n) ((n) >> 28)
-#define BINDINST_OP(n) (((n) >> 24) & 0xF)
-#define BINDINST_PA(n) (((n) >> 16) & 0xFF)
-#define BINDINST_PB(n) ((n) & 0xFFFF)
-
-#define BI_ABORT() BINDINST(COND_AL,OP_ABORT,0,0,0)
-#define BI_MATCH() BINDINST(COND_AL,OP_MATCH,0,0,0)
-#define BI_GOTO(n) BINDINST(COND_AL,OP_GOTO,n,0,0)
-#define BI_SET(f) BINDINST(COND_AL,OP_SET,f,0,0)
-#define BI_CLEAR(f) BINDINST(COND_AL,OP_CLEAR,f,0,0)
-#define BI_LABEL(n) BINDINST(COND_AL,OP_LABEL,n,0,0)
-
-#define BI_ABORT_IF(c,b,v) BINDINST(COND_##c,OP_ABORT,0,b,v)
-#define BI_MATCH_IF(c,b,v) BINDINST(COND_##c,OP_MATCH,0,b,v)
-#define BI_GOTO_IF(c,b,v,n) BINDINST(COND_##c,OP_GOTO,n,b,v)
-#define BI_SET_IF(c,b,v,f) BINDINST(COND_##c,OP_SET,f,b,v)
-#define BI_CLEAR_IF(c,b,v,f) BINDINST(COND_##c,OP_CLEAR,f,b,v)
-
-// for drivers that only want to be bound on user request
-#define BI_ABORT_IF_AUTOBIND BI_ABORT_IF(NE, BIND_AUTOBIND, 0)
-
-// global binding variables at 0x00XX
-#define BIND_FLAGS 0x0000 // value of the flags register
-#define BIND_PROTOCOL 0x0001 // primary protcol of the device
-#define BIND_AUTOBIND 0x0002 // if this is an automated bind/load
-
-// pci binding variables at 0x01XX
-#define BIND_PCI_VID 0x0100
-#define BIND_PCI_DID 0x0101
-#define BIND_PCI_CLASS 0x0102
-#define BIND_PCI_SUBCLASS 0x0103
-#define BIND_PCI_INTERFACE 0x0104
-#define BIND_PCI_REVISION 0x0105
-#define BIND_PCI_BDF_ADDR 0x0106
-
-// pci binding variable utils
-#define BIND_PCI_BDF_PACK(bus, dev, func) \
- ((((uint32_t)(bus) & 0xFF) << 8) | \
- (((uint32_t)(dev) & 0x1F) << 3) | \
- ((uint32_t)(func) & 0x07))
-
-#define BIND_PCI_BDF_UNPACK_BUS(bdf) (((uint32_t)(bdf) >> 8) & 0xFF)
-#define BIND_PCI_BDF_UNPACK_DEV(bdf) (((uint32_t)(bdf) >> 3) & 0x1F)
-#define BIND_PCI_BDF_UNPACK_FUNC(bdf) ((uint32_t)(bdf) & 0x07)
-
-// usb binding variables at 0x02XX
-// these are used for both ZX_PROTOCOL_USB and ZX_PROTOCOL_USB_FUNCTION
-#define BIND_USB_VID 0x0200
-#define BIND_USB_PID 0x0201
-#define BIND_USB_CLASS 0x0202
-#define BIND_USB_SUBCLASS 0x0203
-#define BIND_USB_PROTOCOL 0x0204
-
-// Platform bus binding variables at 0x03XX
-#define BIND_PLATFORM_DEV_VID 0x0300
-#define BIND_PLATFORM_DEV_PID 0x0301
-#define BIND_PLATFORM_DEV_DID 0x0302
-#define BIND_PLATFORM_PROTO 0x0303
-
-// ACPI binding variables at 0x04XX
-// The _HID is a 7- or 8-byte string. Because a bind property is 32-bit, use 2
-// properties to bind using the _HID. They are encoded in big endian order for
-// human readability. In the case of 7-byte _HID's, the 8th-byte shall be 0.
-#define BIND_ACPI_HID_0_3 0x0400 // char 0-3
-#define BIND_ACPI_HID_4_7 0x0401 // char 4-7
-// The _CID may be a valid HID value or a bus-specific string. The ACPI bus
-// driver only publishes those that are valid HID values.
-#define BIND_ACPI_CID_0_3 0x0402 // char 0-3
-#define BIND_ACPI_CID_4_7 0x0403 // char 4-7
-
-// Intel HDA Codec binding variables at 0x05XX
-#define BIND_IHDA_CODEC_VID 0x0500
-#define BIND_IHDA_CODEC_DID 0x0501
-#define BIND_IHDA_CODEC_MAJOR_REV 0x0502
-#define BIND_IHDA_CODEC_MINOR_REV 0x0503
-#define BIND_IHDA_CODEC_VENDOR_REV 0x0504
-#define BIND_IHDA_CODEC_VENDOR_STEP 0x0505
-
-// Serial binding variables at 0x06XX
-#define BIND_SERIAL_CLASS 0x0600
-#define BIND_SERIAL_VID 0x0601
-#define BIND_SERIAL_PID 0x0602
-
-// NAND binding variables at 0x07XX
-#define BIND_NAND_CLASS 0x0700
-
-// Bluetooth binding variables at 0x08XX
-#define BIND_BT_GATT_SVC_UUID16 0x0800
-// 128-bit UUID is split across 4 32-bit unsigned ints
-#define BIND_BT_GATT_SVC_UUID128_1 0x0801
-#define BIND_BT_GATT_SVC_UUID128_2 0x0802
-#define BIND_BT_GATT_SVC_UUID128_3 0x0803
-#define BIND_BT_GATT_SVC_UUID128_4 0x0804
-
-// SDIO binding variables at 0x09XX
-#define BIND_SDIO_VID 0x0900
-#define BIND_SDIO_PID 0x0901
-
-// I2C binding variables at 0x0AXX
-#define BIND_I2C_CLASS 0x0A00
-
-// TEMPORARY binding variables at 0xfXX
-// I2C_ADDR is a temporary way to bind the i2c touchscreen on the Acer12. This
-// binding will eventually be made via some sort of ACPI device enumeration.
-#define BIND_I2C_ADDR 0x0f00
-
-typedef struct zx_bind_inst {
- uint32_t op;
- uint32_t arg;
-} zx_bind_inst_t;
-
-typedef struct zx_device_prop {
- uint16_t id;
- uint16_t reserved;
- uint32_t value;
-} zx_device_prop_t;
-
-// simple example
-#if 0
-zx_bind_inst_t i915_binding[] = {
- BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_PCI),
- BI_ABORT_IF(NE, BIND_PCI_VID, 0x8086),
- BI_MATCH_IF(EQ, BIND_PCI_DID, 0x1616), // broadwell
- BI_MATCH_IF(EQ, BIND_PCI_DID, 0x1916), // skylake
- BI_ABORT(),
-};
-#endif
-
-#define ZIRCON_NOTE_NAME "Zircon"
-#define ZIRCON_NOTE_DRIVER 0x31565244 // DRV1
-
-typedef struct {
- // Elf64_Nhdr fields:
- uint32_t namesz;
- uint32_t descsz;
- uint32_t type;
- // ELF note name. namesz is the exact size of the name (including '\0'),
- // but the storage size is always rounded up to a multiple of 4 bytes.
- char name[(sizeof(ZIRCON_NOTE_NAME) + 3) & -4];
-} zircon_driver_note_header_t;
-
-#define ZIRCON_DRIVER_NOTE_HEADER_INIT(object) { \
- /* .namesz = */ sizeof(ZIRCON_NOTE_NAME), \
- /* .descsz = */ (sizeof(object) - \
- sizeof(zircon_driver_note_header_t)), \
- /* .type = */ ZIRCON_NOTE_DRIVER, \
- /* .name = */ ZIRCON_NOTE_NAME, \
- }
-
-typedef struct {
- // See flag bits below.
- uint32_t flags;
-
- // Driver Metadata
- uint32_t bindcount;
- uint32_t reserved0;
- char name[32];
- char vendor[16];
- char version[16];
-
- // Driver Bind Program follows
-} zircon_driver_note_payload_t;
-
-// Flag bits in the driver note:
-
-// Driver is built with `-fsanitize=address` and can only be loaded into a
-// devhost that supports the ASan runtime.
-#define ZIRCON_DRIVER_NOTE_FLAG_ASAN (1u << 0)
-
-#define ZIRCON_DRIVER_NOTE_PAYLOAD_INIT(Driver,VendorName,Version,BindCount) \
- { \
- /* .flags = */ ZIRCON_DRIVER_NOTE_FLAGS, \
- /* .bindcount = */ (BindCount), \
- /* .reserved0 = */ 0, \
- /* .name = */ #Driver, \
- /* .vendor = */ VendorName, \
- /* .version = */ Version, \
- }
-
-#define ZIRCON_DRIVER_NOTE_FLAGS \
- (__has_feature(address_sanitizer) ? ZIRCON_DRIVER_NOTE_FLAG_ASAN : 0)
-
-typedef struct {
- zircon_driver_note_header_t header;
- zircon_driver_note_payload_t payload;
-} zircon_driver_note_t;
-
-static_assert(offsetof(zircon_driver_note_t, payload) ==
- sizeof(zircon_driver_note_header_t),
- "alignment snafu?");
-
-// Without this, ASan will add redzone padding after the object, which
-// would make it invalid ELF note format.
-#if __has_feature(address_sanitizer)
-# define ZIRCON_DRIVER_NOTE_ASAN __attribute__((no_sanitize("address")))
-#else
-# define ZIRCON_DRIVER_NOTE_ASAN
-#endif
-
-// GCC has a quirk about how '__attribute__((visibility("default")))'
-// (__EXPORT here) works for const variables in C++. The attribute has no
-// effect when used on the definition of a const variable, and GCC gives a
-// warning/error about that. The attribute must appear on the "extern"
-// declaration of the variable instead.
-
-// We explicitly align the note to 4 bytes. That's its natural alignment
-// anyway, but the compilers sometimes like to over-align as an
-// optimization while other tools sometimes like to complain if SHT_NOTE
-// sections are over-aligned (since this could result in padding being
-// inserted that makes it violate the ELF note format). Standard C11
-// doesn't permit alignas(...) on a type but we could use __ALIGNED(4) on
-// all the types (i.e. GNU __attribute__ syntax instead of C11 syntax).
-// But the alignment of the types is not actually the issue: it's the
-// compiler deciding to over-align the individual object regardless of its
-// type's alignment, so we have to explicitly set the alignment of the
-// object to defeat any compiler default over-alignment.
-
-#define ZIRCON_DRIVER_BEGIN(Driver,Ops,VendorName,Version,BindCount) \
-zx_driver_rec_t __zircon_driver_rec__ __EXPORT = {\
- /* .ops = */ &(Ops),\
- /* .driver = */ NULL,\
- /* .log_flags = */ 7, /* DDK_LOG_ERROR | DDK_LOG_WARN | DDK_LOG_INFO */\
-};\
-extern const struct zircon_driver_note __zircon_driver_note__ __EXPORT;\
-alignas(4) __SECTION(".note.zircon.driver." #Driver) ZIRCON_DRIVER_NOTE_ASAN \
-const struct zircon_driver_note {\
- zircon_driver_note_t note;\
- zx_bind_inst_t binding[BindCount];\
-} __zircon_driver_note__ = {\
- /* .note = */{\
- ZIRCON_DRIVER_NOTE_HEADER_INIT(__zircon_driver_note__),\
- ZIRCON_DRIVER_NOTE_PAYLOAD_INIT(Driver,VendorName,Version,BindCount),\
- },\
- /* .binding = */ {
-
-#define ZIRCON_DRIVER_END(Driver) }};
-
-//TODO: if we moved the Ops from the BEGIN() to END() macro we
-// could add a zircon_driver_note_t* to the zx_driver_rec_t,
-// define it in END(), and have only one symbol to dlsym()
-// when loading drivers
-
-__END_CDECLS;
diff --git a/arch/arm64/sysroot/include/zircon/errors.h b/arch/arm64/sysroot/include/zircon/errors.h
index 1c1ed80..390acfb 100644
--- a/arch/arm64/sysroot/include/zircon/errors.h
+++ b/arch/arm64/sysroot/include/zircon/errors.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_ERRORS_H_
+#define SYSROOT_ZIRCON_ERRORS_H_
// Zircon statuses are signed 32 bit integers. The space of values is
// divided as follows:
@@ -108,7 +109,6 @@
// and should thus retry.
#define ZX_ERR_UNAVAILABLE (-28)
-
// ======= Permission check errors =======
// ZX_ERR_ACCESS_DENIED: The caller did not have permission to perform
// the specified operation.
@@ -229,3 +229,10 @@
// ZX_ERR_CONNECTION_ABORTED: Connection was aborted.
#define ZX_ERR_CONNECTION_ABORTED (-76)
+
+// ======= VDSO-private errors =======
+
+// ZX_ERR_INTERNAL_INTR_KILLED: A task was killed during an operation.
+#define ZX_ERR_INTERNAL_INTR_KILLED (-502)
+
+#endif // SYSROOT_ZIRCON_ERRORS_H_
diff --git a/arch/arm64/sysroot/include/zircon/exception.h b/arch/arm64/sysroot/include/zircon/exception.h
new file mode 100644
index 0000000..bf3843b
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/exception.h
@@ -0,0 +1,19 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#pragma once
+
+#include <zircon/syscalls/exception.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__EXPORT const char* _zx_exception_get_string(zx_excp_type_t exception);
+__EXPORT const char* zx_exception_get_string(zx_excp_type_t exception);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/arch/arm64/sysroot/include/zircon/features.h b/arch/arm64/sysroot/include/zircon/features.h
index a560007..d0c0720 100644
--- a/arch/arm64/sysroot/include/zircon/features.h
+++ b/arch/arm64/sysroot/include/zircon/features.h
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_FEATURES_H_
-#define ZIRCON_FEATURES_H_
+#ifndef SYSROOT_ZIRCON_FEATURES_H_
+#define SYSROOT_ZIRCON_FEATURES_H_
// clang-format off
// types of features that can be retrieved via |zx_system_get_features|
-#define ZX_FEATURE_KIND_CPU ((uint32_t)0)
+#define ZX_FEATURE_KIND_CPU ((uint32_t)0)
+#define ZX_FEATURE_KIND_HW_BREAKPOINT_COUNT ((uint32_t)1)
+#define ZX_FEATURE_KIND_HW_WATCHPOINT_COUNT ((uint32_t)2)
// arch-independent CPU features
#define ZX_HAS_CPU_FEATURES ((uint32_t)(1u << 0))
@@ -35,6 +37,9 @@
#define ZX_ARM64_FEATURE_ISA_SM4 ((uint32_t)(1u << 12))
#define ZX_ARM64_FEATURE_ISA_DP ((uint32_t)(1u << 13))
#define ZX_ARM64_FEATURE_ISA_DPB ((uint32_t)(1u << 14))
+#define ZX_ARM64_FEATURE_ISA_FHM ((uint32_t)(1u << 15))
+#define ZX_ARM64_FEATURE_ISA_TS ((uint32_t)(1u << 16))
+#define ZX_ARM64_FEATURE_ISA_RNDR ((uint32_t)(1u << 17))
#else
@@ -42,4 +47,4 @@
#endif
-#endif // ZIRCON_FEATURES_H_
+#endif // SYSROOT_ZIRCON_FEATURES_H_
diff --git a/arch/arm64/sysroot/include/zircon/fidl.h b/arch/arm64/sysroot/include/zircon/fidl.h
index e971472..7388729 100644
--- a/arch/arm64/sysroot/include/zircon/fidl.h
+++ b/arch/arm64/sysroot/include/zircon/fidl.h
@@ -2,20 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_FIDL_H_
-#define ZIRCON_FIDL_H_
+#ifndef SYSROOT_ZIRCON_FIDL_H_
+#define SYSROOT_ZIRCON_FIDL_H_
-#include <assert.h>
-#include <stdalign.h>
-#include <stdint.h>
-
+#include <assert.h> // NOLINT(modernize-deprecated-headers, foobar)
+#include <stdalign.h> // NOLINT(modernize-deprecated-headers)
+#include <stdint.h> // NOLINT(modernize-*)
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS
// Fidl data types have a representation in a wire format. This wire
-// format is shared by all language bindings, including C11 and C++14.
+// format is shared by all language bindings, including C11 and C++.
//
// The C bindings also define a representation of fidl data types. For
// a given type, the size and alignment of all parts of the type agree
@@ -55,12 +54,21 @@
#define FIDL_ALLOC_ABSENT ((uintptr_t)0)
// Out of line allocations are all 8 byte aligned.
+// TODO(fxbug.dev/42792): Remove either this FIDL_ALIGN macro or the FidlAlign function in
+// fidl/internal.h.
#define FIDL_ALIGNMENT ((size_t)8)
-#define FIDL_ALIGN(a) (((a) + 7) & ~7)
+#define FIDL_ALIGN(a) (((a) + 7u) & ~7u)
#define FIDL_ALIGNDECL alignas(FIDL_ALIGNMENT)
-// An opaque struct representing the encoding of a particular fidl
-// type.
+// The maximum depth of out-of-line objects in the wire format.
+// 0 is the initial depth, 1 is the first out of line object, etc.
+// Tables count as two depth levels because the vector body and the
+// table elements are both out of line.
+#define FIDL_MAX_DEPTH 32
+
+// An opaque struct containing metadata for encoding a particular fidl
+// type. The actual length of the struct is different depending on the
+// kind of fidl type it is describing.
typedef struct fidl_type fidl_type_t;
// Primitive types.
@@ -119,11 +127,11 @@
// but is checked as part of validation.
typedef struct fidl_string {
- // Number of UTF-8 code units (bytes), must be 0 if |data| is null.
- uint64_t size;
+ // Number of UTF-8 code units (bytes), must be 0 if |data| is null.
+ uint64_t size;
- // Pointer to UTF-8 code units (bytes) or null
- char* data;
+ // Pointer to UTF-8 code units (bytes) or null
+ char* data;
} fidl_string_t;
// When encoded, an absent nullable string is represented as a
@@ -169,11 +177,11 @@
// but is checked as part of validation.
typedef struct fidl_vector {
- // Number of elements, must be 0 if |data| is null.
- uint64_t count;
+ // Number of elements, must be 0 if |data| is null.
+ uint64_t count;
- // Pointer to element data or null.
- void* data;
+ // Pointer to element data or null.
+ void* data;
} fidl_vector_t;
// When encoded, an absent nullable vector is represented as a
@@ -193,6 +201,42 @@
// vector<T>:N fidl_vector_t A vector of T, up to N elements.
// vector<T>:N? fidl_vector_t An optional vector of T, up to N elements.
+// Envelope.
+
+// An efficient way to encapsulate uninterpreted FIDL messages.
+// - Stores a variable size uninterpreted payload out-of-line.
+// - Payload may contain an arbitrary number of bytes and handles.
+// - Allows for encapsulation of one FIDL message inside of another.
+// - Building block for extensible structures such as tables & extensible
+// unions.
+
+// When encoded for transfer, |data| indicates presence of content:
+// - FIDL_ALLOC_ABSENT : envelope is null
+// - FIDL_ALLOC_PRESENT : envelope is non-null, |data| is the next out-of-line object
+// When decoded for consumption, |data| is a pointer to content.
+// - nullptr : envelope is null
+// - <valid pointer> : envelope is non-null, |data| is at indicated memory address
+
+typedef struct {
+ // The size of the entire envelope contents, including any additional
+ // out-of-line objects that the envelope may contain. For example, a
+ // vector<string>'s num_bytes for ["hello", "world"] would include the
+ // string contents in the size, not just the outer vector. Always a multiple
+ // of 8; must be zero if envelope is null.
+ uint32_t num_bytes;
+
+ // The number of handles in the envelope, including any additional
+ // out-of-line objects that the envelope contains. Must be zero if envelope is null.
+ uint32_t num_handles;
+
+ // A pointer to the out-of-line envelope data in decoded form, or
+ // FIDL_ALLOC_(ABSENT|PRESENT) in encoded form.
+ union {
+ void* data;
+ uintptr_t presence;
+ };
+} fidl_envelope_t;
+
// Handle types.
// Handle types are encoded directly. Just like primitive types, there
@@ -278,16 +322,53 @@
// union_foo, or else
// FIDL_ALLOC_ABSENT.
+// Tables.
+
+// Tables are 'flexible structs', where all members are optional, and new
+// members can be added, or old members removed while preserving ABI
+// compatibility. Each table member is referenced by ordinal, sequentially
+// assigned from 1 onward, with no gaps. Each member content is stored
+// out-of-line in an envelope, and a table is simply a vector of these envelopes
+// with the requirement that the last envelope must be present in order
+// to guarantee a canonical representation.
+
+typedef struct {
+ fidl_vector_t envelopes;
+} fidl_table_t;
+
+// Extensible unions.
+
+// Extensible unions, or "xunions" (colloquially pronounced "zoo-nions") are
+// similar to unions, except that storage for union members are out-of-line
+// rather than inline. This enables union members to be added and removed while
+// preserving ABI compatibility with the existing xunion definition.
+
+typedef uint64_t fidl_xunion_tag_t;
+
+enum {
+ kFidlXUnionEmptyTag = 0, // The tag representing an empty xunion.
+};
+
+typedef struct {
+ fidl_xunion_tag_t tag;
+ fidl_envelope_t envelope;
+} fidl_xunion_t;
+
// Messages.
// All fidl messages share a common 16 byte header.
+enum {
+ kFidlWireFormatMagicNumberInitial = 1,
+};
+
typedef struct fidl_message_header {
- zx_txid_t txid;
- // This reserved word is used by Epitaphs to represent an error value.
- uint32_t reserved0;
- uint32_t flags;
- uint32_t ordinal;
+ zx_txid_t txid;
+ uint8_t flags[3];
+ // This value indicates the message's wire format. Two sides with different
+ // wire formats are incompatible with each other
+ uint8_t magic_number;
+ uint64_t ordinal;
} fidl_message_header_t;
// Messages which do not have a response use zero as a special
@@ -295,46 +376,65 @@
#define FIDL_TXID_NO_RESPONSE 0ul
-// The system reserves the high half of the ordinal space.
+// An outgoing FIDL message.
+typedef struct fidl_outgoing_msg {
+ // The bytes of the message.
+ //
+ // The bytes of the message might be in the encoded or decoded form.
+ // Functions that take a |fidl_outgoing_msg_t| as an argument should document whether
+ // the expect encoded or decoded messages.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ void* bytes;
-#define FIDL_ORD_SYSTEM_MASK 0x80000000ul
+ // The handles of the message.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ zx_handle_t* handles;
-// A FIDL message.
-typedef struct fidl_msg {
- // The bytes of the message.
- //
- // The bytes of the message might be in the encoded or decoded form.
- // Functions that take a |fidl_msg_t| as an argument should document whether
- // the expect encoded or decoded messages.
- //
- // See |num_bytes| for the number of bytes in the message.
- void* bytes;
+ // The number of bytes in |bytes|.
+ uint32_t num_bytes;
- // The handles of the message.
- //
- // See |num_bytes| for the number of bytes in the message.
- zx_handle_t* handles;
+ // The number of handles in |handles|.
+ uint32_t num_handles;
+} fidl_outgoing_msg_t;
- // The number of bytes in |bytes|.
- uint32_t num_bytes;
+// An incoming FIDL message.
+typedef struct fidl_incoming_msg {
+ // The bytes of the message.
+ //
+ // The bytes of the message might be in the encoded or decoded form.
+ // Functions that take a |fidl_incoming_msg_t| as an argument should document whether
+ // the expect encoded or decoded messages.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ void* bytes;
- // The number of handles in |handles|.
- uint32_t num_handles;
-} fidl_msg_t;
+ // The handles of the message.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ zx_handle_t* handles;
+
+ // The number of bytes in |bytes|.
+ uint32_t num_bytes;
+
+ // The number of handles in |handles|.
+ uint32_t num_handles;
+} fidl_incoming_msg_t;
// An outstanding FIDL transaction.
typedef struct fidl_txn fidl_txn_t;
struct fidl_txn {
- // Replies to the outstanding request and complete the FIDL transaction.
- //
- // Pass the |fidl_txn_t| object itself as the first parameter. The |msg|
- // should already be encoded. This function always consumes any handles
- // present in |msg|.
- //
- // Call |reply| only once for each |txn| object. After |reply| returns, the
- // |txn| object is considered invalid and might have been freed or reused
- // for another purpose.
- zx_status_t (*reply)(fidl_txn_t* txn, const fidl_msg_t* msg);
+ // Replies to the outstanding request and complete the FIDL transaction.
+ //
+ // Pass the |fidl_txn_t| object itself as the first parameter. The |msg|
+ // should already be encoded. This function always consumes any handles
+ // present in |msg|.
+ //
+ // Call |reply| only once for each |txn| object. After |reply| returns, the
+ // |txn| object is considered invalid and might have been freed or reused
+ // for another purpose.
+ zx_status_t (*reply)(fidl_txn_t* txn, const fidl_outgoing_msg_t* msg);
};
// An epitaph is a message that a server sends just prior to closing the
@@ -342,17 +442,22 @@
// Epitaphs are defined in the FIDL wire format specification. Once sent down
// the wire, the channel should be closed.
typedef struct fidl_epitaph {
- FIDL_ALIGNDECL
+ FIDL_ALIGNDECL
- // The error associated with this epitaph is stored in the reserved word of
- // the message header. System errors must be constants of type zx_status_t,
- // which are all negative. Positive numbers should be used for application
- // errors. A value of ZX_OK indicates no error.
- fidl_message_header_t hdr;
+ // The method ordinal for all epitaphs must be kFidlOrdinalEpitaph
+ fidl_message_header_t hdr;
+
+ // The error associated with this epitaph is stored as a struct{int32} in
+ // the message payload. System errors must be constants of type zx_status_t,
+ // which are all negative. Positive numbers should be used for application
+ // errors. A value of ZX_OK indicates no error.
+ zx_status_t error;
} fidl_epitaph_t;
// This ordinal value is reserved for Epitaphs.
-#define FIDL_EPITAPH_ORDINAL 0xFFFFFFFF
+enum {
+ kFidlOrdinalEpitaph = 0xFFFFFFFFFFFFFFFF,
+};
// Assumptions.
@@ -374,4 +479,4 @@
__END_CDECLS
-#endif // ZIRCON_FIDL_H_
+#endif // SYSROOT_ZIRCON_FIDL_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/debug/arm64.h b/arch/arm64/sysroot/include/zircon/hw/debug/arm64.h
new file mode 100644
index 0000000..b0b6ea3
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/debug/arm64.h
@@ -0,0 +1,278 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
+#define SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
+
+#include <stdint.h>
+
+// ARM64 Hardware Debug Resources
+// =================================================================================================
+
+// Hardware Breakpoints ----------------------------------------------------------------------------
+//
+// Hardware breakpoints permits to stop a thread when it executes an address setup in one of the
+// hw breakpoints registers. They will work independent whether the address in question is
+// read-only or not.
+
+// ARMv8 assures at least 2 hardware breakpoints.
+#define ARM64_MIN_HW_BREAKPOINTS 2
+#define ARM64_MAX_HW_BREAKPOINTS 16
+
+// Access macros:
+// All the relevant register fields are exposed through macros.
+// For convenience of use, use the get/set macros:
+//
+// uint64_t ARM64_<REG>_<FIELD>_GET(uint64_t reg)
+// void ARM64_<REG>_<FIELD>_SET(uint64_t* reg, uint64_t value)
+//
+// Examples:
+// uint64_t bas = ARM64_DBGBCR_BAS_GET(dbgbcr);
+// ARM64_DBGBCR_BAS_SET(&dbgbcr, modified_bas);
+
+// DBGBCR<n>: Debug Control Register for HW Breakpoint #n.
+//
+// Control register for HW breakpoints. There is one foreach HW breakpoint present within the
+// system. They go numbering by DBGBCR0, DBGBCR1, ... until the value defined in ID_AADFR0_EL1.
+//
+// For each control register, there is an equivalent DBGBVR<n> that holds the address the thread
+// will compare against.
+
+// The following fields are accepted by the user. All other fields are ignored (masked).
+//
+// - E
+
+// This mask is applied when to DBGBCR. Any set values on those fields will be overwritten.
+//
+// - PMC = 0b10
+// - BAS = 0b1111
+// - HMC = 0
+// - SSC = 0
+// - LBN = 0
+// - BT = 0
+
+// Enable/disable the breakpoint.
+#define ARM64_DBGBCR_E 1lu // Bit 0
+#define ARM64_DBGBCR_E_SHIFT 0u
+#define ARM64_DBGBCR_E_MASK (ARM64_DBGBCR_E << ARM64_DBGBCR_E_SHIFT)
+#define ARM64_DBGBCR_E_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_E_MASK, ARM64_DBGBCR_E_SHIFT)
+#define ARM64_DBGBCR_E_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_E_MASK, \
+ ARM64_DBGBCR_E_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_PMC 0b11lu // Bits 1-2.
+#define ARM64_DBGBCR_PMC_SHIFT 1u
+#define ARM64_DBGBCR_PMC_MASK (ARM64_DBGBCR_PMC << ARM64_DBGBCR_PMC_SHIFT)
+#define ARM64_DBGBCR_PMC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_PMC_MASK, ARM64_DBGBCR_PMC_SHIFT)
+#define ARM64_DBGBCR_PMC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_PMC_MASK, \
+ ARM64_DBGBCR_PMC_SHIFT)
+
+// Byte Address Select. Defines which half-words triggers the breakpoint.
+// In AArch64 implementations (which zircon targets), is res1.
+#define ARM64_DBGBCR_BAS 0b1111lu // Bits 5-8.
+#define ARM64_DBGBCR_BAS_SHIFT 5u
+#define ARM64_DBGBCR_BAS_MASK (ARM64_DBGBCR_BAS << ARM64_DBGBCR_BAS_SHIFT)
+#define ARM64_DBGBCR_BAS_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_BAS_MASK, ARM64_DBGBCR_BAS_SHIFT)
+#define ARM64_DBGBCR_BAS_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_BAS_MASK, \
+ ARM64_DBGBCR_BAS_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_HMC 0b1lu // Bit 13.
+#define ARM64_DBGBCR_HMC_SHIFT 13u
+#define ARM64_DBGBCR_HMC_MASK (ARM64_DBGBCR_HMC << ARM64_DBGBCR_HMC_SHIFT)
+#define ARM64_DBGBCR_HMC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_HMC_MASK, ARM64_DBGBCR_HMC_SHIFT)
+#define ARM64_DBGBCR_HMC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_HMC_MASK, \
+ ARM64_DBGBCR_HMC_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_SSC 0b11lu // Bits 14-15.
+#define ARM64_DBGBCR_SSC_SHIFT 14u
+#define ARM64_DBGBCR_SSC_MASK (ARM64_DBGBCR_SSC << ARM64_DBGBCR_SSC_SHIFT)
+#define ARM64_DBGBCR_SSC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_SSC_MASK, ARM64_DBGBCR_SSC_SHIFT)
+#define ARM64_DBGBCR_SSC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_SSC_MASK, \
+ ARM64_DBGBCR_SSC_SHIFT)
+
+// Linked Breakpoint Number. Zircon doesn't use this feature. Always zero.
+#define ARM64_DBGBCR_LBN 0b1111lu // Bits 16-19.
+#define ARM64_DBGBCR_LBN_SHIFT 16u
+#define ARM64_DBGBCR_LBN_MASK (ARM64_DBGBCR_LBN << ARM64_DBGBCR_LBN_SHIFT)
+#define ARM64_DBGBCR_LBN_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_LBN_MASK, ARM64_DBGBCR_LBN_SHIFT)
+#define ARM64_DBGBCR_LBN_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_LBN_MASK, \
+ ARM64_DBGBCR_LBN_SHIFT)
+
+// Breakpoint Type. Zircon only uses unlinked address match (zero).
+#define ARM64_DBGBCR_BT 0b1111lu // Bits 20-23.
+#define ARM64_DBGBCR_BT_SHIFT 20u
+#define ARM64_DBGBCR_BT_MASK (ARM64_DBGBCR_BT << ARM64_DBGBCR_BT_SHIFT)
+#define ARM64_DBGBCR_BT_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_BT_MASK, ARM64_DBGBCR_BT_SHIFT)
+#define ARM64_DBGBCR_BT_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_BT_MASK, \
+ ARM64_DBGBCR_BT_SHIFT)
+
+// Watchpoints ------------------------------------------------------------------------------------
+
+// Watchpoints permits to stop a thread when it read/writes to a particular address in memory.
+// This will work even if the address is read-only memory (for a read, of course).
+
+// ARMv8 assures at least 2 watchpoints.
+#define ARM64_MIN_HW_WATCHPOINTS 2
+#define ARM64_MAX_HW_WATCHPOINTS 16
+
+// DBGWCR<n>: Watchpoint Control Register.
+//
+// Control register for watchpoints. There is one for each watchpoint present within the system.
+// They go numbering by DBGWCR0, DBGWCR1, ... until the value defined ID_AAFR0_EL1.
+// For each control register, there is an equivalent DBGWCR<n> that holds the address the thread
+// will compare against. How this address is interpreted depends upon the configuration of the
+// associated control register.
+
+// The following fields are accepted by the user. All other fields are ignored (masked).
+//
+// - E
+// - BAS
+// - TODO(donosoc): Expose LSC.
+
+// This mask is applied when to DBGWCR. Any set values on those fields will be overwritten.
+//
+// - PAC = 0b10
+// - LSC = 0b10: Write watchpoint. TODO(donosoc): Expose to users so they can define it.
+// - HMC = 0
+// - SSC = 0b01
+// - LBN = 0
+// - WT = 0
+
+// Enable/disable the watchpoint.
+#define ARM64_DBGWCR_E 1lu // Bit 1.
+#define ARM64_DBGWCR_E_SHIFT 0u
+#define ARM64_DBGWCR_E_MASK (ARM64_DBGWCR_E << ARM64_DBGWCR_E_SHIFT)
+#define ARM64_DBGWCR_E_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_E_MASK, ARM64_DBGWCR_E_SHIFT)
+#define ARM64_DBGWCR_E_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_E_MASK, \
+ ARM64_DBGWCR_E_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_PAC 0b11lu // Bits 1-2.
+#define ARM64_DBGWCR_PAC_SHIFT 1u
+#define ARM64_DBGWCR_PAC_MASK (ARM64_DBGWCR_PAC << ARM64_DBGWCR_PAC_SHIFT)
+#define ARM64_DBGWCR_PAC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_PAC_MASK, ARM64_DBGWCR_PAC_SHIFT)
+#define ARM64_DBGWCR_PAC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_PAC_MASK, \
+ ARM64_DBGWCR_PAC_SHIFT)
+
+// Load/Store Control.
+//
+// On what event the watchpoint trigger:
+// 01: Read from address.
+// 10: Write to address.
+// 11: Read/Write to address.
+#define ARM64_DBGWCR_LSC 0b11lu // Bits 3-4.
+#define ARM64_DBGWCR_LSC_SHIFT 3u
+#define ARM64_DBGWCR_LSC_MASK (ARM64_DBGWCR_LSC << ARM64_DBGWCR_LSC_SHIFT)
+#define ARM64_DBGWCR_LSC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_LSC_MASK, ARM64_DBGWCR_LSC_SHIFT)
+#define ARM64_DBGWCR_LSC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_LSC_MASK, \
+ ARM64_DBGWCR_LSC_SHIFT)
+
+// Byte Address Select.
+//
+// Each bit defines what bytes to match onto:
+// 0bxxxx'xxx1: Match DBGWVR<n> + 0
+// 0bxxxx'xx1x: Match DBGWVR<n> + 1
+// 0bxxxx'x1xx: Match DBGWVR<n> + 2
+// 0bxxxx'1xxx: Match DBGWVR<n> + 3
+// 0bxxx1'xxxx: Match DBGWVR<n> + 4
+// 0bxx1x'xxxx: Match DBGWVR<n> + 5
+// 0bx1xx'xxxx: Match DBGWVR<n> + 6
+// 0b1xxx'xxxx: Match DBGWVR<n> + 7
+#define ARM64_DBGWCR_BAS 0b11111111lu // Bits 5-12.
+#define ARM64_DBGWCR_BAS_SHIFT 5u
+#define ARM64_DBGWCR_BAS_MASK (ARM64_DBGWCR_BAS << ARM64_DBGWCR_BAS_SHIFT)
+#define ARM64_DBGWCR_BAS_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_BAS_MASK, ARM64_DBGWCR_BAS_SHIFT)
+#define ARM64_DBGWCR_BAS_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_BAS_MASK, \
+ ARM64_DBGWCR_BAS_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_HMC 1lu // Bit 13.
+#define ARM64_DBGWCR_HMC_SHIFT 13u
+#define ARM64_DBGWCR_HMC_MASK (ARM64_DBGWCR_HMC << ARM64_DBGWCR_HMC_SHIFT)
+#define ARM64_DBGWCR_HMC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_HMC_MASK, ARM64_DBGWCR_HMC_SHIFT)
+#define ARM64_DBGWCR_HMC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_HMC_MASK, \
+ ARM64_DBGWCR_HMC_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_SSC 0b11lu // Bits 14-15.
+#define ARM64_DBGWCR_SSC_SHIFT 14u
+#define ARM64_DBGWCR_SSC_MASK (ARM64_DBGWCR_SSC << ARM64_DBGWCR_SSC_SHIFT)
+#define ARM64_DBGWCR_SSC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_SSC_MASK, ARM64_DBGWCR_SSC_SHIFT)
+#define ARM64_DBGWCR_SSC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_SSC_MASK, \
+ ARM64_DBGWCR_SSC_SHIFT)
+
+// Linked Breakpoint Number. Zircon doesn't use this feature. Always zero.
+#define ARM64_DBGWCR_LBN 0b1111lu // Bits 16-19.
+#define ARM64_DBGWCR_LBN_SHIFT 16u
+#define ARM64_DBGWCR_LBN_MASK (ARM64_DBGWCR_LBN << ARM64_DBGWCR_LBN_SHIFT)
+#define ARM64_DBGWCR_LBN_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_LBN_MASK, ARM64_DBGWCR_LBN_SHIFT)
+#define ARM64_DBGWCR_LBN_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_LBN_MASK, \
+ ARM64_DBGWCR_LBN_SHIFT)
+
+// Watchpoint Type. Zircon always use unlinked (0).
+#define ARM64_DBGWCR_WT 1lu // Bit 20.
+#define ARM64_DBGWCR_WT_SHIFT 20u
+#define ARM64_DBGWCR_WT_MASK (ARM64_DBGWCR_WT << ARM64_DBGWCR_WT_SHIFT)
+#define ARM64_DBGWCR_WT_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_WT_MASK, ARM64_DBGWCR_WT_SHIFT)
+#define ARM64_DBGWCR_WT_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_WT_MASK, \
+ ARM64_DBGWCR_WT_SHIFT)
+
+// Mask. How many address bits to mask.
+// This permits the watchpoint to track up to 2G worth of addresses.
+// TODO(donosoc): Initially the debugger is going for parity with x64, which only permits 8 bytes.
+// Eventually expose the ability to track bigger ranges.
+#define ARM64_DBGWCR_MSK 0b11111lu // Bits 24-28.
+#define ARM64_DBGWCR_MSK_SHIFT 24u
+#define ARM64_DBGWCR_MSK_MASK (ARM64_DBGWCR_MSK << ARM64_DBGWCR_MSK_SHIFT)
+#define ARM64_DBGWCR_MSK_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_MSK_MASK, ARM64_DBGWCR_MSK_SHIFT)
+#define ARM64_DBGWCR_MSK_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_MSK_MASK, \
+ ARM64_DBGWCR_MSK_SHIFT)
+
+// Helper functions ================================================================================
+
+inline uint32_t __arm64_internal_hw_debug_get_reg_value(uint32_t reg, uint32_t mask,
+ uint32_t shift) {
+ return (reg & mask) >> shift;
+}
+
+inline void __arm64_internal_hw_debug_set_reg_value(uint32_t* reg, uint32_t value, uint32_t mask,
+ uint32_t shift) {
+ *reg &= ~mask;
+ *reg |= (value << shift) & mask;
+}
+
+#endif // SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/debug/x86.h b/arch/arm64/sysroot/include/zircon/hw/debug/x86.h
new file mode 100644
index 0000000..413b63a
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/debug/x86.h
@@ -0,0 +1,421 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_DEBUG_X86_H_
+#define SYSROOT_ZIRCON_HW_DEBUG_X86_H_
+
+#include <stdint.h>
+
+// x86/x64 Hardware Debug Resources
+// =================================================================================================
+
+// Hardware Breakpoints ----------------------------------------------------------------------------
+//
+// Hardware breakpoints permits to stop a thread when it executes an address setup in one of the
+// hw breakpoints registers. They will work independent whether the address in question is
+// read-only or not.
+
+// Access macros:
+// All the relevant register fields are exposed through macros.
+// For convenience of use, use the get/set macros:
+//
+// uint64_t X86_<REG>_<FIELD>_GET(uint64_t reg)
+// void X86_<REG>_<FIELD>_SET(uint64_t* reg, uint64_t value)
+//
+// Examples:
+// uint64_t rw0 = X86_DBG_CONTROL_RW0_GET(dr7);
+// X86_DBG_CONTROL_RW0_SET(&dr7, modified_rw0);
+
+// DR6: Debug Status Register.
+//
+// This register is updated when the CPU encounters a #DB harware exception. This registers permits
+// users to interpret the result of an exception, such as if it was a single-step, hardware
+// breakpoint, etc.
+//
+// No bit is writeable from userspace. All values will be ignored.
+
+// Whether the address-breakpoint register 0 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B0 1ul
+#define X86_DBG_STATUS_B0_SHIFT 0
+#define X86_DBG_STATUS_B0_MASK (X86_DBG_STATUS_B0 << X86_DBG_STATUS_B0_SHIFT)
+#define X86_DBG_STATUS_B0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B0_MASK, X86_DBG_STATUS_B0_SHIFT)
+#define X86_DBG_STATUS_B0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B0_MASK, \
+ X86_DBG_STATUS_B0_SHIFT)
+
+// Whether the address-breakpoint register 1 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B1 1ul
+#define X86_DBG_STATUS_B1_SHIFT 1
+#define X86_DBG_STATUS_B1_MASK (X86_DBG_STATUS_B1 << X86_DBG_STATUS_B1_SHIFT)
+#define X86_DBG_STATUS_B1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B1_MASK, X86_DBG_STATUS_B1_SHIFT)
+#define X86_DBG_STATUS_B1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B1_MASK, \
+ X86_DBG_STATUS_B1_SHIFT)
+
+// Whether the address-breakpoint register 2 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B2 1ul
+#define X86_DBG_STATUS_B2_SHIFT 2
+#define X86_DBG_STATUS_B2_MASK (X86_DBG_STATUS_B2 << X86_DBG_STATUS_B2_SHIFT)
+#define X86_DBG_STATUS_B2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B2_MASK, X86_DBG_STATUS_B2_SHIFT)
+#define X86_DBG_STATUS_B2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B2_MASK, \
+ X86_DBG_STATUS_B2_SHIFT)
+
+// Whether the address-breakpoint register 3 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B3 1ul
+#define X86_DBG_STATUS_B3_SHIFT 3
+#define X86_DBG_STATUS_B3_MASK (X86_DBG_STATUS_B3 << X86_DBG_STATUS_B3_SHIFT)
+#define X86_DBG_STATUS_B3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B3_MASK, X86_DBG_STATUS_B3_SHIFT)
+#define X86_DBG_STATUS_B3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B3_MASK, \
+ X86_DBG_STATUS_B3_SHIFT)
+
+// Whether there were any software accesses to any debug register (DR0, DR7) while the
+// general-detect condition was enabled in DR7.
+#define X86_DBG_STATUS_BD 1ul
+#define X86_DBG_STATUS_BD_SHIFT 13
+#define X86_DBG_STATUS_BD_MASK (X86_DBG_STATUS_BD << X86_DBG_STATUS_BD_SHIFT)
+#define X86_DBG_STATUS_BD_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BD_MASK, X86_DBG_STATUS_BD_SHIFT)
+#define X86_DBG_STATUS_BD_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BD_MASK, \
+ X86_DBG_STATUS_BD_SHIFT)
+
+// Set to 1 whether the #DB exception occurs as a result of a single-step exception. Single step
+// has the highest priority among debug exceptions. Other status bits can be set within the DR6
+// register among this bit, so callers should also check for those.
+#define X86_DBG_STATUS_BS 1ul
+#define X86_DBG_STATUS_BS_SHIFT 14
+#define X86_DBG_STATUS_BS_MASK (X86_DBG_STATUS_BS << X86_DBG_STATUS_BS_SHIFT)
+#define X86_DBG_STATUS_BS_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BS_MASK, X86_DBG_STATUS_BS_SHIFT)
+#define X86_DBG_STATUS_BS_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BS_MASK, \
+ X86_DBG_STATUS_BS_SHIFT)
+
+// Set to 1 when the exception occurred as a result of a intel task switch to another intel task
+// with a TSS T-bit set to 1. This is not used by zircon.
+#define X86_DBG_STATUS_BT 1ul
+#define X86_DBG_STATUS_BT_SHIFT 15
+#define X86_DBG_STATUS_BT_MASK (X86_DBG_STATUS_BT << X86_DBG_STATUS_BT_SHIFT)
+#define X86_DBG_STATUS_BT_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BT_MASK, X86_DBG_STATUS_BT_SHIFT)
+#define X86_DBG_STATUS_BT_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BT_MASK, \
+ X86_DBG_STATUS_BT_SHIFT)
+
+// DR7: Debug Control Register.
+//
+// This register is used to establish the breakpoint conditions for the address breakpoint registers
+// (DR0-DR3) and to enable debug exceptions for each of them individually. DR7 is also used to
+// enable general-detect breakpoint condition (not permitted by zircon).
+//
+// The following fields are accepted by the user. All other fields are ignored (masked):
+//
+// - L0, L1, L2, L3
+// - LEN0, LEN1, LEN2, LEN3
+// - RW0, RW1, RW2, RW3
+
+// Local Breakpoint Enable 0.
+// Enables debug exceptions to occur when the corresponding address register (DR0) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L0 1ul
+#define X86_DBG_CONTROL_L0_SHIFT 0
+#define X86_DBG_CONTROL_L0_MASK (X86_DBG_CONTROL_L0 << X86_DBG_CONTROL_L0_SHIFT)
+#define X86_DBG_CONTROL_L0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L0_MASK, X86_DBG_CONTROL_L0_SHIFT)
+#define X86_DBG_CONTROL_L0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L0_MASK, \
+ X86_DBG_CONTROL_L0_SHIFT)
+
+// Global Breakpoint Enable 0.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR0) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G0 1ul
+#define X86_DBG_CONTROL_G0_SHIFT 1
+#define X86_DBG_CONTROL_G0_MASK (X86_DBG_CONTROL_G0 << X86_DBG_CONTROL_G0_SHIFT)
+#define X86_DBG_CONTROL_G0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G0_MASK, X86_DBG_CONTROL_G0_SHIFT)
+#define X86_DBG_CONTROL_G0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G0_MASK, \
+ X86_DBG_CONTROL_G0_SHIFT)
+
+// Local Breakpoint Enable 1.
+// Enables debug exceptions to occur when the corresponding address register (DR1) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L1 1ul
+#define X86_DBG_CONTROL_L1_SHIFT 2
+#define X86_DBG_CONTROL_L1_MASK (X86_DBG_CONTROL_L1 << X86_DBG_CONTROL_L1_SHIFT)
+#define X86_DBG_CONTROL_L1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L1_MASK, X86_DBG_CONTROL_L1_SHIFT)
+#define X86_DBG_CONTROL_L1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L1_MASK, \
+ X86_DBG_CONTROL_L1_SHIFT)
+
+// Global Breakpoint Enable 1.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR1) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G1 1ul
+#define X86_DBG_CONTROL_G1_SHIFT 3
+#define X86_DBG_CONTROL_G1_MASK (X86_DBG_CONTROL_G1 << X86_DBG_CONTROL_G1_SHIFT)
+#define X86_DBG_CONTROL_G1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G1_MASK, X86_DBG_CONTROL_G1_SHIFT)
+#define X86_DBG_CONTROL_G1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G1_MASK, \
+ X86_DBG_CONTROL_G1_SHIFT)
+
+// Local Breakpoint Enable 2.
+// Enables debug exceptions to occur when the corresponding address register (DR2) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L2 1ul
+#define X86_DBG_CONTROL_L2_SHIFT 4
+#define X86_DBG_CONTROL_L2_MASK (X86_DBG_CONTROL_L2 << X86_DBG_CONTROL_L2_SHIFT)
+#define X86_DBG_CONTROL_L2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L2_MASK, X86_DBG_CONTROL_L2_SHIFT)
+#define X86_DBG_CONTROL_L2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L2_MASK, \
+ X86_DBG_CONTROL_L2_SHIFT)
+
+// Global Breakpoint Enable 2.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR2) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G2 1ul
+#define X86_DBG_CONTROL_G2_SHIFT 5
+#define X86_DBG_CONTROL_G2_MASK (X86_DBG_CONTROL_G2 << X86_DBG_CONTROL_G2_SHIFT)
+#define X86_DBG_CONTROL_G2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G2_MASK, X86_DBG_CONTROL_G2_SHIFT)
+#define X86_DBG_CONTROL_G2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G2_MASK, \
+ X86_DBG_CONTROL_G2_SHIFT)
+
+// Local Breakpoint Enable 3.
+// Enables debug exceptions to occur when the corresponding address register (DR3) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L3 1ul
+#define X86_DBG_CONTROL_L3_SHIFT 6
+#define X86_DBG_CONTROL_L3_MASK (X86_DBG_CONTROL_L3 << X86_DBG_CONTROL_L3_SHIFT)
+#define X86_DBG_CONTROL_L3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L3_MASK, X86_DBG_CONTROL_L3_SHIFT)
+#define X86_DBG_CONTROL_L3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L3_MASK, \
+ X86_DBG_CONTROL_L3_SHIFT)
+
+// Global Breakpoint Enable 3.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR3) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G3 1u
+#define X86_DBG_CONTROL_G3_SHIFT 7
+#define X86_DBG_CONTROL_G3_MASK (X86_DBG_CONTROL_G3 << X86_DBG_CONTROL_G3_SHIFT)
+#define X86_DBG_CONTROL_G3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G3_MASK, X86_DBG_CONTROL_G3_SHIFT)
+#define X86_DBG_CONTROL_G3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G3_MASK, \
+ X86_DBG_CONTROL_G3_SHIFT)
+
+// Local Enable [Legacy Implementations].
+// Enables exact breakpoints on the while executing the current intel task. This bit is ignored by
+// implementations of the AMD64 architecture.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_LE 1ul
+#define X86_DBG_CONTROL_LE_SHIFT 8
+#define X86_DBG_CONTROL_LE_MASK (X86_DBG_CONTROL_LE << X86_DBG_CONTROL_LE_SHIFT)
+#define X86_DBG_CONTROL_LE_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LE_MASK, X86_DBG_CONTROL_LE_SHIFT)
+#define X86_DBG_CONTROL_LE_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LE_MASK, \
+ X86_DBG_CONTROL_LE_SHIFT)
+
+// Global Enable [Legacy Implementations].
+// Enables exact breakpoints on the while executing *any* intel task. This bit is ignored by
+// implementations of the AMD64 architecture.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_GE 1ul
+#define X86_DBG_CONTROL_GE_SHIFT 9
+#define X86_DBG_CONTROL_GE_MASK (X86_DBG_CONTROL_GE << X86_DBG_CONTROL_GE_SHIFT)
+#define X86_DBG_CONTROL_GE_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_GE_MASK, X86_DBG_CONTROL_GE_SHIFT)
+#define X86_DBG_CONTROL_GE_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_GE_MASK, \
+ X86_DBG_CONTROL_GE_SHIFT)
+
+// General Detect Enable.
+// Whether an attempt to execute a "MOV DR<n>" instruction will trigger a debug exception. This bit
+// is cleared when a #DB handler is entered, so the handler can read/write to those registers.
+// This exception occurs before executing the instruction and DR6.DB is set the the processor.
+// Debuggers can use this bit to prevent the currently executing prgram from interfering with the
+// debug operations.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_GD 1ul
+#define X86_DBG_CONTROL_GD_SHIFT 13
+#define X86_DBG_CONTROL_GD_MASK (X86_DBG_CONTROL_GD << X86_DBG_CONTROL_GD_SHIFT)
+#define X86_DBG_CONTROL_GD_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_GD_MASK, X86_DBG_CONTROL_GD_SHIFT)
+#define X86_DBG_CONTROL_GD_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_GD_MASK, \
+ X86_DBG_CONTROL_GD_SHIFT)
+
+// Read/Write 0.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR0).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW0 3ul
+#define X86_DBG_CONTROL_RW0_SHIFT 16
+#define X86_DBG_CONTROL_RW0_MASK (X86_DBG_CONTROL_RW0 << X86_DBG_CONTROL_RW0_SHIFT)
+#define X86_DBG_CONTROL_RW0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW0_MASK, X86_DBG_CONTROL_RW0_SHIFT)
+#define X86_DBG_CONTROL_RW0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW0_MASK, \
+ X86_DBG_CONTROL_RW0_SHIFT)
+
+// Length 0.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR0). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN0 3ul
+#define X86_DBG_CONTROL_LEN0_SHIFT 18
+#define X86_DBG_CONTROL_LEN0_MASK (X86_DBG_CONTROL_LEN0 << X86_DBG_CONTROL_LEN0_SHIFT)
+#define X86_DBG_CONTROL_LEN0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN0_MASK, \
+ X86_DBG_CONTROL_LEN0_SHIFT)
+#define X86_DBG_CONTROL_LEN0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN0_MASK, \
+ X86_DBG_CONTROL_LEN0_SHIFT)
+
+// Read/Write 1.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR1).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW1 3ul
+#define X86_DBG_CONTROL_RW1_SHIFT 20
+#define X86_DBG_CONTROL_RW1_MASK (X86_DBG_CONTROL_RW1 << X86_DBG_CONTROL_RW1_SHIFT)
+#define X86_DBG_CONTROL_RW1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW1_MASK, X86_DBG_CONTROL_RW1_SHIFT)
+#define X86_DBG_CONTROL_RW1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW1_MASK, \
+ X86_DBG_CONTROL_RW1_SHIFT)
+
+// Length 1.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR1). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN1 3ul
+#define X86_DBG_CONTROL_LEN1_SHIFT 22
+#define X86_DBG_CONTROL_LEN1_MASK (X86_DBG_CONTROL_LEN1 << X86_DBG_CONTROL_LEN1_SHIFT)
+#define X86_DBG_CONTROL_LEN1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN1_MASK, \
+ X86_DBG_CONTROL_LEN1_SHIFT)
+#define X86_DBG_CONTROL_LEN1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN1_MASK, \
+ X86_DBG_CONTROL_LEN1_SHIFT)
+
+// Read/Write 2.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR2).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW2 3ul
+#define X86_DBG_CONTROL_RW2_SHIFT 24
+#define X86_DBG_CONTROL_RW2_MASK (X86_DBG_CONTROL_RW2 << X86_DBG_CONTROL_RW2_SHIFT)
+#define X86_DBG_CONTROL_RW2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW2_MASK, X86_DBG_CONTROL_RW2_SHIFT)
+#define X86_DBG_CONTROL_RW2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW2_MASK, \
+ X86_DBG_CONTROL_RW2_SHIFT)
+
+// Length 2.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR2). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN2 3ul
+#define X86_DBG_CONTROL_LEN2_SHIFT 26
+#define X86_DBG_CONTROL_LEN2_MASK (X86_DBG_CONTROL_LEN2 << X86_DBG_CONTROL_LEN2_SHIFT)
+#define X86_DBG_CONTROL_LEN2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN2_MASK, \
+ X86_DBG_CONTROL_LEN2_SHIFT)
+#define X86_DBG_CONTROL_LEN2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN2_MASK, \
+ X86_DBG_CONTROL_LEN2_SHIFT)
+
+// Read/Write 3.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR3).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW3 3ul
+#define X86_DBG_CONTROL_RW3_SHIFT 28
+#define X86_DBG_CONTROL_RW3_MASK (X86_DBG_CONTROL_RW3 << X86_DBG_CONTROL_RW3_SHIFT)
+#define X86_DBG_CONTROL_RW3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW3_MASK, X86_DBG_CONTROL_RW3_SHIFT)
+#define X86_DBG_CONTROL_RW3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW3_MASK, \
+ X86_DBG_CONTROL_RW3_SHIFT)
+
+// Length 3.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR3). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN3 3ul
+#define X86_DBG_CONTROL_LEN3_SHIFT 30
+#define X86_DBG_CONTROL_LEN3_MASK (X86_DBG_CONTROL_LEN3 << X86_DBG_CONTROL_LEN3_SHIFT)
+#define X86_DBG_CONTROL_LEN3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN3_MASK, \
+ X86_DBG_CONTROL_LEN3_SHIFT)
+#define X86_DBG_CONTROL_LEN3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN3_MASK, \
+ X86_DBG_CONTROL_LEN3_SHIFT)
+
+// Helper functions ================================================================================
+
+inline uint64_t __x86_internal_hw_debug_get_reg_value(uint64_t reg, uint64_t mask, uint64_t shift) {
+ return (reg & mask) >> shift;
+}
+
+inline void __x86_internal_hw_debug_set_reg_value(uint64_t* reg, uint64_t value, uint64_t mask,
+ uint64_t shift) {
+ *reg &= ~mask;
+ *reg |= (value << shift) & mask;
+}
+
+#endif // SYSROOT_ZIRCON_HW_DEBUG_X86_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/gpt.h b/arch/arm64/sysroot/include/zircon/hw/gpt.h
index c3112f5..d93a23c 100644
--- a/arch/arm64/sysroot/include/zircon/hw/gpt.h
+++ b/arch/arm64/sysroot/include/zircon/hw/gpt.h
@@ -2,59 +2,224 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_GPT_H_
+#define SYSROOT_ZIRCON_HW_GPT_H_
+#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
-
#include <zircon/compiler.h>
-#define GPT_MAGIC (0x5452415020494645ull) // 'EFI PART'
+#define GPT_MAGIC (0x5452415020494645ull) // 'EFI PART'
#define GPT_HEADER_SIZE 0x5c
-#define GPT_ENTRY_SIZE 0x80
+#define GPT_ENTRY_SIZE 0x80
#define GPT_GUID_LEN 16
#define GPT_GUID_STRLEN 37
#define GPT_NAME_LEN 72
typedef struct gpt_header {
- uint64_t magic;
- uint32_t revision;
- uint32_t size;
- uint32_t crc32;
- uint32_t reserved0;
- uint64_t current;
- uint64_t backup;
- uint64_t first;
- uint64_t last;
- uint8_t guid[GPT_GUID_LEN];
- uint64_t entries;
- uint32_t entries_count;
- uint32_t entries_size;
- uint32_t entries_crc;
+ uint64_t magic; // Magic number.
+ uint32_t revision; // Revision.
+ uint32_t size; // Size of the header.
+ uint32_t crc32; // Checksum of this header.
+ uint32_t reserved0; // Reserved field.
+ uint64_t current; // Block where this table is stored.
+ uint64_t backup; // Block where other copy of partition table is stored.
+ uint64_t first; // First usable block. Block after primary partition table ends.
+ uint64_t last; // Last usable block. Block before backup partition table starts.
+ uint8_t guid[GPT_GUID_LEN]; // Disk GUID.
+ uint64_t entries; // Starting block where entries for this partition tables are found.
+ // Value equals 2 for primary copy.
+ uint32_t entries_count; // Total number of entries.
+ uint32_t entries_size; // Size of each entry.
+ uint32_t entries_crc; // Checksum of the entire entries array.
} __PACKED gpt_header_t;
-typedef struct gpt_entry {
- uint8_t type[GPT_GUID_LEN];
- uint8_t guid[GPT_GUID_LEN];
- uint64_t first;
- uint64_t last;
- uint64_t flags;
- uint8_t name[GPT_NAME_LEN]; // UTF-16 on disk
-} __PACKED gpt_entry_t;
+static_assert(GPT_HEADER_SIZE == sizeof(gpt_header_t), "Gpt header size invalid");
+typedef struct gpt_entry {
+ uint8_t type[GPT_GUID_LEN];
+ uint8_t guid[GPT_GUID_LEN];
+ uint64_t first;
+ uint64_t last;
+ uint64_t flags;
+ uint8_t name[GPT_NAME_LEN]; // UTF-16 on disk
+} gpt_entry_t;
+
+static_assert(GPT_ENTRY_SIZE == sizeof(gpt_entry_t), "Gpt entry size invalid");
+
+// GUIDs are specified in mixed-endian, to avoid manual errors use this macro.
+// Example usage: GPT_GUID(0x00112233, 0x4455, 0x6677, 0x8899, 0xAABBCCDDEEFF)
+// clang-format off
+#define GPT_GUID(group0, group1, group2, group3, group4) { \
+ /* group0: 4 bytes, little-endian. */ \
+ (group0 >> 0) & 0xFF, \
+ (group0 >> 8) & 0xFF, \
+ (group0 >> 16) & 0xFF, \
+ (group0 >> 24) & 0xFF, \
+ /* group1: 2 bytes, little-endian. */ \
+ (group1 >> 0) & 0xFF, \
+ (group1 >> 8) & 0xFF, \
+ /* group2: 2 bytes, little-endian. */ \
+ (group2 >> 0) & 0xFF, \
+ (group2 >> 8) & 0xFF, \
+ /* group3: 2 bytes, big-endian. */ \
+ (group3 >> 8) & 0xFF, \
+ (group3 >> 0) & 0xFF, \
+ /* group4: 6 bytes, big-endian. */ \
+ (group4 >> 40) & 0xFF, \
+ (group4 >> 32) & 0xFF, \
+ (group4 >> 24) & 0xFF, \
+ (group4 >> 16) & 0xFF, \
+ (group4 >> 8) & 0xFF, \
+ (group4 >> 0) & 0xFF \
+}
+// clang-format on
+
+// == GPT partition definitions ==
+//
+// These are some common partition definitions used across various boards.
+// The general scheme is:
+// |type|: identical for slotted partitions, e.g. zircon_{a,b,r} will all
+// share the same type GUID
+// |guid|: unspecified and generally expected to be random
+// |name|: specific name for uniquely identifying partitions
+//
+// New boards should adopt this scheme when possible, but see below for a
+// slightly different legacy scheme used by existing boards.
+
+// clang-format off
+
+// bootloader_{a,b,r}
+//
+// These partitions are optional and may be used to hold bootloader and/or
+// other firmware images. The format is SoC-specific.
+#define GPT_BOOTLOADER_A_NAME "bootloader_a"
+#define GPT_BOOTLOADER_B_NAME "bootloader_b"
+#define GPT_BOOTLOADER_R_NAME "bootloader_r"
+#define GPT_BOOTLOADER_ABR_TYPE_GUID GPT_GUID(0xfe8a2634, 0x5e2e, 0x46ba, 0x99e3, 0x3a192091a350)
+
+// durable
+//
+// This partition holds mutable data that must remain intact across factory
+// reset. It differs from durable_boot only in that it is larger, ignored by
+// bootloaders, and is expected to have a filesystem.
+//
+// This partition is expected to be written to by Fuchsia during normal
+// operation. It is expected to be read by Fuchsia, but not by any bootloader
+// or firmware. It is expected to have a filesystem with encryption built in.
+// Use of this partition increases attack surface and should be minimized.
+#define GPT_DURABLE_NAME "durable"
+#define GPT_DURABLE_TYPE_GUID GPT_GUID(0xd9fd4535, 0x106c, 0x4cec, 0x8d37, 0xdfc020ca87cb)
+
+// durable_boot
+//
+// This partition holds A/B/R metadata and other very small mutable data that
+// must remain intact across factory reset. There is no filesystem and the
+// content layout is fixed.
+//
+// This partition is expected to be written to by Fuchsia and the main
+// bootloader during normal operation. It is expected to be read by bootloaders
+// very early in boot. It has no encryption or integrity check built in. Use of
+// this partition increases attack surface and should be minimized.
+#define GPT_DURABLE_BOOT_NAME "durable_boot"
+#define GPT_DURABLE_BOOT_TYPE_GUID GPT_GUID(0xa409e16b, 0x78aa, 0x4acc, 0x995c, 0x302352621a41)
+
+// factory
+//
+// This partition holds factory-provisioned data used by the Fuchsia-based
+// system and is read-only.
+//
+// It is expected that this partition is only written in the factory and has a
+// simple file system. It is not encrypted, but is checked for integrity by
+// Fuchsia. Bootloaders and firmware are expected to ignore this partition.
+#define GPT_FACTORY_NAME "factory"
+#define GPT_FACTORY_TYPE_GUID GPT_GUID(0xf95d940e, 0xcaba, 0x4578, 0x9b93, 0xbb6c90f29d3e)
+
+// factory_boot
+//
+// This partition holds factory-provisioned data used by the bootloader and is
+// read-only. It must be small enough to be loaded into memory and verified
+// during boot.
+//
+// It is expected that this partition is only written in the factory and has a
+// simple structured format, not a filesystem. It is not encrypted but is
+// checked for integrity by the verified boot process. It is expected to be read
+// only by the main bootloader, not by Fuchsia.
+#define GPT_FACTORY_BOOT_NAME "factory_boot"
+#define GPT_FACTORY_BOOT_TYPE_GUID GPT_GUID(0x10b8dbaa, 0xd2bf, 0x42a9, 0x98c6, 0xa7c5db3701e7)
+
+// fvm
+//
+// This partition is owned by the Fuchsia Volume Manager. It will be used for
+// both system and user data.
+#define GPT_FVM_NAME "fvm"
+#define GPT_FVM_TYPE_GUID GPT_GUID(0x49fd7cb8, 0xdf15, 0x4e73, 0xb9d9, 0x992070127f0f)
+
+// vbmeta_{a,b,r}
+//
+// These partitions each hold verified boot metadata for a particular A/B/R
+// slot. The format is defined by libavb.
+//
+// These partitions are expected to be written in the factory and during an OTA
+// update. They are expected to be read by the main bootloader and possibly by
+// Fuchsia. They are not encrypted, but are checked for integrity as part of the
+// verified boot process.
+#define GPT_VBMETA_A_NAME "vbmeta_a"
+#define GPT_VBMETA_B_NAME "vbmeta_b"
+#define GPT_VBMETA_R_NAME "vbmeta_r"
+#define GPT_VBMETA_ABR_TYPE_GUID GPT_GUID(0x421a8bfc, 0x85d9, 0x4d85, 0xacda, 0xb64eec0133e9)
+
+// zircon_{a,b,r}
+//
+// These partitions each hold a complete Zircon boot image, including an
+// embedded bootfs image, for a particular A/B/R slot.
+//
+// These partitions are expected to be written in the factory and during an OTA
+// update. They are expected to be read only by the main bootloader. They are
+// not encrypted but are checked for integrity as part of the verified boot
+// process.
+#define GPT_ZIRCON_A_NAME "zircon_a"
+#define GPT_ZIRCON_B_NAME "zircon_b"
+#define GPT_ZIRCON_R_NAME "zircon_r"
+#define GPT_ZIRCON_ABR_TYPE_GUID GPT_GUID(0x9b37fff6, 0x2e58, 0x466a, 0x983a, 0xf7926d0b04e0)
+
+// Microsoft basic data partition
+//
+// These partitions usually contain FAT filesystems. They are mounted by the fat
+// implementation at //src/storage/fuchsia-fatfs.
+// These partitions do not have an expected label.
+#define GPT_MICROSOFT_BASIC_DATA_TYPE_GUID \
+ GPT_GUID(0xebd0a0a2, 0xb9e5, 0x4433, 0x87c0, 0x68b6b72699c7)
+
+// clang-format on
+
+// == Legacy GPT partition definitions ==
+//
+// These definitions instead use the following scheme:
+// |type|: unique for each partition, e.g. zircon_{a,b,r} will each have their
+// own type GUID
+// |guid|: unspecified and generally expected to be random
+// |name|: specific name, can use this or |type| find an individual partition
+
+// clang-format off
+#define GUID_EMPTY_STRING "00000000-0000-0000-0000-000000000000"
#define GUID_EMPTY_VALUE { \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, \
0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
}
+#define GUID_EMPTY_NAME "empty"
+#define GUID_EFI_STRING "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
#define GUID_EFI_VALUE { \
0x28, 0x73, 0x2a, 0xc1, \
0x1f, 0xf8, \
0xd2, 0x11, \
0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b \
}
+#define GUID_EFI_NAME "fuchsia-esp"
// GUID for a system partition
#define GUID_SYSTEM_STRING "606B000B-B7C7-4653-A7D5-B737332C899D"
@@ -64,6 +229,7 @@
0x53, 0x46, \
0xa7, 0xd5, 0xb7, 0x37, 0x33, 0x2c, 0x89, 0x9d \
}
+#define GUID_SYSTEM_NAME "fuchsia-system"
// GUID for a data partition
#define GUID_DATA_STRING "08185F0C-892D-428A-A789-DBEEC8F55E6A"
@@ -73,6 +239,7 @@
0x8a, 0x42, \
0xa7, 0x89, 0xdb, 0xee, 0xc8, 0xf5, 0x5e, 0x6a \
}
+#define GUID_DATA_NAME "fuchsia-data"
// GUID for a installer partition
#define GUID_INSTALL_STRING "48435546-4953-2041-494E-5354414C4C52"
@@ -82,6 +249,7 @@
0x41, 0x20, \
0x49, 0x4E, 0x53, 0x54, 0x41, 0x4C, 0x4C, 0x52 \
}
+#define GUID_INSTALL_NAME "fuchsia-install"
#define GUID_BLOB_STRING "2967380E-134C-4CBB-B6DA-17E7CE1CA45D"
#define GUID_BLOB_VALUE { \
@@ -90,6 +258,7 @@
0xbb, 0x4c, \
0xb6, 0xda, 0x17, 0xe7, 0xce, 0x1c, 0xa4, 0x5d \
}
+#define GUID_BLOB_NAME "fuchsia-blob"
#define GUID_FVM_STRING "41D0E340-57E3-954E-8C1E-17ECAC44CFF5"
#define GUID_FVM_VALUE { \
@@ -98,75 +267,188 @@
0x4e, 0x95, \
0x8c, 0x1e, 0x17, 0xec, 0xac, 0x44, 0xcf, 0xf5 \
}
+#define GUID_FVM_NAME "fuchsia-fvm"
#define GUID_ZIRCON_A_STRING "DE30CC86-1F4A-4A31-93C4-66F147D33E05"
-#define GUID_ZIRCON_A_VALUE { \
- 0x86, 0xcc, 0x30, 0xde, \
- 0x4a, 0x1f, \
- 0x31, 0x4a, \
+#define GUID_ZIRCON_A_VALUE { \
+ 0x86, 0xcc, 0x30, 0xde, \
+ 0x4a, 0x1f, \
+ 0x31, 0x4a, \
0x93, 0xc4, 0x66, 0xf1, 0x47, 0xd3, 0x3e, 0x05, \
}
+#define GUID_ZIRCON_A_NAME "zircon-a"
#define GUID_ZIRCON_B_STRING "23CC04DF-C278-4CE7-8471-897D1A4BCDF7"
-#define GUID_ZIRCON_B_VALUE { \
- 0xdf, 0x04, 0xcc, 0x23, \
- 0x78, 0xc2, \
- 0xe7, 0x4c, \
+#define GUID_ZIRCON_B_VALUE { \
+ 0xdf, 0x04, 0xcc, 0x23, \
+ 0x78, 0xc2, \
+ 0xe7, 0x4c, \
0x84, 0x71, 0x89, 0x7d, 0x1a, 0x4b, 0xcd, 0xf7 \
}
+#define GUID_ZIRCON_B_NAME "zircon-b"
#define GUID_ZIRCON_R_STRING "A0E5CF57-2DEF-46BE-A80C-A2067C37CD49"
-#define GUID_ZIRCON_R_VALUE { \
- 0x57, 0xcf, 0xe5, 0xa0, \
- 0xef, 0x2d, \
- 0xbe, 0x46, \
+#define GUID_ZIRCON_R_VALUE { \
+ 0x57, 0xcf, 0xe5, 0xa0, \
+ 0xef, 0x2d, \
+ 0xbe, 0x46, \
0xa8, 0x0c, 0xa2, 0x06, 0x7c, 0x37, 0xcd, 0x49 \
}
+#define GUID_ZIRCON_R_NAME "zircon-r"
#define GUID_SYS_CONFIG_STRING "4E5E989E-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_SYS_CONFIG_VALUE { \
+#define GUID_SYS_CONFIG_VALUE { \
0x9e, 0x98, 0x5e, 0x4e, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_SYS_CONFIG_NAME "sys-config"
#define GUID_FACTORY_CONFIG_STRING "5A3A90BE-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_FACTORY_CONFIG_VALUE { \
+#define GUID_FACTORY_CONFIG_VALUE { \
0xbe, 0x90, 0x3a, 0x5a, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_FACTORY_CONFIG_NAME "factory-config"
#define GUID_BOOTLOADER_STRING "5ECE94FE-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_BOOTLOADER_VALUE { \
+#define GUID_BOOTLOADER_VALUE { \
0xfe, 0x94, 0xce, 0x5e, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_BOOTLOADER_NAME "bootloader"
#define GUID_TEST_STRING "8B94D043-30BE-4871-9DFA-D69556E8C1F3"
-#define GUID_TEST_VALUE { \
+#define GUID_TEST_VALUE { \
0x43, 0xD0, 0x94, 0x8b, \
0xbe, 0x30, \
- 0x71, 0x38, \
+ 0x71, 0x48, \
0x9d, 0xfa, 0xd6, 0x95, 0x56, 0xe8, 0xc1, 0xf3 \
}
+#define GUID_TEST_NAME "guid-test"
#define GUID_VBMETA_A_STRING "A13B4D9A-EC5F-11E8-97D8-6C3BE52705BF"
-#define GUID_VBMETA_A_VALUE { \
+#define GUID_VBMETA_A_VALUE { \
0x9a, 0x4d, 0x3b, 0xa1, \
0x5f, 0xec, \
- 0xd8, 0x97, \
- 0x6c, 0x3b, 0x6c, 0x3b, 0xe2, 0x27, 0x05, 0xbf \
+ 0xe8, 0x11, \
+ 0x97, 0xd8, 0x6c, 0x3b, 0xe5, 0x27, 0x05, 0xbf \
}
+#define GUID_VBMETA_A_NAME "vbmeta_a"
#define GUID_VBMETA_B_STRING "A288ABF2-EC5F-11E8-97D8-6C3BE52705BF"
-#define GUID_VBMETA_B_VALUE { \
+#define GUID_VBMETA_B_VALUE { \
0xf2, 0xab, 0x88, 0xa2, \
0x5f, 0xec, \
- 0xd8, 0x97, \
- 0x6c, 0x3b, 0x6c, 0x3b, 0xe2, 0x27, 0x05, 0xbf \
+ 0xe8, 0x11, \
+ 0x97, 0xd8, 0x6c, 0x3b, 0xe5, 0x27, 0x05, 0xbf \
}
+#define GUID_VBMETA_B_NAME "vbmeta_b"
+
+#define GUID_VBMETA_R_STRING "6A2460C3-CD11-4E8B-80A8-12CCE268ED0A"
+#define GUID_VBMETA_R_VALUE { \
+ 0xc3, 0x60, 0x24, 0x6a, \
+ 0x11, 0xcd, \
+ 0x8b, 0x4e, \
+ 0x80, 0xa8, 0x12, 0xcc, 0xe2, 0x68, 0xed, 0x0a \
+}
+#define GUID_VBMETA_R_NAME "vbmeta_r"
+
+#define GUID_ABR_META_STRING "1D75395D-F2C6-476B-A8B7-45CC1C97B476"
+#define GUID_ABR_META_VALUE { \
+ 0x5d, 0x39, 0x75, 0x1d, \
+ 0xc6, 0xf2, \
+ 0x6b, 0x47, \
+ 0xa8, 0xb7, 0x45, 0xcc, 0x1c, 0x97, 0xb4, 0x76 \
+}
+#define GUID_ABR_META_NAME "misc"
+
+#define GUID_CROS_KERNEL_STRING "FE3A2A5D-4F32-41A7-B725-ACCC3285A309"
+#define GUID_CROS_KERNEL_VALUE { \
+ 0x5d, 0x2a, 0x3a, 0xfe, \
+ 0x32, 0x4f, \
+ 0xa7, 0x41, \
+ 0xb7, 0x25, 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 \
+}
+#define GUID_CROS_KERNEL_NAME "cros-kernel"
+
+#define GUID_CROS_ROOTFS_STRING "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC"
+#define GUID_CROS_ROOTFS_VALUE { \
+ 0x02, 0xe2, 0xb8, 0x3C, \
+ 0x7e, 0x3b, \
+ 0xdd, 0x47, \
+ 0x8a, 0x3c, 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec \
+}
+#define GUID_CROS_ROOTFS_NAME "cros-rootfs"
+
+#define GUID_CROS_RESERVED_STRING "2E0A753D-9E48-43B0-8337-B15192CB1B5E"
+#define GUID_CROS_RESERVED_VALUE { \
+ 0x3d, 0x75, 0x0a, 0x2e, \
+ 0x48, 0x9e, \
+ 0xb0, 0x43, \
+ 0x83, 0x37, 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e \
+}
+#define GUID_CROS_RESERVED_NAME "cros-reserved"
+
+#define GUID_CROS_FIRMWARE_STRING "CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3"
+#define GUID_CROS_FIRMWARE_VALUE { \
+ 0x8e, 0xe8, 0xb6, 0xca, \
+ 0xf3, 0xab, \
+ 0x02, 0x41, \
+ 0xa0, 0x7a, 0xd4, 0xbb, 0x9b, 0xe3, 0xc1, 0xd3 \
+}
+#define GUID_CROS_FIRMWARE_NAME "cros-firmware"
+
+#define GUID_CROS_DATA_STRING "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
+#define GUID_CROS_DATA_VALUE { \
+ 0xa2, 0xa0, 0xd0, 0xeb, \
+ 0xe5, 0xb9, \
+ 0x33, 0x44, \
+ 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 \
+}
+#define GUID_CROS_DATA_NAME "cros-data"
+
+#define GUID_BIOS_STRING "21686148-6449-6E6F-744E-656564454649"
+#define GUID_BIOS_VALUE { \
+ 0x48, 0x61, 0x68, 0x21, \
+ 0x49, 0x64, \
+ 0x6f, 0x6e, \
+ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 \
+}
+#define GUID_BIOS_NAME "bios"
+
+#define GUID_EMMC_BOOT1_STRING "900B0FC5-90CD-4D4F-84F9-9F8ED579DB88"
+#define GUID_EMMC_BOOT1_VALUE { \
+ 0xc5, 0x0f, 0x0b, 0x90, \
+ 0xcd, 0x90, \
+ 0x4f, 0x4d, \
+ 0x84, 0xf9, 0x9f, 0x8e, 0xd5, 0x79, 0xdb, 0x88 \
+}
+#define GUID_EMMC_BOOT1_NAME "emmc-boot1"
+
+#define GUID_EMMC_BOOT2_STRING "B2B2E8D1-7C10-4EBC-A2D0-4614568260AD"
+#define GUID_EMMC_BOOT2_VALUE { \
+ 0xd1, 0xe8, 0xb2, 0xb2, \
+ 0x10, 0x7c, \
+ 0xbc, 0x4e, \
+ 0xa2, 0xd0, 0x46, 0x14, 0x56, 0x82, 0x60, 0xad \
+}
+#define GUID_EMMC_BOOT2_NAME "emmc-boot2"
+
+#define GUID_LINUX_FILESYSTEM_DATA_STRING "0FC63DAF-8483-4772-8E79-3D69D8477DE4"
+#define GUID_LINUX_FILESYSTEM_DATA_VALUE { \
+ 0xaf, 0x3d, 0xc6, 0x0f, \
+ 0x83, 0x84, \
+ 0x72, 0x47, \
+ 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4 \
+}
+#define GUID_LINUX_FILESYSTEM_DATA_NAME "linux-filesystem"
+
+// clang-format on
+
+#endif // SYSROOT_ZIRCON_HW_GPT_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/i2c.h b/arch/arm64/sysroot/include/zircon/hw/i2c.h
index a8f0f4b..e35b6f1 100644
--- a/arch/arm64/sysroot/include/zircon/hw/i2c.h
+++ b/arch/arm64/sysroot/include/zircon/hw/i2c.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_I2C_H_
+#define SYSROOT_ZIRCON_HW_I2C_H_
#define I2C_CLASS_HID 1
+
+#endif // SYSROOT_ZIRCON_HW_I2C_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/pci.h b/arch/arm64/sysroot/include/zircon/hw/pci.h
index 06c7023..7de1bca 100644
--- a/arch/arm64/sysroot/include/zircon/hw/pci.h
+++ b/arch/arm64/sysroot/include/zircon/hw/pci.h
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_HW_PCI_H_
-#define ZIRCON_HW_PCI_H_
+#ifndef SYSROOT_ZIRCON_HW_PCI_H_
+#define SYSROOT_ZIRCON_HW_PCI_H_
#include <stdint.h>
#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// Structure for passing around PCI address information
typedef struct pci_bdf {
- uint8_t bus_id;
- uint8_t device_id;
- uint8_t function_id;
+ uint8_t bus_id;
+ uint8_t device_id;
+ uint8_t function_id;
} pci_bdf_t;
// TODO(cja): This header is used for the transition of these defines from
@@ -43,8 +43,8 @@
#define PCI_INVALID_VENDOR_ID (0xFFFF)
-#endif // WITH_KERNEL_PCIE
+#endif // WITH_KERNEL_PCIE
-__END_CDECLS;
+__END_CDECLS
-#endif // ZIRCON_HW_PCI_H_
+#endif // SYSROOT_ZIRCON_HW_PCI_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-audio.h b/arch/arm64/sysroot/include/zircon/hw/usb-audio.h
deleted file mode 100644
index 7af2994..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-audio.h
+++ /dev/null
@@ -1,524 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS;
-
-////////////////////////////////////////////////////
-//
-// General Audio interface constants
-//
-////////////////////////////////////////////////////
-
-// audio interface subclasses
-#define USB_SUBCLASS_AUDIO_CONTROL 0x01
-#define USB_SUBCLASS_AUDIO_STREAMING 0x02
-#define USB_SUBCLASS_MIDI_STREAMING 0x03
-
-// audio class specific descriptor types
-#define USB_AUDIO_CS_DEVICE 0x21
-#define USB_AUDIO_CS_CONFIGURATION 0x22
-#define USB_AUDIO_CS_STRING 0x23
-#define USB_AUDIO_CS_INTERFACE 0x24
-#define USB_AUDIO_CS_ENDPOINT 0x25
-
-////////////////////////////////////////////////////
-//
-// Audio Control interface constants
-//
-////////////////////////////////////////////////////
-
-// audio class specific AC interface descriptor subtypes
-#define USB_AUDIO_AC_HEADER 0x01
-#define USB_AUDIO_AC_INPUT_TERMINAL 0x02
-#define USB_AUDIO_AC_OUTPUT_TERMINAL 0x03
-#define USB_AUDIO_AC_MIXER_UNIT 0x04
-#define USB_AUDIO_AC_SELECTOR_UNIT 0x05
-#define USB_AUDIO_AC_FEATURE_UNIT 0x06
-#define USB_AUDIO_AC_PROCESSING_UNIT 0x07
-#define USB_AUDIO_AC_EXTENSION_UNIT 0x08
-
-// processing unit process types
-#define USB_AUDIO_UP_DOWN_MIX_PROCESS 0x01
-#define USB_AUDIO_DOLBY_PROLOGIC_PROCESS 0x02
-#define USB_AUDIO_3D_STEREO_EXTENDER_PROCESS 0x03
-#define USB_AUDIO_REVERBERATION_PROCESS 0x04
-#define USB_AUDIO_CHORUS_PROCESS 0x05
-#define USB_AUDIO_DYN_RANGE_COMP_PROCESS 0x06
-
-// audio class specific endpoint descriptor subtypes
-#define USB_AUDIO_EP_GENERAL 0x01
-
-// audio class specific request codes
-#define USB_AUDIO_SET_CUR 0x01
-#define USB_AUDIO_GET_CUR 0x81
-#define USB_AUDIO_SET_MIN 0x02
-#define USB_AUDIO_GET_MIN 0x82
-#define USB_AUDIO_SET_MAX 0x03
-#define USB_AUDIO_GET_MAX 0x83
-#define USB_AUDIO_SET_RES 0x04
-#define USB_AUDIO_GET_RES 0x84
-#define USB_AUDIO_SET_MEM 0x05
-#define USB_AUDIO_GET_MEM 0x85
-#define USB_AUDIO_GET_STAT 0xFF
-
-// terminal control selectors
-#define USB_AUDIO_COPY_PROTECT_CONTROL 0x01
-
-// feature unit control selectors
-#define USB_AUDIO_MUTE_CONTROL 0x01
-#define USB_AUDIO_VOLUME_CONTROL 0x02
-#define USB_AUDIO_BASS_CONTROL 0x03
-#define USB_AUDIO_MID_CONTROL 0x04
-#define USB_AUDIO_TREBLE_CONTROL 0x05
-#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
-#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
-#define USB_AUDIO_DELAY_CONTROL 0x08
-#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
-#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
-
-// feature unit control support bitmasks
-#define USB_AUDIO_FU_BMA_MUTE (1u << 0u)
-#define USB_AUDIO_FU_BMA_VOLUME (1u << 1u)
-#define USB_AUDIO_FU_BMA_BASS (1u << 2u)
-#define USB_AUDIO_FU_BMA_MID (1u << 3u)
-#define USB_AUDIO_FU_BMA_TREBLE (1u << 4u)
-#define USB_AUDIO_FU_BMA_GRAPHIC_EQUALIZER (1u << 5u)
-#define USB_AUDIO_FU_BMA_AUTOMATIC_GAIN (1u << 6u)
-#define USB_AUDIO_FU_BMA_DELAY (1u << 7u)
-#define USB_AUDIO_FU_BMA_BASS_BOOST (1u << 8u)
-#define USB_AUDIO_FU_BMA_LOUDNESS (1u << 9u)
-
-// up/down mix processing unit control selectors
-#define USB_AUDIO_UD_ENABLE_CONTROL 0x01
-#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
-#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
-
-// Dolby Prologic processing unit control selectors
-#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
-#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
-
-// 3D stereo extender processing unit control selectors
-#define USB_AUDIO_3D_ENABLE_CONTROL 0x01
-#define USB_AUDIO_SPACIOUSNESS_CONTROL 0x03
-
-// reverberation processing unit control selectors
-#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
-#define USB_AUDIO_REVERB_LEVEL_CONTROL 0x02
-#define USB_AUDIO_REVERB_TIME_CONTROL 0x03
-#define USB_AUDIO_REVERB_FEEDBACK_CONTROL 0x04
-
-// chorus processing unit control selectors
-#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
-#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
-#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
-#define USB_AUDIO_CHORUS_DEPTH_CONTROL 0x04
-
-// dynamic range compressor processing unit control selectors
-#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
-#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
-#define USB_AUDIO_MAXAMPL_CONTROL 0x03
-#define USB_AUDIO_THRESHOLD_CONTROL 0x04
-#define USB_AUDIO_ATTACK_TIME 0x05
-#define USB_AUDIO_RELEASE_TIME 0x06
-
-// extension unit control selectors
-#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
-
-// endpoint control selectors
-#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
-#define USB_AUDIO_PITCH_CONTROL 0x02
-
-// USB audio terminal types
-#define USB_AUDIO_TERMINAL_USB_UNDEFINED 0x0100
-#define USB_AUDIO_TERMINAL_USB_STREAMING 0x0101
-#define USB_AUDIO_TERMINAL_USB_VENDOR 0x01FF
-#define USB_AUDIO_TERMINAL_INPUT_UNDEFINED 0x0200
-#define USB_AUDIO_TERMINAL_MICROPHONE 0x0201
-#define USB_AUDIO_TERMINAL_DESKTOP_MICROPHONE 0x0202
-#define USB_AUDIO_TERMINAL_PERSONAL_MICROPHONE 0x0203
-#define USB_AUDIO_TERMINAL_OMNI_DIRECTIONAL_MICROPHONE 0x0204
-#define USB_AUDIO_TERMINAL_MICROPHONE_ARRAY 0x0205
-#define USB_AUDIO_TERMINAL_PROCESSING_MICROPHONE_ARRAY 0x0206
-#define USB_AUDIO_TERMINAL_OUTPUT_UNDEFINED 0x0300
-#define USB_AUDIO_TERMINAL_SPEAKER 0x0301
-#define USB_AUDIO_TERMINAL_HEADPHONES 0x0302
-#define USB_AUDIO_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x0303
-#define USB_AUDIO_TERMINAL_DESKTOP_SPEAKER 0x0304
-#define USB_AUDIO_TERMINAL_ROOM_SPEAKER 0x0305
-#define USB_AUDIO_TERMINAL_COMMUNICATION_SPEAKER 0x0306
-#define USB_AUDIO_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x0307
-#define USB_AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED 0x0400
-#define USB_AUDIO_TERMINAL_HANDSET 0x0401
-#define USB_AUDIO_TERMINAL_HEADSET 0x0402
-#define USB_AUDIO_TERMINAL_SPEAKERPHONE 0x0403
-#define USB_AUDIO_TERMINAL_ECHO_SUPPRESSING_SPEAKERPHONE 0x0404
-#define USB_AUDIO_TERMINAL_ECHO_CANCELING_SPEAKERPHONE 0x0405
-#define USB_AUDIO_TERMINAL_TELEPHONY_UNDEFINED 0x0500
-#define USB_AUDIO_TERMINAL_PHONE_LINE 0x0501
-#define USB_AUDIO_TERMINAL_TELEPHONE 0x0502
-#define USB_AUDIO_TERMINAL_DOWN_LINE_PHONE 0x0503
-#define USB_AUDIO_TERMINAL_EXTERNAL_UNDEFINED 0x0600
-#define USB_AUDIO_TERMINAL_ANALOG_CONNECTOR 0x0601
-#define USB_AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE 0x0602
-#define USB_AUDIO_TERMINAL_LINE_CONNECTOR 0x0603
-#define USB_AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR 0x0604
-#define USB_AUDIO_TERMINAL_SPDIF_INTERFACE 0x0605
-#define USB_AUDIO_TERMINAL_1394_DA_STREAM 0x0606
-#define USB_AUDIO_TERMINAL_1394_DV_STREAM_SOUNDTRACK 0x0607
-#define USB_AUDIO_TERMINAL_EMBEDDED_UNDEFINED 0x0700
-#define USB_AUDIO_TERMINAL_LEVEL_CALIBRATION_NOISE_SOURCE 0x0701
-#define USB_AUDIO_TERMINAL_EQUALIZATION_NOISE 0x0702
-#define USB_AUDIO_TERMINAL_CD_PLAYER 0x0703
-#define USB_AUDIO_TERMINAL_DAT 0x0704
-#define USB_AUDIO_TERMINAL_DCC 0x0705
-#define USB_AUDIO_TERMINAL_MINI_DISK 0x0706
-#define USB_AUDIO_TERMINAL_ANALOG_TAPE 0x0707
-#define USB_AUDIO_TERMINAL_PHONOGRAPH 0x0708
-#define USB_AUDIO_TERMINAL_VCR_AUDIO 0x0709
-#define USB_AUDIO_TERMINAL_VIDEO_DISK_AUDIO 0x070A
-#define USB_AUDIO_TERMINAL_DVD_AUDIO 0x070B
-#define USB_AUDIO_TERMINAL_TV_TUNER_AUDIO 0x070C
-#define USB_AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
-#define USB_AUDIO_TERMINAL_CABLE_TUNER_AUDIO 0x070E
-#define USB_AUDIO_TERMINAL_DSS_AUDIO 0x070F
-#define USB_AUDIO_TERMINAL_RADIO_RECEIVER 0x0710
-#define USB_AUDIO_TERMINAL_RADIO_TRANSMITTER 0x0711
-#define USB_AUDIO_TERMINAL_MULTI_TRACK_RECORDER 0x0712
-#define USB_AUDIO_TERMINAL_SYNTHESIZER 0x0713
-
-////////////////////////////////////////////////////
-//
-// Audio streaming interface constants
-//
-////////////////////////////////////////////////////
-
-// Audio stream class-specific AS interface descriptor subtypes
-#define USB_AUDIO_AS_GENERAL 0x01
-#define USB_AUDIO_AS_FORMAT_TYPE 0x02
-#define USB_AUDIO_AS_FORMAT_SPECIFIC 0x03
-
-// wFormatTag values present in the class specific AS header
-// Defined in Section A.1 of USB Device Class Definition for Audio Data Formats
-#define USB_AUDIO_AS_FT_TYPE_I_UNDEFINED 0x0000
-#define USB_AUDIO_AS_FT_PCM 0x0001
-#define USB_AUDIO_AS_FT_PCM8 0x0002
-#define USB_AUDIO_AS_FT_IEEE_FLOAT 0x0003
-#define USB_AUDIO_AS_FT_ALAW 0x0004
-#define USB_AUDIO_AS_FT_MULAW 0x0005
-#define USB_AUDIO_AS_FT_TYPE_II_UNDEFINED 0x1000
-#define USB_AUDIO_AS_FT_MPEG 0x1001
-#define USB_AUDIO_AS_FT_AC3 0x1002
-#define USB_AUDIO_AS_FT_TYPE_III_UNDEFINED 0x2000
-#define USB_AUDIO_AS_FT_IEC1937_AC3 0x2001
-#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L1 0x2002
-#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L23 0x2003
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_EXT 0x2004
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L1_LS 0x2005
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L23_LS 0x2006
-
-// Audio stream class-specific format-specific types
-#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
-#define USB_AUDIO_FORMAT_TYPE_I 0x01
-#define USB_AUDIO_FORMAT_TYPE_II 0x02
-#define USB_AUDIO_FORMAT_TYPE_III 0x03
-
-////////////////////////////////////////////////////
-//
-// MIDI streaming interface constants
-//
-////////////////////////////////////////////////////
-
-// MIDI class specific MS interface descriptor subtypes
-#define USB_MIDI_MS_HEADER 0x01
-#define USB_MIDI_IN_JACK 0x02
-#define USB_MIDI_OUT_JACK 0x03
-#define USB_MIDI_ELEMENT 0x04
-
-// MIDI class specific MS endpoint descriptor subtypes
-#define USB_MIDI_MS_GENERAL 0x01
-
-// MIDI IN and OUT jack types
-#define USB_MIDI_JACK_EMBEDDED 0x01
-#define USB_MIDI_JACK_INTERNAL 0x02
-
-// MIDI endpoint control selectors
-#define USB_MIDI_ASSOCIATION_CONTROL 0x01
-
-
-// Top level header structure shared by all USB audio descriptors.
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype;
-} __PACKED usb_audio_desc_header;
-
-// Audio Control Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_HEADER
- uint16_t bcdADC;
- uint16_t wTotalLength;
- uint8_t bInCollection;
- uint8_t baInterfaceNr[];
-} __PACKED usb_audio_ac_header_desc;
-
-// Common header structure shared by all unit and terminal descriptors found in
-// an Audio Control interface descriptor.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_.*_(TERMINAL|UNIT)
- uint8_t bID;
-} __PACKED usb_audio_ac_ut_desc;
-
-// Common header structure shared by all terminal descriptors found in an Audio
-// Control interface descriptor.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_(INPUT|OUTPUT)_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
-} __PACKED usb_audio_ac_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_INPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t iTerminal;
-} __PACKED usb_audio_ac_input_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_OUTPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bSourceID;
- uint8_t iTerminal;
-} __PACKED usb_audio_ac_output_terminal_desc;
-
-// Note: Mixer unit descriptors contain two inlined variable length arrays, each
-// with descriptor data following them. They are therefor described using 3
-// structure definitions which are logically concatenated, but separated by the
-// inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_MIXER_UNIT
- uint8_t bUnitID;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_mixer_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_mixer_unit_desc_1;
-
-typedef struct {
- uint8_t iMixer;
-} __PACKED usb_audio_ac_mixer_unit_desc_2;
-
-// Note: Selector unit descriptors contain an inlined variable length array with
-// descriptor data following it. They are therefor described using 2 structure
-// definitions which are logically concatenated, but separated by the inline
-// array.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_SELECTOR_UNIT
- uint8_t bUnitID;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_selector_unit_desc_0;
-
-typedef struct {
- uint8_t iSelector;
-} __PACKED usb_audio_ac_selector_unit_desc_1;
-
-// Note: Feature unit descriptors contain an inlined variable length array with
-// descriptor data following it. They are therefor described using 2 structure
-// definitions which are logically concatenated, but separated by the inline
-// array.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_FEATURE_UNIT
- uint8_t bUnitID;
- uint8_t bSourceID;
- uint8_t bControlSize;
- uint8_t bmaControls[];
-} __PACKED usb_audio_ac_feature_unit_desc_0;
-
-typedef struct {
- uint8_t iFeature;
-} __PACKED usb_audio_ac_feature_unit_desc_1;
-
-// Note: Processing unit descriptors contain two inlined variable length arrays,
-// each with descriptor data following them. They are therefor described using
-// 3 structure definitions which are logically concatinated, but separated by
-// the inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_PROCESSING_UNIT
- uint8_t bUnitID;
- uint16_t wProcessType;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_processing_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bControlSize;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_processing_unit_desc_1;
-
-typedef struct {
- uint8_t iProcessing;
- // Note: The Process-specific control structure follows this with the
- // structure type determined by wProcessType
- // TODO(johngro) : Define the process specific control structures. As of
- // the 1.0 revision of the USB audio spec, the types to be defined are...
- //
- // ** Up/Down-mix
- // ** Dolby Prologic
- // ** 3D-Stereo Extender
- // ** Reverberation
- // ** Chorus
- // ** Dynamic Range Compressor
-} __PACKED usb_audio_ac_processing_unit_desc_2;
-
-// Note: Extension unit descriptors contain two inlined variable length arrays,
-// each with descriptor data following them. They are therefor described using
-// 3 structure definitions which are logically concatenated, but separated by
-// the inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_EXTENSION_UNIT
- uint8_t bUnitID;
- uint16_t wExtensionCode;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_extension_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bControlSize;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_extension_unit_desc_1;
-
-typedef struct {
- uint8_t iExtension;
-} __PACKED usb_audio_ac_extension_unit_desc_2;
-
-// Audio Streaming Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_GENERAL
- uint8_t bTerminalLink;
- uint8_t bDelay;
- uint16_t wFormatTag;
-} __PACKED usb_audio_as_header_desc;
-
-typedef struct {
- uint8_t freq[3]; // 24 bit unsigned integer, little-endian
-} __PACKED usb_audio_as_samp_freq;
-
-// Common header used by all format type descriptors
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
- uint8_t bFormatType;
-} __PACKED usb_audio_as_format_type_hdr;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
- uint8_t bFormatType; // USB_AUDIO_FORMAT_TYPE_I
- uint8_t bNrChannels;
- uint8_t bSubFrameSize;
- uint8_t bBitResolution;
- uint8_t bSamFreqType; // number of sampling frequencies
- usb_audio_as_samp_freq tSamFreq[]; // list of sampling frequencies (3 bytes each)
-} __PACKED usb_audio_as_format_type_i_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_AUDIO_EP_GENERAL
- uint8_t bmAttributes;
- uint8_t bLockDelayUnits;
- uint16_t wLockDelay;
-} __PACKED usb_audio_as_isoch_ep_desc;
-
-// MIDI Streaming Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_MS_HEADER
- uint16_t bcdMSC;
- uint16_t wTotalLength;
-} __PACKED usb_midi_ms_header_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_IN_JACK
- uint8_t bJackType;
- uint8_t bJackID;
- uint8_t iJack;
-} __PACKED usb_midi_ms_in_jack_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_OUT_JACK
- uint8_t bJackType;
- uint8_t bJackID;
- uint8_t bNrInputPins;
- uint8_t baSourceID;
- uint8_t baSourcePin;
-} __PACKED usb_midi_ms_out_jack_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_MIDI_MS_GENERAL
- uint8_t bNumEmbMIDIJack;
- uint8_t baAssocJackID[];
-} __PACKED usb_midi_ms_endpoint_desc;
-
-__END_CDECLS;
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-cdc.h b/arch/arm64/sysroot/include/zircon/hw/usb-cdc.h
deleted file mode 100644
index f64a422..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-cdc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-
-/* CDC Subclasses for the Communications Interface Class */
-#define USB_CDC_SUBCLASS_DIRECT_LINE 0x01
-#define USB_CDC_SUBCLASS_ABSTRACT 0x02
-#define USB_CDC_SUBCLASS_TELEPHONE 0x03
-#define USB_CDC_SUBCLASS_MULTI_CHANNEL 0x04
-#define USB_CDC_SUBCLASS_CAPI 0x05
-#define USB_CDC_SUBCLASS_ETHERNET 0x06
-#define USB_CDC_SUBCLASS_ATM 0x07
-#define USB_CDC_SUBCLASS_WIRELESS_HANDSET 0x08
-#define USB_CDC_SUBCLASS_DEVICE_MGMT 0x09
-#define USB_CDC_SUBCLASS_MOBILE_DIRECT 0x0A
-#define USB_CDC_SUBCLASS_OBEX 0x0B
-#define USB_CDC_SUBCLASS_ETHERNET_EMU 0x0C
-#define USB_CDC_SUBCLASS_NETWORK_CTRL 0x0D
-
-/* CDC Descriptor SubTypes */
-#define USB_CDC_DST_HEADER 0x00
-#define USB_CDC_DST_CALL_MGMT 0x01
-#define USB_CDC_DST_ABSTRACT_CTRL_MGMT 0x02
-#define USB_CDC_DST_DIRECT_LINE_MGMT 0x03
-#define USB_CDC_DST_TELEPHONE_RINGER 0x04
-#define USB_CDC_DST_TELEPHONE_CALL_REPORTING 0x05
-#define USB_CDC_DST_UNION 0x06
-#define USB_CDC_DST_COUNTRY_SELECTION 0x07
-#define USB_CDC_DST_TELEPHONE_OP_MODES 0x08
-#define USB_CDC_DST_USB_TERMINAL 0x09
-#define USB_CDC_DST_NETWORK_CHANNEL 0x0A
-#define USB_CDC_DST_PROTOCOL_UNIT 0x0B
-#define USB_CDC_DST_EXTENSION_UNIT 0x0C
-#define USB_CDC_DST_MULTI_CHANNEL_MGMT 0x0D
-#define USB_CDC_DST_CAPI_CTRL_MGMT 0x0E
-#define USB_CDC_DST_ETHERNET 0x0F
-#define USB_CDC_DST_ATM_NETWORKING 0x10
-#define USB_CDC_DST_WIRELESS_HANDSET_CTRL 0x11
-#define USB_CDC_DST_MOBILE_DIRECT_LINE 0x12
-#define USB_CDC_DST_MDLM_DETAIL 0x13
-#define USB_CDC_DST_DEVICE_MGMT 0x14
-#define USB_CDC_DST_OBEX 0x15
-#define USB_CDC_DST_COMMAND_SET 0x16
-#define USB_CDC_DST_COMMAND_SET_DETAIL 0x17
-#define USB_CDC_DST_TELEPHONE_CTRL 0x18
-#define USB_CDC_DST_OBEX_SERVICE_ID 0x19
-#define USB_CDC_DST_NCM 0x1A
-
-/* CDC Class-Specific Notification Codes */
-#define USB_CDC_NC_NETWORK_CONNECTION 0x00
-#define USB_CDC_NC_RESPONSE_AVAILABLE 0x01
-#define USB_CDC_NC_SERIAL_STATE 0x20
-#define USB_CDC_NC_CONNECTION_SPEED_CHANGE 0x2A
-
-/* CDC Ethernet Class-Specific Request Codes */
-#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
-#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
-#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
-#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
-#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
-
-/* CDC Class-Specific Requests */
-#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
-#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
-
-__BEGIN_CDECLS;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_HEADER
- uint16_t bcdCDC;
-} __attribute__ ((packed)) usb_cs_header_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_CALL_MGMT
- uint8_t bmCapabilities;
- uint8_t bDataInterface;
-} __attribute__ ((packed)) usb_cs_call_mgmt_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_ABSTRACT_CTRL_MGMT
- uint8_t bmCapabilities;
-} __attribute__ ((packed)) usb_cs_abstract_ctrl_mgmt_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
- uint8_t bControlInterface;
- uint8_t bSubordinateInterface[];
-} __attribute__ ((packed)) usb_cs_union_interface_descriptor_t;
-
-// fixed size version of usb_cs_union_interface_descriptor_t
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
- uint8_t bControlInterface;
- uint8_t bSubordinateInterface;
-} __attribute__ ((packed)) usb_cs_union_interface_descriptor_1_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_ETHERNET
- uint8_t iMACAddress;
- uint32_t bmEthernetStatistics;
- uint16_t wMaxSegmentSize;
- uint16_t wNumberMCFilters;
- uint8_t bNumberPowerFilters;
-} __attribute__ ((packed)) usb_cs_ethernet_interface_descriptor_t;
-
-typedef struct {
- uint8_t bmRequestType;
- uint8_t bNotification;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-} __attribute__ ((packed)) usb_cdc_notification_t;
-
-typedef struct {
- usb_cdc_notification_t notification;
- uint32_t downlink_br;
- uint32_t uplink_br;
- } __attribute__ ((packed)) usb_cdc_speed_change_notification_t;
-
-__END_CDECLS;
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-hid.h b/arch/arm64/sysroot/include/zircon/hw/usb-hid.h
deleted file mode 100644
index d8be878..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-hid.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-__BEGIN_CDECLS;
-
-/* HID Request Values */
-#define USB_HID_GET_REPORT 0x01
-#define USB_HID_GET_IDLE 0x02
-#define USB_HID_GET_PROTOCOL 0x03
-#define USB_HID_SET_REPORT 0x09
-#define USB_HID_SET_IDLE 0x0A
-#define USB_HID_SET_PROTOCOL 0x0B
-
-typedef struct {
- uint8_t bDescriptorType;
- uint16_t wDescriptorLength;
-} __attribute__((packed)) usb_hid_descriptor_entry_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdHID;
- uint8_t bCountryCode;
- uint8_t bNumDescriptors;
- usb_hid_descriptor_entry_t descriptors[];
-} __attribute__((packed)) usb_hid_descriptor_t;
-
-__END_CDECLS;
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-hub.h b/arch/arm64/sysroot/include/zircon/hw/usb-hub.h
deleted file mode 100644
index 2a8b395..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-hub.h
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-__BEGIN_CDECLS;
-
-// Hub request types
-#define USB_RECIP_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
-#define USB_RECIP_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
-
-// Hub requests
-#define USB_HUB_SET_DEPTH 12
-
-// Hub descriptor types
-#define USB_HUB_DESC_TYPE 0x29
-#define USB_HUB_DESC_TYPE_SS 0x2A // for superspeed hubs
-
-// Hub Class Feature Selectors (USB 2.0 spec Table 11.17)
-#define USB_FEATURE_C_HUB_LOCAL_POWER 0
-#define USB_FEATURE_C_HUB_OVER_CURRENT 1
-#define USB_FEATURE_PORT_CONNECTION 0
-#define USB_FEATURE_PORT_ENABLE 1
-#define USB_FEATURE_PORT_SUSPEND 2
-#define USB_FEATURE_PORT_OVER_CURRENT 3
-#define USB_FEATURE_PORT_RESET 4
-#define USB_FEATURE_PORT_LINK_STATE 5
-#define USB_FEATURE_PORT_POWER 8
-#define USB_FEATURE_PORT_LOW_SPEED 9
-#define USB_FEATURE_C_PORT_CONNECTION 16
-#define USB_FEATURE_C_PORT_ENABLE 17
-#define USB_FEATURE_C_PORT_SUSPEND 18
-#define USB_FEATURE_C_PORT_OVER_CURRENT 19
-#define USB_FEATURE_C_PORT_RESET 20
-#define USB_FEATURE_PORT_TEST 21
-#define USB_FEATURE_PORT_INDICATOR 22
-#define USB_FEATURE_PORT_INDICATOR 22
-#define USB_FEATURE_PORT_U1_TIMEOUT 23
-#define USB_FEATURE_PORT_U2_TIMEOUT 24
-#define USB_FEATURE_C_PORT_LINK_STATE 25
-#define USB_FEATURE_C_PORT_CONFIG_ERROR 26
-#define USB_FEATURE_PORT_REMOTE_WAKE_MASK 27
-#define USB_FEATURE_BH_PORT_RESET 28
-#define USB_FEATURE_C_BH_PORT_RESET 29
-#define USB_FEATURE_FORCE_LINKPM_ACCEPT 30
-
-typedef struct {
- uint8_t bDescLength;
- uint8_t bDescriptorType;
- uint8_t bNbrPorts;
- uint16_t wHubCharacteristics;
- uint8_t bPowerOn2PwrGood;
- uint8_t bHubContrCurrent;
- union {
- // USB 2.0
- struct {
- // variable length depending on number of ports
- uint8_t DeviceRemovable[4];
- uint8_t PortPwrCtrlMask[4];
- } __attribute__ ((packed)) hs;
- // USB 3.0
- struct {
- uint8_t bHubHdrDecLat;
- uint16_t wHubDelay;
- uint16_t DeviceRemovable;
- } __attribute__ ((packed)) ss;
- } __attribute__ ((packed));
-} __attribute__ ((packed)) usb_hub_descriptor_t;
-
-typedef struct {
- uint16_t wHubStatus;
- uint16_t wHubChange;
-} __attribute__ ((packed)) usb_hub_status_t;
-
-// wHubStatus bits
-#define USB_HUB_LOCAL_POWER (1 << 0)
-#define USB_HUB_OVER_CURRENT (1 << 1)
-
-typedef struct {
- uint16_t wPortStatus;
- uint16_t wPortChange;
-} __attribute__ ((packed)) usb_port_status_t;
-
-// Port Status bits
-#define USB_PORT_CONNECTION (1 << 0)
-#define USB_PORT_ENABLE (1 << 1)
-#define USB_PORT_SUSPEND (1 << 2) // USB 2.0 only
-#define USB_PORT_OVER_CURRENT (1 << 3)
-#define USB_PORT_RESET (1 << 4)
-#define USB_PORT_POWER (1 << 8) // USB 2.0 only
-#define USB_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
-#define USB_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
-#define USB_PORT_TEST_MODE (1 << 11) // USB 2.0 only
-#define USB_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
-
-// Port Status Changed bits
-#define USB_C_PORT_CONNECTION (1 << 0)
-#define USB_C_PORT_ENABLE (1 << 1) // USB 2.0 only
-#define USB_C_PORT_SUSPEND (1 << 2) // USB 2.0 only
-#define USB_C_PORT_OVER_CURRENT (1 << 3)
-#define USB_C_PORT_RESET (1 << 4)
-#define USB_C_BH_PORT_RESET (1 << 5) // USB 3.0 only
-#define USB_C_PORT_LINK_STATE (1 << 6) // USB 3.0 only
-#define USB_C_PORT_CONFIG_ERROR (1 << 7) // USB 3.0 only
-#define USB_C_PORT_POWER (1 << 8) // USB 2.0 only
-#define USB_C_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
-#define USB_C_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
-#define USB_C_PORT_TEST_MODE (1 << 11) // USB 2.0 only
-#define USB_C_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
-
-__END_CDECLS;
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-mass-storage.h b/arch/arm64/sysroot/include/zircon/hw/usb-mass-storage.h
deleted file mode 100644
index f2d1d80..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-mass-storage.h
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-// SCSI commands
-#define UMS_TEST_UNIT_READY 0x00
-#define UMS_REQUEST_SENSE 0x03
-#define UMS_INQUIRY 0x12
-#define UMS_MODE_SELECT6 0x15
-#define UMS_MODE_SENSE6 0x1A
-#define UMS_START_STOP_UNIT 0x1B
-#define UMS_TOGGLE_REMOVABLE 0x1E
-#define UMS_READ_FORMAT_CAPACITIES 0x23
-#define UMS_READ_CAPACITY10 0x25
-#define UMS_READ10 0x28
-#define UMS_WRITE10 0x2A
-#define UMS_SYNCHRONIZE_CACHE 0x35
-#define UMS_MODE_SELECT10 0x55
-#define UMS_MODE_SENSE10 0x5A
-#define UMS_READ16 0x88
-#define UMS_WRITE16 0x8A
-#define UMS_READ_CAPACITY16 0x9E
-#define UMS_READ12 0xA8
-#define UMS_WRITE12 0xAA
-
-// control request values
-#define USB_REQ_RESET 0xFF
-#define USB_REQ_GET_MAX_LUN 0xFE
-
-// error codes for CSW processing
-typedef uint32_t csw_status_t;
-#define CSW_SUCCESS ((csw_status_t)0)
-#define CSW_FAILED ((csw_status_t)1)
-#define CSW_PHASE_ERROR ((csw_status_t)2)
-#define CSW_INVALID ((csw_status_t)3)
-#define CSW_TAG_MISMATCH ((csw_status_t)4)
-
-// signatures in header and status
-#define CBW_SIGNATURE 0x43425355
-#define CSW_SIGNATURE 0x53425355
-
-// transfer lengths
-#define UMS_INQUIRY_TRANSFER_LENGTH 0x24
-#define UMS_REQUEST_SENSE_TRANSFER_LENGTH 0x12
-#define UMS_READ_FORMAT_CAPACITIES_TRANSFER_LENGTH 0xFC
-
-// 6 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint16_t lba; // logical block address
- uint8_t length;
- uint8_t control;
-} __PACKED scsi_command6_t;
-static_assert(sizeof(scsi_command6_t) == 6, "");
-
-// 10 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint32_t lba; // logical block address
- uint8_t misc2;
- uint8_t length_hi; // break length into two pieces to avoid odd alignment
- uint8_t length_lo;
- uint8_t control;
-} __PACKED scsi_command10_t;
-static_assert(sizeof(scsi_command10_t) == 10, "");
-
-// 12 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint32_t lba; // logical block address
- uint32_t length;
- uint8_t misc2;
- uint8_t control;
-} __PACKED scsi_command12_t;
-static_assert(sizeof(scsi_command12_t) == 12, "");
-
-// 16 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint64_t lba; // logical block address
- uint32_t length;
- uint8_t misc2;
- uint8_t control;
-} __PACKED scsi_command16_t;
-static_assert(sizeof(scsi_command16_t) == 16, "");
-
-// SCSI Read Capacity 10 payload
-// This is big endian
-typedef struct {
- uint32_t lba;
- uint32_t block_length;
-} __PACKED scsi_read_capacity_10_t;
-static_assert(sizeof(scsi_read_capacity_10_t) == 8, "");
-
-// SCSI Read Capacity 16 payload
-// This is big endian
-typedef struct {
- uint64_t lba;
- uint32_t block_length;
- uint8_t ptype_prot_en; // bit 0: PROT_EN, bits 1-3: P_TYPE
- uint8_t resesrved[19];
-} __PACKED scsi_read_capacity_16_t;
-static_assert(sizeof(scsi_read_capacity_16_t) == 32, "");
-
-// SCSI Mode Sense 6 command
-typedef struct {
- uint8_t opcode; // UMS_MODE_SENSE6
- uint8_t disable_block_desc;
- uint8_t page;
- uint8_t subpage;
- uint8_t allocation_length;
- uint8_t control;
-} __PACKED scsi_mode_sense_6_command_t;
-static_assert(sizeof(scsi_mode_sense_6_command_t) == 6, "");
-
-// SCSI Mode Sense 6 data response
-typedef struct {
- uint8_t mode_data_length;
- uint8_t medium_type;
- uint8_t device_specific_param;
- uint8_t block_desc_length;
-} __PACKED scsi_mode_sense_6_data_t;
-#define MODE_SENSE_DSP_RO 0x80 // bit 7 of device_specific_param: read-only
-
-// Command Block Wrapper
-typedef struct {
- uint32_t dCBWSignature; // CBW_SIGNATURE
- uint32_t dCBWTag;
- uint32_t dCBWDataTransferLength;
- uint8_t bmCBWFlags;
- uint8_t bCBWLUN;
- uint8_t bCBWCBLength;
- uint8_t CBWCB[16];
-} __PACKED ums_cbw_t;
-static_assert(sizeof(ums_cbw_t) == 31, "");
-
-// Command Status Wrapper
-typedef struct {
- uint32_t dCSWSignature; // CSW_SIGNATURE
- uint32_t dCSWTag;
- uint32_t dCSWDataResidue;
- uint8_t bmCSWStatus;
-} __PACKED ums_csw_t;
-static_assert(sizeof(ums_csw_t) == 13, "");
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb-video.h b/arch/arm64/sysroot/include/zircon/hw/usb-video.h
deleted file mode 100644
index 1ff6e22..0000000
--- a/arch/arm64/sysroot/include/zircon/hw/usb-video.h
+++ /dev/null
@@ -1,304 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-
-__BEGIN_CDECLS;
-
-// video interface subclasses
-#define USB_SUBCLASS_VIDEO_CONTROL 0x01
-#define USB_SUBCLASS_VIDEO_STREAMING 0x02
-#define USB_SUBCLASS_VIDEO_INTERFACE_COLLECTION 0x03
-
-// video class specific descriptor types
-#define USB_VIDEO_CS_DEVICE 0x21
-#define USB_VIDEO_CS_CONFIGURATION 0x22
-#define USB_VIDEO_CS_STRING 0x23
-#define USB_VIDEO_CS_INTERFACE 0x24
-#define USB_VIDEO_CS_ENDPOINT 0x25
-
-// video class specific VC interface descriptor subtypes
-#define USB_VIDEO_VC_HEADER 0x01
-#define USB_VIDEO_VC_INPUT_TERMINAL 0x02
-#define USB_VIDEO_VC_OUTPUT_TERMINAL 0x03
-#define USB_VIDEO_VC_SELECTOR_UNIT 0x04
-#define USB_VIDEO_VC_PROCESSING_UNIT 0x05
-#define USB_VIDEO_VC_EXTENSION_UNIT 0x06
-#define USB_VIDEO_VC_ENCODING_UNIT 0x07
-
-// video class specific VS interface descriptor subtypes
-#define USB_VIDEO_VS_INPUT_HEADER 0x01
-#define USB_VIDEO_VS_OUTPUT_HEADER 0x02
-#define USB_VIDEO_VS_STILL_IMAGE_FRAME 0x03
-#define USB_VIDEO_VS_FORMAT_UNCOMPRESSED 0x04
-#define USB_VIDEO_VS_FRAME_UNCOMPRESSED 0x05
-#define USB_VIDEO_VS_FORMAT_MJPEG 0x06
-#define USB_VIDEO_VS_FRAME_MJPEG 0x07
-#define USB_VIDEO_VS_FORMAT_MPEG2TS 0x0A
-#define USB_VIDEO_VS_FORMAT_DV 0x0C
-#define USB_VIDEO_VS_COLORFORMAT 0x0D
-#define USB_VIDEO_VS_FORMAT_FRAME_BASED 0x10
-#define USB_VIDEO_VS_FRAME_FRAME_BASED 0x11
-#define USB_VIDEO_VS_FORMAT_STREAM_BASED 0x12
-#define USB_VIDEO_VS_FORMAT_H264 0x13
-#define USB_VIDEO_VS_FRAME_H264 0x14
-#define USB_VIDEO_VS_FORMAT_H264_SIMULCAST 0x15
-#define USB_VIDEO_VS_FORMAT_VP8 0x16
-#define USB_VIDEO_VS_FRAME_VP8 0x17
-#define USB_VIDEO_VS_FORMAT_VP8_SIMULCAST 0x18
-
-// video class specific endpoint descriptor subtypes
-#define USB_VIDEO_EP_GENERAL 0x01
-#define USB_VIDEO_EP_ENDPOINT 0x02
-#define USB_VIDEO_EP_INTERRUPT 0x03
-
-// video class specific request codes
-#define USB_VIDEO_SET_CUR 0x01
-#define USB_VIDEO_SET_CUR_ALL 0x11
-#define USB_VIDEO_GET_CUR 0x81
-#define USB_VIDEO_GET_MIN 0x82
-#define USB_VIDEO_GET_MAX 0x83
-#define USB_VIDEO_GET_RES 0x84
-#define USB_VIDEO_GET_LEN 0x85
-#define USB_VIDEO_GET_INFO 0x86
-#define USB_VIDEO_GET_DEF 0x87
-#define USB_VIDEO_GET_CUR_ALL 0x91
-#define USB_VIDEO_GET_MIN_ALL 0x92
-#define USB_VIDEO_GET_MAX_ALL 0x93
-#define USB_VIDEO_GET_RES_ALL 0x94
-#define USB_VIDEO_GET_DEF_ALL 0x97
-
-// video streaming interface control selectors
-#define USB_VIDEO_VS_PROBE_CONTROL 0x01
-#define USB_VIDEO_VS_COMMIT_CONTROL 0x02
-#define USB_VIDEO_VS_STILL_PROBE_CONTROL 0x03
-#define USB_VIDEO_VS_STILL_COMMIT_CONTROL 0x04
-#define USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
-#define USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL 0x06
-#define USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL 0x07
-#define USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
-#define USB_VIDEO_VS_SYNCH_DELAY_CONTROL 0x09
-
-// header for usb_video_vc_* below
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype;
-} __PACKED usb_video_vc_desc_header;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_HEADER
- uint16_t bcdUVC;
- uint16_t wTotalLength;
- uint32_t dwClockFrequency;
- uint8_t bInCollection;
- uint8_t baInterfaceNr[];
-} __PACKED usb_video_vc_header_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_INPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t iTerminal;
-} __PACKED usb_video_vc_input_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bSourceID;
- uint8_t iTerminal;
-} __PACKED usb_video_vc_output_terminal_desc;
-
-// class specific VC interrupt endpoint descriptor
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_ENDPOINT_INTERRUPT
- uint16_t wMaxTransferSize;
-} __PACKED usb_video_vc_interrupt_endpoint_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VS_HEADER
- uint8_t bNumFormats;
- uint16_t wTotalLength;
- uint8_t bEndpointAddress;
- uint8_t bmInfo;
- uint8_t bTerminalLink;
- uint8_t bStillCaptureMethod;
- uint8_t bTriggerSupport;
- uint8_t bTriggerUsage;
- uint8_t bControlSize;
- uint8_t bmaControls[];
-} __PACKED usb_video_vs_input_header_desc;
-
-#define GUID_LENGTH 16
-
-// A GUID consists of a:
-// - four-byte integer
-// - two-byte integer
-// - two-byte integer
-// - eight-byte array
-//
-// The string representation uses big endian format, so to convert it
-// to a byte array we need to reverse the byte order of the three integers.
-//
-// See USB Video Class revision 1.5, FAQ section 2.9
-// for GUID Data Structure Layout.
-
-#define USB_VIDEO_GUID_YUY2_STRING "32595559-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_YUY2_VALUE { \
- 0x59, 0x55, 0x59, 0x32, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_NV12_STRING "3231564E-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_NV12_VALUE { \
- 0x4e, 0x56, 0x31, 0x32, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_M420_STRING "3032344D-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_M420_VALUE { \
- 0x4d, 0x34, 0x32, 0x30, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_I420_STRING "30323449-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_I420_VALUE { \
- 0x49, 0x34, 0x32, 0x30, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-// USB Video Payload Uncompressed
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_UNCOMPRESSED
- uint8_t bFormatIndex;
- uint8_t bNumFrameDescriptors;
- uint8_t guidFormat[GUID_LENGTH];
- uint8_t bBitsPerPixel;
- uint8_t bDefaultFrameIndex;
- uint8_t bAspectRatioX;
- uint8_t bAspectRatioY;
- uint8_t bmInterfaceFlags;
- uint8_t bCopyProtect;
-} __PACKED usb_video_vs_uncompressed_format_desc;
-
-// USB Video Payload MJPEG
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_MJPEG
- uint8_t bFormatIndex;
- uint8_t bNumFrameDescriptors;
- uint8_t bmFlags;
- uint8_t bDefaultFrameIndex;
- uint8_t bAspectRatioX;
- uint8_t bAspectRatioY;
- uint8_t bmInterfaceFlags;
- uint8_t bCopyProtect;
-} __PACKED usb_video_vs_mjpeg_format_desc;
-
-// Uncompressed and MJPEG formats have the same frame descriptor structure.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FRAME_UNCOMPRESSED / USB_VIDEO_VS_FRAME_MJPEG
- uint8_t bFrameIndex;
- uint8_t bmCapabilities;
- uint16_t wWidth;
- uint16_t wHeight;
- uint32_t dwMinBitRate;
- uint32_t dwMaxBitRate;
- uint32_t dwMaxVideoFrameBufferSize;
- uint32_t dwDefaultFrameInterval;
- uint8_t bFrameIntervalType;
- uint32_t dwFrameInterval[];
-} __PACKED usb_video_vs_frame_desc;
-
-// Stream negotiation
-#define USB_VIDEO_BM_HINT_FRAME_INTERVAL (1 << 0)
-#define USB_VIDEO_BM_HINT_KEY_FRAME_RATE (1 << 1)
-#define USB_VIDEO_BM_HINT_P_FRAME_RATE (1 << 2)
-#define USB_VIDEO_BM_HINT_COMP_QUALITY (1 << 3)
-#define USB_VIDEO_BM_HINT_COMP_WINDOW_SIZE (1 << 4)
-
-typedef struct {
- uint16_t bmHint;
- uint8_t bFormatIndex;
- uint8_t bFrameIndex;
- uint32_t dwFrameInterval;
- uint16_t wKeyFrameRate;
- uint16_t wPFrameRate;
- uint16_t wCompQuality;
- uint16_t wCompWindowSize;
- uint16_t wDelay;
- uint32_t dwMaxVideoFrameSize;
- uint32_t dwMaxPayloadTransferSize;
- // The following fields are optional.
- uint32_t dwClockFrequency;
- uint8_t bmFramingInfo;
- uint8_t bPreferedVersion;
- uint8_t bMinVersion;
- uint8_t bMaxVersion;
- uint8_t bUsage;
- uint8_t bBitDepthLuma;
- uint8_t bmSettings;
- uint8_t bMaxNumberOfRefFramesPlus1;
- uint16_t bmRateControlModes;
- uint32_t bmLayoutPerStream;
-} __PACKED usb_video_vc_probe_and_commit_controls;
-
-// For accessing payload bmHeaderInfo bitmap
-#define USB_VIDEO_VS_PAYLOAD_HEADER_FID (1 << 0)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_EOF (1 << 1)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_PTS (1 << 2)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_SCR (1 << 3)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_RES (1 << 4)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_STI (1 << 5)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_ERR (1 << 6)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_EOH (1 << 7)
-
-// Common header for all payloads.
-typedef struct {
- uint8_t bHeaderLength;
- uint8_t bmHeaderInfo;
-
-} __PACKED usb_video_vs_payload_header;
-
-typedef struct {
- uint8_t bHeaderLength;
- uint8_t bmHeaderInfo;
- uint32_t dwPresentationTime;
- uint32_t scrSourceTimeClock;
- // Frame number when the source clock was sampled.
- uint16_t scrSourceClockSOFCounter;
-} __PACKED usb_video_vs_uncompressed_payload_header;
-
-__END_CDECLS;
-
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb.h b/arch/arm64/sysroot/include/zircon/hw/usb.h
index 697f7f0..c62e948 100644
--- a/arch/arm64/sysroot/include/zircon/hw/usb.h
+++ b/arch/arm64/sysroot/include/zircon/hw/usb.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_USB_H_
+#define SYSROOT_ZIRCON_HW_USB_H_
// clang-format off
@@ -10,7 +11,7 @@
#include <stdint.h>
#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// maximum number of endpoints per device
#define USB_MAX_EPS 32
@@ -59,11 +60,28 @@
#define USB_CLASS_DIAGNOSTIC 0xdc
#define USB_CLASS_WIRELESS 0xe0
#define USB_CLASS_MISC 0xef
+#define USB_CLASS_APPLICATION_SPECIFIC 0xfe
#define USB_CLASS_VENDOR 0xFf
+#define USB_SUBCLASS_COMM_ACM 0x02
+
+#define USB_SUBCLASS_WIRELESS_MISC 0x01
+#define USB_PROTOCOL_WIRELESS_MISC_RNDIS 0x03
+
+#define USB_SUBCLASS_MSC_RNDIS 0x04
+#define USB_PROTOCOL_MSC_RNDIS_ETHERNET 0x01
+
#define USB_SUBCLASS_MSC_SCSI 0x06
#define USB_PROTOCOL_MSC_BULK_ONLY 0x50
+#define USB_SUBCLASS_DFU 0x01
+#define USB_PROTOCOL_DFU 0x02
+
+#define USB_SUBCLASS_VENDOR 0xFF
+#define USB_PROTOCOL_TEST_FTDI 0x01
+#define USB_PROTOCOL_TEST_HID_ONE_ENDPOINT 0x02
+#define USB_PROTOCOL_TEST_HID_TWO_ENDPOINT 0x03
+
/* Descriptor Types */
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
@@ -196,6 +214,9 @@
uint16_t wMaxPacketSize;
uint8_t bInterval;
} __attribute__ ((packed)) usb_endpoint_descriptor_t;
+#define usb_ep_num(ep) ((ep)->bEndpointAddress & USB_ENDPOINT_NUM_MASK)
+// usb_ep_num2() useful with you have bEndpointAddress outside of a descriptor.
+#define usb_ep_num2(addr) ((addr) & USB_ENDPOINT_NUM_MASK)
#define usb_ep_direction(ep) ((ep)->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
#define usb_ep_type(ep) ((ep)->bmAttributes & USB_ENDPOINT_TYPE_MASK)
#define usb_ep_sync_type(ep) ((ep)->bmAttributes & USB_ENDPOINT_SYNCHRONIZATION_MASK)
@@ -207,6 +228,18 @@
typedef struct {
uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_DEVICE_QUALIFIER
+ uint16_t bcdUSB;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bMaxPacketSize0;
+ uint8_t bNumConfigurations;
+ uint8_t bReserved;
+} __attribute__ ((packed)) usb_device_qualifier_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
uint8_t bDescriptorType; // USB_DT_SS_EP_COMPANION
uint8_t bMaxBurst;
uint8_t bmAttributes;
@@ -239,4 +272,18 @@
uint8_t bDescriptorSubType;
} __attribute__ ((packed)) usb_cs_interface_descriptor_t;
-__END_CDECLS;
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_STRING
+ uint16_t wLangIds[127];
+} __attribute__ ((packed)) usb_langid_desc_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_STRING
+ uint16_t code_points[127];
+} __attribute__ ((packed)) usb_string_desc_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/audio.h b/arch/arm64/sysroot/include/zircon/hw/usb/audio.h
new file mode 100644
index 0000000..4e68f87
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/audio.h
@@ -0,0 +1,527 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_AUDIO_H_
+#define SYSROOT_ZIRCON_HW_USB_AUDIO_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+////////////////////////////////////////////////////
+//
+// General Audio interface constants
+//
+////////////////////////////////////////////////////
+
+// audio interface subclasses
+#define USB_SUBCLASS_AUDIO_CONTROL 0x01
+#define USB_SUBCLASS_AUDIO_STREAMING 0x02
+#define USB_SUBCLASS_MIDI_STREAMING 0x03
+
+// audio class specific descriptor types
+#define USB_AUDIO_CS_DEVICE 0x21
+#define USB_AUDIO_CS_CONFIGURATION 0x22
+#define USB_AUDIO_CS_STRING 0x23
+#define USB_AUDIO_CS_INTERFACE 0x24
+#define USB_AUDIO_CS_ENDPOINT 0x25
+
+////////////////////////////////////////////////////
+//
+// Audio Control interface constants
+//
+////////////////////////////////////////////////////
+
+// audio class specific AC interface descriptor subtypes
+#define USB_AUDIO_AC_HEADER 0x01
+#define USB_AUDIO_AC_INPUT_TERMINAL 0x02
+#define USB_AUDIO_AC_OUTPUT_TERMINAL 0x03
+#define USB_AUDIO_AC_MIXER_UNIT 0x04
+#define USB_AUDIO_AC_SELECTOR_UNIT 0x05
+#define USB_AUDIO_AC_FEATURE_UNIT 0x06
+#define USB_AUDIO_AC_PROCESSING_UNIT 0x07
+#define USB_AUDIO_AC_EXTENSION_UNIT 0x08
+
+// processing unit process types
+#define USB_AUDIO_UP_DOWN_MIX_PROCESS 0x01
+#define USB_AUDIO_DOLBY_PROLOGIC_PROCESS 0x02
+#define USB_AUDIO_3D_STEREO_EXTENDER_PROCESS 0x03
+#define USB_AUDIO_REVERBERATION_PROCESS 0x04
+#define USB_AUDIO_CHORUS_PROCESS 0x05
+#define USB_AUDIO_DYN_RANGE_COMP_PROCESS 0x06
+
+// audio class specific endpoint descriptor subtypes
+#define USB_AUDIO_EP_GENERAL 0x01
+
+// audio class specific request codes
+#define USB_AUDIO_SET_CUR 0x01
+#define USB_AUDIO_GET_CUR 0x81
+#define USB_AUDIO_SET_MIN 0x02
+#define USB_AUDIO_GET_MIN 0x82
+#define USB_AUDIO_SET_MAX 0x03
+#define USB_AUDIO_GET_MAX 0x83
+#define USB_AUDIO_SET_RES 0x04
+#define USB_AUDIO_GET_RES 0x84
+#define USB_AUDIO_SET_MEM 0x05
+#define USB_AUDIO_GET_MEM 0x85
+#define USB_AUDIO_GET_STAT 0xFF
+
+// terminal control selectors
+#define USB_AUDIO_COPY_PROTECT_CONTROL 0x01
+
+// feature unit control selectors
+#define USB_AUDIO_MUTE_CONTROL 0x01
+#define USB_AUDIO_VOLUME_CONTROL 0x02
+#define USB_AUDIO_BASS_CONTROL 0x03
+#define USB_AUDIO_MID_CONTROL 0x04
+#define USB_AUDIO_TREBLE_CONTROL 0x05
+#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
+#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
+#define USB_AUDIO_DELAY_CONTROL 0x08
+#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
+#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
+
+// feature unit control support bitmasks
+#define USB_AUDIO_FU_BMA_MUTE (1u << 0u)
+#define USB_AUDIO_FU_BMA_VOLUME (1u << 1u)
+#define USB_AUDIO_FU_BMA_BASS (1u << 2u)
+#define USB_AUDIO_FU_BMA_MID (1u << 3u)
+#define USB_AUDIO_FU_BMA_TREBLE (1u << 4u)
+#define USB_AUDIO_FU_BMA_GRAPHIC_EQUALIZER (1u << 5u)
+#define USB_AUDIO_FU_BMA_AUTOMATIC_GAIN (1u << 6u)
+#define USB_AUDIO_FU_BMA_DELAY (1u << 7u)
+#define USB_AUDIO_FU_BMA_BASS_BOOST (1u << 8u)
+#define USB_AUDIO_FU_BMA_LOUDNESS (1u << 9u)
+
+// up/down mix processing unit control selectors
+#define USB_AUDIO_UD_ENABLE_CONTROL 0x01
+#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
+#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
+
+// Dolby Prologic processing unit control selectors
+#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
+#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
+
+// 3D stereo extender processing unit control selectors
+#define USB_AUDIO_3D_ENABLE_CONTROL 0x01
+#define USB_AUDIO_SPACIOUSNESS_CONTROL 0x03
+
+// reverberation processing unit control selectors
+#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
+#define USB_AUDIO_REVERB_LEVEL_CONTROL 0x02
+#define USB_AUDIO_REVERB_TIME_CONTROL 0x03
+#define USB_AUDIO_REVERB_FEEDBACK_CONTROL 0x04
+
+// chorus processing unit control selectors
+#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
+#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
+#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
+#define USB_AUDIO_CHORUS_DEPTH_CONTROL 0x04
+
+// dynamic range compressor processing unit control selectors
+#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
+#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
+#define USB_AUDIO_MAXAMPL_CONTROL 0x03
+#define USB_AUDIO_THRESHOLD_CONTROL 0x04
+#define USB_AUDIO_ATTACK_TIME 0x05
+#define USB_AUDIO_RELEASE_TIME 0x06
+
+// extension unit control selectors
+#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
+
+// endpoint control selectors
+#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
+#define USB_AUDIO_PITCH_CONTROL 0x02
+
+// USB audio terminal types
+#define USB_AUDIO_TERMINAL_USB_UNDEFINED 0x0100
+#define USB_AUDIO_TERMINAL_USB_STREAMING 0x0101
+#define USB_AUDIO_TERMINAL_USB_VENDOR 0x01FF
+#define USB_AUDIO_TERMINAL_INPUT_UNDEFINED 0x0200
+#define USB_AUDIO_TERMINAL_MICROPHONE 0x0201
+#define USB_AUDIO_TERMINAL_DESKTOP_MICROPHONE 0x0202
+#define USB_AUDIO_TERMINAL_PERSONAL_MICROPHONE 0x0203
+#define USB_AUDIO_TERMINAL_OMNI_DIRECTIONAL_MICROPHONE 0x0204
+#define USB_AUDIO_TERMINAL_MICROPHONE_ARRAY 0x0205
+#define USB_AUDIO_TERMINAL_PROCESSING_MICROPHONE_ARRAY 0x0206
+#define USB_AUDIO_TERMINAL_OUTPUT_UNDEFINED 0x0300
+#define USB_AUDIO_TERMINAL_SPEAKER 0x0301
+#define USB_AUDIO_TERMINAL_HEADPHONES 0x0302
+#define USB_AUDIO_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x0303
+#define USB_AUDIO_TERMINAL_DESKTOP_SPEAKER 0x0304
+#define USB_AUDIO_TERMINAL_ROOM_SPEAKER 0x0305
+#define USB_AUDIO_TERMINAL_COMMUNICATION_SPEAKER 0x0306
+#define USB_AUDIO_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x0307
+#define USB_AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED 0x0400
+#define USB_AUDIO_TERMINAL_HANDSET 0x0401
+#define USB_AUDIO_TERMINAL_HEADSET 0x0402
+#define USB_AUDIO_TERMINAL_SPEAKERPHONE 0x0403
+#define USB_AUDIO_TERMINAL_ECHO_SUPPRESSING_SPEAKERPHONE 0x0404
+#define USB_AUDIO_TERMINAL_ECHO_CANCELING_SPEAKERPHONE 0x0405
+#define USB_AUDIO_TERMINAL_TELEPHONY_UNDEFINED 0x0500
+#define USB_AUDIO_TERMINAL_PHONE_LINE 0x0501
+#define USB_AUDIO_TERMINAL_TELEPHONE 0x0502
+#define USB_AUDIO_TERMINAL_DOWN_LINE_PHONE 0x0503
+#define USB_AUDIO_TERMINAL_EXTERNAL_UNDEFINED 0x0600
+#define USB_AUDIO_TERMINAL_ANALOG_CONNECTOR 0x0601
+#define USB_AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE 0x0602
+#define USB_AUDIO_TERMINAL_LINE_CONNECTOR 0x0603
+#define USB_AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR 0x0604
+#define USB_AUDIO_TERMINAL_SPDIF_INTERFACE 0x0605
+#define USB_AUDIO_TERMINAL_1394_DA_STREAM 0x0606
+#define USB_AUDIO_TERMINAL_1394_DV_STREAM_SOUNDTRACK 0x0607
+#define USB_AUDIO_TERMINAL_EMBEDDED_UNDEFINED 0x0700
+#define USB_AUDIO_TERMINAL_LEVEL_CALIBRATION_NOISE_SOURCE 0x0701
+#define USB_AUDIO_TERMINAL_EQUALIZATION_NOISE 0x0702
+#define USB_AUDIO_TERMINAL_CD_PLAYER 0x0703
+#define USB_AUDIO_TERMINAL_DAT 0x0704
+#define USB_AUDIO_TERMINAL_DCC 0x0705
+#define USB_AUDIO_TERMINAL_MINI_DISK 0x0706
+#define USB_AUDIO_TERMINAL_ANALOG_TAPE 0x0707
+#define USB_AUDIO_TERMINAL_PHONOGRAPH 0x0708
+#define USB_AUDIO_TERMINAL_VCR_AUDIO 0x0709
+#define USB_AUDIO_TERMINAL_VIDEO_DISK_AUDIO 0x070A
+#define USB_AUDIO_TERMINAL_DVD_AUDIO 0x070B
+#define USB_AUDIO_TERMINAL_TV_TUNER_AUDIO 0x070C
+#define USB_AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
+#define USB_AUDIO_TERMINAL_CABLE_TUNER_AUDIO 0x070E
+#define USB_AUDIO_TERMINAL_DSS_AUDIO 0x070F
+#define USB_AUDIO_TERMINAL_RADIO_RECEIVER 0x0710
+#define USB_AUDIO_TERMINAL_RADIO_TRANSMITTER 0x0711
+#define USB_AUDIO_TERMINAL_MULTI_TRACK_RECORDER 0x0712
+#define USB_AUDIO_TERMINAL_SYNTHESIZER 0x0713
+
+////////////////////////////////////////////////////
+//
+// Audio streaming interface constants
+//
+////////////////////////////////////////////////////
+
+// Audio stream class-specific AS interface descriptor subtypes
+#define USB_AUDIO_AS_GENERAL 0x01
+#define USB_AUDIO_AS_FORMAT_TYPE 0x02
+#define USB_AUDIO_AS_FORMAT_SPECIFIC 0x03
+
+// wFormatTag values present in the class specific AS header
+// Defined in Section A.1 of USB Device Class Definition for Audio Data Formats
+#define USB_AUDIO_AS_FT_TYPE_I_UNDEFINED 0x0000
+#define USB_AUDIO_AS_FT_PCM 0x0001
+#define USB_AUDIO_AS_FT_PCM8 0x0002
+#define USB_AUDIO_AS_FT_IEEE_FLOAT 0x0003
+#define USB_AUDIO_AS_FT_ALAW 0x0004
+#define USB_AUDIO_AS_FT_MULAW 0x0005
+#define USB_AUDIO_AS_FT_TYPE_II_UNDEFINED 0x1000
+#define USB_AUDIO_AS_FT_MPEG 0x1001
+#define USB_AUDIO_AS_FT_AC3 0x1002
+#define USB_AUDIO_AS_FT_TYPE_III_UNDEFINED 0x2000
+#define USB_AUDIO_AS_FT_IEC1937_AC3 0x2001
+#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L1 0x2002
+#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L23 0x2003
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_EXT 0x2004
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L1_LS 0x2005
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L23_LS 0x2006
+
+// Audio stream class-specific format-specific types
+#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
+#define USB_AUDIO_FORMAT_TYPE_I 0x01
+#define USB_AUDIO_FORMAT_TYPE_II 0x02
+#define USB_AUDIO_FORMAT_TYPE_III 0x03
+
+////////////////////////////////////////////////////
+//
+// MIDI streaming interface constants
+//
+////////////////////////////////////////////////////
+
+// MIDI class specific MS interface descriptor subtypes
+#define USB_MIDI_MS_HEADER 0x01
+#define USB_MIDI_IN_JACK 0x02
+#define USB_MIDI_OUT_JACK 0x03
+#define USB_MIDI_ELEMENT 0x04
+
+// MIDI class specific MS endpoint descriptor subtypes
+#define USB_MIDI_MS_GENERAL 0x01
+
+// MIDI IN and OUT jack types
+#define USB_MIDI_JACK_EMBEDDED 0x01
+#define USB_MIDI_JACK_INTERNAL 0x02
+
+// MIDI endpoint control selectors
+#define USB_MIDI_ASSOCIATION_CONTROL 0x01
+
+
+// Top level header structure shared by all USB audio descriptors.
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype;
+} __PACKED usb_audio_desc_header;
+
+// Audio Control Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_HEADER
+ uint16_t bcdADC;
+ uint16_t wTotalLength;
+ uint8_t bInCollection;
+ uint8_t baInterfaceNr[];
+} __PACKED usb_audio_ac_header_desc;
+
+// Common header structure shared by all unit and terminal descriptors found in
+// an Audio Control interface descriptor.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_.*_(TERMINAL|UNIT)
+ uint8_t bID;
+} __PACKED usb_audio_ac_ut_desc;
+
+// Common header structure shared by all terminal descriptors found in an Audio
+// Control interface descriptor.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_(INPUT|OUTPUT)_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+} __PACKED usb_audio_ac_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_INPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t iTerminal;
+} __PACKED usb_audio_ac_input_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_OUTPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bSourceID;
+ uint8_t iTerminal;
+} __PACKED usb_audio_ac_output_terminal_desc;
+
+// Note: Mixer unit descriptors contain two inlined variable length arrays, each
+// with descriptor data following them. They are therefor described using 3
+// structure definitions which are logically concatenated, but separated by the
+// inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_MIXER_UNIT
+ uint8_t bUnitID;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_mixer_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_mixer_unit_desc_1;
+
+typedef struct {
+ uint8_t iMixer;
+} __PACKED usb_audio_ac_mixer_unit_desc_2;
+
+// Note: Selector unit descriptors contain an inlined variable length array with
+// descriptor data following it. They are therefor described using 2 structure
+// definitions which are logically concatenated, but separated by the inline
+// array.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_SELECTOR_UNIT
+ uint8_t bUnitID;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_selector_unit_desc_0;
+
+typedef struct {
+ uint8_t iSelector;
+} __PACKED usb_audio_ac_selector_unit_desc_1;
+
+// Note: Feature unit descriptors contain an inlined variable length array with
+// descriptor data following it. They are therefor described using 2 structure
+// definitions which are logically concatenated, but separated by the inline
+// array.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_FEATURE_UNIT
+ uint8_t bUnitID;
+ uint8_t bSourceID;
+ uint8_t bControlSize;
+ uint8_t bmaControls[];
+} __PACKED usb_audio_ac_feature_unit_desc_0;
+
+typedef struct {
+ uint8_t iFeature;
+} __PACKED usb_audio_ac_feature_unit_desc_1;
+
+// Note: Processing unit descriptors contain two inlined variable length arrays,
+// each with descriptor data following them. They are therefor described using
+// 3 structure definitions which are logically concatenated, but separated by
+// the inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_PROCESSING_UNIT
+ uint8_t bUnitID;
+ uint16_t wProcessType;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_processing_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bControlSize;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_processing_unit_desc_1;
+
+typedef struct {
+ uint8_t iProcessing;
+ // Note: The Process-specific control structure follows this with the
+ // structure type determined by wProcessType
+ // TODO(johngro) : Define the process specific control structures. As of
+ // the 1.0 revision of the USB audio spec, the types to be defined are...
+ //
+ // ** Up/Down-mix
+ // ** Dolby Prologic
+ // ** 3D-Stereo Extender
+ // ** Reverberation
+ // ** Chorus
+ // ** Dynamic Range Compressor
+} __PACKED usb_audio_ac_processing_unit_desc_2;
+
+// Note: Extension unit descriptors contain two inlined variable length arrays,
+// each with descriptor data following them. They are therefor described using
+// 3 structure definitions which are logically concatenated, but separated by
+// the inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_EXTENSION_UNIT
+ uint8_t bUnitID;
+ uint16_t wExtensionCode;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_extension_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bControlSize;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_extension_unit_desc_1;
+
+typedef struct {
+ uint8_t iExtension;
+} __PACKED usb_audio_ac_extension_unit_desc_2;
+
+// Audio Streaming Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_GENERAL
+ uint8_t bTerminalLink;
+ uint8_t bDelay;
+ uint16_t wFormatTag;
+} __PACKED usb_audio_as_header_desc;
+
+typedef struct {
+ uint8_t freq[3]; // 24 bit unsigned integer, little-endian
+} __PACKED usb_audio_as_samp_freq;
+
+// Common header used by all format type descriptors
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
+ uint8_t bFormatType;
+} __PACKED usb_audio_as_format_type_hdr;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
+ uint8_t bFormatType; // USB_AUDIO_FORMAT_TYPE_I
+ uint8_t bNrChannels;
+ uint8_t bSubFrameSize;
+ uint8_t bBitResolution;
+ uint8_t bSamFreqType; // number of sampling frequencies
+ usb_audio_as_samp_freq tSamFreq[]; // list of sampling frequencies (3 bytes each)
+} __PACKED usb_audio_as_format_type_i_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_AUDIO_EP_GENERAL
+ uint8_t bmAttributes;
+ uint8_t bLockDelayUnits;
+ uint16_t wLockDelay;
+} __PACKED usb_audio_as_isoch_ep_desc;
+
+// MIDI Streaming Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_MS_HEADER
+ uint16_t bcdMSC;
+ uint16_t wTotalLength;
+} __PACKED usb_midi_ms_header_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_IN_JACK
+ uint8_t bJackType;
+ uint8_t bJackID;
+ uint8_t iJack;
+} __PACKED usb_midi_ms_in_jack_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_OUT_JACK
+ uint8_t bJackType;
+ uint8_t bJackID;
+ uint8_t bNrInputPins;
+ uint8_t baSourceID;
+ uint8_t baSourcePin;
+} __PACKED usb_midi_ms_out_jack_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_MIDI_MS_GENERAL
+ uint8_t bNumEmbMIDIJack;
+ uint8_t baAssocJackID[];
+} __PACKED usb_midi_ms_endpoint_desc;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_AUDIO_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/cdc.h b/arch/arm64/sysroot/include/zircon/hw/usb/cdc.h
new file mode 100644
index 0000000..67ac8c7
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/cdc.h
@@ -0,0 +1,150 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_CDC_H_
+#define SYSROOT_ZIRCON_HW_USB_CDC_H_
+
+#include <stdint.h>
+
+// clang-format off
+
+#include <zircon/compiler.h>
+
+/* CDC Subclasses for the Communications Interface Class */
+#define USB_CDC_SUBCLASS_DIRECT_LINE 0x01
+#define USB_CDC_SUBCLASS_ABSTRACT 0x02
+#define USB_CDC_SUBCLASS_TELEPHONE 0x03
+#define USB_CDC_SUBCLASS_MULTI_CHANNEL 0x04
+#define USB_CDC_SUBCLASS_CAPI 0x05
+#define USB_CDC_SUBCLASS_ETHERNET 0x06
+#define USB_CDC_SUBCLASS_ATM 0x07
+#define USB_CDC_SUBCLASS_WIRELESS_HANDSET 0x08
+#define USB_CDC_SUBCLASS_DEVICE_MGMT 0x09
+#define USB_CDC_SUBCLASS_MOBILE_DIRECT 0x0A
+#define USB_CDC_SUBCLASS_OBEX 0x0B
+#define USB_CDC_SUBCLASS_ETHERNET_EMU 0x0C
+#define USB_CDC_SUBCLASS_NETWORK_CTRL 0x0D
+
+/* CDC Descriptor SubTypes */
+#define USB_CDC_DST_HEADER 0x00
+#define USB_CDC_DST_CALL_MGMT 0x01
+#define USB_CDC_DST_ABSTRACT_CTRL_MGMT 0x02
+#define USB_CDC_DST_DIRECT_LINE_MGMT 0x03
+#define USB_CDC_DST_TELEPHONE_RINGER 0x04
+#define USB_CDC_DST_TELEPHONE_CALL_REPORTING 0x05
+#define USB_CDC_DST_UNION 0x06
+#define USB_CDC_DST_COUNTRY_SELECTION 0x07
+#define USB_CDC_DST_TELEPHONE_OP_MODES 0x08
+#define USB_CDC_DST_USB_TERMINAL 0x09
+#define USB_CDC_DST_NETWORK_CHANNEL 0x0A
+#define USB_CDC_DST_PROTOCOL_UNIT 0x0B
+#define USB_CDC_DST_EXTENSION_UNIT 0x0C
+#define USB_CDC_DST_MULTI_CHANNEL_MGMT 0x0D
+#define USB_CDC_DST_CAPI_CTRL_MGMT 0x0E
+#define USB_CDC_DST_ETHERNET 0x0F
+#define USB_CDC_DST_ATM_NETWORKING 0x10
+#define USB_CDC_DST_WIRELESS_HANDSET_CTRL 0x11
+#define USB_CDC_DST_MOBILE_DIRECT_LINE 0x12
+#define USB_CDC_DST_MDLM_DETAIL 0x13
+#define USB_CDC_DST_DEVICE_MGMT 0x14
+#define USB_CDC_DST_OBEX 0x15
+#define USB_CDC_DST_COMMAND_SET 0x16
+#define USB_CDC_DST_COMMAND_SET_DETAIL 0x17
+#define USB_CDC_DST_TELEPHONE_CTRL 0x18
+#define USB_CDC_DST_OBEX_SERVICE_ID 0x19
+#define USB_CDC_DST_NCM 0x1A
+
+/* CDC Class-Specific Notification Codes */
+#define USB_CDC_NC_NETWORK_CONNECTION 0x00
+#define USB_CDC_NC_RESPONSE_AVAILABLE 0x01
+#define USB_CDC_NC_SERIAL_STATE 0x20
+#define USB_CDC_NC_CONNECTION_SPEED_CHANGE 0x2A
+
+/* CDC Ethernet Class-Specific Request Codes */
+#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
+#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
+#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
+#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
+#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
+
+/* CDC Ethernet Packet Filter Modes Bits */
+#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
+#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1)
+#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
+#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
+#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4)
+
+/* CDC Class-Specific Requests */
+#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
+#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
+
+__BEGIN_CDECLS
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_HEADER
+ uint16_t bcdCDC;
+} __attribute__ ((packed)) usb_cs_header_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_CALL_MGMT
+ uint8_t bmCapabilities;
+ uint8_t bDataInterface;
+} __attribute__ ((packed)) usb_cs_call_mgmt_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_ABSTRACT_CTRL_MGMT
+ uint8_t bmCapabilities;
+} __attribute__ ((packed)) usb_cs_abstract_ctrl_mgmt_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
+ uint8_t bControlInterface;
+ uint8_t bSubordinateInterface[];
+} __attribute__ ((packed)) usb_cs_union_interface_descriptor_t;
+
+// fixed size version of usb_cs_union_interface_descriptor_t
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
+ uint8_t bControlInterface;
+ uint8_t bSubordinateInterface;
+} __attribute__ ((packed)) usb_cs_union_interface_descriptor_1_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_ETHERNET
+ uint8_t iMACAddress;
+ uint32_t bmEthernetStatistics;
+ uint16_t wMaxSegmentSize;
+ uint16_t wNumberMCFilters;
+ uint8_t bNumberPowerFilters;
+} __attribute__ ((packed)) usb_cs_ethernet_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bmRequestType;
+ uint8_t bNotification;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+} __attribute__ ((packed)) usb_cdc_notification_t;
+
+typedef struct {
+ usb_cdc_notification_t notification;
+ uint32_t downlink_br;
+ uint32_t uplink_br;
+ } __attribute__ ((packed)) usb_cdc_speed_change_notification_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_CDC_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/dfu.h b/arch/arm64/sysroot/include/zircon/hw/usb/dfu.h
new file mode 100644
index 0000000..7ca40f0
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/dfu.h
@@ -0,0 +1,82 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_DFU_H_
+#define SYSROOT_ZIRCON_HW_USB_DFU_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// USB DFU Spec, Rev 1.1
+
+// DFU Class-Specific Request Values
+// Table 3.2
+#define USB_DFU_DETACH 0x00
+#define USB_DFU_DNLOAD 0x01
+#define USB_DFU_UPLOAD 0x02
+#define USB_DFU_GET_STATUS 0x03
+#define USB_DFU_CLR_STATUS 0x04
+#define USB_DFU_GET_STATE 0x05
+#define USB_DFU_ABORT 0x06
+
+// DFU Class-Specific Descriptor Types
+// Table 4.1.3
+#define USB_DFU_CS_FUNCTIONAL 0x21
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DFU_CS_FUNCTIONAL
+ uint8_t bmAttributes;
+ uint16_t wDetachTimeOut;
+ uint16_t wTransferSize;
+ uint16_t bcdDFUVersion;
+} __PACKED usb_dfu_func_desc_t;
+
+// DFU_GET_STATUS Response
+// Section 6.1.2
+typedef struct {
+ uint8_t bStatus;
+ uint8_t bwPollTimeout[3]; // 24 bit unsigned integer
+ uint8_t bState;
+ uint8_t bString;
+} __PACKED usb_dfu_get_status_data_t;
+
+// DFU Device Status Values
+#define USB_DFU_STATUS_OK 0x00
+#define USB_DFU_STATUS_ERR_TARGET 0x01
+#define USB_DFU_STATUS_ERR_FILE 0x02
+#define USB_DFU_STATUS_ERR_WRITE 0x03
+#define USB_DFU_STATUS_ERR_ERASE 0x04
+#define USB_DFU_STATUS_ERR_CHECK_ERASED 0x05
+#define USB_DFU_STATUS_ERR_PROG 0x06
+#define USB_DFU_STATUS_ERR_VERIFY 0x07
+#define USB_DFU_STATUS_ERR_ADDRESS 0x08
+#define USB_DFU_STATUS_ERR_NOT_DONE 0x09
+#define USB_DFU_STATUS_ERR_FIRMWARE 0x0A
+#define USB_DFU_STATUS_ERR_VENDOR 0x0B
+#define USB_DFU_STATUS_ERR_USER 0x0C
+#define USB_DFU_STATUS_ERR_POR 0x0D
+#define USB_DFU_STATUS_ERR_UNKNOWN 0x0E
+#define USB_DFU_STATUS_ERR_STALLED_PKT 0x0F
+
+// DFU Device State Values
+#define USB_DFU_STATE_APP_IDLE 0x00
+#define USB_DFU_STATE_APP_DETACH 0x01
+#define USB_DFU_STATE_DFU_IDLE 0x02
+#define USB_DFU_STATE_DFU_DNLOAD_SYNC 0x03
+#define USB_DFU_STATE_DFU_DNBUSY 0x04
+#define USB_DFU_STATE_DFU_DNLOAD_IDLE 0x05
+#define USB_DFU_STATE_DFU_MANIFEST_SYNC 0x06
+#define USB_DFU_STATE_DFU_MANIFEST 0x07
+#define USB_DFU_STATE_DFU_MANIFEST_WAIT_RESET 0x08
+#define USB_DFU_STATE_DFU_UPLOAD_IDLE 0x09
+#define USB_DFU_STATE_DFU_ERROR 0x0A
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_DFU_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/hid.h b/arch/arm64/sysroot/include/zircon/hw/usb/hid.h
new file mode 100644
index 0000000..97dea4e
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/hid.h
@@ -0,0 +1,46 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_HID_H_
+#define SYSROOT_ZIRCON_HW_USB_HID_H_
+
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+__BEGIN_CDECLS
+
+// clang-format off
+
+// HID Request Values.
+#define USB_HID_GET_REPORT 0x01
+#define USB_HID_GET_IDLE 0x02
+#define USB_HID_GET_PROTOCOL 0x03
+#define USB_HID_SET_REPORT 0x09
+#define USB_HID_SET_IDLE 0x0A
+#define USB_HID_SET_PROTOCOL 0x0B
+
+// HID USB protocols
+#define USB_HID_PROTOCOL_KBD 0x01
+#define USB_HID_PROTOCOL_MOUSE 0x02
+#define USB_HID_SUBCLASS_BOOT 0x01
+
+// clang-format on
+
+typedef struct {
+ uint8_t bDescriptorType;
+ uint16_t wDescriptorLength;
+} __attribute__((packed)) usb_hid_descriptor_entry_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t bcdHID;
+ uint8_t bCountryCode;
+ uint8_t bNumDescriptors;
+ usb_hid_descriptor_entry_t descriptors[];
+} __attribute__((packed)) usb_hid_descriptor_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_HID_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/hub.h b/arch/arm64/sysroot/include/zircon/hw/usb/hub.h
new file mode 100644
index 0000000..10ed110
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/hub.h
@@ -0,0 +1,120 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_HUB_H_
+#define SYSROOT_ZIRCON_HW_USB_HUB_H_
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+// clang-format off
+
+__BEGIN_CDECLS
+
+// Hub request types
+#define USB_RECIP_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
+#define USB_RECIP_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
+
+// Hub requests
+#define USB_HUB_SET_DEPTH 12
+
+// Hub descriptor types
+#define USB_HUB_DESC_TYPE 0x29
+#define USB_HUB_DESC_TYPE_SS 0x2A // for superspeed hubs
+
+// Hub Class Feature Selectors (USB 2.0 spec Table 11.17)
+#define USB_FEATURE_C_HUB_LOCAL_POWER 0
+#define USB_FEATURE_C_HUB_OVER_CURRENT 1
+#define USB_FEATURE_PORT_CONNECTION 0
+#define USB_FEATURE_PORT_ENABLE 1
+#define USB_FEATURE_PORT_SUSPEND 2
+#define USB_FEATURE_PORT_OVER_CURRENT 3
+#define USB_FEATURE_PORT_RESET 4
+#define USB_FEATURE_PORT_LINK_STATE 5
+#define USB_FEATURE_PORT_POWER 8
+#define USB_FEATURE_PORT_LOW_SPEED 9
+#define USB_FEATURE_C_PORT_CONNECTION 16
+#define USB_FEATURE_C_PORT_ENABLE 17
+#define USB_FEATURE_C_PORT_SUSPEND 18
+#define USB_FEATURE_C_PORT_OVER_CURRENT 19
+#define USB_FEATURE_C_PORT_RESET 20
+#define USB_FEATURE_PORT_TEST 21
+#define USB_FEATURE_PORT_INDICATOR 22
+#define USB_FEATURE_PORT_INDICATOR 22
+#define USB_FEATURE_PORT_U1_TIMEOUT 23
+#define USB_FEATURE_PORT_U2_TIMEOUT 24
+#define USB_FEATURE_C_PORT_LINK_STATE 25
+#define USB_FEATURE_C_PORT_CONFIG_ERROR 26
+#define USB_FEATURE_PORT_REMOTE_WAKE_MASK 27
+#define USB_FEATURE_BH_PORT_RESET 28
+#define USB_FEATURE_C_BH_PORT_RESET 29
+#define USB_FEATURE_FORCE_LINKPM_ACCEPT 30
+
+typedef struct {
+ uint8_t bDescLength;
+ uint8_t bDescriptorType;
+ uint8_t bNbrPorts;
+ uint16_t wHubCharacteristics;
+ uint8_t bPowerOn2PwrGood;
+ uint8_t bHubContrCurrent;
+ union {
+ // USB 2.0
+ struct {
+ // variable length depending on number of ports
+ uint8_t DeviceRemovable[4];
+ uint8_t PortPwrCtrlMask[4];
+ } __attribute__ ((packed)) hs;
+ // USB 3.0
+ struct {
+ uint8_t bHubHdrDecLat;
+ uint16_t wHubDelay;
+ uint16_t DeviceRemovable;
+ } __attribute__ ((packed)) ss;
+ } __attribute__ ((packed));
+} __attribute__ ((packed)) usb_hub_descriptor_t;
+
+typedef struct {
+ uint16_t wHubStatus;
+ uint16_t wHubChange;
+} __attribute__ ((packed)) usb_hub_status_t;
+
+// wHubStatus bits
+#define USB_HUB_LOCAL_POWER (1 << 0)
+#define USB_HUB_OVER_CURRENT (1 << 1)
+
+typedef struct {
+ uint16_t wPortStatus;
+ uint16_t wPortChange;
+} __attribute__ ((packed)) usb_port_status_t;
+
+// Port Status bits
+#define USB_PORT_CONNECTION (1 << 0)
+#define USB_PORT_ENABLE (1 << 1)
+#define USB_PORT_SUSPEND (1 << 2) // USB 2.0 only
+#define USB_PORT_OVER_CURRENT (1 << 3)
+#define USB_PORT_RESET (1 << 4)
+#define USB_PORT_POWER (1 << 8) // USB 2.0 only
+#define USB_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
+#define USB_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
+#define USB_PORT_TEST_MODE (1 << 11) // USB 2.0 only
+#define USB_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
+
+// Port Status Changed bits
+#define USB_C_PORT_CONNECTION (1 << 0)
+#define USB_C_PORT_ENABLE (1 << 1) // USB 2.0 only
+#define USB_C_PORT_SUSPEND (1 << 2) // USB 2.0 only
+#define USB_C_PORT_OVER_CURRENT (1 << 3)
+#define USB_C_PORT_RESET (1 << 4)
+#define USB_C_BH_PORT_RESET (1 << 5) // USB 3.0 only
+#define USB_C_PORT_LINK_STATE (1 << 6) // USB 3.0 only
+#define USB_C_PORT_CONFIG_ERROR (1 << 7) // USB 3.0 only
+#define USB_C_PORT_POWER (1 << 8) // USB 2.0 only
+#define USB_C_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
+#define USB_C_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
+#define USB_C_PORT_TEST_MODE (1 << 11) // USB 2.0 only
+#define USB_C_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_HUB_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/ums.h b/arch/arm64/sysroot/include/zircon/hw/usb/ums.h
new file mode 100644
index 0000000..6640803
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/ums.h
@@ -0,0 +1,159 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_UMS_H_
+#define SYSROOT_ZIRCON_HW_USB_UMS_H_
+
+// clang-format off
+
+// SCSI commands
+#define UMS_TEST_UNIT_READY 0x00
+#define UMS_REQUEST_SENSE 0x03
+#define UMS_INQUIRY 0x12
+#define UMS_MODE_SELECT6 0x15
+#define UMS_MODE_SENSE6 0x1A
+#define UMS_START_STOP_UNIT 0x1B
+#define UMS_TOGGLE_REMOVABLE 0x1E
+#define UMS_READ_FORMAT_CAPACITIES 0x23
+#define UMS_READ_CAPACITY10 0x25
+#define UMS_READ10 0x28
+#define UMS_WRITE10 0x2A
+#define UMS_SYNCHRONIZE_CACHE 0x35
+#define UMS_MODE_SELECT10 0x55
+#define UMS_MODE_SENSE10 0x5A
+#define UMS_READ16 0x88
+#define UMS_WRITE16 0x8A
+#define UMS_READ_CAPACITY16 0x9E
+#define UMS_READ12 0xA8
+#define UMS_WRITE12 0xAA
+
+// control request values
+#define USB_REQ_RESET 0xFF
+#define USB_REQ_GET_MAX_LUN 0xFE
+
+// error codes for CSW processing
+typedef uint32_t csw_status_t;
+#define CSW_SUCCESS ((csw_status_t)0)
+#define CSW_FAILED ((csw_status_t)1)
+#define CSW_PHASE_ERROR ((csw_status_t)2)
+#define CSW_INVALID ((csw_status_t)3)
+#define CSW_TAG_MISMATCH ((csw_status_t)4)
+
+// signatures in header and status
+#define CBW_SIGNATURE 0x43425355
+#define CSW_SIGNATURE 0x53425355
+
+// transfer lengths
+#define UMS_INQUIRY_TRANSFER_LENGTH 0x24
+#define UMS_REQUEST_SENSE_TRANSFER_LENGTH 0x12
+#define UMS_READ_FORMAT_CAPACITIES_TRANSFER_LENGTH 0xFC
+
+// 6 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint16_t lba; // logical block address
+ uint8_t length;
+ uint8_t control;
+} __PACKED scsi_command6_t;
+static_assert(sizeof(scsi_command6_t) == 6, "");
+
+// 10 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint32_t lba; // logical block address
+ uint8_t misc2;
+ uint8_t length_hi; // break length into two pieces to avoid odd alignment
+ uint8_t length_lo;
+ uint8_t control;
+} __PACKED scsi_command10_t;
+static_assert(sizeof(scsi_command10_t) == 10, "");
+
+// 12 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint32_t lba; // logical block address
+ uint32_t length;
+ uint8_t misc2;
+ uint8_t control;
+} __PACKED scsi_command12_t;
+static_assert(sizeof(scsi_command12_t) == 12, "");
+
+// 16 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint64_t lba; // logical block address
+ uint32_t length;
+ uint8_t misc2;
+ uint8_t control;
+} __PACKED scsi_command16_t;
+static_assert(sizeof(scsi_command16_t) == 16, "");
+
+// SCSI Read Capacity 10 payload
+// This is big endian
+typedef struct {
+ uint32_t lba;
+ uint32_t block_length;
+} __PACKED scsi_read_capacity_10_t;
+static_assert(sizeof(scsi_read_capacity_10_t) == 8, "");
+
+// SCSI Read Capacity 16 payload
+// This is big endian
+typedef struct {
+ uint64_t lba;
+ uint32_t block_length;
+ uint8_t ptype_prot_en; // bit 0: PROT_EN, bits 1-3: P_TYPE
+ uint8_t resesrved[19];
+} __PACKED scsi_read_capacity_16_t;
+static_assert(sizeof(scsi_read_capacity_16_t) == 32, "");
+
+// SCSI Mode Sense 6 command
+typedef struct {
+ uint8_t opcode; // UMS_MODE_SENSE6
+ uint8_t disable_block_desc;
+ uint8_t page;
+ uint8_t subpage;
+ uint8_t allocation_length;
+ uint8_t control;
+} __PACKED scsi_mode_sense_6_command_t;
+static_assert(sizeof(scsi_mode_sense_6_command_t) == 6, "");
+
+// SCSI Mode Sense 6 data response
+typedef struct {
+ uint8_t mode_data_length;
+ uint8_t medium_type;
+ uint8_t device_specific_param;
+ uint8_t block_desc_length;
+} __PACKED scsi_mode_sense_6_data_t;
+#define MODE_SENSE_DSP_RO 0x80 // bit 7 of device_specific_param: read-only
+
+// Command Block Wrapper
+typedef struct {
+ uint32_t dCBWSignature; // CBW_SIGNATURE
+ uint32_t dCBWTag;
+ uint32_t dCBWDataTransferLength;
+ uint8_t bmCBWFlags;
+ uint8_t bCBWLUN;
+ uint8_t bCBWCBLength;
+ uint8_t CBWCB[16];
+} __PACKED ums_cbw_t;
+static_assert(sizeof(ums_cbw_t) == 31, "");
+
+// Command Status Wrapper
+typedef struct {
+ uint32_t dCSWSignature; // CSW_SIGNATURE
+ uint32_t dCSWTag;
+ uint32_t dCSWDataResidue;
+ uint8_t bmCSWStatus;
+} __PACKED ums_csw_t;
+static_assert(sizeof(ums_csw_t) == 13, "");
+
+#endif // SYSROOT_ZIRCON_HW_USB_UMS_H_
diff --git a/arch/arm64/sysroot/include/zircon/hw/usb/video.h b/arch/arm64/sysroot/include/zircon/hw/usb/video.h
new file mode 100644
index 0000000..925b5b6
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/hw/usb/video.h
@@ -0,0 +1,308 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_VIDEO_H_
+#define SYSROOT_ZIRCON_HW_USB_VIDEO_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <stdint.h>
+
+__BEGIN_CDECLS;
+
+// video interface subclasses
+#define USB_SUBCLASS_VIDEO_CONTROL 0x01
+#define USB_SUBCLASS_VIDEO_STREAMING 0x02
+#define USB_SUBCLASS_VIDEO_INTERFACE_COLLECTION 0x03
+
+// video class specific descriptor types
+#define USB_VIDEO_CS_DEVICE 0x21
+#define USB_VIDEO_CS_CONFIGURATION 0x22
+#define USB_VIDEO_CS_STRING 0x23
+#define USB_VIDEO_CS_INTERFACE 0x24
+#define USB_VIDEO_CS_ENDPOINT 0x25
+
+// video class specific VC interface descriptor subtypes
+#define USB_VIDEO_VC_HEADER 0x01
+#define USB_VIDEO_VC_INPUT_TERMINAL 0x02
+#define USB_VIDEO_VC_OUTPUT_TERMINAL 0x03
+#define USB_VIDEO_VC_SELECTOR_UNIT 0x04
+#define USB_VIDEO_VC_PROCESSING_UNIT 0x05
+#define USB_VIDEO_VC_EXTENSION_UNIT 0x06
+#define USB_VIDEO_VC_ENCODING_UNIT 0x07
+
+// video class specific VS interface descriptor subtypes
+#define USB_VIDEO_VS_INPUT_HEADER 0x01
+#define USB_VIDEO_VS_OUTPUT_HEADER 0x02
+#define USB_VIDEO_VS_STILL_IMAGE_FRAME 0x03
+#define USB_VIDEO_VS_FORMAT_UNCOMPRESSED 0x04
+#define USB_VIDEO_VS_FRAME_UNCOMPRESSED 0x05
+#define USB_VIDEO_VS_FORMAT_MJPEG 0x06
+#define USB_VIDEO_VS_FRAME_MJPEG 0x07
+#define USB_VIDEO_VS_FORMAT_MPEG2TS 0x0A
+#define USB_VIDEO_VS_FORMAT_DV 0x0C
+#define USB_VIDEO_VS_COLORFORMAT 0x0D
+#define USB_VIDEO_VS_FORMAT_FRAME_BASED 0x10
+#define USB_VIDEO_VS_FRAME_FRAME_BASED 0x11
+#define USB_VIDEO_VS_FORMAT_STREAM_BASED 0x12
+#define USB_VIDEO_VS_FORMAT_H264 0x13
+#define USB_VIDEO_VS_FRAME_H264 0x14
+#define USB_VIDEO_VS_FORMAT_H264_SIMULCAST 0x15
+#define USB_VIDEO_VS_FORMAT_VP8 0x16
+#define USB_VIDEO_VS_FRAME_VP8 0x17
+#define USB_VIDEO_VS_FORMAT_VP8_SIMULCAST 0x18
+
+// video class specific endpoint descriptor subtypes
+#define USB_VIDEO_EP_GENERAL 0x01
+#define USB_VIDEO_EP_ENDPOINT 0x02
+#define USB_VIDEO_EP_INTERRUPT 0x03
+
+// video class specific request codes
+#define USB_VIDEO_SET_CUR 0x01
+#define USB_VIDEO_SET_CUR_ALL 0x11
+#define USB_VIDEO_GET_CUR 0x81
+#define USB_VIDEO_GET_MIN 0x82
+#define USB_VIDEO_GET_MAX 0x83
+#define USB_VIDEO_GET_RES 0x84
+#define USB_VIDEO_GET_LEN 0x85
+#define USB_VIDEO_GET_INFO 0x86
+#define USB_VIDEO_GET_DEF 0x87
+#define USB_VIDEO_GET_CUR_ALL 0x91
+#define USB_VIDEO_GET_MIN_ALL 0x92
+#define USB_VIDEO_GET_MAX_ALL 0x93
+#define USB_VIDEO_GET_RES_ALL 0x94
+#define USB_VIDEO_GET_DEF_ALL 0x97
+
+// video streaming interface control selectors
+#define USB_VIDEO_VS_PROBE_CONTROL 0x01
+#define USB_VIDEO_VS_COMMIT_CONTROL 0x02
+#define USB_VIDEO_VS_STILL_PROBE_CONTROL 0x03
+#define USB_VIDEO_VS_STILL_COMMIT_CONTROL 0x04
+#define USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
+#define USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL 0x06
+#define USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL 0x07
+#define USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
+#define USB_VIDEO_VS_SYNCH_DELAY_CONTROL 0x09
+
+// header for usb_video_vc_* below
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype;
+} __PACKED usb_video_vc_desc_header;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_HEADER
+ uint16_t bcdUVC;
+ uint16_t wTotalLength;
+ uint32_t dwClockFrequency;
+ uint8_t bInCollection;
+ uint8_t baInterfaceNr[];
+} __PACKED usb_video_vc_header_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_INPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t iTerminal;
+} __PACKED usb_video_vc_input_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bSourceID;
+ uint8_t iTerminal;
+} __PACKED usb_video_vc_output_terminal_desc;
+
+// class specific VC interrupt endpoint descriptor
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_ENDPOINT_INTERRUPT
+ uint16_t wMaxTransferSize;
+} __PACKED usb_video_vc_interrupt_endpoint_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VS_HEADER
+ uint8_t bNumFormats;
+ uint16_t wTotalLength;
+ uint8_t bEndpointAddress;
+ uint8_t bmInfo;
+ uint8_t bTerminalLink;
+ uint8_t bStillCaptureMethod;
+ uint8_t bTriggerSupport;
+ uint8_t bTriggerUsage;
+ uint8_t bControlSize;
+ uint8_t bmaControls[];
+} __PACKED usb_video_vs_input_header_desc;
+
+#define GUID_LENGTH 16
+
+// A GUID consists of a:
+// - four-byte integer
+// - two-byte integer
+// - two-byte integer
+// - eight-byte array
+//
+// The string representation uses big endian format, so to convert it
+// to a byte array we need to reverse the byte order of the three integers.
+//
+// See USB Video Class revision 1.5, FAQ section 2.9
+// for GUID Data Structure Layout.
+
+#define USB_VIDEO_GUID_YUY2_STRING "32595559-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_YUY2_VALUE { \
+ 0x59, 0x55, 0x59, 0x32, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_NV12_STRING "3231564E-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_NV12_VALUE { \
+ 0x4e, 0x56, 0x31, 0x32, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_M420_STRING "3032344D-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_M420_VALUE { \
+ 0x4d, 0x34, 0x32, 0x30, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_I420_STRING "30323449-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_I420_VALUE { \
+ 0x49, 0x34, 0x32, 0x30, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+// USB Video Payload Uncompressed
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_UNCOMPRESSED
+ uint8_t bFormatIndex;
+ uint8_t bNumFrameDescriptors;
+ uint8_t guidFormat[GUID_LENGTH];
+ uint8_t bBitsPerPixel;
+ uint8_t bDefaultFrameIndex;
+ uint8_t bAspectRatioX;
+ uint8_t bAspectRatioY;
+ uint8_t bmInterfaceFlags;
+ uint8_t bCopyProtect;
+} __PACKED usb_video_vs_uncompressed_format_desc;
+
+// USB Video Payload MJPEG
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_MJPEG
+ uint8_t bFormatIndex;
+ uint8_t bNumFrameDescriptors;
+ uint8_t bmFlags;
+ uint8_t bDefaultFrameIndex;
+ uint8_t bAspectRatioX;
+ uint8_t bAspectRatioY;
+ uint8_t bmInterfaceFlags;
+ uint8_t bCopyProtect;
+} __PACKED usb_video_vs_mjpeg_format_desc;
+
+// Uncompressed and MJPEG formats have the same frame descriptor structure.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FRAME_UNCOMPRESSED / USB_VIDEO_VS_FRAME_MJPEG
+ uint8_t bFrameIndex;
+ uint8_t bmCapabilities;
+ uint16_t wWidth;
+ uint16_t wHeight;
+ uint32_t dwMinBitRate;
+ uint32_t dwMaxBitRate;
+ uint32_t dwMaxVideoFrameBufferSize;
+ uint32_t dwDefaultFrameInterval;
+ uint8_t bFrameIntervalType;
+ uint32_t dwFrameInterval[];
+} __PACKED usb_video_vs_frame_desc;
+
+// Stream negotiation
+#define USB_VIDEO_BM_HINT_FRAME_INTERVAL (1 << 0)
+#define USB_VIDEO_BM_HINT_KEY_FRAME_RATE (1 << 1)
+#define USB_VIDEO_BM_HINT_P_FRAME_RATE (1 << 2)
+#define USB_VIDEO_BM_HINT_COMP_QUALITY (1 << 3)
+#define USB_VIDEO_BM_HINT_COMP_WINDOW_SIZE (1 << 4)
+
+typedef struct {
+ uint16_t bmHint;
+ uint8_t bFormatIndex;
+ uint8_t bFrameIndex;
+ uint32_t dwFrameInterval;
+ uint16_t wKeyFrameRate;
+ uint16_t wPFrameRate;
+ uint16_t wCompQuality;
+ uint16_t wCompWindowSize;
+ uint16_t wDelay;
+ uint32_t dwMaxVideoFrameSize;
+ uint32_t dwMaxPayloadTransferSize;
+ // The following fields are optional.
+ uint32_t dwClockFrequency;
+ uint8_t bmFramingInfo;
+ uint8_t bPreferedVersion;
+ uint8_t bMinVersion;
+ uint8_t bMaxVersion;
+ uint8_t bUsage;
+ uint8_t bBitDepthLuma;
+ uint8_t bmSettings;
+ uint8_t bMaxNumberOfRefFramesPlus1;
+ uint16_t bmRateControlModes;
+ uint32_t bmLayoutPerStream;
+} __PACKED usb_video_vc_probe_and_commit_controls;
+
+// For accessing payload bmHeaderInfo bitmap
+#define USB_VIDEO_VS_PAYLOAD_HEADER_FID (1 << 0)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_EOF (1 << 1)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_PTS (1 << 2)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_SCR (1 << 3)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_RES (1 << 4)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_STI (1 << 5)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_ERR (1 << 6)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_EOH (1 << 7)
+
+// Common header for all payloads.
+typedef struct {
+ uint8_t bHeaderLength;
+ uint8_t bmHeaderInfo;
+
+} __PACKED usb_video_vs_payload_header;
+
+typedef struct {
+ uint8_t bHeaderLength;
+ uint8_t bmHeaderInfo;
+ uint32_t dwPresentationTime;
+ uint32_t scrSourceTimeClock;
+ // Frame number when the source clock was sampled.
+ uint16_t scrSourceClockSOFCounter;
+} __PACKED usb_video_vs_uncompressed_payload_header;
+
+__END_CDECLS;
+
+
+#endif // SYSROOT_ZIRCON_HW_USB_VIDEO_H_
diff --git a/arch/arm64/sysroot/include/zircon/limits.h b/arch/arm64/sysroot/include/zircon/limits.h
index 4c691a3..f062d5e 100644
--- a/arch/arm64/sysroot/include/zircon/limits.h
+++ b/arch/arm64/sysroot/include/zircon/limits.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_LIMITS_H_
-#define ZIRCON_LIMITS_H_
+#ifndef SYSROOT_ZIRCON_LIMITS_H_
+#define SYSROOT_ZIRCON_LIMITS_H_
#include <stdint.h>
#define ZX_PAGE_SHIFT ((uint32_t)12u)
-#define ZX_PAGE_SIZE ((uint32_t)(1u << ZX_PAGE_SHIFT))
+#define ZX_PAGE_SIZE ((uintptr_t)(1u << ZX_PAGE_SHIFT))
#define ZX_PAGE_MASK (ZX_PAGE_SIZE - 1u)
-#endif // ZIRCON_LIMITS_H_
+#endif // SYSROOT_ZIRCON_LIMITS_H_
diff --git a/arch/arm64/sysroot/include/zircon/listnode.h b/arch/arm64/sysroot/include/zircon/listnode.h
index b987bdf..fb64acf 100644
--- a/arch/arm64/sysroot/include/zircon/listnode.h
+++ b/arch/arm64/sysroot/include/zircon/listnode.h
@@ -2,303 +2,299 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_LISTNODE_H_
+#define SYSROOT_ZIRCON_LISTNODE_H_
-#include <zircon/compiler.h>
#include <stdbool.h>
#include <stddef.h>
+#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
#define containerof(ptr, type, member) ((type*)((uintptr_t)(ptr)-offsetof(type, member)))
typedef struct list_node list_node_t;
struct list_node {
- list_node_t* prev;
- list_node_t* next;
+ list_node_t* prev;
+ list_node_t* next;
};
#define LIST_INITIAL_VALUE(list) \
- { &(list), &(list) }
+ { &(list), &(list) }
#define LIST_INITIAL_CLEARED_VALUE \
- { NULL, NULL }
+ { NULL, NULL }
-static inline void list_initialize(list_node_t* list) {
- list->prev = list->next = list;
-}
+static inline void list_initialize(list_node_t* list) { list->prev = list->next = list; }
-static inline void list_clear_node(list_node_t* item) {
- item->prev = item->next = 0;
-}
+static inline void list_clear_node(list_node_t* item) { item->prev = item->next = 0; }
static inline bool list_in_list(const list_node_t* item) {
- if (item->prev == 0 && item->next == 0)
- return false;
- else
- return true;
+ if (item->prev == 0 && item->next == 0)
+ return false;
+ else
+ return true;
}
static inline void list_add_head(list_node_t* list, list_node_t* item) {
- item->next = list->next;
- item->prev = list;
- list->next->prev = item;
- list->next = item;
+ item->next = list->next;
+ item->prev = list;
+ list->next->prev = item;
+ list->next = item;
}
#define list_add_after(entry, new_entry) list_add_head(entry, new_entry)
static inline void list_add_tail(list_node_t* list, list_node_t* item) {
- item->prev = list->prev;
- item->next = list;
- list->prev->next = item;
- list->prev = item;
+ item->prev = list->prev;
+ item->next = list;
+ list->prev->next = item;
+ list->prev = item;
}
#define list_add_before(entry, new_entry) list_add_tail(entry, new_entry)
static inline void list_delete(list_node_t* item) {
- item->next->prev = item->prev;
- item->prev->next = item->next;
- item->prev = item->next = 0;
+ item->next->prev = item->prev;
+ item->prev->next = item->next;
+ item->prev = item->next = 0;
}
static inline void list_replace_node(list_node_t* old_node, list_node_t* new_node) {
- // replace a spot in a list with a new node
- // assumes old_node is part of a list and new_node is not
- new_node->next = old_node->next;
- new_node->prev = old_node->prev;
- old_node->prev = old_node->next = 0;
+ // replace a spot in a list with a new node
+ // assumes old_node is part of a list and new_node is not
+ new_node->next = old_node->next;
+ new_node->prev = old_node->prev;
+ old_node->prev = old_node->next = 0;
- new_node->next->prev = new_node;
- new_node->prev->next = new_node;
+ new_node->next->prev = new_node;
+ new_node->prev->next = new_node;
}
static inline list_node_t* list_remove_head(list_node_t* list) {
- if (list->next != list) {
- list_node_t* item = list->next;
- list_delete(item);
- return item;
- } else {
- return NULL;
- }
+ if (list->next != list) {
+ list_node_t* item = list->next;
+ list_delete(item);
+ return item;
+ } else {
+ return NULL;
+ }
}
-#define list_remove_head_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_remove_head(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_remove_head_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_remove_head(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_remove_tail(list_node_t* list) {
- if (list->prev != list) {
- list_node_t* item = list->prev;
- list_delete(item);
- return item;
- } else {
- return NULL;
- }
+ if (list->prev != list) {
+ list_node_t* item = list->prev;
+ list_delete(item);
+ return item;
+ } else {
+ return NULL;
+ }
}
-#define list_remove_tail_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_remove_tail(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_remove_tail_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_remove_tail(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
-static inline list_node_t* list_peek_head(list_node_t* list) {
- if (list->next != list) {
- return list->next;
- } else {
- return NULL;
- }
+static inline list_node_t* list_peek_head(const list_node_t* list) {
+ if (list->next != list) {
+ return list->next;
+ } else {
+ return NULL;
+ }
}
-#define list_peek_head_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_peek_head(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_peek_head_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_peek_head(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
-static inline list_node_t* list_peek_tail(list_node_t* list) {
- if (list->prev != list) {
- return list->prev;
- } else {
- return NULL;
- }
+static inline list_node_t* list_peek_tail(const list_node_t* list) {
+ if (list->prev != list) {
+ return list->prev;
+ } else {
+ return NULL;
+ }
}
-#define list_peek_tail_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_peek_tail(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_peek_tail_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_peek_tail(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_prev(list_node_t* list, list_node_t* item) {
- if (item->prev != list)
- return item->prev;
- else
- return NULL;
+ if (item->prev != list)
+ return item->prev;
+ else
+ return NULL;
}
-#define list_prev_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_prev(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_prev_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_prev(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_prev_wrap(list_node_t* list, list_node_t* item) {
- if (item->prev != list)
- return item->prev;
- else if (item->prev->prev != list)
- return item->prev->prev;
- else
- return NULL;
+ if (item->prev != list)
+ return item->prev;
+ else if (item->prev->prev != list)
+ return item->prev->prev;
+ else
+ return NULL;
}
-#define list_prev_wrap_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_prev_wrap(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_prev_wrap_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_prev_wrap(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_next(list_node_t* list, list_node_t* item) {
- if (item->next != list)
- return item->next;
- else
- return NULL;
+ if (item->next != list)
+ return item->next;
+ else
+ return NULL;
}
-#define list_next_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_next(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_next_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_next(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_next_wrap(list_node_t* list, list_node_t* item) {
- if (item->next != list)
- return item->next;
- else if (item->next->next != list)
- return item->next->next;
- else
- return NULL;
+ if (item->next != list)
+ return item->next;
+ else if (item->next->next != list)
+ return item->next->next;
+ else
+ return NULL;
}
-#define list_next_wrap_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_next_wrap(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_next_wrap_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_next_wrap(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
// iterates over the list, node should be list_node_t*
#define list_for_every(list, node) for (node = (list)->next; node != (list); node = node->next)
// iterates over the list in a safe way for deletion of current node
// node and temp_node should be list_node_t*
-#define list_for_every_safe(list, node, temp_node) \
- for (node = (list)->next, temp_node = (node)->next; node != (list); \
- node = temp_node, temp_node = (node)->next)
+#define list_for_every_safe(list, node, temp_node) \
+ for (node = (list)->next, temp_node = (node)->next; node != (list); \
+ node = temp_node, temp_node = (node)->next)
// iterates over the list, entry should be the container structure type *
-#define list_for_every_entry(list, entry, type, member) \
- for ((entry) = containerof((list)->next, type, member); &(entry)->member != (list); \
- (entry) = containerof((entry)->member.next, type, member))
+#define list_for_every_entry(list, entry, type, member) \
+ for ((entry) = containerof((list)->next, type, member); &(entry)->member != (list); \
+ (entry) = containerof((entry)->member.next, type, member))
// iterates over the list in a safe way for deletion of current node
// entry and temp_entry should be the container structure type *
#define list_for_every_entry_safe(list, entry, temp_entry, type, member) \
- for (entry = containerof((list)->next, type, member), \
- temp_entry = containerof((entry)->member.next, type, member); \
- &(entry)->member != (list); \
- entry = temp_entry, temp_entry = containerof((temp_entry)->member.next, type, member))
+ for (entry = containerof((list)->next, type, member), \
+ temp_entry = containerof((entry)->member.next, type, member); \
+ &(entry)->member != (list); \
+ entry = temp_entry, temp_entry = containerof((temp_entry)->member.next, type, member))
static inline bool list_is_empty(const list_node_t* list) {
- return (list->next == list) ? true : false;
+ return (list->next == list) ? true : false;
}
static inline size_t list_length(const list_node_t* list) {
- size_t cnt = 0;
- const list_node_t* node = list;
- list_for_every(list, node) {
- cnt++;
- }
+ size_t cnt = 0;
+ const list_node_t* node = list;
+ list_for_every(list, node) { cnt++; }
- return cnt;
+ return cnt;
}
// Splice the contents of splice_from into the list immediately following pos.
static inline void list_splice_after(list_node_t* splice_from, list_node_t* pos) {
- if (list_is_empty(splice_from)) {
- return;
- }
- splice_from->next->prev = pos;
- splice_from->prev->next = pos->next;
- pos->next->prev = splice_from->prev;
- pos->next = splice_from->next;
- list_initialize(splice_from);
+ if (list_is_empty(splice_from)) {
+ return;
+ }
+ splice_from->next->prev = pos;
+ splice_from->prev->next = pos->next;
+ pos->next->prev = splice_from->prev;
+ pos->next = splice_from->next;
+ list_initialize(splice_from);
}
// Split the contents of list after (but not including) pos, into split_to
// (which should be empty).
-static inline void list_split_after(list_node_t* list, list_node_t* pos,
- list_node_t* split_to) {
- if (pos->next == list) {
- list_initialize(split_to);
- return;
- }
- split_to->prev = list->prev;
- split_to->prev->next = split_to;
- split_to->next = pos->next;
- split_to->next->prev = split_to;
- pos->next = list;
- list->prev = pos;
+static inline void list_split_after(list_node_t* list, list_node_t* pos, list_node_t* split_to) {
+ if (pos->next == list) {
+ list_initialize(split_to);
+ return;
+ }
+ split_to->prev = list->prev;
+ split_to->prev->next = split_to;
+ split_to->next = pos->next;
+ split_to->next->prev = split_to;
+ pos->next = list;
+ list->prev = pos;
}
// Moves all the contents of old_list (which may or may not be empty)
// to new_list (which should be empty).
static inline void list_move(list_node_t* old_list, list_node_t* new_list) {
- list_initialize(new_list);
- list_splice_after(old_list, new_list);
+ list_initialize(new_list);
+ list_splice_after(old_list, new_list);
}
-__END_CDECLS;
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_LISTNODE_H_
diff --git a/arch/arm64/sysroot/include/zircon/lookup.h b/arch/arm64/sysroot/include/zircon/lookup.h
new file mode 100644
index 0000000..fffa781
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/lookup.h
@@ -0,0 +1,34 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_LOOKUP_H_
+#define SYSROOT_ZIRCON_LOOKUP_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+__BEGIN_CDECLS
+
+struct address {
+ int family;
+ unsigned scopeid;
+ uint8_t addr[16];
+ int sortkey;
+};
+
+/* The limit of 48 results is a non-sharp bound on the number of addresses
+ * that can fit in one 512-byte DNS packet full of v4 results and a second
+ * packet full of v6 results. Due to headers, the actual limit is lower. */
+#define MAXADDRS 48
+
+// This function is used by musl to perform an actual DNS lookup - it takes
+// a name and address family, sends a DNS query, and fills out the addresses
+// and canonical name with the response.
+int _getaddrinfo_from_dns(struct address buf[MAXADDRS], char canon[256], const char* name,
+ int family);
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_LOOKUP_H_
diff --git a/arch/arm64/sysroot/include/zircon/pixelformat.h b/arch/arm64/sysroot/include/zircon/pixelformat.h
index 8d15c0c..f28f35f 100644
--- a/arch/arm64/sysroot/include/zircon/pixelformat.h
+++ b/arch/arm64/sysroot/include/zircon/pixelformat.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PIXELFORMAT_H_
-#define ZIRCON_PIXELFORMAT_H_
+#ifndef SYSROOT_ZIRCON_PIXELFORMAT_H_
+#define SYSROOT_ZIRCON_PIXELFORMAT_H_
#include <stdint.h>
@@ -20,7 +20,9 @@
#define ZX_PIXEL_FORMAT_MONO_8 ((zx_pixel_format_t)0x00010007)
#define ZX_PIXEL_FORMAT_GRAY_8 ((zx_pixel_format_t)0x00010007)
#define ZX_PIXEL_FORMAT_NV12 ((zx_pixel_format_t)0x00010008)
-
+#define ZX_PIXEL_FORMAT_RGB_888 ((zx_pixel_format_t)0x00030009)
+#define ZX_PIXEL_FORMAT_ABGR_8888 ((zx_pixel_format_t)0x0004000a)
+#define ZX_PIXEL_FORMAT_BGR_888x ((zx_pixel_format_t)0x0004000b)
#define ZX_PIXEL_FORMAT_BYTES(pf) (((pf) >> 16) & 7)
-#endif // ZIRCON_PIXELFORMAT_H_
+#endif // SYSROOT_ZIRCON_PIXELFORMAT_H_
diff --git a/arch/arm64/sysroot/include/zircon/process.h b/arch/arm64/sysroot/include/zircon/process.h
index bec8a79..ef2bcb1 100644
--- a/arch/arm64/sysroot/include/zircon/process.h
+++ b/arch/arm64/sysroot/include/zircon/process.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PROCESS_H_
-#define ZIRCON_PROCESS_H_
+#ifndef SYSROOT_ZIRCON_PROCESS_H_
+#define SYSROOT_ZIRCON_PROCESS_H_
-#include <zircon/types.h>
#include <stdint.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
@@ -32,4 +32,4 @@
__END_CDECLS
-#endif // ZIRCON_PROCESS_H_
+#endif // SYSROOT_ZIRCON_PROCESS_H_
diff --git a/arch/arm64/sysroot/include/zircon/processargs.h b/arch/arm64/sysroot/include/zircon/processargs.h
index dfc771f..ee99985 100644
--- a/arch/arm64/sysroot/include/zircon/processargs.h
+++ b/arch/arm64/sysroot/include/zircon/processargs.h
@@ -2,95 +2,95 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PROCESSARGS_H_
-#define ZIRCON_PROCESSARGS_H_
+#ifndef SYSROOT_ZIRCON_PROCESSARGS_H_
+#define SYSROOT_ZIRCON_PROCESSARGS_H_
+#include <stdint.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
-#include <stdint.h>
__BEGIN_CDECLS
// This is a protocol for passing state to a new process
// via a message in a channel.
-#define ZX_PROCARGS_PROTOCOL ((uint32_t)0x4150585du) // MXPA
+#define ZX_PROCARGS_PROTOCOL ((uint32_t)0x4150585du) // MXPA
#define ZX_PROCARGS_VERSION ((uint32_t)0x0001000u)
typedef struct zx_proc_args zx_proc_args_t;
struct zx_proc_args {
- // Protocol and version identifiers to allow for
- // different process start message protocols and
- // versioning of the same.
- uint32_t protocol;
- uint32_t version;
+ // Protocol and version identifiers to allow for
+ // different process start message protocols and
+ // versioning of the same.
+ uint32_t protocol;
+ uint32_t version;
- // Offset from start of message to handle info
- // array, which contains one uint32_t per handle
- // passed along with the message.
- uint32_t handle_info_off;
+ // Offset from start of message to handle info
+ // array, which contains one uint32_t per handle
+ // passed along with the message.
+ uint32_t handle_info_off;
- // Offset from start of message to arguments and
- // count of arguments. Arguments are provided as
- // a set of null-terminated utf-8 strings, one
- // after the other.
- uint32_t args_off;
- uint32_t args_num;
+ // Offset from start of message to arguments and
+ // count of arguments. Arguments are provided as
+ // a set of null-terminated utf-8 strings, one
+ // after the other.
+ uint32_t args_off;
+ uint32_t args_num;
- // Offset from start of message to environment strings and count of
- // them. Environment entries are provided as a set of null-terminated
- // UTF-8 strings, one after the other. Canonically each string has
- // the form "NAME=VALUE", but nothing enforces this.
- uint32_t environ_off;
- uint32_t environ_num;
+ // Offset from start of message to environment strings and count of
+ // them. Environment entries are provided as a set of null-terminated
+ // UTF-8 strings, one after the other. Canonically each string has
+ // the form "NAME=VALUE", but nothing enforces this.
+ uint32_t environ_off;
+ uint32_t environ_num;
- // Offset from start of message to name strings and count of them.
- // These strings are packed similar to the argument strings,
- // but are referenced by PA_NS_* handle table entries and used
- // to set up namespaces.
- //
- // Specifically: In a handle table entry with PA_HND_TYPE(info)
- // of PA_NS_*, PA_HND_ARG(info) is an index into this name table.
- uint32_t names_off;
- uint32_t names_num;
+ // Offset from start of message to name strings and count of them.
+ // These strings are packed similar to the argument strings,
+ // but are referenced by PA_NS_* handle table entries and used
+ // to set up namespaces.
+ //
+ // Specifically: In a handle table entry with PA_HND_TYPE(info)
+ // of PA_NS_*, PA_HND_ARG(info) is an index into this name table.
+ uint32_t names_off;
+ uint32_t names_num;
};
// Handle Info entries associate a type and optional
// argument with each handle included in the process
// arguments message.
-#define PA_HND(type, arg) (((type)&0xFF)| (((arg)&0xFFFF)<<16))
-#define PA_HND_TYPE(n) ((n) & 0xFF)
-#define PA_HND_SUBTYPE(n) (((n) >> 8) & 0xFF)
-#define PA_HND_ARG(n) (((n) >> 16) & 0xFFFF)
+#define PA_HND(type, arg) (((type)&0xFF) | (((arg)&0xFFFF) << 16))
+#define PA_HND_TYPE(n) ((n)&0xFF)
+#define PA_HND_ARG(n) (((n) >> 16) & 0xFFFF)
// --- Core Runtime Handles ---
// Used by libc init (or equivalent) and dynamic loader
// Handle to our own process.
-#define PA_PROC_SELF 0x01u
+#define PA_PROC_SELF 0x01u
// Handle to the initial thread of our own process.
-#define PA_THREAD_SELF 0x02u
+#define PA_THREAD_SELF 0x02u
-// Handle to a Job object which can be used to make child processes. The
-// Job can be the same as the one used to create this process or it can
+// Handle to a job object which can be used to make child processes.
+//
+// The job can be the same as the one used to create this process or it can
// be different.
-#define PA_JOB_DEFAULT 0x03u
+#define PA_JOB_DEFAULT 0x03u
// Handle to the root of our address space
-#define PA_VMAR_ROOT 0x04u
+#define PA_VMAR_ROOT 0x04u
// Handle to the VMAR used to load the initial program image.
-#define PA_VMAR_LOADED 0x05u
-
+#define PA_VMAR_LOADED 0x05u
// --- Loader Service and VMO Handles ---
// Used by libc init (or equivalent) and dynamic loader
// Service for loading shared libraries.
+//
// See |fuchsia.ldsvc.Loader| for the interface definition.
-#define PA_LDSVC_LOADER 0x10u
+#define PA_LDSVC_LOADER 0x10u
// Handle to the VMO containing the ELF image of the system vDSO. This
// handle is duplicable, transferable, readable, and executable, but not
@@ -100,7 +100,7 @@
// might create or propagate it on to its children so they can do so.
// Each process's own vDSO was mapped in by its creator before the
// process started, its address passed as an argument to entry point.
-#define PA_VMO_VDSO 0x11u
+#define PA_VMO_VDSO 0x11u
// Handle to the VMO used to map the initial thread's stack. This
// handle usually has all rights. The protocol between process creator
@@ -111,53 +111,66 @@
// calling convention for function entry. Thus the new process can
// compute its exact stack bounds by subtracting the size reported by
// this VMO from the (adjusted back up) initial SP value.
-#define PA_VMO_STACK 0x13u
+#define PA_VMO_STACK 0x13u
// VM object handle for the main executable file
-#define PA_VMO_EXECUTABLE 0x14u
+#define PA_VMO_EXECUTABLE 0x14u
// Used by kernel and userboot during startup
-#define PA_VMO_BOOTDATA 0x1Au
+#define PA_VMO_BOOTDATA 0x1Au
// Used by kernel and userboot during startup
-#define PA_VMO_BOOTFS 0x1Bu
+#define PA_VMO_BOOTFS 0x1Bu
// Used by the kernel to export debug information as a file in bootfs. When
// devmgr starts, it looks for handles of this type, and adds them as files in
// /boot/kernel/<vmo-name>.
-#define PA_VMO_KERNEL_FILE 0x1Cu
-
+#define PA_VMO_KERNEL_FILE 0x1Cu
// --- Namespace Handles ---
// A handle which will handle OPEN requests relative
// to a particular path which is specified by the
// nametable entry referred to by the "arg" field
-#define PA_NS_DIR 0x20u
+#define PA_NS_DIR 0x20u
+// --- File Descriptor Handles ---
-// --- FDIO Handles ---
-// Used by libfdio for passing fdtable, fsroot, etc
+// A handle which will be used as a file descriptor.
+#define PA_FD 0x30u
-// Handle types the fdio library uses
-#define PA_FDIO_REMOTE 0x32u
-#define PA_FDIO_LOGGER 0x35u
-#define PA_FDIO_SOCKET 0x36u
+// -- Lifecyle handle --
+//
+// A Handle to a channel on which the process may receive lifecycle events from
+// the ELF runner by serving the |fuchsia.process.Lifecycle| protocol.
+#define PA_LIFECYCLE 0x3Au
// Server endpoint for handling connection to appmgr services.
-#define PA_DIRECTORY_REQUEST 0x3Bu
+#define PA_DIRECTORY_REQUEST 0x3Bu
// Used by devmgr and devhosts
-#define PA_RESOURCE 0x3Fu
+#define PA_RESOURCE 0x3Fu
+// --- Clock handles ---
+//
+// A clock which provides access to UTC. Used by runtimes which are expected to
+// provide access to UTC via their standard libraries.
+//
+#define PA_CLOCK_UTC 0x40u
+
+// --- Resource handles ---
+#define PA_MMIO_RESOURCE 0x50
+#define PA_IRQ_RESOURCE 0x51
+#define PA_IOPORT_RESOURCE 0x52
+#define PA_SMC_RESOURCE 0x53
// --- Various ---
// Handle types for one-off use and prototyping
-#define PA_USER0 0xF0u
-#define PA_USER1 0xF1u
-#define PA_USER2 0xF2u
+#define PA_USER0 0xF0u
+#define PA_USER1 0xF1u
+#define PA_USER2 0xF2u
__END_CDECLS
-#endif // ZIRCON_PROCESSARGS_H_
+#endif // SYSROOT_ZIRCON_PROCESSARGS_H_
diff --git a/arch/arm64/sysroot/include/zircon/rights.h b/arch/arm64/sysroot/include/zircon/rights.h
index 8c9f021..1cfa768 100644
--- a/arch/arm64/sysroot/include/zircon/rights.h
+++ b/arch/arm64/sysroot/include/zircon/rights.h
@@ -2,34 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_RIGHTS_H_
-#define ZIRCON_RIGHTS_H_
+#ifndef SYSROOT_ZIRCON_RIGHTS_H_
+#define SYSROOT_ZIRCON_RIGHTS_H_
#include <stdint.h>
typedef uint32_t zx_rights_t;
-#define ZX_RIGHT_NONE ((zx_rights_t)0u)
-#define ZX_RIGHT_DUPLICATE ((zx_rights_t)1u << 0)
-#define ZX_RIGHT_TRANSFER ((zx_rights_t)1u << 1)
-#define ZX_RIGHT_READ ((zx_rights_t)1u << 2)
-#define ZX_RIGHT_WRITE ((zx_rights_t)1u << 3)
-#define ZX_RIGHT_EXECUTE ((zx_rights_t)1u << 4)
-#define ZX_RIGHT_MAP ((zx_rights_t)1u << 5)
-#define ZX_RIGHT_GET_PROPERTY ((zx_rights_t)1u << 6)
-#define ZX_RIGHT_SET_PROPERTY ((zx_rights_t)1u << 7)
-#define ZX_RIGHT_ENUMERATE ((zx_rights_t)1u << 8)
-#define ZX_RIGHT_DESTROY ((zx_rights_t)1u << 9)
-#define ZX_RIGHT_SET_POLICY ((zx_rights_t)1u << 10)
-#define ZX_RIGHT_GET_POLICY ((zx_rights_t)1u << 11)
-#define ZX_RIGHT_SIGNAL ((zx_rights_t)1u << 12)
-#define ZX_RIGHT_SIGNAL_PEER ((zx_rights_t)1u << 13)
-#define ZX_RIGHT_WAIT ((zx_rights_t)1u << 14)
-#define ZX_RIGHT_INSPECT ((zx_rights_t)1u << 15)
-#define ZX_RIGHT_MANAGE_JOB ((zx_rights_t)1u << 16)
-#define ZX_RIGHT_MANAGE_PROCESS ((zx_rights_t)1u << 17)
-#define ZX_RIGHT_MANAGE_THREAD ((zx_rights_t)1u << 18)
-#define ZX_RIGHT_APPLY_PROFILE ((zx_rights_t)1u << 19)
-#define ZX_RIGHT_SAME_RIGHTS ((zx_rights_t)1u << 31)
+#define ZX_RIGHT_NONE ((zx_rights_t)0u)
+#define ZX_RIGHT_DUPLICATE ((zx_rights_t)1u << 0)
+#define ZX_RIGHT_TRANSFER ((zx_rights_t)1u << 1)
+#define ZX_RIGHT_READ ((zx_rights_t)1u << 2)
+#define ZX_RIGHT_WRITE ((zx_rights_t)1u << 3)
+#define ZX_RIGHT_EXECUTE ((zx_rights_t)1u << 4)
+#define ZX_RIGHT_MAP ((zx_rights_t)1u << 5)
+#define ZX_RIGHT_GET_PROPERTY ((zx_rights_t)1u << 6)
+#define ZX_RIGHT_SET_PROPERTY ((zx_rights_t)1u << 7)
+#define ZX_RIGHT_ENUMERATE ((zx_rights_t)1u << 8)
+#define ZX_RIGHT_DESTROY ((zx_rights_t)1u << 9)
+#define ZX_RIGHT_SET_POLICY ((zx_rights_t)1u << 10)
+#define ZX_RIGHT_GET_POLICY ((zx_rights_t)1u << 11)
+#define ZX_RIGHT_SIGNAL ((zx_rights_t)1u << 12)
+#define ZX_RIGHT_SIGNAL_PEER ((zx_rights_t)1u << 13)
+#define ZX_RIGHT_WAIT ((zx_rights_t)1u << 14)
+#define ZX_RIGHT_INSPECT ((zx_rights_t)1u << 15)
+#define ZX_RIGHT_MANAGE_JOB ((zx_rights_t)1u << 16)
+#define ZX_RIGHT_MANAGE_PROCESS ((zx_rights_t)1u << 17)
+#define ZX_RIGHT_MANAGE_THREAD ((zx_rights_t)1u << 18)
+#define ZX_RIGHT_APPLY_PROFILE ((zx_rights_t)1u << 19)
+#define ZX_RIGHT_SAME_RIGHTS ((zx_rights_t)1u << 31)
// Convenient names for commonly grouped rights.
#define ZX_RIGHTS_BASIC (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WAIT | ZX_RIGHT_INSPECT)
@@ -40,88 +40,85 @@
#define ZX_RIGHTS_POLICY (ZX_RIGHT_GET_POLICY | ZX_RIGHT_SET_POLICY)
-#define ZX_DEFAULT_CHANNEL_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_DUPLICATE)) | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | \
- ZX_RIGHT_SIGNAL_PEER)
+#define ZX_DEFAULT_CHANNEL_RIGHTS \
+ ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_DUPLICATE)) | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | \
+ ZX_RIGHT_SIGNAL_PEER)
#define ZX_DEFAULT_EVENT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_SYSTEM_EVENT_LOW_MEMORY_RIGHTS \
+ (ZX_RIGHT_WAIT | ZX_RIGHT_DUPLICATE | ZX_RIGHT_TRANSFER)
+
#define ZX_DEFAULT_EVENTPAIR_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
#define ZX_DEFAULT_FIFO_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO |\
- ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
-#define ZX_DEFAULT_GUEST_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE |\
- ZX_RIGHT_INSPECT | ZX_RIGHT_MANAGE_PROCESS)
+#define ZX_DEFAULT_GUEST_RIGHTS \
+ (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE | ZX_RIGHT_INSPECT | \
+ ZX_RIGHT_MANAGE_PROCESS)
#define ZX_DEFAULT_INTERRUPT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_IO_MAPPING_RIGHTS \
- (ZX_RIGHT_READ | ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_IO_MAPPING_RIGHTS (ZX_RIGHT_READ | ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_JOB_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHTS_POLICY | ZX_RIGHT_ENUMERATE | \
- ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_JOB | ZX_RIGHT_MANAGE_PROCESS)
+#define ZX_DEFAULT_JOB_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHTS_POLICY | ZX_RIGHT_ENUMERATE | \
+ ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_JOB | ZX_RIGHT_MANAGE_PROCESS | \
+ ZX_RIGHT_MANAGE_THREAD)
-#define ZX_DEFAULT_LOG_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_LOG_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_PCI_DEVICE_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
+#define ZX_DEFAULT_MSI_RIGHTS (ZX_RIGHTS_BASIC)
-#define ZX_DEFAULT_PCI_INTERRUPT_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_PCI_DEVICE_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
-#define ZX_DEFAULT_PORT_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO)
+#define ZX_DEFAULT_PCI_INTERRUPT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_PROCESS_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_ENUMERATE | ZX_RIGHT_DESTROY | \
- ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_PROCESS | ZX_RIGHT_MANAGE_THREAD)
+#define ZX_DEFAULT_PORT_RIGHTS ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO)
+
+#define ZX_DEFAULT_PROCESS_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_ENUMERATE | ZX_RIGHT_DESTROY | \
+ ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_PROCESS | ZX_RIGHT_MANAGE_THREAD)
#define ZX_DEFAULT_RESOURCE_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE |\
- ZX_RIGHT_INSPECT)
+ (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE | ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_SOCKET_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_GET_PROPERTY |\
- ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
+#define ZX_DEFAULT_SOCKET_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_GET_PROPERTY | ZX_RIGHT_SET_PROPERTY | \
+ ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
-#define ZX_DEFAULT_THREAD_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY |\
- ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_THREAD)
+#define ZX_DEFAULT_STREAM_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_PROPERTY | ZX_RIGHT_SIGNAL)
+
+#define ZX_DEFAULT_THREAD_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | \
+ ZX_RIGHT_MANAGE_THREAD)
#define ZX_DEFAULT_TIMER_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_VCPU_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_EXECUTE | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_VCPU_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_EXECUTE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_VMAR_RIGHTS \
- (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
+#define ZX_DEFAULT_VMAR_RIGHTS (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
-#define ZX_DEFAULT_VMO_RIGHTS\
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY |\
- ZX_RIGHT_EXECUTE | ZX_RIGHT_MAP | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_VMO_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_MAP | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_IOMMU_RIGHTS \
- (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
+#define ZX_DEFAULT_IOMMU_RIGHTS (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
#define ZX_DEFAULT_BTI_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO | ZX_RIGHT_MAP)
+ ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_MAP)
-#define ZX_DEFAULT_PROFILE_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHT_APPLY_PROFILE)
+#define ZX_DEFAULT_PROFILE_RIGHTS ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHT_APPLY_PROFILE)
-#define ZX_DEFAULT_PMT_RIGHTS \
- (ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_PMT_RIGHTS (ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_SUSPEND_TOKEN_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_SUSPEND_TOKEN_RIGHTS (ZX_RIGHT_TRANSFER | ZX_RIGHT_INSPECT)
#define ZX_DEFAULT_PAGER_RIGHTS \
- (ZX_RIGHT_INSPECT | ZX_RIGHT_ENUMERATE | ZX_RIGHT_GET_PROPERTY |\
- ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_TRANSFER)
+ (ZX_RIGHT_INSPECT | ZX_RIGHT_GET_PROPERTY | ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_TRANSFER)
-#endif // ZIRCON_RIGHTS_H_
+#define ZX_DEFAULT_EXCEPTION_RIGHTS (ZX_RIGHT_TRANSFER | ZX_RIGHTS_PROPERTY | ZX_RIGHT_INSPECT)
+
+#define ZX_DEFAULT_CLOCK_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
+
+#endif // SYSROOT_ZIRCON_RIGHTS_H_
diff --git a/arch/arm64/sysroot/include/zircon/sanitizer.h b/arch/arm64/sysroot/include/zircon/sanitizer.h
index 0b0b7a3..c2f2e8e 100644
--- a/arch/arm64/sysroot/include/zircon/sanitizer.h
+++ b/arch/arm64/sysroot/include/zircon/sanitizer.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SANITIZER_H_
+#define SYSROOT_ZIRCON_SANITIZER_H_
// Interfaces declared in this file are intended for the use of sanitizer
// runtime library implementation code. Each sanitizer runtime works only
@@ -38,14 +39,20 @@
// [shadow_base, shadow_limit) Shadow memory, preallocated.
// [0, shadow_base) Shadow gap, cannot be allocated.
typedef struct saniziter_shadow_bounds {
- uintptr_t shadow_base;
- uintptr_t shadow_limit;
- uintptr_t memory_limit;
+ uintptr_t shadow_base;
+ uintptr_t shadow_limit;
+ uintptr_t memory_limit;
} sanitizer_shadow_bounds_t;
// Returns the shadow bounds for the current process.
sanitizer_shadow_bounds_t __sanitizer_shadow_bounds(void);
+// Fill the shadow memory corresponding to [base, base+size) with |value|. The
+// threshold is used as a hint to determine when to switch to a more efficient
+// mechanism when zero-filling large shadow regions. This assumes that both
+// |base| and |size| are aligned to the shadow multiple.
+void __sanitizer_fill_shadow(uintptr_t base, size_t size, uint8_t value, size_t threshold);
+
// Write logging information from the sanitizer runtime. The buffer
// is expected to be printable text with '\n' ending each line.
// Timestamps and globally unique identifiers of the calling process
@@ -58,7 +65,7 @@
// files and their debugging information. The text can contain markup
// around address values that should be resolved symbolically; see
// TODO(mcgrathr) for the format and details of the post-processor.
-void __sanitizer_log_write(const char *buffer, size_t len);
+void __sanitizer_log_write(const char* buffer, size_t len);
// Runtimes that have binary data to publish (e.g. coverage) use this
// interface. The name describes the data sink that will receive this
@@ -80,16 +87,32 @@
// after this call returns. On success, this yields a read-only VMO
// handle from which the contents associated with that name can be
// read; the caller is responsible for closing this handle.
-zx_status_t __sanitizer_get_configuration(const char* config_name,
- zx_handle_t* out_vmo);
+zx_status_t __sanitizer_get_configuration(const char* config_name, zx_handle_t* out_vmo);
// Changes protection of the code in the range of len bytes starting
// from addr. The writable argument specifies whether the code should
// be made writable or not. This function is only valid on ranges within
// the caller's own code segment.
// TODO(phosek) removes this when the proper debugging interface exists.
-zx_status_t __sanitizer_change_code_protection(uintptr_t addr, size_t len,
- bool writable);
+zx_status_t __sanitizer_change_code_protection(uintptr_t addr, size_t len, bool writable);
+
+// This stops all other threads in the process so memory should be quiescent.
+// Then it makes callbacks for memory regions containing non-const global
+// variables, thread stacks, thread registers, and thread-local storage
+// regions (this includes thread_local variables as well as tss_set or
+// pthread_setspecific values). Each callback is optional; no such callbacks
+// are made if a null function pointer is given. The memory region passed to
+// each callback can be accessed only during that single callback and might no
+// longer be valid once the callback returns. Then it makes a final callback
+// before allowing other threads to resume running normally. If there are
+// problems stopping threads, no memory callbacks will be made and the
+// argument to the final callback will get an error code rather than ZX_OK.
+typedef void sanitizer_memory_snapshot_callback_t(void* mem, size_t len, void* arg);
+void __sanitizer_memory_snapshot(sanitizer_memory_snapshot_callback_t* globals,
+ sanitizer_memory_snapshot_callback_t* stacks,
+ sanitizer_memory_snapshot_callback_t* regs,
+ sanitizer_memory_snapshot_callback_t* tls,
+ void (*done)(zx_status_t, void*), void* arg);
// The "hook" interfaces are functions that the sanitizer runtime library
// can define and libc will call. There are default definitions in libc
@@ -106,17 +129,16 @@
// the initial thread has switched to its real thread stack. Since not
// even all of libc's own constructors have run yet, this should not call
// into libc or other library code.
-__EXPORT void __sanitizer_startup_hook(int argc, char** argv, char** envp,
- void* stack_base, size_t stack_size);
+__EXPORT void __sanitizer_startup_hook(int argc, char** argv, char** envp, void* stack_base,
+ size_t stack_size);
// This is called when a new thread has been created but is not yet
// running. Its C11 thrd_t value has been determined and its stack has
// been allocated. All that remains is to actually start the thread
// running (which can fail only in catastrophic bug situations). Its
// return value will be passed to __sanitizer_thread_create_hook, below.
-__EXPORT void* __sanitizer_before_thread_create_hook(
- thrd_t thread, bool detached, const char* name,
- void* stack_base, size_t stack_size);
+__EXPORT void* __sanitizer_before_thread_create_hook(thrd_t thread, bool detached, const char* name,
+ void* stack_base, size_t stack_size);
// This is called after a new thread has been created or creation has
// failed at the final stage; __sanitizer_before_thread_create_hook has
@@ -128,8 +150,7 @@
// <threads.h> thrd_* value), thread creation has failed and the thread
// details reported to __sanitizer_before_thread_create_hook will be
// freed without the thread ever starting.
-__EXPORT void __sanitizer_thread_create_hook(
- void* hook, thrd_t thread, int error);
+__EXPORT void __sanitizer_thread_create_hook(void* hook, thrd_t thread, int error);
// This is called in each new thread as it starts up. The argument is
// the same one returned by __sanitizer_before_thread_create_hook and
@@ -141,4 +162,10 @@
// The argument is the same one passed to __sanitizer_thread_start_hook.
__EXPORT void __sanitizer_thread_exit_hook(void* hook, thrd_t self);
+// This is called with the argument to _exit and its return value
+// is the actual exit status for the process.
+__EXPORT int __sanitizer_process_exit_hook(int status);
+
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SANITIZER_H_
diff --git a/arch/arm64/sysroot/include/zircon/status.h b/arch/arm64/sysroot/include/zircon/status.h
index 5d83c72..798d2b0 100644
--- a/arch/arm64/sysroot/include/zircon/status.h
+++ b/arch/arm64/sysroot/include/zircon/status.h
@@ -15,8 +15,8 @@
//
// For example, zx_status_get_string(ZX_ERR_TIMED_OUT) returns the string
// "ZX_ERR_TIMED_OUT".
-const char* _zx_status_get_string(zx_status_t status);
-const char* zx_status_get_string(zx_status_t status);
+__EXPORT const char* _zx_status_get_string(zx_status_t status);
+__EXPORT const char* zx_status_get_string(zx_status_t status);
#ifdef __cplusplus
}
diff --git a/arch/arm64/sysroot/include/zircon/string_view.h b/arch/arm64/sysroot/include/zircon/string_view.h
new file mode 100644
index 0000000..f54ff2a
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/string_view.h
@@ -0,0 +1,67 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#pragma once
+
+#include <stddef.h>
+#if __cplusplus >= 201103L && __has_include(<type_traits>)
+#include <type_traits>
+#endif
+
+// This represents a UTF-8 string constant provided by the vDSO itself.
+// This pointer remains valid and the string doesn't change for the
+// life of the process (if not the system).
+//
+// This type exists to be the return value type for vDSO functions.
+// In current machine ABIs, it's returned "for free" in two registers.
+// To a C caller, these functions have ABIs indistinguishable from if
+// they simply returned `const char*` so there is no overhead to
+// supporting the explicit-length API as well as the traditional C
+// string API, though it does require writing out `.c_str` in the
+// source. C++ 17 callers can take advantage of direct coercion to
+// the standard std::string_view and std::u8string_view types, which
+// also allows e.g. direct construction of std::string.
+typedef struct {
+ const char* c_str; // UTF-8, guaranteed to be '\0'-terminated.
+ size_t length; // Length, not including the '\0' terminator.
+
+#ifdef __cplusplus
+ // This is ABI-identical to the usual implementation of std::string_view,
+ // when applied to NUL-terminated C strings. But this API doesn't presume
+ // that std::string_view has a particular implementation or exists at all.
+ // For convenience of use without directly using the C++ standard library
+ // API, a templatized implicit coercion is defined to types that have the
+ // API of std::string_view or std::u8string_view. With the most common
+ // implementations, this coercion will be compiled away to nothing.
+ template <
+ typename _T
+#if __cplusplus >= 201103L && __has_include(<type_traits>)
+ ,
+ typename = typename std::enable_if<sizeof(typename _T::value_type) == sizeof(char)>::type
+#endif
+ >
+ operator _T() {
+ // It's preferable to exclude incompatible types via SFINAE so that
+ // the user's diagnostic experience is exactly as if no coercion
+ // operator existed. SFINAE should exclude this definition when a
+ // C++11 <type_traits> is available to define std::enable_if. If
+ // no standard C++ library header is available, this will provide
+ // a specific diagnostic.
+ static_assert(sizeof(typename _T::value_type) == sizeof(char),
+ "zx_string_view_t can be coerced to C++ 17 std::string_view"
+ " or std::u8string_view or types with equivalent API");
+ return {reinterpret_cast<typename _T::const_pointer>(c_str), length};
+ }
+
+ // Preferably zx_string_view_t values should just be coerced to
+ // std::string_view. But it provides the most minimal aspects of
+ // the equivalent API in case a return value expression is used
+ // directly as `zx_foo_string().data()`, for example.
+ using value_type = char;
+ using const_pointer = const char*;
+ using size_type = size_t;
+ const_pointer data() const { return c_str; }
+ size_type size() const { return length; }
+#endif
+} zx_string_view_t;
diff --git a/arch/arm64/sysroot/include/zircon/syscalls.h b/arch/arm64/sysroot/include/zircon/syscalls.h
index b5c0057..9e79e55 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls.h
@@ -2,29 +2,40 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_H_
-#define ZIRCON_SYSCALLS_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_H_
+#define SYSROOT_ZIRCON_SYSCALLS_H_
-#include <zircon/types.h>
-#include <zircon/syscalls/types.h>
-
-#include <zircon/syscalls/pci.h>
+#include <zircon/string_view.h>
#include <zircon/syscalls/object.h>
+#include <zircon/syscalls/pci.h>
#include <zircon/syscalls/profile.h>
+#include <zircon/syscalls/types.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
-#if defined(__clang__)
-#define ZX_SYSCALL_PARAM_ATTR(x) __attribute__((annotate("zx_" #x)))
+#define _ZX_SYSCALL_DECL(name, type, attrs, nargs, arglist, prototype) \
+ extern attrs type zx_##name prototype; \
+ extern attrs type _zx_##name prototype;
+
+#ifdef __clang__
+#define _ZX_SYSCALL_ANNO(attr) __attribute__((attr))
#else
-#define ZX_SYSCALL_PARAM_ATTR(x) // no-op
+#define _ZX_SYSCALL_ANNO(attr) // Nothing for compilers without the support.
#endif
-#include <zircon/syscalls/definitions.h>
+#include <zircon/syscalls/internal/cdecls.inc>
+
+#undef _ZX_SYSCALL_ANNO
+#undef _ZX_SYSCALL_DECL
// Compatibility wrappers for deprecated syscalls also go here, when
// there are any.
+// This DEPRECATED interface is replaced by zx_system_get_version_string.
+zx_status_t zx_system_get_version(char* version, size_t version_size) __LEAF_FN;
+zx_status_t _zx_system_get_version(char* version, size_t version_size) __LEAF_FN;
+
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/clock.h b/arch/arm64/sysroot/include/zircon/syscalls/clock.h
new file mode 100644
index 0000000..eab1cd1
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/syscalls/clock.h
@@ -0,0 +1,90 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
+#define SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
+
+#include <zircon/time.h>
+
+// clang-format off
+
+// Argument version identifiers.
+//
+// All zx_clock_* syscalls which fetch or receive a structure's worth of
+// arguments encode a version number in the options field of the syscall. This
+// version field is in the same location and is the same size for each syscall,
+// so a common set of macros may be used for encoding and decoding.
+#define ZX_CLOCK_ARGS_VERSION_SHIFT ((uint64_t)58u)
+#define ZX_CLOCK_ARGS_VERSION_BITS ((uint64_t)6u)
+#define ZX_CLOCK_ARGS_VERSION_MASK \
+ (((((uint64_t)1) << ZX_CLOCK_ARGS_VERSION_BITS) - 1) << ZX_CLOCK_ARGS_VERSION_SHIFT)
+#define ZX_CLOCK_ARGS_VERSION(_N) \
+ (((uint64_t)(_N) << ZX_CLOCK_ARGS_VERSION_SHIFT) & ZX_CLOCK_ARGS_VERSION_MASK)
+
+// Clock creation options.
+#define ZX_CLOCK_OPT_MONOTONIC ((uint64_t)1u << 0)
+#define ZX_CLOCK_OPT_CONTINUOUS ((uint64_t)1u << 1)
+#define ZX_CLOCK_OPT_AUTO_START ((uint64_t)1u << 2)
+
+#define ZX_CLOCK_OPTS_ALL ( \
+ ZX_CLOCK_OPT_MONOTONIC | \
+ ZX_CLOCK_OPT_CONTINUOUS | \
+ ZX_CLOCK_OPT_AUTO_START)
+
+// Clock update flags
+#define ZX_CLOCK_UPDATE_OPTION_VALUE_VALID ((uint64_t)1u << 0)
+#define ZX_CLOCK_UPDATE_OPTION_RATE_ADJUST_VALID ((uint64_t)1u << 1)
+#define ZX_CLOCK_UPDATE_OPTION_ERROR_BOUND_VALID ((uint64_t)1u << 2)
+
+#define ZX_CLOCK_UPDATE_OPTIONS_ALL ( \
+ ZX_CLOCK_UPDATE_OPTION_VALUE_VALID | \
+ ZX_CLOCK_UPDATE_OPTION_RATE_ADJUST_VALID | \
+ ZX_CLOCK_UPDATE_OPTION_ERROR_BOUND_VALID)
+
+// Clock rate adjustment limits
+#define ZX_CLOCK_UPDATE_MIN_RATE_ADJUST ((int32_t)-1000)
+#define ZX_CLOCK_UPDATE_MAX_RATE_ADJUST ((int32_t)1000)
+
+// Special clock error values
+#define ZX_CLOCK_UNKNOWN_ERROR ((uint64_t)0xFFFFFFFFFFFFFFFF)
+
+// clang-format on
+
+typedef struct zx_clock_create_args_v1 {
+ zx_time_t backstop_time;
+} zx_clock_create_args_v1_t;
+
+typedef struct zx_clock_rate {
+ uint32_t synthetic_ticks;
+ uint32_t reference_ticks;
+} zx_clock_rate_t;
+
+typedef struct zx_clock_transformation {
+ int64_t reference_offset;
+ int64_t synthetic_offset;
+ zx_clock_rate_t rate;
+} zx_clock_transformation_t;
+
+typedef struct zx_clock_details_v1 {
+ uint64_t options;
+ zx_time_t backstop_time;
+ zx_clock_transformation_t ticks_to_synthetic;
+ zx_clock_transformation_t mono_to_synthetic;
+ uint64_t error_bound;
+ zx_ticks_t query_ticks;
+ zx_ticks_t last_value_update_ticks;
+ zx_ticks_t last_rate_adjust_update_ticks;
+ zx_ticks_t last_error_bounds_update_ticks;
+ uint32_t generation_counter;
+ uint8_t padding1[4];
+} zx_clock_details_v1_t;
+
+typedef struct zx_clock_update_args_v1 {
+ int32_t rate_adjust;
+ uint8_t padding1[4];
+ int64_t value;
+ uint64_t error_bound;
+} zx_clock_update_args_v1_t;
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/debug.h b/arch/arm64/sysroot/include/zircon/syscalls/debug.h
index 82ea309..373381f 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/debug.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/debug.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_DEBUG_
-#define ZIRCON_SYSCALLS_DEBUG_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_DEBUG_
+#define SYSROOT_ZIRCON_SYSCALLS_DEBUG_
#include <stdint.h>
#include <zircon/compiler.h>
@@ -14,43 +14,47 @@
// Value for ZX_THREAD_STATE_GENERAL_REGS on x86-64 platforms.
typedef struct zx_thread_state_general_regs {
- uint64_t rax;
- uint64_t rbx;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rsi;
- uint64_t rdi;
- uint64_t rbp;
- uint64_t rsp;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- uint64_t rip;
- uint64_t rflags;
+ uint64_t rax;
+ uint64_t rbx;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rsi;
+ uint64_t rdi;
+ uint64_t rbp;
+ uint64_t rsp;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ uint64_t rip;
+ uint64_t rflags;
+ uint64_t fs_base;
+ uint64_t gs_base;
} zx_thread_state_general_regs_t;
// Value for ZX_THREAD_STATE_FP_REGS on x64. Holds x87 and MMX state.
typedef struct zx_thread_state_fp_regs {
- uint16_t fcw; // Control word.
- uint16_t fsw; // Status word.
- uint8_t ftw; // Tag word.
- uint8_t reserved;
- uint16_t fop; // Opcode.
- uint64_t fip; // Instruction pointer.
- uint64_t fdp; // Data pointer.
+ uint16_t fcw; // Control word.
+ uint16_t fsw; // Status word.
+ uint8_t ftw; // Tag word.
+ uint8_t reserved;
+ uint16_t fop; // Opcode.
+ uint64_t fip; // Instruction pointer.
+ uint64_t fdp; // Data pointer.
- // The x87/MMX state. For x87 the each "st" entry has the low 80 bits used for the register
- // contents. For MMX, the low 64 bits are used. The higher bits are unused.
- __ALIGNED(16)
- struct {
- uint64_t low;
- uint64_t high;
- } st[8];
+ uint8_t padding1[8];
+
+ // The x87/MMX state. For x87 the each "st" entry has the low 80 bits used for the register
+ // contents. For MMX, the low 64 bits are used. The higher bits are unused.
+ __ALIGNED(16)
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } st[8];
} zx_thread_state_fp_regs_t;
// Value for ZX_THREAD_STATE_VECTOR_REGS on x64. Holds SSE and AVX registers.
@@ -58,58 +62,56 @@
// Setting vector registers will only work for threads that have previously executed an
// instruction using the corresponding register class.
typedef struct zx_thread_state_vector_regs {
- // When only 16 registers are supported (pre-AVX-512), zmm[16-31] will be 0.
- // YMM registers (256 bits) are v[0-4], XMM registers (128 bits) are v[0-2].
- struct {
- uint64_t v[8];
- } zmm[32];
+ // When only 16 registers are supported (pre-AVX-512), zmm[16-31] will be 0.
+ // YMM registers (256 bits) are v[0-4], XMM registers (128 bits) are v[0-2].
+ struct {
+ uint64_t v[8];
+ } zmm[32];
- // AVX-512 opmask registers. Will be 0 unless AVX-512 is supported.
- uint64_t opmask[8];
+ // AVX-512 opmask registers. Will be 0 unless AVX-512 is supported.
+ uint64_t opmask[8];
- // SIMD control and status register.
- uint32_t mxcsr;
+ // SIMD control and status register.
+ uint32_t mxcsr;
+
+ uint8_t padding1[4];
} zx_thread_state_vector_regs_t;
// Value for ZX_THREAD_STATE_DEBUG_REGS on x64 platforms.
typedef struct zx_thread_state_debug_regs {
uint64_t dr[4];
// DR4 and D5 are not used.
- uint64_t dr6; // Status register.
- uint64_t dr7; // Control register.
- // TODO(donosoc): These values are deprecated but are still used by zxdb. We debine both values
- // in order to do a soft transition. Delete these values once zxdb has made the
- // update.
- uint64_t dr6_status; // Status register.
- uint64_t dr7_control; // Control register.
+ uint64_t dr6; // Status register.
+ uint64_t dr7; // Control register.
} zx_thread_state_debug_regs_t;
#elif defined(__aarch64__)
// Value for ZX_THREAD_STATE_GENERAL_REGS on ARM64 platforms.
typedef struct zx_thread_state_general_regs {
- uint64_t r[30];
- uint64_t lr;
- uint64_t sp;
- uint64_t pc;
- uint64_t cpsr;
+ uint64_t r[30];
+ uint64_t lr;
+ uint64_t sp;
+ uint64_t pc;
+ uint64_t cpsr;
+ uint64_t tpidr;
} zx_thread_state_general_regs_t;
// Value for ZX_THREAD_STATE_FP_REGS on ARM64 platforms.
// This is unused because vector state is used for all floating point on ARM64.
typedef struct zx_thread_state_fp_regs {
- // Avoids sizing differences for empty structs between C and C++.
- uint32_t unused;
+ // Avoids sizing differences for empty structs between C and C++.
+ uint32_t unused;
} zx_thread_state_fp_regs_t;
// Value for ZX_THREAD_STATE_VECTOR_REGS on ARM64 platforms.
typedef struct zx_thread_state_vector_regs {
- uint32_t fpcr;
- uint32_t fpsr;
- struct {
- uint64_t low;
- uint64_t high;
- } v[32];
+ uint32_t fpcr;
+ uint32_t fpsr;
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } v[32];
} zx_thread_state_vector_regs_t;
// ARMv8-A provides 2 to 16 hardware breakpoint registers.
@@ -122,19 +124,34 @@
// Value for XZ_THREAD_STATE_DEBUG_REGS for ARM64 platforms.
typedef struct zx_thread_state_debug_regs {
struct {
- uint64_t dbgbvr; // HW Breakpoint Value register.
- uint32_t dbgbcr; // HW Breakpoint Control register.
+ uint32_t dbgbcr; // HW Breakpoint Control register.
+ uint8_t padding1[4];
+ uint64_t dbgbvr; // HW Breakpoint Value register.
} hw_bps[AARCH64_MAX_HW_BREAKPOINTS];
// Number of HW Breakpoints in the platform.
// Will be set on read and ignored on write.
- uint8_t hw_bps_count;
+
struct {
- uint64_t dbgwvr; // HW Watchpoint Value register.
- uint32_t dbgwcr; // HW Watchpoint Control register.
+ uint32_t dbgwcr; // HW Watchpoint Control register.
+ uint8_t padding1[4];
+ uint64_t dbgwvr; // HW Watchpoint Value register.
} hw_wps[AARCH64_MAX_HW_WATCHPOINTS];
- // Number of HW Watchpoints in the platform.
+
+ // Faulting Virtual Address for watchpoint exceptions.
+ // Read-only, values are ignored on write.
+ uint64_t far;
+
+ // The esr value since the last exception.
+ // Read-only, values are ignored on write.
+ uint32_t esr;
+
+ // Number of HW Breakpoints/Watchpoints in the platform.
// Will be set on read and ignored on write.
+ uint8_t hw_bps_count;
uint8_t hw_wps_count;
+
+ uint8_t padding1[2];
+
} zx_thread_state_debug_regs_t;
#endif
@@ -149,14 +166,14 @@
// Possible values for "kind" in zx_thread_read_state and zx_thread_write_state.
typedef uint32_t zx_thread_state_topic_t;
-#define ZX_THREAD_STATE_GENERAL_REGS ((uint32_t)0) // zx_thread_state_general_regs_t value.
-#define ZX_THREAD_STATE_FP_REGS ((uint32_t)1) // zx_thread_state_fp_regs_t value.
-#define ZX_THREAD_STATE_VECTOR_REGS ((uint32_t)2) // zx_thread_state_vector_regs_t value.
-#define ZX_THREAD_STATE_DEBUG_REGS ((uint32_t)4) // zx_thread_state_debug_regs_t value.
-#define ZX_THREAD_STATE_SINGLE_STEP ((uint32_t)5) // zx_thread_state_single_step_t value.
-#define ZX_THREAD_X86_REGISTER_FS ((uint32_t)6) // zx_thread_x86_register_fs_t value.
-#define ZX_THREAD_X86_REGISTER_GS ((uint32_t)7) // zx_thread_x86_register_gs_t value.
+#define ZX_THREAD_STATE_GENERAL_REGS ((uint32_t)0) // zx_thread_state_general_regs_t value.
+#define ZX_THREAD_STATE_FP_REGS ((uint32_t)1) // zx_thread_state_fp_regs_t value.
+#define ZX_THREAD_STATE_VECTOR_REGS ((uint32_t)2) // zx_thread_state_vector_regs_t value.
+#define ZX_THREAD_STATE_DEBUG_REGS ((uint32_t)4) // zx_thread_state_debug_regs_t value.
+#define ZX_THREAD_STATE_SINGLE_STEP ((uint32_t)5) // zx_thread_state_single_step_t value.
+#define ZX_THREAD_X86_REGISTER_FS ((uint32_t)6) // zx_thread_x86_register_fs_t value.
+#define ZX_THREAD_X86_REGISTER_GS ((uint32_t)7) // zx_thread_x86_register_gs_t value.
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_DEBUG_
+#endif // SYSROOT_ZIRCON_SYSCALLS_DEBUG_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/definitions.h b/arch/arm64/sysroot/include/zircon/syscalls/definitions.h
deleted file mode 100644
index 70da713..0000000
--- a/arch/arm64/sysroot/include/zircon/syscalls/definitions.h
+++ /dev/null
@@ -1,1839 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// This is a GENERATED file, see //zircon/system/host/abigen.
-// The license governing this file can be found in the LICENSE file.
-
-extern zx_time_t zx_clock_get(
- zx_clock_t clock_id) __LEAF_FN;
-
-extern zx_time_t _zx_clock_get(
- zx_clock_t clock_id) __LEAF_FN;
-
-extern zx_status_t zx_clock_get_new(
- zx_clock_t clock_id,
- zx_time_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_clock_get_new(
- zx_clock_t clock_id,
- zx_time_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_time_t zx_clock_get_monotonic(
- void) __LEAF_FN;
-
-extern zx_time_t _zx_clock_get_monotonic(
- void) __LEAF_FN;
-
-extern zx_status_t zx_nanosleep(
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_nanosleep(
- zx_time_t deadline) __LEAF_FN;
-
-extern uint64_t zx_ticks_get(
- void) __LEAF_FN;
-
-extern uint64_t _zx_ticks_get(
- void) __LEAF_FN;
-
-extern uint64_t zx_ticks_per_second(
- void) __LEAF_FN __CONST;
-
-extern uint64_t _zx_ticks_per_second(
- void) __LEAF_FN __CONST;
-
-extern zx_time_t zx_deadline_after(
- zx_duration_t nanoseconds) __LEAF_FN;
-
-extern zx_time_t _zx_deadline_after(
- zx_duration_t nanoseconds) __LEAF_FN;
-
-extern zx_status_t zx_clock_adjust(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_clock_t clock_id,
- int64_t offset) __LEAF_FN;
-
-extern zx_status_t _zx_clock_adjust(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_clock_t clock_id,
- int64_t offset) __LEAF_FN;
-
-extern uint32_t zx_system_get_dcache_line_size(
- void) __LEAF_FN __CONST;
-
-extern uint32_t _zx_system_get_dcache_line_size(
- void) __LEAF_FN __CONST;
-
-extern uint32_t zx_system_get_num_cpus(
- void) __LEAF_FN __CONST;
-
-extern uint32_t _zx_system_get_num_cpus(
- void) __LEAF_FN __CONST;
-
-extern zx_status_t zx_system_get_version(
- char* version,
- size_t version_size) __LEAF_FN;
-
-extern zx_status_t _zx_system_get_version(
- char* version,
- size_t version_size) __LEAF_FN;
-
-extern uint64_t zx_system_get_physmem(
- void) __LEAF_FN;
-
-extern uint64_t _zx_system_get_physmem(
- void) __LEAF_FN;
-
-extern zx_status_t zx_system_get_features(
- uint32_t kind,
- ZX_SYSCALL_PARAM_ATTR(features) uint32_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_system_get_features(
- uint32_t kind,
- ZX_SYSCALL_PARAM_ATTR(features) uint32_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_cache_flush(
- const void* addr,
- size_t size,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_cache_flush(
- const void* addr,
- size_t size,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_handle_close(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_handle_close(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_handle_close_many(
- const zx_handle_t* handles,
- size_t num_handles) __LEAF_FN;
-
-extern zx_status_t _zx_handle_close_many(
- const zx_handle_t* handles,
- size_t num_handles) __LEAF_FN;
-
-extern zx_status_t zx_handle_duplicate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_handle_duplicate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_handle_replace(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_handle_replace(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_one(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_signals_t signals,
- zx_time_t deadline,
- zx_signals_t* observed) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_one(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_signals_t signals,
- zx_time_t deadline,
- zx_signals_t* observed) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_many(
- zx_wait_item_t* items,
- size_t count,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_many(
- zx_wait_item_t* items,
- size_t count,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_async(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- zx_signals_t signals,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_async(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- zx_signals_t signals,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_object_signal(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t _zx_object_signal(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t zx_object_signal_peer(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t _zx_object_signal_peer(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t zx_object_get_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t zx_object_set_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- const void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- const void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t zx_object_set_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t cookie) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t cookie) __LEAF_FN;
-
-extern zx_status_t zx_object_get_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t* cookie) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t* cookie) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_object_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t topic,
- void* buffer,
- size_t buffer_size,
- size_t* actual_count,
- size_t* avail_count) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t topic,
- void* buffer,
- size_t buffer_size,
- size_t* actual_count,
- size_t* avail_count) __LEAF_FN;
-
-extern zx_status_t zx_object_get_child(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t koid,
- zx_rights_t rights,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_child(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t koid,
- zx_rights_t rights,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_object_set_profile(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t profile,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_profile(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t profile,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_channel_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_channel_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_channel_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_read_etc(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_info_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_read_etc(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_info_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* bytes,
- uint32_t num_bytes,
- const zx_handle_t* handles,
- uint32_t num_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* bytes,
- uint32_t num_bytes,
- const zx_handle_t* handles,
- uint32_t num_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t deadline,
- const zx_channel_call_args_t* args,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_channel_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t deadline,
- const zx_channel_call_args_t* args,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_socket_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_socket_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_socket_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t _zx_socket_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t zx_socket_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t _zx_socket_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t zx_socket_share(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t socket_to_share) __LEAF_FN;
-
-extern zx_status_t _zx_socket_share(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t socket_to_share) __LEAF_FN;
-
-extern zx_status_t zx_socket_accept(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_socket) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_socket_accept(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_socket) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_socket_shutdown(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_socket_shutdown(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options) __LEAF_FN;
-
-extern void zx_thread_exit(
- void) __LEAF_FN __NO_RETURN;
-
-extern void _zx_thread_exit(
- void) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_thread_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t process,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_thread_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t process,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_thread_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t thread_entry,
- zx_vaddr_t stack,
- uintptr_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t _zx_thread_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t thread_entry,
- zx_vaddr_t stack,
- uintptr_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t zx_thread_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_thread_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_thread_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_thread_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_thread_set_priority(
- int32_t prio) __LEAF_FN;
-
-extern zx_status_t _zx_thread_set_priority(
- int32_t prio) __LEAF_FN;
-
-extern void zx_process_exit(
- int64_t retcode) __LEAF_FN __NO_RETURN;
-
-extern void _zx_process_exit(
- int64_t retcode) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_process_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* proc_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_process_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* proc_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_process_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t thread,
- zx_vaddr_t entry,
- zx_vaddr_t stack,
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t _zx_process_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t thread,
- zx_vaddr_t entry,
- zx_vaddr_t stack,
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t zx_process_read_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_process_read_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_process_write_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_process_write_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_job_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_job,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_job_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_job,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_job_set_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- uint32_t options,
- uint32_t topic,
- const void* policy,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t _zx_job_set_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- uint32_t options,
- uint32_t topic,
- const void* policy,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t zx_task_bind_exception_port(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_task_bind_exception_port(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_task_suspend(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_task_suspend(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_task_suspend_token(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_task_suspend_token(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_task_resume_from_exception(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_task_resume_from_exception(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_task_kill(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_task_kill(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_event_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_event_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_eventpair_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_eventpair_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_futex_wait(
- const zx_futex_t* value_ptr,
- zx_futex_t current_value,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_futex_owner,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wait(
- const zx_futex_t* value_ptr,
- zx_futex_t current_value,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_futex_owner,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_futex_wake(
- const zx_futex_t* value_ptr,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wake(
- const zx_futex_t* value_ptr,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t zx_futex_wake_single_owner(
- const zx_futex_t* value_ptr) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wake_single_owner(
- const zx_futex_t* value_ptr) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue_single_owner(
- const zx_futex_t* wake_ptr,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue_single_owner(
- const zx_futex_t* wake_ptr,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t zx_futex_get_owner(
- const zx_futex_t* value_ptr,
- zx_koid_t* koid) __LEAF_FN;
-
-extern zx_status_t _zx_futex_get_owner(
- const zx_futex_t* value_ptr,
- zx_koid_t* koid) __LEAF_FN;
-
-extern zx_status_t zx_futex_wait_deprecated(
- const zx_futex_t* value_ptr,
- int32_t current_value,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wait_deprecated(
- const zx_futex_t* value_ptr,
- int32_t current_value,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue_deprecated(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- int32_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue_deprecated(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- int32_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count) __LEAF_FN;
-
-extern zx_status_t zx_port_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_port_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_port_queue(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t _zx_port_queue(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t zx_port_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t _zx_port_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t zx_port_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t source,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t _zx_port_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t source,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t zx_timer_create(
- uint32_t options,
- zx_clock_t clock_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_timer_create(
- uint32_t options,
- zx_clock_t clock_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_timer_set(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_duration_t slack) __LEAF_FN;
-
-extern zx_status_t _zx_timer_set(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_duration_t slack) __LEAF_FN;
-
-extern zx_status_t zx_timer_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_timer_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create(
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create(
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_get_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t* size) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_get_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t* size) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_set_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_set_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_op_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t op,
- uint64_t offset,
- uint64_t size,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_op_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t op,
- uint64_t offset,
- uint64_t size,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_clone(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_clone(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_set_cache_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t cache_policy) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_set_cache_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t cache_policy) __LEAF_FN;
-
-extern zx_status_t zx_vmo_replace_as_executable(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmex,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_replace_as_executable(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmex,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_allocate_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- uint64_t offset,
- uint64_t size,
- uint32_t map_flags,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_allocate_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- uint64_t offset,
- uint64_t size,
- uint32_t map_flags,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_map_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- uint32_t map_flags,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_map_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- uint32_t map_flags,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_protect_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len,
- uint32_t prot_flags) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_protect_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len,
- uint32_t prot_flags) __LEAF_FN;
-
-extern zx_status_t zx_vmar_allocate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- zx_vm_option_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_allocate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- zx_vm_option_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_vmar_map(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_map(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_unmap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_unmap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t zx_vmar_protect(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_protect(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern void zx_cprng_draw(
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern void _zx_cprng_draw(
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_cprng_add_entropy(
- const void* buffer,
- size_t len) __LEAF_FN;
-
-extern zx_status_t _zx_cprng_add_entropy(
- const void* buffer,
- size_t len) __LEAF_FN;
-
-extern zx_status_t zx_fifo_create(
- size_t elem_count,
- size_t elem_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((4, 5)) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_create(
- size_t elem_count,
- size_t elem_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((4, 5)) __LEAF_FN;
-
-extern zx_status_t zx_fifo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t zx_fifo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- const void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- const void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t zx_profile_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const zx_profile_info_t* profile,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_profile_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const zx_profile_info_t* profile,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_unmap_handle_close_thread_exit(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmar_handle,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_unmap_handle_close_thread_exit(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmar_handle,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN;
-
-extern void zx_futex_wake_handle_close_thread_exit(
- const zx_futex_t* value_ptr,
- uint32_t count,
- int32_t new_value,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN __NO_RETURN;
-
-extern void _zx_futex_wake_handle_close_thread_exit(
- const zx_futex_t* value_ptr,
- uint32_t count,
- int32_t new_value,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_log_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- const void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_log_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- const void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_log_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_log_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* data,
- uint32_t offset,
- size_t data_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* data,
- uint32_t offset,
- size_t data_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t action,
- uint32_t options,
- void* ptr) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t action,
- uint32_t options,
- void* ptr) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t id,
- uint32_t arg0,
- uint32_t arg1) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t id,
- uint32_t arg0,
- uint32_t arg1) __LEAF_FN;
-
-extern zx_status_t zx_mtrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- uint32_t action,
- uint32_t options,
- void* ptr,
- size_t ptr_size) __LEAF_FN;
-
-extern zx_status_t _zx_mtrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- uint32_t action,
- uint32_t options,
- void* ptr,
- size_t ptr_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- char* buffer,
- size_t* buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- char* buffer,
- size_t* buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_write(
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_write(
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_send_command(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_send_command(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t src_obj,
- uint32_t src_num,
- uint32_t options,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t src_obj,
- uint32_t src_num,
- uint32_t options,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_bind(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_bind(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t* out_timestamp) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t* out_timestamp) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_ack(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_ack(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_trigger(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t timestamp) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_trigger(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t timestamp) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_bind_vcpu(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vcpu,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_bind_vcpu(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vcpu,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_ioports_request(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint16_t io_addr,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t _zx_ioports_request(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint16_t io_addr,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create_contiguous(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bti,
- size_t size,
- uint32_t alignment_log2,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create_contiguous(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bti,
- size_t size,
- uint32_t alignment_log2,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create_physical(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- zx_paddr_t paddr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create_physical(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- zx_paddr_t paddr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_iommu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t type,
- const void* desc,
- size_t desc_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_iommu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t type,
- const void* desc,
- size_t desc_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_bti_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t iommu,
- uint32_t options,
- uint64_t bti_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_bti_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t iommu,
- uint32_t options,
- uint64_t bti_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_bti_pin(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t offset,
- uint64_t size,
- zx_paddr_t* addrs,
- size_t addrs_count,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((8)) __LEAF_FN;
-
-extern zx_status_t _zx_bti_pin(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t offset,
- uint64_t size,
- zx_paddr_t* addrs,
- size_t addrs_count,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((8)) __LEAF_FN;
-
-extern zx_status_t zx_bti_release_quarantine(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_bti_release_quarantine(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_pmt_unpin(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_pmt_unpin(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_framebuffer_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t* format,
- uint32_t* width,
- uint32_t* height,
- uint32_t* stride) __NONNULL((2, 3, 4, 5)) __LEAF_FN;
-
-extern zx_status_t _zx_framebuffer_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t* format,
- uint32_t* width,
- uint32_t* height,
- uint32_t* stride) __NONNULL((2, 3, 4, 5)) __LEAF_FN;
-
-extern zx_status_t zx_framebuffer_set_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint32_t len,
- uint32_t format,
- uint32_t width,
- uint32_t height,
- uint32_t stride) __LEAF_FN;
-
-extern zx_status_t _zx_framebuffer_set_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint32_t len,
- uint32_t format,
- uint32_t width,
- uint32_t height,
- uint32_t stride) __LEAF_FN;
-
-extern zx_status_t zx_pci_get_nth_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t index,
- zx_pcie_device_info_t* out_info,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_get_nth_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t index,
- zx_pcie_device_info_t* out_info,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t zx_pci_enable_bus_master(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool enable) __LEAF_FN;
-
-extern zx_status_t _zx_pci_enable_bus_master(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool enable) __LEAF_FN;
-
-extern zx_status_t zx_pci_reset_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_pci_reset_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_pci_config_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t* out_val) __LEAF_FN;
-
-extern zx_status_t _zx_pci_config_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t* out_val) __LEAF_FN;
-
-extern zx_status_t zx_pci_config_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t val) __LEAF_FN;
-
-extern zx_status_t _zx_pci_config_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t val) __LEAF_FN;
-
-extern zx_status_t zx_pci_cfg_pio_rw(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint8_t bus,
- uint8_t dev,
- uint8_t func,
- uint8_t offset,
- uint32_t* val,
- size_t width,
- bool write) __LEAF_FN;
-
-extern zx_status_t _zx_pci_cfg_pio_rw(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint8_t bus,
- uint8_t dev,
- uint8_t func,
- uint8_t offset,
- uint32_t* val,
- size_t width,
- bool write) __LEAF_FN;
-
-extern zx_status_t zx_pci_get_bar(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t bar_num,
- zx_pci_bar_t* out_bar,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_get_bar(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t bar_num,
- zx_pci_bar_t* out_bar,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_pci_map_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- int32_t which_irq,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_map_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- int32_t which_irq,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_pci_query_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t* out_max_irqs) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_query_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t* out_max_irqs) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_pci_set_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t requested_irq_count) __LEAF_FN;
-
-extern zx_status_t _zx_pci_set_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t requested_irq_count) __LEAF_FN;
-
-extern zx_status_t zx_pci_init(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_pci_init_arg_t* init_buf,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t _zx_pci_init(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_pci_init_arg_t* init_buf,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t zx_pci_add_subtract_io_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool mmio,
- uint64_t base,
- uint64_t len,
- bool add) __LEAF_FN;
-
-extern zx_status_t _zx_pci_add_subtract_io_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool mmio,
- uint64_t base,
- uint64_t len,
- bool add) __LEAF_FN;
-
-extern zx_status_t zx_pc_firmware_tables(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_paddr_t* acpi_rsdp,
- zx_paddr_t* smbios) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_pc_firmware_tables(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_paddr_t* acpi_rsdp,
- zx_paddr_t* smbios) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_smc_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_smc_parameters_t* parameters,
- zx_smc_result_t* out_smc_result) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_smc_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_smc_parameters_t* parameters,
- zx_smc_result_t* out_smc_result) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_resource_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_rsrc,
- uint32_t options,
- uint64_t base,
- size_t size,
- const char* name,
- size_t name_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* resource_out) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_resource_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_rsrc,
- uint32_t options,
- uint64_t base,
- size_t size,
- const char* name,
- size_t name_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* resource_out) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_guest_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* guest_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t _zx_guest_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* guest_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t zx_guest_set_trap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t _zx_guest_set_trap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t guest,
- uint32_t options,
- zx_vaddr_t entry,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t guest,
- uint32_t options,
- zx_vaddr_t entry,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_resume(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_port_packet_t* packet) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_resume(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_port_packet_t* packet) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t vector) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t vector) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_system_mexec(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t kernel,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bootimage) __LEAF_FN;
-
-extern zx_status_t _zx_system_mexec(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t kernel,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bootimage) __LEAF_FN;
-
-extern zx_status_t zx_system_mexec_payload_get(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_system_mexec_payload_get(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_system_powerctl(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t cmd,
- const zx_system_powerctl_arg_t* arg) __LEAF_FN;
-
-extern zx_status_t _zx_system_powerctl(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t cmd,
- const zx_system_powerctl_arg_t* arg) __LEAF_FN;
-
-extern zx_status_t zx_pager_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(pager) zx_handle_t* out_pager) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_pager_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(pager) zx_handle_t* out_pager) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_pager_create_vmo(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t pager,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(out_pager_vmo) zx_handle_t* out_pager_vmo) __NONNULL((6)) __LEAF_FN;
-
-extern zx_status_t _zx_pager_create_vmo(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t pager,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(out_pager_vmo) zx_handle_t* out_pager_vmo) __NONNULL((6)) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_0(
- void) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_0(
- void) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_1(
- int a) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_1(
- int a) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_2(
- int a,
- int b) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_2(
- int a,
- int b) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_3(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_3(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_4(
- int a,
- int b,
- int c,
- int d) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_4(
- int a,
- int b,
- int c,
- int d) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_5(
- int a,
- int b,
- int c,
- int d,
- int e) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_5(
- int a,
- int b,
- int c,
- int d,
- int e) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_6(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_6(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_7(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_7(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_8(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g,
- int h) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_8(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g,
- int h) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_wrapper(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_wrapper(
- int a,
- int b,
- int c) __LEAF_FN;
-
-
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/exception.h b/arch/arm64/sysroot/include/zircon/syscalls/exception.h
index 4ddf2fb..6191e0f 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/exception.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/exception.h
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_EXCEPTION_H_
-#define ZIRCON_SYSCALLS_EXCEPTION_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
+#define SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
#include <zircon/compiler.h>
-#include <zircon/syscalls/port.h>
#include <zircon/types.h>
__BEGIN_CDECLS
@@ -14,63 +13,60 @@
// ask clang format not to mess up the indentation:
// clang-format off
-// This bit is set for synthetic exceptions to distinguish them from
-// architectural exceptions.
-// Note: Port packet types provide 8 bits to distinguish the exception type.
-// See zircon/port.h.
-#define ZX_EXCP_SYNTH ((uint8_t)0x80)
+// The following exception values were chosen for historical reasons.
-// The kind of an exception.
-// Exception types are a subset of port packet types. See zircon/port.h.
-
-// These are architectural exceptions.
+// Architectural exceptions.
+//
// Depending on the exception, further information can be found in
// |report.context.arch|.
-// General exception not covered by another value.
-#define ZX_EXCP_GENERAL ZX_PKT_TYPE_EXCEPTION(0)
-#define ZX_EXCP_FATAL_PAGE_FAULT ZX_PKT_TYPE_EXCEPTION(1)
-#define ZX_EXCP_UNDEFINED_INSTRUCTION ZX_PKT_TYPE_EXCEPTION(2)
-#define ZX_EXCP_SW_BREAKPOINT ZX_PKT_TYPE_EXCEPTION(3)
-#define ZX_EXCP_HW_BREAKPOINT ZX_PKT_TYPE_EXCEPTION(4)
-#define ZX_EXCP_UNALIGNED_ACCESS ZX_PKT_TYPE_EXCEPTION(5)
+#define ZX_EXCP_GENERAL ((uint32_t) 0x008u)
+#define ZX_EXCP_FATAL_PAGE_FAULT ((uint32_t) 0x108u)
+#define ZX_EXCP_UNDEFINED_INSTRUCTION ((uint32_t) 0x208u)
+#define ZX_EXCP_SW_BREAKPOINT ((uint32_t) 0x308u)
+#define ZX_EXCP_HW_BREAKPOINT ((uint32_t) 0x408u)
+#define ZX_EXCP_UNALIGNED_ACCESS ((uint32_t) 0x508u)
// Synthetic exceptions.
+// These bits are set for synthetic exceptions to distinguish them from
+// architectural exceptions.
+#define ZX_EXCP_SYNTH ((uint32_t) 0x8000u)
+
// A thread is starting.
-// This exception is sent to debuggers only (ZX_EXCEPTION_PORT_TYPE_DEBUGGER).
-// The thread is paused until it is resumed by the debugger
-// with zx_task_resume_from_exception.
-#define ZX_EXCP_THREAD_STARTING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 0)
+// This exception is sent to debuggers only (ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER).
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_THREAD_STARTING ((uint32_t) 0x008u | ZX_EXCP_SYNTH)
// A thread is exiting.
-// This exception is sent to debuggers only (ZX_EXCEPTION_PORT_TYPE_DEBUGGER).
+// This exception is sent to debuggers only (ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER).
// This exception is different from ZX_EXCP_GONE in that a debugger can
// still examine thread state.
-// The thread is paused until it is resumed by the debugger
-// with zx_task_resume_from_exception.
-#define ZX_EXCP_THREAD_EXITING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 1)
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_THREAD_EXITING ((uint32_t) 0x108u | ZX_EXCP_SYNTH)
// This exception is generated when a syscall fails with a job policy
// error (for example, an invalid handle argument is passed to the
// syscall when the ZX_POL_BAD_HANDLE policy is enabled) and
-// ZX_POL_ACTION_EXCEPTION is set for the policy. The thread that
-// invoked the syscall may be resumed with zx_task_resume_from_exception.
-#define ZX_EXCP_POLICY_ERROR ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 2)
+// ZX_POL_ACTION_EXCEPTION is set for the policy.
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_POLICY_ERROR ((uint32_t) 0x208u | ZX_EXCP_SYNTH)
// A process is starting.
// This exception is sent to job debuggers only
-// (ZX_EXCEPTION_PORT_TYPE_JOB_DEBUGGER).
-// The initial thread is paused until it is resumed by the debugger with
-// zx_task_resume_from_exception.
-#define ZX_EXCP_PROCESS_STARTING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 3)
+// (ZX_EXCEPTION_CHANNEL_TYPE_JOB_DEBUGGER).
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_PROCESS_STARTING ((uint32_t) 0x308u | ZX_EXCP_SYNTH)
typedef uint32_t zx_excp_type_t;
-// Assuming |excp| is an exception type, return non-zero if it is an
-// architectural exception.
-#define ZX_EXCP_IS_ARCH(excp) \
- (((excp) & (ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH) & ~ZX_PKT_TYPE_MASK)) == 0)
+// Assuming |excp| is an exception type, the following returns true if the
+// type is architectural.
+#define ZX_EXCP_IS_ARCH(excp) (((excp) & ZX_EXCP_SYNTH) == 0)
typedef struct zx_x86_64_exc_data {
uint64_t vector;
@@ -80,6 +76,7 @@
typedef struct zx_arm64_exc_data {
uint32_t esr;
+ uint8_t padding1[4];
uint64_t far;
} zx_arm64_exc_data_t;
@@ -90,7 +87,10 @@
struct {
union {
zx_x86_64_exc_data_t x86_64;
- zx_arm64_exc_data_t arm_64;
+ struct {
+ zx_arm64_exc_data_t arm_64;
+ uint8_t padding1[8];
+ };
} u;
} arch;
} zx_exception_context_t;
@@ -110,26 +110,27 @@
zx_exception_context_t context;
} zx_exception_report_t;
-// Options for zx_task_resume_from_exception()
-#define ZX_RESUME_TRY_NEXT ((uint32_t)2)
-// Indicates that instead of resuming from the faulting instruction we instead
-// let the next exception handler in the search order, if any, process the
-// exception. If there are no more then the entire process is killed.
+// Basic info sent along with the handle over an exception channel.
+typedef struct zx_exception_info {
+ zx_koid_t pid;
+ zx_koid_t tid;
+ zx_excp_type_t type;
+ uint8_t padding1[4];
+} zx_exception_info_t;
-// Options for zx_task_bind_exception_port.
-#define ZX_EXCEPTION_PORT_DEBUGGER ((uint32_t)1)
-// When binding an exception port to a process, set the process's debugger
-// exception port.
+// Options for zx_create_exception_channel.
+// When creating an exception channel, use the task's debug channel.
+#define ZX_EXCEPTION_CHANNEL_DEBUGGER ((uint32_t)1)
-// The type of exception port a thread may be waiting for a response from.
-// These values are reported in zx_info_thread_t.wait_exception_port_type.
-#define ZX_EXCEPTION_PORT_TYPE_NONE ((uint32_t)0u)
-#define ZX_EXCEPTION_PORT_TYPE_DEBUGGER ((uint32_t)1u)
-#define ZX_EXCEPTION_PORT_TYPE_THREAD ((uint32_t)2u)
-#define ZX_EXCEPTION_PORT_TYPE_PROCESS ((uint32_t)3u)
-#define ZX_EXCEPTION_PORT_TYPE_JOB ((uint32_t)4u)
-#define ZX_EXCEPTION_PORT_TYPE_JOB_DEBUGGER ((uint32_t)5u)
+// The type of exception handler a thread may be waiting for a response from.
+// These values are reported in zx_info_thread_t.wait_exception_channel_type.
+#define ZX_EXCEPTION_CHANNEL_TYPE_NONE ((uint32_t)0u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER ((uint32_t)1u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_THREAD ((uint32_t)2u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_PROCESS ((uint32_t)3u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_JOB ((uint32_t)4u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_JOB_DEBUGGER ((uint32_t)5u)
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_EXCEPTION_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h b/arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h
index a62de92..f574d4e 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
+#define SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
#include <assert.h>
@@ -27,41 +28,51 @@
// Structure to read and write VCPU state.
typedef struct zx_vcpu_state {
#if __aarch64__
- uint64_t x[31];
- uint64_t sp;
- // Contains only the user-controllable upper 4-bits (NZCV).
- uint32_t cpsr;
+ uint64_t x[31];
+ uint64_t sp;
+ // Contains only the user-controllable upper 4-bits (NZCV).
+ uint32_t cpsr;
+ uint8_t padding1[4];
#elif __x86_64__
- uint64_t rax;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rbx;
- uint64_t rsp;
- uint64_t rbp;
- uint64_t rsi;
- uint64_t rdi;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- // Contains only the user-controllable lower 32-bits.
- uint64_t rflags;
+ uint64_t rax;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rbx;
+ uint64_t rsp;
+ uint64_t rbp;
+ uint64_t rsi;
+ uint64_t rdi;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ // Contains only the user-controllable lower 32-bits.
+ uint64_t rflags;
#endif
} zx_vcpu_state_t;
// Structure to read and write VCPU state for IO ports.
typedef struct zx_vcpu_io {
- uint8_t access_size;
- union {
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
- uint8_t data[4];
+ uint8_t access_size;
+ uint8_t padding1[3];
+ union {
+ struct {
+ uint8_t u8;
+ uint8_t padding2[3];
};
+ struct {
+ uint16_t u16;
+ uint8_t padding3[2];
+ };
+ uint32_t u32;
+ uint8_t data[4];
+ };
} zx_vcpu_io_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc b/arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc
new file mode 100644
index 0000000..63510b9
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc
@@ -0,0 +1,1090 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// WARNING: THIS FILE IS MACHINE GENERATED BY //tools/kazoo. DO NOT EDIT.
+
+#ifndef _ZX_SYSCALL_DECL
+#error "<zircon/syscalls.h> is the public API header"
+#endif
+
+_ZX_SYSCALL_DECL(bti_create, zx_status_t, /* no attributes */, 4,
+ (iommu, options, bti_id, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t iommu,
+ uint32_t options,
+ uint64_t bti_id,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(bti_pin, zx_status_t, /* no attributes */, 8,
+ (handle, options, vmo, offset, size, addrs, num_addrs, pmt), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint64_t offset,
+ uint64_t size,
+ zx_paddr_t* addrs,
+ size_t num_addrs,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* pmt))
+
+_ZX_SYSCALL_DECL(bti_release_quarantine, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(cache_flush, zx_status_t, /* no attributes */, 3,
+ (addr, size, options), (
+ const void* addr,
+ size_t size,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(channel_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(channel_read, zx_status_t, /* no attributes */, 8,
+ (handle, options, bytes, handles, num_bytes, num_handles, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("FuchsiaUnchecked")) zx_handle_t handle,
+ uint32_t options,
+ void* bytes,
+ _ZX_SYSCALL_ANNO(acquire_handle("FuchsiaUnchecked")) zx_handle_t* handles,
+ uint32_t num_bytes,
+ uint32_t num_handles,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_read_etc, zx_status_t, /* no attributes */, 8,
+ (handle, options, bytes, handles, num_bytes, num_handles, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* bytes,
+ zx_handle_info_t* handles,
+ uint32_t num_bytes,
+ uint32_t num_handles,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_write, zx_status_t, /* no attributes */, 6,
+ (handle, options, bytes, num_bytes, handles, num_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* bytes,
+ uint32_t num_bytes,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) const zx_handle_t* handles,
+ uint32_t num_handles))
+
+_ZX_SYSCALL_DECL(channel_write_etc, zx_status_t, /* no attributes */, 6,
+ (handle, options, bytes, num_bytes, handles, num_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* bytes,
+ uint32_t num_bytes,
+ zx_handle_disposition_t* handles,
+ uint32_t num_handles))
+
+_ZX_SYSCALL_DECL(channel_call, zx_status_t, /* no attributes */, 6,
+ (handle, options, deadline, args, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t deadline,
+ const zx_channel_call_args_t* args,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_call_etc, zx_status_t, /* no attributes */, 6,
+ (handle, options, deadline, args, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t deadline,
+ zx_channel_call_etc_args_t* args,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(clock_get, zx_status_t, /* no attributes */, 2,
+ (clock_id, out), (
+ zx_clock_t clock_id,
+ zx_time_t* out))
+
+_ZX_SYSCALL_DECL(clock_get_monotonic, zx_time_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(clock_adjust, zx_status_t, /* no attributes */, 3,
+ (handle, clock_id, offset), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_clock_t clock_id,
+ int64_t offset))
+
+_ZX_SYSCALL_DECL(clock_create, zx_status_t, /* no attributes */, 3,
+ (options, args, out), (
+ uint64_t options,
+ const void* args,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(clock_read, zx_status_t, /* no attributes */, 2,
+ (handle, now), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t* now))
+
+_ZX_SYSCALL_DECL(clock_get_details, zx_status_t, /* no attributes */, 3,
+ (handle, options, details), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t options,
+ void* details))
+
+_ZX_SYSCALL_DECL(clock_update, zx_status_t, /* no attributes */, 3,
+ (handle, options, args), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t options,
+ const void* args))
+
+_ZX_SYSCALL_DECL(cprng_draw, void, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(cprng_add_entropy, zx_status_t, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debug_read, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ char* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(debug_write, zx_status_t, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ const char* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debug_send_command, zx_status_t, /* no attributes */, 3,
+ (resource, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ const char* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debuglog_create, zx_status_t, /* no attributes */, 3,
+ (resource, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(debuglog_write, zx_status_t, /* no attributes */, 4,
+ (handle, options, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debuglog_read, zx_status_t, /* no attributes */, 4,
+ (handle, options, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(event_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(eventpair_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(exception_get_thread, zx_status_t, /* no attributes */, 2,
+ (handle, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(exception_get_process, zx_status_t, /* no attributes */, 2,
+ (handle, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(fifo_create, zx_status_t, /* no attributes */, 5,
+ (elem_count, elem_size, options, out0, out1), (
+ size_t elem_count,
+ size_t elem_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(fifo_read, zx_status_t, /* no attributes */, 5,
+ (handle, elem_size, data, data_size, actual_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ size_t elem_size,
+ void* data,
+ size_t data_size,
+ size_t* actual_count))
+
+_ZX_SYSCALL_DECL(fifo_write, zx_status_t, /* no attributes */, 5,
+ (handle, elem_size, data, count, actual_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ size_t elem_size,
+ const void* data,
+ size_t count,
+ size_t* actual_count))
+
+_ZX_SYSCALL_DECL(framebuffer_get_info, zx_status_t, /* no attributes */, 5,
+ (resource, format, width, height, stride), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t* format,
+ uint32_t* width,
+ uint32_t* height,
+ uint32_t* stride))
+
+_ZX_SYSCALL_DECL(framebuffer_set_range, zx_status_t, /* no attributes */, 7,
+ (resource, vmo, len, format, width, height, stride), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint32_t len,
+ uint32_t format,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride))
+
+_ZX_SYSCALL_DECL(futex_wait, zx_status_t, /* no attributes */, 4,
+ (value_ptr, current_value, new_futex_owner, deadline), (
+ const zx_futex_t* value_ptr,
+ zx_futex_t current_value,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_futex_owner,
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(futex_wake, zx_status_t, /* no attributes */, 2,
+ (value_ptr, wake_count), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count))
+
+_ZX_SYSCALL_DECL(futex_requeue, zx_status_t, /* no attributes */, 6,
+ (value_ptr, wake_count, current_value, requeue_ptr, requeue_count, new_requeue_owner), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count,
+ zx_futex_t current_value,
+ const zx_futex_t* requeue_ptr,
+ uint32_t requeue_count,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_requeue_owner))
+
+_ZX_SYSCALL_DECL(futex_wake_single_owner, zx_status_t, /* no attributes */, 1,
+ (value_ptr), (
+ const zx_futex_t* value_ptr))
+
+_ZX_SYSCALL_DECL(futex_requeue_single_owner, zx_status_t, /* no attributes */, 5,
+ (value_ptr, current_value, requeue_ptr, requeue_count, new_requeue_owner), (
+ const zx_futex_t* value_ptr,
+ zx_futex_t current_value,
+ const zx_futex_t* requeue_ptr,
+ uint32_t requeue_count,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_requeue_owner))
+
+_ZX_SYSCALL_DECL(futex_get_owner, zx_status_t, /* no attributes */, 2,
+ (value_ptr, koid), (
+ const zx_futex_t* value_ptr,
+ zx_koid_t* koid))
+
+_ZX_SYSCALL_DECL(guest_create, zx_status_t, /* no attributes */, 4,
+ (resource, options, guest_handle, vmar_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* guest_handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* vmar_handle))
+
+_ZX_SYSCALL_DECL(guest_set_trap, zx_status_t, /* no attributes */, 6,
+ (handle, kind, addr, size, port_handle, key), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ zx_vaddr_t addr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port_handle,
+ uint64_t key))
+
+_ZX_SYSCALL_DECL(handle_close, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(handle_close_many, zx_status_t, /* no attributes */, 2,
+ (handles, num_handles), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) const zx_handle_t* handles,
+ size_t num_handles))
+
+_ZX_SYSCALL_DECL(handle_duplicate, zx_status_t, /* no attributes */, 3,
+ (handle, rights, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(handle_replace, zx_status_t, /* no attributes */, 3,
+ (handle, rights, out), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(interrupt_create, zx_status_t, /* no attributes */, 4,
+ (src_obj, src_num, options, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t src_obj,
+ uint32_t src_num,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(interrupt_bind, zx_status_t, /* no attributes */, 4,
+ (handle, port_handle, key, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port_handle,
+ uint64_t key,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(interrupt_wait, zx_status_t, /* no attributes */, 2,
+ (handle, out_timestamp), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t* out_timestamp))
+
+_ZX_SYSCALL_DECL(interrupt_destroy, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(interrupt_ack, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(interrupt_trigger, zx_status_t, /* no attributes */, 3,
+ (handle, options, timestamp), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t timestamp))
+
+_ZX_SYSCALL_DECL(interrupt_bind_vcpu, zx_status_t, /* no attributes */, 3,
+ (handle, vcpu, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vcpu,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(iommu_create, zx_status_t, /* no attributes */, 5,
+ (resource, type, desc, desc_size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t type,
+ const void* desc,
+ size_t desc_size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(ioports_request, zx_status_t, /* no attributes */, 3,
+ (resource, io_addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint16_t io_addr,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(ioports_release, zx_status_t, /* no attributes */, 3,
+ (resource, io_addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint16_t io_addr,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(job_create, zx_status_t, /* no attributes */, 3,
+ (parent_job, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_job,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(job_set_policy, zx_status_t, /* no attributes */, 5,
+ (handle, options, topic, policy, policy_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint32_t topic,
+ const void* policy,
+ uint32_t policy_size))
+
+_ZX_SYSCALL_DECL(job_set_critical, zx_status_t, /* no attributes */, 3,
+ (job, options, process), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t job,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t process))
+
+_ZX_SYSCALL_DECL(ktrace_read, zx_status_t, /* no attributes */, 5,
+ (handle, data, offset, data_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ void* data,
+ uint32_t offset,
+ size_t data_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(ktrace_control, zx_status_t, /* no attributes */, 4,
+ (handle, action, options, ptr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t action,
+ uint32_t options,
+ void* ptr))
+
+_ZX_SYSCALL_DECL(ktrace_write, zx_status_t, /* no attributes */, 4,
+ (handle, id, arg0, arg1), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t id,
+ uint32_t arg0,
+ uint32_t arg1))
+
+_ZX_SYSCALL_DECL(nanosleep, zx_status_t, /* no attributes */, 1,
+ (deadline), (
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(ticks_get, zx_ticks_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(ticks_per_second, zx_ticks_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(deadline_after, zx_time_t, /* no attributes */, 1,
+ (nanoseconds), (
+ zx_duration_t nanoseconds))
+
+_ZX_SYSCALL_DECL(vmar_unmap_handle_close_thread_exit, zx_status_t, /* no attributes */, 4,
+ (vmar_handle, addr, size, close_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmar_handle,
+ zx_vaddr_t addr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t close_handle))
+
+_ZX_SYSCALL_DECL(futex_wake_handle_close_thread_exit, void, __NO_RETURN, 4,
+ (value_ptr, wake_count, new_value, close_handle), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count,
+ int32_t new_value,
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t close_handle))
+
+_ZX_SYSCALL_DECL(msi_allocate, zx_status_t, /* no attributes */, 3,
+ (handle, count, out_allocation), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t count,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_allocation))
+
+_ZX_SYSCALL_DECL(msi_create, zx_status_t, /* no attributes */, 6,
+ (handle, options, msi_id, vmo, vmo_offset, out_interrupt), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint32_t msi_id,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ size_t vmo_offset,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_interrupt))
+
+_ZX_SYSCALL_DECL(mtrace_control, zx_status_t, /* no attributes */, 6,
+ (handle, kind, action, options, ptr, ptr_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ uint32_t action,
+ uint32_t options,
+ void* ptr,
+ size_t ptr_size))
+
+_ZX_SYSCALL_DECL(object_wait_one, zx_status_t, /* no attributes */, 4,
+ (handle, signals, deadline, observed), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_signals_t signals,
+ zx_time_t deadline,
+ zx_signals_t* observed))
+
+_ZX_SYSCALL_DECL(object_wait_many, zx_status_t, /* no attributes */, 3,
+ (items, num_items, deadline), (
+ zx_wait_item_t* items,
+ size_t num_items,
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(object_wait_async, zx_status_t, /* no attributes */, 5,
+ (handle, port, key, signals, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port,
+ uint64_t key,
+ zx_signals_t signals,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(object_signal, zx_status_t, /* no attributes */, 3,
+ (handle, clear_mask, set_mask), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t clear_mask,
+ uint32_t set_mask))
+
+_ZX_SYSCALL_DECL(object_signal_peer, zx_status_t, /* no attributes */, 3,
+ (handle, clear_mask, set_mask), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t clear_mask,
+ uint32_t set_mask))
+
+_ZX_SYSCALL_DECL(object_get_property, zx_status_t, /* no attributes */, 4,
+ (handle, property, value, value_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t property,
+ void* value,
+ size_t value_size))
+
+_ZX_SYSCALL_DECL(object_set_property, zx_status_t, /* no attributes */, 4,
+ (handle, property, value, value_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t property,
+ const void* value,
+ size_t value_size))
+
+_ZX_SYSCALL_DECL(object_get_info, zx_status_t, /* no attributes */, 6,
+ (handle, topic, buffer, buffer_size, actual, avail), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t topic,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual,
+ size_t* avail))
+
+_ZX_SYSCALL_DECL(object_get_child, zx_status_t, /* no attributes */, 4,
+ (handle, koid, rights, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t koid,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(object_set_profile, zx_status_t, /* no attributes */, 3,
+ (handle, profile, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t profile,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(pager_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(pager_create_vmo, zx_status_t, /* no attributes */, 6,
+ (pager, options, port, key, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port,
+ uint64_t key,
+ uint64_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(pager_detach_vmo, zx_status_t, /* no attributes */, 2,
+ (pager, vmo), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo))
+
+_ZX_SYSCALL_DECL(pager_supply_pages, zx_status_t, /* no attributes */, 6,
+ (pager, pager_vmo, offset, length, aux_vmo, aux_offset), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager_vmo,
+ uint64_t offset,
+ uint64_t length,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t aux_vmo,
+ uint64_t aux_offset))
+
+_ZX_SYSCALL_DECL(pager_op_range, zx_status_t, /* no attributes */, 6,
+ (pager, op, pager_vmo, offset, length, data), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ uint32_t op,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager_vmo,
+ uint64_t offset,
+ uint64_t length,
+ uint64_t data))
+
+_ZX_SYSCALL_DECL(pc_firmware_tables, zx_status_t, /* no attributes */, 3,
+ (handle, acpi_rsdp, smbios), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_paddr_t* acpi_rsdp,
+ zx_paddr_t* smbios))
+
+_ZX_SYSCALL_DECL(pci_get_nth_device, zx_status_t, /* no attributes */, 4,
+ (handle, index, out_info, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t index,
+ zx_pcie_device_info_t* out_info,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_enable_bus_master, zx_status_t, /* no attributes */, 2,
+ (handle, enable), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t enable))
+
+_ZX_SYSCALL_DECL(pci_reset_device, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(pci_config_read, zx_status_t, /* no attributes */, 4,
+ (handle, offset, width, out_val), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint16_t offset,
+ size_t width,
+ uint32_t* out_val))
+
+_ZX_SYSCALL_DECL(pci_config_write, zx_status_t, /* no attributes */, 4,
+ (handle, offset, width, val), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint16_t offset,
+ size_t width,
+ uint32_t val))
+
+_ZX_SYSCALL_DECL(pci_cfg_pio_rw, zx_status_t, /* no attributes */, 8,
+ (handle, bus, dev, func, offset, val, width, write), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint8_t bus,
+ uint8_t dev,
+ uint8_t func,
+ uint8_t offset,
+ uint32_t* val,
+ size_t width,
+ uint32_t write))
+
+_ZX_SYSCALL_DECL(pci_get_bar, zx_status_t, /* no attributes */, 4,
+ (handle, bar_num, out_bar, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t bar_num,
+ zx_pci_bar_t* out_bar,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_map_interrupt, zx_status_t, /* no attributes */, 3,
+ (handle, which_irq, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ int32_t which_irq,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_query_irq_mode, zx_status_t, /* no attributes */, 3,
+ (handle, mode, out_max_irqs), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mode,
+ uint32_t* out_max_irqs))
+
+_ZX_SYSCALL_DECL(pci_set_irq_mode, zx_status_t, /* no attributes */, 3,
+ (handle, mode, requested_irq_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mode,
+ uint32_t requested_irq_count))
+
+_ZX_SYSCALL_DECL(pci_init, zx_status_t, /* no attributes */, 3,
+ (handle, init_buf, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_pci_init_arg_t* init_buf,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(pci_add_subtract_io_range, zx_status_t, /* no attributes */, 5,
+ (handle, mmio, base, len, add), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mmio,
+ uint64_t base,
+ uint64_t len,
+ uint32_t add))
+
+_ZX_SYSCALL_DECL(pmt_unpin, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(port_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(port_queue, zx_status_t, /* no attributes */, 2,
+ (handle, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(port_wait, zx_status_t, /* no attributes */, 3,
+ (handle, deadline, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t deadline,
+ zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(port_cancel, zx_status_t, /* no attributes */, 3,
+ (handle, source, key), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t source,
+ uint64_t key))
+
+_ZX_SYSCALL_DECL(process_exit, void, __NO_RETURN, 1,
+ (retcode), (
+ int64_t retcode))
+
+_ZX_SYSCALL_DECL(process_create, zx_status_t, /* no attributes */, 6,
+ (job, name, name_size, options, proc_handle, vmar_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t job,
+ const char* name,
+ size_t name_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* proc_handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* vmar_handle))
+
+_ZX_SYSCALL_DECL(process_start, zx_status_t, /* no attributes */, 6,
+ (handle, thread, entry, stack, arg1, arg2), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t thread,
+ zx_vaddr_t entry,
+ zx_vaddr_t stack,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t arg1,
+ uintptr_t arg2))
+
+_ZX_SYSCALL_DECL(process_read_memory, zx_status_t, /* no attributes */, 5,
+ (handle, vaddr, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t vaddr,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(process_write_memory, zx_status_t, /* no attributes */, 5,
+ (handle, vaddr, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t vaddr,
+ const void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(profile_create, zx_status_t, /* no attributes */, 4,
+ (root_job, options, profile, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t root_job,
+ uint32_t options,
+ const zx_profile_info_t* profile,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(resource_create, zx_status_t, /* no attributes */, 7,
+ (parent_rsrc, options, base, size, name, name_size, resource_out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_rsrc,
+ uint32_t options,
+ uint64_t base,
+ size_t size,
+ const char* name,
+ size_t name_size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* resource_out))
+
+_ZX_SYSCALL_DECL(smc_call, zx_status_t, /* no attributes */, 3,
+ (handle, parameters, out_smc_result), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_smc_parameters_t* parameters,
+ zx_smc_result_t* out_smc_result))
+
+_ZX_SYSCALL_DECL(socket_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(socket_write, zx_status_t, /* no attributes */, 5,
+ (handle, options, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(socket_read, zx_status_t, /* no attributes */, 5,
+ (handle, options, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(socket_shutdown, zx_status_t, /* no attributes */, 2,
+ (handle, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(stream_create, zx_status_t, /* no attributes */, 4,
+ (options, vmo, seek, out_stream), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ zx_off_t seek,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_stream))
+
+_ZX_SYSCALL_DECL(stream_writev, zx_status_t, /* no attributes */, 5,
+ (handle, options, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_writev_at, zx_status_t, /* no attributes */, 6,
+ (handle, options, offset, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_off_t offset,
+ const zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_readv, zx_status_t, /* no attributes */, 5,
+ (handle, options, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_readv_at, zx_status_t, /* no attributes */, 6,
+ (handle, options, offset, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_off_t offset,
+ zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_seek, zx_status_t, /* no attributes */, 4,
+ (handle, whence, offset, out_seek), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_stream_seek_origin_t whence,
+ int64_t offset,
+ zx_off_t* out_seek))
+
+_ZX_SYSCALL_DECL(system_get_dcache_line_size, uint32_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_num_cpus, uint32_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_version_string, zx_string_view_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_physmem, uint64_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_features, zx_status_t, /* no attributes */, 2,
+ (kind, features), (
+ uint32_t kind,
+ uint32_t* features))
+
+_ZX_SYSCALL_DECL(system_get_event, zx_status_t, /* no attributes */, 3,
+ (root_job, kind, event), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t root_job,
+ uint32_t kind,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* event))
+
+_ZX_SYSCALL_DECL(system_mexec, zx_status_t, /* no attributes */, 3,
+ (resource, kernel_vmo, bootimage_vmo), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t kernel_vmo,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t bootimage_vmo))
+
+_ZX_SYSCALL_DECL(system_mexec_payload_get, zx_status_t, /* no attributes */, 3,
+ (resource, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(system_powerctl, zx_status_t, /* no attributes */, 3,
+ (resource, cmd, arg), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t cmd,
+ const zx_system_powerctl_arg_t* arg))
+
+_ZX_SYSCALL_DECL(task_suspend, zx_status_t, /* no attributes */, 2,
+ (handle, token), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* token))
+
+_ZX_SYSCALL_DECL(task_suspend_token, zx_status_t, /* no attributes */, 2,
+ (handle, token), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* token))
+
+_ZX_SYSCALL_DECL(task_create_exception_channel, zx_status_t, /* no attributes */, 3,
+ (handle, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(task_kill, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(thread_exit, void, __NO_RETURN, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(thread_create, zx_status_t, /* no attributes */, 5,
+ (process, name, name_size, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t process,
+ const char* name,
+ size_t name_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(thread_start, zx_status_t, /* no attributes */, 5,
+ (handle, thread_entry, stack, arg1, arg2), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t thread_entry,
+ zx_vaddr_t stack,
+ uintptr_t arg1,
+ uintptr_t arg2))
+
+_ZX_SYSCALL_DECL(thread_read_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(thread_write_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(timer_create, zx_status_t, /* no attributes */, 3,
+ (options, clock_id, out), (
+ uint32_t options,
+ zx_clock_t clock_id,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(timer_set, zx_status_t, /* no attributes */, 3,
+ (handle, deadline, slack), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t deadline,
+ zx_duration_t slack))
+
+_ZX_SYSCALL_DECL(timer_cancel, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(vcpu_create, zx_status_t, /* no attributes */, 4,
+ (guest, options, entry, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t guest,
+ uint32_t options,
+ zx_vaddr_t entry,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vcpu_resume, zx_status_t, /* no attributes */, 2,
+ (handle, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(vcpu_interrupt, zx_status_t, /* no attributes */, 2,
+ (handle, vector), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t vector))
+
+_ZX_SYSCALL_DECL(vcpu_read_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vcpu_write_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmar_allocate, zx_status_t, /* no attributes */, 6,
+ (parent_vmar, options, offset, size, child_vmar, child_addr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_vmar,
+ zx_vm_option_t options,
+ size_t offset,
+ size_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* child_vmar,
+ zx_vaddr_t* child_addr))
+
+_ZX_SYSCALL_DECL(vmar_destroy, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(vmar_map, zx_status_t, /* no attributes */, 7,
+ (handle, options, vmar_offset, vmo, vmo_offset, len, mapped_addr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vm_option_t options,
+ size_t vmar_offset,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint64_t vmo_offset,
+ size_t len,
+ zx_vaddr_t* mapped_addr))
+
+_ZX_SYSCALL_DECL(vmar_unmap, zx_status_t, /* no attributes */, 3,
+ (handle, addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t addr,
+ size_t len))
+
+_ZX_SYSCALL_DECL(vmar_protect, zx_status_t, /* no attributes */, 4,
+ (handle, options, addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vm_option_t options,
+ zx_vaddr_t addr,
+ size_t len))
+
+_ZX_SYSCALL_DECL(vmar_op_range, zx_status_t, /* no attributes */, 6,
+ (handle, op, address, size, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t op,
+ zx_vaddr_t address,
+ size_t size,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_create, zx_status_t, /* no attributes */, 3,
+ (size, options, out), (
+ uint64_t size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_read, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, offset, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ void* buffer,
+ uint64_t offset,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_write, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, offset, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const void* buffer,
+ uint64_t offset,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_get_size, zx_status_t, /* no attributes */, 2,
+ (handle, size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t* size))
+
+_ZX_SYSCALL_DECL(vmo_set_size, zx_status_t, /* no attributes */, 2,
+ (handle, size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t size))
+
+_ZX_SYSCALL_DECL(vmo_op_range, zx_status_t, /* no attributes */, 6,
+ (handle, op, offset, size, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t op,
+ uint64_t offset,
+ uint64_t size,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_create_child, zx_status_t, /* no attributes */, 5,
+ (handle, options, offset, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint64_t offset,
+ uint64_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_set_cache_policy, zx_status_t, /* no attributes */, 2,
+ (handle, cache_policy), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t cache_policy))
+
+_ZX_SYSCALL_DECL(vmo_replace_as_executable, zx_status_t, /* no attributes */, 3,
+ (handle, vmex, out), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmex,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_create_contiguous, zx_status_t, /* no attributes */, 4,
+ (bti, size, alignment_log2, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t bti,
+ size_t size,
+ uint32_t alignment_log2,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_create_physical, zx_status_t, /* no attributes */, 4,
+ (resource, paddr, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ zx_paddr_t paddr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/iommu.h b/arch/arm64/sysroot/include/zircon/syscalls/iommu.h
index e567175..414320d 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/iommu.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/iommu.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
+#define SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
#include <assert.h>
-#include <zircon/compiler.h>
#include <stdbool.h>
#include <stdint.h>
+#include <zircon/compiler.h>
__BEGIN_CDECLS
@@ -19,77 +20,78 @@
// Data structures for creating a dummy IOMMU instance
typedef struct zx_iommu_desc_dummy {
- uint8_t reserved;
+ uint8_t reserved;
} zx_iommu_desc_dummy_t;
-
// Data structures for creating an Intel IOMMU instance
// This scope represents a single PCI endpoint device
#define ZX_IOMMU_INTEL_SCOPE_ENDPOINT 0
// This scope represents a PCI-PCI bridge. The bridge and all of its downstream
// devices will be included in this scope.
-#define ZX_IOMMU_INTEL_SCOPE_BRIDGE 1
+#define ZX_IOMMU_INTEL_SCOPE_BRIDGE 1
// TODO(teisenbe): Investigate FIDL for this. Multiple embedded lists seems
// right up its alley.
typedef struct zx_iommu_desc_intel_scope {
- uint8_t type;
- // The bus number of the first bus decoded by the host bridge this scope is attached to.
- uint8_t start_bus;
- // Number of bridges (including the host bridge) between host bridge and the
- // device.
- uint8_t num_hops;
- // The device number and function numbers of the bridges along the way,
- // ending with the device itself.
- // |dev_func[0]| is the address on |start_bus| of the first bridge in the
- // path (excluding the host bridge). |dev_func[num_hops-1]| is the address
- // of the the device itself.
- uint8_t dev_func[5];
+ uint8_t type;
+ // The bus number of the first bus decoded by the host bridge this scope is attached to.
+ uint8_t start_bus;
+ // Number of bridges (including the host bridge) between host bridge and the
+ // device.
+ uint8_t num_hops;
+ // The device number and function numbers of the bridges along the way,
+ // ending with the device itself.
+ // |dev_func[0]| is the address on |start_bus| of the first bridge in the
+ // path (excluding the host bridge). |dev_func[num_hops-1]| is the address
+ // of the device itself.
+ uint8_t dev_func[5];
} zx_iommu_desc_intel_scope_t;
typedef struct zx_iommu_desc_intel_reserved_memory {
- uint64_t base_addr; // Physical address of the base of reserved memory.
- uint64_t len; // Number of bytes of reserved memory.
+ uint64_t base_addr; // Physical address of the base of reserved memory.
+ uint64_t len; // Number of bytes of reserved memory.
- // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
- uint8_t scope_bytes;
+ // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
+ uint8_t scope_bytes;
- uint8_t _reserved[7]; // Padding
+ uint8_t _reserved[7]; // Padding
- // This is a list of all devices that need access to this memory range.
- //
- // zx_iommu_desc_intel_scope_t scopes[num_scopes];
+ // This is a list of all devices that need access to this memory range.
+ //
+ // zx_iommu_desc_intel_scope_t scopes[num_scopes];
} zx_iommu_desc_intel_reserved_memory_t;
typedef struct zx_iommu_desc_intel {
- uint64_t register_base; // Physical address of registers
- uint16_t pci_segment; // The PCI segment associated with this IOMMU
+ uint64_t register_base; // Physical address of registers
+ uint16_t pci_segment; // The PCI segment associated with this IOMMU
- // If true, this IOMMU has all PCI devices in its segment under its scope.
- // In this case, the list of scopes acts as a blacklist.
- bool whole_segment;
+ // If false, scopes[] represents all PCI devices in this segment managed by this IOMMU.
+ // If true, scopes[] represents all PCI devices in this segment *not* managed by this IOMMU.
+ bool whole_segment;
- // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
- uint8_t scope_bytes;
+ // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
+ uint8_t scope_bytes;
- // The number of bytes of zx_iommu_desc_intel_reserved_memory_t's that follow the scope
- // list.
- uint16_t reserved_memory_bytes;
+ // The number of bytes of zx_iommu_desc_intel_reserved_memory_t's that follow the scope
+ // list.
+ uint16_t reserved_memory_bytes;
- uint8_t _reserved[2]; // Padding
+ uint8_t _reserved[2]; // Padding
- // If |whole_segment| is false, this is a list of all devices managed by
- // this IOMMU. If |whole_segment| is true, this is a list of all devices on
- // this segment *not* managed by this IOMMU. It has a total length in bytes of
- // |scope_bytes|.
- //
- // zx_iommu_desc_intel_scope_t scopes[];
+ // If |whole_segment| is false, this is a list of all devices managed by
+ // this IOMMU. If |whole_segment| is true, this is a list of all devices on
+ // this segment *not* managed by this IOMMU. It has a total length in bytes of
+ // |scope_bytes|.
+ //
+ // zx_iommu_desc_intel_scope_t scopes[];
- // A list of all BIOS-reserved memory regions this IOMMU needs to translate.
- // It has a total length in bytes of |reserved_memory_bytes|.
- //
- // zx_iommu_desc_intel_reserved_memory_t reserved_mem[];
+ // A list of all BIOS-reserved memory regions this IOMMU needs to translate.
+ // It has a total length in bytes of |reserved_memory_bytes|.
+ //
+ // zx_iommu_desc_intel_reserved_memory_t reserved_mem[];
} zx_iommu_desc_intel_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/log.h b/arch/arm64/sysroot/include/zircon/syscalls/log.h
index e89d9c5..c6af1d9 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/log.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/log.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_LOG_H_
+#define SYSROOT_ZIRCON_SYSCALLS_LOG_H_
#include <zircon/types.h>
@@ -10,13 +11,14 @@
// Defines and structures for zx_log_*()
typedef struct zx_log_record {
- uint32_t reserved;
- uint16_t datalen;
- uint16_t flags;
- zx_time_t timestamp;
- uint64_t pid;
- uint64_t tid;
- char data[];
+ uint32_t rollout;
+ uint16_t datalen;
+ uint8_t severity;
+ uint8_t flags;
+ zx_time_t timestamp;
+ uint64_t pid;
+ uint64_t tid;
+ char data[];
} zx_log_record_t;
// ask clang format not to mess up the indentation:
@@ -24,32 +26,26 @@
#define ZX_LOG_RECORD_MAX 256
-// Common Log Levels
-#define ZX_LOG_ERROR (0x0001)
-#define ZX_LOG_WARN (0x0002)
-#define ZX_LOG_INFO (0x0004)
-
-// Verbose log levels
-#define ZX_LOG_TRACE (0x0010)
-#define ZX_LOG_SPEW (0x0020)
-
-// Custom Log Levels
-#define ZX_LOG_DEBUG1 (0x0100)
-#define ZX_LOG_DEBUG2 (0x0200)
-#define ZX_LOG_DEBUG3 (0x0400)
-#define ZX_LOG_DEBUG4 (0x0800)
+// Log Levels
+#define ZX_LOG_TRACE (0x10)
+#define ZX_LOG_DEBUG (0x20)
+#define ZX_LOG_INFO (0x30)
+#define ZX_LOG_WARNING (0x40)
+#define ZX_LOG_ERROR (0x50)
+#define ZX_LOG_FATAL (0x60)
// Filter Flags
// Do not forward this message via network
// (for logging in network core and drivers)
-#define ZX_LOG_LOCAL (0x1000)
+#define ZX_LOG_LOCAL (0x10)
-#define ZX_LOG_LEVEL_MASK (0x0FFF)
-#define ZX_LOG_FLAGS_MASK (0xFFFF)
+#define ZX_LOG_FLAGS_MASK (0x10)
// Options
#define ZX_LOG_FLAG_READABLE 0x40000000
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_LOG_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/object.h b/arch/arm64/sysroot/include/zircon/syscalls/object.h
index 33e2e90..81414d5 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/object.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/object.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_OBJECT_H_
-#define ZIRCON_SYSCALLS_OBJECT_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
+#define SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
#include <zircon/types.h>
@@ -12,6 +12,9 @@
// ask clang format not to mess up the indentation:
// clang-format off
+// Help macro for building versioned topics. Version is the upper 4 bits and starts counting at 0.
+#define __ZX_INFO_TOPIC(t, v) ((zx_object_info_topic_t) ((t) | ((v) << 28)))
+
// Valid topics for zx_object_get_info.
typedef uint32_t zx_object_info_topic_t;
#define ZX_INFO_NONE ((zx_object_info_topic_t) 0u)
@@ -26,7 +29,8 @@
#define ZX_INFO_THREAD_EXCEPTION_REPORT ((zx_object_info_topic_t) 11u) // zx_exception_report_t[1]
#define ZX_INFO_TASK_STATS ((zx_object_info_topic_t) 12u) // zx_info_task_stats_t[1]
#define ZX_INFO_PROCESS_MAPS ((zx_object_info_topic_t) 13u) // zx_info_maps_t[n]
-#define ZX_INFO_PROCESS_VMOS ((zx_object_info_topic_t) 14u) // zx_info_vmo_t[n]
+#define ZX_INFO_PROCESS_VMOS_V1 __ZX_INFO_TOPIC(14u, 0) // zx_info_vmo_t[n]
+#define ZX_INFO_PROCESS_VMOS __ZX_INFO_TOPIC(14u, 1) // zx_info_vmo_t[n]
#define ZX_INFO_THREAD_STATS ((zx_object_info_topic_t) 15u) // zx_info_thread_stats_t[1]
#define ZX_INFO_CPU_STATS ((zx_object_info_topic_t) 16u) // zx_info_cpu_stats_t[n]
#define ZX_INFO_KMEM_STATS ((zx_object_info_topic_t) 17u) // zx_info_kmem_stats_t[1]
@@ -35,11 +39,27 @@
#define ZX_INFO_BTI ((zx_object_info_topic_t) 20u) // zx_info_bti_t[1]
#define ZX_INFO_PROCESS_HANDLE_STATS ((zx_object_info_topic_t) 21u) // zx_info_process_handle_stats_t[1]
#define ZX_INFO_SOCKET ((zx_object_info_topic_t) 22u) // zx_info_socket_t[1]
-#define ZX_INFO_VMO ((zx_object_info_topic_t) 23u) // zx_info_vmo_t[1]
+#define ZX_INFO_VMO_V1 __ZX_INFO_TOPIC(23u, 0) // zx_info_vmo_t[1]
+#define ZX_INFO_VMO __ZX_INFO_TOPIC(23u, 1) // zx_info_vmo_t[1]
+#define ZX_INFO_JOB ((zx_object_info_topic_t) 24u) // zx_info_job_t[1]
+#define ZX_INFO_TIMER ((zx_object_info_topic_t) 25u) // zx_info_timer_t[1]
+#define ZX_INFO_STREAM ((zx_object_info_topic_t) 26u) // zx_info_stream_t[1]
+#define ZX_INFO_HANDLE_TABLE ((zx_object_info_topic_t) 27u) // zx_info_handle_extended_t[n]
+#define ZX_INFO_MSI ((zx_object_info_topic_t) 28u) // zx_info_msi_t[1]
+#define ZX_INFO_GUEST_STATS ((zx_object_info_topic_t) 29u) // zx_info_guest_stats_t[1]
+#define ZX_INFO_TASK_RUNTIME ((zx_object_info_topic_t) 30u) // zx_info_task_runtime_t[1]
-typedef uint32_t zx_obj_props_t;
-#define ZX_OBJ_PROP_NONE ((zx_obj_props_t)0u)
-#define ZX_OBJ_PROP_WAITABLE ((zx_obj_props_t)1u)
+// Return codes set when a task is killed.
+#define ZX_TASK_RETCODE_SYSCALL_KILL ((int64_t) -1024) // via zx_task_kill().
+#define ZX_TASK_RETCODE_OOM_KILL ((int64_t) -1025) // by the OOM killer.
+#define ZX_TASK_RETCODE_POLICY_KILL ((int64_t) -1026) // by the Job policy.
+#define ZX_TASK_RETCODE_VDSO_KILL ((int64_t) -1027) // by the VDSO.
+#define ZX_TASK_RETCODE_EXCEPTION_KILL ((int64_t) -1028) // Exception not handled.
+#define ZX_TASK_RETCODE_CRITICAL_PROCESS_KILL ((int64_t) -1029) // by a critical process.
+
+// Sentinel indicating an invalid or missing CPU.
+#define ZX_INFO_INVALID_CPU ((uint32_t)0xFFFFFFFFu)
+
typedef struct zx_info_handle_basic {
// The unique id assigned by kernel to the object referenced by the
@@ -61,11 +81,46 @@
// not change even if the related object no longer exists.
zx_koid_t related_koid;
- // Set to ZX_OBJ_PROP_WAITABLE if the object referenced by the
- // handle can be waited on; zero otherwise.
- zx_obj_props_t props;
+ uint32_t reserved;
+
+ uint8_t padding1[4];
} zx_info_handle_basic_t;
+typedef struct zx_info_handle_extended {
+ // The object type: channel, event, socket, etc.
+ zx_obj_type_t type;
+
+ // The handle value which is only valid for the process which
+ // was passed to ZX_INFO_HANDLE_TABLE.
+ zx_handle_t handle_value;
+
+ // The immutable rights assigned to the handle. Two handles that
+ // have the same koid and the same rights are equivalent and
+ // interchangeable.
+ zx_rights_t rights;
+
+ uint32_t reserved;
+
+ // The unique id assigned by kernel to the object referenced by the
+ // handle.
+ zx_koid_t koid;
+
+ // If the object referenced by the handle is related to another (such
+ // as the other end of a channel, or the parent of a job) then
+ // |related_koid| is the koid of that object, otherwise it is zero.
+ // This relationship is immutable: an object's |related_koid| does
+ // not change even if the related object no longer exists.
+ zx_koid_t related_koid;
+
+ // If the object referenced by the handle has a peer, like the
+ // other end of a channel, then this is the koid of the process
+ // which currently owns it. This value is not stable; the process
+ // can change the owner at any moment.
+ //
+ // This is currently unimplemented and contains 0.
+ zx_koid_t peer_owner_koid;
+} zx_info_handle_extended_t;
+
typedef struct zx_info_handle_count {
// The number of outstanding handles to a kernel object.
uint32_t handle_count;
@@ -73,12 +128,12 @@
typedef struct zx_info_process_handle_stats {
// The number of outstanding handles to kernel objects of each type.
- uint32_t handle_count[64];
+ uint32_t handle_count[ZX_OBJ_TYPE_UPPER_BOUND];
} zx_info_process_handle_stats_t;
typedef struct zx_info_process {
// The process's return code; only valid if |exited| is true.
- // Guaranteed to be non-zero if the process was killed by |zx_task_kill|.
+ // If the process was killed, it will be one of the ZX_TASK_RETCODE values.
int64_t return_code;
// True if the process has ever left the initial creation state,
@@ -90,8 +145,70 @@
// True if a debugger is attached to the process.
bool debugger_attached;
+
+ uint8_t padding1[5];
} zx_info_process_t;
+typedef struct zx_info_job {
+ // The job's return code; only valid if |exited| is true.
+ // If the process was killed, it will be one of the ZX_TASK_RETCODE values.
+ int64_t return_code;
+
+ // If true, the job has exited and |return_code| is valid.
+ bool exited;
+
+ // True if the ZX_PROP_JOB_KILL_ON_OOM was set.
+ bool kill_on_oom;
+
+ // True if a debugger is attached to the job.
+ bool debugger_attached;
+
+ uint8_t padding1[5];
+} zx_info_job_t;
+
+typedef struct zx_info_timer {
+ // The options passed to zx_timer_create().
+ uint32_t options;
+
+ uint8_t padding1[4];
+
+ // The deadline with respect to ZX_CLOCK_MONOTONIC at which the timer will
+ // fire next.
+ //
+ // This value will be zero if the timer is not set to fire.
+ zx_time_t deadline;
+
+ // Specifies a range from deadline - slack to deadline + slack during which
+ // the timer is allowed to fire. The system uses this parameter as a hint to
+ // coalesce nearby timers.
+ //
+ // The precise coalescing behavior is controlled by the options parameter
+ // specified when the timer was created.
+ //
+ // This value will be zero if the timer is not set to fire.
+ zx_duration_t slack;
+} zx_info_timer_t;
+
+typedef struct zx_info_stream {
+ // The options passed to zx_stream_create().
+ uint32_t options;
+
+ uint8_t padding1[4];
+
+ // The current seek offset.
+ //
+ // Used by zx_stream_readv and zx_stream_writev to determine where to read
+ // and write the stream.
+ zx_off_t seek;
+
+ // The current size of the stream.
+ //
+ // The number of bytes in the stream that store data. The stream itself
+ // might have a larger capacity to avoid reallocating the underlying storage
+ // as the stream grows or shrinks.
+ uint64_t content_size;
+} zx_info_stream_t;
+
typedef uint32_t zx_thread_state_t;
typedef struct zx_info_thread {
@@ -99,15 +216,32 @@
zx_thread_state_t state;
// If |state| is ZX_THREAD_STATE_BLOCKED_EXCEPTION, the thread has gotten
- // an exception and is waiting for the exception to be handled by the
- // specified port.
- // The value is one of ZX_EXCEPTION_PORT_TYPE_*.
- uint32_t wait_exception_port_type;
+ // an exception and is waiting for the exception response from the specified
+ // handler.
+
+ // The value is one of ZX_EXCEPTION_CHANNEL_TYPE_*.
+ uint32_t wait_exception_channel_type;
+
+ // CPUs this thread may be scheduled on, as specified by
+ // a profile object applied to this thread.
+ //
+ // The kernel may not internally store invalid CPUs in the mask, so
+ // this may not exactly match the mask applied to the thread for
+ // CPUs beyond what the system is able to use.
+ zx_cpu_set_t cpu_affinity_mask;
} zx_info_thread_t;
typedef struct zx_info_thread_stats {
// Total accumulated running time of the thread.
zx_duration_t total_runtime;
+
+ // CPU number that this thread was last scheduled on, or ZX_INFO_INVALID_CPU
+ // if the thread has never been scheduled on a CPU. By the time this call
+ // returns, the thread may have been scheduled elsewhere, so this
+ // information should only be used as a hint or for statistics.
+ uint32_t last_scheduled_cpu;
+
+ uint8_t padding1[4];
} zx_info_thread_stats_t;
// Statistics about resources (e.g., memory) used by a task. Can be relatively
@@ -155,12 +289,22 @@
// The number of bytes in the device's address space (UINT64_MAX if 2^64).
uint64_t aspace_size;
+
+ // The count of the pinned memory object tokens. Requesting this count is
+ // racy, so this should only be used for informative reasons.
+ uint64_t pmo_count;
+
+ // The count of the quarantined pinned memory object tokens. Requesting this count is
+ // racy, so this should only be used for informative reasons.
+ uint64_t quarantine_count;
} zx_info_bti_t;
typedef struct zx_info_socket {
// The options passed to zx_socket_create().
uint32_t options;
+ uint8_t padding1[4];
+
// The maximum size of the receive buffer of a socket, in bytes.
//
// The receive buffer may become full at a capacity less than the maximum
@@ -199,6 +343,7 @@
// MMU flags for the mapping.
// Bitwise OR of ZX_VM_PERM_{READ,WRITE,EXECUTE} values.
zx_vm_option_t mmu_flags;
+ uint8_t padding1[4];
// koid of the mapped VMO.
zx_koid_t vmo_koid;
// Offset into the above VMO.
@@ -232,6 +377,7 @@
size_t depth;
// The type of this entry; indicates which union entry is valid.
zx_info_maps_type_t type;
+ uint8_t padding1[4];
union {
zx_info_maps_mapping_t mapping;
// No additional fields for other types.
@@ -256,7 +402,10 @@
// if (ZX_INFO_VMO_TYPE(f) == ZX_INFO_VMO_TYPE_PAGED)
#define ZX_INFO_VMO_TYPE(flags) ((flags) & (1u<<0))
-// The VMO is a clone, and is a copy-on-write clone.
+// The VMO is resizable.
+#define ZX_INFO_VMO_RESIZABLE (1u<<1)
+
+// The VMO is a child, and is a copy-on-write clone.
#define ZX_INFO_VMO_IS_COW_CLONE (1u<<2)
// When reading a list of VMOs pointed to by a process, indicates that the
@@ -268,6 +417,14 @@
// the VMO.
#define ZX_INFO_VMO_VIA_MAPPING (1u<<4)
+// The VMO is a pager owned VMO created by zx_pager_create_vmo or is
+// a clone of a VMO with this flag set. Will only be set on VMOs with
+// the ZX_INFO_VMO_TYPE_PAGED flag set.
+#define ZX_INFO_VMO_PAGER_BACKED (1u<<5)
+
+// The VMO is contiguous
+#define ZX_INFO_VMO_CONTIGUOUS (1u<<6)
+
// Describes a VMO. For mapping information, see |zx_info_maps_t|.
typedef struct zx_info_vmo {
// The koid of this VMO.
@@ -301,6 +458,8 @@
// Bitwise OR of ZX_INFO_VMO_* values.
uint32_t flags;
+ uint8_t padding1[4];
+
// If |ZX_INFO_VMO_TYPE(flags) == ZX_INFO_VMO_TYPE_PAGED|, the amount of
// memory currently allocated to this VMO; i.e., the amount of physical
// memory it consumes. Undefined otherwise.
@@ -310,15 +469,83 @@
// Undefined otherwise.
zx_rights_t handle_rights;
- // VMO creation options. This is a bitmask of
- // kResizable = (1u << 0);
- // kContiguous = (1u << 1);
- uint32_t create_options;
-
// VMO mapping cache policy. One of ZX_CACHE_POLICY_*
uint32_t cache_policy;
+
+ // Amount of kernel memory, in bytes, allocated to track metadata
+ // associated with this VMO.
+ uint64_t metadata_bytes;
+
+ // Running counter of the number of times the kernel, without user request,
+ // performed actions on this VMO that would have caused |committed_bytes| to
+ // report a different value.
+ uint64_t committed_change_events;
} zx_info_vmo_t;
+typedef struct zx_info_vmo_v1 {
+ zx_koid_t koid;
+ char name[ZX_MAX_NAME_LEN];
+ uint64_t size_bytes;
+ zx_koid_t parent_koid;
+ size_t num_children;
+ size_t num_mappings;
+ size_t share_count;
+ uint32_t flags;
+ uint8_t padding1[4];
+ uint64_t committed_bytes;
+ zx_rights_t handle_rights;
+ uint32_t cache_policy;
+} zx_info_vmo_v1_t;
+
+typedef struct zx_info_guest_stats {
+ uint32_t cpu_number;
+ uint32_t flags;
+
+ uint64_t vm_entries;
+ uint64_t vm_exits;
+#ifdef __aarch64__
+ uint64_t wfi_wfe_instructions;
+ uint64_t instruction_aborts;
+ uint64_t data_aborts;
+ uint64_t system_instructions;
+ uint64_t smc_instructions;
+ uint64_t interrupts;
+#else
+ uint64_t interrupts;
+ uint64_t interrupt_windows;
+ uint64_t cpuid_instructions;
+ uint64_t hlt_instructions;
+ uint64_t control_register_accesses;
+ uint64_t io_instructions;
+ uint64_t rdmsr_instructions;
+ uint64_t wrmsr_instructions;
+ uint64_t ept_violations;
+ uint64_t xsetbv_instructions;
+ uint64_t pause_instructions;
+ uint64_t vmcall_instructions;
+#endif
+} zx_info_guest_stats_t;
+
+// Info on the runtime of a task.
+typedef struct zx_info_task_runtime {
+ // The total amount of time this task and its children were running.
+ // * Threads include only their own runtime.
+ // * Processes include the runtime for all of their threads (including threads that previously
+ // exited).
+ // * Jobs include the runtime for all of their processes (including processes that previously
+ // exited).
+ zx_duration_t cpu_time;
+
+ // The total amount of time this task and its children were queued to run.
+ // * Threads include only their own queue time.
+ // * Processes include the queue time for all of their threads (including threads that
+ // previously exited).
+ // * Jobs include the queue time for all of their processes (including processes that previously
+ // exited).
+ zx_duration_t queue_time;
+} zx_info_task_runtime_t;
+
+
// kernel statistics per cpu
// TODO(cpu), expose the deprecated stats via a new syscall.
typedef struct zx_info_cpu_stats {
@@ -399,6 +626,19 @@
char name[ZX_MAX_NAME_LEN];
} zx_info_resource_t;
+typedef struct zx_info_msi {
+ // The target adress for write transactions.
+ uint64_t target_addr;
+ // The data that the device will write when triggering an IRQ.
+ uint32_t target_data;
+ // The first IRQ in the allocated block.
+ uint32_t base_irq_id;
+ // The number of IRQs in the allocated block.
+ uint32_t num_irq;
+ // The number of outstanding interrupt objects created off this Msi object.
+ uint32_t interrupt_count;
+} zx_info_msi_t;
+
#define ZX_INFO_CPU_STATS_FLAG_ONLINE (1u<<0)
// Object properties.
@@ -422,6 +662,19 @@
// Argument is the base address of the vDSO mapping (or zero), a uintptr_t.
#define ZX_PROP_PROCESS_VDSO_BASE_ADDRESS ((uint32_t) 6u)
+// Whether the dynamic loader should issue a debug trap when loading a shared library,
+// either initially or when running (e.g. dlopen).
+//
+// See docs/reference/syscalls/object_get_property.md
+// See third_party/ulib/musl/ldso/dynlink.c.
+#define ZX_PROP_PROCESS_BREAK_ON_LOAD ((uint32_t) 7u)
+
+// The process's context id as recorded by h/w instruction tracing, a uintptr_t.
+// On X86 this is the cr3 value.
+// TODO(dje): Wasn't sure whether the gaps in property numbers are unusable
+// due to being old dleeted values. For now I just picked something.
+#define ZX_PROP_PROCESS_HW_TRACE_CONTEXT_ID ((uint32_t) 8u)
+
// Argument is a size_t.
#define ZX_PROP_SOCKET_RX_THRESHOLD 12u
#define ZX_PROP_SOCKET_TX_THRESHOLD 13u
@@ -429,6 +682,21 @@
// Terminate this job if the system is low on memory.
#define ZX_PROP_JOB_KILL_ON_OOM 15u
+// Exception close behavior.
+#define ZX_PROP_EXCEPTION_STATE 16u
+
+// The size of the content in a VMO, in bytes.
+//
+// The content size of a VMO can be larger or smaller than the actual size of
+// the VMO.
+//
+// Argument is a uint64_t.
+#define ZX_PROP_VMO_CONTENT_SIZE 17u
+
+// How an exception should be handled.
+// See //docs/concepts/kernel/exceptions.md.
+#define ZX_PROP_EXCEPTION_STRATEGY 18u
+
// Basic thread states, in zx_info_thread_t.state.
#define ZX_THREAD_STATE_NEW ((zx_thread_state_t) 0x0000u)
#define ZX_THREAD_STATE_RUNNING ((zx_thread_state_t) 0x0001u)
@@ -449,11 +717,22 @@
#define ZX_THREAD_STATE_BLOCKED_WAIT_ONE ((zx_thread_state_t) 0x0603u)
#define ZX_THREAD_STATE_BLOCKED_WAIT_MANY ((zx_thread_state_t) 0x0703u)
#define ZX_THREAD_STATE_BLOCKED_INTERRUPT ((zx_thread_state_t) 0x0803u)
+#define ZX_THREAD_STATE_BLOCKED_PAGER ((zx_thread_state_t) 0x0903u)
// Reduce possibly-more-precise state to a basic state.
// Useful if, for example, you want to check for BLOCKED on anything.
#define ZX_THREAD_STATE_BASIC(n) ((n) & 0xff)
+// How a thread should behave when the current exception is closed.
+// ZX_PROP_EXCEPTION_STATE values.
+#define ZX_EXCEPTION_STATE_TRY_NEXT 0u
+#define ZX_EXCEPTION_STATE_HANDLED 1u
+
+// How an exception should be handled
+// ZX_PROP_EXCEPTION_STRATEGY values.
+#define ZX_EXCEPTION_STRATEGY_FIRST_CHANCE 0u
+#define ZX_EXCEPTION_STRATEGY_SECOND_CHANCE 1u
+
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_OBJECT_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/pci.h b/arch/arm64/sysroot/include/zircon/syscalls/pci.h
index b97f1c3..d1049c2 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/pci.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/pci.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PCI_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PCI_H_
#include <zircon/types.h>
@@ -32,7 +33,10 @@
size_t size;
union {
uintptr_t addr;
- zx_handle_t handle;
+ struct {
+ zx_handle_t handle;
+ uint8_t padding1[4];
+ };
};
} zx_pci_bar_t;
@@ -50,6 +54,8 @@
uint8_t bus_id;
uint8_t dev_id;
uint8_t func_id;
+
+ uint8_t padding1;
} zx_pcie_device_info_t;
#define ZX_PCI_MAX_BUSSES (256u)
@@ -84,6 +90,10 @@
[ZX_PCI_MAX_FUNCTIONS_PER_DEVICE]
[ZX_PCI_MAX_LEGACY_IRQ_PINS];
+// We support up to 224 IRQs on a system, this is the maximum supported by
+// LAPICs (today) so this should be a safe number.
+#define ZX_PCI_MAX_IRQS 224
+
typedef struct zx_pci_init_arg {
zx_pci_irq_swizzle_lut_t dev_pin_to_global_irq;
@@ -92,7 +102,8 @@
uint32_t global_irq;
bool level_triggered;
bool active_high;
- } irqs[64];
+ uint8_t padding1[2];
+ } irqs[ZX_PCI_MAX_IRQS];
uint32_t addr_window_count;
struct {
@@ -102,6 +113,7 @@
uint8_t bus_end;
uint8_t cfg_space_type;
bool has_ecam;
+ uint8_t padding1[4];
} addr_windows[];
} zx_pci_init_arg_t;
@@ -118,3 +130,5 @@
#define ZX_PCIE_IRQ_MODE_MSI_X ((zx_pci_irq_mode_t) 3u)
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_PCI_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/policy.h b/arch/arm64/sysroot/include/zircon/syscalls/policy.h
index f7061ce..158c604 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/policy.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/policy.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
+#define SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
#include <zircon/types.h>
@@ -13,18 +14,33 @@
// Policy is applied for the conditions that are not
// specified by the parent job policy.
-#define ZX_JOB_POL_RELATIVE 0u
+#define ZX_JOB_POL_RELATIVE 0u
// Policy is either applied as-is or the syscall fails.
-#define ZX_JOB_POL_ABSOLUTE 1u
+#define ZX_JOB_POL_ABSOLUTE 1u
// Basic policy topic.
-#define ZX_JOB_POL_BASIC 0u
+#define ZX_JOB_POL_BASIC_V1 0u
+#define ZX_JOB_POL_BASIC_V2 0x01000000u
-// Input structure to use with ZX_JOB_POL_BASIC.
-typedef struct zx_policy_basic {
+// Timer slack policy topic.
+#define ZX_JOB_POL_TIMER_SLACK 1u
+
+// Input structure to use with ZX_JOB_POL_BASIC_V1.
+typedef struct zx_policy_basic_v1 {
uint32_t condition;
uint32_t policy;
-} zx_policy_basic_t;
+} zx_policy_basic_v1_t;
+
+// Input structure to use with ZX_JOB_POL_BASIC_V2.
+typedef struct zx_policy_basic_v2 {
+ uint32_t condition;
+ uint32_t action;
+ uint32_t flags;
+} zx_policy_basic_v2_t;
+
+#define ZX_JOB_POL_BASIC ZX_JOB_POL_BASIC_V1
+typedef struct zx_policy_basic_v1 zx_policy_basic;
+typedef struct zx_policy_basic_v1 zx_policy_basic_t;
// Conditions handled by job policy.
#define ZX_POL_BAD_HANDLE 0u
@@ -40,16 +56,34 @@
#define ZX_POL_NEW_FIFO 10u
#define ZX_POL_NEW_TIMER 11u
#define ZX_POL_NEW_PROCESS 12u
+#define ZX_POL_NEW_PROFILE 13u
+#define ZX_POL_AMBIENT_MARK_VMO_EXEC 14u
#ifdef _KERNEL
-#define ZX_POL_MAX 13u
+#define ZX_POL_MAX 15u
#endif
// Policy actions.
-// ZX_POL_ACTION_ALLOW and ZX_POL_ACTION_DENY can be ORed with ZX_POL_ACTION_EXCEPTION.
-// ZX_POL_ACTION_KILL implies ZX_POL_ACTION_DENY.
#define ZX_POL_ACTION_ALLOW 0u
#define ZX_POL_ACTION_DENY 1u
-#define ZX_POL_ACTION_EXCEPTION 2u
-#define ZX_POL_ACTION_KILL 5u
+#define ZX_POL_ACTION_ALLOW_EXCEPTION 2u
+#define ZX_POL_ACTION_DENY_EXCEPTION 3u
+#define ZX_POL_ACTION_KILL 4u
+#ifdef _KERNEL
+#define ZX_POL_ACTION_MAX 5u
+#endif
+
+// Policy override.
+#define ZX_POL_OVERRIDE_ALLOW 0u
+#define ZX_POL_OVERRIDE_DENY 1u
+
+
+// Input structure to use with ZX_JOB_POL_TIMER_SLACK.
+typedef struct zx_policy_timer_slack {
+ zx_duration_t min_slack;
+ uint32_t default_mode;
+ uint8_t padding1[4];
+} zx_policy_timer_slack_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/port.h b/arch/arm64/sysroot/include/zircon/syscalls/port.h
index 10bc39b..06b3b6a 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/port.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/port.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_PORT_H_
-#define ZIRCON_SYSCALLS_PORT_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PORT_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PORT_H_
#include <zircon/compiler.h>
#include <zircon/types.h>
@@ -13,140 +13,162 @@
// clang-format off
// zx_object_wait_async() options
+// Do not use ZX_WAIT_ASYNC_ONCE. It is now superfluous and will be removed.
#define ZX_WAIT_ASYNC_ONCE ((uint32_t)0u)
-#define ZX_WAIT_ASYNC_REPEATING ((uint32_t)1u)
+#define ZX_WAIT_ASYNC_TIMESTAMP ((uint32_t)1u)
// packet types. zx_port_packet_t::type
#define ZX_PKT_TYPE_USER ((uint8_t)0x00u)
#define ZX_PKT_TYPE_SIGNAL_ONE ((uint8_t)0x01u)
-#define ZX_PKT_TYPE_SIGNAL_REP ((uint8_t)0x02u)
+// 0x02 was previously used for "ZX_PKT_TYPE_SIGNAL_REP".
#define ZX_PKT_TYPE_GUEST_BELL ((uint8_t)0x03u)
#define ZX_PKT_TYPE_GUEST_MEM ((uint8_t)0x04u)
#define ZX_PKT_TYPE_GUEST_IO ((uint8_t)0x05u)
#define ZX_PKT_TYPE_GUEST_VCPU ((uint8_t)0x06u)
#define ZX_PKT_TYPE_INTERRUPT ((uint8_t)0x07u)
-#define ZX_PKT_TYPE_EXCEPTION(n) ((uint32_t)(0x08u | (((n) & 0xFFu) << 8)))
+#define ZX_PKT_TYPE_PAGE_REQUEST ((uint8_t)0x09u)
// For options passed to port_create
#define ZX_PORT_BIND_TO_INTERRUPT ((uint32_t)(0x1u << 0))
#define ZX_PKT_TYPE_MASK ((uint32_t)0x000000FFu)
-#define ZX_PKT_IS_USER(type) ((type) == ZX_PKT_TYPE_USER)
-#define ZX_PKT_IS_SIGNAL_ONE(type) ((type) == ZX_PKT_TYPE_SIGNAL_ONE)
-#define ZX_PKT_IS_SIGNAL_REP(type) ((type) == ZX_PKT_TYPE_SIGNAL_REP)
-#define ZX_PKT_IS_GUEST_BELL(type) ((type) == ZX_PKT_TYPE_GUEST_BELL)
-#define ZX_PKT_IS_GUEST_MEM(type) ((type) == ZX_PKT_TYPE_GUEST_MEM)
-#define ZX_PKT_IS_GUEST_IO(type) ((type) == ZX_PKT_TYPE_GUEST_IO)
-#define ZX_PKT_IS_GUEST_VCPU(type) ((type) == ZX_PKT_TYPE_GUEST_VCPU)
-#define ZX_PKT_IS_INTERRUPT(type) ((type) == ZX_PKT_TYPE_INTERRUPT)
-#define ZX_PKT_IS_EXCEPTION(type) (((type) & ZX_PKT_TYPE_MASK) == ZX_PKT_TYPE_EXCEPTION(0))
+#define ZX_PKT_IS_USER(type) ((type) == ZX_PKT_TYPE_USER)
+#define ZX_PKT_IS_SIGNAL_ONE(type) ((type) == ZX_PKT_TYPE_SIGNAL_ONE)
+#define ZX_PKT_IS_GUEST_BELL(type) ((type) == ZX_PKT_TYPE_GUEST_BELL)
+#define ZX_PKT_IS_GUEST_MEM(type) ((type) == ZX_PKT_TYPE_GUEST_MEM)
+#define ZX_PKT_IS_GUEST_IO(type) ((type) == ZX_PKT_TYPE_GUEST_IO)
+#define ZX_PKT_IS_GUEST_VCPU(type) ((type) == ZX_PKT_TYPE_GUEST_VCPU)
+#define ZX_PKT_IS_INTERRUPT(type) ((type) == ZX_PKT_TYPE_INTERRUPT)
+#define ZX_PKT_IS_PAGE_REQUEST(type) ((type) == ZX_PKT_TYPE_PAGE_REQUEST)
// zx_packet_guest_vcpu_t::type
#define ZX_PKT_GUEST_VCPU_INTERRUPT ((uint8_t)0)
#define ZX_PKT_GUEST_VCPU_STARTUP ((uint8_t)1)
+
+// zx_packet_page_request_t::command
+#define ZX_PAGER_VMO_READ ((uint16_t) 0)
+#define ZX_PAGER_VMO_COMPLETE ((uint16_t) 1)
// clang-format on
// port_packet_t::type ZX_PKT_TYPE_USER.
typedef union zx_packet_user {
- uint64_t u64[4];
- uint32_t u32[8];
- uint16_t u16[16];
- uint8_t c8[32];
+ uint64_t u64[4];
+ uint32_t u32[8];
+ uint16_t u16[16];
+ uint8_t c8[32];
} zx_packet_user_t;
-// port_packet_t::type ZX_PKT_TYPE_SIGNAL_ONE and ZX_PKT_TYPE_SIGNAL_REP.
+// port_packet_t::type ZX_PKT_TYPE_SIGNAL_ONE.
typedef struct zx_packet_signal {
- zx_signals_t trigger;
- zx_signals_t observed;
- uint64_t count;
- uint64_t reserved0;
- uint64_t reserved1;
+ zx_signals_t trigger;
+ zx_signals_t observed;
+ uint64_t count;
+ uint64_t timestamp;
+ uint64_t reserved1;
} zx_packet_signal_t;
-typedef struct zx_packet_exception {
- uint64_t pid;
- uint64_t tid;
- uint64_t reserved0;
- uint64_t reserved1;
-} zx_packet_exception_t;
-
typedef struct zx_packet_guest_bell {
- zx_gpaddr_t addr;
- uint64_t reserved0;
- uint64_t reserved1;
- uint64_t reserved2;
+ zx_gpaddr_t addr;
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_guest_bell_t;
typedef struct zx_packet_guest_mem {
- zx_gpaddr_t addr;
+ zx_gpaddr_t addr;
#if __aarch64__
- uint8_t access_size;
- bool sign_extend;
- uint8_t xt;
- bool read;
- uint64_t data;
- uint64_t reserved;
+ uint8_t access_size;
+ bool sign_extend;
+ uint8_t xt;
+ bool read;
+ uint8_t padding1[4];
+ uint64_t data;
+ uint64_t reserved;
#elif __x86_64__
// NOTE: x86 instructions are guaranteed to be 15 bytes or fewer.
#define X86_MAX_INST_LEN 15u
- uint8_t inst_len;
- uint8_t inst_buf[X86_MAX_INST_LEN];
- uint8_t default_operand_size;
- uint8_t reserved[7];
+ uint8_t inst_len;
+ uint8_t inst_buf[X86_MAX_INST_LEN];
+ // This is the default operand size as determined by the CS and EFER register (Volume 3,
+ // Section 5.2.1). If operating in 64-bit mode then near branches and all instructions, except
+ // far branches, that implicitly reference the RSP will actually have a default operand size of
+ // 64-bits (Volume 2, Section 2.2.1.7), and not the 32-bits that will be given here.
+ uint8_t default_operand_size;
+ uint8_t reserved[7];
#endif
} zx_packet_guest_mem_t;
typedef struct zx_packet_guest_io {
- uint16_t port;
- uint8_t access_size;
- bool input;
- union {
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
- uint8_t data[4];
+ uint16_t port;
+ uint8_t access_size;
+ bool input;
+ union {
+ struct {
+ uint8_t u8;
+ uint8_t padding1[3];
};
- uint64_t reserved0;
- uint64_t reserved1;
- uint64_t reserved2;
+ struct {
+ uint16_t u16;
+ uint8_t padding2[2];
+ };
+ uint32_t u32;
+ uint8_t data[4];
+ };
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_guest_io_t;
typedef struct zx_packet_guest_vcpu {
- union {
- struct {
- uint64_t mask;
- uint8_t vector;
- } interrupt;
- struct {
- uint64_t id;
- zx_gpaddr_t entry;
- } startup;
- };
- uint8_t type;
- uint64_t reserved;
+ union {
+ struct {
+ uint64_t mask;
+ uint8_t vector;
+ uint8_t padding1[7];
+ } interrupt;
+ struct {
+ uint64_t id;
+ zx_gpaddr_t entry;
+ } startup;
+ };
+ uint8_t type;
+ uint8_t padding1[7];
+ uint64_t reserved;
} zx_packet_guest_vcpu_t;
typedef struct zx_packet_interrupt {
- zx_time_t timestamp;
+ zx_time_t timestamp;
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_interrupt_t;
+typedef struct zx_packet_page_request {
+ uint16_t command;
+ uint16_t flags;
+ uint32_t reserved0;
+ uint64_t offset;
+ uint64_t length;
+ uint64_t reserved1;
+} zx_packet_page_request_t;
+
typedef struct zx_port_packet {
- uint64_t key;
- uint32_t type;
- int32_t status;
- union {
- zx_packet_user_t user;
- zx_packet_signal_t signal;
- zx_packet_exception_t exception;
- zx_packet_guest_bell_t guest_bell;
- zx_packet_guest_mem_t guest_mem;
- zx_packet_guest_io_t guest_io;
- zx_packet_guest_vcpu_t guest_vcpu;
- zx_packet_interrupt_t interrupt;
- };
+ uint64_t key;
+ uint32_t type;
+ zx_status_t status;
+ union {
+ zx_packet_user_t user;
+ zx_packet_signal_t signal;
+ zx_packet_guest_bell_t guest_bell;
+ zx_packet_guest_mem_t guest_mem;
+ zx_packet_guest_io_t guest_io;
+ zx_packet_guest_vcpu_t guest_vcpu;
+ zx_packet_interrupt_t interrupt;
+ zx_packet_page_request_t page_request;
+ };
} zx_port_packet_t;
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_PORT_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_PORT_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/profile.h b/arch/arm64/sysroot/include/zircon/syscalls/profile.h
index 10ed499..5abf561 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/profile.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/profile.h
@@ -2,36 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
+#include <zircon/syscalls/scheduler.h>
#include <zircon/types.h>
__BEGIN_CDECLS
-// ask clang format not to mess up the indentation:
-// clang-format off
+#define ZX_PRIORITY_LOWEST 0
+#define ZX_PRIORITY_LOW 8
+#define ZX_PRIORITY_DEFAULT 16
+#define ZX_PRIORITY_HIGH 24
+#define ZX_PRIORITY_HIGHEST 31
-#define ZX_PROFILE_INFO_SCHEDULER 1
-
-typedef struct zx_profile_scheduler {
- int32_t priority;
- uint32_t boost;
- uint32_t deboost;
- uint32_t quantum;
-} zx_profile_scheduler_t;
-
-#define ZX_PRIORITY_LOWEST 0
-#define ZX_PRIORITY_LOW 8
-#define ZX_PRIORITY_DEFAULT 16
-#define ZX_PRIORITY_HIGH 24
-#define ZX_PRIORITY_HIGHEST 31
+#define ZX_PROFILE_INFO_FLAG_PRIORITY (1 << 0)
+#define ZX_PROFILE_INFO_FLAG_CPU_MASK (1 << 1)
+#define ZX_PROFILE_INFO_FLAG_DEADLINE (1 << 2)
typedef struct zx_profile_info {
- uint32_t type; // one of ZX_PROFILE_INFO_
- union {
- zx_profile_scheduler_t scheduler;
+ // A bitmask of ZX_PROFILE_INFO_FLAG_* values. Specifies which fields
+ // below have been specified. Other fields are considered unset.
+ uint32_t flags;
+
+ uint8_t padding1[4];
+
+ union {
+ struct {
+ // Scheduling priority. |flags| must have ZX_PROFILE_INFO_FLAG_PRIORITY set.
+ int32_t priority;
+
+ uint8_t padding2[20];
};
+
+ // Scheduling deadline. |flags| must have ZX_PROFILE_INFO_FLAG_DEADLINE set.
+ zx_sched_deadline_params_t deadline_params;
+ };
+
+ // CPUs that threads may be scheduled on. |flags| must have
+ // ZX_PROFILE_INFO_FLAG_CPU_MASK set.
+ zx_cpu_set_t cpu_affinity_mask;
} zx_profile_info_t;
-
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/resource.h b/arch/arm64/sysroot/include/zircon/syscalls/resource.h
index 6defbda..9243d17 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/resource.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/resource.h
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
+#define SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
#include <stdint.h>
-
#include <zircon/compiler.h>
// Resources that require a region allocator to handle exclusive reservations
@@ -14,21 +14,23 @@
// bookkeeping. It's important that ZX_RSRC_KIND_COUNT is defined for each
// architecture to properly allocate only the bookkeeping necessary.
//
-// TODO(ZX-2419): Don't expose ZX_RSRC_KIND_COUNT to userspace
+// TODO(fxbug.dev/32272): Don't expose ZX_RSRC_KIND_COUNT to userspace
typedef uint32_t zx_rsrc_kind_t;
-#define ZX_RSRC_KIND_MMIO ((zx_rsrc_kind_t)0u)
-#define ZX_RSRC_KIND_IRQ ((zx_rsrc_kind_t)1u)
-#define ZX_RSRC_KIND_IOPORT ((zx_rsrc_kind_t)2u)
-#define ZX_RSRC_KIND_HYPERVISOR ((zx_rsrc_kind_t)3u)
-#define ZX_RSRC_KIND_ROOT ((zx_rsrc_kind_t)4u)
-#define ZX_RSRC_KIND_VMEX ((zx_rsrc_kind_t)5u)
-#define ZX_RSRC_KIND_SMC ((zx_rsrc_kind_t)6u)
-#define ZX_RSRC_KIND_COUNT ((zx_rsrc_kind_t)7u)
+#define ZX_RSRC_KIND_MMIO ((zx_rsrc_kind_t)0u)
+#define ZX_RSRC_KIND_IRQ ((zx_rsrc_kind_t)1u)
+#define ZX_RSRC_KIND_IOPORT ((zx_rsrc_kind_t)2u)
+#define ZX_RSRC_KIND_HYPERVISOR ((zx_rsrc_kind_t)3u)
+#define ZX_RSRC_KIND_ROOT ((zx_rsrc_kind_t)4u)
+#define ZX_RSRC_KIND_VMEX ((zx_rsrc_kind_t)5u)
+#define ZX_RSRC_KIND_SMC ((zx_rsrc_kind_t)6u)
+#define ZX_RSRC_KIND_COUNT ((zx_rsrc_kind_t)7u)
typedef uint32_t zx_rsrc_flags_t;
-#define ZX_RSRC_FLAG_EXCLUSIVE ((zx_rsrc_flags_t)0x00010000u)
-#define ZX_RSRC_FLAGS_MASK ((zx_rsrc_flags_t)ZX_RSRC_FLAG_EXCLUSIVE)
+#define ZX_RSRC_FLAG_EXCLUSIVE ((zx_rsrc_flags_t)0x00010000u)
+#define ZX_RSRC_FLAGS_MASK ((zx_rsrc_flags_t)ZX_RSRC_FLAG_EXCLUSIVE)
-#define ZX_RSRC_EXTRACT_KIND(x) ((x) & 0x0000FFFF)
-#define ZX_RSRC_EXTRACT_FLAGS(x) ((x) & 0xFFFF0000)
+#define ZX_RSRC_EXTRACT_KIND(x) ((x)&0x0000FFFF)
+#define ZX_RSRC_EXTRACT_FLAGS(x) ((x)&0xFFFF0000)
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/scheduler.h b/arch/arm64/sysroot/include/zircon/syscalls/scheduler.h
new file mode 100644
index 0000000..c119562
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/syscalls/scheduler.h
@@ -0,0 +1,36 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
+
+#include <zircon/compiler.h>
+#include <zircon/time.h>
+
+__BEGIN_CDECLS
+
+// Parameters for deadline scheduler profiles.
+//
+// At minimum, the following relation must hold:
+//
+// 0 < capacity <= relative_deadline <= period
+//
+// Additional restrictions on the range and granularity of the parameters may be
+// enforced, which can vary from system to system.
+//
+typedef struct zx_sched_deadline_params {
+ // The worst case execution time of the deadline work per interarrival period.
+ zx_duration_t capacity;
+
+ // The worst case finish time of the deadline work, relative to the beginning
+ // of the current interarrival period.
+ zx_duration_t relative_deadline;
+
+ // The worst case interarrival period of the deadline work.
+ zx_duration_t period;
+} zx_sched_deadline_params_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/smc.h b/arch/arm64/sysroot/include/zircon/syscalls/smc.h
index 5c8f9ba..93f1761 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/smc.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/smc.h
@@ -2,37 +2,46 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SMC_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SMC_H_
#include <zircon/types.h>
__BEGIN_CDECLS
+// Silicon Partner.
+#define ARM_SMC_SERVICE_CALL_NUM_SIP_SERVICE_BASE 0x02
+#define ARM_SMC_SERVICE_CALL_NUM_SIP_SERVICE_LENGTH 0x01
#define ARM_SMC_SERVICE_CALL_NUM_TRUSTED_OS_BASE 0x32
#define ARM_SMC_SERVICE_CALL_NUM_TRUSTED_OS_LENGTH 0xE
#define ARM_SMC_SERVICE_CALL_NUM_MAX 0x3F
#define ARM_SMC_SERVICE_CALL_NUM_MASK 0x3F
#define ARM_SMC_SERVICE_CALL_NUM_SHIFT 24
#define ARM_SMC_GET_SERVICE_CALL_NUM_FROM_FUNC_ID(func_id) \
- (((func_id) >> ARM_SMC_SERVICE_CALL_NUM_SHIFT) & ARM_SMC_SERVICE_CALL_NUM_MASK)
+ (((func_id) >> ARM_SMC_SERVICE_CALL_NUM_SHIFT) & ARM_SMC_SERVICE_CALL_NUM_MASK)
typedef struct zx_smc_parameters {
- uint32_t func_id;
- uint64_t arg1;
- uint64_t arg2;
- uint64_t arg3;
- uint64_t arg4;
- uint64_t arg5;
- uint64_t arg6;
- uint16_t client_id;
- uint16_t secure_os_id;
+ uint32_t func_id;
+ uint8_t padding1[4];
+ uint64_t arg1;
+ uint64_t arg2;
+ uint64_t arg3;
+ uint64_t arg4;
+ uint64_t arg5;
+ uint64_t arg6;
+ uint16_t client_id;
+ uint16_t secure_os_id;
+ uint8_t padding2[4];
} zx_smc_parameters_t;
typedef struct zx_smc_result {
- uint64_t arg0;
- uint64_t arg1;
- uint64_t arg2;
- uint64_t arg3;
+ uint64_t arg0;
+ uint64_t arg1;
+ uint64_t arg2;
+ uint64_t arg3;
+ uint64_t arg6; // at least one implementation uses it as a way to return session_id.
} zx_smc_result_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SMC_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/system.h b/arch/arm64/sysroot/include/zircon/syscalls/system.h
index c58de1d..b54d443 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/system.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/system.h
@@ -2,36 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
#include <zircon/types.h>
__BEGIN_CDECLS
// Commands used by zx_system_powerctl()
-#define ZX_SYSTEM_POWERCTL_ENABLE_ALL_CPUS 1u
+#define ZX_SYSTEM_POWERCTL_ENABLE_ALL_CPUS 1u
#define ZX_SYSTEM_POWERCTL_DISABLE_ALL_CPUS_BUT_PRIMARY 2u
-#define ZX_SYSTEM_POWERCTL_ACPI_TRANSITION_S_STATE 3u
-#define ZX_SYSTEM_POWERCTL_X86_SET_PKG_PL1 4u
-#define ZX_SYSTEM_POWERCTL_REBOOT 5u
-#define ZX_SYSTEM_POWERCTL_REBOOT_BOOTLOADER 6u
-#define ZX_SYSTEM_POWERCTL_REBOOT_RECOVERY 7u
-#define ZX_SYSTEM_POWERCTL_SHUTDOWN 8u
+#define ZX_SYSTEM_POWERCTL_ACPI_TRANSITION_S_STATE 3u
+#define ZX_SYSTEM_POWERCTL_X86_SET_PKG_PL1 4u
+#define ZX_SYSTEM_POWERCTL_REBOOT 5u
+#define ZX_SYSTEM_POWERCTL_REBOOT_BOOTLOADER 6u
+#define ZX_SYSTEM_POWERCTL_REBOOT_RECOVERY 7u
+#define ZX_SYSTEM_POWERCTL_SHUTDOWN 8u
typedef struct zx_system_powerctl_arg {
- union {
- struct {
- uint8_t target_s_state; // Value between 1 and 5 indicating which S-state
- uint8_t sleep_type_a; // Value from ACPI VM (SLP_TYPa)
- uint8_t sleep_type_b; // Value from ACPI VM (SLP_TYPb)
- } acpi_transition_s_state;
- struct {
- uint32_t power_limit; // PL1 value in milliwatts
- uint32_t time_window; // PL1 time window in microseconds
- uint8_t clamp; // PL1 clamping enable
- uint8_t enable; // PL1 enable
- } x86_power_limit;
+ union {
+ struct {
+ struct {
+ uint8_t target_s_state; // Value between 1 and 5 indicating which S-state
+ uint8_t sleep_type_a; // Value from ACPI VM (SLP_TYPa)
+ uint8_t sleep_type_b; // Value from ACPI VM (SLP_TYPb)
+ } acpi_transition_s_state;
+ uint8_t padding1[9];
};
+ struct {
+ uint32_t power_limit; // PL1 value in milliwatts
+ uint32_t time_window; // PL1 time window in microseconds
+ uint8_t clamp; // PL1 clamping enable
+ uint8_t enable; // PL1 enable
+ uint8_t padding2[2];
+ } x86_power_limit;
+ };
} zx_system_powerctl_arg_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
diff --git a/arch/arm64/sysroot/include/zircon/syscalls/types.h b/arch/arm64/sysroot/include/zircon/syscalls/types.h
index a5a69c8..b7910f2 100644
--- a/arch/arm64/sysroot/include/zircon/syscalls/types.h
+++ b/arch/arm64/sysroot/include/zircon/syscalls/types.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
+#define SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
#include <zircon/compiler.h>
@@ -20,3 +21,5 @@
typedef struct zx_smc_result zx_smc_result_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
diff --git a/arch/arm64/sysroot/include/zircon/testonly-syscalls.h b/arch/arm64/sysroot/include/zircon/testonly-syscalls.h
new file mode 100644
index 0000000..d994d86
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/testonly-syscalls.h
@@ -0,0 +1,30 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_TESTONLY_SYSCALLS_H_
+#define SYSROOT_ZIRCON_TESTONLY_SYSCALLS_H_
+
+#include <zircon/syscalls.h>
+
+__BEGIN_CDECLS
+
+// Make sure this matches <zircon/syscalls.h>.
+#define _ZX_SYSCALL_DECL(name, type, attrs, nargs, arglist, prototype) \
+ extern attrs type zx_##name prototype; \
+ extern attrs type _zx_##name prototype;
+
+#ifdef __clang__
+#define _ZX_SYSCALL_ANNO(attr) __attribute__((attr))
+#else
+#define _ZX_SYSCALL_ANNO(attr) // Nothing for compilers without the support.
+#endif
+
+#include <zircon/syscalls/internal/testonly-cdecls.inc>
+
+#undef _ZX_SYSCALL_ANNO
+#undef _ZX_SYSCALL_DECL
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_ONLY_SYSCALLS_H_
diff --git a/arch/arm64/sysroot/include/zircon/threads.h b/arch/arm64/sysroot/include/zircon/threads.h
index 937a9f9..2cfdd7e 100644
--- a/arch/arm64/sysroot/include/zircon/threads.h
+++ b/arch/arm64/sysroot/include/zircon/threads.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_THREADS_H_
+#define SYSROOT_ZIRCON_THREADS_H_
#include <threads.h>
#include <zircon/compiler.h>
@@ -19,19 +20,37 @@
// Converts a threads.h-style status value to an |zx_status_t|.
static inline zx_status_t __PURE thrd_status_to_zx_status(int thrd_status) {
- switch (thrd_status) {
+ switch (thrd_status) {
case thrd_success:
- return ZX_OK;
+ return ZX_OK;
case thrd_nomem:
- return ZX_ERR_NO_MEMORY;
+ return ZX_ERR_NO_MEMORY;
case thrd_timedout:
- return ZX_ERR_TIMED_OUT;
+ return ZX_ERR_TIMED_OUT;
case thrd_busy:
- return ZX_ERR_SHOULD_WAIT;
+ return ZX_ERR_SHOULD_WAIT;
default:
case thrd_error:
- return ZX_ERR_INTERNAL;
- }
+ return ZX_ERR_INTERNAL;
+ }
}
__END_CDECLS
+
+#ifdef __cplusplus
+
+#if __has_include(<thread>)
+
+#include <thread>
+
+// Get the zx_handle_t corresponding to the std::thread::native_handle() value.
+// See `thrd_get_zx_handle` (above) for constraints on the returned handle.
+// Using this API avoids any assumptions about std::thread::native_handle_type
+// corresponding exactly to thrd_t or any other particular type.
+zx_handle_t native_thread_get_zx_handle(std::thread::native_handle_type);
+
+#endif // __has_include(<thread>)
+
+#endif // __cplusplus
+
+#endif // SYSROOT_ZIRCON_THREADS_H_
diff --git a/arch/arm64/sysroot/include/zircon/time.h b/arch/arm64/sysroot/include/zircon/time.h
index a075d89..33f5452 100644
--- a/arch/arm64/sysroot/include/zircon/time.h
+++ b/arch/arm64/sysroot/include/zircon/time.h
@@ -1,96 +1,184 @@
-// Copyright 2018 The Fuchsia Authors
-//
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file or at
-// https://opensource.org/licenses/MIT
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_TIME_H_
+#define SYSROOT_ZIRCON_TIME_H_
+#include <stdint.h>
#include <zircon/compiler.h>
-#include <zircon/types.h>
-// These functions perform overflow-safe time arithmetic, clamping to ZX_TIME_INFINITE in case of
-// overflow and ZX_TIME_INFINITE_PAST in case of underflow.
+#if __has_include(<time.h>)
+#include <time.h>
+#endif
+
+__BEGIN_CDECLS
+
+// absolute time in nanoseconds (generally with respect to the monotonic clock)
+typedef int64_t zx_time_t;
+// a duration in nanoseconds
+typedef int64_t zx_duration_t;
+// a duration in hardware ticks
+typedef int64_t zx_ticks_t;
+
+#define ZX_TIME_INFINITE INT64_MAX
+#define ZX_TIME_INFINITE_PAST INT64_MIN
+
+// These functions perform overflow-safe time arithmetic and unit conversion, clamping to
+// ZX_TIME_INFINITE in case of overflow and ZX_TIME_INFINITE_PAST in case of underflow.
//
// C++ code should use zx::time and zx::duration instead.
//
-// The naming scheme is zx_<first argument>_<operation>_<second argument>.
+// For arithmetic the naming scheme is:
+// zx_<first argument>_<operation>_<second argument>
//
-// TODO(maniscalco): Consider expanding the set of operations to include division, modulo, unit
-// conversion, and floating point math.
+// For unit conversion the naming scheme is:
+// zx_duration_from_<unit of argument>
+//
+// TODO(maniscalco): Consider expanding the set of operations to include division, modulo, and
+// floating point math.
__CONSTEXPR static inline zx_time_t zx_time_add_duration(zx_time_t time, zx_duration_t duration) {
- zx_time_t x = 0;
- if (unlikely(add_overflow(time, duration, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_time_t x = 0;
+ if (unlikely(add_overflow(time, duration, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_time_t zx_time_sub_duration(zx_time_t time, zx_duration_t duration) {
- zx_time_t x = 0;
- if (unlikely(sub_overflow(time, duration, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
-
+ zx_time_t x = 0;
+ if (unlikely(sub_overflow(time, duration, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_time_sub_time(zx_time_t time1, zx_time_t time2) {
- zx_duration_t x = 0;
- if (unlikely(sub_overflow(time1, time2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(sub_overflow(time1, time2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_add_duration(zx_duration_t dur1,
zx_duration_t dur2) {
- zx_duration_t x = 0;
- if (unlikely(add_overflow(dur1, dur2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(add_overflow(dur1, dur2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_sub_duration(zx_duration_t dur1,
zx_duration_t dur2) {
- zx_duration_t x = 0;
- if (unlikely(sub_overflow(dur1, dur2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(sub_overflow(dur1, dur2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_mul_int64(zx_duration_t duration,
int64_t multiplier) {
- zx_duration_t x = 0;
- if (unlikely(mul_overflow(duration, multiplier, &x))) {
- if ((duration > 0 && multiplier > 0) || (duration < 0 && multiplier < 0)) {
- return ZX_TIME_INFINITE;
- } else {
- return ZX_TIME_INFINITE_PAST;
- }
+ zx_duration_t x = 0;
+ if (unlikely(mul_overflow(duration, multiplier, &x))) {
+ if ((duration > 0 && multiplier > 0) || (duration < 0 && multiplier < 0)) {
+ return ZX_TIME_INFINITE;
+ } else {
+ return ZX_TIME_INFINITE_PAST;
}
- return x;
+ }
+ return x;
}
+
+__CONSTEXPR static inline int64_t zx_nsec_from_duration(zx_duration_t n) { return n; }
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_nsec(int64_t n) {
+ return zx_duration_mul_int64(1, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_usec(int64_t n) {
+ return zx_duration_mul_int64(1000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_msec(int64_t n) {
+ return zx_duration_mul_int64(1000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_sec(int64_t n) {
+ return zx_duration_mul_int64(1000000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_min(int64_t n) {
+ return zx_duration_mul_int64(60000000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_hour(int64_t n) {
+ return zx_duration_mul_int64(3600000000000, n);
+}
+
+#if __has_include(<time.h>)
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_timespec(struct timespec ts) {
+ return zx_duration_add_duration(zx_duration_from_sec(ts.tv_sec),
+ zx_duration_from_nsec(ts.tv_nsec));
+}
+
+__CONSTEXPR static inline struct timespec zx_timespec_from_duration(zx_duration_t duration) {
+ const struct timespec ts = {
+ (time_t)(duration / 1000000000),
+ (long int)(duration % 1000000000),
+ };
+ return ts;
+}
+
+__CONSTEXPR static inline zx_time_t zx_time_from_timespec(struct timespec ts) {
+ // implicit converstion of the return type (zx_time_t and zx_duration_t are the same)
+ return zx_duration_from_timespec(ts);
+}
+
+__CONSTEXPR static inline struct timespec zx_timespec_from_time(zx_time_t time) {
+ // implicit conversion of the parameter type (zx_time_t and zx_duration_t are the same)
+ return zx_timespec_from_duration(time);
+}
+
+#endif // __has_include(<time.h>)
+
+// Similar to the functions above, these macros perform overflow-safe unit conversion. Prefer to use
+// the functions above instead of these macros.
+#define ZX_NSEC(n) (__ISCONSTANT(n) ? ((zx_duration_t)(1LL * (n))) : (zx_duration_from_nsec(n)))
+#define ZX_USEC(n) (__ISCONSTANT(n) ? ((zx_duration_t)(1000LL * (n))) : (zx_duration_from_usec(n)))
+#define ZX_MSEC(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(1000000LL * (n))) : (zx_duration_from_msec(n)))
+#define ZX_SEC(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(1000000000LL * (n))) : (zx_duration_from_sec(n)))
+#define ZX_MIN(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(60LL * 1000000000LL * (n))) : (zx_duration_from_min(n)))
+#define ZX_HOUR(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(3600LL * 1000000000LL * (n))) : (zx_duration_from_hour(n)))
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_TIME_H_
diff --git a/arch/arm64/sysroot/include/zircon/tls.h b/arch/arm64/sysroot/include/zircon/tls.h
index acacef1..91a6f43 100644
--- a/arch/arm64/sysroot/include/zircon/tls.h
+++ b/arch/arm64/sysroot/include/zircon/tls.h
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_TLS_
-#define ZIRCON_TLS_
+#ifndef SYSROOT_ZIRCON_TLS_
+#define SYSROOT_ZIRCON_TLS_
// These constants are part of the C/C++ ABI known to compilers for
// *-fuchsia targets. These are offsets from the thread pointer.
// This file must be includable in assembly files.
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__i386__)
-#define ZX_TLS_STACK_GUARD_OFFSET 0x10
-#define ZX_TLS_UNSAFE_SP_OFFSET 0x18
+#define ZX_TLS_STACK_GUARD_OFFSET 0x10
+#define ZX_TLS_UNSAFE_SP_OFFSET 0x18
#elif defined(__aarch64__)
-#define ZX_TLS_STACK_GUARD_OFFSET (-0x10)
-#define ZX_TLS_UNSAFE_SP_OFFSET (-0x8)
+#define ZX_TLS_STACK_GUARD_OFFSET (-0x10)
+#define ZX_TLS_UNSAFE_SP_OFFSET (-0x8)
#else
@@ -26,4 +26,4 @@
#endif
-#endif // ZIRCON_TLS_
+#endif // SYSROOT_ZIRCON_TLS_
diff --git a/arch/arm64/sysroot/include/zircon/types.h b/arch/arm64/sysroot/include/zircon/types.h
index 6f93626..5832d95 100644
--- a/arch/arm64/sysroot/include/zircon/types.h
+++ b/arch/arm64/sysroot/include/zircon/types.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_TYPES_H_
-#define ZIRCON_TYPES_H_
+#ifndef SYSROOT_ZIRCON_TYPES_H_
+#define SYSROOT_ZIRCON_TYPES_H_
#include <stdbool.h>
#include <stddef.h>
@@ -12,6 +12,7 @@
#include <zircon/errors.h>
#include <zircon/limits.h>
#include <zircon/rights.h>
+#include <zircon/time.h>
#ifndef __cplusplus
#ifndef _KERNEL
@@ -33,26 +34,12 @@
typedef uint32_t zx_handle_t;
-#define ZX_HANDLE_INVALID ((zx_handle_t)0)
+#define ZX_HANDLE_INVALID ((zx_handle_t)0)
+#define ZX_HANDLE_FIXED_BITS_MASK ((zx_handle_t)0x3)
// See errors.h for the values zx_status_t can take.
typedef int32_t zx_status_t;
-// absolute time in nanoseconds (generally with respect to the monotonic clock)
-typedef int64_t zx_time_t;
-// a duration in nanoseconds
-typedef int64_t zx_duration_t;
-// a duration in hardware ticks
-typedef uint64_t zx_ticks_t;
-#define ZX_TIME_INFINITE INT64_MAX
-#define ZX_TIME_INFINITE_PAST INT64_MIN
-#define ZX_NSEC(n) ((zx_duration_t)(1LL * (n)))
-#define ZX_USEC(n) ((zx_duration_t)(1000LL * (n)))
-#define ZX_MSEC(n) ((zx_duration_t)(1000000LL * (n)))
-#define ZX_SEC(n) ((zx_duration_t)(1000000000LL * (n)))
-#define ZX_MIN(n) (ZX_SEC(n) * 60LL)
-#define ZX_HOUR(n) (ZX_MIN(n) * 60LL)
-
// clock ids
typedef uint32_t zx_clock_t;
#define ZX_CLOCK_MONOTONIC ((zx_clock_t)0)
@@ -107,7 +94,7 @@
#define ZX_USER_SIGNAL_6 ((zx_signals_t)1u << 30)
#define ZX_USER_SIGNAL_7 ((zx_signals_t)1u << 31)
-// Cancelation (handle was closed while waiting with it)
+// Cancellation (handle was closed while waiting with it)
#define ZX_SIGNAL_HANDLE_CLOSED __ZX_OBJECT_HANDLE_CLOSED
// Event
@@ -124,22 +111,18 @@
#define ZX_CHANNEL_WRITABLE __ZX_OBJECT_WRITABLE
#define ZX_CHANNEL_PEER_CLOSED __ZX_OBJECT_PEER_CLOSED
+// Clock
+#define ZX_CLOCK_STARTED __ZX_OBJECT_SIGNAL_4
+
// Socket
#define ZX_SOCKET_READABLE __ZX_OBJECT_READABLE
#define ZX_SOCKET_WRITABLE __ZX_OBJECT_WRITABLE
#define ZX_SOCKET_PEER_CLOSED __ZX_OBJECT_PEER_CLOSED
#define ZX_SOCKET_PEER_WRITE_DISABLED __ZX_OBJECT_SIGNAL_4
#define ZX_SOCKET_WRITE_DISABLED __ZX_OBJECT_SIGNAL_5
-#define ZX_SOCKET_CONTROL_READABLE __ZX_OBJECT_SIGNAL_6
-#define ZX_SOCKET_CONTROL_WRITABLE __ZX_OBJECT_SIGNAL_7
-#define ZX_SOCKET_ACCEPT __ZX_OBJECT_SIGNAL_8
-#define ZX_SOCKET_SHARE __ZX_OBJECT_SIGNAL_9
#define ZX_SOCKET_READ_THRESHOLD __ZX_OBJECT_SIGNAL_10
#define ZX_SOCKET_WRITE_THRESHOLD __ZX_OBJECT_SIGNAL_11
-// Deprecated
-#define ZX_SOCKET_READ_DISABLED ZX_SOCKET_PEER_WRITE_DISABLED
-
// Fifo
#define ZX_FIFO_READABLE __ZX_OBJECT_READABLE
#define ZX_FIFO_WRITABLE __ZX_OBJECT_WRITABLE
@@ -149,8 +132,9 @@
#define ZX_TASK_TERMINATED __ZX_OBJECT_SIGNALED
// Job
-#define ZX_JOB_NO_PROCESSES __ZX_OBJECT_SIGNALED
+#define ZX_JOB_TERMINATED __ZX_OBJECT_SIGNALED
#define ZX_JOB_NO_JOBS __ZX_OBJECT_SIGNAL_4
+#define ZX_JOB_NO_PROCESSES __ZX_OBJECT_SIGNAL_5
// Process
#define ZX_PROCESS_TERMINATED __ZX_OBJECT_SIGNALED
@@ -173,28 +157,15 @@
// global kernel object id.
// Note: kernel object ids use 63 bits, with the most significant bit being zero.
// The remaining values (msb==1) are for use by programs and tools that wish to
-// create koids for artificial objets.
+// create koids for artificial objects.
typedef uint64_t zx_koid_t;
#define ZX_KOID_INVALID ((uint64_t) 0)
#define ZX_KOID_KERNEL ((uint64_t) 1)
-
-// Transaction ID and argument types for zx_channel_call.
-typedef uint32_t zx_txid_t;
-
-typedef struct zx_channel_call_args {
- const void* wr_bytes;
- const zx_handle_t* wr_handles;
- void *rd_bytes;
- zx_handle_t* rd_handles;
- uint32_t wr_num_bytes;
- uint32_t wr_num_handles;
- uint32_t rd_num_bytes;
- uint32_t rd_num_handles;
-} zx_channel_call_args_t;
+// The first non-reserved koid. The first 1024 are reserved.
+#define ZX_KOID_FIRST ((uint64_t) 1024)
// Maximum number of wait items allowed for zx_object_wait_many()
-// TODO(ZX-1349) Re-lower this.
-#define ZX_WAIT_MANY_MAX_ITEMS ((size_t)16)
+#define ZX_WAIT_MANY_MAX_ITEMS ((size_t)64)
// Structure for zx_object_wait_many():
typedef struct zx_wait_item {
@@ -204,10 +175,11 @@
} zx_wait_item_t;
// VM Object creation options
-#define ZX_VMO_NON_RESIZABLE ((uint32_t)1u)
+#define ZX_VMO_RESIZABLE ((uint32_t)1u << 1)
// VM Object opcodes
#define ZX_VMO_OP_COMMIT ((uint32_t)1u)
+// Keep value in sync with ZX_VMAR_OP_DECOMMIT.
#define ZX_VMO_OP_DECOMMIT ((uint32_t)2u)
#define ZX_VMO_OP_LOCK ((uint32_t)3u)
#define ZX_VMO_OP_UNLOCK ((uint32_t)4u)
@@ -216,10 +188,26 @@
#define ZX_VMO_OP_CACHE_INVALIDATE ((uint32_t)7u)
#define ZX_VMO_OP_CACHE_CLEAN ((uint32_t)8u)
#define ZX_VMO_OP_CACHE_CLEAN_INVALIDATE ((uint32_t)9u)
+#define ZX_VMO_OP_ZERO ((uint32_t)10u)
+
+// VMAR opcodes
+// Keep value in sync with ZX_VMO_OP_DECOMMIT.
+#define ZX_VMAR_OP_DECOMMIT ((uint32_t)2u)
+#define ZX_VMAR_OP_MAP_RANGE ((uint32_t)3u)
+
+// Pager opcodes
+#define ZX_PAGER_OP_FAIL ((uint32_t)1u)
// VM Object clone flags
-#define ZX_VMO_CLONE_COPY_ON_WRITE ((uint32_t)1u << 0)
-#define ZX_VMO_CLONE_NON_RESIZEABLE ((uint32_t)1u << 1)
+#define ZX_VMO_CHILD_SNAPSHOT ((uint32_t)1u << 0)
+#define ZX_VMO_CHILD_SNAPSHOT_AT_LEAST_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_RESIZABLE ((uint32_t)1u << 2)
+#define ZX_VMO_CHILD_SLICE ((uint32_t)1u << 3)
+#define ZX_VMO_CHILD_NO_WRITE ((uint32_t)1u << 5)
+// Old clone flags that are on the path to deprecation.
+#define ZX_VMO_CLONE_COPY_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_COPY_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_PRIVATE_PAGER_COPY ((uint32_t)1u << 4)
typedef uint32_t zx_vm_option_t;
// Mapping flags to vmar routines
@@ -235,7 +223,33 @@
#define ZX_VM_CAN_MAP_EXECUTE ((zx_vm_option_t)(1u << 9))
#define ZX_VM_MAP_RANGE ((zx_vm_option_t)(1u << 10))
#define ZX_VM_REQUIRE_NON_RESIZABLE ((zx_vm_option_t)(1u << 11))
+#define ZX_VM_ALLOW_FAULTS ((zx_vm_option_t)(1u << 12))
+#define ZX_VM_OFFSET_IS_UPPER_LIMIT ((zx_vm_option_t)(1u << 13))
+#define ZX_VM_ALIGN_BASE 24
+#define ZX_VM_ALIGN_1KB ((zx_vm_option_t)(10u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2KB ((zx_vm_option_t)(11u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4KB ((zx_vm_option_t)(12u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_8KB ((zx_vm_option_t)(13u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_16KB ((zx_vm_option_t)(14u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_32KB ((zx_vm_option_t)(15u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_64KB ((zx_vm_option_t)(16u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_128KB ((zx_vm_option_t)(17u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_256KB ((zx_vm_option_t)(18u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_512KB ((zx_vm_option_t)(19u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_1MB ((zx_vm_option_t)(20u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2MB ((zx_vm_option_t)(21u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4MB ((zx_vm_option_t)(22u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_8MB ((zx_vm_option_t)(23u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_16MB ((zx_vm_option_t)(24u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_32MB ((zx_vm_option_t)(25u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_64MB ((zx_vm_option_t)(26u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_128MB ((zx_vm_option_t)(27u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_256MB ((zx_vm_option_t)(28u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_512MB ((zx_vm_option_t)(29u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_1GB ((zx_vm_option_t)(30u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2GB ((zx_vm_option_t)(31u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4GB ((zx_vm_option_t)(32u << ZX_VM_ALIGN_BASE))
// virtual address
typedef uintptr_t zx_vaddr_t;
@@ -250,14 +264,22 @@
// offset
typedef uint64_t zx_off_t;
+// vectorized I/O
+typedef struct zx_iovec {
+ void* buffer;
+ size_t capacity;
+} zx_iovec_t;
+
// Maximum string length for kernel names (process name, thread name, etc)
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
#define ZX_MAX_NAME_LEN ((size_t)32u)
// Buffer size limits on the cprng syscalls
#define ZX_CPRNG_DRAW_MAX_LEN ((size_t)256u)
#define ZX_CPRNG_ADD_ENTROPY_MAX_LEN ((size_t)256u)
-// interrupt bind flags
+// interrupt_create flags
#define ZX_INTERRUPT_REMAP_IRQ ((uint32_t)0x1u)
#define ZX_INTERRUPT_MODE_DEFAULT ((uint32_t)0u << 1)
#define ZX_INTERRUPT_MODE_EDGE_LOW ((uint32_t)1u << 1)
@@ -268,35 +290,58 @@
#define ZX_INTERRUPT_MODE_MASK ((uint32_t)0xe)
#define ZX_INTERRUPT_VIRTUAL ((uint32_t)0x10)
+// interrupt_bind flags
+#define ZX_INTERRUPT_BIND ((uint32_t)0x0u)
+#define ZX_INTERRUPT_UNBIND ((uint32_t)0x1u)
+
// Preallocated virtual interrupt slot, typically used for signaling interrupt threads to exit.
#define ZX_INTERRUPT_SLOT_USER ((uint32_t)62u)
// interrupt wait slots must be in the range 0 - 62 inclusive
#define ZX_INTERRUPT_MAX_SLOTS ((uint32_t)62u)
+// msi_create flags
+#define ZX_MSI_MODE_MSI_X ((uint32_t)0x1u)
+
// PCI interrupt handles use interrupt slot 0 for the PCI hardware interrupt
#define ZX_PCI_INTERRUPT_SLOT ((uint32_t)0u)
// Channel options and limits.
#define ZX_CHANNEL_READ_MAY_DISCARD ((uint32_t)1u)
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
#define ZX_CHANNEL_MAX_MSG_BYTES ((uint32_t)65536u)
#define ZX_CHANNEL_MAX_MSG_HANDLES ((uint32_t)64u)
+// Fifo limits.
+#define ZX_FIFO_MAX_SIZE_BYTES ZX_PAGE_SIZE
+
// Socket options and limits.
-// These options can be passed to zx_socket_shutdown()
+// These options can be passed to zx_socket_shutdown().
#define ZX_SOCKET_SHUTDOWN_WRITE ((uint32_t)1u << 0)
#define ZX_SOCKET_SHUTDOWN_READ ((uint32_t)1u << 1)
#define ZX_SOCKET_SHUTDOWN_MASK (ZX_SOCKET_SHUTDOWN_WRITE | ZX_SOCKET_SHUTDOWN_READ)
-// These can be passed to zx_socket_create()
+// These can be passed to zx_socket_create().
#define ZX_SOCKET_STREAM ((uint32_t)0u)
#define ZX_SOCKET_DATAGRAM ((uint32_t)1u << 0)
-#define ZX_SOCKET_HAS_CONTROL ((uint32_t)1u << 1)
-#define ZX_SOCKET_HAS_ACCEPT ((uint32_t)1u << 2)
-#define ZX_SOCKET_CREATE_MASK (ZX_SOCKET_DATAGRAM | ZX_SOCKET_HAS_CONTROL | ZX_SOCKET_HAS_ACCEPT)
+#define ZX_SOCKET_CREATE_MASK (ZX_SOCKET_DATAGRAM)
-// These can be passed to zx_socket_read() and zx_socket_write().
-#define ZX_SOCKET_CONTROL ((uint32_t)1u << 2)
+// These can be passed to zx_socket_read().
+#define ZX_SOCKET_PEEK ((uint32_t)1u << 3)
+
+// These can be passed to zx_stream_create().
+#define ZX_STREAM_MODE_READ ((uint32_t)1u << 0)
+#define ZX_STREAM_MODE_WRITE ((uint32_t)1u << 1)
+#define ZX_STREAM_CREATE_MASK (ZX_STREAM_MODE_READ | ZX_STREAM_MODE_WRITE)
+
+// These can be passed to zx_stream_writev().
+#define ZX_STREAM_APPEND ((uint32_t)1u << 0)
+
+typedef uint32_t zx_stream_seek_origin_t;
+#define ZX_STREAM_SEEK_ORIGIN_START ((zx_stream_seek_origin_t)0u)
+#define ZX_STREAM_SEEK_ORIGIN_CURRENT ((zx_stream_seek_origin_t)1u)
+#define ZX_STREAM_SEEK_ORIGIN_END ((zx_stream_seek_origin_t)2u)
// Flags which can be used to to control cache policy for APIs which map memory.
#define ZX_CACHE_POLICY_CACHED ((uint32_t)0u)
@@ -316,11 +361,15 @@
#define ZX_TIMER_SLACK_LATE ((uint32_t)2u)
// Bus Transaction Initiator options.
-#define ZX_BTI_PERM_READ ((uint32_t)1u << 0)
-#define ZX_BTI_PERM_WRITE ((uint32_t)1u << 1)
-#define ZX_BTI_PERM_EXECUTE ((uint32_t)1u << 2)
-#define ZX_BTI_COMPRESS ((uint32_t)1u << 3)
-#define ZX_BTI_CONTIGUOUS ((uint32_t)1u << 4)
+#define ZX_BTI_PERM_READ ((uint32_t)1u << 0)
+#define ZX_BTI_PERM_WRITE ((uint32_t)1u << 1)
+#define ZX_BTI_PERM_EXECUTE ((uint32_t)1u << 2)
+#define ZX_BTI_COMPRESS ((uint32_t)1u << 3)
+#define ZX_BTI_CONTIGUOUS ((uint32_t)1u << 4)
+
+// Job options.
+// These options can be passed to zx_job_set_critical().
+#define ZX_JOB_CRITICAL_PROCESS_RETCODE_NONZERO ((uint32_t)1u << 0)
typedef uint32_t zx_obj_type_t;
@@ -349,8 +398,25 @@
#define ZX_OBJ_TYPE_PMT ((zx_obj_type_t)26u)
#define ZX_OBJ_TYPE_SUSPEND_TOKEN ((zx_obj_type_t)27u)
#define ZX_OBJ_TYPE_PAGER ((zx_obj_type_t)28u)
-#define ZX_OBJ_TYPE_LAST ((zx_obj_type_t)29u)
+#define ZX_OBJ_TYPE_EXCEPTION ((zx_obj_type_t)29u)
+#define ZX_OBJ_TYPE_CLOCK ((zx_obj_type_t)30u)
+#define ZX_OBJ_TYPE_STREAM ((zx_obj_type_t)31u)
+#define ZX_OBJ_TYPE_MSI_ALLOCATION ((zx_obj_type_t)32u)
+#define ZX_OBJ_TYPE_MSI_INTERRUPT ((zx_obj_type_t)33u)
+// System ABI commits to having no more than 64 object types.
+//
+// See zx_info_process_handle_stats_t for an example of a binary interface that
+// depends on having an upper bound for the number of object types.
+#define ZX_OBJ_TYPE_UPPER_BOUND ((zx_obj_type_t)64u)
+
+typedef uint32_t zx_system_event_type_t;
+#define ZX_SYSTEM_EVENT_OUT_OF_MEMORY ((zx_system_event_type_t)1u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_CRITICAL ((zx_system_event_type_t)2u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_WARNING ((zx_system_event_type_t)3u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_NORMAL ((zx_system_event_type_t)4u)
+
+// Used in channel_read_etc.
typedef struct zx_handle_info {
zx_handle_t handle;
zx_obj_type_t type;
@@ -358,6 +424,45 @@
uint32_t unused;
} zx_handle_info_t;
+typedef uint32_t zx_handle_op_t;
+
+#define ZX_HANDLE_OP_MOVE ((zx_handle_op_t)0u)
+#define ZX_HANDLE_OP_DUPLICATE ((zx_handle_op_t)1u)
+
+// Used in channel_write_etc.
+typedef struct zx_handle_disposition {
+ zx_handle_op_t operation;
+ zx_handle_t handle;
+ zx_obj_type_t type;
+ zx_rights_t rights;
+ zx_status_t result;
+} zx_handle_disposition_t;
+
+// Transaction ID and argument types for zx_channel_call.
+typedef uint32_t zx_txid_t;
+
+typedef struct zx_channel_call_args {
+ const void* wr_bytes;
+ const zx_handle_t* wr_handles;
+ void *rd_bytes;
+ zx_handle_t* rd_handles;
+ uint32_t wr_num_bytes;
+ uint32_t wr_num_handles;
+ uint32_t rd_num_bytes;
+ uint32_t rd_num_handles;
+} zx_channel_call_args_t;
+
+typedef struct zx_channel_call_etc_args {
+ const void* wr_bytes;
+ zx_handle_disposition_t* wr_handles;
+ void *rd_bytes;
+ zx_handle_info_t* rd_handles;
+ uint32_t wr_num_bytes;
+ uint32_t wr_num_handles;
+ uint32_t rd_num_bytes;
+ uint32_t rd_num_handles;
+} zx_channel_call_etc_args_t;
+
// The ZX_VM_FLAG_* constants are to be deprecated in favor of the ZX_VM_*
// versions.
#define ZX_VM_FLAG_PERM_READ ((uint32_t)1u << 0)
@@ -373,6 +478,24 @@
#define ZX_VM_FLAG_MAP_RANGE ((uint32_t)1u << 10)
#define ZX_VM_FLAG_REQUIRE_NON_RESIZABLE ((uint32_t)1u << 11)
+// CPU masks specifying sets of CPUs.
+//
+// We currently are limited to systems with 512 CPUs or less.
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
+#define ZX_CPU_SET_MAX_CPUS 512
+#define ZX_CPU_SET_BITS_PER_WORD 64
+
+typedef struct zx_cpu_set {
+ // The |N|'th CPU is considered in the CPU set if the bit:
+ //
+ // cpu_mask[N / ZX_CPU_SET_BITS_PER_WORD]
+ // & (1 << (N % ZX_CPU_SET_BITS_PER_WORD))
+ //
+ // is set.
+ uint64_t mask[ZX_CPU_SET_MAX_CPUS / ZX_CPU_SET_BITS_PER_WORD];
+} zx_cpu_set_t;
+
#ifdef __cplusplus
// We cannot use <stdatomic.h> with C++ code as _Atomic qualifier defined by
// C11 is not valid in C++11. There is not a single standard name that can
@@ -389,7 +512,8 @@
typedef atomic_int zx_futex_t;
#endif
#endif
+typedef int zx_futex_storage_t;
__END_CDECLS
-#endif // ZIRCON_TYPES_H_
+#endif // SYSROOT_ZIRCON_TYPES_H_
diff --git a/arch/arm64/sysroot/include/zircon/utc.h b/arch/arm64/sysroot/include/zircon/utc.h
new file mode 100644
index 0000000..180fd50
--- /dev/null
+++ b/arch/arm64/sysroot/include/zircon/utc.h
@@ -0,0 +1,71 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_UTC_H_
+#define SYSROOT_ZIRCON_UTC_H_
+
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// Accessors for the Zircon-specific UTC clock reference maintained by the
+// language runtime
+
+// zx_utc_reference_get
+//
+// Returns a handle to the currently assigned UTC clock, or ZX_HANDLE_INVALID if
+// no such clock currently exists. The handle returned has borrow semantics,
+// and should never be directly closed by the user. If a program wishes to take
+// ownership of the clock, it should do so using |zx_utc_reference_swap|.
+//
+// Thread safety is the responsibility of the user. In particular, if a clock
+// is fetched by a user using |zx_utc_reference_get|, but then the clock is
+// swapped out using |zx_utc_reference_swap| and the original clock is closed,
+// then the initial clock handle returned is now invalid and could result in a
+// use-after-close situation. It is the user's responsibility to avoid these
+// situations.
+//
+zx_handle_t _zx_utc_reference_get(void);
+zx_handle_t zx_utc_reference_get(void);
+
+// zx_utc_reference_swap
+//
+// Atomically swap the clock handle provided with the current UTC reference.
+//
+// Upon success, the runtime takes ownership of the handle provided by
+// |new_utc_reference| and returns the previous clock handle to the caller via
+// |prev_utc_reference_out|, or ZX_HANDLE_INVALID if no clock was currently
+// assigned. The clock returned via swap is now owned by the caller.
+//
+// In the case of failure, the handle passed in by new_utc_reference will be
+// consumed, and the clock held by the runtime will remain unchanged.
+//
+// Clock handles provided to libc via zx_utc_reference_swap must have read rights
+// or they will be rejected.
+//
+// Parameters:
+// new_utc_reference : A handle to the clock to install as the UTC reference.
+// Ownership of this handle will _always_ be consumed
+// by zx_utc_reference_swap.
+// prev_utc_reference_out : Either the handle to the previous UTC clock (success
+// case), or ZX_HANDLE_INVALID in the case of failure.
+// If a valid handle is returned in this out parameter,
+// it is _always_ owned by the caller after the call.
+// It is illegal to pass NULL for this parameter.
+//
+//
+// Return Values:
+// If a new clock reference is being provided, the return value of
+// |zx_utc_reference_swap| will be the result of a |zx_clock_read| call made to
+// verify the clock. If ZX_HANDLE_INVALID was passed in order to uninstall a
+// reference clock, the function cannot fail and will always return ZX_OK.
+//
+zx_status_t _zx_utc_reference_swap(zx_handle_t new_utc_reference,
+ zx_handle_t* prev_utc_reference_out) __NONNULL((2));
+zx_status_t zx_utc_reference_swap(zx_handle_t new_utc_reference,
+ zx_handle_t* prev_utc_reference_out) __NONNULL((2));
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_UTC_H_
diff --git a/arch/arm64/sysroot/lib/Scrt1.o b/arch/arm64/sysroot/lib/Scrt1.o
index ceef414..cbbd2f6 100644
--- a/arch/arm64/sysroot/lib/Scrt1.o
+++ b/arch/arm64/sysroot/lib/Scrt1.o
Binary files differ
diff --git a/arch/arm64/sysroot/lib/libc.so b/arch/arm64/sysroot/lib/libc.so
index aef212b..7a15850 100755
--- a/arch/arm64/sysroot/lib/libc.so
+++ b/arch/arm64/sysroot/lib/libc.so
Binary files differ
diff --git a/arch/arm64/sysroot/lib/libzircon.so b/arch/arm64/sysroot/lib/libzircon.so
index 9985d58..41436d0 100755
--- a/arch/arm64/sysroot/lib/libzircon.so
+++ b/arch/arm64/sysroot/lib/libzircon.so
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_core_validation.so b/arch/x64/dist/libVkLayer_core_validation.so
deleted file mode 100755
index d11db74..0000000
--- a/arch/x64/dist/libVkLayer_core_validation.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_image_pipe_swapchain.so b/arch/x64/dist/libVkLayer_image_pipe_swapchain.so
deleted file mode 100755
index d94a22e..0000000
--- a/arch/x64/dist/libVkLayer_image_pipe_swapchain.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_object_tracker.so b/arch/x64/dist/libVkLayer_object_tracker.so
deleted file mode 100755
index c30fdd4..0000000
--- a/arch/x64/dist/libVkLayer_object_tracker.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_parameter_validation.so b/arch/x64/dist/libVkLayer_parameter_validation.so
deleted file mode 100755
index 5661ecb..0000000
--- a/arch/x64/dist/libVkLayer_parameter_validation.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_threading.so b/arch/x64/dist/libVkLayer_threading.so
deleted file mode 100755
index 4664719..0000000
--- a/arch/x64/dist/libVkLayer_threading.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libVkLayer_unique_objects.so b/arch/x64/dist/libVkLayer_unique_objects.so
deleted file mode 100755
index bcb6c68..0000000
--- a/arch/x64/dist/libVkLayer_unique_objects.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libasync-default.so b/arch/x64/dist/libasync-default.so
deleted file mode 100755
index e57cac5..0000000
--- a/arch/x64/dist/libasync-default.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libfdio.so b/arch/x64/dist/libfdio.so
index e27ae92..163c2e0 100755
--- a/arch/x64/dist/libfdio.so
+++ b/arch/x64/dist/libfdio.so
Binary files differ
diff --git a/arch/x64/dist/libmemfs.so b/arch/x64/dist/libmemfs.so
deleted file mode 100755
index 829662b..0000000
--- a/arch/x64/dist/libmemfs.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libsvc.so b/arch/x64/dist/libsvc.so
deleted file mode 100755
index b1736b0..0000000
--- a/arch/x64/dist/libsvc.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libsyslog.so b/arch/x64/dist/libsyslog.so
deleted file mode 100755
index 990253a..0000000
--- a/arch/x64/dist/libsyslog.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libtrace-engine.so b/arch/x64/dist/libtrace-engine.so
deleted file mode 100755
index 99eddbe..0000000
--- a/arch/x64/dist/libtrace-engine.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/dist/libvulkan.so b/arch/x64/dist/libvulkan.so
deleted file mode 100755
index 001f83a..0000000
--- a/arch/x64/dist/libvulkan.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libasync-default.so b/arch/x64/lib/libasync-default.so
deleted file mode 100755
index b5e0808..0000000
--- a/arch/x64/lib/libasync-default.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libfdio.so b/arch/x64/lib/libfdio.so
index c504a0b..163c2e0 100755
--- a/arch/x64/lib/libfdio.so
+++ b/arch/x64/lib/libfdio.so
Binary files differ
diff --git a/arch/x64/lib/libmemfs.so b/arch/x64/lib/libmemfs.so
deleted file mode 100755
index 1e58f43..0000000
--- a/arch/x64/lib/libmemfs.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libsvc.so b/arch/x64/lib/libsvc.so
deleted file mode 100755
index b1736b0..0000000
--- a/arch/x64/lib/libsvc.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libsync.a b/arch/x64/lib/libsync.a
index c656320..a1a266f 100644
--- a/arch/x64/lib/libsync.a
+++ b/arch/x64/lib/libsync.a
Binary files differ
diff --git a/arch/x64/lib/libsyslog.so b/arch/x64/lib/libsyslog.so
deleted file mode 100755
index 5eab748..0000000
--- a/arch/x64/lib/libsyslog.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libtrace-engine.so b/arch/x64/lib/libtrace-engine.so
deleted file mode 100755
index 2938916..0000000
--- a/arch/x64/lib/libtrace-engine.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/lib/libvulkan.so b/arch/x64/lib/libvulkan.so
deleted file mode 100755
index 001f83a..0000000
--- a/arch/x64/lib/libvulkan.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/sysroot/debug/libc.so b/arch/x64/sysroot/debug/libc.so
deleted file mode 100755
index fa4fc80..0000000
--- a/arch/x64/sysroot/debug/libc.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/sysroot/debug/libzircon.so b/arch/x64/sysroot/debug/libzircon.so
deleted file mode 100755
index 9043c37..0000000
--- a/arch/x64/sysroot/debug/libzircon.so
+++ /dev/null
Binary files differ
diff --git a/arch/x64/sysroot/dist/lib/asan-ubsan/ld.so.1 b/arch/x64/sysroot/dist/lib/asan-ubsan/ld.so.1
new file mode 100755
index 0000000..4af158d
--- /dev/null
+++ b/arch/x64/sysroot/dist/lib/asan-ubsan/ld.so.1
Binary files differ
diff --git a/arch/x64/sysroot/dist/lib/asan/ld.so.1 b/arch/x64/sysroot/dist/lib/asan/ld.so.1
new file mode 100755
index 0000000..1ae8ce7
--- /dev/null
+++ b/arch/x64/sysroot/dist/lib/asan/ld.so.1
Binary files differ
diff --git a/arch/x64/sysroot/dist/lib/ld.so.1 b/arch/x64/sysroot/dist/lib/ld.so.1
index 375c845..2717357 100755
--- a/arch/x64/sysroot/dist/lib/ld.so.1
+++ b/arch/x64/sysroot/dist/lib/ld.so.1
Binary files differ
diff --git a/arch/x64/sysroot/include/alloca.h b/arch/x64/sysroot/include/alloca.h
index c1679dd..7deb5b9 100644
--- a/arch/x64/sysroot/include/alloca.h
+++ b/arch/x64/sysroot/include/alloca.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ALLOCA_H_
+#define SYSROOT_ALLOCA_H_
#ifdef __cplusplus
extern "C" {
@@ -16,3 +17,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ALLOCA_H_
diff --git a/arch/x64/sysroot/include/ar.h b/arch/x64/sysroot/include/ar.h
index d20348b..d0d4176 100644
--- a/arch/x64/sysroot/include/ar.h
+++ b/arch/x64/sysroot/include/ar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_AR_H_
+#define SYSROOT_AR_H_
#ifdef __cplusplus
extern "C" {
@@ -9,14 +10,16 @@
#define ARFMAG "`\n"
struct ar_hdr {
- char ar_name[16];
- char ar_date[12];
- char ar_uid[6], ar_gid[6];
- char ar_mode[8];
- char ar_size[10];
- char ar_fmag[2];
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6], ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_AR_H_
diff --git a/arch/x64/sysroot/include/arpa/ftp.h b/arch/x64/sysroot/include/arpa/ftp.h
index e1b66d3..7d86bec 100644
--- a/arch/x64/sysroot/include/arpa/ftp.h
+++ b/arch/x64/sysroot/include/arpa/ftp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_FTP_H_
+#define SYSROOT_ARPA_FTP_H_
#define PRELIM 1
#define COMPLETE 2
@@ -32,3 +33,5 @@
char* typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local"};
char* formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control"};
#endif
+
+#endif // SYSROOT_ARPA_FTP_H_
diff --git a/arch/x64/sysroot/include/arpa/inet.h b/arch/x64/sysroot/include/arpa/inet.h
index cfb02ea..4fa0af5 100644
--- a/arch/x64/sysroot/include/arpa/inet.h
+++ b/arch/x64/sysroot/include/arpa/inet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_INET_H_
+#define SYSROOT_ARPA_INET_H_
#ifdef __cplusplus
extern "C" {
@@ -31,3 +32,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ARPA_INET_H_
diff --git a/arch/x64/sysroot/include/arpa/nameser.h b/arch/x64/sysroot/include/arpa/nameser.h
index 9218a58..734d205 100644
--- a/arch/x64/sysroot/include/arpa/nameser.h
+++ b/arch/x64/sysroot/include/arpa/nameser.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_NAMESER_H_
+#define SYSROOT_ARPA_NAMESER_H_
#ifdef __cplusplus
extern "C" {
@@ -25,27 +26,27 @@
#define NS_DEFAULTPORT 53
typedef enum __ns_sect {
- ns_s_qd = 0,
- ns_s_zn = 0,
- ns_s_an = 1,
- ns_s_pr = 1,
- ns_s_ns = 2,
- ns_s_ud = 2,
- ns_s_ar = 3,
- ns_s_max = 4
+ ns_s_qd = 0,
+ ns_s_zn = 0,
+ ns_s_an = 1,
+ ns_s_pr = 1,
+ ns_s_ns = 2,
+ ns_s_ud = 2,
+ ns_s_ar = 3,
+ ns_s_max = 4
} ns_sect;
typedef struct __ns_msg {
- const unsigned char *_msg, *_eom;
- uint16_t _id, _flags, _counts[ns_s_max];
- const unsigned char* _sections[ns_s_max];
- ns_sect _sect;
- int _rrnum;
- const unsigned char* _msg_ptr;
+ const unsigned char *_msg, *_eom;
+ uint16_t _id, _flags, _counts[ns_s_max];
+ const unsigned char* _sections[ns_s_max];
+ ns_sect _sect;
+ int _rrnum;
+ const unsigned char* _msg_ptr;
} ns_msg;
struct _ns_flagdata {
- int mask, shift;
+ int mask, shift;
};
extern const struct _ns_flagdata _ns_flagdata[];
@@ -55,15 +56,15 @@
#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
#define ns_msg_getflag(handle, flag) \
- (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
+ (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
typedef struct __ns_rr {
- char name[NS_MAXDNAME];
- uint16_t type;
- uint16_t rr_class;
- uint32_t ttl;
- uint16_t rdlength;
- const unsigned char* rdata;
+ char name[NS_MAXDNAME];
+ uint16_t type;
+ uint16_t rr_class;
+ uint32_t ttl;
+ uint16_t rdlength;
+ const unsigned char* rdata;
} ns_rr;
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
@@ -74,66 +75,66 @@
#define ns_rr_rdata(rr) ((rr).rdata + 0)
typedef enum __ns_flag {
- ns_f_qr,
- ns_f_opcode,
- ns_f_aa,
- ns_f_tc,
- ns_f_rd,
- ns_f_ra,
- ns_f_z,
- ns_f_ad,
- ns_f_cd,
- ns_f_rcode,
- ns_f_max
+ ns_f_qr,
+ ns_f_opcode,
+ ns_f_aa,
+ ns_f_tc,
+ ns_f_rd,
+ ns_f_ra,
+ ns_f_z,
+ ns_f_ad,
+ ns_f_cd,
+ ns_f_rcode,
+ ns_f_max
} ns_flag;
typedef enum __ns_opcode {
- ns_o_query = 0,
- ns_o_iquery = 1,
- ns_o_status = 2,
- ns_o_notify = 4,
- ns_o_update = 5,
- ns_o_max = 6
+ ns_o_query = 0,
+ ns_o_iquery = 1,
+ ns_o_status = 2,
+ ns_o_notify = 4,
+ ns_o_update = 5,
+ ns_o_max = 6
} ns_opcode;
typedef enum __ns_rcode {
- ns_r_noerror = 0,
- ns_r_formerr = 1,
- ns_r_servfail = 2,
- ns_r_nxdomain = 3,
- ns_r_notimpl = 4,
- ns_r_refused = 5,
- ns_r_yxdomain = 6,
- ns_r_yxrrset = 7,
- ns_r_nxrrset = 8,
- ns_r_notauth = 9,
- ns_r_notzone = 10,
- ns_r_max = 11,
- ns_r_badvers = 16,
- ns_r_badsig = 16,
- ns_r_badkey = 17,
- ns_r_badtime = 18
+ ns_r_noerror = 0,
+ ns_r_formerr = 1,
+ ns_r_servfail = 2,
+ ns_r_nxdomain = 3,
+ ns_r_notimpl = 4,
+ ns_r_refused = 5,
+ ns_r_yxdomain = 6,
+ ns_r_yxrrset = 7,
+ ns_r_nxrrset = 8,
+ ns_r_notauth = 9,
+ ns_r_notzone = 10,
+ ns_r_max = 11,
+ ns_r_badvers = 16,
+ ns_r_badsig = 16,
+ ns_r_badkey = 17,
+ ns_r_badtime = 18
} ns_rcode;
typedef enum __ns_update_operation {
- ns_uop_delete = 0,
- ns_uop_add = 1,
- ns_uop_max = 2
+ ns_uop_delete = 0,
+ ns_uop_add = 1,
+ ns_uop_max = 2
} ns_update_operation;
struct ns_tsig_key {
- char name[NS_MAXDNAME], alg[NS_MAXDNAME];
- unsigned char* data;
- int len;
+ char name[NS_MAXDNAME], alg[NS_MAXDNAME];
+ unsigned char* data;
+ int len;
};
typedef struct ns_tsig_key ns_tsig_key;
struct ns_tcp_tsig_state {
- int counter;
- struct dst_key* key;
- void* ctx;
- unsigned char sig[NS_PACKETSZ];
- int siglen;
+ int counter;
+ struct dst_key* key;
+ void* ctx;
+ unsigned char sig[NS_PACKETSZ];
+ int siglen;
};
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
@@ -146,58 +147,58 @@
#define NS_TSIG_ERROR_FORMERR -12
typedef enum __ns_type {
- ns_t_invalid = 0,
- ns_t_a = 1,
- ns_t_ns = 2,
- ns_t_md = 3,
- ns_t_mf = 4,
- ns_t_cname = 5,
- ns_t_soa = 6,
- ns_t_mb = 7,
- ns_t_mg = 8,
- ns_t_mr = 9,
- ns_t_null = 10,
- ns_t_wks = 11,
- ns_t_ptr = 12,
- ns_t_hinfo = 13,
- ns_t_minfo = 14,
- ns_t_mx = 15,
- ns_t_txt = 16,
- ns_t_rp = 17,
- ns_t_afsdb = 18,
- ns_t_x25 = 19,
- ns_t_isdn = 20,
- ns_t_rt = 21,
- ns_t_nsap = 22,
- ns_t_nsap_ptr = 23,
- ns_t_sig = 24,
- ns_t_key = 25,
- ns_t_px = 26,
- ns_t_gpos = 27,
- ns_t_aaaa = 28,
- ns_t_loc = 29,
- ns_t_nxt = 30,
- ns_t_eid = 31,
- ns_t_nimloc = 32,
- ns_t_srv = 33,
- ns_t_atma = 34,
- ns_t_naptr = 35,
- ns_t_kx = 36,
- ns_t_cert = 37,
- ns_t_a6 = 38,
- ns_t_dname = 39,
- ns_t_sink = 40,
- ns_t_opt = 41,
- ns_t_apl = 42,
- ns_t_tkey = 249,
- ns_t_tsig = 250,
- ns_t_ixfr = 251,
- ns_t_axfr = 252,
- ns_t_mailb = 253,
- ns_t_maila = 254,
- ns_t_any = 255,
- ns_t_zxfr = 256,
- ns_t_max = 65536
+ ns_t_invalid = 0,
+ ns_t_a = 1,
+ ns_t_ns = 2,
+ ns_t_md = 3,
+ ns_t_mf = 4,
+ ns_t_cname = 5,
+ ns_t_soa = 6,
+ ns_t_mb = 7,
+ ns_t_mg = 8,
+ ns_t_mr = 9,
+ ns_t_null = 10,
+ ns_t_wks = 11,
+ ns_t_ptr = 12,
+ ns_t_hinfo = 13,
+ ns_t_minfo = 14,
+ ns_t_mx = 15,
+ ns_t_txt = 16,
+ ns_t_rp = 17,
+ ns_t_afsdb = 18,
+ ns_t_x25 = 19,
+ ns_t_isdn = 20,
+ ns_t_rt = 21,
+ ns_t_nsap = 22,
+ ns_t_nsap_ptr = 23,
+ ns_t_sig = 24,
+ ns_t_key = 25,
+ ns_t_px = 26,
+ ns_t_gpos = 27,
+ ns_t_aaaa = 28,
+ ns_t_loc = 29,
+ ns_t_nxt = 30,
+ ns_t_eid = 31,
+ ns_t_nimloc = 32,
+ ns_t_srv = 33,
+ ns_t_atma = 34,
+ ns_t_naptr = 35,
+ ns_t_kx = 36,
+ ns_t_cert = 37,
+ ns_t_a6 = 38,
+ ns_t_dname = 39,
+ ns_t_sink = 40,
+ ns_t_opt = 41,
+ ns_t_apl = 42,
+ ns_t_tkey = 249,
+ ns_t_tsig = 250,
+ ns_t_ixfr = 251,
+ ns_t_axfr = 252,
+ ns_t_mailb = 253,
+ ns_t_maila = 254,
+ ns_t_any = 255,
+ ns_t_zxfr = 256,
+ ns_t_max = 65536
} ns_type;
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || (t) == ns_t_mailb || (t) == ns_t_maila)
@@ -207,29 +208,29 @@
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || (t) == ns_t_zxfr)
typedef enum __ns_class {
- ns_c_invalid = 0,
- ns_c_in = 1,
- ns_c_2 = 2,
- ns_c_chaos = 3,
- ns_c_hs = 4,
- ns_c_none = 254,
- ns_c_any = 255,
- ns_c_max = 65536
+ ns_c_invalid = 0,
+ ns_c_in = 1,
+ ns_c_2 = 2,
+ ns_c_chaos = 3,
+ ns_c_hs = 4,
+ ns_c_none = 254,
+ ns_c_any = 255,
+ ns_c_max = 65536
} ns_class;
typedef enum __ns_key_types {
- ns_kt_rsa = 1,
- ns_kt_dh = 2,
- ns_kt_dsa = 3,
- ns_kt_private = 254
+ ns_kt_rsa = 1,
+ ns_kt_dh = 2,
+ ns_kt_dsa = 3,
+ ns_kt_private = 254
} ns_key_types;
typedef enum __ns_cert_types {
- cert_t_pkix = 1,
- cert_t_spki = 2,
- cert_t_pgp = 3,
- cert_t_url = 253,
- cert_t_oid = 254
+ cert_t_pkix = 1,
+ cert_t_spki = 2,
+ cert_t_pgp = 3,
+ cert_t_url = 253,
+ cert_t_oid = 254
} ns_cert_types;
#define NS_KEY_TYPEMASK 0xC000
@@ -253,9 +254,9 @@
#define NS_KEY_RESERVED10 0x0020
#define NS_KEY_RESERVED11 0x0010
#define NS_KEY_SIGNATORYMASK 0x000F
-#define NS_KEY_RESERVED_BITMASK \
- (NS_KEY_RESERVED2 | NS_KEY_RESERVED4 | NS_KEY_RESERVED5 | NS_KEY_RESERVED8 | \
- NS_KEY_RESERVED9 | NS_KEY_RESERVED10 | NS_KEY_RESERVED11)
+#define NS_KEY_RESERVED_BITMASK \
+ (NS_KEY_RESERVED2 | NS_KEY_RESERVED4 | NS_KEY_RESERVED5 | NS_KEY_RESERVED8 | NS_KEY_RESERVED9 | \
+ NS_KEY_RESERVED10 | NS_KEY_RESERVED11)
#define NS_KEY_RESERVED_BITMASK2 0xFFFF
#define NS_ALG_MD5RSA 1
#define NS_ALG_DH 2
@@ -317,34 +318,34 @@
#define __BIND 19950621
typedef struct {
- unsigned id : 16;
+ unsigned id : 16;
#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned qr : 1;
- unsigned opcode : 4;
- unsigned aa : 1;
- unsigned tc : 1;
- unsigned rd : 1;
- unsigned ra : 1;
- unsigned unused : 1;
- unsigned ad : 1;
- unsigned cd : 1;
- unsigned rcode : 4;
+ unsigned qr : 1;
+ unsigned opcode : 4;
+ unsigned aa : 1;
+ unsigned tc : 1;
+ unsigned rd : 1;
+ unsigned ra : 1;
+ unsigned unused : 1;
+ unsigned ad : 1;
+ unsigned cd : 1;
+ unsigned rcode : 4;
#else
- unsigned rd : 1;
- unsigned tc : 1;
- unsigned aa : 1;
- unsigned opcode : 4;
- unsigned qr : 1;
- unsigned rcode : 4;
- unsigned cd : 1;
- unsigned ad : 1;
- unsigned unused : 1;
- unsigned ra : 1;
+ unsigned rd : 1;
+ unsigned tc : 1;
+ unsigned aa : 1;
+ unsigned opcode : 4;
+ unsigned qr : 1;
+ unsigned rcode : 4;
+ unsigned cd : 1;
+ unsigned ad : 1;
+ unsigned unused : 1;
+ unsigned ra : 1;
#endif
- unsigned qdcount : 16;
- unsigned ancount : 16;
- unsigned nscount : 16;
- unsigned arcount : 16;
+ unsigned qdcount : 16;
+ unsigned ancount : 16;
+ unsigned nscount : 16;
+ unsigned arcount : 16;
} HEADER;
#define PACKETSZ NS_PACKETSZ
@@ -446,3 +447,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ARPA_NAMESER_H_
diff --git a/arch/x64/sysroot/include/arpa/telnet.h b/arch/x64/sysroot/include/arpa/telnet.h
index d6880cf..2da3eda 100644
--- a/arch/x64/sysroot/include/arpa/telnet.h
+++ b/arch/x64/sysroot/include/arpa/telnet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_TELNET_H_
+#define SYSROOT_ARPA_TELNET_H_
#define IAC 255
#define DONT 254
@@ -23,10 +24,9 @@
#define SYNCH 242
-#define telcmds \
- ((char[][6]){ \
- "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", \
- "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0})
+#define telcmds \
+ ((char[][6]){"EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", \
+ "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0})
#define TELCMD_FIRST xEOF
#define TELCMD_LAST IAC
@@ -176,9 +176,9 @@
#define NSLC 18
-#define SLC_NAMELIST \
- "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#define SLC_NAMELIST \
+ "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
#ifdef SLC_NAMES
char* slc_names[] = {SLC_NAMELIST};
#else
@@ -256,11 +256,14 @@
#ifdef ENCRYPT_NAMES
char* encrypt_names[] = {
- "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START",
+ "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START",
"REQUEST-END", "ENC-KEYID", "DEC-KEYID", 0,
};
char* enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64", 0,
+ "ANY",
+ "DES_CFB64",
+ "DES_OFB64",
+ 0,
};
#else
extern char* encrypt_names[];
@@ -272,3 +275,5 @@
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
+
+#endif // SYSROOT_ARPA_TELNET_H_
diff --git a/arch/x64/sysroot/include/arpa/tftp.h b/arch/x64/sysroot/include/arpa/tftp.h
index 3a76d2f..e091368 100644
--- a/arch/x64/sysroot/include/arpa/tftp.h
+++ b/arch/x64/sysroot/include/arpa/tftp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ARPA_TFTP_H_
+#define SYSROOT_ARPA_TFTP_H_
#define SEGSIZE 512
#define RRQ 01
@@ -7,13 +8,13 @@
#define ACK 04
#define ERROR 05
struct tftphdr {
- short th_opcode;
- union {
- unsigned short tu_block;
- short tu_code;
- char tu_stuff[1];
- } th_u;
- char th_data[1];
+ short th_opcode;
+ union {
+ unsigned short tu_block;
+ short tu_code;
+ char tu_stuff[1];
+ } th_u;
+ char th_data[1];
};
#define th_block th_u.tu_block
#define th_code th_u.tu_code
@@ -27,3 +28,5 @@
#define EBADID 5
#define EEXISTS 6
#define ENOUSER 7
+
+#endif // SYSROOT_ARPA_TFTP_H_
diff --git a/arch/x64/sysroot/include/bits/aarch64/fenv.h b/arch/x64/sysroot/include/bits/aarch64/fenv.h
index 6bb1f56..a370540 100644
--- a/arch/x64/sysroot/include/bits/aarch64/fenv.h
+++ b/arch/x64/sysroot/include/bits/aarch64/fenv.h
@@ -12,8 +12,8 @@
typedef unsigned int fexcept_t;
typedef struct {
- unsigned int __fpcr;
- unsigned int __fpsr;
+ unsigned int __fpcr;
+ unsigned int __fpsr;
} fenv_t;
#define FE_DFL_ENV ((const fenv_t*)-1)
diff --git a/arch/x64/sysroot/include/bits/aarch64/float.h b/arch/x64/sysroot/include/bits/aarch64/float.h
deleted file mode 100644
index 719c790..0000000
--- a/arch/x64/sysroot/include/bits/aarch64/float.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#define FLT_EVAL_METHOD 0
-
-#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
-#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
-#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
-#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
-
-#define LDBL_MANT_DIG 113
-#define LDBL_MIN_EXP (-16381)
-#define LDBL_MAX_EXP 16384
-
-#define LDBL_DIG 33
-#define LDBL_MIN_10_EXP (-4931)
-#define LDBL_MAX_10_EXP 4932
-
-#define DECIMAL_DIG 36
diff --git a/arch/x64/sysroot/include/bits/aarch64/ioctl.h b/arch/x64/sysroot/include/bits/aarch64/ioctl.h
index f963024..40835ba 100644
--- a/arch/x64/sysroot/include/bits/aarch64/ioctl.h
+++ b/arch/x64/sysroot/include/bits/aarch64/ioctl.h
@@ -94,10 +94,10 @@
#define TIOCSER_TEMT 0x01
struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
};
#define TIOCM_LE 0x001
diff --git a/arch/x64/sysroot/include/bits/aarch64/ipc.h b/arch/x64/sysroot/include/bits/aarch64/ipc.h
index df2ed2b..26161a2 100644
--- a/arch/x64/sysroot/include/bits/aarch64/ipc.h
+++ b/arch/x64/sysroot/include/bits/aarch64/ipc.h
@@ -1,14 +1,14 @@
struct ipc_perm {
- key_t __ipc_perm_key;
- uid_t uid;
- gid_t gid;
- uid_t cuid;
- gid_t cgid;
- mode_t mode;
- unsigned short __ipc_perm_seq;
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ unsigned short __ipc_perm_seq;
- unsigned long __pad1;
- unsigned long __pad2;
+ unsigned long __pad1;
+ unsigned long __pad2;
};
#define IPC_64 0
diff --git a/arch/x64/sysroot/include/bits/aarch64/setjmp.h b/arch/x64/sysroot/include/bits/aarch64/setjmp.h
index e3db976..c37aeb8 100644
--- a/arch/x64/sysroot/include/bits/aarch64/setjmp.h
+++ b/arch/x64/sysroot/include/bits/aarch64/setjmp.h
@@ -1 +1 @@
-typedef unsigned long long int __jmp_buf[22];
+typedef unsigned long long int __jmp_buf[23];
diff --git a/arch/x64/sysroot/include/bits/aarch64/signal.h b/arch/x64/sysroot/include/bits/aarch64/signal.h
index 766d3f9..64e57f3 100644
--- a/arch/x64/sysroot/include/bits/aarch64/signal.h
+++ b/arch/x64/sysroot/include/bits/aarch64/signal.h
@@ -11,49 +11,51 @@
typedef unsigned long gregset_t[34];
typedef struct {
- long double vregs[32];
- unsigned int fpsr;
- unsigned int fpcr;
+ long double vregs[32];
+ unsigned int fpsr;
+ unsigned int fpcr;
} fpregset_t;
typedef struct sigcontext {
- unsigned long fault_address;
- unsigned long regs[31];
- unsigned long sp, pc, pstate;
- long double __reserved[256];
+ unsigned long fault_address;
+ unsigned long regs[31];
+ unsigned long sp, pc, pstate;
+ long double __reserved[256];
} mcontext_t;
#define FPSIMD_MAGIC 0x46508001
#define ESR_MAGIC 0x45535201
struct _aarch64_ctx {
- unsigned int magic;
- unsigned int size;
+ unsigned int magic;
+ unsigned int size;
};
struct fpsimd_context {
- struct _aarch64_ctx head;
- unsigned int fpsr;
- unsigned int fpcr;
- long double vregs[32];
+ struct _aarch64_ctx head;
+ unsigned int fpsr;
+ unsigned int fpcr;
+ long double vregs[32];
};
struct esr_context {
- struct _aarch64_ctx head;
- unsigned long esr;
+ struct _aarch64_ctx head;
+ unsigned long esr;
};
#else
-typedef struct { long double __regs[18 + 256]; } mcontext_t;
+typedef struct {
+ long double __regs[18 + 256];
+} mcontext_t;
#endif
struct sigaltstack {
- void* ss_sp;
- int ss_flags;
- size_t ss_size;
+ void* ss_sp;
+ int ss_flags;
+ size_t ss_size;
};
typedef struct __ucontext {
- unsigned long uc_flags;
- struct ucontext* uc_link;
- stack_t uc_stack;
- sigset_t uc_sigmask;
- mcontext_t uc_mcontext;
+ unsigned long uc_flags;
+ struct ucontext* uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
} ucontext_t;
#define SA_NOCLDSTOP 1
diff --git a/arch/x64/sysroot/include/bits/aarch64/stat.h b/arch/x64/sysroot/include/bits/aarch64/stat.h
index 0fe7e69..02102fa 100644
--- a/arch/x64/sysroot/include/bits/aarch64/stat.h
+++ b/arch/x64/sysroot/include/bits/aarch64/stat.h
@@ -1,18 +1,18 @@
struct stat {
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- unsigned long __pad;
- off_t st_size;
- blksize_t st_blksize;
- int __pad2;
- blkcnt_t st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned __unused[2];
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ unsigned long __pad;
+ off_t st_size;
+ blksize_t st_blksize;
+ int __pad2;
+ blkcnt_t st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned __unused1[2];
};
diff --git a/arch/x64/sysroot/include/bits/alltypes.h b/arch/x64/sysroot/include/bits/alltypes.h
index 21fcb7f..95da44c 100644
--- a/arch/x64/sysroot/include/bits/alltypes.h
+++ b/arch/x64/sysroot/include/bits/alltypes.h
@@ -193,8 +193,8 @@
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
typedef struct {
- long long __ll;
- long double __ld;
+ long long __ll;
+ long double __ld;
} max_align_t;
#define __DEFINED_max_align_t
#endif
@@ -310,24 +310,24 @@
#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
struct iovec {
- void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
#define __DEFINED_struct_iovec
#endif
#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
struct timeval {
- time_t tv_sec;
- suseconds_t tv_usec;
+ time_t tv_sec;
+ suseconds_t tv_usec;
};
#define __DEFINED_struct_timeval
#endif
#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
struct timespec {
- time_t tv_sec;
- long tv_nsec;
+ time_t tv_sec;
+ long tv_nsec;
};
#define __DEFINED_struct_timespec
#endif
@@ -373,7 +373,9 @@
#endif
#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
-typedef struct __sigset_t { unsigned long __bits[128 / sizeof(long)]; } sigset_t;
+typedef struct __sigset_t {
+ unsigned long __bits[128 / sizeof(long)];
+} sigset_t;
#define __DEFINED_sigset_t
#endif
@@ -398,22 +400,30 @@
#endif
#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
-typedef struct { unsigned __attr; } pthread_mutexattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_mutexattr_t;
#define __DEFINED_pthread_mutexattr_t
#endif
#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
-typedef struct { unsigned __attr; } pthread_condattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_condattr_t;
#define __DEFINED_pthread_condattr_t
#endif
#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
-typedef struct { unsigned __attr; } pthread_barrierattr_t;
+typedef struct {
+ unsigned __attr;
+} pthread_barrierattr_t;
#define __DEFINED_pthread_barrierattr_t
#endif
#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
-typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+typedef struct {
+ unsigned __attr[2];
+} pthread_rwlockattr_t;
#define __DEFINED_pthread_rwlockattr_t
#endif
@@ -432,31 +442,35 @@
#endif
#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
-typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
+typedef struct __mbstate_t {
+ unsigned __opaque1, __opaque2;
+} mbstate_t;
#define __DEFINED_mbstate_t
#endif
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
typedef struct {
- const char* __name;
- int __c11;
- size_t _a_stacksize;
- size_t _a_guardsize;
- void* _a_stackaddr;
- int _a_detach;
- int _a_sched;
- int _a_policy;
- int _a_prio;
+ const char* __name;
+ int __c11;
+ size_t _a_stacksize;
+ size_t _a_guardsize;
+ void* _a_stackaddr;
+ int _a_detach;
+ int _a_sched;
+ int _a_policy;
+ int _a_prio;
} pthread_attr_t;
#define __DEFINED_pthread_attr_t
#endif
#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
typedef struct {
- int _m_type;
- __C11_ATOMIC(int) _m_lock;
- __C11_ATOMIC(int) _m_waiters;
- int _m_count;
+ unsigned _m_attr;
+ __C11_ATOMIC(int)
+ _m_lock;
+ __C11_ATOMIC(int)
+ _m_waiters;
+ int _m_count;
} pthread_mutex_t;
#define __DEFINED_pthread_mutex_t
#endif
@@ -467,55 +481,64 @@
__attribute__((__capability__("mutex")))
#endif
{
- int __i[1];
+ int __i[1];
} mtx_t;
#define __DEFINED_mtx_t
#endif
#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
typedef struct {
- void* _c_head;
- int _c_clock;
- void* _c_tail;
- __C11_ATOMIC(int) _c_lock;
+ void* _c_head;
+ int _c_clock;
+ void* _c_tail;
+ __C11_ATOMIC(int)
+ _c_lock;
} pthread_cond_t;
#define __DEFINED_pthread_cond_t
#endif
#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
typedef struct {
- void* _c_head;
- int _c_clock;
- void* _c_tail;
- __C11_ATOMIC(int) _c_lock;
+ void* _c_head;
+ int _c_clock;
+ void* _c_tail;
+ __C11_ATOMIC(int) _c_lock;
} cnd_t;
#define __DEFINED_cnd_t
#endif
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
typedef struct {
- __C11_ATOMIC(int) _rw_lock;
- __C11_ATOMIC(int) _rw_waiters;
+ __C11_ATOMIC(int)
+ _rw_lock;
+ __C11_ATOMIC(int)
+ _rw_waiters;
} pthread_rwlock_t;
#define __DEFINED_pthread_rwlock_t
#endif
#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
typedef struct {
- __C11_ATOMIC(int) _b_lock;
- __C11_ATOMIC(int) _b_waiters;
- unsigned int _b_limit;
- __C11_ATOMIC(int) _b_count;
- __C11_ATOMIC(int) _b_waiters2;
- void* _b_inst;
+ __C11_ATOMIC(int)
+ _b_lock;
+ __C11_ATOMIC(int)
+ _b_waiters;
+ unsigned int _b_limit;
+ __C11_ATOMIC(int)
+ _b_count;
+ __C11_ATOMIC(int)
+ _b_waiters2;
+ void* _b_inst;
} pthread_barrier_t;
#define __DEFINED_pthread_barrier_t
#endif
#if defined(__NEED_sem_t) && !defined(__DEFINED_sem_t)
typedef struct {
- __C11_ATOMIC(int) _s_value;
- __C11_ATOMIC(int) _s_waiters;
+ __C11_ATOMIC(int)
+ _s_value;
+ __C11_ATOMIC(int)
+ _s_waiters;
} sem_t;
#define __DEFINED_sem_t
#endif
diff --git a/arch/x64/sysroot/include/bits/float.h b/arch/x64/sysroot/include/bits/float.h
deleted file mode 100644
index 45354da..0000000
--- a/arch/x64/sysroot/include/bits/float.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#if defined(__x86_64__)
-#include "x86_64/float.h"
-#elif defined(__aarch64__)
-#include "aarch64/float.h"
-#else
-#error Unsupported architecture!
-#endif
diff --git a/arch/x64/sysroot/include/bits/msg.h b/arch/x64/sysroot/include/bits/msg.h
index 9b3f7e5..1c8034b 100644
--- a/arch/x64/sysroot/include/bits/msg.h
+++ b/arch/x64/sysroot/include/bits/msg.h
@@ -1,12 +1,12 @@
struct msqid_ds {
- struct ipc_perm msg_perm;
- time_t msg_stime;
- time_t msg_rtime;
- time_t msg_ctime;
- unsigned long msg_cbytes;
- msgqnum_t msg_qnum;
- msglen_t msg_qbytes;
- pid_t msg_lspid;
- pid_t msg_lrpid;
- unsigned long __unused[2];
+ struct ipc_perm msg_perm;
+ time_t msg_stime;
+ time_t msg_rtime;
+ time_t msg_ctime;
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
};
diff --git a/arch/x64/sysroot/include/bits/null.h b/arch/x64/sysroot/include/bits/null.h
index 1788e0c..76e7b77 100644
--- a/arch/x64/sysroot/include/bits/null.h
+++ b/arch/x64/sysroot/include/bits/null.h
@@ -4,9 +4,12 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
-#pragma once
+#ifndef SYSROOT_BITS_NULL_H_
+#define SYSROOT_BITS_NULL_H_
// The compiler's <stddef.h> defines NULL without defining anything
// else if __need_NULL is defined first.
#define __need_NULL
#include <stddef.h>
+
+#endif // SYSROOT_BITS_NULL_H_
diff --git a/arch/x64/sysroot/include/bits/sem.h b/arch/x64/sysroot/include/bits/sem.h
index d7aa74b..db4102f 100644
--- a/arch/x64/sysroot/include/bits/sem.h
+++ b/arch/x64/sysroot/include/bits/sem.h
@@ -1,14 +1,14 @@
struct semid_ds {
- struct ipc_perm sem_perm;
- time_t sem_otime;
- time_t sem_ctime;
+ struct ipc_perm sem_perm;
+ time_t sem_otime;
+ time_t sem_ctime;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned short sem_nsems;
- char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
+ unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
#else
- char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
- unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(time_t) - sizeof(short)];
+ unsigned short sem_nsems;
#endif
- time_t __unused3;
- time_t __unused4;
+ time_t __unused3;
+ time_t __unused4;
};
diff --git a/arch/x64/sysroot/include/bits/shm.h b/arch/x64/sysroot/include/bits/shm.h
index 8bb1c74..a3b9dcc 100644
--- a/arch/x64/sysroot/include/bits/shm.h
+++ b/arch/x64/sysroot/include/bits/shm.h
@@ -1,24 +1,24 @@
#define SHMLBA 4096
struct shmid_ds {
- struct ipc_perm shm_perm;
- size_t shm_segsz;
- time_t shm_atime;
- time_t shm_dtime;
- time_t shm_ctime;
- pid_t shm_cpid;
- pid_t shm_lpid;
- unsigned long shm_nattch;
- unsigned long __pad1;
- unsigned long __pad2;
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+ time_t shm_dtime;
+ time_t shm_ctime;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+ unsigned long __pad1;
+ unsigned long __pad2;
};
struct shminfo {
- unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+ unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
};
struct shm_info {
- int __used_ids;
- unsigned long shm_tot, shm_rss, shm_swp;
- unsigned long __swap_attempts, __swap_successes;
+ int __used_ids;
+ unsigned long shm_tot, shm_rss, shm_swp;
+ unsigned long __swap_attempts, __swap_successes;
};
diff --git a/arch/x64/sysroot/include/bits/socket.h b/arch/x64/sysroot/include/bits/socket.h
index aad18bf..1127d5b 100644
--- a/arch/x64/sysroot/include/bits/socket.h
+++ b/arch/x64/sysroot/include/bits/socket.h
@@ -1,33 +1,33 @@
#include <endian.h>
struct msghdr {
- void* msg_name;
- socklen_t msg_namelen;
- struct iovec* msg_iov;
+ void* msg_name;
+ socklen_t msg_namelen;
+ struct iovec* msg_iov;
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad1, msg_iovlen;
+ int __pad1, msg_iovlen;
#else
- int msg_iovlen, __pad1;
+ int msg_iovlen, __pad1;
#endif
- void* msg_control;
+ void* msg_control;
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad2;
- socklen_t msg_controllen;
+ int __pad2;
+ socklen_t msg_controllen;
#else
- socklen_t msg_controllen;
- int __pad2;
+ socklen_t msg_controllen;
+ int __pad2;
#endif
- int msg_flags;
+ int msg_flags;
};
struct cmsghdr {
#if __BYTE_ORDER == __BIG_ENDIAN
- int __pad1;
- socklen_t cmsg_len;
+ int __pad1;
+ socklen_t cmsg_len;
#else
- socklen_t cmsg_len;
- int __pad1;
+ socklen_t cmsg_len;
+ int __pad1;
#endif
- int cmsg_level;
- int cmsg_type;
+ int cmsg_level;
+ int cmsg_type;
};
diff --git a/arch/x64/sysroot/include/bits/statfs.h b/arch/x64/sysroot/include/bits/statfs.h
index 656aa8d..ef2bbe3 100644
--- a/arch/x64/sysroot/include/bits/statfs.h
+++ b/arch/x64/sysroot/include/bits/statfs.h
@@ -1,7 +1,7 @@
struct statfs {
- unsigned long f_type, f_bsize;
- fsblkcnt_t f_blocks, f_bfree, f_bavail;
- fsfilcnt_t f_files, f_ffree;
- fsid_t f_fsid;
- unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
+ unsigned long f_type, f_bsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree;
+ fsid_t f_fsid;
+ unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
};
diff --git a/arch/x64/sysroot/include/bits/termios.h b/arch/x64/sysroot/include/bits/termios.h
index 1a06f76..d9a7359 100644
--- a/arch/x64/sysroot/include/bits/termios.h
+++ b/arch/x64/sysroot/include/bits/termios.h
@@ -1,12 +1,12 @@
struct termios {
- tcflag_t c_iflag;
- tcflag_t c_oflag;
- tcflag_t c_cflag;
- tcflag_t c_lflag;
- cc_t c_line;
- cc_t c_cc[NCCS];
- speed_t __c_ispeed;
- speed_t __c_ospeed;
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t __c_ispeed;
+ speed_t __c_ospeed;
};
#define VINTR 0
diff --git a/arch/x64/sysroot/include/bits/x86_64/fenv.h b/arch/x64/sysroot/include/bits/x86_64/fenv.h
index 5cea203..32e7dbf 100644
--- a/arch/x64/sysroot/include/bits/x86_64/fenv.h
+++ b/arch/x64/sysroot/include/bits/x86_64/fenv.h
@@ -15,20 +15,20 @@
typedef unsigned short fexcept_t;
typedef struct {
- unsigned short __control_word;
- unsigned short __unused1;
- unsigned short __status_word;
- unsigned short __unused2;
- unsigned short __tags;
- unsigned short __unused3;
- unsigned int __eip;
- unsigned short __cs_selector;
- unsigned int __opcode : 11;
- unsigned int __unused4 : 5;
- unsigned int __data_offset;
- unsigned short __data_selector;
- unsigned short __unused5;
- unsigned int __mxcsr;
+ unsigned short __control_word;
+ unsigned short __unused1;
+ unsigned short __status_word;
+ unsigned short __unused2;
+ unsigned short __tags;
+ unsigned short __unused3;
+ unsigned int __eip;
+ unsigned short __cs_selector;
+ unsigned int __opcode : 11;
+ unsigned int __unused4 : 5;
+ unsigned int __data_offset;
+ unsigned short __data_selector;
+ unsigned short __unused5;
+ unsigned int __mxcsr;
} fenv_t;
#define FE_DFL_ENV ((const fenv_t*)-1)
diff --git a/arch/x64/sysroot/include/bits/x86_64/float.h b/arch/x64/sysroot/include/bits/x86_64/float.h
deleted file mode 100644
index f935e34..0000000
--- a/arch/x64/sysroot/include/bits/x86_64/float.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifdef __FLT_EVAL_METHOD__
-#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#else
-#define FLT_EVAL_METHOD 0
-#endif
-
-#define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
-#define LDBL_MIN 3.3621031431120935063e-4932L
-#define LDBL_MAX 1.1897314953572317650e+4932L
-#define LDBL_EPSILON 1.0842021724855044340e-19L
-
-#define LDBL_MANT_DIG 64
-#define LDBL_MIN_EXP (-16381)
-#define LDBL_MAX_EXP 16384
-
-#define LDBL_DIG 18
-#define LDBL_MIN_10_EXP (-4931)
-#define LDBL_MAX_10_EXP 4932
-
-#define DECIMAL_DIG 21
diff --git a/arch/x64/sysroot/include/bits/x86_64/io.h b/arch/x64/sysroot/include/bits/x86_64/io.h
index bbfb2e6..7234422 100644
--- a/arch/x64/sysroot/include/bits/x86_64/io.h
+++ b/arch/x64/sysroot/include/bits/x86_64/io.h
@@ -1,77 +1,53 @@
static __inline void outb(unsigned char __val, unsigned short __port) {
- __asm__ volatile("outb %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outb %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline void outw(unsigned short __val, unsigned short __port) {
- __asm__ volatile("outw %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outw %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline void outl(unsigned int __val, unsigned short __port) {
- __asm__ volatile("outl %0,%1"
- :
- : "a"(__val), "dN"(__port));
+ __asm__ volatile("outl %0,%1" : : "a"(__val), "dN"(__port));
}
static __inline unsigned char inb(unsigned short __port) {
- unsigned char __val;
- __asm__ volatile("inb %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned char __val;
+ __asm__ volatile("inb %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline unsigned short inw(unsigned short __port) {
- unsigned short __val;
- __asm__ volatile("inw %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned short __val;
+ __asm__ volatile("inw %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline unsigned int inl(unsigned short __port) {
- unsigned int __val;
- __asm__ volatile("inl %1,%0"
- : "=a"(__val)
- : "dN"(__port));
- return __val;
+ unsigned int __val;
+ __asm__ volatile("inl %1,%0" : "=a"(__val) : "dN"(__port));
+ return __val;
}
static __inline void outsb(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsb"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void outsw(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsw"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void outsl(unsigned short __port, const void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; outsl"
- : "+S"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insb(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insb"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insw(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insw"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
static __inline void insl(unsigned short __port, void* __buf, unsigned long __n) {
- __asm__ volatile("cld; rep; insl"
- : "+D"(__buf), "+c"(__n)
- : "d"(__port));
+ __asm__ volatile("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(__port));
}
diff --git a/arch/x64/sysroot/include/bits/x86_64/ioctl.h b/arch/x64/sysroot/include/bits/x86_64/ioctl.h
index 66525bf..bc8d16a 100644
--- a/arch/x64/sysroot/include/bits/x86_64/ioctl.h
+++ b/arch/x64/sysroot/include/bits/x86_64/ioctl.h
@@ -88,10 +88,10 @@
#define TIOCSER_TEMT 0x01
struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
};
#define TIOCM_LE 0x001
diff --git a/arch/x64/sysroot/include/bits/x86_64/ipc.h b/arch/x64/sysroot/include/bits/x86_64/ipc.h
index b563143..c66f9ed 100644
--- a/arch/x64/sysroot/include/bits/x86_64/ipc.h
+++ b/arch/x64/sysroot/include/bits/x86_64/ipc.h
@@ -1,13 +1,13 @@
struct ipc_perm {
- key_t __ipc_perm_key;
- uid_t uid;
- gid_t gid;
- uid_t cuid;
- gid_t cgid;
- mode_t mode;
- int __ipc_perm_seq;
- long __pad1;
- long __pad2;
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ int __ipc_perm_seq;
+ long __pad1;
+ long __pad2;
};
#define IPC_64 0
diff --git a/arch/x64/sysroot/include/bits/x86_64/signal.h b/arch/x64/sysroot/include/bits/x86_64/signal.h
index 529bbc4..26095e9 100644
--- a/arch/x64/sysroot/include/bits/x86_64/signal.h
+++ b/arch/x64/sysroot/include/bits/x86_64/signal.h
@@ -35,47 +35,49 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef long long greg_t, gregset_t[23];
typedef struct _fpstate {
- unsigned short cwd, swd, ftw, fop;
- unsigned long long rip, rdp;
- unsigned mxcsr, mxcr_mask;
- struct {
- unsigned short significand[4], exponent, padding[3];
- } _st[8];
- struct {
- unsigned element[4];
- } _xmm[16];
- unsigned padding[24];
+ unsigned short cwd, swd, ftw, fop;
+ unsigned long long rip, rdp;
+ unsigned mxcsr, mxcr_mask;
+ struct {
+ unsigned short significand[4], exponent, padding[3];
+ } _st[8];
+ struct {
+ unsigned element[4];
+ } _xmm[16];
+ unsigned padding[24];
} * fpregset_t;
struct sigcontext {
- unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
- unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
- unsigned short cs, gs, fs, __pad0;
- unsigned long err, trapno, oldmask, cr2;
- struct _fpstate* fpstate;
- unsigned long __reserved1[8];
+ unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
+ unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
+ unsigned short cs, gs, fs, __pad0;
+ unsigned long err, trapno, oldmask, cr2;
+ struct _fpstate* fpstate;
+ unsigned long __reserved1[8];
};
typedef struct {
- gregset_t gregs;
- fpregset_t fpregs;
- unsigned long long __reserved1[8];
+ gregset_t gregs;
+ fpregset_t fpregs;
+ unsigned long long __reserved1[8];
} mcontext_t;
#else
-typedef struct { unsigned long __space[32]; } mcontext_t;
+typedef struct {
+ unsigned long __space[32];
+} mcontext_t;
#endif
struct sigaltstack {
- void* ss_sp;
- int ss_flags;
- size_t ss_size;
+ void* ss_sp;
+ int ss_flags;
+ size_t ss_size;
};
typedef struct __ucontext {
- unsigned long uc_flags;
- struct __ucontext* uc_link;
- stack_t uc_stack;
- mcontext_t uc_mcontext;
- sigset_t uc_sigmask;
- unsigned long __fpregs_mem[64];
+ unsigned long uc_flags;
+ struct __ucontext* uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+ unsigned long __fpregs_mem[64];
} ucontext_t;
#define SA_NOCLDSTOP 1
diff --git a/arch/x64/sysroot/include/bits/x86_64/stat.h b/arch/x64/sysroot/include/bits/x86_64/stat.h
index d3b3447..9533ce5 100644
--- a/arch/x64/sysroot/include/bits/x86_64/stat.h
+++ b/arch/x64/sysroot/include/bits/x86_64/stat.h
@@ -2,21 +2,21 @@
* by the corresponding correctly-sized userspace types. */
struct stat {
- dev_t st_dev;
- ino_t st_ino;
- nlink_t st_nlink;
+ dev_t st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
- mode_t st_mode;
- uid_t st_uid;
- gid_t st_gid;
- unsigned int __pad0;
- dev_t st_rdev;
- off_t st_size;
- blksize_t st_blksize;
- blkcnt_t st_blocks;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned int __pad0;
+ dev_t st_rdev;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- long __unused[3];
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused1[3];
};
diff --git a/arch/x64/sysroot/include/byteswap.h b/arch/x64/sysroot/include/byteswap.h
index 6350775..54d1c36 100644
--- a/arch/x64/sysroot/include/byteswap.h
+++ b/arch/x64/sysroot/include/byteswap.h
@@ -1,21 +1,21 @@
-#pragma once
+#ifndef SYSROOT_BYTESWAP_H_
+#define SYSROOT_BYTESWAP_H_
#include <features.h>
#include <stdint.h>
-static __inline uint16_t __bswap_16(uint16_t __x) {
- return __x << 8 | __x >> 8;
-}
+static __inline uint16_t __bswap_16(uint16_t __x) { return (uint16_t)(__x << 8 | __x >> 8); }
static __inline uint32_t __bswap_32(uint32_t __x) {
- return __x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) |
- __x << 24;
+ return __x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24;
}
static __inline uint64_t __bswap_64(uint64_t __x) {
- return ((uint64_t)__bswap_32(__x)) << 32 | __bswap_32(__x >> 32);
+ return ((uint64_t)__bswap_32((uint32_t)__x)) << 32 | __bswap_32((uint32_t)(__x >> 32));
}
#define bswap_16(x) __bswap_16(x)
#define bswap_32(x) __bswap_32(x)
#define bswap_64(x) __bswap_64(x)
+
+#endif // SYSROOT_BYTESWAP_H_
diff --git a/arch/x64/sysroot/include/complex.h b/arch/x64/sysroot/include/complex.h
index 9761553..c4bb294 100644
--- a/arch/x64/sysroot/include/complex.h
+++ b/arch/x64/sysroot/include/complex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_COMPLEX_H_
+#define SYSROOT_COMPLEX_H_
#ifdef __cplusplus
extern "C" {
@@ -101,12 +102,12 @@
long double creall(long double complex);
#ifndef __cplusplus
-#define __CIMAG(x, t) \
- (+(union { \
- _Complex t __z; \
- t __xy[2]; \
- }){(_Complex t)(x)} \
- .__xy[1])
+#define __CIMAG(x, t) \
+ (+(union { \
+ _Complex t __z; \
+ t __xy[2]; \
+ }){(_Complex t)(x)} \
+ .__xy[1])
#define creal(x) ((double)(x))
#define crealf(x) ((float)(x))
@@ -133,3 +134,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_COMPLEX_H_
diff --git a/arch/x64/sysroot/include/cpio.h b/arch/x64/sysroot/include/cpio.h
index f921413..21d069e 100644
--- a/arch/x64/sysroot/include/cpio.h
+++ b/arch/x64/sysroot/include/cpio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_CPIO_H_
+#define SYSROOT_CPIO_H_
#define MAGIC "070707"
@@ -24,3 +25,5 @@
#define C_ISLNK 0120000
#define C_ISCTG 0110000
#define C_ISREG 0100000
+
+#endif // SYSROOT_CPIO_H_
diff --git a/arch/x64/sysroot/include/crypt.h b/arch/x64/sysroot/include/crypt.h
deleted file mode 100644
index 029698c..0000000
--- a/arch/x64/sysroot/include/crypt.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct crypt_data {
- int initialized;
- char __buf[256];
-};
-
-char* crypt(const char*, const char*);
-char* crypt_r(const char*, const char*, struct crypt_data*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/x64/sysroot/include/ctype.h b/arch/x64/sysroot/include/ctype.h
index f4cd85b..12be80d 100644
--- a/arch/x64/sysroot/include/ctype.h
+++ b/arch/x64/sysroot/include/ctype.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_CTYPE_H_
+#define SYSROOT_CTYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -22,9 +23,7 @@
int toupper(int);
#ifndef __cplusplus
-static __inline int __isspace(int _c) {
- return _c == ' ' || (unsigned)_c - '\t' < 5;
-}
+static __inline int __isspace(int _c) { return _c == ' ' || (unsigned)_c - '\t' < 5; }
#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a) | 32) - 'a') < 26)
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a) - '0') < 10)
@@ -49,3 +48,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_CTYPE_H_
diff --git a/arch/x64/sysroot/include/dirent.h b/arch/x64/sysroot/include/dirent.h
index 0c463c4..4542825 100644
--- a/arch/x64/sysroot/include/dirent.h
+++ b/arch/x64/sysroot/include/dirent.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_DIRENT_H_
+#define SYSROOT_DIRENT_H_
#ifdef __cplusplus
extern "C" {
@@ -17,11 +18,11 @@
typedef struct __dirstream DIR;
struct dirent {
- ino_t d_ino;
- off_t d_off;
- unsigned short d_reclen;
- unsigned char d_type;
- char d_name[256];
+ ino_t d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
};
#define d_fileno d_ino
@@ -62,3 +63,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_DIRENT_H_
diff --git a/arch/x64/sysroot/include/dlfcn.h b/arch/x64/sysroot/include/dlfcn.h
index 04cc834..ff069c9 100644
--- a/arch/x64/sysroot/include/dlfcn.h
+++ b/arch/x64/sysroot/include/dlfcn.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_DLFCN_H_
+#define SYSROOT_DLFCN_H_
#ifdef __cplusplus
extern "C" {
@@ -25,10 +26,10 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef struct {
- const char* dli_fname;
- void* dli_fbase;
- const char* dli_sname;
- void* dli_saddr;
+ const char* dli_fname;
+ void* dli_fbase;
+ const char* dli_sname;
+ void* dli_saddr;
} Dl_info;
int dladdr(const void*, Dl_info*);
int dlinfo(void*, int, void*);
@@ -37,3 +38,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_DLFCN_H_
diff --git a/arch/x64/sysroot/include/elf.h b/arch/x64/sysroot/include/elf.h
index a5efbda..88a35f0 100644
--- a/arch/x64/sysroot/include/elf.h
+++ b/arch/x64/sysroot/include/elf.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ELF_H_
+#define SYSROOT_ELF_H_
#ifdef __cplusplus
extern "C" {
@@ -34,37 +35,37 @@
#define EI_NIDENT (16)
typedef struct {
- unsigned char e_ident[EI_NIDENT];
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry;
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
- Elf32_Half e_shstrndx;
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
} Elf32_Ehdr;
typedef struct {
- unsigned char e_ident[EI_NIDENT];
- Elf64_Half e_type;
- Elf64_Half e_machine;
- Elf64_Word e_version;
- Elf64_Addr e_entry;
- Elf64_Off e_phoff;
- Elf64_Off e_shoff;
- Elf64_Word e_flags;
- Elf64_Half e_ehsize;
- Elf64_Half e_phentsize;
- Elf64_Half e_phnum;
- Elf64_Half e_shentsize;
- Elf64_Half e_shnum;
- Elf64_Half e_shstrndx;
+ unsigned char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
} Elf64_Ehdr;
#define EI_MAG0 0
@@ -217,29 +218,29 @@
#define EV_NUM 2
typedef struct {
- Elf32_Word sh_name;
- Elf32_Word sh_type;
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
} Elf32_Shdr;
typedef struct {
- Elf64_Word sh_name;
- Elf64_Word sh_type;
- Elf64_Xword sh_flags;
- Elf64_Addr sh_addr;
- Elf64_Off sh_offset;
- Elf64_Xword sh_size;
- Elf64_Word sh_link;
- Elf64_Word sh_info;
- Elf64_Xword sh_addralign;
- Elf64_Xword sh_entsize;
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
} Elf64_Shdr;
#define SHN_UNDEF 0
@@ -313,31 +314,31 @@
#define GRP_COMDAT 0x1
typedef struct {
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Section st_shndx;
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Section st_shndx;
} Elf32_Sym;
typedef struct {
- Elf64_Word st_name;
- unsigned char st_info;
- unsigned char st_other;
- Elf64_Section st_shndx;
- Elf64_Addr st_value;
- Elf64_Xword st_size;
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Section st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
} Elf64_Sym;
typedef struct {
- Elf32_Half si_boundto;
- Elf32_Half si_flags;
+ Elf32_Half si_boundto;
+ Elf32_Half si_flags;
} Elf32_Syminfo;
typedef struct {
- Elf64_Half si_boundto;
- Elf64_Half si_flags;
+ Elf64_Half si_boundto;
+ Elf64_Half si_flags;
} Elf64_Syminfo;
#define SYMINFO_BT_SELF 0xffff
@@ -396,25 +397,25 @@
#define STV_PROTECTED 3
typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
} Elf32_Rel;
typedef struct {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
} Elf64_Rel;
typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
} Elf32_Rela;
typedef struct {
- Elf64_Addr r_offset;
- Elf64_Xword r_info;
- Elf64_Sxword r_addend;
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+ Elf64_Sxword r_addend;
} Elf64_Rela;
#define ELF32_R_SYM(val) ((val) >> 8)
@@ -426,25 +427,25 @@
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type))
typedef struct {
- Elf32_Word p_type;
- Elf32_Off p_offset;
- Elf32_Addr p_vaddr;
- Elf32_Addr p_paddr;
- Elf32_Word p_filesz;
- Elf32_Word p_memsz;
- Elf32_Word p_flags;
- Elf32_Word p_align;
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
} Elf32_Phdr;
typedef struct {
- Elf64_Word p_type;
- Elf64_Word p_flags;
- Elf64_Off p_offset;
- Elf64_Addr p_vaddr;
- Elf64_Addr p_paddr;
- Elf64_Xword p_filesz;
- Elf64_Xword p_memsz;
- Elf64_Xword p_align;
+ Elf64_Word p_type;
+ Elf64_Word p_flags;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Addr p_paddr;
+ Elf64_Xword p_filesz;
+ Elf64_Xword p_memsz;
+ Elf64_Xword p_align;
} Elf64_Phdr;
#define PT_NULL 0
@@ -520,19 +521,19 @@
#define NT_VERSION 1
typedef struct {
- Elf32_Sword d_tag;
- union {
- Elf32_Word d_val;
- Elf32_Addr d_ptr;
- } d_un;
+ Elf32_Sword d_tag;
+ union {
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
} Elf32_Dyn;
typedef struct {
- Elf64_Sxword d_tag;
- union {
- Elf64_Xword d_val;
- Elf64_Addr d_ptr;
- } d_un;
+ Elf64_Sxword d_tag;
+ union {
+ Elf64_Xword d_val;
+ Elf64_Addr d_ptr;
+ } d_un;
} Elf64_Dyn;
#define DT_NULL 0
@@ -672,23 +673,23 @@
#define DF_P1_GROUPPERM 0x00000002
typedef struct {
- Elf32_Half vd_version;
- Elf32_Half vd_flags;
- Elf32_Half vd_ndx;
- Elf32_Half vd_cnt;
- Elf32_Word vd_hash;
- Elf32_Word vd_aux;
- Elf32_Word vd_next;
+ Elf32_Half vd_version;
+ Elf32_Half vd_flags;
+ Elf32_Half vd_ndx;
+ Elf32_Half vd_cnt;
+ Elf32_Word vd_hash;
+ Elf32_Word vd_aux;
+ Elf32_Word vd_next;
} Elf32_Verdef;
typedef struct {
- Elf64_Half vd_version;
- Elf64_Half vd_flags;
- Elf64_Half vd_ndx;
- Elf64_Half vd_cnt;
- Elf64_Word vd_hash;
- Elf64_Word vd_aux;
- Elf64_Word vd_next;
+ Elf64_Half vd_version;
+ Elf64_Half vd_flags;
+ Elf64_Half vd_ndx;
+ Elf64_Half vd_cnt;
+ Elf64_Word vd_hash;
+ Elf64_Word vd_aux;
+ Elf64_Word vd_next;
} Elf64_Verdef;
#define VER_DEF_NONE 0
@@ -704,29 +705,29 @@
#define VER_NDX_ELIMINATE 0xff01
typedef struct {
- Elf32_Word vda_name;
- Elf32_Word vda_next;
+ Elf32_Word vda_name;
+ Elf32_Word vda_next;
} Elf32_Verdaux;
typedef struct {
- Elf64_Word vda_name;
- Elf64_Word vda_next;
+ Elf64_Word vda_name;
+ Elf64_Word vda_next;
} Elf64_Verdaux;
typedef struct {
- Elf32_Half vn_version;
- Elf32_Half vn_cnt;
- Elf32_Word vn_file;
- Elf32_Word vn_aux;
- Elf32_Word vn_next;
+ Elf32_Half vn_version;
+ Elf32_Half vn_cnt;
+ Elf32_Word vn_file;
+ Elf32_Word vn_aux;
+ Elf32_Word vn_next;
} Elf32_Verneed;
typedef struct {
- Elf64_Half vn_version;
- Elf64_Half vn_cnt;
- Elf64_Word vn_file;
- Elf64_Word vn_aux;
- Elf64_Word vn_next;
+ Elf64_Half vn_version;
+ Elf64_Half vn_cnt;
+ Elf64_Word vn_file;
+ Elf64_Word vn_aux;
+ Elf64_Word vn_next;
} Elf64_Verneed;
#define VER_NEED_NONE 0
@@ -734,35 +735,35 @@
#define VER_NEED_NUM 2
typedef struct {
- Elf32_Word vna_hash;
- Elf32_Half vna_flags;
- Elf32_Half vna_other;
- Elf32_Word vna_name;
- Elf32_Word vna_next;
+ Elf32_Word vna_hash;
+ Elf32_Half vna_flags;
+ Elf32_Half vna_other;
+ Elf32_Word vna_name;
+ Elf32_Word vna_next;
} Elf32_Vernaux;
typedef struct {
- Elf64_Word vna_hash;
- Elf64_Half vna_flags;
- Elf64_Half vna_other;
- Elf64_Word vna_name;
- Elf64_Word vna_next;
+ Elf64_Word vna_hash;
+ Elf64_Half vna_flags;
+ Elf64_Half vna_other;
+ Elf64_Word vna_name;
+ Elf64_Word vna_next;
} Elf64_Vernaux;
#define VER_FLG_WEAK 0x2
typedef struct {
- uint32_t a_type;
- union {
- uint32_t a_val;
- } a_un;
+ uint32_t a_type;
+ union {
+ uint32_t a_val;
+ } a_un;
} Elf32_auxv_t;
typedef struct {
- uint64_t a_type;
- union {
- uint64_t a_val;
- } a_un;
+ uint64_t a_type;
+ union {
+ uint64_t a_val;
+ } a_un;
} Elf64_auxv_t;
#define AT_NULL 0
@@ -812,15 +813,15 @@
#define AT_L3_CACHESHAPE 37
typedef struct {
- Elf32_Word n_namesz;
- Elf32_Word n_descsz;
- Elf32_Word n_type;
+ Elf32_Word n_namesz;
+ Elf32_Word n_descsz;
+ Elf32_Word n_type;
} Elf32_Nhdr;
typedef struct {
- Elf64_Word n_namesz;
- Elf64_Word n_descsz;
- Elf64_Word n_type;
+ Elf64_Word n_namesz;
+ Elf64_Word n_descsz;
+ Elf64_Word n_type;
} Elf64_Nhdr;
#define ELF_NOTE_SOLARIS "SUNW Solaris"
@@ -841,19 +842,19 @@
#define NT_GNU_GOLD_VERSION 4
typedef struct {
- Elf32_Xword m_value;
- Elf32_Word m_info;
- Elf32_Word m_poffset;
- Elf32_Half m_repeat;
- Elf32_Half m_stride;
+ Elf32_Xword m_value;
+ Elf32_Word m_info;
+ Elf32_Word m_poffset;
+ Elf32_Half m_repeat;
+ Elf32_Half m_stride;
} Elf32_Move;
typedef struct {
- Elf64_Xword m_value;
- Elf64_Xword m_info;
- Elf64_Xword m_poffset;
- Elf64_Half m_repeat;
- Elf64_Half m_stride;
+ Elf64_Xword m_value;
+ Elf64_Xword m_info;
+ Elf64_Xword m_poffset;
+ Elf64_Half m_repeat;
+ Elf64_Half m_stride;
} Elf64_Move;
#define ELF32_M_SYM(info) ((info) >> 8)
@@ -1138,29 +1139,29 @@
#define STB_MIPS_SPLIT_COMMON 13
typedef union {
- struct {
- Elf32_Word gt_current_g_value;
- Elf32_Word gt_unused;
- } gt_header;
- struct {
- Elf32_Word gt_g_value;
- Elf32_Word gt_bytes;
- } gt_entry;
+ struct {
+ Elf32_Word gt_current_g_value;
+ Elf32_Word gt_unused;
+ } gt_header;
+ struct {
+ Elf32_Word gt_g_value;
+ Elf32_Word gt_bytes;
+ } gt_entry;
} Elf32_gptab;
typedef struct {
- Elf32_Word ri_gprmask;
- Elf32_Word ri_cprmask[4];
- Elf32_Sword ri_gp_value;
+ Elf32_Word ri_gprmask;
+ Elf32_Word ri_cprmask[4];
+ Elf32_Sword ri_gp_value;
} Elf32_RegInfo;
typedef struct {
- unsigned char kind;
+ unsigned char kind;
- unsigned char size;
- Elf32_Section section;
+ unsigned char size;
+ Elf32_Section section;
- Elf32_Word info;
+ Elf32_Word info;
} Elf_Options;
#define ODK_NULL 0
@@ -1197,8 +1198,8 @@
#define OPAD_SYMBOL 0x4
typedef struct {
- Elf32_Word hwp_flags1;
- Elf32_Word hwp_flags2;
+ Elf32_Word hwp_flags1;
+ Elf32_Word hwp_flags2;
} Elf_Options_Hw;
#define OHWA0_R4KEOP_CHECKED 0x00000001
@@ -1341,19 +1342,19 @@
#define RHF_RLD_ORDER_SAFE (1 << 14)
typedef struct {
- Elf32_Word l_name;
- Elf32_Word l_time_stamp;
- Elf32_Word l_checksum;
- Elf32_Word l_version;
- Elf32_Word l_flags;
+ Elf32_Word l_name;
+ Elf32_Word l_time_stamp;
+ Elf32_Word l_checksum;
+ Elf32_Word l_version;
+ Elf32_Word l_flags;
} Elf32_Lib;
typedef struct {
- Elf64_Word l_name;
- Elf64_Word l_time_stamp;
- Elf64_Word l_checksum;
- Elf64_Word l_version;
- Elf64_Word l_flags;
+ Elf64_Word l_name;
+ Elf64_Word l_time_stamp;
+ Elf64_Word l_checksum;
+ Elf64_Word l_version;
+ Elf64_Word l_flags;
} Elf64_Lib;
#define LL_NONE 0
@@ -2580,3 +2581,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ELF_H_
diff --git a/arch/x64/sysroot/include/endian.h b/arch/x64/sysroot/include/endian.h
index 499f985..5ca6625 100644
--- a/arch/x64/sysroot/include/endian.h
+++ b/arch/x64/sysroot/include/endian.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ENDIAN_H_
+#define SYSROOT_ENDIAN_H_
#include <features.h>
@@ -21,16 +22,14 @@
#include <stdint.h>
-static __inline uint16_t __bswap16(uint16_t __x) {
- return (uint16_t)(__x << 8 | __x >> 8);
-}
+static __inline uint16_t __bswap16(uint16_t __x) { return (uint16_t)(__x << 8 | __x >> 8); }
static __inline uint32_t __bswap32(uint32_t __x) {
- return (uint32_t)(__x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24);
+ return (uint32_t)(__x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) | __x << 24);
}
static __inline uint64_t __bswap64(uint64_t __x) {
- return ((uint64_t)__bswap32((uint32_t)__x)) << 32 | (uint64_t)__bswap32((uint32_t)(__x >> 32));
+ return ((uint64_t)__bswap32((uint32_t)__x)) << 32 | (uint64_t)__bswap32((uint32_t)(__x >> 32));
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -74,3 +73,5 @@
#endif
#endif
+
+#endif // SYSROOT_ENDIAN_H_
diff --git a/arch/x64/sysroot/include/err.h b/arch/x64/sysroot/include/err.h
index 3ed5f7f..29842fe 100644
--- a/arch/x64/sysroot/include/err.h
+++ b/arch/x64/sysroot/include/err.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ERR_H_
+#define SYSROOT_ERR_H_
#include <features.h>
#include <stdarg.h>
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ERR_H_
diff --git a/arch/x64/sysroot/include/errno.h b/arch/x64/sysroot/include/errno.h
index 4d3b968..af13f58 100644
--- a/arch/x64/sysroot/include/errno.h
+++ b/arch/x64/sysroot/include/errno.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ERRNO_H_
+#define SYSROOT_ERRNO_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ERRNO_H_
diff --git a/arch/x64/sysroot/include/fcntl.h b/arch/x64/sysroot/include/fcntl.h
index f045529..e5e47bd 100644
--- a/arch/x64/sysroot/include/fcntl.h
+++ b/arch/x64/sysroot/include/fcntl.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FCNTL_H_
+#define SYSROOT_FCNTL_H_
#ifdef __cplusplus
extern "C" {
@@ -19,11 +20,11 @@
#include <bits/alltypes.h>
struct flock {
- short l_type;
- short l_whence;
- off_t l_start;
- off_t l_len;
- pid_t l_pid;
+ short l_type;
+ short l_whence;
+ off_t l_start;
+ off_t l_len;
+ pid_t l_pid;
};
int creat(const char*, mode_t);
@@ -54,7 +55,6 @@
#ifdef _ALL_SOURCE
#define O_NOREMOTE 0x00200000
#define O_ADMIN 0x00000004
-#define O_PIPELINE 0x80000000
#endif
// Flags which do not align with ZXIO_FS_*
@@ -195,8 +195,8 @@
#define F_OWNER_PGRP 2
#define F_OWNER_GID 2
struct f_owner_ex {
- int type;
- pid_t pid;
+ int type;
+ pid_t pid;
};
#define FALLOC_FL_KEEP_SIZE 1
#define FALLOC_FL_PUNCH_HOLE 2
@@ -220,3 +220,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FCNTL_H_
diff --git a/arch/x64/sysroot/include/features.h b/arch/x64/sysroot/include/features.h
index 7bd75ad..1520efb 100644
--- a/arch/x64/sysroot/include/features.h
+++ b/arch/x64/sysroot/include/features.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FEATURES_H_
+#define SYSROOT_FEATURES_H_
#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
@@ -30,3 +31,5 @@
#else
#define _Noreturn
#endif
+
+#endif // SYSROOT_FEATURES_H_
diff --git a/arch/x64/sysroot/include/fenv.h b/arch/x64/sysroot/include/fenv.h
index 42508ac..391f59f 100644
--- a/arch/x64/sysroot/include/fenv.h
+++ b/arch/x64/sysroot/include/fenv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FENV_H_
+#define SYSROOT_FENV_H_
#ifdef __cplusplus
extern "C" {
@@ -23,3 +24,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FENV_H_
diff --git a/arch/x64/sysroot/include/float.h b/arch/x64/sysroot/include/float.h
deleted file mode 100644
index 691c4fc..0000000
--- a/arch/x64/sysroot/include/float.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int __flt_rounds(void);
-#define FLT_ROUNDS (__flt_rounds())
-
-#define FLT_RADIX 2
-
-#define FLT_TRUE_MIN 1.40129846432481707092e-45F
-#define FLT_MIN 1.17549435082228750797e-38F
-#define FLT_MAX 3.40282346638528859812e+38F
-#define FLT_EPSILON 1.1920928955078125e-07F
-
-#define FLT_MANT_DIG 24
-#define FLT_MIN_EXP (-125)
-#define FLT_MAX_EXP 128
-#define FLT_HAS_SUBNORM 1
-
-#define FLT_DIG 6
-#define FLT_DECIMAL_DIG 9
-#define FLT_MIN_10_EXP (-37)
-#define FLT_MAX_10_EXP 38
-
-#define DBL_TRUE_MIN 4.94065645841246544177e-324
-#define DBL_MIN 2.22507385850720138309e-308
-#define DBL_MAX 1.79769313486231570815e+308
-#define DBL_EPSILON 2.22044604925031308085e-16
-
-#define DBL_MANT_DIG 53
-#define DBL_MIN_EXP (-1021)
-#define DBL_MAX_EXP 1024
-#define DBL_HAS_SUBNORM 1
-
-#define DBL_DIG 15
-#define DBL_DECIMAL_DIG 17
-#define DBL_MIN_10_EXP (-307)
-#define DBL_MAX_10_EXP 308
-
-#define LDBL_HAS_SUBNORM 1
-#define LDBL_DECIMAL_DIG DECIMAL_DIG
-
-#include <bits/float.h>
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/x64/sysroot/include/fmtmsg.h b/arch/x64/sysroot/include/fmtmsg.h
index e6b0923..51abcc5 100644
--- a/arch/x64/sysroot/include/fmtmsg.h
+++ b/arch/x64/sysroot/include/fmtmsg.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FMTMSG_H_
+#define SYSROOT_FMTMSG_H_
#ifdef __cplusplus
extern "C" {
@@ -42,3 +43,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FMTMSG_H_
diff --git a/arch/x64/sysroot/include/fnmatch.h b/arch/x64/sysroot/include/fnmatch.h
index ea277a4..2e0f6cc 100644
--- a/arch/x64/sysroot/include/fnmatch.h
+++ b/arch/x64/sysroot/include/fnmatch.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_FNMATCH_H_
+#define SYSROOT_FNMATCH_H_
#ifdef __cplusplus
extern "C" {
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_FNMATCH_H_
diff --git a/arch/x64/sysroot/include/ftw.h b/arch/x64/sysroot/include/ftw.h
deleted file mode 100644
index 1c282aa..0000000
--- a/arch/x64/sysroot/include/ftw.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <features.h>
-#include <sys/stat.h>
-
-#define FTW_F 1
-#define FTW_D 2
-#define FTW_DNR 3
-#define FTW_NS 4
-#define FTW_SL 5
-#define FTW_DP 6
-#define FTW_SLN 7
-
-#define FTW_PHYS 1
-#define FTW_MOUNT 2
-#define FTW_CHDIR 4
-#define FTW_DEPTH 8
-
-struct FTW {
- int base;
- int level;
-};
-
-int ftw(const char*, int (*)(const char*, const struct stat*, int), int);
-int nftw(const char*, int (*)(const char*, const struct stat*, int, struct FTW*), int, int);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/x64/sysroot/include/getopt.h b/arch/x64/sysroot/include/getopt.h
index 8019e90..bcc632d 100644
--- a/arch/x64/sysroot/include/getopt.h
+++ b/arch/x64/sysroot/include/getopt.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GETOPT_H_
+#define SYSROOT_GETOPT_H_
#ifdef __cplusplus
extern "C" {
@@ -9,10 +10,10 @@
extern int optind, opterr, optopt, optreset;
struct option {
- const char* name;
- int has_arg;
- int* flag;
- int val;
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
};
int getopt_long(int, char* const*, const char*, const struct option*, int*);
@@ -25,3 +26,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GETOPT_H_
diff --git a/arch/x64/sysroot/include/glob.h b/arch/x64/sysroot/include/glob.h
index 580ffe1..98ff3f6 100644
--- a/arch/x64/sysroot/include/glob.h
+++ b/arch/x64/sysroot/include/glob.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GLOB_H_
+#define SYSROOT_GLOB_H_
#ifdef __cplusplus
extern "C" {
@@ -11,11 +12,11 @@
#include <bits/alltypes.h>
typedef struct {
- size_t gl_pathc;
- char** gl_pathv;
- size_t gl_offs;
- int __dummy1;
- void* __dummy2[5];
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ int __dummy1;
+ void* __dummy2[5];
} glob_t;
int glob(const char* __restrict, int, int (*)(const char*, int), glob_t* __restrict);
@@ -38,3 +39,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GLOB_H_
diff --git a/arch/x64/sysroot/include/grp.h b/arch/x64/sysroot/include/grp.h
index 5e0dd0a..4cfdd08 100644
--- a/arch/x64/sysroot/include/grp.h
+++ b/arch/x64/sysroot/include/grp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_GRP_H_
+#define SYSROOT_GRP_H_
#ifdef __cplusplus
extern "C" {
@@ -16,10 +17,10 @@
#include <bits/alltypes.h>
struct group {
- char* gr_name;
- char* gr_passwd;
- gid_t gr_gid;
- char** gr_mem;
+ char* gr_name;
+ char* gr_passwd;
+ gid_t gr_gid;
+ char** gr_mem;
};
struct group* getgrgid(gid_t);
@@ -46,3 +47,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_GRP_H_
diff --git a/arch/x64/sysroot/include/iconv.h b/arch/x64/sysroot/include/iconv.h
index 4fee288..c0c056b 100644
--- a/arch/x64/sysroot/include/iconv.h
+++ b/arch/x64/sysroot/include/iconv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_ICONV_H_
+#define SYSROOT_ICONV_H_
#ifdef __cplusplus
extern "C" {
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_ICONV_H_
diff --git a/arch/x64/sysroot/include/ifaddrs.h b/arch/x64/sysroot/include/ifaddrs.h
index 912a2b6..908945e 100644
--- a/arch/x64/sysroot/include/ifaddrs.h
+++ b/arch/x64/sysroot/include/ifaddrs.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_IFADDRS_H_
+#define SYSROOT_IFADDRS_H_
#ifdef __cplusplus
extern "C" {
@@ -9,16 +10,16 @@
#include <sys/socket.h>
struct ifaddrs {
- struct ifaddrs* ifa_next;
- char* ifa_name;
- unsigned ifa_flags;
- struct sockaddr* ifa_addr;
- struct sockaddr* ifa_netmask;
- union {
- struct sockaddr* ifu_broadaddr;
- struct sockaddr* ifu_dstaddr;
- } ifa_ifu;
- void* ifa_data;
+ struct ifaddrs* ifa_next;
+ char* ifa_name;
+ unsigned ifa_flags;
+ struct sockaddr* ifa_addr;
+ struct sockaddr* ifa_netmask;
+ union {
+ struct sockaddr* ifu_broadaddr;
+ struct sockaddr* ifu_dstaddr;
+ } ifa_ifu;
+ void* ifa_data;
};
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_IFADDRS_H_
diff --git a/arch/x64/sysroot/include/inttypes.h b/arch/x64/sysroot/include/inttypes.h
index db1b4d3..43bf604 100644
--- a/arch/x64/sysroot/include/inttypes.h
+++ b/arch/x64/sysroot/include/inttypes.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_INTTYPES_H_
+#define SYSROOT_INTTYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -9,7 +10,9 @@
#define __NEED_wchar_t
#include <bits/alltypes.h>
-typedef struct { intmax_t quot, rem; } imaxdiv_t;
+typedef struct {
+ intmax_t quot, rem;
+} imaxdiv_t;
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
@@ -138,7 +141,6 @@
#endif
-
#define PRId8 __INT8_FMTd__
#define PRId16 __INT16_FMTd__
#define PRId32 __INT32_FMTd__
@@ -350,3 +352,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_INTTYPES_H_
diff --git a/arch/x64/sysroot/include/iso646.h b/arch/x64/sysroot/include/iso646.h
index 59e7e16..8b7dda8 100644
--- a/arch/x64/sysroot/include/iso646.h
+++ b/arch/x64/sysroot/include/iso646.h
@@ -1,13 +1,14 @@
-#pragma once
+#ifndef SYSROOT_ISO646_H_
+#define SYSROOT_ISO646_H_
#ifndef __cplusplus
-#define and&&
+#define and &&
#define and_eq &=
-#define bitand&
+#define bitand &
#define bitor |
-#define compl~
-#define not!
+#define compl ~
+#define not !
#define not_eq !=
#define or ||
#define or_eq |=
@@ -15,3 +16,5 @@
#define xor_eq ^=
#endif
+
+#endif // SYSROOT_ISO646_H_
diff --git a/arch/x64/sysroot/include/langinfo.h b/arch/x64/sysroot/include/langinfo.h
index 0ee81bb..a14fcfd 100644
--- a/arch/x64/sysroot/include/langinfo.h
+++ b/arch/x64/sysroot/include/langinfo.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LANGINFO_H_
+#define SYSROOT_LANGINFO_H_
#ifdef __cplusplus
extern "C" {
@@ -87,3 +88,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LANGINFO_H_
diff --git a/arch/x64/sysroot/include/libgen.h b/arch/x64/sysroot/include/libgen.h
index 546dce0..f7f79b6 100644
--- a/arch/x64/sysroot/include/libgen.h
+++ b/arch/x64/sysroot/include/libgen.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LIBGEN_H_
+#define SYSROOT_LIBGEN_H_
#ifdef __cplusplus
extern "C" {
@@ -10,3 +11,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LIBGEN_H_
diff --git a/arch/x64/sysroot/include/limits.h b/arch/x64/sysroot/include/limits.h
index 290ef73..cf60386 100644
--- a/arch/x64/sysroot/include/limits.h
+++ b/arch/x64/sysroot/include/limits.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LIMITS_H_
+#define SYSROOT_LIMITS_H_
#include <features.h>
@@ -48,7 +49,6 @@
#define PATH_MAX 4096
#define NZERO 20
#define NGROUPS_MAX 32
-#define ARG_MAX 131072
#define IOV_MAX 1024
#define SYMLOOP_MAX 40
#define WORD_BIT 32
@@ -149,3 +149,5 @@
#define _XOPEN_IOV_MAX 16
#define _XOPEN_NAME_MAX 255
#define _XOPEN_PATH_MAX 1024
+
+#endif // SYSROOT_LIMITS_H_
diff --git a/arch/x64/sysroot/include/link.h b/arch/x64/sysroot/include/link.h
index 657e9a0..78ebd48 100644
--- a/arch/x64/sysroot/include/link.h
+++ b/arch/x64/sysroot/include/link.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_LINK_H_
+#define SYSROOT_LINK_H_
#ifdef __cplusplus
extern "C" {
@@ -15,31 +16,40 @@
typedef uint32_t Elf_Symndx;
struct dl_phdr_info {
- ElfW(Addr) dlpi_addr;
- const char* dlpi_name;
- const ElfW(Phdr) * dlpi_phdr;
- ElfW(Half) dlpi_phnum;
- unsigned long long int dlpi_adds;
- unsigned long long int dlpi_subs;
- size_t dlpi_tls_modid;
- void* dlpi_tls_data;
+ ElfW(Addr) dlpi_addr;
+ const char* dlpi_name;
+ const ElfW(Phdr) * dlpi_phdr;
+ ElfW(Half) dlpi_phnum;
+ unsigned long long int dlpi_adds;
+ unsigned long long int dlpi_subs;
+ size_t dlpi_tls_modid;
+ void* dlpi_tls_data;
};
struct link_map {
- ElfW(Addr) l_addr;
- char* l_name;
- ElfW(Dyn) * l_ld;
- struct link_map *l_next, *l_prev;
+ ElfW(Addr) l_addr;
+ char* l_name;
+ ElfW(Dyn) * l_ld;
+ struct link_map *l_next, *l_prev;
};
struct r_debug {
- int r_version;
- struct link_map* r_map;
- ElfW(Addr) r_brk;
- enum { RT_CONSISTENT,
- RT_ADD,
- RT_DELETE } r_state;
- ElfW(Addr) r_ldbase;
+ int r_version;
+ struct link_map* r_map;
+ ElfW(Addr) r_brk;
+
+ /* This is the address of a function internal to the run-time linker
+ that triggers a debug trap. This function will always be called
+ when the linker begins to map in a library or unmap it, and again
+ when the mapping change is complete.
+
+ The debugger can compare the address of a sw exception to this value
+ to determine whether the debug trap was triggered by the run-time
+ linker. */
+ ElfW(Addr) r_brk_on_load;
+
+ enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
+ ElfW(Addr) r_ldbase;
};
int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
@@ -47,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LINK_H_
diff --git a/arch/x64/sysroot/include/locale.h b/arch/x64/sysroot/include/locale.h
index 44f8d0b..ce78a02 100644
--- a/arch/x64/sysroot/include/locale.h
+++ b/arch/x64/sysroot/include/locale.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_LOCALE_H_
+#define SYSROOT_LOCALE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define LC_CTYPE 0
@@ -16,31 +18,31 @@
#define LC_ALL 6
struct lconv {
- char* decimal_point;
- char* thousands_sep;
- char* grouping;
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
- char* int_curr_symbol;
- char* currency_symbol;
- char* mon_decimal_point;
- char* mon_thousands_sep;
- char* mon_grouping;
- char* positive_sign;
- char* negative_sign;
- char int_frac_digits;
- char frac_digits;
- char p_cs_precedes;
- char p_sep_by_space;
- char n_cs_precedes;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_p_cs_precedes;
- char int_p_sep_by_space;
- char int_n_cs_precedes;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_p_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_cs_precedes;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
};
char* setlocale(int, const char*);
@@ -73,3 +75,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_LOCALE_H_
diff --git a/arch/x64/sysroot/include/malloc.h b/arch/x64/sysroot/include/malloc.h
index d057b89..6abb854 100644
--- a/arch/x64/sysroot/include/malloc.h
+++ b/arch/x64/sysroot/include/malloc.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MALLOC_H_
+#define SYSROOT_MALLOC_H_
#ifdef __cplusplus
extern "C" {
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MALLOC_H_
diff --git a/arch/x64/sysroot/include/math.h b/arch/x64/sysroot/include/math.h
index a32ec07..089c266 100644
--- a/arch/x64/sysroot/include/math.h
+++ b/arch/x64/sysroot/include/math.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MATH_H_
+#define SYSROOT_MATH_H_
#ifdef __cplusplus
extern "C" {
@@ -40,67 +41,63 @@
int __fpclassifyl(long double);
static __inline unsigned __FLOAT_BITS(float __f) {
- union {
- float __f;
- unsigned __i;
- } __u;
- __u.__f = __f;
- return __u.__i;
+ union {
+ float __f;
+ unsigned __i;
+ } __u;
+ __u.__f = __f;
+ return __u.__i;
}
static __inline unsigned long long __DOUBLE_BITS(double __f) {
- union {
- double __f;
- unsigned long long __i;
- } __u;
- __u.__f = __f;
- return __u.__i;
+ union {
+ double __f;
+ unsigned long long __i;
+ } __u;
+ __u.__f = __f;
+ return __u.__i;
}
-#define fpclassify(x) \
- (sizeof(x) == sizeof(float) ? __fpclassifyf(x) : sizeof(x) == sizeof(double) \
- ? __fpclassify(x) \
- : __fpclassifyl(x))
+#define fpclassify(x) \
+ (sizeof(x) == sizeof(float) ? __fpclassifyf(x) \
+ : sizeof(x) == sizeof(double) ? __fpclassify(x) : __fpclassifyl(x))
-#define isinf(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) == 0x7ffULL << 52 \
- : __fpclassifyl(x) == FP_INFINITE)
+#define isinf(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) == 0x7ffULL << 52 \
+ : __fpclassifyl(x) == FP_INFINITE)
-#define isnan(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) > 0x7ffULL << 52 \
- : __fpclassifyl(x) == FP_NAN)
+#define isnan(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) > 0x7ffULL << 52 \
+ : __fpclassifyl(x) == FP_NAN)
-#define isnormal(x) \
- (sizeof(x) == sizeof(float) \
- ? ((__FLOAT_BITS(x) + 0x00800000) & 0x7fffffff) >= 0x01000000 \
- : sizeof(x) == sizeof(double) \
- ? ((__DOUBLE_BITS(x) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53 \
- : __fpclassifyl(x) == FP_NORMAL)
+#define isnormal(x) \
+ (sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x) + 0x00800000) & 0x7fffffff) >= 0x01000000 \
+ : sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x) + (1ULL << 52)) & \
+ -1ULL >> 1) >= 1ULL << 53 \
+ : __fpclassifyl(x) == FP_NORMAL)
-#define isfinite(x) \
- (sizeof(x) == sizeof(float) \
- ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 \
- : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) < 0x7ffULL << 52 \
- : __fpclassifyl(x) > FP_INFINITE)
+#define isfinite(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 \
+ : sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL >> 1) < 0x7ffULL << 52 \
+ : __fpclassifyl(x) > FP_INFINITE)
int __signbit(double);
int __signbitf(float);
int __signbitl(long double);
-#define signbit(x) \
- (sizeof(x) == sizeof(float) \
- ? (int)(__FLOAT_BITS(x) >> 31) \
- : sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x) >> 63) : __signbitl(x))
+#define signbit(x) \
+ (sizeof(x) == sizeof(float) \
+ ? (int)(__FLOAT_BITS(x) >> 31) \
+ : sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x) >> 63) : __signbitl(x))
#define isunordered(x, y) __builtin_isunordered(x, y)
-#define __ISREL_DEF(rel, op, type) \
- static __inline int __is##rel(type __x, type __y) { \
- return !isunordered(__x, __y) && __x op __y; \
- }
+#define __ISREL_DEF(rel, op, type) \
+ static __inline int __is##rel(type __x, type __y) { return !isunordered(__x, __y) && __x op __y; }
__ISREL_DEF(lessf, <, float_t)
__ISREL_DEF(less, <, double_t)
@@ -429,3 +426,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MATH_H_
diff --git a/arch/x64/sysroot/include/monetary.h b/arch/x64/sysroot/include/monetary.h
index b6081b9..d1955fa 100644
--- a/arch/x64/sysroot/include/monetary.h
+++ b/arch/x64/sysroot/include/monetary.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_MONETARY_H_
+#define SYSROOT_MONETARY_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_MONETARY_H_
diff --git a/arch/x64/sysroot/include/net/ethernet.h b/arch/x64/sysroot/include/net/ethernet.h
index 41dab8b..9cee87d 100644
--- a/arch/x64/sysroot/include/net/ethernet.h
+++ b/arch/x64/sysroot/include/net/ethernet.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_ETHERNET_H_
+#define SYSROOT_NET_ETHERNET_H_
#ifdef __cplusplus
extern "C" {
@@ -9,13 +10,13 @@
#include <sys/types.h>
struct ether_addr {
- uint8_t ether_addr_octet[ETH_ALEN];
+ uint8_t ether_addr_octet[ETH_ALEN];
};
struct ether_header {
- uint8_t ether_dhost[ETH_ALEN];
- uint8_t ether_shost[ETH_ALEN];
- uint16_t ether_type;
+ uint8_t ether_dhost[ETH_ALEN];
+ uint8_t ether_shost[ETH_ALEN];
+ uint16_t ether_type;
};
#define ETHERTYPE_PUP 0x0200
@@ -48,3 +49,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_ETHERNET_H_
diff --git a/arch/x64/sysroot/include/net/if.h b/arch/x64/sysroot/include/net/if.h
index 687175b..e97c3ee 100644
--- a/arch/x64/sysroot/include/net/if.h
+++ b/arch/x64/sysroot/include/net/if.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_IF_H_
+#define SYSROOT_NET_IF_H_
#ifdef __cplusplus
extern "C" {
@@ -9,8 +10,8 @@
#define IF_NAMESIZE 16
struct if_nameindex {
- unsigned int if_index;
- char* if_name;
+ unsigned int if_index;
+ char* if_name;
};
unsigned int if_nametoindex(const char*);
@@ -41,53 +42,53 @@
#define IFF_LOWER_UP 0x10000
#define IFF_DORMANT 0x20000
#define IFF_ECHO 0x40000
-#define IFF_VOLATILE \
- (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST | IFF_ECHO | IFF_MASTER | IFF_SLAVE | \
- IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)
+#define IFF_VOLATILE \
+ (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST | IFF_ECHO | IFF_MASTER | IFF_SLAVE | \
+ IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)
struct ifaddr {
- struct sockaddr ifa_addr;
- union {
- struct sockaddr ifu_broadaddr;
- struct sockaddr ifu_dstaddr;
- } ifa_ifu;
- struct iface* ifa_ifp;
- struct ifaddr* ifa_next;
+ struct sockaddr ifa_addr;
+ union {
+ struct sockaddr ifu_broadaddr;
+ struct sockaddr ifu_dstaddr;
+ } ifa_ifu;
+ struct iface* ifa_ifp;
+ struct ifaddr* ifa_next;
};
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
struct ifmap {
- unsigned long int mem_start;
- unsigned long int mem_end;
- unsigned short int base_addr;
- unsigned char irq;
- unsigned char dma;
- unsigned char port;
+ unsigned long int mem_start;
+ unsigned long int mem_end;
+ unsigned short int base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
};
#define IFHWADDRLEN 6
#define IFNAMSIZ IF_NAMESIZE
struct ifreq {
- union {
- char ifrn_name[IFNAMSIZ];
- } ifr_ifrn;
- union {
- struct sockaddr ifru_addr;
- struct sockaddr ifru_dstaddr;
- struct sockaddr ifru_broadaddr;
- struct sockaddr ifru_netmask;
- struct sockaddr ifru_hwaddr;
- short int ifru_flags;
- int ifru_ivalue;
- int ifru_mtu;
- struct ifmap ifru_map;
- char ifru_slave[IFNAMSIZ];
- char ifru_newname[IFNAMSIZ];
- void* ifru_data;
- } ifr_ifru;
+ union {
+ char ifrn_name[IFNAMSIZ];
+ } ifr_ifrn;
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short int ifru_flags;
+ int ifru_ivalue;
+ int ifru_mtu;
+ struct ifmap ifru_map;
+ char ifru_slave[IFNAMSIZ];
+ char ifru_newname[IFNAMSIZ];
+ void* ifru_data;
+ } ifr_ifru;
};
#define ifr_name ifr_ifrn.ifrn_name
@@ -111,11 +112,11 @@
#define _IOT_ifreq_int _IOT(_IOTS(char), IFNAMSIZ, _IOTS(int), 1, 0, 0)
struct ifconf {
- int ifc_len;
- union {
- void* ifcu_buf;
- struct ifreq* ifcu_req;
- } ifc_ifcu;
+ int ifc_len;
+ union {
+ void* ifcu_buf;
+ struct ifreq* ifcu_req;
+ } ifc_ifcu;
};
#define ifc_buf ifc_ifcu.ifcu_buf
@@ -127,3 +128,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_IF_H_
diff --git a/arch/x64/sysroot/include/net/if_arp.h b/arch/x64/sysroot/include/net/if_arp.h
index 6da9341..40b902d 100644
--- a/arch/x64/sysroot/include/net/if_arp.h
+++ b/arch/x64/sysroot/include/net/if_arp.h
@@ -1,6 +1,7 @@
/* Nonstandard header */
-#pragma once
+#ifndef SYSROOT_NET_IF_ARP_H_
+#define SYSROOT_NET_IF_ARP_H_
#ifdef __cplusplus
extern "C" {
@@ -21,11 +22,11 @@
#define ARPOP_NAK 10
struct arphdr {
- uint16_t ar_hrd;
- uint16_t ar_pro;
- uint8_t ar_hln;
- uint8_t ar_pln;
- uint16_t ar_op;
+ uint16_t ar_hrd;
+ uint16_t ar_pro;
+ uint8_t ar_hln;
+ uint8_t ar_pln;
+ uint16_t ar_op;
};
#define ARPHRD_NETROM 0
@@ -96,18 +97,18 @@
#define ARPHRD_NONE 0xFFFE
struct arpreq {
- struct sockaddr arp_pa;
- struct sockaddr arp_ha;
- int arp_flags;
- struct sockaddr arp_netmask;
- char arp_dev[16];
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
+ char arp_dev[16];
};
struct arpreq_old {
- struct sockaddr arp_pa;
- struct sockaddr arp_ha;
- int arp_flags;
- struct sockaddr arp_netmask;
+ struct sockaddr arp_pa;
+ struct sockaddr arp_ha;
+ int arp_flags;
+ struct sockaddr arp_netmask;
};
#define ATF_COM 0x02
@@ -123,14 +124,16 @@
#define ARPD_FLUSH 0x03
struct arpd_request {
- unsigned short req;
- uint32_t ip;
- unsigned long dev;
- unsigned long stamp;
- unsigned long updated;
- unsigned char ha[MAX_ADDR_LEN];
+ unsigned short req;
+ uint32_t ip;
+ unsigned long dev;
+ unsigned long stamp;
+ unsigned long updated;
+ unsigned char ha[MAX_ADDR_LEN];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_IF_ARP_H_
diff --git a/arch/x64/sysroot/include/net/route.h b/arch/x64/sysroot/include/net/route.h
index 5d2d3d0..dc5960b 100644
--- a/arch/x64/sysroot/include/net/route.h
+++ b/arch/x64/sysroot/include/net/route.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NET_ROUTE_H_
+#define SYSROOT_NET_ROUTE_H_
#ifdef __cplusplus
extern "C" {
@@ -10,36 +11,36 @@
#include <sys/types.h>
struct rtentry {
- unsigned long int rt_pad1;
- struct sockaddr rt_dst;
- struct sockaddr rt_gateway;
- struct sockaddr rt_genmask;
- unsigned short int rt_flags;
- short int rt_pad2;
- unsigned long int rt_pad3;
- unsigned char rt_tos;
- unsigned char rt_class;
- short int rt_pad4[sizeof(long) / 2 - 1];
- short int rt_metric;
- char* rt_dev;
- unsigned long int rt_mtu;
- unsigned long int rt_window;
- unsigned short int rt_irtt;
+ unsigned long int rt_pad1;
+ struct sockaddr rt_dst;
+ struct sockaddr rt_gateway;
+ struct sockaddr rt_genmask;
+ unsigned short int rt_flags;
+ short int rt_pad2;
+ unsigned long int rt_pad3;
+ unsigned char rt_tos;
+ unsigned char rt_class;
+ short int rt_pad4[sizeof(long) / 2 - 1];
+ short int rt_metric;
+ char* rt_dev;
+ unsigned long int rt_mtu;
+ unsigned long int rt_window;
+ unsigned short int rt_irtt;
};
#define rt_mss rt_mtu
struct in6_rtmsg {
- struct in6_addr rtmsg_dst;
- struct in6_addr rtmsg_src;
- struct in6_addr rtmsg_gateway;
- uint32_t rtmsg_type;
- uint16_t rtmsg_dst_len;
- uint16_t rtmsg_src_len;
- uint32_t rtmsg_metric;
- unsigned long int rtmsg_info;
- uint32_t rtmsg_flags;
- int rtmsg_ifindex;
+ struct in6_addr rtmsg_dst;
+ struct in6_addr rtmsg_src;
+ struct in6_addr rtmsg_gateway;
+ uint32_t rtmsg_type;
+ uint16_t rtmsg_dst_len;
+ uint16_t rtmsg_src_len;
+ uint32_t rtmsg_metric;
+ unsigned long int rtmsg_info;
+ uint32_t rtmsg_flags;
+ int rtmsg_ifindex;
};
#define RTF_UP 0x0001
@@ -114,3 +115,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NET_ROUTE_H_
diff --git a/arch/x64/sysroot/include/netdb.h b/arch/x64/sysroot/include/netdb.h
index 5b8ab72..d5bb5ef 100644
--- a/arch/x64/sysroot/include/netdb.h
+++ b/arch/x64/sysroot/include/netdb.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETDB_H_
+#define SYSROOT_NETDB_H_
#ifdef __cplusplus
extern "C" {
@@ -13,14 +14,14 @@
#endif
struct addrinfo {
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- socklen_t ai_addrlen;
- struct sockaddr* ai_addr;
- char* ai_canonname;
- struct addrinfo* ai_next;
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ socklen_t ai_addrlen;
+ struct sockaddr* ai_addr;
+ char* ai_canonname;
+ struct addrinfo* ai_next;
};
#define IPPORT_RESERVED 1024
@@ -61,32 +62,32 @@
/* Legacy functions follow (marked OBsolete in SUS) */
struct netent {
- char* n_name;
- char** n_aliases;
- int n_addrtype;
- uint32_t n_net;
+ char* n_name;
+ char** n_aliases;
+ int n_addrtype;
+ uint32_t n_net;
};
struct hostent {
- char* h_name;
- char** h_aliases;
- int h_addrtype;
- int h_length;
- char** h_addr_list;
+ char* h_name;
+ char** h_aliases;
+ int h_addrtype;
+ int h_length;
+ char** h_addr_list;
};
#define h_addr h_addr_list[0]
struct servent {
- char* s_name;
- char** s_aliases;
- int s_port;
- char* s_proto;
+ char* s_name;
+ char** s_aliases;
+ int s_port;
+ char* s_proto;
};
struct protoent {
- char* p_name;
- char** p_aliases;
- int p_proto;
+ char* p_name;
+ char** p_aliases;
+ int p_proto;
};
void sethostent(int);
@@ -150,3 +151,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETDB_H_
diff --git a/arch/x64/sysroot/include/netinet/ether.h b/arch/x64/sysroot/include/netinet/ether.h
index 0a65077..74668fb 100644
--- a/arch/x64/sysroot/include/netinet/ether.h
+++ b/arch/x64/sysroot/include/netinet/ether.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_ETHER_H_
+#define SYSROOT_NETINET_ETHER_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_ETHER_H_
diff --git a/arch/x64/sysroot/include/netinet/icmp6.h b/arch/x64/sysroot/include/netinet/icmp6.h
index 9a50bcd..dde64cb 100644
--- a/arch/x64/sysroot/include/netinet/icmp6.h
+++ b/arch/x64/sysroot/include/netinet/icmp6.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_ICMP6_H_
+#define SYSROOT_NETINET_ICMP6_H_
#ifdef __cplusplus
extern "C" {
@@ -17,18 +18,18 @@
#define ICMP6_FILTER_PASSONLY 4
struct icmp6_filter {
- uint32_t icmp6_filt[8];
+ uint32_t icmp6_filt[8];
};
struct icmp6_hdr {
- uint8_t icmp6_type;
- uint8_t icmp6_code;
- uint16_t icmp6_cksum;
- union {
- uint32_t icmp6_un_data32[1];
- uint16_t icmp6_un_data16[2];
- uint8_t icmp6_un_data8[4];
- } icmp6_dataun;
+ uint8_t icmp6_type;
+ uint8_t icmp6_code;
+ uint16_t icmp6_cksum;
+ union {
+ uint32_t icmp6_un_data32[1];
+ uint16_t icmp6_un_data16[2];
+ uint8_t icmp6_un_data8[4];
+ } icmp6_dataun;
};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
@@ -67,16 +68,16 @@
#define ICMP6_PARAMPROB_OPTION 2
#define ICMP6_FILTER_WILLPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) == 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) == 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) != 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type)&31))) != 0)
#define ICMP6_FILTER_SETPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type)&31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type)&31))))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type)&31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type)&31))))
#define ICMP6_FILTER_SETPASSALL(filterp) memset(filterp, 0, sizeof(struct icmp6_filter));
@@ -89,7 +90,7 @@
#define ND_REDIRECT 137
struct nd_router_solicit {
- struct icmp6_hdr nd_rs_hdr;
+ struct icmp6_hdr nd_rs_hdr;
};
#define nd_rs_type nd_rs_hdr.icmp6_type
@@ -98,9 +99,9 @@
#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
struct nd_router_advert {
- struct icmp6_hdr nd_ra_hdr;
- uint32_t nd_ra_reachable;
- uint32_t nd_ra_retransmit;
+ struct icmp6_hdr nd_ra_hdr;
+ uint32_t nd_ra_reachable;
+ uint32_t nd_ra_retransmit;
};
#define nd_ra_type nd_ra_hdr.icmp6_type
@@ -114,8 +115,8 @@
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit {
- struct icmp6_hdr nd_ns_hdr;
- struct in6_addr nd_ns_target;
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target;
};
#define nd_ns_type nd_ns_hdr.icmp6_type
@@ -124,8 +125,8 @@
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
struct nd_neighbor_advert {
- struct icmp6_hdr nd_na_hdr;
- struct in6_addr nd_na_target;
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target;
};
#define nd_na_type nd_na_hdr.icmp6_type
@@ -143,9 +144,9 @@
#endif
struct nd_redirect {
- struct icmp6_hdr nd_rd_hdr;
- struct in6_addr nd_rd_target;
- struct in6_addr nd_rd_dst;
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target;
+ struct in6_addr nd_rd_dst;
};
#define nd_rd_type nd_rd_hdr.icmp6_type
@@ -154,8 +155,8 @@
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
struct nd_opt_hdr {
- uint8_t nd_opt_type;
- uint8_t nd_opt_len;
+ uint8_t nd_opt_type;
+ uint8_t nd_opt_len;
};
#define ND_OPT_SOURCE_LINKADDR 1
@@ -167,14 +168,14 @@
#define ND_OPT_HOME_AGENT_INFO 8
struct nd_opt_prefix_info {
- uint8_t nd_opt_pi_type;
- uint8_t nd_opt_pi_len;
- uint8_t nd_opt_pi_prefix_len;
- uint8_t nd_opt_pi_flags_reserved;
- uint32_t nd_opt_pi_valid_time;
- uint32_t nd_opt_pi_preferred_time;
- uint32_t nd_opt_pi_reserved2;
- struct in6_addr nd_opt_pi_prefix;
+ uint8_t nd_opt_pi_type;
+ uint8_t nd_opt_pi_len;
+ uint8_t nd_opt_pi_prefix_len;
+ uint8_t nd_opt_pi_flags_reserved;
+ uint32_t nd_opt_pi_valid_time;
+ uint32_t nd_opt_pi_preferred_time;
+ uint32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
};
#define ND_OPT_PI_FLAG_ONLINK 0x80
@@ -182,22 +183,22 @@
#define ND_OPT_PI_FLAG_RADDR 0x20
struct nd_opt_rd_hdr {
- uint8_t nd_opt_rh_type;
- uint8_t nd_opt_rh_len;
- uint16_t nd_opt_rh_reserved1;
- uint32_t nd_opt_rh_reserved2;
+ uint8_t nd_opt_rh_type;
+ uint8_t nd_opt_rh_len;
+ uint16_t nd_opt_rh_reserved1;
+ uint32_t nd_opt_rh_reserved2;
};
struct nd_opt_mtu {
- uint8_t nd_opt_mtu_type;
- uint8_t nd_opt_mtu_len;
- uint16_t nd_opt_mtu_reserved;
- uint32_t nd_opt_mtu_mtu;
+ uint8_t nd_opt_mtu_type;
+ uint8_t nd_opt_mtu_len;
+ uint16_t nd_opt_mtu_reserved;
+ uint32_t nd_opt_mtu_mtu;
};
struct mld_hdr {
- struct icmp6_hdr mld_icmp6_hdr;
- struct in6_addr mld_addr;
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr;
};
#define mld_type mld_icmp6_hdr.icmp6_type
@@ -209,11 +210,11 @@
#define ICMP6_ROUTER_RENUMBERING 138
struct icmp6_router_renum {
- struct icmp6_hdr rr_hdr;
- uint8_t rr_segnum;
- uint8_t rr_flags;
- uint16_t rr_maxdelay;
- uint32_t rr_reserved;
+ struct icmp6_hdr rr_hdr;
+ uint8_t rr_segnum;
+ uint8_t rr_flags;
+ uint16_t rr_maxdelay;
+ uint32_t rr_reserved;
};
#define rr_type rr_hdr.icmp6_type
@@ -228,14 +229,14 @@
#define ICMP6_RR_FLAGS_PREVDONE 0x08
struct rr_pco_match {
- uint8_t rpm_code;
- uint8_t rpm_len;
- uint8_t rpm_ordinal;
- uint8_t rpm_matchlen;
- uint8_t rpm_minlen;
- uint8_t rpm_maxlen;
- uint16_t rpm_reserved;
- struct in6_addr rpm_prefix;
+ uint8_t rpm_code;
+ uint8_t rpm_len;
+ uint8_t rpm_ordinal;
+ uint8_t rpm_matchlen;
+ uint8_t rpm_minlen;
+ uint8_t rpm_maxlen;
+ uint16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
};
#define RPM_PCO_ADD 1
@@ -243,14 +244,14 @@
#define RPM_PCO_SETGLOBAL 3
struct rr_pco_use {
- uint8_t rpu_uselen;
- uint8_t rpu_keeplen;
- uint8_t rpu_ramask;
- uint8_t rpu_raflags;
- uint32_t rpu_vltime;
- uint32_t rpu_pltime;
- uint32_t rpu_flags;
- struct in6_addr rpu_prefix;
+ uint8_t rpu_uselen;
+ uint8_t rpu_keeplen;
+ uint8_t rpu_ramask;
+ uint8_t rpu_raflags;
+ uint32_t rpu_vltime;
+ uint32_t rpu_pltime;
+ uint32_t rpu_flags;
+ struct in6_addr rpu_prefix;
};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
@@ -265,11 +266,11 @@
#endif
struct rr_result {
- uint16_t rrr_flags;
- uint8_t rrr_ordinal;
- uint8_t rrr_matchedlen;
- uint32_t rrr_ifid;
- struct in6_addr rrr_prefix;
+ uint16_t rrr_flags;
+ uint8_t rrr_ordinal;
+ uint8_t rrr_matchedlen;
+ uint32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -281,20 +282,22 @@
#endif
struct nd_opt_adv_interval {
- uint8_t nd_opt_adv_interval_type;
- uint8_t nd_opt_adv_interval_len;
- uint16_t nd_opt_adv_interval_reserved;
- uint32_t nd_opt_adv_interval_ival;
+ uint8_t nd_opt_adv_interval_type;
+ uint8_t nd_opt_adv_interval_len;
+ uint16_t nd_opt_adv_interval_reserved;
+ uint32_t nd_opt_adv_interval_ival;
};
struct nd_opt_home_agent_info {
- uint8_t nd_opt_home_agent_info_type;
- uint8_t nd_opt_home_agent_info_len;
- uint16_t nd_opt_home_agent_info_reserved;
- uint16_t nd_opt_home_agent_info_preference;
- uint16_t nd_opt_home_agent_info_lifetime;
+ uint8_t nd_opt_home_agent_info_type;
+ uint8_t nd_opt_home_agent_info_len;
+ uint16_t nd_opt_home_agent_info_reserved;
+ uint16_t nd_opt_home_agent_info_preference;
+ uint16_t nd_opt_home_agent_info_lifetime;
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_ICMP6_H_
diff --git a/arch/x64/sysroot/include/netinet/if_ether.h b/arch/x64/sysroot/include/netinet/if_ether.h
index ee7d38e..f826e96 100644
--- a/arch/x64/sysroot/include/netinet/if_ether.h
+++ b/arch/x64/sysroot/include/netinet/if_ether.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IF_ETHER_H_
+#define SYSROOT_NETINET_IF_ETHER_H_
#include <stdint.h>
#include <sys/types.h>
@@ -93,20 +94,20 @@
#define ETH_P_CAIF 0x00F7
struct ethhdr {
- uint8_t h_dest[ETH_ALEN];
- uint8_t h_source[ETH_ALEN];
- uint16_t h_proto;
+ uint8_t h_dest[ETH_ALEN];
+ uint8_t h_source[ETH_ALEN];
+ uint16_t h_proto;
};
#include <net/ethernet.h>
#include <net/if_arp.h>
struct ether_arp {
- struct arphdr ea_hdr;
- uint8_t arp_sha[ETH_ALEN];
- uint8_t arp_spa[4];
- uint8_t arp_tha[ETH_ALEN];
- uint8_t arp_tpa[4];
+ struct arphdr ea_hdr;
+ uint8_t arp_sha[ETH_ALEN];
+ uint8_t arp_spa[4];
+ uint8_t arp_tha[ETH_ALEN];
+ uint8_t arp_tpa[4];
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
@@ -114,12 +115,14 @@
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
-#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
- do { \
- (enaddr)[0] = 0x01; \
- (enaddr)[1] = 0x00; \
- (enaddr)[2] = 0x5e; \
- (enaddr)[3] = ((uint8_t*)ipaddr)[1] & 0x7f; \
- (enaddr)[4] = ((uint8_t*)ipaddr)[2]; \
- (enaddr)[5] = ((uint8_t*)ipaddr)[3]; \
- } while (0)
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+ do { \
+ (enaddr)[0] = 0x01; \
+ (enaddr)[1] = 0x00; \
+ (enaddr)[2] = 0x5e; \
+ (enaddr)[3] = ((uint8_t*)ipaddr)[1] & 0x7f; \
+ (enaddr)[4] = ((uint8_t*)ipaddr)[2]; \
+ (enaddr)[5] = ((uint8_t*)ipaddr)[3]; \
+ } while (0)
+
+#endif // SYSROOT_NETINET_IF_ETHER_H_
diff --git a/arch/x64/sysroot/include/netinet/igmp.h b/arch/x64/sysroot/include/netinet/igmp.h
index a59a1cc..99eb989 100644
--- a/arch/x64/sysroot/include/netinet/igmp.h
+++ b/arch/x64/sysroot/include/netinet/igmp.h
@@ -1,13 +1,14 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IGMP_H_
+#define SYSROOT_NETINET_IGMP_H_
#include <netinet/in.h>
#include <stdint.h>
struct igmp {
- uint8_t igmp_type;
- uint8_t igmp_code;
- uint16_t igmp_cksum;
- struct in_addr igmp_group;
+ uint8_t igmp_type;
+ uint8_t igmp_code;
+ uint16_t igmp_cksum;
+ struct in_addr igmp_group;
};
#define IGMP_MINLEN 8
@@ -40,3 +41,5 @@
#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
+
+#endif // SYSROOT_NETINET_IGMP_H_
diff --git a/arch/x64/sysroot/include/netinet/in.h b/arch/x64/sysroot/include/netinet/in.h
index e626a93..6d18e44 100644
--- a/arch/x64/sysroot/include/netinet/in.h
+++ b/arch/x64/sysroot/include/netinet/in.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IN_H_
+#define SYSROOT_NETINET_IN_H_
#ifdef __cplusplus
extern "C" {
@@ -11,38 +12,38 @@
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
struct in_addr {
- in_addr_t s_addr;
+ in_addr_t s_addr;
};
struct sockaddr_in {
- sa_family_t sin_family;
- in_port_t sin_port;
- struct in_addr sin_addr;
- uint8_t sin_zero[8];
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t sin_zero[8];
};
struct in6_addr {
- union {
- uint8_t __s6_addr[16];
- uint16_t __s6_addr16[8];
- uint32_t __s6_addr32[4];
- } __in6_union;
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
};
#define s6_addr __in6_union.__s6_addr
#define s6_addr16 __in6_union.__s6_addr16
#define s6_addr32 __in6_union.__s6_addr32
struct sockaddr_in6 {
- sa_family_t sin6_family;
- in_port_t sin6_port;
- uint32_t sin6_flowinfo;
- struct in6_addr sin6_addr;
- uint32_t sin6_scope_id;
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
};
struct ipv6_mreq {
- struct in6_addr ipv6mr_multiaddr;
- unsigned ipv6mr_interface;
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
};
#define INADDR_ANY ((in_addr_t)0x00000000)
@@ -55,18 +56,18 @@
#define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002)
#define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff)
-#define IN6ADDR_ANY_INIT \
- { \
- { \
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } \
- } \
- }
-#define IN6ADDR_LOOPBACK_INIT \
- { \
- { \
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } \
- } \
- }
+#define IN6ADDR_ANY_INIT \
+ { \
+ { \
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } \
+ } \
+ }
+#define IN6ADDR_LOOPBACK_INIT \
+ { \
+ { \
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } \
+ } \
+ }
extern const struct in6_addr in6addr_any, in6addr_loopback;
@@ -114,46 +115,46 @@
#define IPPROTO_RAW 255
#define IPPROTO_MAX 256
-#define IN6_IS_ADDR_UNSPECIFIED(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint32_t*)(a))[3] == 0)
+#define IN6_IS_ADDR_UNSPECIFIED(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint32_t*)(a))[3] == 0)
-#define IN6_IS_ADDR_LOOPBACK(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint8_t*)(a))[12] == 0 && ((uint8_t*)(a))[13] == 0 && ((uint8_t*)(a))[14] == 0 && \
- ((uint8_t*)(a))[15] == 1)
+#define IN6_IS_ADDR_LOOPBACK(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint8_t*)(a))[12] == 0 && ((uint8_t*)(a))[13] == 0 && ((uint8_t*)(a))[14] == 0 && \
+ ((uint8_t*)(a))[15] == 1)
#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t*)(a))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(a) \
- ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0x80)
+ ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0x80)
#define IN6_IS_ADDR_SITELOCAL(a) \
- ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0xc0)
+ ((((uint8_t*)(a))[0]) == 0xfe && (((uint8_t*)(a))[1] & 0xc0) == 0xc0)
-#define IN6_IS_ADDR_V4MAPPED(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint8_t*)(a))[8] == 0 && \
- ((uint8_t*)(a))[9] == 0 && ((uint8_t*)(a))[10] == 0xff && ((uint8_t*)(a))[11] == 0xff)
+#define IN6_IS_ADDR_V4MAPPED(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint8_t*)(a))[8] == 0 && \
+ ((uint8_t*)(a))[9] == 0 && ((uint8_t*)(a))[10] == 0xff && ((uint8_t*)(a))[11] == 0xff)
-#define IN6_IS_ADDR_V4COMPAT(a) \
- (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
- ((uint8_t*)(a))[15] > 1)
+#define IN6_IS_ADDR_V4COMPAT(a) \
+ (((uint32_t*)(a))[0] == 0 && ((uint32_t*)(a))[1] == 0 && ((uint32_t*)(a))[2] == 0 && \
+ ((uint8_t*)(a))[15] > 1)
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x1))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x2))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x5))
+ (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(a) (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t*)(a))[1] & 0xf) == 0xe))
#define __ARE_4_EQUAL(a, b) \
- (!((0 [a] - 0 [b]) | (1 [a] - 1 [b]) | (2 [a] - 2 [b]) | (3 [a] - 3 [b])))
+ (!((0 [a] - 0 [b]) | (1 [a] - 1 [b]) | (2 [a] - 2 [b]) | (3 [a] - 3 [b])))
#define IN6_ARE_ADDR_EQUAL(a, b) __ARE_4_EQUAL((const uint32_t*)(a), (const uint32_t*)(b))
#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
@@ -230,8 +231,8 @@
#define IP_MAX_MEMBERSHIPS 20
struct ip_opts {
- struct in_addr ip_dst;
- char ip_opts[40];
+ struct in_addr ip_dst;
+ char ip_opts[40];
};
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -248,68 +249,68 @@
#define MCAST_INCLUDE 1
struct ip_mreq {
- struct in_addr imr_multiaddr;
- struct in_addr imr_interface;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
};
struct ip_mreqn {
- struct in_addr imr_multiaddr;
- struct in_addr imr_address;
- int imr_ifindex;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
};
struct ip_mreq_source {
- struct in_addr imr_multiaddr;
- struct in_addr imr_interface;
- struct in_addr imr_sourceaddr;
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+ struct in_addr imr_sourceaddr;
};
struct ip_msfilter {
- struct in_addr imsf_multiaddr;
- struct in_addr imsf_interface;
- uint32_t imsf_fmode;
- uint32_t imsf_numsrc;
- struct in_addr imsf_slist[1];
+ struct in_addr imsf_multiaddr;
+ struct in_addr imsf_interface;
+ uint32_t imsf_fmode;
+ uint32_t imsf_numsrc;
+ struct in_addr imsf_slist[1];
};
#define IP_MSFILTER_SIZE(numsrc) \
- (sizeof(struct ip_msfilter) - sizeof(struct in_addr) + (numsrc) * sizeof(struct in_addr))
+ (sizeof(struct ip_msfilter) - sizeof(struct in_addr) + (numsrc) * sizeof(struct in_addr))
struct group_req {
- uint32_t gr_interface;
- struct sockaddr_storage gr_group;
+ uint32_t gr_interface;
+ struct sockaddr_storage gr_group;
};
struct group_source_req {
- uint32_t gsr_interface;
- struct sockaddr_storage gsr_group;
- struct sockaddr_storage gsr_source;
+ uint32_t gsr_interface;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
};
struct group_filter {
- uint32_t gf_interface;
- struct sockaddr_storage gf_group;
- uint32_t gf_fmode;
- uint32_t gf_numsrc;
- struct sockaddr_storage gf_slist[1];
+ uint32_t gf_interface;
+ struct sockaddr_storage gf_group;
+ uint32_t gf_fmode;
+ uint32_t gf_numsrc;
+ struct sockaddr_storage gf_slist[1];
};
-#define GROUP_FILTER_SIZE(numsrc) \
- (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) + \
- (numsrc) * sizeof(struct sockaddr_storage))
+#define GROUP_FILTER_SIZE(numsrc) \
+ (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) + \
+ (numsrc) * sizeof(struct sockaddr_storage))
struct in_pktinfo {
- int ipi_ifindex;
- struct in_addr ipi_spec_dst;
- struct in_addr ipi_addr;
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
};
struct in6_pktinfo {
- struct in6_addr ipi6_addr;
- unsigned ipi6_ifindex;
+ struct in6_addr ipi6_addr;
+ unsigned ipi6_ifindex;
};
struct ip6_mtuinfo {
- struct sockaddr_in6 ip6m_addr;
- uint32_t ip6m_mtu;
+ struct sockaddr_in6 ip6m_addr;
+ uint32_t ip6m_mtu;
};
#endif
@@ -392,3 +393,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IN_H_
diff --git a/arch/x64/sysroot/include/netinet/in_systm.h b/arch/x64/sysroot/include/netinet/in_systm.h
index ea7ed91..8e688ab 100644
--- a/arch/x64/sysroot/include/netinet/in_systm.h
+++ b/arch/x64/sysroot/include/netinet/in_systm.h
@@ -1,6 +1,9 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IN_SYSTM_H_
+#define SYSROOT_NETINET_IN_SYSTM_H_
#include <stdint.h>
typedef uint16_t n_short;
typedef uint32_t n_long, n_time;
+
+#endif // SYSROOT_NETINET_IN_SYSTM_H_
diff --git a/arch/x64/sysroot/include/netinet/ip.h b/arch/x64/sysroot/include/netinet/ip.h
index 1c0978a..c795ef0 100644
--- a/arch/x64/sysroot/include/netinet/ip.h
+++ b/arch/x64/sysroot/include/netinet/ip.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP_H_
+#define SYSROOT_NETINET_IP_H_
#ifdef __cplusplus
extern "C" {
@@ -9,53 +10,53 @@
#include <stdint.h>
struct timestamp {
- uint8_t len;
- uint8_t ptr;
+ uint8_t len;
+ uint8_t ptr;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int flags : 4;
- unsigned int overflow : 4;
+ unsigned int flags : 4;
+ unsigned int overflow : 4;
#else
- unsigned int overflow : 4;
- unsigned int flags : 4;
+ unsigned int overflow : 4;
+ unsigned int flags : 4;
#endif
- uint32_t data[9];
+ uint32_t data[9];
};
struct iphdr {
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ihl : 4;
- unsigned int version : 4;
+ unsigned int ihl : 4;
+ unsigned int version : 4;
#else
- unsigned int version : 4;
- unsigned int ihl : 4;
+ unsigned int version : 4;
+ unsigned int ihl : 4;
#endif
- uint8_t tos;
- uint16_t tot_len;
- uint16_t id;
- uint16_t frag_off;
- uint8_t ttl;
- uint8_t protocol;
- uint16_t check;
- uint32_t saddr;
- uint32_t daddr;
+ uint8_t tos;
+ uint16_t tot_len;
+ uint16_t id;
+ uint16_t frag_off;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t check;
+ uint32_t saddr;
+ uint32_t daddr;
};
struct ip {
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ip_hl : 4;
- unsigned int ip_v : 4;
+ unsigned int ip_hl : 4;
+ unsigned int ip_v : 4;
#else
- unsigned int ip_v : 4;
- unsigned int ip_hl : 4;
+ unsigned int ip_v : 4;
+ unsigned int ip_hl : 4;
#endif
- uint8_t ip_tos;
- uint16_t ip_len;
- uint16_t ip_id;
- uint16_t ip_off;
- uint8_t ip_ttl;
- uint8_t ip_p;
- uint16_t ip_sum;
- struct in_addr ip_src, ip_dst;
+ uint8_t ip_tos;
+ uint16_t ip_len;
+ uint16_t ip_id;
+ uint16_t ip_off;
+ uint8_t ip_ttl;
+ uint8_t ip_p;
+ uint16_t ip_sum;
+ struct in_addr ip_src, ip_dst;
};
#define IP_RF 0x8000
@@ -64,17 +65,17 @@
#define IP_OFFMASK 0x1fff
struct ip_timestamp {
- uint8_t ipt_code;
- uint8_t ipt_len;
- uint8_t ipt_ptr;
+ uint8_t ipt_code;
+ uint8_t ipt_len;
+ uint8_t ipt_ptr;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int ipt_flg : 4;
- unsigned int ipt_oflw : 4;
+ unsigned int ipt_flg : 4;
+ unsigned int ipt_oflw : 4;
#else
- unsigned int ipt_oflw : 4;
- unsigned int ipt_flg : 4;
+ unsigned int ipt_oflw : 4;
+ unsigned int ipt_flg : 4;
#endif
- uint32_t data[9];
+ uint32_t data[9];
};
#define IPVERSION 4
@@ -193,3 +194,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP_H_
diff --git a/arch/x64/sysroot/include/netinet/ip6.h b/arch/x64/sysroot/include/netinet/ip6.h
index e809200..45f1c68 100644
--- a/arch/x64/sysroot/include/netinet/ip6.h
+++ b/arch/x64/sysroot/include/netinet/ip6.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP6_H_
+#define SYSROOT_NETINET_IP6_H_
#ifdef __cplusplus
extern "C" {
@@ -9,17 +10,17 @@
#include <stdint.h>
struct ip6_hdr {
- union {
- struct ip6_hdrctl {
- uint32_t ip6_un1_flow;
- uint16_t ip6_un1_plen;
- uint8_t ip6_un1_nxt;
- uint8_t ip6_un1_hlim;
- } ip6_un1;
- uint8_t ip6_un2_vfc;
- } ip6_ctlun;
- struct in6_addr ip6_src;
- struct in6_addr ip6_dst;
+ union {
+ struct ip6_hdrctl {
+ uint32_t ip6_un1_flow;
+ uint16_t ip6_un1_plen;
+ uint8_t ip6_un1_nxt;
+ uint8_t ip6_un1_hlim;
+ } ip6_un1;
+ uint8_t ip6_un2_vfc;
+ } ip6_ctlun;
+ struct in6_addr ip6_src;
+ struct in6_addr ip6_dst;
};
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
@@ -30,42 +31,42 @@
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
struct ip6_ext {
- uint8_t ip6e_nxt;
- uint8_t ip6e_len;
+ uint8_t ip6e_nxt;
+ uint8_t ip6e_len;
};
struct ip6_hbh {
- uint8_t ip6h_nxt;
- uint8_t ip6h_len;
+ uint8_t ip6h_nxt;
+ uint8_t ip6h_len;
};
struct ip6_dest {
- uint8_t ip6d_nxt;
- uint8_t ip6d_len;
+ uint8_t ip6d_nxt;
+ uint8_t ip6d_len;
};
struct ip6_rthdr {
- uint8_t ip6r_nxt;
- uint8_t ip6r_len;
- uint8_t ip6r_type;
- uint8_t ip6r_segleft;
+ uint8_t ip6r_nxt;
+ uint8_t ip6r_len;
+ uint8_t ip6r_type;
+ uint8_t ip6r_segleft;
};
struct ip6_rthdr0 {
- uint8_t ip6r0_nxt;
- uint8_t ip6r0_len;
- uint8_t ip6r0_type;
- uint8_t ip6r0_segleft;
- uint8_t ip6r0_reserved;
- uint8_t ip6r0_slmap[3];
- struct in6_addr ip6r0_addr[];
+ uint8_t ip6r0_nxt;
+ uint8_t ip6r0_len;
+ uint8_t ip6r0_type;
+ uint8_t ip6r0_segleft;
+ uint8_t ip6r0_reserved;
+ uint8_t ip6r0_slmap[3];
+ struct in6_addr ip6r0_addr[];
};
struct ip6_frag {
- uint8_t ip6f_nxt;
- uint8_t ip6f_reserved;
- uint16_t ip6f_offlg;
- uint32_t ip6f_ident;
+ uint8_t ip6f_nxt;
+ uint8_t ip6f_reserved;
+ uint16_t ip6f_offlg;
+ uint32_t ip6f_ident;
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -79,8 +80,8 @@
#endif
struct ip6_opt {
- uint8_t ip6o_type;
- uint8_t ip6o_len;
+ uint8_t ip6o_type;
+ uint8_t ip6o_len;
};
#define IP6OPT_TYPE(o) ((o)&0xc0)
@@ -99,29 +100,29 @@
#define IP6OPT_ROUTER_ALERT 0x05
struct ip6_opt_jumbo {
- uint8_t ip6oj_type;
- uint8_t ip6oj_len;
- uint8_t ip6oj_jumbo_len[4];
+ uint8_t ip6oj_type;
+ uint8_t ip6oj_len;
+ uint8_t ip6oj_jumbo_len[4];
};
#define IP6OPT_JUMBO_LEN 6
struct ip6_opt_nsap {
- uint8_t ip6on_type;
- uint8_t ip6on_len;
- uint8_t ip6on_src_nsap_len;
- uint8_t ip6on_dst_nsap_len;
+ uint8_t ip6on_type;
+ uint8_t ip6on_len;
+ uint8_t ip6on_src_nsap_len;
+ uint8_t ip6on_dst_nsap_len;
};
struct ip6_opt_tunnel {
- uint8_t ip6ot_type;
- uint8_t ip6ot_len;
- uint8_t ip6ot_encap_limit;
+ uint8_t ip6ot_type;
+ uint8_t ip6ot_len;
+ uint8_t ip6ot_encap_limit;
};
struct ip6_opt_router {
- uint8_t ip6or_type;
- uint8_t ip6or_len;
- uint8_t ip6or_value[2];
+ uint8_t ip6or_type;
+ uint8_t ip6or_len;
+ uint8_t ip6or_value[2];
};
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -137,3 +138,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP6_H_
diff --git a/arch/x64/sysroot/include/netinet/ip_icmp.h b/arch/x64/sysroot/include/netinet/ip_icmp.h
index 4c1c322..c239456 100644
--- a/arch/x64/sysroot/include/netinet/ip_icmp.h
+++ b/arch/x64/sysroot/include/netinet/ip_icmp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_IP_ICMP_H_
+#define SYSROOT_NETINET_IP_ICMP_H_
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -9,20 +10,20 @@
#endif
struct icmphdr {
- uint8_t type;
- uint8_t code;
- uint16_t checksum;
- union {
- struct {
- uint16_t id;
- uint16_t sequence;
- } echo;
- uint32_t gateway;
- struct {
- uint16_t __unused;
- uint16_t mtu;
- } frag;
- } un;
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ union {
+ struct {
+ uint16_t id;
+ uint16_t sequence;
+ } echo;
+ uint32_t gateway;
+ struct {
+ uint16_t __unused;
+ uint16_t mtu;
+ } frag;
+ } un;
};
#define ICMP_ECHOREPLY 0
@@ -67,47 +68,47 @@
#define ICMP_EXC_FRAGTIME 1
struct icmp_ra_addr {
- uint32_t ira_addr;
- uint32_t ira_preference;
+ uint32_t ira_addr;
+ uint32_t ira_preference;
};
struct icmp {
- uint8_t icmp_type;
- uint8_t icmp_code;
- uint16_t icmp_cksum;
- union {
- uint8_t ih_pptr;
- struct in_addr ih_gwaddr;
- struct ih_idseq {
- uint16_t icd_id;
- uint16_t icd_seq;
- } ih_idseq;
- uint32_t ih_void;
+ uint8_t icmp_type;
+ uint8_t icmp_code;
+ uint16_t icmp_cksum;
+ union {
+ uint8_t ih_pptr;
+ struct in_addr ih_gwaddr;
+ struct ih_idseq {
+ uint16_t icd_id;
+ uint16_t icd_seq;
+ } ih_idseq;
+ uint32_t ih_void;
- struct ih_pmtu {
- uint16_t ipm_void;
- uint16_t ipm_nextmtu;
- } ih_pmtu;
+ struct ih_pmtu {
+ uint16_t ipm_void;
+ uint16_t ipm_nextmtu;
+ } ih_pmtu;
- struct ih_rtradv {
- uint8_t irt_num_addrs;
- uint8_t irt_wpa;
- uint16_t irt_lifetime;
- } ih_rtradv;
- } icmp_hun;
- union {
- struct {
- uint32_t its_otime;
- uint32_t its_rtime;
- uint32_t its_ttime;
- } id_ts;
- struct {
- struct ip idi_ip;
- } id_ip;
- struct icmp_ra_addr id_radv;
- uint32_t id_mask;
- uint8_t id_data[1];
- } icmp_dun;
+ struct ih_rtradv {
+ uint8_t irt_num_addrs;
+ uint8_t irt_wpa;
+ uint16_t irt_lifetime;
+ } ih_rtradv;
+ } icmp_hun;
+ union {
+ struct {
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
+ } id_ts;
+ struct {
+ struct ip idi_ip;
+ } id_ip;
+ struct icmp_ra_addr id_radv;
+ uint32_t id_mask;
+ uint8_t id_data[1];
+ } icmp_dun;
};
#define icmp_pptr icmp_hun.ih_pptr
@@ -175,12 +176,14 @@
#define ICMP_PARAMPROB_OPTABSENT 1
-#define ICMP_INFOTYPE(type) \
- ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || (type) == ICMP_ROUTERADVERT || \
- (type) == ICMP_ROUTERSOLICIT || (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
- (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || (type) == ICMP_MASKREQ || \
- (type) == ICMP_MASKREPLY)
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || (type) == ICMP_ROUTERADVERT || \
+ (type) == ICMP_ROUTERSOLICIT || (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || (type) == ICMP_MASKREQ || \
+ (type) == ICMP_MASKREPLY)
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_IP_ICMP_H_
diff --git a/arch/x64/sysroot/include/netinet/tcp.h b/arch/x64/sysroot/include/netinet/tcp.h
index 9274ba5..e892dd2 100644
--- a/arch/x64/sysroot/include/netinet/tcp.h
+++ b/arch/x64/sysroot/include/netinet/tcp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_TCP_H_
+#define SYSROOT_NETINET_TCP_H_
#include <features.h>
@@ -74,62 +75,61 @@
struct tcphdr {
#ifdef _GNU_SOURCE
#ifdef __GNUC__
- __extension__
+ __extension__
#endif
- union {
- struct {
-
- uint16_t source;
- uint16_t dest;
- uint32_t seq;
- uint32_t ack_seq;
+ union {
+ struct {
+ uint16_t source;
+ uint16_t dest;
+ uint32_t seq;
+ uint32_t ack_seq;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint16_t res1 : 4;
- uint16_t doff : 4;
- uint16_t fin : 1;
- uint16_t syn : 1;
- uint16_t rst : 1;
- uint16_t psh : 1;
- uint16_t ack : 1;
- uint16_t urg : 1;
- uint16_t res2 : 2;
+ uint16_t res1 : 4;
+ uint16_t doff : 4;
+ uint16_t fin : 1;
+ uint16_t syn : 1;
+ uint16_t rst : 1;
+ uint16_t psh : 1;
+ uint16_t ack : 1;
+ uint16_t urg : 1;
+ uint16_t res2 : 2;
#else
- uint16_t doff : 4;
- uint16_t res1 : 4;
- uint16_t res2 : 2;
- uint16_t urg : 1;
- uint16_t ack : 1;
- uint16_t psh : 1;
- uint16_t rst : 1;
- uint16_t syn : 1;
- uint16_t fin : 1;
+ uint16_t doff : 4;
+ uint16_t res1 : 4;
+ uint16_t res2 : 2;
+ uint16_t urg : 1;
+ uint16_t ack : 1;
+ uint16_t psh : 1;
+ uint16_t rst : 1;
+ uint16_t syn : 1;
+ uint16_t fin : 1;
#endif
- uint16_t window;
- uint16_t check;
- uint16_t urg_ptr;
- };
- struct {
+ uint16_t window;
+ uint16_t check;
+ uint16_t urg_ptr;
+ };
+ struct {
#endif
- uint16_t th_sport;
- uint16_t th_dport;
- uint32_t th_seq;
- uint32_t th_ack;
+ uint16_t th_sport;
+ uint16_t th_dport;
+ uint32_t th_seq;
+ uint32_t th_ack;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t th_x2 : 4;
- uint8_t th_off : 4;
+ uint8_t th_x2 : 4;
+ uint8_t th_off : 4;
#else
- uint8_t th_off : 4;
- uint8_t th_x2 : 4;
+ uint8_t th_off : 4;
+ uint8_t th_x2 : 4;
#endif
- uint8_t th_flags;
- uint16_t th_win;
- uint16_t th_sum;
- uint16_t th_urp;
+ uint8_t th_flags;
+ uint16_t th_win;
+ uint16_t th_sum;
+ uint16_t th_urp;
#ifdef _GNU_SOURCE
- };
};
+ };
#endif
};
#endif
@@ -147,53 +147,55 @@
#define TCP_CA_Loss 4
struct tcp_info {
- uint8_t tcpi_state;
- uint8_t tcpi_ca_state;
- uint8_t tcpi_retransmits;
- uint8_t tcpi_probes;
- uint8_t tcpi_backoff;
- uint8_t tcpi_options;
- uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
- uint32_t tcpi_rto;
- uint32_t tcpi_ato;
- uint32_t tcpi_snd_mss;
- uint32_t tcpi_rcv_mss;
- uint32_t tcpi_unacked;
- uint32_t tcpi_sacked;
- uint32_t tcpi_lost;
- uint32_t tcpi_retrans;
- uint32_t tcpi_fackets;
- uint32_t tcpi_last_data_sent;
- uint32_t tcpi_last_ack_sent;
- uint32_t tcpi_last_data_recv;
- uint32_t tcpi_last_ack_recv;
- uint32_t tcpi_pmtu;
- uint32_t tcpi_rcv_ssthresh;
- uint32_t tcpi_rtt;
- uint32_t tcpi_rttvar;
- uint32_t tcpi_snd_ssthresh;
- uint32_t tcpi_snd_cwnd;
- uint32_t tcpi_advmss;
- uint32_t tcpi_reordering;
- uint32_t tcpi_rcv_rtt;
- uint32_t tcpi_rcv_space;
- uint32_t tcpi_total_retrans;
- uint64_t tcpi_pacing_rate;
- uint64_t tcpi_max_pacing_rate;
- uint64_t tcpi_bytes_acked;
- uint64_t tcpi_bytes_received;
- uint32_t tcpi_segs_out;
- uint32_t tcpi_segs_in;
+ uint8_t tcpi_state;
+ uint8_t tcpi_ca_state;
+ uint8_t tcpi_retransmits;
+ uint8_t tcpi_probes;
+ uint8_t tcpi_backoff;
+ uint8_t tcpi_options;
+ uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
+ uint32_t tcpi_rto;
+ uint32_t tcpi_ato;
+ uint32_t tcpi_snd_mss;
+ uint32_t tcpi_rcv_mss;
+ uint32_t tcpi_unacked;
+ uint32_t tcpi_sacked;
+ uint32_t tcpi_lost;
+ uint32_t tcpi_retrans;
+ uint32_t tcpi_fackets;
+ uint32_t tcpi_last_data_sent;
+ uint32_t tcpi_last_ack_sent;
+ uint32_t tcpi_last_data_recv;
+ uint32_t tcpi_last_ack_recv;
+ uint32_t tcpi_pmtu;
+ uint32_t tcpi_rcv_ssthresh;
+ uint32_t tcpi_rtt;
+ uint32_t tcpi_rttvar;
+ uint32_t tcpi_snd_ssthresh;
+ uint32_t tcpi_snd_cwnd;
+ uint32_t tcpi_advmss;
+ uint32_t tcpi_reordering;
+ uint32_t tcpi_rcv_rtt;
+ uint32_t tcpi_rcv_space;
+ uint32_t tcpi_total_retrans;
+ uint64_t tcpi_pacing_rate;
+ uint64_t tcpi_max_pacing_rate;
+ uint64_t tcpi_bytes_acked;
+ uint64_t tcpi_bytes_received;
+ uint32_t tcpi_segs_out;
+ uint32_t tcpi_segs_in;
};
#define TCP_MD5SIG_MAXKEYLEN 80
struct tcp_md5sig {
- struct sockaddr_storage tcpm_addr;
- uint16_t __tcpm_pad1;
- uint16_t tcpm_keylen;
- uint32_t __tcpm_pad2;
- uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
+ struct sockaddr_storage tcpm_addr;
+ uint16_t __tcpm_pad1;
+ uint16_t tcpm_keylen;
+ uint32_t __tcpm_pad2;
+ uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
};
#endif
+
+#endif // SYSROOT_NETINET_TCP_H_
diff --git a/arch/x64/sysroot/include/netinet/udp.h b/arch/x64/sysroot/include/netinet/udp.h
index ddde1c7..1a0fba7 100644
--- a/arch/x64/sysroot/include/netinet/udp.h
+++ b/arch/x64/sysroot/include/netinet/udp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NETINET_UDP_H_
+#define SYSROOT_NETINET_UDP_H_
#ifdef __cplusplus
extern "C" {
@@ -15,10 +16,10 @@
#endif
struct udphdr {
- uint16_t uh_sport;
- uint16_t uh_dport;
- uint16_t uh_ulen;
- uint16_t uh_sum;
+ uint16_t uh_sport;
+ uint16_t uh_dport;
+ uint16_t uh_ulen;
+ uint16_t uh_sum;
};
#define UDP_CORK 1
@@ -33,3 +34,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETINET_UDP_H_
diff --git a/arch/x64/sysroot/include/netpacket/packet.h b/arch/x64/sysroot/include/netpacket/packet.h
index 3e35676..3066046 100644
--- a/arch/x64/sysroot/include/netpacket/packet.h
+++ b/arch/x64/sysroot/include/netpacket/packet.h
@@ -1,21 +1,22 @@
-#pragma once
+#ifndef SYSROOT_NETPACKET_PACKET_H_
+#define SYSROOT_NETPACKET_PACKET_H_
#ifdef __cplusplus
extern "C" {
#endif
struct sockaddr_ll {
- unsigned short sll_family, sll_protocol;
- int sll_ifindex;
- unsigned short sll_hatype;
- unsigned char sll_pkttype, sll_halen;
- unsigned char sll_addr[8];
+ unsigned short sll_family, sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype, sll_halen;
+ unsigned char sll_addr[8];
};
struct packet_mreq {
- int mr_ifindex;
- unsigned short int mr_type, mr_alen;
- unsigned char mr_address[8];
+ int mr_ifindex;
+ unsigned short int mr_type, mr_alen;
+ unsigned char mr_address[8];
};
#define PACKET_HOST 0
@@ -56,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NETPACKET_PACKET_H_
diff --git a/arch/x64/sysroot/include/nl_types.h b/arch/x64/sysroot/include/nl_types.h
index 570224d..e30f86e 100644
--- a/arch/x64/sysroot/include/nl_types.h
+++ b/arch/x64/sysroot/include/nl_types.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_NL_TYPES_H_
+#define SYSROOT_NL_TYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_NL_TYPES_H_
diff --git a/arch/x64/sysroot/include/paths.h b/arch/x64/sysroot/include/paths.h
index 36b6127..0ff06aa 100644
--- a/arch/x64/sysroot/include/paths.h
+++ b/arch/x64/sysroot/include/paths.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PATHS_H_
+#define SYSROOT_PATHS_H_
#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin"
@@ -23,3 +24,5 @@
#define _PATH_VARDB "/var/lib/misc/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
+
+#endif // SYSROOT_PATHS_H_
diff --git a/arch/x64/sysroot/include/poll.h b/arch/x64/sysroot/include/poll.h
index d8b3726..4c7c800 100644
--- a/arch/x64/sysroot/include/poll.h
+++ b/arch/x64/sysroot/include/poll.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_POLL_H_
+#define SYSROOT_POLL_H_
#ifdef __cplusplus
extern "C" {
@@ -28,9 +29,9 @@
typedef unsigned long nfds_t;
struct pollfd {
- int fd;
- short events;
- short revents;
+ int fd;
+ short events;
+ short revents;
};
int poll(struct pollfd*, nfds_t, int);
@@ -46,3 +47,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_POLL_H_
diff --git a/arch/x64/sysroot/include/pthread.h b/arch/x64/sysroot/include/pthread.h
index 07576e5..d4b9f00 100644
--- a/arch/x64/sysroot/include/pthread.h
+++ b/arch/x64/sysroot/include/pthread.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PTHREAD_H_
+#define SYSROOT_PTHREAD_H_
#ifdef __cplusplus
extern "C" {
@@ -25,11 +26,11 @@
#define __NEED_pthread_once_t
#define __NEED_size_t
-#include <bits/alltypes.h>
-
#include <sched.h>
#include <time.h>
+#include <bits/alltypes.h>
+
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
@@ -54,11 +55,11 @@
#define PTHREAD_PROCESS_PRIVATE 0
#define PTHREAD_MUTEX_INITIALIZER \
- {}
+ {}
#define PTHREAD_RWLOCK_INITIALIZER \
- {}
+ {}
#define PTHREAD_COND_INITIALIZER \
- {}
+ {}
#define PTHREAD_ONCE_INIT 0
#define PTHREAD_CANCEL_ENABLE 0
@@ -147,8 +148,9 @@
int pthread_attr_getdetachstate(const pthread_attr_t*, int*);
int pthread_attr_setdetachstate(pthread_attr_t*, int);
int pthread_attr_getstack(const pthread_attr_t* __restrict, void** __restrict, size_t* __restrict);
-int pthread_attr_setstack(pthread_attr_t*, void*, size_t)
- __attribute__((__deprecated__("pthread_attr_setstack is not available in Fuchsia; perhaps pthread_attr_setstacksize and/or pthread_attr_setguardsize is sufficient for your needs?")));
+int pthread_attr_setstack(pthread_attr_t*, void*, size_t) __attribute__((__deprecated__(
+ "pthread_attr_setstack is not available in Fuchsia; perhaps pthread_attr_setstacksize and/or "
+ "pthread_attr_setguardsize is sufficient for your needs?")));
int pthread_attr_getschedparam(const pthread_attr_t* __restrict, struct sched_param* __restrict);
int pthread_attr_setschedparam(pthread_attr_t* __restrict, const struct sched_param* __restrict);
@@ -194,3 +196,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_PTHREAD_H_
diff --git a/arch/x64/sysroot/include/pty.h b/arch/x64/sysroot/include/pty.h
deleted file mode 100644
index 943a6a8..0000000
--- a/arch/x64/sysroot/include/pty.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/ioctl.h>
-#include <termios.h>
-
-int openpty(int*, int*, char*, const struct termios*, const struct winsize*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/x64/sysroot/include/pwd.h b/arch/x64/sysroot/include/pwd.h
index 1d63e72..213eefa 100644
--- a/arch/x64/sysroot/include/pwd.h
+++ b/arch/x64/sysroot/include/pwd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_PWD_H_
+#define SYSROOT_PWD_H_
#ifdef __cplusplus
extern "C" {
@@ -17,13 +18,13 @@
#include <bits/alltypes.h>
struct passwd {
- char* pw_name;
- char* pw_passwd;
- uid_t pw_uid;
- gid_t pw_gid;
- char* pw_gecos;
- char* pw_dir;
- char* pw_shell;
+ char* pw_name;
+ char* pw_passwd;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char* pw_gecos;
+ char* pw_dir;
+ char* pw_shell;
};
void setpwent(void);
@@ -43,3 +44,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_PWD_H_
diff --git a/arch/x64/sysroot/include/regex.h b/arch/x64/sysroot/include/regex.h
index 70c4613..53fac22 100644
--- a/arch/x64/sysroot/include/regex.h
+++ b/arch/x64/sysroot/include/regex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_REGEX_H_
+#define SYSROOT_REGEX_H_
#ifdef __cplusplus
extern "C" {
@@ -12,15 +13,15 @@
#include <bits/alltypes.h>
typedef struct re_pattern_buffer {
- size_t re_nsub;
- void *__opaque, *__padding[4];
- size_t __nsub2;
- char __padding2;
+ size_t re_nsub;
+ void *__opaque, *__padding[4];
+ size_t __nsub2;
+ char __padding2;
} regex_t;
typedef struct {
- regoff_t rm_so;
- regoff_t rm_eo;
+ regoff_t rm_so;
+ regoff_t rm_eo;
} regmatch_t;
#define REG_EXTENDED 1
@@ -57,3 +58,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_REGEX_H_
diff --git a/arch/x64/sysroot/include/resolv.h b/arch/x64/sysroot/include/resolv.h
index 7efcd49..a90e0e8 100644
--- a/arch/x64/sysroot/include/resolv.h
+++ b/arch/x64/sysroot/include/resolv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_RESOLV_H_
+#define SYSROOT_RESOLV_H_
#include <arpa/nameser.h>
#include <netinet/in.h>
@@ -23,41 +24,41 @@
/* unused; purely for broken apps */
typedef struct __res_state {
- int retrans;
- int retry;
- unsigned long options;
- int nscount;
- struct sockaddr_in nsaddr_list[MAXNS];
+ int retrans;
+ int retry;
+ unsigned long options;
+ int nscount;
+ struct sockaddr_in nsaddr_list[MAXNS];
#define nsaddr nsaddr_list[0]
- unsigned short id;
- char* dnsrch[MAXDNSRCH + 1];
- char defdname[256];
- unsigned long pfcode;
- unsigned ndots : 4;
- unsigned nsort : 4;
- unsigned ipv6_unavail : 1;
- unsigned unused : 23;
+ unsigned short id;
+ char* dnsrch[MAXDNSRCH + 1];
+ char defdname[256];
+ unsigned long pfcode;
+ unsigned ndots : 4;
+ unsigned nsort : 4;
+ unsigned ipv6_unavail : 1;
+ unsigned unused : 23;
+ struct {
+ struct in_addr addr;
+ uint32_t mask;
+ } sort_list[MAXRESOLVSORT];
+ void* qhook;
+ void* rhook;
+ int res_h_errno;
+ int _vcsock;
+ unsigned _flags;
+ union {
+ char pad[52];
struct {
- struct in_addr addr;
- uint32_t mask;
- } sort_list[MAXRESOLVSORT];
- void* qhook;
- void* rhook;
- int res_h_errno;
- int _vcsock;
- unsigned _flags;
- union {
- char pad[52];
- struct {
- uint16_t nscount;
- uint16_t nsmap[MAXNS];
- int nssocks[MAXNS];
- uint16_t nscount6;
- uint16_t nsinit;
- struct sockaddr_in6* nsaddrs[MAXNS];
- unsigned int _initstamp[2];
- } _ext;
- } _u;
+ uint16_t nscount;
+ uint16_t nsmap[MAXNS];
+ int nssocks[MAXNS];
+ uint16_t nscount6;
+ uint16_t nsinit;
+ struct sockaddr_in6* nsaddrs[MAXNS];
+ unsigned int _initstamp[2];
+ } _ext;
+ } _u;
} * res_state;
#define __RES 19991006
@@ -67,9 +68,9 @@
#endif
struct res_sym {
- int number;
- char* name;
- char* humanname;
+ int number;
+ char* name;
+ char* humanname;
};
#define RES_F_VC 0x00000001
@@ -138,3 +139,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_RESOLV_H_
diff --git a/arch/x64/sysroot/include/sched.h b/arch/x64/sysroot/include/sched.h
index f77dff7..ac06166 100644
--- a/arch/x64/sysroot/include/sched.h
+++ b/arch/x64/sysroot/include/sched.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SCHED_H_
+#define SYSROOT_SCHED_H_
#ifdef __cplusplus
extern "C" {
@@ -17,11 +18,11 @@
#include <bits/alltypes.h>
struct sched_param {
- int sched_priority;
- int sched_ss_low_priority;
- struct timespec sched_ss_repl_period;
- struct timespec sched_ss_init_budget;
- int sched_ss_max_repl;
+ int sched_priority;
+ int sched_ss_low_priority;
+ struct timespec sched_ss_repl_period;
+ struct timespec sched_ss_init_budget;
+ int sched_ss_max_repl;
};
int sched_get_priority_max(int);
@@ -47,28 +48,30 @@
void* calloc(size_t, size_t);
void free(void*);
-typedef struct cpu_set_t { unsigned long __bits[128 / sizeof(long)]; } cpu_set_t;
+typedef struct cpu_set_t {
+ unsigned long __bits[128 / sizeof(long)];
+} cpu_set_t;
int __sched_cpucount(size_t, const cpu_set_t*);
int sched_getcpu(void);
int sched_getaffinity(pid_t, size_t, cpu_set_t*);
int sched_setaffinity(pid_t, size_t, const cpu_set_t*);
#define __CPU_op_S(i, size, set, op) \
- ((i) / 8U >= (size) \
- ? 0 \
- : ((set)->__bits[(i) / 8 / sizeof(long)] op(1UL << ((i) % (8 * sizeof(long))))))
+ ((i) / 8U >= (size) \
+ ? 0 \
+ : ((set)->__bits[(i) / 8 / sizeof(long)] op(1UL << ((i) % (8 * sizeof(long))))))
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &= ~)
#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
-#define __CPU_op_func_S(func, op) \
- static __inline void __CPU_##func##_S(size_t __size, cpu_set_t* __dest, \
- const cpu_set_t* __src1, const cpu_set_t* __src2) { \
- size_t __i; \
- for (__i = 0; __i < __size / sizeof(long); __i++) \
- __dest->__bits[__i] = __src1->__bits[__i] op __src2->__bits[__i]; \
- }
+#define __CPU_op_func_S(func, op) \
+ static __inline void __CPU_##func##_S(size_t __size, cpu_set_t* __dest, const cpu_set_t* __src1, \
+ const cpu_set_t* __src2) { \
+ size_t __i; \
+ for (__i = 0; __i < __size / sizeof(long); __i++) \
+ __dest->__bits[__i] = __src1->__bits[__i] op __src2->__bits[__i]; \
+ }
__CPU_op_func_S(AND, &) __CPU_op_func_S(OR, |) __CPU_op_func_S(XOR, ^)
@@ -80,9 +83,9 @@
#define CPU_ZERO_S(size, set) memset(set, 0, size)
#define CPU_EQUAL_S(size, set1, set2) (!memcmp(set1, set2, size))
-#define CPU_ALLOC_SIZE(n) \
- (sizeof(long) * ((n) / (8 * sizeof(long)) + \
- ((n) % (8 * sizeof(long)) + 8 * sizeof(long) - 1) / (8 * sizeof(long))))
+#define CPU_ALLOC_SIZE(n) \
+ (sizeof(long) * ((n) / (8 * sizeof(long)) + \
+ ((n) % (8 * sizeof(long)) + 8 * sizeof(long) - 1) / (8 * sizeof(long))))
#define CPU_ALLOC(n) ((cpu_set_t*)calloc(1, CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)
@@ -103,3 +106,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SCHED_H_
diff --git a/arch/x64/sysroot/include/search.h b/arch/x64/sysroot/include/search.h
index eb50439..5348eab 100644
--- a/arch/x64/sysroot/include/search.h
+++ b/arch/x64/sysroot/include/search.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SEARCH_H_
+#define SYSROOT_SEARCH_H_
#ifdef __cplusplus
extern "C" {
@@ -9,16 +10,12 @@
#define __NEED_size_t
#include <bits/alltypes.h>
-typedef enum { FIND,
- ENTER } ACTION;
-typedef enum { preorder,
- postorder,
- endorder,
- leaf } VISIT;
+typedef enum { FIND, ENTER } ACTION;
+typedef enum { preorder, postorder, endorder, leaf } VISIT;
typedef struct entry {
- char* key;
- void* data;
+ char* key;
+ void* data;
} ENTRY;
int hcreate(size_t);
@@ -27,9 +24,9 @@
#ifdef _GNU_SOURCE
struct hsearch_data {
- struct __tab* __tab;
- unsigned int __unused1;
- unsigned int __unused2;
+ struct __tab* __tab;
+ unsigned int __unused1;
+ unsigned int __unused2;
};
int hcreate_r(size_t, struct hsearch_data*);
@@ -50,8 +47,8 @@
#ifdef _GNU_SOURCE
struct qelem {
- struct qelem *q_forw, *q_back;
- char q_data[1];
+ struct qelem *q_forw, *q_back;
+ char q_data[1];
};
void tdestroy(void*, void (*)(void*));
@@ -60,3 +57,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SEARCH_H_
diff --git a/arch/x64/sysroot/include/semaphore.h b/arch/x64/sysroot/include/semaphore.h
index e4bf7a8..d9e996e 100644
--- a/arch/x64/sysroot/include/semaphore.h
+++ b/arch/x64/sysroot/include/semaphore.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SEMAPHORE_H_
+#define SYSROOT_SEMAPHORE_H_
#ifdef __cplusplus
extern "C" {
@@ -9,10 +10,10 @@
#define __NEED_sem_t
#define __NEED_time_t
#define __NEED_struct_timespec
-#include <bits/alltypes.h>
-
#include <fcntl.h>
+#include <bits/alltypes.h>
+
#define SEM_FAILED ((sem_t*)0)
int sem_close(sem_t*);
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SEMAPHORE_H_
diff --git a/arch/x64/sysroot/include/setjmp.h b/arch/x64/sysroot/include/setjmp.h
index eaceeca..65971b7 100644
--- a/arch/x64/sysroot/include/setjmp.h
+++ b/arch/x64/sysroot/include/setjmp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SETJMP_H_
+#define SYSROOT_SETJMP_H_
#ifdef __cplusplus
extern "C" {
@@ -9,9 +10,9 @@
#include <bits/setjmp.h>
typedef struct __jmp_buf_tag {
- __jmp_buf __jb;
- unsigned long __fl;
- unsigned long __ss[128 / sizeof(long)];
+ __jmp_buf __jb;
+ unsigned long __fl;
+ unsigned long __ss[128 / sizeof(long)];
} jmp_buf[1];
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
@@ -34,3 +35,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SETJMP_H_
diff --git a/arch/x64/sysroot/include/signal.h b/arch/x64/sysroot/include/signal.h
index b26c9b0..594cf80 100644
--- a/arch/x64/sysroot/include/signal.h
+++ b/arch/x64/sysroot/include/signal.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SIGNAL_H_
+#define SYSROOT_SIGNAL_H_
#ifdef __cplusplus
extern "C" {
@@ -86,55 +87,55 @@
#define CLD_CONTINUED 6
union sigval {
- int sival_int;
- void* sival_ptr;
+ int sival_int;
+ void* sival_ptr;
};
typedef struct {
#ifdef __SI_SWAP_ERRNO_CODE
- int si_signo, si_code, si_errno;
+ int si_signo, si_code, si_errno;
#else
- int si_signo, si_errno, si_code;
+ int si_signo, si_errno, si_code;
#endif
- union {
- char __pad[128 - 2 * sizeof(int) - sizeof(long)];
+ union {
+ char __pad[128 - 2 * sizeof(int) - sizeof(long)];
+ struct {
+ union {
struct {
- union {
- struct {
- pid_t si_pid;
- uid_t si_uid;
- } __piduid;
- struct {
- int si_timerid;
- int si_overrun;
- } __timer;
- } __first;
- union {
- union sigval si_value;
- struct {
- int si_status;
- clock_t si_utime, si_stime;
- } __sigchld;
- } __second;
- } __si_common;
+ pid_t si_pid;
+ uid_t si_uid;
+ } __piduid;
struct {
- void* si_addr;
- short si_addr_lsb;
- struct {
- void* si_lower;
- void* si_upper;
- } __addr_bnd;
- } __sigfault;
+ int si_timerid;
+ int si_overrun;
+ } __timer;
+ } __first;
+ union {
+ union sigval si_value;
struct {
- long si_band;
- int si_fd;
- } __sigpoll;
- struct {
- void* si_call_addr;
- int si_syscall;
- unsigned si_arch;
- } __sigsys;
- } __si_fields;
+ int si_status;
+ clock_t si_utime, si_stime;
+ } __sigchld;
+ } __second;
+ } __si_common;
+ struct {
+ void* si_addr;
+ short si_addr_lsb;
+ struct {
+ void* si_lower;
+ void* si_upper;
+ } __addr_bnd;
+ } __sigfault;
+ struct {
+ long si_band;
+ int si_fd;
+ } __sigpoll;
+ struct {
+ void* si_call_addr;
+ int si_syscall;
+ unsigned si_arch;
+ } __sigsys;
+ } __si_fields;
} siginfo_t;
#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
@@ -157,24 +158,24 @@
#define si_arch __si_fields.__sigsys.si_arch
struct sigaction {
- union {
- void (*sa_handler)(int);
- void (*sa_sigaction)(int, siginfo_t*, void*);
- } __sa_handler;
- sigset_t sa_mask;
- int sa_flags;
- void (*sa_restorer)(void);
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t*, void*);
+ } __sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
};
#define sa_handler __sa_handler.sa_handler
#define sa_sigaction __sa_handler.sa_sigaction
struct sigevent {
- union sigval sigev_value;
- int sigev_signo;
- int sigev_notify;
- void (*sigev_notify_function)(union sigval);
- pthread_attr_t* sigev_notify_attributes;
- char __pad[56 - 3 * sizeof(long)];
+ union sigval sigev_value;
+ int sigev_signo;
+ int sigev_notify;
+ void (*sigev_notify_function)(union sigval);
+ pthread_attr_t* sigev_notify_attributes;
+ char __pad[56 - 3 * sizeof(long)];
};
#define SIGEV_SIGNAL 0
@@ -258,3 +259,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SIGNAL_H_
diff --git a/arch/x64/sysroot/include/spawn.h b/arch/x64/sysroot/include/spawn.h
index 74710cb..1c70bb2 100644
--- a/arch/x64/sysroot/include/spawn.h
+++ b/arch/x64/sysroot/include/spawn.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SPAWN_H_
+#define SYSROOT_SPAWN_H_
#ifdef __cplusplus
extern "C" {
@@ -22,16 +23,16 @@
#define POSIX_SPAWN_SETSCHEDULER 32
typedef struct {
- int __flags;
- pid_t __pgrp;
- sigset_t __def, __mask;
- int __prio, __pol, __pad[16];
+ int __flags;
+ pid_t __pgrp;
+ sigset_t __def, __mask;
+ int __prio, __pol, __pad[16];
} posix_spawnattr_t;
typedef struct {
- int __pad0[2];
- void* __actions;
- int __pad[16];
+ int __pad0[2];
+ void* __actions;
+ int __pad[16];
} posix_spawn_file_actions_t;
int posix_spawn(pid_t* __restrict, const char* __restrict, const posix_spawn_file_actions_t*,
@@ -74,3 +75,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SPAWN_H_
diff --git a/arch/x64/sysroot/include/stdio.h b/arch/x64/sysroot/include/stdio.h
index fde69be..c08aba0 100644
--- a/arch/x64/sysroot/include/stdio.h
+++ b/arch/x64/sysroot/include/stdio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STDIO_H_
+#define SYSROOT_STDIO_H_
#ifdef __cplusplus
extern "C" {
@@ -44,8 +45,8 @@
#define L_tmpnam 20
typedef union _G_fpos64_t {
- char __opaque[16];
- double __align;
+ char __opaque[16];
+ double __align;
} fpos_t;
extern FILE* const stdin;
@@ -180,3 +181,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STDIO_H_
diff --git a/arch/x64/sysroot/include/stdlib.h b/arch/x64/sysroot/include/stdlib.h
index 0c29b16..862c83f 100644
--- a/arch/x64/sysroot/include/stdlib.h
+++ b/arch/x64/sysroot/include/stdlib.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_STDLIB_H_
+#define SYSROOT_STDLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -53,9 +55,15 @@
long labs(long);
long long llabs(long long);
-typedef struct { int quot, rem; } div_t;
-typedef struct { long quot, rem; } ldiv_t;
-typedef struct { long long quot, rem; } lldiv_t;
+typedef struct {
+ int quot, rem;
+} div_t;
+typedef struct {
+ long quot, rem;
+} ldiv_t;
+typedef struct {
+ long long quot, rem;
+} lldiv_t;
div_t div(int, int);
ldiv_t ldiv(long, long);
@@ -110,7 +118,6 @@
int grantpt(int);
int unlockpt(int);
char* ptsname(int);
-char* l64a(long);
long a64l(const char*);
void setkey(const char*);
double drand48(void);
@@ -146,3 +153,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STDLIB_H_
diff --git a/arch/x64/sysroot/include/stdnoreturn.h b/arch/x64/sysroot/include/stdnoreturn.h
deleted file mode 100644
index 574bcca..0000000
--- a/arch/x64/sysroot/include/stdnoreturn.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#ifndef __cplusplus
-#include <features.h>
-#define noreturn _Noreturn
-#endif
diff --git a/arch/x64/sysroot/include/string.h b/arch/x64/sysroot/include/string.h
index d7ea6bb..0265b57 100644
--- a/arch/x64/sysroot/include/string.h
+++ b/arch/x64/sysroot/include/string.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_STRING_H_
+#define SYSROOT_STRING_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -84,3 +86,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STRING_H_
diff --git a/arch/x64/sysroot/include/strings.h b/arch/x64/sysroot/include/strings.h
index 343f31a..eb703d1 100644
--- a/arch/x64/sysroot/include/strings.h
+++ b/arch/x64/sysroot/include/strings.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STRINGS_H_
+#define SYSROOT_STRINGS_H_
#ifdef __cplusplus
extern "C" {
@@ -33,3 +34,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STRINGS_H_
diff --git a/arch/x64/sysroot/include/stropts.h b/arch/x64/sysroot/include/stropts.h
index c2e6b7f..92eb968 100644
--- a/arch/x64/sysroot/include/stropts.h
+++ b/arch/x64/sysroot/include/stropts.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_STROPTS_H_
+#define SYSROOT_STROPTS_H_
#ifdef __cplusplus
extern "C" {
@@ -81,51 +82,51 @@
#define MOREDATA 2
struct bandinfo {
- unsigned char bi_pri;
- int bi_flag;
+ unsigned char bi_pri;
+ int bi_flag;
};
struct strbuf {
- int maxlen;
- int len;
- char* buf;
+ int maxlen;
+ int len;
+ char* buf;
};
struct strpeek {
- struct strbuf ctlbuf;
- struct strbuf databuf;
- unsigned flags;
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
};
struct strfdinsert {
- struct strbuf ctlbuf;
- struct strbuf databuf;
- unsigned flags;
- int fildes;
- int offset;
+ struct strbuf ctlbuf;
+ struct strbuf databuf;
+ unsigned flags;
+ int fildes;
+ int offset;
};
struct strioctl {
- int ic_cmd;
- int ic_timout;
- int ic_len;
- char* ic_dp;
+ int ic_cmd;
+ int ic_timout;
+ int ic_len;
+ char* ic_dp;
};
struct strrecvfd {
- int fd;
- int uid;
- int gid;
- char __fill[8];
+ int fd;
+ int uid;
+ int gid;
+ char __fill[8];
};
struct str_mlist {
- char l_name[FMNAMESZ + 1];
+ char l_name[FMNAMESZ + 1];
};
struct str_list {
- int sl_nmods;
- struct str_mlist* sl_modlist;
+ int sl_nmods;
+ struct str_mlist* sl_modlist;
};
int isastream(int);
@@ -134,3 +135,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_STROPTS_H_
diff --git a/arch/x64/sysroot/include/sys/acct.h b/arch/x64/sysroot/include/sys/acct.h
index be32528..8561ad0 100644
--- a/arch/x64/sysroot/include/sys/acct.h
+++ b/arch/x64/sysroot/include/sys/acct.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_ACCT_H_
+#define SYSROOT_SYS_ACCT_H_
#ifdef __cplusplus
extern "C" {
@@ -14,45 +15,45 @@
typedef uint16_t comp_t;
struct acct {
- char ac_flag;
- uint16_t ac_uid;
- uint16_t ac_gid;
- uint16_t ac_tty;
- uint32_t ac_btime;
- comp_t ac_utime;
- comp_t ac_stime;
- comp_t ac_etime;
- comp_t ac_mem;
- comp_t ac_io;
- comp_t ac_rw;
- comp_t ac_minflt;
- comp_t ac_majflt;
- comp_t ac_swaps;
- uint32_t ac_exitcode;
- char ac_comm[ACCT_COMM + 1];
- char ac_pad[10];
+ char ac_flag;
+ uint16_t ac_uid;
+ uint16_t ac_gid;
+ uint16_t ac_tty;
+ uint32_t ac_btime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_etime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ uint32_t ac_exitcode;
+ char ac_comm[ACCT_COMM + 1];
+ char ac_pad[10];
};
struct acct_v3 {
- char ac_flag;
- char ac_version;
- uint16_t ac_tty;
- uint32_t ac_exitcode;
- uint32_t ac_uid;
- uint32_t ac_gid;
- uint32_t ac_pid;
- uint32_t ac_ppid;
- uint32_t ac_btime;
- float ac_etime;
- comp_t ac_utime;
- comp_t ac_stime;
- comp_t ac_mem;
- comp_t ac_io;
- comp_t ac_rw;
- comp_t ac_minflt;
- comp_t ac_majflt;
- comp_t ac_swaps;
- char ac_comm[ACCT_COMM];
+ char ac_flag;
+ char ac_version;
+ uint16_t ac_tty;
+ uint32_t ac_exitcode;
+ uint32_t ac_uid;
+ uint32_t ac_gid;
+ uint32_t ac_pid;
+ uint32_t ac_ppid;
+ uint32_t ac_btime;
+ float ac_etime;
+ comp_t ac_utime;
+ comp_t ac_stime;
+ comp_t ac_mem;
+ comp_t ac_io;
+ comp_t ac_rw;
+ comp_t ac_minflt;
+ comp_t ac_majflt;
+ comp_t ac_swaps;
+ char ac_comm[ACCT_COMM];
};
#define AFORK 1
@@ -67,3 +68,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_ACCT_H_
diff --git a/arch/x64/sysroot/include/sys/auxv.h b/arch/x64/sysroot/include/sys/auxv.h
index 72d5de9..61ddea0 100644
--- a/arch/x64/sysroot/include/sys/auxv.h
+++ b/arch/x64/sysroot/include/sys/auxv.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_AUXV_H_
+#define SYSROOT_SYS_AUXV_H_
#ifdef __cplusplus
extern "C" {
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_AUXV_H_
diff --git a/arch/x64/sysroot/include/sys/eventfd.h b/arch/x64/sysroot/include/sys/eventfd.h
index c22369e..4259bac 100644
--- a/arch/x64/sysroot/include/sys/eventfd.h
+++ b/arch/x64/sysroot/include/sys/eventfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_EVENTFD_H_
+#define SYSROOT_SYS_EVENTFD_H_
#ifdef __cplusplus
extern "C" {
@@ -20,3 +21,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_EVENTFD_H_
diff --git a/arch/x64/sysroot/include/sys/file.h b/arch/x64/sysroot/include/sys/file.h
index c32fcb8..fe17290 100644
--- a/arch/x64/sysroot/include/sys/file.h
+++ b/arch/x64/sysroot/include/sys/file.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_FILE_H_
+#define SYSROOT_SYS_FILE_H_
#ifdef __cplusplus
extern "C" {
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_FILE_H_
diff --git a/arch/x64/sysroot/include/sys/fsuid.h b/arch/x64/sysroot/include/sys/fsuid.h
index 29ea02b..a9f654c 100644
--- a/arch/x64/sysroot/include/sys/fsuid.h
+++ b/arch/x64/sysroot/include/sys/fsuid.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_FSUID_H_
+#define SYSROOT_SYS_FSUID_H_
#ifdef __cplusplus
extern "C" {
@@ -15,3 +16,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_FSUID_H_
diff --git a/arch/x64/sysroot/include/sys/io.h b/arch/x64/sysroot/include/sys/io.h
index f5013a2..89617e5 100644
--- a/arch/x64/sysroot/include/sys/io.h
+++ b/arch/x64/sysroot/include/sys/io.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IO_H_
+#define SYSROOT_SYS_IO_H_
#ifdef __cplusplus
extern "C" {
@@ -14,3 +15,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IO_H_
diff --git a/arch/x64/sysroot/include/sys/ioctl.h b/arch/x64/sysroot/include/sys/ioctl.h
index c782d2e..ad22a3b 100644
--- a/arch/x64/sysroot/include/sys/ioctl.h
+++ b/arch/x64/sysroot/include/sys/ioctl.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IOCTL_H_
+#define SYSROOT_SYS_IOCTL_H_
#ifdef __cplusplus
extern "C" {
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IOCTL_H_
diff --git a/arch/x64/sysroot/include/sys/ipc.h b/arch/x64/sysroot/include/sys/ipc.h
index a3a380c..5d019f4 100644
--- a/arch/x64/sysroot/include/sys/ipc.h
+++ b/arch/x64/sysroot/include/sys/ipc.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_IPC_H_
+#define SYSROOT_SYS_IPC_H_
#ifdef __cplusplus
extern "C" {
@@ -39,3 +40,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_IPC_H_
diff --git a/arch/x64/sysroot/include/sys/klog.h b/arch/x64/sysroot/include/sys/klog.h
index ccde5e8..b182302 100644
--- a/arch/x64/sysroot/include/sys/klog.h
+++ b/arch/x64/sysroot/include/sys/klog.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_KLOG_H_
+#define SYSROOT_SYS_KLOG_H_
#ifdef __cplusplus
extern "C" {
@@ -9,3 +10,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_KLOG_H_
diff --git a/arch/x64/sysroot/include/sys/mman.h b/arch/x64/sysroot/include/sys/mman.h
index c5ff3bf..7a913ae 100644
--- a/arch/x64/sysroot/include/sys/mman.h
+++ b/arch/x64/sysroot/include/sys/mman.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MMAN_H_
+#define SYSROOT_SYS_MMAN_H_
#ifdef __cplusplus
extern "C" {
@@ -29,6 +30,7 @@
#define MAP_NONBLOCK 0x10000
#define MAP_STACK 0x20000
#define MAP_HUGETLB 0x40000
+#define MAP_JIT 0x80000
#define MAP_FILE 0
#define PROT_NONE 0
@@ -96,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MMAN_H_
diff --git a/arch/x64/sysroot/include/sys/mount.h b/arch/x64/sysroot/include/sys/mount.h
index 9d3394b..53181ea 100644
--- a/arch/x64/sysroot/include/sys/mount.h
+++ b/arch/x64/sysroot/include/sys/mount.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MOUNT_H_
+#define SYSROOT_SYS_MOUNT_H_
#ifdef __cplusplus
extern "C" {
@@ -68,3 +69,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MOUNT_H_
diff --git a/arch/x64/sysroot/include/sys/msg.h b/arch/x64/sysroot/include/sys/msg.h
index 6d08dad..be0114b 100644
--- a/arch/x64/sysroot/include/sys/msg.h
+++ b/arch/x64/sysroot/include/sys/msg.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_MSG_H_
+#define SYSROOT_SYS_MSG_H_
#ifdef __cplusplus
extern "C" {
@@ -28,8 +29,8 @@
#define MSG_INFO 12
struct msginfo {
- int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
- unsigned short msgseg;
+ int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
+ unsigned short msgseg;
};
int msgctl(int, int, struct msqid_ds*);
@@ -39,11 +40,13 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
struct msgbuf {
- long mtype;
- char mtext[1];
+ long mtype;
+ char mtext[1];
};
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_MSG_H_
diff --git a/arch/x64/sysroot/include/sys/mtio.h b/arch/x64/sysroot/include/sys/mtio.h
index 2f4cf9a..3d9f753 100644
--- a/arch/x64/sysroot/include/sys/mtio.h
+++ b/arch/x64/sysroot/include/sys/mtio.h
@@ -1,11 +1,12 @@
-#pragma once
+#ifndef SYSROOT_SYS_MTIO_H_
+#define SYSROOT_SYS_MTIO_H_
#include <sys/ioctl.h>
#include <sys/types.h>
struct mtop {
- short mt_op;
- int mt_count;
+ short mt_op;
+ int mt_count;
};
#define _IOT_mtop _IOT(_IOTS(short), 1, _IOTS(int), 1, 0, 0)
@@ -47,13 +48,13 @@
#define MTMKPART 34
struct mtget {
- long mt_type;
- long mt_resid;
- long mt_dsreg;
- long mt_gstat;
- long mt_erreg;
- int mt_fileno;
- int mt_blkno;
+ long mt_type;
+ long mt_resid;
+ long mt_dsreg;
+ long mt_gstat;
+ long mt_erreg;
+ int mt_fileno;
+ int mt_blkno;
};
#define MT_ISUNKNOWN 0x01
@@ -78,53 +79,51 @@
#define MT_ISFTAPE_FLAG 0x800000
struct mt_tape_info {
- long t_type;
- char* t_name;
+ long t_type;
+ char* t_name;
};
#define MT_TAPE_INFO \
- { \
- {MT_ISUNKNOWN, "Unknown type of tape device"}, \
- {MT_ISQIC02, "Generic QIC-02 tape streamer"}, {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
- {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, {MT_ISCMSJ500, "CMS Jumbo 500"}, \
- {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
- {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
- {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
- {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
- {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
- {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
- {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
- {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
- {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
- {MT_ISSCSI2, "Generic SCSI-2 tape"}, { \
- 0, 0 \
- } \
- }
+ { \
+ {MT_ISUNKNOWN, "Unknown type of tape device"}, {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
+ {MT_ISWT5150, "Wangtek 5150, QIC-150"}, {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
+ {MT_ISCMSJ500, "CMS Jumbo 500"}, {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
+ {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
+ {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
+ {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
+ {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
+ {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
+ {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
+ {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
+ {MT_ISSCSI2, "Generic SCSI-2 tape"}, { \
+ 0, 0 \
+ } \
+ }
struct mtpos {
- long mt_blkno;
+ long mt_blkno;
};
struct mtconfiginfo {
- long mt_type;
- long ifc_type;
- unsigned short irqnr;
- unsigned short dmanr;
- unsigned short port;
- unsigned long debug;
- unsigned have_dens : 1;
- unsigned have_bsf : 1;
- unsigned have_fsr : 1;
- unsigned have_bsr : 1;
- unsigned have_eod : 1;
- unsigned have_seek : 1;
- unsigned have_tell : 1;
- unsigned have_ras1 : 1;
- unsigned have_ras2 : 1;
- unsigned have_ras3 : 1;
- unsigned have_qfa : 1;
- unsigned pad1 : 5;
- char reserved[10];
+ long mt_type;
+ long ifc_type;
+ unsigned short irqnr;
+ unsigned short dmanr;
+ unsigned short port;
+ unsigned long debug;
+ unsigned have_dens : 1;
+ unsigned have_bsf : 1;
+ unsigned have_fsr : 1;
+ unsigned have_bsr : 1;
+ unsigned have_eod : 1;
+ unsigned have_seek : 1;
+ unsigned have_tell : 1;
+ unsigned have_ras1 : 1;
+ unsigned have_ras2 : 1;
+ unsigned have_ras3 : 1;
+ unsigned have_qfa : 1;
+ unsigned pad1 : 5;
+ char reserved[10];
};
#define MTIOCTOP _IOW('m', 1, struct mtop)
@@ -180,3 +179,5 @@
#ifndef DEFTAPE
#define DEFTAPE "/dev/tape"
#endif
+
+#endif // SYSROOT_SYS_MTIO_H_
diff --git a/arch/x64/sysroot/include/sys/param.h b/arch/x64/sysroot/include/sys/param.h
index 64989a4..301bba7 100644
--- a/arch/x64/sysroot/include/sys/param.h
+++ b/arch/x64/sysroot/include/sys/param.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_PARAM_H_
+#define SYSROOT_SYS_PARAM_H_
#define MAXSYMLINKS 20
#define MAXHOSTNAMELEN 64
@@ -29,3 +30,5 @@
#include <endian.h>
#include <limits.h>
+
+#endif // SYSROOT_SYS_PARAM_H_
diff --git a/arch/x64/sysroot/include/sys/personality.h b/arch/x64/sysroot/include/sys/personality.h
index 3da0e20..b32d1eb 100644
--- a/arch/x64/sysroot/include/sys/personality.h
+++ b/arch/x64/sysroot/include/sys/personality.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_PERSONALITY_H_
+#define SYSROOT_SYS_PERSONALITY_H_
#ifdef __cplusplus
extern "C" {
@@ -42,3 +43,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_PERSONALITY_H_
diff --git a/arch/x64/sysroot/include/sys/quota.h b/arch/x64/sysroot/include/sys/quota.h
index ae2e194..aec5dc9 100644
--- a/arch/x64/sysroot/include/sys/quota.h
+++ b/arch/x64/sysroot/include/sys/quota.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_QUOTA_H_
+#define SYSROOT_SYS_QUOTA_H_
#ifdef __cplusplus
extern "C" {
@@ -57,15 +58,15 @@
#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
struct dqblk {
- uint64_t dqb_bhardlimit;
- uint64_t dqb_bsoftlimit;
- uint64_t dqb_curspace;
- uint64_t dqb_ihardlimit;
- uint64_t dqb_isoftlimit;
- uint64_t dqb_curinodes;
- uint64_t dqb_btime;
- uint64_t dqb_itime;
- uint32_t dqb_valid;
+ uint64_t dqb_bhardlimit;
+ uint64_t dqb_bsoftlimit;
+ uint64_t dqb_curspace;
+ uint64_t dqb_ihardlimit;
+ uint64_t dqb_isoftlimit;
+ uint64_t dqb_curinodes;
+ uint64_t dqb_btime;
+ uint64_t dqb_itime;
+ uint32_t dqb_valid;
};
#define dq_bhardlimit dq_dqb.dqb_bhardlimit
@@ -86,10 +87,10 @@
#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
struct dqinfo {
- uint64_t dqi_bgrace;
- uint64_t dqi_igrace;
- uint32_t dqi_flags;
- uint32_t dqi_valid;
+ uint64_t dqi_bgrace;
+ uint64_t dqi_igrace;
+ uint32_t dqi_flags;
+ uint32_t dqi_valid;
};
int quotactl(int, const char*, int, char*);
@@ -97,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_QUOTA_H_
diff --git a/arch/x64/sysroot/include/sys/random.h b/arch/x64/sysroot/include/sys/random.h
index 080c3b4..258201d 100644
--- a/arch/x64/sysroot/include/sys/random.h
+++ b/arch/x64/sysroot/include/sys/random.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_RANDOM_H_
+#define SYSROOT_SYS_RANDOM_H_
#include <stddef.h>
@@ -11,3 +12,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_RANDOM_H_
diff --git a/arch/x64/sysroot/include/sys/reboot.h b/arch/x64/sysroot/include/sys/reboot.h
index f28375d..a83629c 100644
--- a/arch/x64/sysroot/include/sys/reboot.h
+++ b/arch/x64/sysroot/include/sys/reboot.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_REBOOT_H_
+#define SYSROOT_SYS_REBOOT_H_
#ifdef __cplusplus
extern "C" {
@@ -17,3 +18,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_REBOOT_H_
diff --git a/arch/x64/sysroot/include/sys/reg.h b/arch/x64/sysroot/include/sys/reg.h
index 22a9caa..0f37ffe 100644
--- a/arch/x64/sysroot/include/sys/reg.h
+++ b/arch/x64/sysroot/include/sys/reg.h
@@ -1,6 +1,9 @@
-#pragma once
+#ifndef SYSROOT_SYS_REG_H_
+#define SYSROOT_SYS_REG_H_
#include <limits.h>
#include <unistd.h>
#include <bits/reg.h>
+
+#endif // SYSROOT_SYS_REG_H_
diff --git a/arch/x64/sysroot/include/sys/select.h b/arch/x64/sysroot/include/sys/select.h
index 25197d8..5d4fd7d 100644
--- a/arch/x64/sysroot/include/sys/select.h
+++ b/arch/x64/sysroot/include/sys/select.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SELECT_H_
+#define SYSROOT_SYS_SELECT_H_
#ifdef __cplusplus
extern "C" {
@@ -19,21 +20,23 @@
typedef unsigned long fd_mask;
-typedef struct { unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)]; } fd_set;
+typedef struct {
+ unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
+} fd_set;
-#define FD_ZERO(s) \
- do { \
- int __i; \
- unsigned long* __b = (s)->fds_bits; \
- for (__i = sizeof(fd_set) / sizeof(long); __i; __i--) \
- *__b++ = 0; \
- } while (0)
+#define FD_ZERO(s) \
+ do { \
+ int __i; \
+ unsigned long* __b = (s)->fds_bits; \
+ for (__i = sizeof(fd_set) / sizeof(long); __i; __i--) \
+ *__b++ = 0; \
+ } while (0)
#define FD_SET(d, s) \
- ((s)->fds_bits[(d) / (8 * sizeof(long))] |= (1UL << ((d) % (8 * sizeof(long)))))
+ ((s)->fds_bits[(d) / (8 * sizeof(long))] |= (1UL << ((d) % (8 * sizeof(long)))))
#define FD_CLR(d, s) \
- ((s)->fds_bits[(d) / (8 * sizeof(long))] &= ~(1UL << ((d) % (8 * sizeof(long)))))
+ ((s)->fds_bits[(d) / (8 * sizeof(long))] &= ~(1UL << ((d) % (8 * sizeof(long)))))
#define FD_ISSET(d, s) \
- !!((s)->fds_bits[(d) / (8 * sizeof(long))] & (1UL << ((d) % (8 * sizeof(long)))))
+ !!((s)->fds_bits[(d) / (8 * sizeof(long))] & (1UL << ((d) % (8 * sizeof(long)))))
int select(int, fd_set* __restrict, fd_set* __restrict, fd_set* __restrict,
struct timeval* __restrict);
@@ -47,3 +50,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SELECT_H_
diff --git a/arch/x64/sysroot/include/sys/sem.h b/arch/x64/sysroot/include/sys/sem.h
index 864161f..a4330af 100644
--- a/arch/x64/sysroot/include/sys/sem.h
+++ b/arch/x64/sysroot/include/sys/sem.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SEM_H_
+#define SYSROOT_SYS_SEM_H_
#ifdef __cplusplus
extern "C" {
@@ -12,10 +13,10 @@
#ifdef _GNU_SOURCE
#define __NEED_struct_timespec
#endif
-#include <bits/alltypes.h>
-
#include <sys/ipc.h>
+#include <bits/alltypes.h>
+
#define SEM_UNDO 0x1000
#define GETPID 11
#define GETVAL 12
@@ -35,22 +36,22 @@
#define SEM_INFO 19
struct seminfo {
- int semmap;
- int semmni;
- int semmns;
- int semmnu;
- int semmsl;
- int semopm;
- int semume;
- int semusz;
- int semvzx;
- int semaem;
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvzx;
+ int semaem;
};
struct sembuf {
- unsigned short sem_num;
- short sem_op;
- short sem_flg;
+ unsigned short sem_num;
+ short sem_op;
+ short sem_flg;
};
int semctl(int, int, int, ...);
@@ -64,3 +65,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SEM_H_
diff --git a/arch/x64/sysroot/include/sys/sendfile.h b/arch/x64/sysroot/include/sys/sendfile.h
deleted file mode 100644
index 1c94a6b..0000000
--- a/arch/x64/sysroot/include/sys/sendfile.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <features.h>
-#include <unistd.h>
-
-ssize_t sendfile(int, int, off_t*, size_t);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/arch/x64/sysroot/include/sys/shm.h b/arch/x64/sysroot/include/sys/shm.h
index b4780d6..55b4389 100644
--- a/arch/x64/sysroot/include/sys/shm.h
+++ b/arch/x64/sysroot/include/sys/shm.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SHM_H_
+#define SYSROOT_SYS_SHM_H_
#ifdef __cplusplus
extern "C" {
@@ -10,10 +11,10 @@
#define __NEED_size_t
#define __NEED_pid_t
-#include <bits/alltypes.h>
-
#include <sys/ipc.h>
+#include <bits/alltypes.h>
+
#ifdef _GNU_SOURCE
#define __used_ids used_ids
#define __swap_attempts swap_attempts
@@ -49,3 +50,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SHM_H_
diff --git a/arch/x64/sysroot/include/sys/signalfd.h b/arch/x64/sysroot/include/sys/signalfd.h
index 832cc78..46a5489 100644
--- a/arch/x64/sysroot/include/sys/signalfd.h
+++ b/arch/x64/sysroot/include/sys/signalfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SIGNALFD_H_
+#define SYSROOT_SYS_SIGNALFD_H_
#ifdef __cplusplus
extern "C" {
@@ -17,26 +18,28 @@
int signalfd(int, const sigset_t*, int);
struct signalfd_siginfo {
- uint32_t ssi_signo;
- int32_t ssi_errno;
- int32_t ssi_code;
- uint32_t ssi_pid;
- uint32_t ssi_uid;
- int32_t ssi_fd;
- uint32_t ssi_tid;
- uint32_t ssi_band;
- uint32_t ssi_overrun;
- uint32_t ssi_trapno;
- int32_t ssi_status;
- int32_t ssi_int;
- uint64_t ssi_ptr;
- uint64_t ssi_utime;
- uint64_t ssi_stime;
- uint64_t ssi_addr;
- uint16_t ssi_addr_lsb;
- uint8_t pad[128 - 12 * 4 - 4 * 8 - 2];
+ uint32_t ssi_signo;
+ int32_t ssi_errno;
+ int32_t ssi_code;
+ uint32_t ssi_pid;
+ uint32_t ssi_uid;
+ int32_t ssi_fd;
+ uint32_t ssi_tid;
+ uint32_t ssi_band;
+ uint32_t ssi_overrun;
+ uint32_t ssi_trapno;
+ int32_t ssi_status;
+ int32_t ssi_int;
+ uint64_t ssi_ptr;
+ uint64_t ssi_utime;
+ uint64_t ssi_stime;
+ uint64_t ssi_addr;
+ uint16_t ssi_addr_lsb;
+ uint8_t pad[128 - 12 * 4 - 4 * 8 - 2];
};
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SIGNALFD_H_
diff --git a/arch/x64/sysroot/include/sys/socket.h b/arch/x64/sysroot/include/sys/socket.h
index 10167be..7f68e6e 100644
--- a/arch/x64/sysroot/include/sys/socket.h
+++ b/arch/x64/sysroot/include/sys/socket.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SOCKET_H_
+#define SYSROOT_SYS_SOCKET_H_
#ifdef __cplusplus
extern "C" {
@@ -16,19 +17,18 @@
#define __NEED_struct_iovec
#include <bits/alltypes.h>
-
#include <bits/socket.h>
#ifdef _GNU_SOURCE
struct ucred {
- pid_t pid;
- uid_t uid;
- gid_t gid;
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
};
struct mmsghdr {
- struct msghdr msg_hdr;
- unsigned int msg_len;
+ struct msghdr msg_hdr;
+ unsigned int msg_len;
};
struct timespec;
@@ -38,8 +38,8 @@
#endif
struct linger {
- int l_onoff;
- int l_linger;
+ int l_onoff;
+ int l_linger;
};
#define SHUT_RD 0
@@ -260,16 +260,15 @@
#define __MHDR_END(mhdr) ((unsigned char*)(mhdr)->msg_control + (mhdr)->msg_controllen)
#define CMSG_DATA(cmsg) ((unsigned char*)(((struct cmsghdr*)(cmsg)) + 1))
-#define CMSG_NXTHDR(mhdr, cmsg) \
- ((cmsg)->cmsg_len < sizeof(struct cmsghdr) \
- ? (struct cmsghdr*)0 \
- : (__CMSG_NEXT(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) \
- ? (struct cmsghdr*)0 \
- : ((struct cmsghdr*)__CMSG_NEXT(cmsg))))
-#define CMSG_FIRSTHDR(mhdr) \
- ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \
- ? (struct cmsghdr*)(mhdr)->msg_control \
- : (struct cmsghdr*)0)
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ ((cmsg)->cmsg_len < sizeof(struct cmsghdr) \
+ ? (struct cmsghdr*)0 \
+ : (__CMSG_NEXT(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) \
+ ? (struct cmsghdr*)0 \
+ : ((struct cmsghdr*)__CMSG_NEXT(cmsg))))
+#define CMSG_FIRSTHDR(mhdr) \
+ ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? (struct cmsghdr*)(mhdr)->msg_control \
+ : (struct cmsghdr*)0)
#define CMSG_ALIGN(len) (((len) + sizeof(size_t) - 1) & (size_t) ~(sizeof(size_t) - 1))
#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
@@ -279,14 +278,14 @@
#define SCM_CREDENTIALS 0x02
struct sockaddr {
- sa_family_t sa_family;
- char sa_data[14];
+ sa_family_t sa_family;
+ char sa_data[14];
};
struct sockaddr_storage {
- sa_family_t ss_family;
- unsigned long __ss_align;
- char __ss_padding[128 - 2 * sizeof(unsigned long)];
+ sa_family_t ss_family;
+ unsigned long __ss_align;
+ char __ss_padding[128 - 2 * sizeof(unsigned long)];
};
int socket(int, int, int);
@@ -319,3 +318,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SOCKET_H_
diff --git a/arch/x64/sysroot/include/sys/stat.h b/arch/x64/sysroot/include/sys/stat.h
index 2be2ff5..d58e26c 100644
--- a/arch/x64/sysroot/include/sys/stat.h
+++ b/arch/x64/sysroot/include/sys/stat.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_STAT_H_
+#define SYSROOT_SYS_STAT_H_
#ifdef __cplusplus
extern "C" {
@@ -19,7 +20,6 @@
#define __NEED_struct_timespec
#include <bits/alltypes.h>
-
#include <bits/stat.h>
#define st_atime st_atim.tv_sec
@@ -98,3 +98,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STAT_H_
diff --git a/arch/x64/sysroot/include/sys/statfs.h b/arch/x64/sysroot/include/sys/statfs.h
index c2a3d41..1459181 100644
--- a/arch/x64/sysroot/include/sys/statfs.h
+++ b/arch/x64/sysroot/include/sys/statfs.h
@@ -1,14 +1,16 @@
-#pragma once
+#ifndef SYSROOT_SYS_STATFS_H_
+#define SYSROOT_SYS_STATFS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <sys/statvfs.h>
-typedef struct __fsid_t { int __val[2]; } fsid_t;
+typedef struct __fsid_t {
+ int __val[2];
+} fsid_t;
#include <bits/statfs.h>
@@ -18,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STATFS_H_
diff --git a/arch/x64/sysroot/include/sys/statvfs.h b/arch/x64/sysroot/include/sys/statvfs.h
index 6031e66..0423246 100644
--- a/arch/x64/sysroot/include/sys/statvfs.h
+++ b/arch/x64/sysroot/include/sys/statvfs.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_STATVFS_H_
+#define SYSROOT_SYS_STATVFS_H_
#ifdef __cplusplus
extern "C" {
@@ -8,23 +9,23 @@
#define __NEED_fsblkcnt_t
#define __NEED_fsfilcnt_t
-#include <bits/alltypes.h>
-
#include <endian.h>
+#include <bits/alltypes.h>
+
struct statvfs {
- unsigned long f_bsize, f_frsize;
- fsblkcnt_t f_blocks, f_bfree, f_bavail;
- fsfilcnt_t f_files, f_ffree, f_favail;
+ unsigned long f_bsize, f_frsize;
+ fsblkcnt_t f_blocks, f_bfree, f_bavail;
+ fsfilcnt_t f_files, f_ffree, f_favail;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned long f_fsid;
- unsigned : 8 * (2 * sizeof(int) - sizeof(long));
+ unsigned long f_fsid;
+ unsigned : 8 * (2 * sizeof(int) - sizeof(long));
#else
- unsigned : 8 * (2 * sizeof(int) - sizeof(long));
- unsigned long f_fsid;
+ unsigned : 8 * (2 * sizeof(int) - sizeof(long));
+ unsigned long f_fsid;
#endif
- unsigned long f_flag, f_namemax;
- int __reserved[6];
+ unsigned long f_flag, f_namemax;
+ int __reserved[6];
};
int statvfs(const char* __restrict, struct statvfs* __restrict);
@@ -45,3 +46,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_STATVFS_H_
diff --git a/arch/x64/sysroot/include/sys/swap.h b/arch/x64/sysroot/include/sys/swap.h
index e9d516d..6420606 100644
--- a/arch/x64/sysroot/include/sys/swap.h
+++ b/arch/x64/sysroot/include/sys/swap.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_SWAP_H_
+#define SYSROOT_SYS_SWAP_H_
#ifdef __cplusplus
extern "C" {
@@ -15,3 +16,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_SWAP_H_
diff --git a/arch/x64/sysroot/include/sys/time.h b/arch/x64/sysroot/include/sys/time.h
index 81c410a..a9476c7 100644
--- a/arch/x64/sysroot/include/sys/time.h
+++ b/arch/x64/sysroot/include/sys/time.h
@@ -1,11 +1,11 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIME_H_
+#define SYSROOT_SYS_TIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <sys/select.h>
int gettimeofday(struct timeval* __restrict, void* __restrict);
@@ -17,8 +17,8 @@
#define ITIMER_PROF 2
struct itimerval {
- struct timeval it_interval;
- struct timeval it_value;
+ struct timeval it_interval;
+ struct timeval it_value;
};
int getitimer(int, struct itimerval*);
@@ -29,8 +29,8 @@
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
+ int tz_minuteswest;
+ int tz_dsttime;
};
int futimes(int, const struct timeval[2]);
int futimesat(int, const char*, const struct timeval[2]);
@@ -40,24 +40,26 @@
#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
#define timercmp(s, t, op) \
- ((s)->tv_sec == (t)->tv_sec ? (s)->tv_usec op(t)->tv_usec : (s)->tv_sec op(t)->tv_sec)
-#define timeradd(s, t, a) \
- (void)((a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
- ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
- ((a)->tv_usec -= 1000000, (a)->tv_sec++))
-#define timersub(s, t, a) \
- (void)((a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
- ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
- ((a)->tv_usec += 1000000, (a)->tv_sec--))
+ ((s)->tv_sec == (t)->tv_sec ? (s)->tv_usec op(t)->tv_usec : (s)->tv_sec op(t)->tv_sec)
+#define timeradd(s, t, a) \
+ (void)((a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
+ ((a)->tv_usec -= 1000000, (a)->tv_sec++))
+#define timersub(s, t, a) \
+ (void)((a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
+ ((a)->tv_usec += 1000000, (a)->tv_sec--))
#endif
#if defined(_GNU_SOURCE)
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
- ((ts)->tv_sec = (tv)->tv_sec, (ts)->tv_nsec = (tv)->tv_usec * 1000, (void)0)
+ ((ts)->tv_sec = (tv)->tv_sec, (ts)->tv_nsec = (tv)->tv_usec * 1000, (void)0)
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
- ((tv)->tv_sec = (ts)->tv_sec, (tv)->tv_usec = (ts)->tv_nsec / 1000, (void)0)
+ ((tv)->tv_sec = (ts)->tv_sec, (tv)->tv_usec = (ts)->tv_nsec / 1000, (void)0)
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIME_H_
diff --git a/arch/x64/sysroot/include/sys/timeb.h b/arch/x64/sysroot/include/sys/timeb.h
index 560158b..bbb7e34 100644
--- a/arch/x64/sysroot/include/sys/timeb.h
+++ b/arch/x64/sysroot/include/sys/timeb.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMEB_H_
+#define SYSROOT_SYS_TIMEB_H_
#ifdef __cplusplus
extern "C" {
@@ -9,9 +10,9 @@
#include <bits/alltypes.h>
struct timeb {
- time_t time;
- unsigned short millitm;
- short timezone, dstflag;
+ time_t time;
+ unsigned short millitm;
+ short timezone, dstflag;
};
int ftime(struct timeb*);
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMEB_H_
diff --git a/arch/x64/sysroot/include/sys/timerfd.h b/arch/x64/sysroot/include/sys/timerfd.h
index c6b52b3..499a938 100644
--- a/arch/x64/sysroot/include/sys/timerfd.h
+++ b/arch/x64/sysroot/include/sys/timerfd.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMERFD_H_
+#define SYSROOT_SYS_TIMERFD_H_
#ifdef __cplusplus
extern "C" {
@@ -21,3 +22,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMERFD_H_
diff --git a/arch/x64/sysroot/include/sys/times.h b/arch/x64/sysroot/include/sys/times.h
index d573297..ec5d3d6 100644
--- a/arch/x64/sysroot/include/sys/times.h
+++ b/arch/x64/sysroot/include/sys/times.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMES_H_
+#define SYSROOT_SYS_TIMES_H_
#ifdef __cplusplus
extern "C" {
@@ -8,10 +9,10 @@
#include <bits/alltypes.h>
struct tms {
- clock_t tms_utime;
- clock_t tms_stime;
- clock_t tms_cutime;
- clock_t tms_cstime;
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
};
clock_t times(struct tms*);
@@ -19,3 +20,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMES_H_
diff --git a/arch/x64/sysroot/include/sys/timex.h b/arch/x64/sysroot/include/sys/timex.h
index 8aa166e..9981c93 100644
--- a/arch/x64/sysroot/include/sys/timex.h
+++ b/arch/x64/sysroot/include/sys/timex.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TIMEX_H_
+#define SYSROOT_SYS_TIMEX_H_
#ifdef __cplusplus
extern "C" {
@@ -6,26 +7,26 @@
#define __NEED_clockid_t
-#include <bits/alltypes.h>
-
#include <sys/time.h>
+#include <bits/alltypes.h>
+
struct ntptimeval {
- struct timeval time;
- long maxerror, esterror;
+ struct timeval time;
+ long maxerror, esterror;
};
struct timex {
- unsigned modes;
- long offset, freq, maxerror, esterror;
- int status;
- long constant, precision, tolerance;
- struct timeval time;
- long tick, ppsfreq, jitter;
- int shift;
- long stabil, jitcnt, calcnt, errcnt, stbcnt;
- int tai;
- int __padding[11];
+ unsigned modes;
+ long offset, freq, maxerror, esterror;
+ int status;
+ long constant, precision, tolerance;
+ struct timeval time;
+ long tick, ppsfreq, jitter;
+ int shift;
+ long stabil, jitcnt, calcnt, errcnt, stbcnt;
+ int tai;
+ int __padding[11];
};
#define ADJ_OFFSET 0x0001
@@ -74,9 +75,9 @@
#define STA_MODE 0x4000
#define STA_CLK 0x8000
-#define STA_RONLY \
- (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR | STA_CLOCKERR | STA_NANO | \
- STA_MODE | STA_CLK)
+#define STA_RONLY \
+ (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR | STA_CLOCKERR | STA_NANO | \
+ STA_MODE | STA_CLK)
#define TIME_OK 0
#define TIME_INS 1
@@ -94,3 +95,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TIMEX_H_
diff --git a/arch/x64/sysroot/include/sys/ttydefaults.h b/arch/x64/sysroot/include/sys/ttydefaults.h
index 742e3a9..e4994fe 100644
--- a/arch/x64/sysroot/include/sys/ttydefaults.h
+++ b/arch/x64/sysroot/include/sys/ttydefaults.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TTYDEFAULTS_H_
+#define SYSROOT_SYS_TTYDEFAULTS_H_
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
@@ -34,3 +35,5 @@
#define CBRK CEOL
#define CRPRNT CREPRINT
#define CFLUSH CDISCARD
+
+#endif // SYSROOT_SYS_TTYDEFAULTS_H_
diff --git a/arch/x64/sysroot/include/sys/types.h b/arch/x64/sysroot/include/sys/types.h
index b1c2a27..ea195a0 100644
--- a/arch/x64/sysroot/include/sys/types.h
+++ b/arch/x64/sysroot/include/sys/types.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_TYPES_H_
+#define SYSROOT_SYS_TYPES_H_
#ifdef __cplusplus
extern "C" {
@@ -71,3 +72,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_TYPES_H_
diff --git a/arch/x64/sysroot/include/sys/uio.h b/arch/x64/sysroot/include/sys/uio.h
index e9f7b5d..4762083 100644
--- a/arch/x64/sysroot/include/sys/uio.h
+++ b/arch/x64/sysroot/include/sys/uio.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_UIO_H_
+#define SYSROOT_SYS_UIO_H_
#ifdef __cplusplus
extern "C" {
@@ -29,3 +30,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UIO_H_
diff --git a/arch/x64/sysroot/include/sys/un.h b/arch/x64/sysroot/include/sys/un.h
index 52bebd4..425c801 100644
--- a/arch/x64/sysroot/include/sys/un.h
+++ b/arch/x64/sysroot/include/sys/un.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_UN_H_
+#define SYSROOT_SYS_UN_H_
#ifdef __cplusplus
extern "C" {
@@ -14,8 +15,8 @@
#include <bits/alltypes.h>
struct sockaddr_un {
- sa_family_t sun_family;
- char sun_path[108];
+ sa_family_t sun_family;
+ char sun_path[108];
};
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -26,3 +27,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UN_H_
diff --git a/arch/x64/sysroot/include/sys/utsname.h b/arch/x64/sysroot/include/sys/utsname.h
index 0333c82..5d5fee1 100644
--- a/arch/x64/sysroot/include/sys/utsname.h
+++ b/arch/x64/sysroot/include/sys/utsname.h
@@ -1,21 +1,23 @@
-#pragma once
+#ifndef SYSROOT_SYS_UTSNAME_H_
+#define SYSROOT_SYS_UTSNAME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+#include <limits.h>
struct utsname {
- char sysname[65];
- char nodename[65];
- char release[65];
- char version[65];
- char machine[65];
+ char sysname[65];
+ char nodename[HOST_NAME_MAX + 1];
+ char release[65];
+ char version[65];
+ char machine[65];
#ifdef _GNU_SOURCE
- char domainname[65];
+ char domainname[65];
#else
- char __domainname[65];
+ char __domainname[65];
#endif
};
@@ -24,3 +26,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_UTSNAME_H_
diff --git a/arch/x64/sysroot/include/sys/wait.h b/arch/x64/sysroot/include/sys/wait.h
index f31bb8e..3b33520 100644
--- a/arch/x64/sysroot/include/sys/wait.h
+++ b/arch/x64/sysroot/include/sys/wait.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYS_WAIT_H_
+#define SYSROOT_SYS_WAIT_H_
#ifdef __cplusplus
extern "C" {
@@ -10,9 +11,7 @@
#define __NEED_id_t
#include <bits/alltypes.h>
-typedef enum { P_ALL = 0,
- P_PID = 1,
- P_PGID = 2 } idtype_t;
+typedef enum { P_ALL = 0, P_PID = 1, P_PGID = 2 } idtype_t;
pid_t wait(int*);
pid_t waitpid(pid_t, int*, int);
@@ -43,3 +42,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYS_WAIT_H_
diff --git a/arch/x64/sysroot/include/sysexits.h b/arch/x64/sysroot/include/sysexits.h
index 82f672a..ca2782d 100644
--- a/arch/x64/sysroot/include/sysexits.h
+++ b/arch/x64/sysroot/include/sysexits.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYSEXITS_H_
+#define SYSROOT_SYSEXITS_H_
#define EX_OK 0
#define EX__BASE 64
@@ -18,3 +19,5 @@
#define EX_NOPERM 77
#define EX_CONFIG 78
#define EX__MAX 78
+
+#endif // SYSROOT_SYSEXITS_H_
diff --git a/arch/x64/sysroot/include/syslog.h b/arch/x64/sysroot/include/syslog.h
index 76fdce7..dcb09e3 100644
--- a/arch/x64/sysroot/include/syslog.h
+++ b/arch/x64/sysroot/include/syslog.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_SYSLOG_H_
+#define SYSROOT_SYSLOG_H_
#ifdef __cplusplus
extern "C" {
@@ -69,50 +70,52 @@
#define INTERNAL_NOPRI 0x10
#define INTERNAL_MARK (LOG_NFACILITIES << 3)
typedef struct {
- char* c_name;
- int c_val;
+ char* c_name;
+ int c_val;
} CODE;
-#define prioritynames \
- ((CODE*)(const CODE[]){{"alert", LOG_ALERT}, \
- {"crit", LOG_CRIT}, \
- {"debug", LOG_DEBUG}, \
- {"emerg", LOG_EMERG}, \
- {"err", LOG_ERR}, \
- {"error", LOG_ERR}, \
- {"info", LOG_INFO}, \
- {"none", INTERNAL_NOPRI}, \
- {"notice", LOG_NOTICE}, \
- {"panic", LOG_EMERG}, \
- {"warn", LOG_WARNING}, \
- {"warning", LOG_WARNING}, \
- {0, -1}})
-#define facilitynames \
- ((CODE*)(const CODE[]){{"auth", LOG_AUTH}, \
- {"authpriv", LOG_AUTHPRIV}, \
- {"cron", LOG_CRON}, \
- {"daemon", LOG_DAEMON}, \
- {"ftp", LOG_FTP}, \
- {"kern", LOG_KERN}, \
- {"lpr", LOG_LPR}, \
- {"mail", LOG_MAIL}, \
- {"mark", INTERNAL_MARK}, \
- {"news", LOG_NEWS}, \
- {"security", LOG_AUTH}, \
- {"syslog", LOG_SYSLOG}, \
- {"user", LOG_USER}, \
- {"uucp", LOG_UUCP}, \
- {"local0", LOG_LOCAL0}, \
- {"local1", LOG_LOCAL1}, \
- {"local2", LOG_LOCAL2}, \
- {"local3", LOG_LOCAL3}, \
- {"local4", LOG_LOCAL4}, \
- {"local5", LOG_LOCAL5}, \
- {"local6", LOG_LOCAL6}, \
- {"local7", LOG_LOCAL7}, \
- {0, -1}})
+#define prioritynames \
+ ((CODE*)(const CODE[]){{"alert", LOG_ALERT}, \
+ {"crit", LOG_CRIT}, \
+ {"debug", LOG_DEBUG}, \
+ {"emerg", LOG_EMERG}, \
+ {"err", LOG_ERR}, \
+ {"error", LOG_ERR}, \
+ {"info", LOG_INFO}, \
+ {"none", INTERNAL_NOPRI}, \
+ {"notice", LOG_NOTICE}, \
+ {"panic", LOG_EMERG}, \
+ {"warn", LOG_WARNING}, \
+ {"warning", LOG_WARNING}, \
+ {0, -1}})
+#define facilitynames \
+ ((CODE*)(const CODE[]){{"auth", LOG_AUTH}, \
+ {"authpriv", LOG_AUTHPRIV}, \
+ {"cron", LOG_CRON}, \
+ {"daemon", LOG_DAEMON}, \
+ {"ftp", LOG_FTP}, \
+ {"kern", LOG_KERN}, \
+ {"lpr", LOG_LPR}, \
+ {"mail", LOG_MAIL}, \
+ {"mark", INTERNAL_MARK}, \
+ {"news", LOG_NEWS}, \
+ {"security", LOG_AUTH}, \
+ {"syslog", LOG_SYSLOG}, \
+ {"user", LOG_USER}, \
+ {"uucp", LOG_UUCP}, \
+ {"local0", LOG_LOCAL0}, \
+ {"local1", LOG_LOCAL1}, \
+ {"local2", LOG_LOCAL2}, \
+ {"local3", LOG_LOCAL3}, \
+ {"local4", LOG_LOCAL4}, \
+ {"local5", LOG_LOCAL5}, \
+ {"local6", LOG_LOCAL6}, \
+ {"local7", LOG_LOCAL7}, \
+ {0, -1}})
#endif
#endif
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_SYSLOG_H_
diff --git a/arch/x64/sysroot/include/tar.h b/arch/x64/sysroot/include/tar.h
index 7703c2b..2dcb983 100644
--- a/arch/x64/sysroot/include/tar.h
+++ b/arch/x64/sysroot/include/tar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_TAR_H_
+#define SYSROOT_TAR_H_
#define TSUID 04000
#define TSGID 02000
@@ -28,3 +29,5 @@
#define TVERSION "00"
#define TVERSLEN 2
+
+#endif // SYSROOT_TAR_H_
diff --git a/arch/x64/sysroot/include/termios.h b/arch/x64/sysroot/include/termios.h
index 65c9d66..4ccfe13 100644
--- a/arch/x64/sysroot/include/termios.h
+++ b/arch/x64/sysroot/include/termios.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_TERMIOS_H_
+#define SYSROOT_TERMIOS_H_
#ifdef __cplusplus
extern "C" {
@@ -41,3 +42,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_TERMIOS_H_
diff --git a/arch/x64/sysroot/include/threads.h b/arch/x64/sysroot/include/threads.h
index 8711302..480a6f7 100644
--- a/arch/x64/sysroot/include/threads.h
+++ b/arch/x64/sysroot/include/threads.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_THREADS_H_
+#define SYSROOT_THREADS_H_
#include <features.h>
#include <time.h>
@@ -24,26 +25,26 @@
#define TSS_DTOR_ITERATIONS 4
enum {
- thrd_success = 0,
- thrd_busy = 1,
- thrd_error = 2,
- thrd_nomem = 3,
- thrd_timedout = 4,
+ thrd_success = 0,
+ thrd_busy = 1,
+ thrd_error = 2,
+ thrd_nomem = 3,
+ thrd_timedout = 4,
};
// These are bitfield values; initialize with e.g. (mtx_plain|mtx_timed).
// mtx_recursive is not implemented.
enum {
- mtx_plain = 0,
- mtx_recursive = 1,
- mtx_timed = 2,
+ mtx_plain = 0,
+ mtx_recursive = 1,
+ mtx_timed = 2,
};
#ifdef _ALL_SOURCE
#define MTX_INIT \
- {}
+ {}
#define CND_INIT \
- {}
+ {}
#endif
#define ONCE_FLAG_INIT 0
@@ -76,14 +77,14 @@
#ifdef __clang__
__attribute__((__acquire_capability__(__m)))
#endif
-;
+ ;
int mtx_timedlock(mtx_t* __restrict, const struct timespec* __restrict);
int mtx_trylock(mtx_t*);
int mtx_unlock(mtx_t* __m)
#ifdef __clang__
__attribute__((__release_capability__(__m)))
#endif
-;
+ ;
int cnd_init(cnd_t*);
void cnd_destroy(cnd_t*);
@@ -103,3 +104,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_THREADS_H_
diff --git a/arch/x64/sysroot/include/time.h b/arch/x64/sysroot/include/time.h
index c20b7db..b81da45 100644
--- a/arch/x64/sysroot/include/time.h
+++ b/arch/x64/sysroot/include/time.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_TIME_H_
+#define SYSROOT_TIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_size_t
@@ -27,17 +29,17 @@
#endif
struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long __tm_gmtoff;
- const char* __tm_zone;
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ long __tm_gmtoff;
+ const char* __tm_zone;
};
clock_t clock(void);
@@ -66,8 +68,8 @@
void tzset(void);
struct itimerspec {
- struct timespec it_interval;
- struct timespec it_value;
+ struct timespec it_interval;
+ struct timespec it_value;
};
#define CLOCK_REALTIME 0
@@ -118,3 +120,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_TIME_H_
diff --git a/arch/x64/sysroot/include/uchar.h b/arch/x64/sysroot/include/uchar.h
index 73e5e5a..79cda7c 100644
--- a/arch/x64/sysroot/include/uchar.h
+++ b/arch/x64/sysroot/include/uchar.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_UCHAR_H_
+#define SYSROOT_UCHAR_H_
#ifdef __cplusplus
extern "C" {
@@ -10,9 +11,10 @@
#define __NEED_mbstate_t
#define __NEED_size_t
-#include <bits/alltypes.h>
#include <features.h>
+#include <bits/alltypes.h>
+
size_t c16rtomb(char* __restrict, char16_t, mbstate_t* __restrict);
size_t mbrtoc16(char16_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict);
@@ -22,3 +24,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UCHAR_H_
diff --git a/arch/x64/sysroot/include/ucontext.h b/arch/x64/sysroot/include/ucontext.h
index 930bb71..ccd910f 100644
--- a/arch/x64/sysroot/include/ucontext.h
+++ b/arch/x64/sysroot/include/ucontext.h
@@ -1,11 +1,11 @@
-#pragma once
+#ifndef SYSROOT_UCONTEXT_H_
+#define SYSROOT_UCONTEXT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
-
#include <signal.h>
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -22,3 +22,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UCONTEXT_H_
diff --git a/arch/x64/sysroot/include/unistd.h b/arch/x64/sysroot/include/unistd.h
index 4f91876..e400030 100644
--- a/arch/x64/sysroot/include/unistd.h
+++ b/arch/x64/sysroot/include/unistd.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_UNISTD_H_
+#define SYSROOT_UNISTD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define STDIN_FILENO 0
@@ -134,8 +136,6 @@
void sync(void);
int syncfs(int);
pid_t setpgrp(void);
-char* crypt(const char*, const char*);
-void encrypt(char*, int);
void swab(const void* __restrict, void* __restrict, ssize_t);
#endif
@@ -432,3 +432,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UNISTD_H_
diff --git a/arch/x64/sysroot/include/utime.h b/arch/x64/sysroot/include/utime.h
index 25e0ff7..b4368aa 100644
--- a/arch/x64/sysroot/include/utime.h
+++ b/arch/x64/sysroot/include/utime.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_UTIME_H_
+#define SYSROOT_UTIME_H_
#ifdef __cplusplus
extern "C" {
@@ -9,8 +10,8 @@
#include <bits/alltypes.h>
struct utimbuf {
- time_t actime;
- time_t modtime;
+ time_t actime;
+ time_t modtime;
};
int utime(const char*, const struct utimbuf*);
@@ -18,3 +19,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_UTIME_H_
diff --git a/arch/x64/sysroot/include/values.h b/arch/x64/sysroot/include/values.h
index a139dca..0862584 100644
--- a/arch/x64/sysroot/include/values.h
+++ b/arch/x64/sysroot/include/values.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_VALUES_H_
+#define SYSROOT_VALUES_H_
#include <limits.h>
@@ -34,3 +35,5 @@
#define FMAXEXP FLT_MAX_EXP
#define BITSPERBYTE CHAR_BIT
+
+#endif // SYSROOT_VALUES_H_
diff --git a/arch/x64/sysroot/include/wchar.h b/arch/x64/sysroot/include/wchar.h
index 5578085..aaa7e9e 100644
--- a/arch/x64/sysroot/include/wchar.h
+++ b/arch/x64/sysroot/include/wchar.h
@@ -1,10 +1,12 @@
-#pragma once
+#ifndef SYSROOT_WCHAR_H_
+#define SYSROOT_WCHAR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <features.h>
+
#include <bits/null.h>
#define __NEED_FILE
@@ -32,13 +34,13 @@
#ifndef WCHAR_MIN
#if defined(__WCHAR_MIN__)
#define WCHAR_MIN __WCHAR_MIN__
-#else // defined(__WCHAR_MIN__)
+#else // defined(__WCHAR_MIN__)
#if defined(__WCHAR_UNSIGNED__)
#define WCHAR_MIN (L'\0' + 0)
#else
#define WCHAR_MIN (-WCHAR_MAX - 1)
-#endif // defined (__WCHAR_UNSIGNED)
-#endif // defined(__WCHAR_MIN__)
+#endif // defined (__WCHAR_UNSIGNED)
+#endif // defined(__WCHAR_MIN__)
#endif
#undef WEOF
@@ -179,3 +181,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WCHAR_H_
diff --git a/arch/x64/sysroot/include/wctype.h b/arch/x64/sysroot/include/wctype.h
index 8c86840..5a04bb8 100644
--- a/arch/x64/sysroot/include/wctype.h
+++ b/arch/x64/sysroot/include/wctype.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_WCTYPE_H_
+#define SYSROOT_WCTYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -55,3 +56,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WCTYPE_H_
diff --git a/arch/x64/sysroot/include/wordexp.h b/arch/x64/sysroot/include/wordexp.h
index 26f8646..dd6caa0 100644
--- a/arch/x64/sysroot/include/wordexp.h
+++ b/arch/x64/sysroot/include/wordexp.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SYSROOT_WORDEXP_H_
+#define SYSROOT_WORDEXP_H_
#ifdef __cplusplus
extern "C" {
@@ -18,9 +19,9 @@
#define WRDE_UNDEF 32
typedef struct {
- size_t we_wordc;
- char** we_wordv;
- size_t we_offs;
+ size_t we_wordc;
+ char** we_wordv;
+ size_t we_offs;
} wordexp_t;
#define WRDE_NOSYS -1
@@ -36,3 +37,5 @@
#ifdef __cplusplus
}
#endif
+
+#endif // SYSROOT_WORDEXP_H_
diff --git a/arch/x64/sysroot/include/zircon/assert.h b/arch/x64/sysroot/include/zircon/assert.h
index 6175321..d53115d 100644
--- a/arch/x64/sysroot/include/zircon/assert.h
+++ b/arch/x64/sysroot/include/zircon/assert.h
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_ASSERT_
-#define ZIRCON_ASSERT_
+#ifndef SYSROOT_ZIRCON_ASSERT_
+#define SYSROOT_ZIRCON_ASSERT_
+
+// For a description of which asserts are enabled at which debug levels, see the documentation for
+// GN build argument |assert_level|.
#ifdef _KERNEL
#include <assert.h>
@@ -16,61 +19,69 @@
#define ZX_DEBUG_ASSERT_MSG_COND(args...) DEBUG_ASSERT_MSG_COND(args)
#define ZX_DEBUG_ASSERT_IMPLEMENTED DEBUG_ASSERT_IMPLEMENTED
-#ifdef ZX_DEBUGLEVEL
-#undef ZX_DEBUGLEVEL
-#endif
-#define ZX_DEBUGLEVEL LK_DEBUGLEVEL
-
-#else // #ifdef _KERNEL
-
-#include <stdio.h> // for printf
-#include <stdlib.h> // for abort
+#else // #ifdef _KERNEL
#include <zircon/compiler.h>
-#define ZX_PANIC(fmt, ...) \
- do { \
- printf(fmt, ##__VA_ARGS__); \
- abort(); \
- } while (0)
+__BEGIN_CDECLS
+void __zx_panic(const char* format, ...) __NO_RETURN __PRINTFLIKE(1, 2);
+__END_CDECLS
-#define ZX_ASSERT(x) \
- do { \
- if (unlikely(!(x))) { \
- ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
- } \
- } while (0)
+#define ZX_PANIC(fmt, ...) __zx_panic((fmt), ##__VA_ARGS__)
-#define ZX_ASSERT_MSG(x, msg, msgargs...) \
- do { \
- if (unlikely(!(x))) { \
- ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n" msg "\n", \
- __FILE__, __LINE__, #x, ##msgargs); \
- } \
- } while (0)
+// Assert that |x| is true, else panic.
+//
+// ZX_ASSERT is always enabled and |x| will be evaluated regardless of any build arguments.
+#define ZX_ASSERT(x) \
+ do { \
+ if (unlikely(!(x))) { \
+ ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
+ } \
+ } while (0)
-// conditionally implement DEBUG_ASSERT based on ZX_DEBUGLEVEL in kernel space
-// user space does not currently implement DEBUG_ASSERT
-#ifdef ZX_DEBUGLEVEL
-#define ZX_DEBUG_ASSERT_IMPLEMENTED (ZX_DEBUGLEVEL > 1)
+// Assert that |x| is true, else panic with the given message.
+//
+// ZX_ASSERT_MSG is always enabled and |x| will be evaluated regardless of any build arguments.
+#define ZX_ASSERT_MSG(x, msg, msgargs...) \
+ do { \
+ if (unlikely(!(x))) { \
+ ZX_PANIC("ASSERT FAILED at (%s:%d): %s\n" msg "\n", __FILE__, __LINE__, #x, ##msgargs); \
+ } \
+ } while (0)
+
+// Conditionally implement ZX_DEBUG_ASSERT based on ZX_ASSERT_LEVEL.
+#ifdef ZX_ASSERT_LEVEL
+
+// ZX_DEBUG_ASSERT_IMPLEMENTED is intended to be used to conditionalize code that is logically part
+// of a debug assert. It's useful for performing complex consistency checks that are difficult to
+// work into a ZX_DEBUG_ASSERT statement.
+#define ZX_DEBUG_ASSERT_IMPLEMENTED (ZX_ASSERT_LEVEL > 1)
#else
#define ZX_DEBUG_ASSERT_IMPLEMENTED 0
#endif
-#define ZX_DEBUG_ASSERT(x) \
- do { \
- if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
- ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
- } \
- } while (0)
+// Assert that |x| is true, else panic.
+//
+// Depending on build arguments, ZX_DEBUG_ASSERT may or may not be enabled. When disabled, |x| will
+// not be evaluated.
+#define ZX_DEBUG_ASSERT(x) \
+ do { \
+ if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
+ ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); \
+ } \
+ } while (0)
-#define ZX_DEBUG_ASSERT_MSG(x, msg, msgargs...) \
- do { \
- if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
- ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n" msg "\n", \
- __FILE__, __LINE__, #x, ##msgargs); \
- } \
- } while (0)
+// Assert that |x| is true, else panic with the given message.
+//
+// Depending on build arguments, ZX_DEBUG_ASSERT_MSG may or may not be enabled. When disabled, |x|
+// will not be evaluated.
+#define ZX_DEBUG_ASSERT_MSG(x, msg, msgargs...) \
+ do { \
+ if (ZX_DEBUG_ASSERT_IMPLEMENTED && unlikely(!(x))) { \
+ ZX_PANIC("DEBUG ASSERT FAILED at (%s:%d): %s\n" msg "\n", __FILE__, __LINE__, #x, \
+ ##msgargs); \
+ } \
+ } while (0)
// implement _COND versions of ZX_DEBUG_ASSERT which only emit the body if
// ZX_DEBUG_ASSERT_IMPLEMENTED is set
@@ -78,9 +89,13 @@
#define ZX_DEBUG_ASSERT_COND(x) ZX_DEBUG_ASSERT(x)
#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) ZX_DEBUG_ASSERT_MSG(x, msg, msgargs)
#else
-#define ZX_DEBUG_ASSERT_COND(x) do { } while (0)
-#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) do { } while (0)
+#define ZX_DEBUG_ASSERT_COND(x) \
+ do { \
+ } while (0)
+#define ZX_DEBUG_ASSERT_MSG_COND(x, msg, msgargs...) \
+ do { \
+ } while (0)
#endif
-#endif // #ifdef _KERNEL
+#endif // #ifdef _KERNEL
-#endif // ZIRCON_ASSERT_
+#endif // SYSROOT_ZIRCON_ASSERT_
diff --git a/arch/x64/sysroot/include/zircon/boot/bootdata.h b/arch/x64/sysroot/include/zircon/boot/bootdata.h
deleted file mode 100644
index d49b9b1..0000000
--- a/arch/x64/sysroot/include/zircon/boot/bootdata.h
+++ /dev/null
@@ -1,317 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#ifndef __ASSEMBLER__
-#include <zircon/compiler.h>
-#include <stdbool.h>
-#include <stdint.h>
-#endif
-
-// lsw of sha256("bootdata")
-#define BOOTDATA_MAGIC (0x868cf7e6)
-
-// lsw of sha256("bootitem")
-#define BOOTITEM_MAGIC (0xb5781729)
-
-// Round n up to the next 8 byte boundary
-#define BOOTDATA_ALIGN(n) (((n) + 7) & (~7))
-
-#define BOOTITEM_NO_CRC32 (0x4a87e8d6)
-
-// This flag is required.
-#define BOOTDATA_FLAG_V2 (0x00010000)
-
-// Bootdata items with the CRC32 flag must have a valid crc32.
-// Otherwise their crc32 field must contain BOOTITEM_NO_CRC32
-#define BOOTDATA_FLAG_CRC32 (0x00020000)
-
-// Bootdata types that have least significant byte set to 'm'
-// are reserved for driver metadata
-#define BOOTDATA_KIND_METADATA (0x0000006D)
-#define BOOTDATA_KIND_MASK (0x000000FF)
-
-// Containers are used to wrap a set of bootdata items
-// written to a file or partition. The "length" is the
-// length of the set of following bootdata items. The
-// "extra" is the value BOOTDATA_MAGIC and "flags" is
-// set to 0.
-#define BOOTDATA_CONTAINER (0x544f4f42) // BOOT
-
-// BOOTFS images. The "extra" field is the decompressed
-// size of the image, if compressed, otherwise the same
-// as the "length" field.
-#define BOOTDATA_BOOTFS_BOOT (0x42534642) // BFSB
-#define BOOTDATA_BOOTFS_SYSTEM (0x53534642) // BFSS
-#define BOOTDATA_BOOTFS_DISCARD (0x58534642) // BFSX
-
-#define BOOTDATA_BOOTFS_MASK (0x00FFFFFF)
-#define BOOTDATA_BOOTFS_TYPE (0x00534642) // BFS\0
-
-// Virtual disk images. The header fields and compression protocol
-// are the same as for the BOOTFS types, but the payload before
-// compression is a raw disk image rather than BOOTFS format.
-#define BOOTDATA_RAMDISK (0x4b534452) // RDSK
-
-// A Zircon Kernel Image
-// Content: bootdata_kernel_t
-#define BOOTDATA_KERNEL (0x4c4e524b) // KRNL
-
-// A Zircon Partition Map
-// Content: bootdata_partition_map_t
-// The bootdata_t.extra field is used as a board specific index
-// to specify which device the partition map applies to.
-#define BOOTDATA_PARTITION_MAP (0x5452506D) // mPRT
-
-// MAC Address for Ethernet, Wifi, Bluetooth, etc.
-// Content: uint8_t[] (variable length based on type of MAC address)
-// The bootdata_t.extra field is used as a board specific index
-// to specify which device the MAC address applies to.
-#define BOOTDATA_MAC_ADDRESS (0x43414D6D) // mMAC
-
-// Flag indicating that the bootfs is compressed.
-#define BOOTDATA_BOOTFS_FLAG_COMPRESSED (1 << 0)
-
-
-// These items are for passing from bootloader to kernel
-
-// Kernel Command Line String
-// Content: uint8_t[]
-#define BOOTDATA_CMDLINE (0x4c444d43) // CMDL
-
-// ACPI Root Table Pointer
-// Content: uint64_t phys addr
-#define BOOTDATA_ACPI_RSDP (0x50445352) // RSDP
-
-// SMBIOS entry point pointer
-// Content: uint64_t phys addr
-#define BOOTDATA_SMBIOS (0x49424d53) // SMBI
-
-// Framebuffer Parameters
-// Content: bootdata_swfb_t
-#define BOOTDATA_FRAMEBUFFER (0x42465753) // SWFB
-
-// Debug Serial Port
-// Content: bootdata_uart_t
-#define BOOTDATA_DEBUG_UART (0x54524155) // UART
-
-// Platform ID Information
-// Content: bootdata_platform_id_t
-#define BOOTDATA_PLATFORM_ID (0x44494C50) // PLID
-
-// Memory which will persist across warm boots
-// Content bootdata_lastlog_nvram_t
-#define BOOTDATA_LASTLOG_NVRAM (0x4c4c564e) // NVLL
-
-// This reflects a typo we need to support for a while
-#define BOOTDATA_LASTLOG_NVRAM2 (0x4c4c5643) // CVLL
-
-// E820 Memory Table
-// Content: e820entry[]
-#define BOOTDATA_E820_TABLE (0x30323845) // E820
-
-// EFI Memory Map
-// Content: a uint64_t entrysz followed by a set of
-// efi_memory_descriptor aligned on entrysz
-#define BOOTDATA_EFI_MEMORY_MAP (0x4d494645) // EFIM
-
-// EFI System Table
-// Content: a uint64_t physical address of the table
-#define BOOTDATA_EFI_SYSTEM_TABLE (0x53494645) // EFIS
-
-// Last crashlog
-// Content: ascii/utf8 log data from previous boot
-#define BOOTDATA_LAST_CRASHLOG (0x4d4f4f42) // BOOM
-
-// CPU configuration
-// Content: bootdata_cpu_config_t
-#define BOOTDATA_CPU_CONFIG (0x43555043) // CPUC
-
-// Memory configuration
-// Content: one or more of bootdata_mem_range_t (count determined by bootdata_t length)
-#define BOOTDATA_MEM_CONFIG (0x434D454D) // MEMC
-
-// Kernel driver configuration
-// Content: driver specific struct, with type determined by bootdata "extra" field
-#define BOOTDATA_KERNEL_DRIVER (0x5652444B) // KDRV
-
-#define BOOTDATA_IGNORE (0x50494b53) // SKIP
-
-#ifndef __ASSEMBLER__
-__BEGIN_CDECLS;
-
-// BootData header, describing the type and size of data
-// used to initialize the system. All fields are little-endian.
-//
-// BootData headers in a stream must be 8-byte-aligned.
-//
-// The length field specifies the actual payload length
-// and does not include the size of padding.
-typedef struct {
- // Boot data type
- uint32_t type;
-
- // Size of the payload following this header
- uint32_t length;
-
- // type-specific extra data
- // For CONTAINER this is MAGIC.
- // For BOOTFS this is the decompressed size.
- uint32_t extra;
-
- // Flags for the boot data. See flag descriptions for each type.
- uint32_t flags;
-
- // For future expansion. Set to 0.
- uint32_t reserved0;
- uint32_t reserved1;
-
- // Must be BOOTITEM_MAGIC
- uint32_t magic;
-
- // Must be the CRC32 of payload if FLAG_CRC32 is set,
- // otherwise must be BOOTITEM_NO_CRC32
- uint32_t crc32;
-} bootdata_t;
-
-typedef struct {
- uint64_t base; // physical base addr
- uint32_t width;
- uint32_t height;
- uint32_t stride;
- uint32_t format;
-} bootdata_swfb_t;
-
-typedef struct {
- uint64_t entry64;
- uint64_t reserved;
-} bootdata_kernel_t;
-
-#define BOOTDATA_PART_NAME_LEN 32
-#define BOOTDATA_PART_GUID_LEN 16
-
-typedef struct {
- uint8_t type_guid[BOOTDATA_PART_GUID_LEN];
- uint8_t uniq_guid[BOOTDATA_PART_GUID_LEN];
- uint64_t first_block;
- uint64_t last_block;
- uint64_t flags;
- char name[BOOTDATA_PART_NAME_LEN];
-} bootdata_partition_t;
-
-typedef struct {
- uint64_t block_count;
- uint64_t block_size;
- uint32_t partition_count;
- uint32_t reserved;
- char guid[BOOTDATA_PART_GUID_LEN];
- bootdata_partition_t partitions[];
-} bootdata_partition_map_t;
-
-typedef struct {
- uint64_t base;
- uint64_t length;
-} bootdata_nvram_t;
-
-#define BOOTDATA_UART_NONE 0
-#define BOOTDATA_UART_PC_PORT 1
-#define BOOTDATA_UART_PC_MMIO 2
-typedef struct {
- uint64_t base;
- uint32_t type;
- uint32_t irq;
-} bootdata_uart_t;
-
-typedef struct {
- uint32_t vid;
- uint32_t pid;
- char board_name[32];
-} bootdata_platform_id_t;
-
-typedef struct {
- uint32_t cpu_count; // number of CPU cores in the cluster
- uint32_t type; // for future use
- uint32_t flags; // for future use
- uint32_t reserved;
-} bootdata_cpu_cluster_t;
-
-typedef struct {
- uint32_t cluster_count;
- uint32_t reserved[3];
- bootdata_cpu_cluster_t clusters[];
-} bootdata_cpu_config_t;
-
-#define BOOTDATA_MEM_RANGE_RAM 1
-#define BOOTDATA_MEM_RANGE_PERIPHERAL 2
-#define BOOTDATA_MEM_RANGE_RESERVED 3
-typedef struct {
- uint64_t paddr;
- uint64_t length;
- uint32_t type;
- uint32_t reserved;
-} bootdata_mem_range_t;
-
-/* EFI Variable for Crash Log */
-#define ZIRCON_VENDOR_GUID \
- {0x82305eb2, 0xd39e, 0x4575, {0xa0, 0xc8, 0x6c, 0x20, 0x72, 0xd0, 0x84, 0x4c}}
-#define ZIRCON_CRASHLOG_EFIVAR \
- { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 };
-#define ZIRCON_CRASHLOG_EFIATTR \
- (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
-
-__END_CDECLS;
-
-
-// BOOTFS is a trivial "filesystem" format
-//
-// It consists of a bootfs_header_t
-//
-// Followed by a series of bootfs_entry_t's of:
-// name length (32bit le)
-// data size (32bit le)
-// data offset (32bit le)
-// namedata (namelength bytes, includes \0)
-//
-// - data offsets must be page aligned (multiple of 4096)
-// - entries start on uint32 boundaries
-
-//lsw of sha256("bootfs")
-#define BOOTFS_MAGIC (0xa56d3ff9)
-
-#define BOOTFS_PAGE_SIZE (4096)
-#define BOOTFS_PAGE_ALIGN(size) \
- (((size) + BOOTFS_PAGE_SIZE - 1) & -BOOTFS_PAGE_SIZE)
-
-#define BOOTFS_MAX_NAME_LEN 256
-
-typedef struct bootfs_header {
- // magic value BOOTFS_MAGIC
- uint32_t magic;
-
- // total size of all bootfs_entry_t's
- // does not include the size of the bootfs_header_t
- uint32_t dirsize;
-
- // 0, 0
- uint32_t reserved0;
- uint32_t reserved1;
-} bootfs_header_t;
-
-typedef struct bootfs_entry {
- uint32_t name_len;
- uint32_t data_len;
- uint32_t data_off;
- char name[];
-} bootfs_entry_t;
-
-#define BOOTFS_ALIGN(nlen) (((nlen) + 3) & (~3))
-#define BOOTFS_RECSIZE(entry) \
- (sizeof(bootfs_entry_t) + BOOTFS_ALIGN(entry->name_len))
-
-static inline bool bootdata_is_metadata(uint32_t type) {
- return ((type & BOOTDATA_KIND_MASK) == BOOTDATA_KIND_METADATA);
-}
-
-#endif
diff --git a/arch/x64/sysroot/include/zircon/boot/bootfs.h b/arch/x64/sysroot/include/zircon/boot/bootfs.h
new file mode 100644
index 0000000..8cc2644
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/boot/bootfs.h
@@ -0,0 +1,66 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_BOOT_BOOTFS_H_
+#define SYSROOT_ZIRCON_BOOT_BOOTFS_H_
+
+#include <stdint.h>
+
+// The payload (after decompression) of an item in BOOTFS format consists
+// of separate "file" images that are each aligned to ZBI_BOOTFS_PAGE_SIZE
+// bytes from the beginning of the item payload. The first "file" consists
+// of a zbi_bootfs_header_t followed by directory entries.
+#define ZBI_BOOTFS_PAGE_SIZE (4096u)
+
+#define ZBI_BOOTFS_PAGE_ALIGN(size) \
+ (((size) + ZBI_BOOTFS_PAGE_SIZE - 1) & ~(ZBI_BOOTFS_PAGE_SIZE - 1))
+
+typedef struct {
+ // Must be ZBI_BOOTFS_MAGIC.
+ uint32_t magic;
+
+ // Size in bytes of all the directory entries.
+ // Does not include the size of the zbi_bootfs_header_t.
+ uint32_t dirsize;
+
+ // Reserved for future use. Set to 0.
+ uint32_t reserved0;
+ uint32_t reserved1;
+} zbi_bootfs_header_t;
+
+// LSW of sha256("bootfs")
+#define ZBI_BOOTFS_MAGIC (0xa56d3ff9)
+
+// Each directory entry holds a pathname and gives the offset and size
+// of the contents of the file by that name.
+typedef struct {
+ // Length of the name[] field at the end. This length includes the
+ // NUL terminator, which must be present, but does not include any
+ // alignment padding required before the next directory entry.
+ uint32_t name_len;
+
+ // Length of the file in bytes. This is an exact size that is not
+ // rounded, though the file is always padded with zeros up to a
+ // multiple of ZBI_BOOTFS_PAGE_SIZE.
+ uint32_t data_len;
+
+ // Offset from the beginning of the payload (zbi_bootfs_header_t) to
+ // the file's data. This must be a multiple of ZBI_BOOTFS_PAGE_SIZE.
+ uint32_t data_off;
+
+ // Pathname of the file, a UTF-8 string. This must include a NUL
+ // terminator at the end. It must not begin with a '/', but it may
+ // contain '/' separators for subdirectories.
+ char name[];
+} zbi_bootfs_dirent_t;
+
+// Each directory entry has a variable size of [16,268] bytes that
+// must be a multiple of 4 bytes.
+#define ZBI_BOOTFS_DIRENT_SIZE(name_len) \
+ ((sizeof(zbi_bootfs_dirent_t) + (name_len) + 3) & -(size_t)4)
+
+// zbi_bootfs_dirent_t.name_len must be > 1 and <= ZBI_BOOTFS_MAX_NAME_LEN.
+#define ZBI_BOOTFS_MAX_NAME_LEN (256)
+
+#endif // SYSROOT_ZIRCON_BOOT_BOOTFS_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/crash-reason.h b/arch/x64/sysroot/include/zircon/boot/crash-reason.h
new file mode 100644
index 0000000..f626fac
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/boot/crash-reason.h
@@ -0,0 +1,59 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
+#define SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
+
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+// 0 is reserved for "Invalid". It will never be used by a functioning
+// crash-logger.
+#define ZIRCON_CRASH_REASON_INVALID ((uint32_t)0)
+
+// "Unknown" indicates that the system does not know the reason for a recent
+// crash. The primary use of this reason is to be something which can be left
+// in the crashlog in case the system spontaneously reboots without a chance to
+// gracefully finalize the log, perhaps because of something like a hardware
+// watchdog timer.
+#define ZIRCON_CRASH_REASON_UNKNOWN ((uint32_t)1)
+
+// "No Crash" indicates that the system deliberately rebooted in an
+// orderly fashion. No crash occurred.
+#define ZIRCON_CRASH_REASON_NO_CRASH ((uint32_t)2)
+
+// "OOM" indicates a crash triggered by the system because of an unrecoverable
+// out-of-memory situation.
+#define ZIRCON_CRASH_REASON_OOM ((uint32_t)3)
+
+// "Panic" indicates a crash triggered by the system because of an unrecoverable
+// kernel panic situation.
+#define ZIRCON_CRASH_REASON_PANIC ((uint32_t)4)
+
+// "Software watchdog" indicates a crash triggered by a kernel level software
+// watchdog construct. Note that this is distinct from a hardware based WDT.
+// If the system reboots because of a hardware watchdog, it will have no chance
+// to record the reboot reason, and the crashlog will indicate "unknown". The
+// HW reboot reason may be known, but only if the bootloader reports it to us.
+#define ZIRCON_CRASH_REASON_SOFTWARE_WATCHDOG ((uint32_t)5)
+
+#ifndef __ASSEMBLER__
+#if !__cplusplus
+typedef uint32_t zircon_crash_reason_t;
+#else // !__cplusplus
+enum class ZirconCrashReason : uint32_t {
+ Invalid = ZIRCON_CRASH_REASON_INVALID,
+ Unknown = ZIRCON_CRASH_REASON_UNKNOWN,
+ NoCrash = ZIRCON_CRASH_REASON_NO_CRASH,
+ Oom = ZIRCON_CRASH_REASON_OOM,
+ Panic = ZIRCON_CRASH_REASON_PANIC,
+ SoftwareWatchdog = ZIRCON_CRASH_REASON_SOFTWARE_WATCHDOG,
+};
+
+// Using alias to maintain compatibility with APIs meant to be used by both C and C++.
+using zircon_crash_reason_t = ZirconCrashReason;
+#endif // !__cplusplus
+#endif // __ASSEMBLER__
+
+#endif // SYSROOT_ZIRCON_BOOT_CRASH_REASON_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/driver-config.h b/arch/x64/sysroot/include/zircon/boot/driver-config.h
index 4913ae1..7f72fca 100644
--- a/arch/x64/sysroot/include/zircon/boot/driver-config.h
+++ b/arch/x64/sysroot/include/zircon/boot/driver-config.h
@@ -2,87 +2,162 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
+#define SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
-#include <zircon/compiler.h>
#include <stdint.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
-// BOOTDATA_KERNEL_DRIVER bootdata types
-#define KDRV_ARM_PSCI 0x49435350 // 'PSCI'
-#define KDRV_ARM_GIC_V2 0x32434947 // 'GIC2'
-#define KDRV_ARM_GIC_V3 0x33434947 // 'GIC3'
-#define KDRV_ARM_GENERIC_TIMER 0x4D495441 // 'ATIM'
-#define KDRV_PL011_UART 0x55304C50 // 'PL0U'
-#define KDRV_AMLOGIC_UART 0x554C4D41 // 'AMLU'
-#define KDRV_NXP_IMX_UART 0x55584D49 // 'IMXU'
-#define KDRV_MT8167_UART 0x5538544D // 'MT8U'
-#define KDRV_HISILICON_POWER 0x4F505348 // 'HSPO'
-#define KDRV_AMLOGIC_HDCP 0x484C4D41 // 'AMLH'
+// ZBI_TYPE_KERNEL_DRIVER item types (for zbi_header_t.extra)
+#define KDRV_ARM_PSCI 0x49435350 // 'PSCI'
+#define KDRV_ARM_GIC_V2 0x32434947 // 'GIC2'
+#define KDRV_ARM_GIC_V3 0x33434947 // 'GIC3'
+#define KDRV_ARM_GENERIC_TIMER 0x4D495441 // 'ATIM'
+#define KDRV_PL011_UART 0x55304C50 // 'PL0U'
+#define KDRV_AMLOGIC_UART 0x554C4D41 // 'AMLU'
+#define KDRV_NXP_IMX_UART 0x55584D49 // 'IMXU'
+#define KDRV_MT8167_UART 0x5538544D // 'MT8U'
+#define KDRV_AMLOGIC_HDCP 0x484C4D41 // 'AMLH'
+#define KDRV_MSM_UART 0x554D534D // 'MSMU'
+#define KDRV_MSM_POWER 1347244877 // 'MSMP'
+#define KDRV_DW8250_UART 0x44573855 // 'DW8U'
+#define KDRV_AS370_POWER 0x50303733 // '370P'
+#define KDRV_AMLOGIC_RNG 0x484C4D52 // 'AMLR'
+#define KDRV_GENERIC_32BIT_WATCHDOG 0x32334457 // 'WD32'
+#define KDRV_I8250_PIO_UART 0x30353238 // '8250'
+#define KDRV_I8250_MMIO_UART 0x4d353238 // '825M'
-// kernel driver struct that can be used for simple drivers
-// used by KDRV_PL011_UART, KDRV_AMLOGIC_UART and KDRV_NXP_IMX_UART
+// Kernel driver struct that can be used for simple drivers.
+// Used by KDRV_PL011_UART, KDRV_AMLOGIC_UART, KDRV_NXP_IMX_UART,
+// and KDRV_I8250_MMIO_UART.
typedef struct {
- uint64_t mmio_phys;
- uint32_t irq;
+ uint64_t mmio_phys;
+ uint32_t irq;
} dcfg_simple_t;
+// Used by KDRV_I8250_PIO_UART.
+typedef struct {
+ uint16_t base;
+ uint32_t irq;
+} dcfg_simple_pio_t;
+
// for KDRV_MT8167_UART
typedef struct {
- uint64_t soc_mmio_phys;
- uint64_t uart_mmio_phys;
- uint32_t irq;
+ uint64_t soc_mmio_phys;
+ uint64_t uart_mmio_phys;
+ uint32_t irq;
} dcfg_soc_uart_t;
// for KDRV_ARM_PSCI
typedef struct {
- bool use_hvc;
- uint64_t shutdown_args[3];
- uint64_t reboot_args[3];
- uint64_t reboot_bootloader_args[3];
- uint64_t reboot_recovery_args[3];
+ bool use_hvc;
+ uint64_t shutdown_args[3];
+ uint64_t reboot_args[3];
+ uint64_t reboot_bootloader_args[3];
+ uint64_t reboot_recovery_args[3];
} dcfg_arm_psci_driver_t;
+typedef struct {
+ uint64_t soc_imem_phys;
+ uint64_t soc_imem_offset;
+} dcfg_msm_power_driver_t;
+
// for KDRV_ARM_GIC_V2
typedef struct {
- uint64_t mmio_phys;
- uint64_t msi_frame_phys;
- uint64_t gicd_offset;
- uint64_t gicc_offset;
- uint64_t gich_offset;
- uint64_t gicv_offset;
- uint32_t ipi_base;
- bool optional;
- bool use_msi;
+ uint64_t mmio_phys;
+ uint64_t msi_frame_phys;
+ uint64_t gicd_offset;
+ uint64_t gicc_offset;
+ uint64_t gich_offset;
+ uint64_t gicv_offset;
+ uint32_t ipi_base;
+ bool optional;
+ bool use_msi;
} dcfg_arm_gicv2_driver_t;
// for KDRV_ARM_GIC_V3
typedef struct {
- uint64_t mmio_phys;
- uint64_t gicd_offset;
- uint64_t gicr_offset;
- uint64_t gicr_stride;
- uint64_t mx8_gpr_phys;
- uint32_t ipi_base;
- bool optional;
+ uint64_t mmio_phys;
+ uint64_t gicd_offset;
+ uint64_t gicr_offset;
+ uint64_t gicr_stride;
+ uint64_t mx8_gpr_phys;
+ uint32_t ipi_base;
+ bool optional;
} dcfg_arm_gicv3_driver_t;
// for KDRV_ARM_GENERIC_TIMER
typedef struct {
- uint32_t irq_phys;
- uint32_t irq_virt;
- uint32_t irq_sphys;
- uint32_t freq_override;
+ uint32_t irq_phys;
+ uint32_t irq_virt;
+ uint32_t irq_sphys;
+ uint32_t freq_override;
} dcfg_arm_generic_timer_driver_t;
-// for KDRV_HISILICON_POWER
-typedef struct {
- uint64_t sctrl_phys;
- uint64_t pmu_phys;
-} dcfg_hisilicon_power_driver_t;
-
// for KDRV_AMLOGIC_HDCP
typedef struct {
- uint64_t preset_phys;
- uint64_t hiu_phys;
- uint64_t hdmitx_phys;
+ uint64_t preset_phys;
+ uint64_t hiu_phys;
+ uint64_t hdmitx_phys;
} dcfg_amlogic_hdcp_driver_t;
+
+// for KDRV_AMLOGIC_RNG
+typedef struct {
+ uint64_t rng_data_phys;
+ uint64_t rng_status_phys;
+ uint64_t rng_refresh_interval_usec;
+} dcfg_amlogic_rng_driver_t;
+
+// Defines a register write action for a generic kernel watchdog driver. An
+// action consists of the following steps.
+//
+// 1) Read from the register located a physical address |addr|
+// 2) Clear all of the bits in the value which was read using the |clr_mask|
+// 3) Set all of the bits in the value using the |set_mask|
+// 4) Write this value back to the address located at addr.
+//
+typedef struct {
+ uint64_t addr;
+ uint32_t clr_mask;
+ uint32_t set_mask;
+} dcfg_generic_32bit_watchdog_action_t;
+
+#define KDRV_GENERIC_32BIT_WATCHDOG_FLAG_ENABLED ((uint32_t)0x00000001)
+#define KDRV_GENERIC_32BIT_WATCHDOG_MIN_PERIOD ZX_MSEC(1)
+
+// Definitions of actions which may be taken by a generic 32 bit watchdog timer
+// kernel driver which may be passed by a bootloader. Field definitions are as
+// follows.
+//
+// |pet_action|
+// The address and masks needed to "pet" (aka, dismiss) a hardware watchdog timer.
+//
+// |enable_action|
+// The address and masks needed to enable a hardware watchdog timer. If enable
+// is an unsupported operation, the addr of the |enable_action| shall be zero.
+//
+// |disable_action|
+// The address and masks needed to disable a hardware watchdog timer. If
+// disable is an unsupported operation, the addr of the |disable_action| shall
+// be zero.
+//
+// |watchdog_period_nsec|
+// The period of the watchdog timer given in nanoseconds. When enabled, the
+// watchdog timer driver must pet the watch dog at least this often. The value
+// must be at least 1 mSec, typically much larger (on the order of a second or
+// two)
+//
+// |flags|
+// Storage for additional flags. Currently, only one flag is defined,
+// "FLAG_ENABLED". When this flag is set, it indicates that the watchdog timer
+// was left enabled by the bootloader at startup.
+typedef struct {
+ dcfg_generic_32bit_watchdog_action_t pet_action;
+ dcfg_generic_32bit_watchdog_action_t enable_action;
+ dcfg_generic_32bit_watchdog_action_t disable_action;
+ zx_duration_t watchdog_period_nsec;
+ uint32_t flags;
+} dcfg_generic_32bit_watchdog_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_DRIVER_CONFIG_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/e820.h b/arch/x64/sysroot/include/zircon/boot/e820.h
index fb8c340..f0f98f0 100644
--- a/arch/x64/sysroot/include/zircon/boot/e820.h
+++ b/arch/x64/sysroot/include/zircon/boot/e820.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_E820_H_
+#define SYSROOT_ZIRCON_BOOT_E820_H_
#include <stdint.h>
#include <zircon/compiler.h>
@@ -14,7 +15,9 @@
#define E820_UNUSABLE 5
typedef struct e820entry {
- uint64_t addr;
- uint64_t size;
- uint32_t type;
+ uint64_t addr;
+ uint64_t size;
+ uint32_t type;
} __PACKED e820entry_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_E820_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/image.h b/arch/x64/sysroot/include/zircon/boot/image.h
index de2411e..28663b6 100644
--- a/arch/x64/sysroot/include/zircon/boot/image.h
+++ b/arch/x64/sysroot/include/zircon/boot/image.h
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_IMAGE_H_
+#define SYSROOT_ZIRCON_BOOT_IMAGE_H_
+
+// This file contains assembly code that cannot be clang formatted.
+// clang-format off
#ifndef __ASSEMBLER__
#include <stdint.h>
#endif
+
// Zircon Boot Image format (ZBI).
//
// A Zircon Boot Image consists of a container header followed by boot
@@ -108,6 +113,7 @@
macro(ZBI_TYPE_DISCARD, "DISCARD", ".bin") \
macro(ZBI_TYPE_STORAGE_RAMDISK, "RAMDISK", ".bin") \
macro(ZBI_TYPE_STORAGE_BOOTFS, "BOOTFS", ".bin") \
+ macro(ZBI_TYPE_STORAGE_BOOTFS_FACTORY, "BOOTFS_FACTORY", ".bin") \
macro(ZBI_TYPE_CMDLINE, "CMDLINE", ".txt") \
macro(ZBI_TYPE_CRASHLOG, "CRASHLOG", ".bin") \
macro(ZBI_TYPE_NVRAM, "NVRAM", ".bin") \
@@ -121,12 +127,17 @@
macro(ZBI_TYPE_EFI_MEMORY_MAP, "EFI_MEMORY_MAP", ".bin") \
macro(ZBI_TYPE_EFI_SYSTEM_TABLE, "EFI_SYSTEM_TABLE", ".bin") \
macro(ZBI_TYPE_E820_TABLE, "E820_TABLE", ".bin") \
- macro(ZBI_TYPE_DEBUG_UART, "DEBUG_UART", ".bin") \
macro(ZBI_TYPE_FRAMEBUFFER, "FRAMEBUFFER", ".bin") \
macro(ZBI_TYPE_DRV_MAC_ADDRESS, "DRV_MAC_ADDRESS", ".bin") \
macro(ZBI_TYPE_DRV_PARTITION_MAP, "DRV_PARTITION_MAP", ".bin") \
- macro(ZBI_TYPE_BOOT_CONFIG, "BOOT_CONFIG", ".bin") \
- macro(ZBI_TYPE_BOOT_VERSION, "BOOT_VERSION", ".bin")
+ macro(ZBI_TYPE_DRV_BOARD_PRIVATE, "DRV_BOARD_PRIVATE", ".bin") \
+ macro(ZBI_TYPE_DRV_BOARD_INFO, "DRV_BOARD_INFO", ".bin") \
+ macro(ZBI_TYPE_IMAGE_ARGS, "IMAGE_ARGS", ".txt") \
+ macro(ZBI_TYPE_BOOT_VERSION, "BOOT_VERSION", ".bin") \
+ macro(ZBI_TYPE_HW_REBOOT_REASON, "HW_REBOOT_REASON", ".bin") \
+ macro(ZBI_TYPE_SERIAL_NUMBER, "SERIAL_NUMBER", ".txt") \
+ macro(ZBI_TYPE_BOOTLOADER_FILE, "BOOTLOADER_FILE", ".bin") \
+ macro(ZBI_TYPE_DEVICETREE, "DEVICETREE", ".dtb")
// Each ZBI starts with a container header.
// length: Total size of the image after this header.
@@ -197,12 +208,12 @@
// The kernel assumes it was loaded at a fixed physical address of
// 0x100000 (1MB). zbi_kernel_t.entry is the absolute physical address
// of the PC location where the kernel will start.
-// TODO(SEC-31): Perhaps this will change??
+// TODO(fxbug.dev/24762): Perhaps this will change??
// The processor is in 64-bit mode with direct virtual to physical
// mapping covering the physical memory where the kernel and
-// bootloader-constructed ZBI were loaded, which must be below 4GB.
-// The %rsi register (or %esi, since the high 32 bits must be zero)
-// holds the physical address of the bootloader-constructed ZBI.
+// bootloader-constructed ZBI were loaded.
+// The %rsi register holds the physical address of the
+// bootloader-constructed ZBI.
// All other registers are unspecified.
//
// ARM64
@@ -257,12 +268,29 @@
// The interpretation of the payload (after possible decompression) is
// indicated by the specific zbi_header_t.type value.
//
-// If ZBI_FLAG_STORAGE_COMPRESSED is set in zbi_header_t.flags, then the
-// payload is compressed with LZ4 and zbi_header_t.extra gives the exact
-// size of the decompressed payload. If ZBI_FLAG_STORAGE_COMPRESSED is
-// not set, then zbi_header_t.extra matches zbi_header_t.length.
+// **Note:** The ZBI_TYPE_STORAGE_* types are not a long-term stable ABI.
+// - Items of these types are always packed for a specific version of the
+// kernel and userland boot services, often in the same build that compiles
+// the kernel.
+// - These item types are **not** expected to be synthesized or
+// examined by boot loaders.
+// - New versions of the `zbi` tool will usually retain the ability to
+// read old formats and non-default switches to write old formats, for
+// diagnostic use.
//
-// TODO(mcgrathr): Document or point to the details of the LZ4 header format.
+// The zbi_header_t.extra field always gives the exact size of the
+// original, uncompressed payload. That equals zbi_header_t.length when
+// the payload is not compressed. If ZBI_FLAG_STORAGE_COMPRESSED is set in
+// zbi_header_t.flags, then the payload is compressed.
+//
+// **Note:** Magic-number and header bytes at the start of the compressed
+// payload indicate the compression algorithm and parameters. The set of
+// compression formats is not a long-term stable ABI.
+// - Zircon [userboot](../../../../docs/userboot.md) and core services
+// do the decompression. A given kernel build's `userboot` will usually
+// only support one particular compression format.
+// - The `zbi` tool will usually retain the ability to compress and
+// decompress for old formats, and can be used to convert between formats.
#define ZBI_FLAG_STORAGE_COMPRESSED (0x00000001)
// A virtual disk image. This is meant to be treated as if it were a
@@ -270,72 +298,14 @@
// the storage device, in whatever format that might be.
#define ZBI_TYPE_STORAGE_RAMDISK (0x4b534452) // RDSK
-// The /boot filesystem in BOOTFS format, specified below.
+// The /boot filesystem in BOOTFS format, specified in <zircon/boot/bootfs.h>.
// A complete ZBI must have exactly one ZBI_TYPE_STORAGE_BOOTFS item.
// Zircon [userboot](../../../../docs/userboot.md) handles the contents
// of this filesystem.
#define ZBI_TYPE_STORAGE_BOOTFS (0x42534642) // BFSB
-// The payload (after decompression) of an item in BOOTFS format consists
-// of separate "file" images that are each aligned to ZBI_BOOTFS_PAGE_SIZE
-// bytes from the beginning of the item payload. The first "file" consists
-// of a zbi_bootfs_header_t followed by directory entries.
-#define ZBI_BOOTFS_PAGE_SIZE (4096u)
-
-#define ZBI_BOOTFS_PAGE_ALIGN(size) \
- (((size) + ZBI_BOOTFS_PAGE_SIZE - 1) & -ZBI_BOOTFS_PAGE_SIZE)
-
-#ifndef __ASSEMBLER__
-typedef struct {
- // Must be ZBI_BOOTFS_MAGIC.
- uint32_t magic;
-
- // Size in bytes of all the directory entries.
- // Does not include the size of the zbi_bootfs_header_t.
- uint32_t dirsize;
-
- // Reserved for future use. Set to 0.
- uint32_t reserved0;
- uint32_t reserved1;
-} zbi_bootfs_header_t;
-#endif
-
-// LSW of sha256("bootfs")
-#define ZBI_BOOTFS_MAGIC (0xa56d3ff9)
-
-// Each directory entry holds a pathname and gives the offset and size
-// of the contents of the file by that name.
-#ifndef __ASSEMBLER__
-typedef struct {
- // Length of the name[] field at the end. This length includes the
- // NUL terminator, which must be present, but does not include any
- // alignment padding required before the next directory entry.
- uint32_t name_len;
-
- // Length of the file in bytes. This is an exact size that is not
- // rounded, though the file is always padded with zeros up to a
- // multiple of ZBI_BOOTFS_PAGE_SIZE.
- uint32_t data_len;
-
- // Offset from the beginning of the payload (zbi_bootfs_header_t) to
- // the file's data. This must be a multiple of ZBI_BOOTFS_PAGE_SIZE.
- uint32_t data_off;
-
- // Pathname of the file, a UTF-8 string. This must include a NUL
- // terminator at the end. It must not begin with a '/', but it may
- // contain '/' separators for subdirectories.
- char name[];
-} zbi_bootfs_dirent_t;
-#endif
-
-// Each directory entry has a variable size of [16,268] bytes that
-// must be a multiple of 4 bytes.
-#define ZBI_BOOTFS_DIRENT_SIZE(name_len) \
- ((sizeof(zbi_bootfs_dirent_t) + (name_len) + 3) & -(size_t)4)
-
-// zbi_bootfs_dirent_t.name_len must be > 1 and <= ZBI_BOOTFS_MAX_NAME_LEN.
-#define ZBI_BOOTFS_MAX_NAME_LEN (256)
-
+// Device-specific factory data, stored in BOOTFS format, specified below.
+#define ZBI_TYPE_STORAGE_BOOTFS_FACTORY (0x46534642) // BFSF
// The remaining types are used to communicate information from the boot
// loader to the kernel. Usually these are synthesized in memory by the
@@ -380,6 +350,14 @@
} zbi_platform_id_t;
#endif
+#define ZBI_TYPE_DRV_BOARD_INFO (0x4953426D) // mBSI
+// Board-specific information.
+#ifndef __ASSEMBLER__
+typedef struct {
+ uint32_t revision;
+} zbi_board_info_t;
+#endif
+
// CPU configuration, a zbi_cpu_config_t header followed by one or more
// zbi_cpu_cluster_t entries. zbi_header_t.length must equal
// zbi_cpu_config_t.cluster_count * sizeof(zbi_cpu_cluster_t).
@@ -447,7 +425,9 @@
} zbi_topology_arm_info_t;
typedef struct {
- uint32_t apic_id;
+ // Indexes here correspond to the logical_ids index for the thread.
+ uint32_t apic_ids[ZBI_MAX_SMT];
+ uint32_t apic_id_count;
} zbi_topology_x86_info_t;
typedef struct {
@@ -467,14 +447,33 @@
} zbi_topology_processor_t;
typedef struct {
- // Relative performance level of this processor in the system, with 0
- // representing the lowest performance.
- // For example on a two cluster ARM big.LITTLE system 0 would be the little
- // cores and 1 would represent the big cores.
+ // Relative performance level of this processor in the system. The value is
+ // interpreted as the performance of this processor relative to the maximum
+ // performance processor in the system. No specific values are required for
+ // the performance level, only that the following relationship holds:
+ //
+ // Pmax is the value of performance_class for the maximum performance
+ // processor in the system, operating at its maximum operating point.
+ //
+ // P is the value of performance_class for this processor, operating at
+ // its maximum operating point.
+ //
+ // R is the performance ratio of this processor to the maximum performance
+ // processor in the system in the range (0.0, 1.0].
+ //
+ // R = (P + 1) / (Pmax + 1)
+ //
+ // If accuracy is limited, choose a conservative value that slightly under-
+ // estimates the performance of lower-performance processors.
uint8_t performance_class;
} zbi_topology_cluster_t;
typedef struct {
+ // Unique id of this cache node. No other semantics are assumed.
+ uint32_t cache_id;
+} zbi_topology_cache_t;
+
+typedef struct {
// Starting and ending memory addresses of this numa region.
uint64_t start_address;
uint64_t end_address;
@@ -499,6 +498,7 @@
zbi_topology_processor_t processor;
zbi_topology_cluster_t cluster;
zbi_topology_numa_region_t numa_region;
+ zbi_topology_cache_t cache;
} entity;
} zbi_topology_node_t;
@@ -544,29 +544,18 @@
#define ZIRCON_VENDOR_GUID \
{0x82305eb2, 0xd39e, 0x4575, {0xa0, 0xc8, 0x6c, 0x20, 0x72, 0xd0, 0x84, 0x4c}}
#define ZIRCON_CRASHLOG_EFIVAR \
- { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 };
+ { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 }
#define ZIRCON_CRASHLOG_EFIATTR \
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
-// Debug serial port, a zbi_uart_t entry.
-#define ZBI_TYPE_DEBUG_UART (0x54524155) // UART
-#ifndef __ASSEMBLER__
-typedef struct {
- uint64_t base;
- uint32_t type;
- uint32_t irq;
-} zbi_uart_t;
-#endif
-#define ZBI_UART_NONE (0)
-#define ZBI_UART_PC_PORT (1)
-#define ZBI_UART_PC_MMIO (2)
-
// Framebuffer parameters, a zbi_swfb_t entry.
#define ZBI_TYPE_FRAMEBUFFER (0x42465753) // SWFB
-// A copy of the boot configuration stored as a kvstore
-// within the sysconfig partition.
-#define ZBI_TYPE_BOOT_CONFIG (0x47464342) // BCFG
+// The image arguments, data is a trivial text format of one "key=value" per line
+// with leading whitespace stripped and "#" comment lines and blank lines ignored.
+// It is processed by bootsvc and parsed args are shared to others via Arguments service.
+// TODO: the format can be streamlined after the /config/devmgr compat support is removed.
+#define ZBI_TYPE_IMAGE_ARGS (0x47524149) // IARG
// A copy of the boot version stored within the sysconfig
// partition
@@ -602,6 +591,10 @@
#define ZBI_TYPE_DRV_PARTITION_MAP (0x5452506D) // mPRT
#define ZBI_PARTITION_NAME_LEN (32)
#define ZBI_PARTITION_GUID_LEN (16)
+
+// Private information for the board driver.
+#define ZBI_TYPE_DRV_BOARD_PRIVATE (0x524F426D) // mBOR
+
#ifndef __ASSEMBLER__
typedef struct {
// GUID specifying the format and use of data stored in the partition.
@@ -639,3 +632,50 @@
zbi_partition_t partitions[];
} zbi_partition_map_t;
#endif
+
+
+#define ZBI_TYPE_HW_REBOOT_REASON (0x42525748) // HWRB
+
+#define ZBI_HW_REBOOT_UNDEFINED ((uint32_t)0)
+#define ZBI_HW_REBOOT_COLD ((uint32_t)1)
+#define ZBI_HW_REBOOT_WARM ((uint32_t)2)
+#define ZBI_HW_REBOOT_BROWNOUT ((uint32_t)3)
+#define ZBI_HW_REBOOT_WATCHDOG ((uint32_t)4)
+
+#ifndef __ASSEMBLER__
+#ifndef __cplusplus
+typedef uint32_t zbi_hw_reboot_reason_t;
+#else
+enum class ZbiHwRebootReason : uint32_t {
+ Undefined = ZBI_HW_REBOOT_UNDEFINED,
+ Cold = ZBI_HW_REBOOT_COLD,
+ Warm = ZBI_HW_REBOOT_WARM,
+ Brownout = ZBI_HW_REBOOT_BROWNOUT,
+ Watchdog = ZBI_HW_REBOOT_WATCHDOG,
+};
+using zbi_hw_reboot_reason_t = ZbiHwRebootReason;
+#endif // __cplusplus
+#endif // __ASSEMBLER__
+
+// The serial number, an unterminated ASCII string of printable non-whitespace
+// characters with length zbi_header_t.length.
+#define ZBI_TYPE_SERIAL_NUMBER (0x4e4c5253) // SRLN
+
+// This type specifies a binary file passed in by the bootloader.
+// The first byte specifies the length of the filename without a NUL terminator.
+// The filename starts on the second byte.
+// The file contents are located immediately after the filename.
+//
+// Layout: | name_len | name | payload
+// ^(1 byte) ^(name_len bytes) ^(length of file)
+#define ZBI_TYPE_BOOTLOADER_FILE (0x4C465442) // BTFL
+
+// The devicetree blob from the legacy boot loader, if any. This is used only
+// for diagnostic and development purposes. Zircon kernel and driver
+// configuration is entirely driven by specific ZBI items from the boot
+// loader. The boot shims for legacy boot loaders pass the raw devicetree
+// along for development purposes, but extract information from it to populate
+// specific ZBI items such as ZBI_TYPE_KERNEL_DRIVER et al.
+#define ZBI_TYPE_DEVICETREE (0xd00dfeed)
+
+#endif // SYSROOT_ZIRCON_BOOT_IMAGE_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/multiboot.h b/arch/x64/sysroot/include/zircon/boot/multiboot.h
index 0076832..85cf0a6 100644
--- a/arch/x64/sysroot/include/zircon/boot/multiboot.h
+++ b/arch/x64/sysroot/include/zircon/boot/multiboot.h
@@ -1,23 +1,22 @@
-// Copyright 2016 The Fuchsia Authors
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Copyright (c) 2009 Corey Tabaka
-//
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file or at
-// https://opensource.org/licenses/MIT
-#ifndef __PLATFORM_MULTIBOOT_H
-#define __PLATFORM_MULTIBOOT_H
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_MULTIBOOT_H_
+#define SYSROOT_ZIRCON_MULTIBOOT_H_
/* magic number for multiboot header */
-#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
// Flags for multiboot header:
// 0x00000002: Boot loader should provide memory map.
// 0x00010000: *_addr fields in multiboot_header_t are used.
-#define MULTIBOOT_HEADER_FLAGS 0x00010002
+#define MULTIBOOT_HEADER_FLAGS 0x00010002
/* magic number passed by multiboot-compliant boot loaders */
-#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
+#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
#ifndef __ASSEMBLER__
@@ -25,52 +24,52 @@
/* multiboot header */
typedef struct multiboot_header {
- uint32_t magic;
- uint32_t flags;
- uint32_t checksum;
- uint32_t header_addr;
- uint32_t load_addr;
- uint32_t load_end_addr;
- uint32_t bss_end_addr;
- uint32_t entry_addr;
+ uint32_t magic;
+ uint32_t flags;
+ uint32_t checksum;
+ uint32_t header_addr;
+ uint32_t load_addr;
+ uint32_t load_end_addr;
+ uint32_t bss_end_addr;
+ uint32_t entry_addr;
} multiboot_header_t;
/* symbol table for a.out */
typedef struct aout_symbol_table {
- uint32_t tabsize;
- uint32_t strsize;
- uint32_t addr;
- uint32_t reserved;
+ uint32_t tabsize;
+ uint32_t strsize;
+ uint32_t addr;
+ uint32_t reserved;
} aout_symbol_table_t;
/* section header table for ELF */
typedef struct elf_section_header_table {
- uint32_t num;
- uint32_t size;
- uint32_t addr;
- uint32_t shndx;
+ uint32_t num;
+ uint32_t size;
+ uint32_t addr;
+ uint32_t shndx;
} elf_section_header_table_t;
/* multiboot info */
typedef struct multiboot_info {
- uint32_t flags;
- uint32_t mem_lower;
- uint32_t mem_upper;
- uint32_t boot_device;
- uint32_t cmdline;
- uint32_t mods_count;
- uint32_t mods_addr;
- union {
- aout_symbol_table_t aout_sym;
- elf_section_header_table_t elf_sec;
- } u;
- uint32_t mmap_length;
- uint32_t mmap_addr;
- uint32_t drives_length;
- uint32_t drives_addr;
- uint32_t config_table;
- uint32_t boot_loader_name;
- uint32_t apm_table;
+ uint32_t flags;
+ uint32_t mem_lower;
+ uint32_t mem_upper;
+ uint32_t boot_device;
+ uint32_t cmdline;
+ uint32_t mods_count;
+ uint32_t mods_addr;
+ union {
+ aout_symbol_table_t aout_sym;
+ elf_section_header_table_t elf_sec;
+ } u;
+ uint32_t mmap_length;
+ uint32_t mmap_addr;
+ uint32_t drives_length;
+ uint32_t drives_addr;
+ uint32_t config_table;
+ uint32_t boot_loader_name;
+ uint32_t apm_table;
} multiboot_info_t;
#define MB_INFO_MEM_SIZE 0x001
@@ -88,20 +87,20 @@
/* module structure */
typedef struct module {
- uint32_t mod_start;
- uint32_t mod_end;
- uint32_t string;
- uint32_t reserved;
+ uint32_t mod_start;
+ uint32_t mod_end;
+ uint32_t string;
+ uint32_t reserved;
} module_t;
/* memory map - be careful that the offset 0 is base_addr_low without size */
typedef struct memory_map {
- uint32_t size;
- uint32_t base_addr_low;
- uint32_t base_addr_high;
- uint32_t length_low;
- uint32_t length_high;
- uint32_t type;
+ uint32_t size;
+ uint32_t base_addr_low;
+ uint32_t base_addr_high;
+ uint32_t length_low;
+ uint32_t length_high;
+ uint32_t type;
} memory_map_t;
/* memory map entry types */
@@ -112,4 +111,4 @@
#endif
-#endif
+#endif // SYSROOT_ZIRCON_BOOT_MULTIBOOT_
diff --git a/arch/x64/sysroot/include/zircon/boot/netboot.h b/arch/x64/sysroot/include/zircon/boot/netboot.h
index 25973c6..1586352 100644
--- a/arch/x64/sysroot/include/zircon/boot/netboot.h
+++ b/arch/x64/sysroot/include/zircon/boot/netboot.h
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_NETBOOT_H_
+#define SYSROOT_ZIRCON_BOOT_NETBOOT_H_
#include <stddef.h>
#include <stdint.h>
+#include <zircon/types.h>
// clang-format off
-#define BOOTLOADER_VERSION "0.7.13"
+#define BOOTLOADER_VERSION "0.7.22"
#define NB_MAGIC 0xAA774217
#define NB_DEBUGLOG_MAGIC 0xAEAE1123
@@ -34,6 +36,7 @@
#define NB_CLOSE 10 // arg=0
#define NB_LAST_DATA 11 // arg=offset, data=data
#define NB_REBOOT 12 // arg=0
+#define NB_GET_ADVERT 13 // arg=0
#define NB_ACK 0 // arg=0 or -err, NB_READ: data=data
#define NB_FILE_RECEIVED 0x70000001 // arg=size
@@ -62,10 +65,17 @@
#define NB_FVM_FILENAME NB_IMAGE_PREFIX NB_FVM_HOST_FILENAME
#define NB_BOOTLOADER_HOST_FILENAME "bootloader.img"
#define NB_BOOTLOADER_FILENAME NB_IMAGE_PREFIX NB_BOOTLOADER_HOST_FILENAME
-#define NB_EFI_HOST_FILENAME "efi.img"
-#define NB_EFI_FILENAME NB_IMAGE_PREFIX NB_EFI_HOST_FILENAME
-#define NB_KERNC_HOST_FILENAME "kernc.img"
-#define NB_KERNC_FILENAME NB_IMAGE_PREFIX NB_KERNC_HOST_FILENAME
+// Firmware images are slightly different, as they have an optional type suffix:
+// firmware_ <- type = "" (the default)
+// firmware_foo <- type = "foo"
+#define NB_FIRMWARE_HOST_FILENAME_PREFIX "firmware_"
+#define NB_FIRMWARE_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWARE_HOST_FILENAME_PREFIX
+#define NB_FIRMWAREA_HOST_FILENAME_PREFIX "firmwarea_"
+#define NB_FIRMWAREA_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWAREA_HOST_FILENAME_PREFIX
+#define NB_FIRMWAREB_HOST_FILENAME_PREFIX "firmwareb_"
+#define NB_FIRMWAREB_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWAREB_HOST_FILENAME_PREFIX
+#define NB_FIRMWARER_HOST_FILENAME_PREFIX "firmwarer_"
+#define NB_FIRMWARER_FILENAME_PREFIX NB_IMAGE_PREFIX NB_FIRMWARER_HOST_FILENAME_PREFIX
#define NB_ZIRCONA_HOST_FILENAME "zircona.img"
#define NB_ZIRCONA_FILENAME NB_IMAGE_PREFIX NB_ZIRCONA_HOST_FILENAME
#define NB_ZIRCONB_HOST_FILENAME "zirconb.img"
@@ -76,8 +86,36 @@
#define NB_VBMETAA_FILENAME NB_IMAGE_PREFIX NB_VBMETAA_HOST_FILENAME
#define NB_VBMETAB_HOST_FILENAME "vbmetab.img"
#define NB_VBMETAB_FILENAME NB_IMAGE_PREFIX NB_VBMETAB_HOST_FILENAME
+#define NB_VBMETAR_HOST_FILENAME "vbmetar.img"
+#define NB_VBMETAR_FILENAME NB_IMAGE_PREFIX NB_VBMETAR_HOST_FILENAME
#define NB_SSHAUTH_HOST_FILENAME "authorized_keys"
#define NB_SSHAUTH_FILENAME NB_IMAGE_PREFIX NB_SSHAUTH_HOST_FILENAME
+#define NB_BOARD_NAME_HOST_FILENAME "board_name"
+#define NB_BOARD_NAME_FILENAME NB_IMAGE_PREFIX NB_BOARD_NAME_HOST_FILENAME
+#define NB_BOARD_REVISION_HOST_FILENAME "board_revision"
+#define NB_BOARD_REVISION_FILENAME NB_IMAGE_PREFIX NB_BOARD_REVISION_HOST_FILENAME
+#define NB_BOARD_INFO_HOST_FILENAME "board_info"
+#define NB_BOARD_INFO_FILENAME NB_IMAGE_PREFIX NB_BOARD_INFO_HOST_FILENAME
+#define NB_INIT_PARTITION_TABLES_HOST_FILENAME "init_partition_tables"
+#define NB_INIT_PARTITION_TABLES_FILENAME NB_IMAGE_PREFIX NB_INIT_PARTITION_TABLES_HOST_FILENAME
+#define NB_WIPE_PARTITION_TABLES_HOST_FILENAME "wipe_partition_tables"
+#define NB_WIPE_PARTITION_TABLES_FILENAME NB_IMAGE_PREFIX NB_WIPE_PARTITION_TABLES_HOST_FILENAME
+
+// Should match paver FIDL definition.
+// Length does not include the '\0' terminator, so when allocating a character
+// buffer to hold the type use (NB_FIRMWARE_TYPE_MAX_LENGTH + 1).
+#define NB_FIRMWARE_TYPE_MAX_LENGTH 256
+
+typedef struct board_info {
+ char board_name[ZX_MAX_NAME_LEN];
+ uint32_t board_revision;
+ uint8_t mac_address[8];
+} board_info_t;
+
+typedef struct modify_partition_table_info {
+ // Path of block device to initialize or wipe.
+ char block_device_path[ZX_MAX_NAME_LEN + 1];
+} modify_partition_table_info_t;
typedef struct nbmsg_t {
uint32_t magic;
@@ -114,3 +152,5 @@
char nodename[MAX_NODENAME_LENGTH];
char data[MAX_LOG_DATA];
} logpacket_t;
+
+#endif // SYSROOT_ZIRCON_BOOT_NETBOOT_H_
diff --git a/arch/x64/sysroot/include/zircon/boot/sysconfig.h b/arch/x64/sysroot/include/zircon/boot/sysconfig.h
index fe59efa..1f7d49b 100644
--- a/arch/x64/sysroot/include/zircon/boot/sysconfig.h
+++ b/arch/x64/sysroot/include/zircon/boot/sysconfig.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
+#define SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
// Zircon sysconfig partition format
//
@@ -19,8 +20,10 @@
// If present, this overrides boot-default, and the bootloader
// deletes this section after use.
-#define ZX_SYSCONFIG_KVSTORE_SIZE 32768
-#define ZX_SYSCONFIG_VERSION_A_OFFSET (0 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_VERSION_B_OFFSET (1 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_BOOT_DEFAULT_OFFSET (2 * ZX_SYSCONFIG_KVSTORE_SIZE)
-#define ZX_SYSCONFIG_BOOT_ONESHOT_OFFSET (3 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_KVSTORE_SIZE 32768
+#define ZX_SYSCONFIG_VERSION_A_OFFSET (0 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_VERSION_B_OFFSET (1 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_BOOT_DEFAULT_OFFSET (2 * ZX_SYSCONFIG_KVSTORE_SIZE)
+#define ZX_SYSCONFIG_BOOT_ONESHOT_OFFSET (3 * ZX_SYSCONFIG_KVSTORE_SIZE)
+
+#endif // SYSROOT_ZIRCON_BOOT_SYSCONFIG_H_
diff --git a/arch/x64/sysroot/include/zircon/compiler.h b/arch/x64/sysroot/include/zircon/compiler.h
index fb3bb42..ce2bcea 100644
--- a/arch/x64/sysroot/include/zircon/compiler.h
+++ b/arch/x64/sysroot/include/zircon/compiler.h
@@ -2,7 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_COMPILER_H_
+#define SYSROOT_ZIRCON_COMPILER_H_
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(x) 0
+#endif
#ifndef __ASSEMBLER__
@@ -10,14 +19,14 @@
#error "Unrecognized compiler!"
#endif
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
#define __UNUSED __attribute__((__unused__))
#define __USED __attribute__((__used__))
#define __PACKED __attribute__((packed))
#define __ALIGNED(x) __attribute__((aligned(x)))
-#define __PRINTFLIKE(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))
-#define __SCANFLIKE(__fmt,__varargs) __attribute__((__format__ (__scanf__, __fmt, __varargs)))
+#define __PRINTFLIKE(__fmt, __varargs) __attribute__((__format__(__printf__, __fmt, __varargs)))
+#define __SCANFLIKE(__fmt, __varargs) __attribute__((__format__(__scanf__, __fmt, __varargs)))
#define __SECTION(x) __attribute__((__section__(x)))
#define __PURE __attribute__((__pure__))
#define __CONST __attribute__((__const__))
@@ -39,18 +48,21 @@
#define __LEAF_FN __attribute__((__leaf__))
#define __OPTIMIZE(x) __attribute__((__optimize__(x)))
#define __EXTERNALLY_VISIBLE __attribute__((__externally_visible__))
-#define __THREAD_ANNOTATION(x)
#define __NO_SAFESTACK
+#define __THREAD_ANNOTATION(x)
#else
#define __LEAF_FN
#define __OPTIMIZE(x)
#define __EXTERNALLY_VISIBLE
+// The thread safety annotations are frequently used with C++ standard library
+// types in userspace, so only enable the annotations if we know that the C++
+// standard library types are annotated or if we're in kernel code.
+#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) || defined(_KERNEL)
#define __THREAD_ANNOTATION(x) __attribute__((x))
-#define __NO_SAFESTACK __attribute__((__no_sanitize__("safe-stack")))
-#endif
-
-#ifndef __has_feature
-#define __has_feature(x) 0
+#else
+#define __THREAD_ANNOTATION(x)
+#endif // _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+#define __NO_SAFESTACK __attribute__((__no_sanitize__("safe-stack", "shadow-call-stack")))
#endif
#define __ALWAYS_INLINE __attribute__((__always_inline__))
@@ -60,19 +72,51 @@
#define __UNREACHABLE __builtin_unreachable()
#define __WEAK_ALIAS(x) __attribute__((__weak__, __alias__(x)))
#define __ALIAS(x) __attribute__((__alias__(x)))
-#define __EXPORT __attribute__ ((__visibility__("default")))
-#define __LOCAL __attribute__ ((__visibility__("hidden")))
+#define __EXPORT __attribute__((__visibility__("default")))
+#define __LOCAL __attribute__((__visibility__("hidden")))
#define __THREAD __thread
#define __offsetof(type, field) __builtin_offsetof(type, field)
+// Only define __NO_UNIQUE_ADDRESS for C++, since it doesn't make sense in C.
+#ifdef __cplusplus
+#if __has_cpp_attribute(no_unique_address)
+#define __NO_UNIQUE_ADDRESS [[no_unique_address]]
+#else
+#define __NO_UNIQUE_ADDRESS
+#endif
+#endif // ifdef __cplusplus
+
#if defined(__cplusplus) && __cplusplus >= 201703L
#define __FALLTHROUGH [[fallthrough]]
#elif defined(__cplusplus) && defined(__clang__)
#define __FALLTHROUGH [[clang::fallthrough]]
-#elif __GNUC__ >= 7
+// The GNU style attribute is supported by Clang for C code, but __GNUC__ for
+// clang right now is 4.
+#elif __GNUC__ >= 7 || (!defined(__cplusplus) && defined(__clang__))
#define __FALLTHROUGH __attribute__((__fallthrough__))
#else
-#define __FALLTHROUGH do {} while (0)
+#define __FALLTHROUGH \
+ do { \
+ } while (0)
+#endif
+
+// C++17 onwards supports [[nodiscard]] on a constructor, warning if
+// a temporary object is created without a name. Such objects would be
+// immediately destroyed again, while the user's expectation might be
+// that it would last the scope.
+//
+// We could ideally just use [[nodiscard]] (or __WARN_UNUSED_RESULT)
+// directly, except GCC < 10.0 has a bug preventing it from being used
+// on constructors. __WARN_UNUSED_CONSTRUCTOR allows us to tag
+// constructors in supported compilers, and is simply ignored in older
+// compilers.
+#if defined(__cplusplus)
+// Clang and GCC versions >= 10.0 support [[nodiscard]] on constructors.
+#if __cplusplus >= 201703L && (defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 10)))
+#define __WARN_UNUSED_CONSTRUCTOR [[nodiscard]]
+#else
+#define __WARN_UNUSED_CONSTRUCTOR
+#endif
#endif
// Publicly exposed thread annotation macros. These have a long and ugly name to
@@ -80,12 +124,17 @@
#define __TA_CAPABILITY(x) __THREAD_ANNOTATION(__capability__(x))
#define __TA_GUARDED(x) __THREAD_ANNOTATION(__guarded_by__(x))
#define __TA_ACQUIRE(...) __THREAD_ANNOTATION(__acquire_capability__(__VA_ARGS__))
+#define __TA_ACQUIRE_SHARED(...) __THREAD_ANNOTATION(__acquire_shared_capability__(__VA_ARGS__))
#define __TA_TRY_ACQUIRE(...) __THREAD_ANNOTATION(__try_acquire_capability__(__VA_ARGS__))
#define __TA_ACQUIRED_BEFORE(...) __THREAD_ANNOTATION(__acquired_before__(__VA_ARGS__))
#define __TA_ACQUIRED_AFTER(...) __THREAD_ANNOTATION(__acquired_after__(__VA_ARGS__))
#define __TA_RELEASE(...) __THREAD_ANNOTATION(__release_capability__(__VA_ARGS__))
+#define __TA_RELEASE_SHARED(...) __THREAD_ANNOTATION(__release_shared_capability__(__VA_ARGS__))
#define __TA_REQUIRES(...) __THREAD_ANNOTATION(__requires_capability__(__VA_ARGS__))
+#define __TA_REQUIRES_SHARED(...) __THREAD_ANNOTATION(__requires_shared_capability__(__VA_ARGS__))
#define __TA_EXCLUDES(...) __THREAD_ANNOTATION(__locks_excluded__(__VA_ARGS__))
+#define __TA_ASSERT(...) __THREAD_ANNOTATION(__assert_capability__(__VA_ARGS__))
+#define __TA_ASSERT_SHARED(...) __THREAD_ANNOTATION(__assert_shared_capability__(__VA_ARGS__))
#define __TA_RETURN_CAPABILITY(x) __THREAD_ANNOTATION(__lock_returned__(x))
#define __TA_SCOPED_CAPABILITY __THREAD_ANNOTATION(__scoped_lockable__)
#define __TA_NO_THREAD_SAFETY_ANALYSIS __THREAD_ANNOTATION(__no_thread_safety_analysis__)
@@ -103,8 +152,8 @@
/* CPP header guards */
#ifdef __cplusplus
-#define __BEGIN_CDECLS extern "C" {
-#define __END_CDECLS }
+#define __BEGIN_CDECLS extern "C" {
+#define __END_CDECLS }
#else
#define __BEGIN_CDECLS
#define __END_CDECLS
@@ -120,3 +169,23 @@
#define add_overflow(a, b, c) __builtin_add_overflow(a, b, c)
#define sub_overflow(a, b, c) __builtin_sub_overflow(a, b, c)
#define mul_overflow(a, b, c) __builtin_mul_overflow(a, b, c)
+
+// A workaround to help static analyzer identify assertion failures
+#if defined(__clang__)
+#define __ANALYZER_CREATE_SINK __attribute__((analyzer_noreturn))
+#else
+#define __ANALYZER_CREATE_SINK // no-op
+#endif
+
+// Lifetime analysis
+#ifndef __OWNER
+#ifdef __clang__
+#define __OWNER(x) [[gsl::Owner(x)]]
+#define __POINTER(x) [[gsl::Pointer(x)]]
+#else
+#define __OWNER(x)
+#define __POINTER(x)
+#endif
+#endif
+
+#endif // SYSROOT_ZIRCON_COMPILER_H_
diff --git a/arch/x64/sysroot/include/zircon/device/audio.h b/arch/x64/sysroot/include/zircon/device/audio.h
new file mode 100644
index 0000000..01b966e
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/device/audio.h
@@ -0,0 +1,467 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_DEVICE_AUDIO_H_
+#define SYSROOT_ZIRCON_DEVICE_AUDIO_H_
+
+#include <sys/types.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+#include <cassert>
+#include <cstdio>
+
+// When communicating with an Audio driver using zx_channel_call, do not use
+// the AUDIO_INVALID_TRANSACTION_ID as your message's transaction ID. It is
+// reserved for async notifications sent from the driver to the application.
+#define AUDIO_INVALID_TRANSACTION_ID ((zx_txid_t)0)
+
+__BEGIN_CDECLS
+
+typedef uint32_t audio_cmd_t;
+
+// Commands sent on the stream channel
+#define AUDIO_STREAM_CMD_GET_FORMATS ((audio_cmd_t)0x1000)
+#define AUDIO_STREAM_CMD_SET_FORMAT ((audio_cmd_t)0x1001)
+#define AUDIO_STREAM_CMD_GET_GAIN ((audio_cmd_t)0x1002)
+#define AUDIO_STREAM_CMD_SET_GAIN ((audio_cmd_t)0x1003)
+#define AUDIO_STREAM_CMD_PLUG_DETECT ((audio_cmd_t)0x1004)
+#define AUDIO_STREAM_CMD_GET_UNIQUE_ID ((audio_cmd_t)0x1005)
+#define AUDIO_STREAM_CMD_GET_STRING ((audio_cmd_t)0x1006)
+#define AUDIO_STREAM_CMD_GET_CLOCK_DOMAIN ((audio_cmd_t)0x1007)
+
+// Async notifications sent on the stream channel.
+#define AUDIO_STREAM_PLUG_DETECT_NOTIFY ((audio_cmd_t)0x2000)
+
+// Commands sent on the ring buffer channel
+#define AUDIO_RB_CMD_GET_FIFO_DEPTH ((audio_cmd_t)0x3000)
+#define AUDIO_RB_CMD_GET_BUFFER ((audio_cmd_t)0x3001)
+#define AUDIO_RB_CMD_START ((audio_cmd_t)0x3002)
+#define AUDIO_RB_CMD_STOP ((audio_cmd_t)0x3003)
+
+// Async notifications sent on the ring buffer channel.
+#define AUDIO_RB_POSITION_NOTIFY ((audio_cmd_t)0x4000)
+
+// Flags used to modify commands.
+// The NO_ACK flag can be used with the SET_GAIN and PLUG_DETECT commands.
+#define AUDIO_FLAG_NO_ACK ((audio_cmd_t)0x80000000)
+
+typedef struct audio_cmd_hdr {
+ zx_txid_t transaction_id;
+ audio_cmd_t cmd;
+} audio_cmd_hdr_t;
+
+static_assert(sizeof(audio_cmd_hdr_t) == 8,
+ "audio_cmd_hdr_t should be 8 bytes! "
+ "If sizeof(zx_txid_t has changed from 4 to 8, "
+ "consider repacking the structs in audio.h");
+
+// audio_sample_format_t
+//
+// Bitfield which describes audio sample format as they reside in memory.
+//
+typedef uint32_t audio_sample_format_t;
+#define AUDIO_SAMPLE_FORMAT_BITSTREAM ((audio_sample_format_t)(1u << 0))
+#define AUDIO_SAMPLE_FORMAT_8BIT ((audio_sample_format_t)(1u << 1))
+#define AUDIO_SAMPLE_FORMAT_16BIT ((audio_sample_format_t)(1u << 2))
+#define AUDIO_SAMPLE_FORMAT_20BIT_PACKED ((audio_sample_format_t)(1u << 4))
+#define AUDIO_SAMPLE_FORMAT_24BIT_PACKED ((audio_sample_format_t)(1u << 5))
+#define AUDIO_SAMPLE_FORMAT_20BIT_IN32 ((audio_sample_format_t)(1u << 6))
+#define AUDIO_SAMPLE_FORMAT_24BIT_IN32 ((audio_sample_format_t)(1u << 7))
+#define AUDIO_SAMPLE_FORMAT_32BIT ((audio_sample_format_t)(1u << 8))
+#define AUDIO_SAMPLE_FORMAT_32BIT_FLOAT ((audio_sample_format_t)(1u << 9))
+#define AUDIO_SAMPLE_FORMAT_FLAG_UNSIGNED ((audio_sample_format_t)(1u << 30))
+#define AUDIO_SAMPLE_FORMAT_FLAG_INVERT_ENDIAN ((audio_sample_format_t)(1u << 31))
+#define AUDIO_SAMPLE_FORMAT_FLAG_MASK \
+ ((audio_sample_format_t)(AUDIO_SAMPLE_FORMAT_FLAG_UNSIGNED | \
+ AUDIO_SAMPLE_FORMAT_FLAG_INVERT_ENDIAN))
+
+// audio_stream_format_range_t
+//
+// A structure used along with the AUDIO_STREAM_CMD_GET_FORMATS command in order
+// to describe the formats supported by an audio stream.
+#define ASF_RANGE_FLAG_FPS_CONTINUOUS ((uint16_t)(1u << 0))
+#define ASF_RANGE_FLAG_FPS_48000_FAMILY ((uint16_t)(1u << 1))
+#define ASF_RANGE_FLAG_FPS_44100_FAMILY ((uint16_t)(1u << 2))
+typedef struct audio_stream_format_range {
+ audio_sample_format_t sample_formats;
+ uint32_t min_frames_per_second;
+ uint32_t max_frames_per_second;
+ uint8_t min_channels;
+ uint8_t max_channels;
+ uint16_t flags;
+} __PACKED audio_stream_format_range_t;
+
+static_assert(sizeof(audio_stream_format_range_t) == 16,
+ "audio_stream_format_range_t should be 16 bytes!");
+
+// audio_set_gain_flags_t
+//
+// Flags used by the AUDIO_STREAM_CMD_SET_GAIN message.
+//
+typedef uint32_t audio_set_gain_flags_t;
+#define AUDIO_SGF_MUTE_VALID \
+ ((audio_set_gain_flags_t)0x1) // Whether or not the mute flag is valid.
+#define AUDIO_SGF_AGC_VALID ((audio_set_gain_flags_t)0x2) // Whether or not the agc flag is valid.
+#define AUDIO_SGF_GAIN_VALID \
+ ((audio_set_gain_flags_t)0x4) // Whether or not the gain float is valid.
+#define AUDIO_SGF_MUTE ((audio_set_gain_flags_t)0x40000000) // Whether or not to mute the stream.
+#define AUDIO_SGF_AGC \
+ ((audio_set_gain_flags_t)0x80000000) // Whether or not enable AGC for the stream.
+
+// audio_pd_flags_t
+//
+// Flags used by AUDIO_STREAM_CMD_PLUG_DETECT commands to enable or disable
+// asynchronous plug detect notifications.
+//
+typedef uint32_t audio_pd_flags_t;
+#define AUDIO_PDF_NONE ((audio_pd_flags_t)0)
+#define AUDIO_PDF_ENABLE_NOTIFICATIONS ((audio_pd_flags_t)0x40000000)
+#define AUDIO_PDF_DISABLE_NOTIFICATIONS ((audio_pd_flags_t)0x80000000)
+
+// audio_pd_notify_flags_t
+//
+// Flags used by responses to the AUDIO_STREAM_CMD_PLUG_DETECT
+// message, and by AUDIO_STREAM_PLUG_DETECT_NOTIFY messages.
+//
+typedef uint32_t audio_pd_notify_flags_t;
+#define AUDIO_PDNF_HARDWIRED \
+ ((audio_pd_notify_flags_t)0x1) // Stream is hardwired (will always be plugged in)
+#define AUDIO_PDNF_CAN_NOTIFY \
+ ((audio_pd_notify_flags_t)0x2) // Stream is able to notify of plug state changes.
+#define AUDIO_PDNF_PLUGGED ((audio_pd_notify_flags_t)0x80000000) // Stream is currently plugged in.
+
+// AUDIO_STREAM_CMD_GET_FORMATS
+//
+// Must not be used with the NO_ACK flag.
+#define AUDIO_STREAM_CMD_GET_FORMATS_MAX_RANGES_PER_RESPONSE (15u)
+typedef struct audio_stream_cmd_get_formats_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_formats_req_t;
+
+// TODO(johngro) : Figure out if zx_txid_t is ever going to go up to 8 bytes or
+// not. If it is, just remove the _pad field below. If not, either keep it as
+// a _pad field, or repurpose it for some flags of some form. Right now, we use
+// it to make sure that format_ranges is aligned to a 16 byte boundary.
+typedef struct audio_stream_cmd_get_formats_resp {
+ audio_cmd_hdr_t hdr;
+ uint32_t _pad;
+ uint16_t format_range_count;
+ uint16_t first_format_range_ndx;
+ audio_stream_format_range_t format_ranges[AUDIO_STREAM_CMD_GET_FORMATS_MAX_RANGES_PER_RESPONSE];
+} audio_stream_cmd_get_formats_resp_t;
+
+static_assert(sizeof(audio_stream_cmd_get_formats_resp_t) == 256,
+ "audio_stream_cmd_get_formats_resp_t must be 256 bytes");
+
+#define AUDIO_SET_FORMAT_REQ_BITMASK_DISABLED ((uint64_t)0)
+
+// AUDIO_STREAM_CMD_SET_FORMAT
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_set_format_req {
+ audio_cmd_hdr_t hdr;
+ uint32_t frames_per_second;
+ audio_sample_format_t sample_format;
+ uint16_t channels;
+ uint64_t channels_to_use_bitmask;
+} audio_stream_cmd_set_format_req_t;
+
+typedef struct audio_stream_cmd_set_format_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint64_t external_delay_nsec;
+
+ // Note: Upon success, a channel used to control the audio buffer will also
+ // be returned.
+} audio_stream_cmd_set_format_resp_t;
+
+// AUDIO_STREAM_CMD_GET_GAIN
+//
+// Request that a gain notification be sent with the current details of the
+// streams current gain settings as well as gain setting capabilities.
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_get_gain_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_gain_req_t;
+
+typedef struct audio_stream_cmd_get_gain_resp {
+ // TODO(johngro) : Is there value in exposing the gain step to the level
+ // above the lowest level stream interface, or should we have all drivers
+ // behave as if they have continuous control at all times?
+ audio_cmd_hdr_t hdr;
+
+ bool cur_mute; // True if the stream is currently muted.
+ bool cur_agc; // True if the stream has AGC currently enabled.
+ float cur_gain; // The current setting gain of the stream in dB
+
+ bool can_mute; // True if the stream is capable of muting
+ bool can_agc; // True if the stream has support for AGC
+ float min_gain; // The minimum valid gain setting, in dB
+ float max_gain; // The maximum valid gain setting, in dB
+ float gain_step; // The smallest valid gain increment, counted from the minimum gain.
+} audio_stream_cmd_get_gain_resp_t;
+
+// AUDIO_STREAM_CMD_SET_GAIN
+//
+// Request that a stream change its gain settings to most closely match those
+// requested. Gain values for Valid requests will be rounded to the nearest
+// gain step. For example, if a stream can control its gain on the range from
+// -60.0 to 0.0 dB, a request to set the gain to -33.3 dB will result in a gain
+// of -33.5 being applied.
+//
+// Gain change requests outside of the capabilities of the stream's
+// amplifier will be rejected with a result of ZX_ERR_INVALID_ARGS. Using the
+// previous example, requests for gains of -65.0 or +3dB would be rejected.
+// Similarly, If an amplifier is capable of gain control but cannot mute, a
+// request to mute will be rejected.
+//
+// TODO(johngro) : Is this the correct behavior? Should we just apply sensible
+// limits instead? IOW - If the user requests a gain of -1000 dB, should we
+// just set the gain to -60dB? Likewise, if they request mute but the amplifier
+// has no hard mute feature, should we just set the gain to the minimum
+// permitted gain?
+//
+// May be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_set_gain_req {
+ audio_cmd_hdr_t hdr;
+ audio_set_gain_flags_t flags;
+ float gain;
+} audio_stream_cmd_set_gain_req_t;
+
+typedef struct audio_stream_cmd_set_gain_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ // The current gain settings observed immediately after processing the set
+ // gain request.
+ bool cur_mute;
+ bool cur_agc;
+ float cur_gain;
+} audio_stream_cmd_set_gain_resp_t;
+
+// AUDIO_STREAM_CMD_PLUG_DETECT
+//
+// Trigger a plug detect operation and/or enable/disable asynchronous plug
+// detect notifications.
+//
+// May be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_plug_detect_req {
+ audio_cmd_hdr_t hdr;
+ audio_pd_flags_t flags; // Options used to enable or disable notifications
+} audio_stream_cmd_plug_detect_req_t;
+
+typedef struct audio_stream_cmd_plug_detect_resp {
+ audio_cmd_hdr_t hdr;
+ audio_pd_notify_flags_t flags; // The current plug state and capabilities
+ zx_time_t plug_state_time; // The time of the plug state last change.
+} audio_stream_cmd_plug_detect_resp_t;
+
+// AUDIO_STREAM_PLUG_DETECT_NOTIFY
+//
+// Message asynchronously in response to a plug state change to clients who have
+// registered for plug state notifications.
+//
+// Note: Solicited and unsolicited plug detect messages currently use the same
+// structure and contain the same information. The difference between the two
+// is that Solicited messages, use AUDIO_STREAM_CMD_PLUG_DETECT as the value of
+// the `cmd` field of their header and the transaction ID of the request sent by
+// the client. Unsolicited messages use AUDIO_STREAM_PLUG_DETECT_NOTIFY as the
+// value value of the `cmd` field of their header, and
+// AUDIO_INVALID_TRANSACTION_ID for their transaction ID.
+typedef audio_stream_cmd_plug_detect_resp_t audio_stream_plug_detect_notify_t;
+
+// AUDIO_STREAM_CMD_GET_UNIQUE_ID
+//
+// Fetch a globally unique, but persistent ID for the stream.
+//
+// Drivers should make every effort to return as unique an identifier as
+// possible for each stream that they publish. This ID must not change between
+// boots. When available, using a globally unique device serial number is
+// strongly encouraged. Other possible sources of unique-ness include a
+// driver's physical connection path, driver binding information, manufacturer
+// calibration data, and so on.
+//
+// Note: a small number of hardcoded unique ID has been provided for built-in
+// devices. Platform drivers for systems with hardwired audio devices may use
+// these unique IDs as appropriate to signal which audio streams represent the
+// built-in devices for the system. Drivers for hot-pluggable audio devices
+// should *never* use these identifiers.
+//
+// Even given this, higher level code should *not* depend on these identifiers
+// being perfectly unique, and should be prepared to take steps to de-dupe
+// identifiers when needed.
+typedef struct audio_stream_cmd_get_unique_id_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_unique_id_req_t;
+
+typedef struct audio_stream_unique_id {
+ uint8_t data[16];
+} audio_stream_unique_id_t;
+
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_SPEAKERS \
+ { \
+ .data = { 0x01, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_HEADPHONE_JACK \
+ { \
+ .data = { 0x02, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_MICROPHONE \
+ { \
+ .data = { 0x03, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_HEADSET_JACK \
+ { \
+ .data = { 0x04, 0x00 } \
+ }
+#define AUDIO_STREAM_UNIQUE_ID_BUILTIN_BT \
+ { \
+ .data = { 0x05, 0x00 } \
+ }
+
+typedef struct audio_stream_cmd_get_unique_id_resp {
+ audio_cmd_hdr_t hdr;
+ audio_stream_unique_id_t unique_id;
+} audio_stream_cmd_get_unique_id_resp_t;
+
+// AUDIO_STREAM_CMD_GET_STRING
+//
+// Fetch the specified string from a device's static string table. Strings
+// returned by the device driver...
+//
+// ++ Must be encoded using UTF8
+// ++ May contain embedded NULLs
+// ++ May not be NULL terminated
+//
+// Drivers are encouraged to NULL terminate all of their strings whenever
+// possible, but are not required to do so if the response buffer is too small.
+//
+typedef uint32_t audio_stream_string_id_t;
+#define AUDIO_STREAM_STR_ID_MANUFACTURER ((audio_stream_string_id_t)0x80000000)
+#define AUDIO_STREAM_STR_ID_PRODUCT ((audio_stream_string_id_t)0x80000001)
+
+typedef struct audio_stream_cmd_get_string_req {
+ audio_cmd_hdr_t hdr;
+ audio_stream_string_id_t id;
+} audio_stream_cmd_get_string_req_t;
+
+typedef struct audio_stream_cmd_get_string_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ audio_stream_string_id_t id;
+ uint32_t strlen;
+ uint8_t str[256 - sizeof(audio_cmd_hdr_t) - (3 * sizeof(uint32_t))];
+} audio_stream_cmd_get_string_resp_t;
+
+static_assert(sizeof(audio_stream_cmd_get_string_resp_t) == 256,
+ "audio_stream_cmd_get_string_resp_t must be exactly 256 bytes");
+
+// AUDIO_STREAM_CMD_GET_CLOCK_DOMAIN
+//
+// Fetch the hardware clock domain for this device.
+// On products containing audio devices that are not locked to the local system clock, the board
+// driver will provide a clock tree entry to the audio driver at driver startup time. From that,
+// the audio driver can extract the clock domain and provide it to the sender, upon receiving this
+// command. This domain value is all that the sender needs, in order to locate controls for that
+// clock domain in the clock tree and trim that clock domain's rate.
+// On products containing audio devices that are locked to the local system monotonic clock, a clock
+// domain value of 0 should be returned.
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_stream_cmd_get_clock_domain_req {
+ audio_cmd_hdr_t hdr;
+} audio_stream_cmd_get_clock_domain_req_t;
+
+typedef struct audio_stream_cmd_get_clock_domain_resp {
+ audio_cmd_hdr_t hdr;
+ int32_t clock_domain;
+} audio_stream_cmd_get_clock_domain_resp_t;
+
+//
+// Ring-buffer commands
+//
+
+// AUDIO_RB_CMD_GET_FIFO_DEPTH
+//
+// TODO(johngro) : Is calling this "FIFO" depth appropriate? Should it be some
+// direction neutral form of something like "max-read-ahead-amount" or something
+// instead?
+//
+// Must not be used with the NO_ACK flag.
+typedef struct audio_rb_cmd_get_fifo_depth_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_get_fifo_depth_req_t;
+
+typedef struct audio_rb_cmd_get_fifo_depth_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+
+ // A representation (in bytes) of how far ahead audio hardware may read
+ // into the stream (in the case of output) or may hold onto audio before
+ // writing it to memory (in the case of input).
+ uint32_t fifo_depth;
+} audio_rb_cmd_get_fifo_depth_resp_t;
+
+// AUDIO_RB_CMD_GET_BUFFER
+typedef struct audio_rb_cmd_get_buffer_req {
+ audio_cmd_hdr_t hdr;
+
+ uint32_t min_ring_buffer_frames;
+ uint32_t notifications_per_ring;
+} audio_rb_cmd_get_buffer_req_t;
+
+typedef struct audio_rb_cmd_get_buffer_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint32_t num_ring_buffer_frames;
+
+ // NOTE: If result == ZX_OK, a VMO handle representing the ring buffer to
+ // be used will be returned as well. Clients may map this buffer with
+ // read-write permissions in the case of an output stream, or read-only
+ // permissions in the case of an input stream. The size of the VMO
+ // indicates where the wrap point of the ring (in bytes) is located in the
+ // VMO. This size *must* always be an integral number of audio frames.
+ //
+ // TODO(johngro) : Should we provide some indication of whether or not this
+ // memory is being used directly for HW DMA and may need explicit cache
+ // flushing/invalidation?
+} audio_rb_cmd_get_buffer_resp_t;
+
+// AUDIO_RB_CMD_START
+typedef struct audio_rb_cmd_start_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_start_req_t;
+
+typedef struct audio_rb_cmd_start_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+ uint64_t start_time;
+} audio_rb_cmd_start_resp_t;
+
+// AUDIO_RB_CMD_STOP
+typedef struct audio_rb_cmd_stop_req {
+ audio_cmd_hdr_t hdr;
+} audio_rb_cmd_stop_req_t;
+
+typedef struct audio_rb_cmd_stop_resp {
+ audio_cmd_hdr_t hdr;
+ zx_status_t result;
+} audio_rb_cmd_stop_resp_t;
+
+// AUDIO_RB_POSITION_NOTIFY
+typedef struct audio_rb_position_notify {
+ audio_cmd_hdr_t hdr;
+
+ // The time, per system monotonic clock, of the below byte position.
+ zx_time_t monotonic_time;
+
+ // The current position (in bytes) of the driver/hardware's read (output) or
+ // write (input) pointer in the ring buffer.
+ uint32_t ring_buffer_pos;
+} audio_rb_position_notify_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_DEVICE_AUDIO_H_
diff --git a/arch/x64/sysroot/include/zircon/device/ioctl-wrapper.h b/arch/x64/sysroot/include/zircon/device/ioctl-wrapper.h
deleted file mode 100644
index 81a1286..0000000
--- a/arch/x64/sysroot/include/zircon/device/ioctl-wrapper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <zircon/compiler.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-__BEGIN_CDECLS
-
-extern ssize_t fdio_ioctl(int fd, int op, const void* in_buf, size_t in_len, void* out_buf, size_t out_len);
-
-#define IOCTL_WRAPPER(name, op) \
-static inline ssize_t name(int fd) { \
- return fdio_ioctl(fd, op, NULL, 0, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_IN(name, op, type) \
-static inline ssize_t name(int fd, const type* in) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_VARIN(name, op, type) \
-static inline ssize_t name(int fd, const type* in, size_t in_len) { \
- return fdio_ioctl(fd, op, in, in_len, NULL, 0); \
-}
-
-#define IOCTL_WRAPPER_OUT(name, op, type) \
-static inline ssize_t name(int fd, type* out) { \
- return fdio_ioctl(fd, op, NULL, 0, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_VAROUT(name, op, type) \
-static inline ssize_t name(int fd, type* out, size_t out_len) { \
- return fdio_ioctl(fd, op, NULL, 0, out, out_len); \
-}
-
-#define IOCTL_WRAPPER_INOUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, outtype* out) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_VARIN_OUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, size_t in_len, outtype* out) { \
- return fdio_ioctl(fd, op, in, in_len, out, out ? sizeof(*out) : 0); \
-}
-
-#define IOCTL_WRAPPER_IN_VAROUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, outtype* out, size_t out_len) { \
- return fdio_ioctl(fd, op, in, in ? sizeof(*in) : 0, out, out_len); \
-}
-
-#define IOCTL_WRAPPER_VARIN_VAROUT(name, op, intype, outtype) \
-static inline ssize_t name(int fd, const intype* in, size_t in_len, outtype* out, size_t out_len) { \
- return fdio_ioctl(fd, op, in, in_len, out, out_len); \
-}
-
-__END_CDECLS
diff --git a/arch/x64/sysroot/include/zircon/device/ioctl.h b/arch/x64/sysroot/include/zircon/device/ioctl.h
deleted file mode 100644
index 7df5529..0000000
--- a/arch/x64/sysroot/include/zircon/device/ioctl.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-// DEFAULT ioctls accept and received byte[] data
-// the particular ioctl may define more specific structures
-#define IOCTL_KIND_DEFAULT 0x0
-
-// GET_HANDLE ioctls accept plain data and return
-// a single handle, optionally followed by plain data
-#define IOCTL_KIND_GET_HANDLE 0x1
-
-// GET_TWO_HANDLES ioctls accept plain data and return
-// two handles, optionally followed by plain data
-#define IOCTL_KIND_GET_TWO_HANDLES 0x2
-
-// GET_THREE_HANDLES ioctls accept plain data and return
-// three handles, optionally followed by plain data
-#define IOCTL_KIND_GET_THREE_HANDLES 0x4
-
-// SET_HANDLE ioctls accept a handle, and optionally
-// plain data afterwards.
-#define IOCTL_KIND_SET_HANDLE 0x3
-
-// SET_TWO_HANDLES ioctls accepts two handles, and
-// optionally plain data afterwards.
-#define IOCTL_KIND_SET_TWO_HANDLES 0x5
-
-// core device/vfs ioctl families
-#define IOCTL_FAMILY_RESERVED 0x00
-#define IOCTL_FAMILY_DEVICE 0x01
-#define IOCTL_FAMILY_VFS 0x02
-#define IOCTL_FAMILY_DMCTL 0x03
-#define IOCTL_FAMILY_TEST 0x04
-
-// device protocol families
-#define IOCTL_FAMILY_CONSOLE 0x10
-#define IOCTL_FAMILY_INPUT 0x11
-// 0x12 unused
-#define IOCTL_FAMILY_BLOCK 0x13
-#define IOCTL_FAMILY_I2C 0x14
-#define IOCTL_FAMILY_USB_DEVICE 0x16
-#define IOCTL_FAMILY_HID 0x17
-// 0x18 unused
-#define IOCTL_FAMILY_AUDIO 0x19
-#define IOCTL_FAMILY_MIDI 0x1A
-#define IOCTL_FAMILY_KTRACE 0x1B
-#define IOCTL_FAMILY_BT_HCI 0x1C
-#define IOCTL_FAMILY_SYSINFO 0x1D
-// 0x1E unused
-#define IOCTL_FAMILY_RTC 0x1F // ioctls for RTC
-#define IOCTL_FAMILY_ETH 0x20
-#define IOCTL_FAMILY_INSNTRACE 0x21 // ioctls for instruction tracing
-#define IOCTL_FAMILY_RAMDISK 0x22
-#define IOCTL_FAMILY_SDMMC 0x23
-#define IOCTL_FAMILY_WLAN 0x24
-#define IOCTL_FAMILY_PTY 0x25
-#define IOCTL_FAMILY_NETCONFIG 0x26
-#define IOCTL_FAMILY_ETHERTAP 0x27
-#define IOCTL_FAMILY_USB_PERIPHERAL 0x28
-#define IOCTL_FAMILY_USB_VIRT_BUS 0x29
-#define IOCTL_FAMILY_CPUPERF 0x2A
-#define IOCTL_FAMILY_POWER 0x30
-#define IOCTL_FAMILY_THERMAL 0x31
-#define IOCTL_FAMILY_CAMERA 0x32
-#define IOCTL_FAMILY_BT_HOST 0x33
-#define IOCTL_FAMILY_WLANPHY 0x34
-#define IOCTL_FAMILY_SERIAL 0x35
-#define IOCTL_FAMILY_WLANTAP 0x36
-#define IOCTL_FAMILY_DISPLAY_CONTROLLER 0x37
-#define IOCTL_FAMILY_DEBUG 0x38
-#define IOCTL_FAMILY_AUDIO_CODEC 0x39
-#define IOCTL_FAMILY_BACKLIGHT 0x3A
-#define IOCTL_FAMILY_NAND_TEST 0x3B
-#define IOCTL_FAMILY_TEE 0x3C
-#define IOCTL_FAMILY_SKIP_BLOCK 0x3D
-#define IOCTL_FAMILY_USB_TEST 0x3E
-#define IOCTL_FAMILY_CLK 0x3F
-// 0x40 unused.
-#define IOCTL_FAMILY_QMI 0x41
-
-// IOCTL constructor
-// --K-FFNN
-#define IOCTL(kind, family, number) \
- ((((kind) & 0xF) << 20) | (((family) & 0xFF) << 8) | ((number) & 0xFF))
-
-// IOCTL accessors
-#define IOCTL_KIND(n) (((n) >> 20) & 0xF)
-#define IOCTL_FAMILY(n) (((n) >> 8) & 0xFF)
-#define IOCTL_NUMBER(n) ((n) & 0xFF)
diff --git a/arch/x64/sysroot/include/zircon/device/ramdisk.h b/arch/x64/sysroot/include/zircon/device/ramdisk.h
deleted file mode 100644
index dac72b9..0000000
--- a/arch/x64/sysroot/include/zircon/device/ramdisk.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <limits.h>
-#include <zircon/boot/image.h>
-#include <zircon/device/ioctl.h>
-#include <zircon/device/ioctl-wrapper.h>
-#include <zircon/types.h>
-
-#define IOCTL_RAMDISK_CONFIG \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 1)
-#define IOCTL_RAMDISK_CONFIG_VMO \
- IOCTL(IOCTL_KIND_SET_HANDLE, IOCTL_FAMILY_RAMDISK, 4)
-#define IOCTL_RAMDISK_UNLINK \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 2)
-#define IOCTL_RAMDISK_SET_FLAGS \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 3)
-#define IOCTL_RAMDISK_WAKE_UP \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 4)
-#define IOCTL_RAMDISK_SLEEP_AFTER \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 5)
-#define IOCTL_RAMDISK_GET_BLK_COUNTS \
- IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_RAMDISK, 6)
-
-// Ramdisk-specific flags
-#define RAMDISK_FLAG_RESUME_ON_WAKE 0xFF000001
-
-typedef struct ramdisk_ioctl_config {
- uint64_t blk_size;
- uint64_t blk_count;
- uint8_t type_guid[ZBI_PARTITION_GUID_LEN];
-} ramdisk_ioctl_config_t;
-
-typedef struct ramdisk_ioctl_config_response {
- char name[NAME_MAX + 1];
-} ramdisk_ioctl_config_response_t;
-
-typedef struct ramdisk_blk_counts {
- uint64_t received;
- uint64_t successful;
- uint64_t failed;
-} ramdisk_blk_counts_t;
-
-// ssize_t ioctl_ramdisk_config(int fd, const ramdisk_ioctl_config_t* in,
-// ramdisk_ioctl_config_response_t* out);
-IOCTL_WRAPPER_INOUT(ioctl_ramdisk_config, IOCTL_RAMDISK_CONFIG, ramdisk_ioctl_config_t,
- ramdisk_ioctl_config_response_t);
-
-// ssize_t ioctl_ramdisk_config_vmo(int fd, const zx_handle_t* in,
-// ramdisk_ioctl_config_response_t* out);
-IOCTL_WRAPPER_INOUT(ioctl_ramdisk_config_vmo, IOCTL_RAMDISK_CONFIG_VMO,
- zx_handle_t, ramdisk_ioctl_config_response_t);
-
-// ssize_t ioctl_ramdisk_unlink(int fd);
-IOCTL_WRAPPER(ioctl_ramdisk_unlink, IOCTL_RAMDISK_UNLINK);
-
-// ssize_t ioctl_ramdisk_set_flags(int fd, uint32_t* in);
-// The flags to set match block_info_t.flags. This is intended to simulate the behavior
-// of other block devices, so it should be used only for tests.
-IOCTL_WRAPPER_IN(ioctl_ramdisk_set_flags, IOCTL_RAMDISK_SET_FLAGS, uint32_t);
-
-// ssize_t ioctl_ramdisk_wake_up(int fd);
-// "Wakes" the ramdisk, if it was sleeping.
-// Transactions are no longer expected to fail after this point, and the ramdisk will not sleep
-// again until the next call to SLEEP_AFTER.
-// This will reset the current transaction count.
-IOCTL_WRAPPER(ioctl_ramdisk_wake_up, IOCTL_RAMDISK_WAKE_UP);
-
-// ssize_t ioctl_ramdisk_sleep_after(int fd, uint64_t* in);
-// Tell the ramdisk to "sleep" after |in| blocks have been written successfully.
-// After this point, all incoming transactions will fail.
-// This will reset the current block count.
-// NOTE! Use caution with RAMDISK_FLAG_RESUME_ON_WAKE set; sleeping with this flags will cause I/O
-// to block indefinitely until another call invokes |ioctl_ramdisk_wake_up|.
-IOCTL_WRAPPER_IN(ioctl_ramdisk_sleep_after, IOCTL_RAMDISK_SLEEP_AFTER, uint64_t);
-
-// ssize_t ioctl_ramdisk_get_blk_counts(int fd, ramdisk_blk_counts_t* out);
-// Retrieve the number of received, successful, and failed block writes since the last call to
-// sleep/wake.
-IOCTL_WRAPPER_OUT(ioctl_ramdisk_get_blk_counts, IOCTL_RAMDISK_GET_BLK_COUNTS, ramdisk_blk_counts_t);
diff --git a/arch/x64/sysroot/include/zircon/dlfcn.h b/arch/x64/sysroot/include/zircon/dlfcn.h
index af4a62b..f37e9be 100644
--- a/arch/x64/sysroot/include/zircon/dlfcn.h
+++ b/arch/x64/sysroot/include/zircon/dlfcn.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_DLFCN_H_
+#define SYSROOT_ZIRCON_DLFCN_H_
#include <dlfcn.h>
#include <zircon/compiler.h>
@@ -30,3 +31,5 @@
zx_status_t dl_clone_loader_service(zx_handle_t* out);
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_DLFCN_H_
diff --git a/arch/x64/sysroot/include/zircon/driver/binding.h b/arch/x64/sysroot/include/zircon/driver/binding.h
deleted file mode 100644
index 7c05026..0000000
--- a/arch/x64/sysroot/include/zircon/driver/binding.h
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <assert.h>
-#include <zircon/compiler.h>
-#include <stdalign.h>
-#include <stddef.h>
-#include <stdint.h>
-
-__BEGIN_CDECLS;
-
-// COAABBBB VVVVVVVV Condition Opcode paramA paramB Value
-
-#define OP_ABORT 0x0 // if (cond) return no-match
-#define OP_MATCH 0x1 // if (cond) return match
-#define OP_GOTO 0x2 // if (cond) advance to next LABEL(paramA)
-#define OP_SET 0x3 // if (cond) flags |= paramA
-#define OP_CLEAR 0x4 // if (cond) flags &= (~paramA)
-#define OP_LABEL 0x5 // no-op, labels line with paramA
-
-#define COND_AL 0x0 // true
-#define COND_EQ 0x1 // bind(paramB) == Value
-#define COND_NE 0x2 // bind(paramB) != Value
-#define COND_GT 0x3 // bind(paramB) > Value
-#define COND_LT 0x4 // bind(paramB) < Value
-#define COND_GE 0x5 // bind(paramB) >= Value
-#define COND_LE 0x6 // bind(paramB) <= Value
-#define COND_MASK 0x7 // (bind(paramB) & Value) != 0
-#define COND_BITS 0x8 // (bind(paramB) & Value) == Value
-
-// branches are forward-only
-// branches always go to the first matching LABEL
-// branches that cannot find a matching LABEL are treated as ABORTs
-// there is an implied unconditional ABORT after the last instruction
-// flags are initially zero, may be set/cleared with SET/CLEAR
-// flags may be tested by comparison against BIND_FLAGS
-
-#define BINDINST(c,o,a,b,v) \
- { (((c)&0xF)<<28)|(((o)&0xF)<<24)|(((a)&0xFF)<<16)|((b)&0xFFFF),(v) }
-
-#define BINDINST_CC(n) ((n) >> 28)
-#define BINDINST_OP(n) (((n) >> 24) & 0xF)
-#define BINDINST_PA(n) (((n) >> 16) & 0xFF)
-#define BINDINST_PB(n) ((n) & 0xFFFF)
-
-#define BI_ABORT() BINDINST(COND_AL,OP_ABORT,0,0,0)
-#define BI_MATCH() BINDINST(COND_AL,OP_MATCH,0,0,0)
-#define BI_GOTO(n) BINDINST(COND_AL,OP_GOTO,n,0,0)
-#define BI_SET(f) BINDINST(COND_AL,OP_SET,f,0,0)
-#define BI_CLEAR(f) BINDINST(COND_AL,OP_CLEAR,f,0,0)
-#define BI_LABEL(n) BINDINST(COND_AL,OP_LABEL,n,0,0)
-
-#define BI_ABORT_IF(c,b,v) BINDINST(COND_##c,OP_ABORT,0,b,v)
-#define BI_MATCH_IF(c,b,v) BINDINST(COND_##c,OP_MATCH,0,b,v)
-#define BI_GOTO_IF(c,b,v,n) BINDINST(COND_##c,OP_GOTO,n,b,v)
-#define BI_SET_IF(c,b,v,f) BINDINST(COND_##c,OP_SET,f,b,v)
-#define BI_CLEAR_IF(c,b,v,f) BINDINST(COND_##c,OP_CLEAR,f,b,v)
-
-// for drivers that only want to be bound on user request
-#define BI_ABORT_IF_AUTOBIND BI_ABORT_IF(NE, BIND_AUTOBIND, 0)
-
-// global binding variables at 0x00XX
-#define BIND_FLAGS 0x0000 // value of the flags register
-#define BIND_PROTOCOL 0x0001 // primary protcol of the device
-#define BIND_AUTOBIND 0x0002 // if this is an automated bind/load
-
-// pci binding variables at 0x01XX
-#define BIND_PCI_VID 0x0100
-#define BIND_PCI_DID 0x0101
-#define BIND_PCI_CLASS 0x0102
-#define BIND_PCI_SUBCLASS 0x0103
-#define BIND_PCI_INTERFACE 0x0104
-#define BIND_PCI_REVISION 0x0105
-#define BIND_PCI_BDF_ADDR 0x0106
-
-// pci binding variable utils
-#define BIND_PCI_BDF_PACK(bus, dev, func) \
- ((((uint32_t)(bus) & 0xFF) << 8) | \
- (((uint32_t)(dev) & 0x1F) << 3) | \
- ((uint32_t)(func) & 0x07))
-
-#define BIND_PCI_BDF_UNPACK_BUS(bdf) (((uint32_t)(bdf) >> 8) & 0xFF)
-#define BIND_PCI_BDF_UNPACK_DEV(bdf) (((uint32_t)(bdf) >> 3) & 0x1F)
-#define BIND_PCI_BDF_UNPACK_FUNC(bdf) ((uint32_t)(bdf) & 0x07)
-
-// usb binding variables at 0x02XX
-// these are used for both ZX_PROTOCOL_USB and ZX_PROTOCOL_USB_FUNCTION
-#define BIND_USB_VID 0x0200
-#define BIND_USB_PID 0x0201
-#define BIND_USB_CLASS 0x0202
-#define BIND_USB_SUBCLASS 0x0203
-#define BIND_USB_PROTOCOL 0x0204
-
-// Platform bus binding variables at 0x03XX
-#define BIND_PLATFORM_DEV_VID 0x0300
-#define BIND_PLATFORM_DEV_PID 0x0301
-#define BIND_PLATFORM_DEV_DID 0x0302
-#define BIND_PLATFORM_PROTO 0x0303
-
-// ACPI binding variables at 0x04XX
-// The _HID is a 7- or 8-byte string. Because a bind property is 32-bit, use 2
-// properties to bind using the _HID. They are encoded in big endian order for
-// human readability. In the case of 7-byte _HID's, the 8th-byte shall be 0.
-#define BIND_ACPI_HID_0_3 0x0400 // char 0-3
-#define BIND_ACPI_HID_4_7 0x0401 // char 4-7
-// The _CID may be a valid HID value or a bus-specific string. The ACPI bus
-// driver only publishes those that are valid HID values.
-#define BIND_ACPI_CID_0_3 0x0402 // char 0-3
-#define BIND_ACPI_CID_4_7 0x0403 // char 4-7
-
-// Intel HDA Codec binding variables at 0x05XX
-#define BIND_IHDA_CODEC_VID 0x0500
-#define BIND_IHDA_CODEC_DID 0x0501
-#define BIND_IHDA_CODEC_MAJOR_REV 0x0502
-#define BIND_IHDA_CODEC_MINOR_REV 0x0503
-#define BIND_IHDA_CODEC_VENDOR_REV 0x0504
-#define BIND_IHDA_CODEC_VENDOR_STEP 0x0505
-
-// Serial binding variables at 0x06XX
-#define BIND_SERIAL_CLASS 0x0600
-#define BIND_SERIAL_VID 0x0601
-#define BIND_SERIAL_PID 0x0602
-
-// NAND binding variables at 0x07XX
-#define BIND_NAND_CLASS 0x0700
-
-// Bluetooth binding variables at 0x08XX
-#define BIND_BT_GATT_SVC_UUID16 0x0800
-// 128-bit UUID is split across 4 32-bit unsigned ints
-#define BIND_BT_GATT_SVC_UUID128_1 0x0801
-#define BIND_BT_GATT_SVC_UUID128_2 0x0802
-#define BIND_BT_GATT_SVC_UUID128_3 0x0803
-#define BIND_BT_GATT_SVC_UUID128_4 0x0804
-
-// SDIO binding variables at 0x09XX
-#define BIND_SDIO_VID 0x0900
-#define BIND_SDIO_PID 0x0901
-
-// I2C binding variables at 0x0AXX
-#define BIND_I2C_CLASS 0x0A00
-
-// TEMPORARY binding variables at 0xfXX
-// I2C_ADDR is a temporary way to bind the i2c touchscreen on the Acer12. This
-// binding will eventually be made via some sort of ACPI device enumeration.
-#define BIND_I2C_ADDR 0x0f00
-
-typedef struct zx_bind_inst {
- uint32_t op;
- uint32_t arg;
-} zx_bind_inst_t;
-
-typedef struct zx_device_prop {
- uint16_t id;
- uint16_t reserved;
- uint32_t value;
-} zx_device_prop_t;
-
-// simple example
-#if 0
-zx_bind_inst_t i915_binding[] = {
- BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_PCI),
- BI_ABORT_IF(NE, BIND_PCI_VID, 0x8086),
- BI_MATCH_IF(EQ, BIND_PCI_DID, 0x1616), // broadwell
- BI_MATCH_IF(EQ, BIND_PCI_DID, 0x1916), // skylake
- BI_ABORT(),
-};
-#endif
-
-#define ZIRCON_NOTE_NAME "Zircon"
-#define ZIRCON_NOTE_DRIVER 0x31565244 // DRV1
-
-typedef struct {
- // Elf64_Nhdr fields:
- uint32_t namesz;
- uint32_t descsz;
- uint32_t type;
- // ELF note name. namesz is the exact size of the name (including '\0'),
- // but the storage size is always rounded up to a multiple of 4 bytes.
- char name[(sizeof(ZIRCON_NOTE_NAME) + 3) & -4];
-} zircon_driver_note_header_t;
-
-#define ZIRCON_DRIVER_NOTE_HEADER_INIT(object) { \
- /* .namesz = */ sizeof(ZIRCON_NOTE_NAME), \
- /* .descsz = */ (sizeof(object) - \
- sizeof(zircon_driver_note_header_t)), \
- /* .type = */ ZIRCON_NOTE_DRIVER, \
- /* .name = */ ZIRCON_NOTE_NAME, \
- }
-
-typedef struct {
- // See flag bits below.
- uint32_t flags;
-
- // Driver Metadata
- uint32_t bindcount;
- uint32_t reserved0;
- char name[32];
- char vendor[16];
- char version[16];
-
- // Driver Bind Program follows
-} zircon_driver_note_payload_t;
-
-// Flag bits in the driver note:
-
-// Driver is built with `-fsanitize=address` and can only be loaded into a
-// devhost that supports the ASan runtime.
-#define ZIRCON_DRIVER_NOTE_FLAG_ASAN (1u << 0)
-
-#define ZIRCON_DRIVER_NOTE_PAYLOAD_INIT(Driver,VendorName,Version,BindCount) \
- { \
- /* .flags = */ ZIRCON_DRIVER_NOTE_FLAGS, \
- /* .bindcount = */ (BindCount), \
- /* .reserved0 = */ 0, \
- /* .name = */ #Driver, \
- /* .vendor = */ VendorName, \
- /* .version = */ Version, \
- }
-
-#define ZIRCON_DRIVER_NOTE_FLAGS \
- (__has_feature(address_sanitizer) ? ZIRCON_DRIVER_NOTE_FLAG_ASAN : 0)
-
-typedef struct {
- zircon_driver_note_header_t header;
- zircon_driver_note_payload_t payload;
-} zircon_driver_note_t;
-
-static_assert(offsetof(zircon_driver_note_t, payload) ==
- sizeof(zircon_driver_note_header_t),
- "alignment snafu?");
-
-// Without this, ASan will add redzone padding after the object, which
-// would make it invalid ELF note format.
-#if __has_feature(address_sanitizer)
-# define ZIRCON_DRIVER_NOTE_ASAN __attribute__((no_sanitize("address")))
-#else
-# define ZIRCON_DRIVER_NOTE_ASAN
-#endif
-
-// GCC has a quirk about how '__attribute__((visibility("default")))'
-// (__EXPORT here) works for const variables in C++. The attribute has no
-// effect when used on the definition of a const variable, and GCC gives a
-// warning/error about that. The attribute must appear on the "extern"
-// declaration of the variable instead.
-
-// We explicitly align the note to 4 bytes. That's its natural alignment
-// anyway, but the compilers sometimes like to over-align as an
-// optimization while other tools sometimes like to complain if SHT_NOTE
-// sections are over-aligned (since this could result in padding being
-// inserted that makes it violate the ELF note format). Standard C11
-// doesn't permit alignas(...) on a type but we could use __ALIGNED(4) on
-// all the types (i.e. GNU __attribute__ syntax instead of C11 syntax).
-// But the alignment of the types is not actually the issue: it's the
-// compiler deciding to over-align the individual object regardless of its
-// type's alignment, so we have to explicitly set the alignment of the
-// object to defeat any compiler default over-alignment.
-
-#define ZIRCON_DRIVER_BEGIN(Driver,Ops,VendorName,Version,BindCount) \
-zx_driver_rec_t __zircon_driver_rec__ __EXPORT = {\
- /* .ops = */ &(Ops),\
- /* .driver = */ NULL,\
- /* .log_flags = */ 7, /* DDK_LOG_ERROR | DDK_LOG_WARN | DDK_LOG_INFO */\
-};\
-extern const struct zircon_driver_note __zircon_driver_note__ __EXPORT;\
-alignas(4) __SECTION(".note.zircon.driver." #Driver) ZIRCON_DRIVER_NOTE_ASAN \
-const struct zircon_driver_note {\
- zircon_driver_note_t note;\
- zx_bind_inst_t binding[BindCount];\
-} __zircon_driver_note__ = {\
- /* .note = */{\
- ZIRCON_DRIVER_NOTE_HEADER_INIT(__zircon_driver_note__),\
- ZIRCON_DRIVER_NOTE_PAYLOAD_INIT(Driver,VendorName,Version,BindCount),\
- },\
- /* .binding = */ {
-
-#define ZIRCON_DRIVER_END(Driver) }};
-
-//TODO: if we moved the Ops from the BEGIN() to END() macro we
-// could add a zircon_driver_note_t* to the zx_driver_rec_t,
-// define it in END(), and have only one symbol to dlsym()
-// when loading drivers
-
-__END_CDECLS;
diff --git a/arch/x64/sysroot/include/zircon/errors.h b/arch/x64/sysroot/include/zircon/errors.h
index 1c1ed80..390acfb 100644
--- a/arch/x64/sysroot/include/zircon/errors.h
+++ b/arch/x64/sysroot/include/zircon/errors.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_ERRORS_H_
+#define SYSROOT_ZIRCON_ERRORS_H_
// Zircon statuses are signed 32 bit integers. The space of values is
// divided as follows:
@@ -108,7 +109,6 @@
// and should thus retry.
#define ZX_ERR_UNAVAILABLE (-28)
-
// ======= Permission check errors =======
// ZX_ERR_ACCESS_DENIED: The caller did not have permission to perform
// the specified operation.
@@ -229,3 +229,10 @@
// ZX_ERR_CONNECTION_ABORTED: Connection was aborted.
#define ZX_ERR_CONNECTION_ABORTED (-76)
+
+// ======= VDSO-private errors =======
+
+// ZX_ERR_INTERNAL_INTR_KILLED: A task was killed during an operation.
+#define ZX_ERR_INTERNAL_INTR_KILLED (-502)
+
+#endif // SYSROOT_ZIRCON_ERRORS_H_
diff --git a/arch/x64/sysroot/include/zircon/exception.h b/arch/x64/sysroot/include/zircon/exception.h
new file mode 100644
index 0000000..bf3843b
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/exception.h
@@ -0,0 +1,19 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#pragma once
+
+#include <zircon/syscalls/exception.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__EXPORT const char* _zx_exception_get_string(zx_excp_type_t exception);
+__EXPORT const char* zx_exception_get_string(zx_excp_type_t exception);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/arch/x64/sysroot/include/zircon/features.h b/arch/x64/sysroot/include/zircon/features.h
index a560007..d0c0720 100644
--- a/arch/x64/sysroot/include/zircon/features.h
+++ b/arch/x64/sysroot/include/zircon/features.h
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_FEATURES_H_
-#define ZIRCON_FEATURES_H_
+#ifndef SYSROOT_ZIRCON_FEATURES_H_
+#define SYSROOT_ZIRCON_FEATURES_H_
// clang-format off
// types of features that can be retrieved via |zx_system_get_features|
-#define ZX_FEATURE_KIND_CPU ((uint32_t)0)
+#define ZX_FEATURE_KIND_CPU ((uint32_t)0)
+#define ZX_FEATURE_KIND_HW_BREAKPOINT_COUNT ((uint32_t)1)
+#define ZX_FEATURE_KIND_HW_WATCHPOINT_COUNT ((uint32_t)2)
// arch-independent CPU features
#define ZX_HAS_CPU_FEATURES ((uint32_t)(1u << 0))
@@ -35,6 +37,9 @@
#define ZX_ARM64_FEATURE_ISA_SM4 ((uint32_t)(1u << 12))
#define ZX_ARM64_FEATURE_ISA_DP ((uint32_t)(1u << 13))
#define ZX_ARM64_FEATURE_ISA_DPB ((uint32_t)(1u << 14))
+#define ZX_ARM64_FEATURE_ISA_FHM ((uint32_t)(1u << 15))
+#define ZX_ARM64_FEATURE_ISA_TS ((uint32_t)(1u << 16))
+#define ZX_ARM64_FEATURE_ISA_RNDR ((uint32_t)(1u << 17))
#else
@@ -42,4 +47,4 @@
#endif
-#endif // ZIRCON_FEATURES_H_
+#endif // SYSROOT_ZIRCON_FEATURES_H_
diff --git a/arch/x64/sysroot/include/zircon/fidl.h b/arch/x64/sysroot/include/zircon/fidl.h
index e971472..7388729 100644
--- a/arch/x64/sysroot/include/zircon/fidl.h
+++ b/arch/x64/sysroot/include/zircon/fidl.h
@@ -2,20 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_FIDL_H_
-#define ZIRCON_FIDL_H_
+#ifndef SYSROOT_ZIRCON_FIDL_H_
+#define SYSROOT_ZIRCON_FIDL_H_
-#include <assert.h>
-#include <stdalign.h>
-#include <stdint.h>
-
+#include <assert.h> // NOLINT(modernize-deprecated-headers, foobar)
+#include <stdalign.h> // NOLINT(modernize-deprecated-headers)
+#include <stdint.h> // NOLINT(modernize-*)
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS
// Fidl data types have a representation in a wire format. This wire
-// format is shared by all language bindings, including C11 and C++14.
+// format is shared by all language bindings, including C11 and C++.
//
// The C bindings also define a representation of fidl data types. For
// a given type, the size and alignment of all parts of the type agree
@@ -55,12 +54,21 @@
#define FIDL_ALLOC_ABSENT ((uintptr_t)0)
// Out of line allocations are all 8 byte aligned.
+// TODO(fxbug.dev/42792): Remove either this FIDL_ALIGN macro or the FidlAlign function in
+// fidl/internal.h.
#define FIDL_ALIGNMENT ((size_t)8)
-#define FIDL_ALIGN(a) (((a) + 7) & ~7)
+#define FIDL_ALIGN(a) (((a) + 7u) & ~7u)
#define FIDL_ALIGNDECL alignas(FIDL_ALIGNMENT)
-// An opaque struct representing the encoding of a particular fidl
-// type.
+// The maximum depth of out-of-line objects in the wire format.
+// 0 is the initial depth, 1 is the first out of line object, etc.
+// Tables count as two depth levels because the vector body and the
+// table elements are both out of line.
+#define FIDL_MAX_DEPTH 32
+
+// An opaque struct containing metadata for encoding a particular fidl
+// type. The actual length of the struct is different depending on the
+// kind of fidl type it is describing.
typedef struct fidl_type fidl_type_t;
// Primitive types.
@@ -119,11 +127,11 @@
// but is checked as part of validation.
typedef struct fidl_string {
- // Number of UTF-8 code units (bytes), must be 0 if |data| is null.
- uint64_t size;
+ // Number of UTF-8 code units (bytes), must be 0 if |data| is null.
+ uint64_t size;
- // Pointer to UTF-8 code units (bytes) or null
- char* data;
+ // Pointer to UTF-8 code units (bytes) or null
+ char* data;
} fidl_string_t;
// When encoded, an absent nullable string is represented as a
@@ -169,11 +177,11 @@
// but is checked as part of validation.
typedef struct fidl_vector {
- // Number of elements, must be 0 if |data| is null.
- uint64_t count;
+ // Number of elements, must be 0 if |data| is null.
+ uint64_t count;
- // Pointer to element data or null.
- void* data;
+ // Pointer to element data or null.
+ void* data;
} fidl_vector_t;
// When encoded, an absent nullable vector is represented as a
@@ -193,6 +201,42 @@
// vector<T>:N fidl_vector_t A vector of T, up to N elements.
// vector<T>:N? fidl_vector_t An optional vector of T, up to N elements.
+// Envelope.
+
+// An efficient way to encapsulate uninterpreted FIDL messages.
+// - Stores a variable size uninterpreted payload out-of-line.
+// - Payload may contain an arbitrary number of bytes and handles.
+// - Allows for encapsulation of one FIDL message inside of another.
+// - Building block for extensible structures such as tables & extensible
+// unions.
+
+// When encoded for transfer, |data| indicates presence of content:
+// - FIDL_ALLOC_ABSENT : envelope is null
+// - FIDL_ALLOC_PRESENT : envelope is non-null, |data| is the next out-of-line object
+// When decoded for consumption, |data| is a pointer to content.
+// - nullptr : envelope is null
+// - <valid pointer> : envelope is non-null, |data| is at indicated memory address
+
+typedef struct {
+ // The size of the entire envelope contents, including any additional
+ // out-of-line objects that the envelope may contain. For example, a
+ // vector<string>'s num_bytes for ["hello", "world"] would include the
+ // string contents in the size, not just the outer vector. Always a multiple
+ // of 8; must be zero if envelope is null.
+ uint32_t num_bytes;
+
+ // The number of handles in the envelope, including any additional
+ // out-of-line objects that the envelope contains. Must be zero if envelope is null.
+ uint32_t num_handles;
+
+ // A pointer to the out-of-line envelope data in decoded form, or
+ // FIDL_ALLOC_(ABSENT|PRESENT) in encoded form.
+ union {
+ void* data;
+ uintptr_t presence;
+ };
+} fidl_envelope_t;
+
// Handle types.
// Handle types are encoded directly. Just like primitive types, there
@@ -278,16 +322,53 @@
// union_foo, or else
// FIDL_ALLOC_ABSENT.
+// Tables.
+
+// Tables are 'flexible structs', where all members are optional, and new
+// members can be added, or old members removed while preserving ABI
+// compatibility. Each table member is referenced by ordinal, sequentially
+// assigned from 1 onward, with no gaps. Each member content is stored
+// out-of-line in an envelope, and a table is simply a vector of these envelopes
+// with the requirement that the last envelope must be present in order
+// to guarantee a canonical representation.
+
+typedef struct {
+ fidl_vector_t envelopes;
+} fidl_table_t;
+
+// Extensible unions.
+
+// Extensible unions, or "xunions" (colloquially pronounced "zoo-nions") are
+// similar to unions, except that storage for union members are out-of-line
+// rather than inline. This enables union members to be added and removed while
+// preserving ABI compatibility with the existing xunion definition.
+
+typedef uint64_t fidl_xunion_tag_t;
+
+enum {
+ kFidlXUnionEmptyTag = 0, // The tag representing an empty xunion.
+};
+
+typedef struct {
+ fidl_xunion_tag_t tag;
+ fidl_envelope_t envelope;
+} fidl_xunion_t;
+
// Messages.
// All fidl messages share a common 16 byte header.
+enum {
+ kFidlWireFormatMagicNumberInitial = 1,
+};
+
typedef struct fidl_message_header {
- zx_txid_t txid;
- // This reserved word is used by Epitaphs to represent an error value.
- uint32_t reserved0;
- uint32_t flags;
- uint32_t ordinal;
+ zx_txid_t txid;
+ uint8_t flags[3];
+ // This value indicates the message's wire format. Two sides with different
+ // wire formats are incompatible with each other
+ uint8_t magic_number;
+ uint64_t ordinal;
} fidl_message_header_t;
// Messages which do not have a response use zero as a special
@@ -295,46 +376,65 @@
#define FIDL_TXID_NO_RESPONSE 0ul
-// The system reserves the high half of the ordinal space.
+// An outgoing FIDL message.
+typedef struct fidl_outgoing_msg {
+ // The bytes of the message.
+ //
+ // The bytes of the message might be in the encoded or decoded form.
+ // Functions that take a |fidl_outgoing_msg_t| as an argument should document whether
+ // the expect encoded or decoded messages.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ void* bytes;
-#define FIDL_ORD_SYSTEM_MASK 0x80000000ul
+ // The handles of the message.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ zx_handle_t* handles;
-// A FIDL message.
-typedef struct fidl_msg {
- // The bytes of the message.
- //
- // The bytes of the message might be in the encoded or decoded form.
- // Functions that take a |fidl_msg_t| as an argument should document whether
- // the expect encoded or decoded messages.
- //
- // See |num_bytes| for the number of bytes in the message.
- void* bytes;
+ // The number of bytes in |bytes|.
+ uint32_t num_bytes;
- // The handles of the message.
- //
- // See |num_bytes| for the number of bytes in the message.
- zx_handle_t* handles;
+ // The number of handles in |handles|.
+ uint32_t num_handles;
+} fidl_outgoing_msg_t;
- // The number of bytes in |bytes|.
- uint32_t num_bytes;
+// An incoming FIDL message.
+typedef struct fidl_incoming_msg {
+ // The bytes of the message.
+ //
+ // The bytes of the message might be in the encoded or decoded form.
+ // Functions that take a |fidl_incoming_msg_t| as an argument should document whether
+ // the expect encoded or decoded messages.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ void* bytes;
- // The number of handles in |handles|.
- uint32_t num_handles;
-} fidl_msg_t;
+ // The handles of the message.
+ //
+ // See |num_bytes| for the number of bytes in the message.
+ zx_handle_t* handles;
+
+ // The number of bytes in |bytes|.
+ uint32_t num_bytes;
+
+ // The number of handles in |handles|.
+ uint32_t num_handles;
+} fidl_incoming_msg_t;
// An outstanding FIDL transaction.
typedef struct fidl_txn fidl_txn_t;
struct fidl_txn {
- // Replies to the outstanding request and complete the FIDL transaction.
- //
- // Pass the |fidl_txn_t| object itself as the first parameter. The |msg|
- // should already be encoded. This function always consumes any handles
- // present in |msg|.
- //
- // Call |reply| only once for each |txn| object. After |reply| returns, the
- // |txn| object is considered invalid and might have been freed or reused
- // for another purpose.
- zx_status_t (*reply)(fidl_txn_t* txn, const fidl_msg_t* msg);
+ // Replies to the outstanding request and complete the FIDL transaction.
+ //
+ // Pass the |fidl_txn_t| object itself as the first parameter. The |msg|
+ // should already be encoded. This function always consumes any handles
+ // present in |msg|.
+ //
+ // Call |reply| only once for each |txn| object. After |reply| returns, the
+ // |txn| object is considered invalid and might have been freed or reused
+ // for another purpose.
+ zx_status_t (*reply)(fidl_txn_t* txn, const fidl_outgoing_msg_t* msg);
};
// An epitaph is a message that a server sends just prior to closing the
@@ -342,17 +442,22 @@
// Epitaphs are defined in the FIDL wire format specification. Once sent down
// the wire, the channel should be closed.
typedef struct fidl_epitaph {
- FIDL_ALIGNDECL
+ FIDL_ALIGNDECL
- // The error associated with this epitaph is stored in the reserved word of
- // the message header. System errors must be constants of type zx_status_t,
- // which are all negative. Positive numbers should be used for application
- // errors. A value of ZX_OK indicates no error.
- fidl_message_header_t hdr;
+ // The method ordinal for all epitaphs must be kFidlOrdinalEpitaph
+ fidl_message_header_t hdr;
+
+ // The error associated with this epitaph is stored as a struct{int32} in
+ // the message payload. System errors must be constants of type zx_status_t,
+ // which are all negative. Positive numbers should be used for application
+ // errors. A value of ZX_OK indicates no error.
+ zx_status_t error;
} fidl_epitaph_t;
// This ordinal value is reserved for Epitaphs.
-#define FIDL_EPITAPH_ORDINAL 0xFFFFFFFF
+enum {
+ kFidlOrdinalEpitaph = 0xFFFFFFFFFFFFFFFF,
+};
// Assumptions.
@@ -374,4 +479,4 @@
__END_CDECLS
-#endif // ZIRCON_FIDL_H_
+#endif // SYSROOT_ZIRCON_FIDL_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/debug/arm64.h b/arch/x64/sysroot/include/zircon/hw/debug/arm64.h
new file mode 100644
index 0000000..b0b6ea3
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/debug/arm64.h
@@ -0,0 +1,278 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
+#define SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
+
+#include <stdint.h>
+
+// ARM64 Hardware Debug Resources
+// =================================================================================================
+
+// Hardware Breakpoints ----------------------------------------------------------------------------
+//
+// Hardware breakpoints permits to stop a thread when it executes an address setup in one of the
+// hw breakpoints registers. They will work independent whether the address in question is
+// read-only or not.
+
+// ARMv8 assures at least 2 hardware breakpoints.
+#define ARM64_MIN_HW_BREAKPOINTS 2
+#define ARM64_MAX_HW_BREAKPOINTS 16
+
+// Access macros:
+// All the relevant register fields are exposed through macros.
+// For convenience of use, use the get/set macros:
+//
+// uint64_t ARM64_<REG>_<FIELD>_GET(uint64_t reg)
+// void ARM64_<REG>_<FIELD>_SET(uint64_t* reg, uint64_t value)
+//
+// Examples:
+// uint64_t bas = ARM64_DBGBCR_BAS_GET(dbgbcr);
+// ARM64_DBGBCR_BAS_SET(&dbgbcr, modified_bas);
+
+// DBGBCR<n>: Debug Control Register for HW Breakpoint #n.
+//
+// Control register for HW breakpoints. There is one foreach HW breakpoint present within the
+// system. They go numbering by DBGBCR0, DBGBCR1, ... until the value defined in ID_AADFR0_EL1.
+//
+// For each control register, there is an equivalent DBGBVR<n> that holds the address the thread
+// will compare against.
+
+// The following fields are accepted by the user. All other fields are ignored (masked).
+//
+// - E
+
+// This mask is applied when to DBGBCR. Any set values on those fields will be overwritten.
+//
+// - PMC = 0b10
+// - BAS = 0b1111
+// - HMC = 0
+// - SSC = 0
+// - LBN = 0
+// - BT = 0
+
+// Enable/disable the breakpoint.
+#define ARM64_DBGBCR_E 1lu // Bit 0
+#define ARM64_DBGBCR_E_SHIFT 0u
+#define ARM64_DBGBCR_E_MASK (ARM64_DBGBCR_E << ARM64_DBGBCR_E_SHIFT)
+#define ARM64_DBGBCR_E_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_E_MASK, ARM64_DBGBCR_E_SHIFT)
+#define ARM64_DBGBCR_E_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_E_MASK, \
+ ARM64_DBGBCR_E_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_PMC 0b11lu // Bits 1-2.
+#define ARM64_DBGBCR_PMC_SHIFT 1u
+#define ARM64_DBGBCR_PMC_MASK (ARM64_DBGBCR_PMC << ARM64_DBGBCR_PMC_SHIFT)
+#define ARM64_DBGBCR_PMC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_PMC_MASK, ARM64_DBGBCR_PMC_SHIFT)
+#define ARM64_DBGBCR_PMC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_PMC_MASK, \
+ ARM64_DBGBCR_PMC_SHIFT)
+
+// Byte Address Select. Defines which half-words triggers the breakpoint.
+// In AArch64 implementations (which zircon targets), is res1.
+#define ARM64_DBGBCR_BAS 0b1111lu // Bits 5-8.
+#define ARM64_DBGBCR_BAS_SHIFT 5u
+#define ARM64_DBGBCR_BAS_MASK (ARM64_DBGBCR_BAS << ARM64_DBGBCR_BAS_SHIFT)
+#define ARM64_DBGBCR_BAS_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_BAS_MASK, ARM64_DBGBCR_BAS_SHIFT)
+#define ARM64_DBGBCR_BAS_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_BAS_MASK, \
+ ARM64_DBGBCR_BAS_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_HMC 0b1lu // Bit 13.
+#define ARM64_DBGBCR_HMC_SHIFT 13u
+#define ARM64_DBGBCR_HMC_MASK (ARM64_DBGBCR_HMC << ARM64_DBGBCR_HMC_SHIFT)
+#define ARM64_DBGBCR_HMC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_HMC_MASK, ARM64_DBGBCR_HMC_SHIFT)
+#define ARM64_DBGBCR_HMC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_HMC_MASK, \
+ ARM64_DBGBCR_HMC_SHIFT)
+
+// PMC, HMC, SSC define the environment where the breakpoint will trigger.
+#define ARM64_DBGBCR_SSC 0b11lu // Bits 14-15.
+#define ARM64_DBGBCR_SSC_SHIFT 14u
+#define ARM64_DBGBCR_SSC_MASK (ARM64_DBGBCR_SSC << ARM64_DBGBCR_SSC_SHIFT)
+#define ARM64_DBGBCR_SSC_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_SSC_MASK, ARM64_DBGBCR_SSC_SHIFT)
+#define ARM64_DBGBCR_SSC_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_SSC_MASK, \
+ ARM64_DBGBCR_SSC_SHIFT)
+
+// Linked Breakpoint Number. Zircon doesn't use this feature. Always zero.
+#define ARM64_DBGBCR_LBN 0b1111lu // Bits 16-19.
+#define ARM64_DBGBCR_LBN_SHIFT 16u
+#define ARM64_DBGBCR_LBN_MASK (ARM64_DBGBCR_LBN << ARM64_DBGBCR_LBN_SHIFT)
+#define ARM64_DBGBCR_LBN_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_LBN_MASK, ARM64_DBGBCR_LBN_SHIFT)
+#define ARM64_DBGBCR_LBN_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_LBN_MASK, \
+ ARM64_DBGBCR_LBN_SHIFT)
+
+// Breakpoint Type. Zircon only uses unlinked address match (zero).
+#define ARM64_DBGBCR_BT 0b1111lu // Bits 20-23.
+#define ARM64_DBGBCR_BT_SHIFT 20u
+#define ARM64_DBGBCR_BT_MASK (ARM64_DBGBCR_BT << ARM64_DBGBCR_BT_SHIFT)
+#define ARM64_DBGBCR_BT_GET(dbgbcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgbcr), ARM64_DBGBCR_BT_MASK, ARM64_DBGBCR_BT_SHIFT)
+#define ARM64_DBGBCR_BT_SET(dbgbcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgbcr), (value), ARM64_DBGBCR_BT_MASK, \
+ ARM64_DBGBCR_BT_SHIFT)
+
+// Watchpoints ------------------------------------------------------------------------------------
+
+// Watchpoints permits to stop a thread when it read/writes to a particular address in memory.
+// This will work even if the address is read-only memory (for a read, of course).
+
+// ARMv8 assures at least 2 watchpoints.
+#define ARM64_MIN_HW_WATCHPOINTS 2
+#define ARM64_MAX_HW_WATCHPOINTS 16
+
+// DBGWCR<n>: Watchpoint Control Register.
+//
+// Control register for watchpoints. There is one for each watchpoint present within the system.
+// They go numbering by DBGWCR0, DBGWCR1, ... until the value defined ID_AAFR0_EL1.
+// For each control register, there is an equivalent DBGWCR<n> that holds the address the thread
+// will compare against. How this address is interpreted depends upon the configuration of the
+// associated control register.
+
+// The following fields are accepted by the user. All other fields are ignored (masked).
+//
+// - E
+// - BAS
+// - TODO(donosoc): Expose LSC.
+
+// This mask is applied when to DBGWCR. Any set values on those fields will be overwritten.
+//
+// - PAC = 0b10
+// - LSC = 0b10: Write watchpoint. TODO(donosoc): Expose to users so they can define it.
+// - HMC = 0
+// - SSC = 0b01
+// - LBN = 0
+// - WT = 0
+
+// Enable/disable the watchpoint.
+#define ARM64_DBGWCR_E 1lu // Bit 1.
+#define ARM64_DBGWCR_E_SHIFT 0u
+#define ARM64_DBGWCR_E_MASK (ARM64_DBGWCR_E << ARM64_DBGWCR_E_SHIFT)
+#define ARM64_DBGWCR_E_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_E_MASK, ARM64_DBGWCR_E_SHIFT)
+#define ARM64_DBGWCR_E_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_E_MASK, \
+ ARM64_DBGWCR_E_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_PAC 0b11lu // Bits 1-2.
+#define ARM64_DBGWCR_PAC_SHIFT 1u
+#define ARM64_DBGWCR_PAC_MASK (ARM64_DBGWCR_PAC << ARM64_DBGWCR_PAC_SHIFT)
+#define ARM64_DBGWCR_PAC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_PAC_MASK, ARM64_DBGWCR_PAC_SHIFT)
+#define ARM64_DBGWCR_PAC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_PAC_MASK, \
+ ARM64_DBGWCR_PAC_SHIFT)
+
+// Load/Store Control.
+//
+// On what event the watchpoint trigger:
+// 01: Read from address.
+// 10: Write to address.
+// 11: Read/Write to address.
+#define ARM64_DBGWCR_LSC 0b11lu // Bits 3-4.
+#define ARM64_DBGWCR_LSC_SHIFT 3u
+#define ARM64_DBGWCR_LSC_MASK (ARM64_DBGWCR_LSC << ARM64_DBGWCR_LSC_SHIFT)
+#define ARM64_DBGWCR_LSC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_LSC_MASK, ARM64_DBGWCR_LSC_SHIFT)
+#define ARM64_DBGWCR_LSC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_LSC_MASK, \
+ ARM64_DBGWCR_LSC_SHIFT)
+
+// Byte Address Select.
+//
+// Each bit defines what bytes to match onto:
+// 0bxxxx'xxx1: Match DBGWVR<n> + 0
+// 0bxxxx'xx1x: Match DBGWVR<n> + 1
+// 0bxxxx'x1xx: Match DBGWVR<n> + 2
+// 0bxxxx'1xxx: Match DBGWVR<n> + 3
+// 0bxxx1'xxxx: Match DBGWVR<n> + 4
+// 0bxx1x'xxxx: Match DBGWVR<n> + 5
+// 0bx1xx'xxxx: Match DBGWVR<n> + 6
+// 0b1xxx'xxxx: Match DBGWVR<n> + 7
+#define ARM64_DBGWCR_BAS 0b11111111lu // Bits 5-12.
+#define ARM64_DBGWCR_BAS_SHIFT 5u
+#define ARM64_DBGWCR_BAS_MASK (ARM64_DBGWCR_BAS << ARM64_DBGWCR_BAS_SHIFT)
+#define ARM64_DBGWCR_BAS_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_BAS_MASK, ARM64_DBGWCR_BAS_SHIFT)
+#define ARM64_DBGWCR_BAS_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_BAS_MASK, \
+ ARM64_DBGWCR_BAS_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_HMC 1lu // Bit 13.
+#define ARM64_DBGWCR_HMC_SHIFT 13u
+#define ARM64_DBGWCR_HMC_MASK (ARM64_DBGWCR_HMC << ARM64_DBGWCR_HMC_SHIFT)
+#define ARM64_DBGWCR_HMC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_HMC_MASK, ARM64_DBGWCR_HMC_SHIFT)
+#define ARM64_DBGWCR_HMC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_HMC_MASK, \
+ ARM64_DBGWCR_HMC_SHIFT)
+
+// PAC, SSC, HMC define the environment where the watchpoint will trigger.
+#define ARM64_DBGWCR_SSC 0b11lu // Bits 14-15.
+#define ARM64_DBGWCR_SSC_SHIFT 14u
+#define ARM64_DBGWCR_SSC_MASK (ARM64_DBGWCR_SSC << ARM64_DBGWCR_SSC_SHIFT)
+#define ARM64_DBGWCR_SSC_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_SSC_MASK, ARM64_DBGWCR_SSC_SHIFT)
+#define ARM64_DBGWCR_SSC_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_SSC_MASK, \
+ ARM64_DBGWCR_SSC_SHIFT)
+
+// Linked Breakpoint Number. Zircon doesn't use this feature. Always zero.
+#define ARM64_DBGWCR_LBN 0b1111lu // Bits 16-19.
+#define ARM64_DBGWCR_LBN_SHIFT 16u
+#define ARM64_DBGWCR_LBN_MASK (ARM64_DBGWCR_LBN << ARM64_DBGWCR_LBN_SHIFT)
+#define ARM64_DBGWCR_LBN_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_LBN_MASK, ARM64_DBGWCR_LBN_SHIFT)
+#define ARM64_DBGWCR_LBN_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_LBN_MASK, \
+ ARM64_DBGWCR_LBN_SHIFT)
+
+// Watchpoint Type. Zircon always use unlinked (0).
+#define ARM64_DBGWCR_WT 1lu // Bit 20.
+#define ARM64_DBGWCR_WT_SHIFT 20u
+#define ARM64_DBGWCR_WT_MASK (ARM64_DBGWCR_WT << ARM64_DBGWCR_WT_SHIFT)
+#define ARM64_DBGWCR_WT_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_WT_MASK, ARM64_DBGWCR_WT_SHIFT)
+#define ARM64_DBGWCR_WT_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_WT_MASK, \
+ ARM64_DBGWCR_WT_SHIFT)
+
+// Mask. How many address bits to mask.
+// This permits the watchpoint to track up to 2G worth of addresses.
+// TODO(donosoc): Initially the debugger is going for parity with x64, which only permits 8 bytes.
+// Eventually expose the ability to track bigger ranges.
+#define ARM64_DBGWCR_MSK 0b11111lu // Bits 24-28.
+#define ARM64_DBGWCR_MSK_SHIFT 24u
+#define ARM64_DBGWCR_MSK_MASK (ARM64_DBGWCR_MSK << ARM64_DBGWCR_MSK_SHIFT)
+#define ARM64_DBGWCR_MSK_GET(dbgwcr) \
+ __arm64_internal_hw_debug_get_reg_value((dbgwcr), ARM64_DBGWCR_MSK_MASK, ARM64_DBGWCR_MSK_SHIFT)
+#define ARM64_DBGWCR_MSK_SET(dbgwcr, value) \
+ __arm64_internal_hw_debug_set_reg_value((dbgwcr), (value), ARM64_DBGWCR_MSK_MASK, \
+ ARM64_DBGWCR_MSK_SHIFT)
+
+// Helper functions ================================================================================
+
+inline uint32_t __arm64_internal_hw_debug_get_reg_value(uint32_t reg, uint32_t mask,
+ uint32_t shift) {
+ return (reg & mask) >> shift;
+}
+
+inline void __arm64_internal_hw_debug_set_reg_value(uint32_t* reg, uint32_t value, uint32_t mask,
+ uint32_t shift) {
+ *reg &= ~mask;
+ *reg |= (value << shift) & mask;
+}
+
+#endif // SYSROOT_ZIRCON_HW_DEBUG_ARM64_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/debug/x86.h b/arch/x64/sysroot/include/zircon/hw/debug/x86.h
new file mode 100644
index 0000000..413b63a
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/debug/x86.h
@@ -0,0 +1,421 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_DEBUG_X86_H_
+#define SYSROOT_ZIRCON_HW_DEBUG_X86_H_
+
+#include <stdint.h>
+
+// x86/x64 Hardware Debug Resources
+// =================================================================================================
+
+// Hardware Breakpoints ----------------------------------------------------------------------------
+//
+// Hardware breakpoints permits to stop a thread when it executes an address setup in one of the
+// hw breakpoints registers. They will work independent whether the address in question is
+// read-only or not.
+
+// Access macros:
+// All the relevant register fields are exposed through macros.
+// For convenience of use, use the get/set macros:
+//
+// uint64_t X86_<REG>_<FIELD>_GET(uint64_t reg)
+// void X86_<REG>_<FIELD>_SET(uint64_t* reg, uint64_t value)
+//
+// Examples:
+// uint64_t rw0 = X86_DBG_CONTROL_RW0_GET(dr7);
+// X86_DBG_CONTROL_RW0_SET(&dr7, modified_rw0);
+
+// DR6: Debug Status Register.
+//
+// This register is updated when the CPU encounters a #DB harware exception. This registers permits
+// users to interpret the result of an exception, such as if it was a single-step, hardware
+// breakpoint, etc.
+//
+// No bit is writeable from userspace. All values will be ignored.
+
+// Whether the address-breakpoint register 0 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B0 1ul
+#define X86_DBG_STATUS_B0_SHIFT 0
+#define X86_DBG_STATUS_B0_MASK (X86_DBG_STATUS_B0 << X86_DBG_STATUS_B0_SHIFT)
+#define X86_DBG_STATUS_B0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B0_MASK, X86_DBG_STATUS_B0_SHIFT)
+#define X86_DBG_STATUS_B0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B0_MASK, \
+ X86_DBG_STATUS_B0_SHIFT)
+
+// Whether the address-breakpoint register 1 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B1 1ul
+#define X86_DBG_STATUS_B1_SHIFT 1
+#define X86_DBG_STATUS_B1_MASK (X86_DBG_STATUS_B1 << X86_DBG_STATUS_B1_SHIFT)
+#define X86_DBG_STATUS_B1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B1_MASK, X86_DBG_STATUS_B1_SHIFT)
+#define X86_DBG_STATUS_B1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B1_MASK, \
+ X86_DBG_STATUS_B1_SHIFT)
+
+// Whether the address-breakpoint register 2 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B2 1ul
+#define X86_DBG_STATUS_B2_SHIFT 2
+#define X86_DBG_STATUS_B2_MASK (X86_DBG_STATUS_B2 << X86_DBG_STATUS_B2_SHIFT)
+#define X86_DBG_STATUS_B2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B2_MASK, X86_DBG_STATUS_B2_SHIFT)
+#define X86_DBG_STATUS_B2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B2_MASK, \
+ X86_DBG_STATUS_B2_SHIFT)
+
+// Whether the address-breakpoint register 3 detects an enabled breakpoint condition, as specified
+// by the DR7 register. It is cleared to 0 otherwise.
+#define X86_DBG_STATUS_B3 1ul
+#define X86_DBG_STATUS_B3_SHIFT 3
+#define X86_DBG_STATUS_B3_MASK (X86_DBG_STATUS_B3 << X86_DBG_STATUS_B3_SHIFT)
+#define X86_DBG_STATUS_B3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_B3_MASK, X86_DBG_STATUS_B3_SHIFT)
+#define X86_DBG_STATUS_B3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_B3_MASK, \
+ X86_DBG_STATUS_B3_SHIFT)
+
+// Whether there were any software accesses to any debug register (DR0, DR7) while the
+// general-detect condition was enabled in DR7.
+#define X86_DBG_STATUS_BD 1ul
+#define X86_DBG_STATUS_BD_SHIFT 13
+#define X86_DBG_STATUS_BD_MASK (X86_DBG_STATUS_BD << X86_DBG_STATUS_BD_SHIFT)
+#define X86_DBG_STATUS_BD_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BD_MASK, X86_DBG_STATUS_BD_SHIFT)
+#define X86_DBG_STATUS_BD_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BD_MASK, \
+ X86_DBG_STATUS_BD_SHIFT)
+
+// Set to 1 whether the #DB exception occurs as a result of a single-step exception. Single step
+// has the highest priority among debug exceptions. Other status bits can be set within the DR6
+// register among this bit, so callers should also check for those.
+#define X86_DBG_STATUS_BS 1ul
+#define X86_DBG_STATUS_BS_SHIFT 14
+#define X86_DBG_STATUS_BS_MASK (X86_DBG_STATUS_BS << X86_DBG_STATUS_BS_SHIFT)
+#define X86_DBG_STATUS_BS_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BS_MASK, X86_DBG_STATUS_BS_SHIFT)
+#define X86_DBG_STATUS_BS_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BS_MASK, \
+ X86_DBG_STATUS_BS_SHIFT)
+
+// Set to 1 when the exception occurred as a result of a intel task switch to another intel task
+// with a TSS T-bit set to 1. This is not used by zircon.
+#define X86_DBG_STATUS_BT 1ul
+#define X86_DBG_STATUS_BT_SHIFT 15
+#define X86_DBG_STATUS_BT_MASK (X86_DBG_STATUS_BT << X86_DBG_STATUS_BT_SHIFT)
+#define X86_DBG_STATUS_BT_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_STATUS_BT_MASK, X86_DBG_STATUS_BT_SHIFT)
+#define X86_DBG_STATUS_BT_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_STATUS_BT_MASK, \
+ X86_DBG_STATUS_BT_SHIFT)
+
+// DR7: Debug Control Register.
+//
+// This register is used to establish the breakpoint conditions for the address breakpoint registers
+// (DR0-DR3) and to enable debug exceptions for each of them individually. DR7 is also used to
+// enable general-detect breakpoint condition (not permitted by zircon).
+//
+// The following fields are accepted by the user. All other fields are ignored (masked):
+//
+// - L0, L1, L2, L3
+// - LEN0, LEN1, LEN2, LEN3
+// - RW0, RW1, RW2, RW3
+
+// Local Breakpoint Enable 0.
+// Enables debug exceptions to occur when the corresponding address register (DR0) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L0 1ul
+#define X86_DBG_CONTROL_L0_SHIFT 0
+#define X86_DBG_CONTROL_L0_MASK (X86_DBG_CONTROL_L0 << X86_DBG_CONTROL_L0_SHIFT)
+#define X86_DBG_CONTROL_L0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L0_MASK, X86_DBG_CONTROL_L0_SHIFT)
+#define X86_DBG_CONTROL_L0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L0_MASK, \
+ X86_DBG_CONTROL_L0_SHIFT)
+
+// Global Breakpoint Enable 0.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR0) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G0 1ul
+#define X86_DBG_CONTROL_G0_SHIFT 1
+#define X86_DBG_CONTROL_G0_MASK (X86_DBG_CONTROL_G0 << X86_DBG_CONTROL_G0_SHIFT)
+#define X86_DBG_CONTROL_G0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G0_MASK, X86_DBG_CONTROL_G0_SHIFT)
+#define X86_DBG_CONTROL_G0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G0_MASK, \
+ X86_DBG_CONTROL_G0_SHIFT)
+
+// Local Breakpoint Enable 1.
+// Enables debug exceptions to occur when the corresponding address register (DR1) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L1 1ul
+#define X86_DBG_CONTROL_L1_SHIFT 2
+#define X86_DBG_CONTROL_L1_MASK (X86_DBG_CONTROL_L1 << X86_DBG_CONTROL_L1_SHIFT)
+#define X86_DBG_CONTROL_L1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L1_MASK, X86_DBG_CONTROL_L1_SHIFT)
+#define X86_DBG_CONTROL_L1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L1_MASK, \
+ X86_DBG_CONTROL_L1_SHIFT)
+
+// Global Breakpoint Enable 1.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR1) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G1 1ul
+#define X86_DBG_CONTROL_G1_SHIFT 3
+#define X86_DBG_CONTROL_G1_MASK (X86_DBG_CONTROL_G1 << X86_DBG_CONTROL_G1_SHIFT)
+#define X86_DBG_CONTROL_G1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G1_MASK, X86_DBG_CONTROL_G1_SHIFT)
+#define X86_DBG_CONTROL_G1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G1_MASK, \
+ X86_DBG_CONTROL_G1_SHIFT)
+
+// Local Breakpoint Enable 2.
+// Enables debug exceptions to occur when the corresponding address register (DR2) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L2 1ul
+#define X86_DBG_CONTROL_L2_SHIFT 4
+#define X86_DBG_CONTROL_L2_MASK (X86_DBG_CONTROL_L2 << X86_DBG_CONTROL_L2_SHIFT)
+#define X86_DBG_CONTROL_L2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L2_MASK, X86_DBG_CONTROL_L2_SHIFT)
+#define X86_DBG_CONTROL_L2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L2_MASK, \
+ X86_DBG_CONTROL_L2_SHIFT)
+
+// Global Breakpoint Enable 2.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR2) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G2 1ul
+#define X86_DBG_CONTROL_G2_SHIFT 5
+#define X86_DBG_CONTROL_G2_MASK (X86_DBG_CONTROL_G2 << X86_DBG_CONTROL_G2_SHIFT)
+#define X86_DBG_CONTROL_G2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G2_MASK, X86_DBG_CONTROL_G2_SHIFT)
+#define X86_DBG_CONTROL_G2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G2_MASK, \
+ X86_DBG_CONTROL_G2_SHIFT)
+
+// Local Breakpoint Enable 3.
+// Enables debug exceptions to occur when the corresponding address register (DR3) detects a
+// breakpoint condition on the current intel task. This bit is never cleared by the processor.
+#define X86_DBG_CONTROL_L3 1ul
+#define X86_DBG_CONTROL_L3_SHIFT 6
+#define X86_DBG_CONTROL_L3_MASK (X86_DBG_CONTROL_L3 << X86_DBG_CONTROL_L3_SHIFT)
+#define X86_DBG_CONTROL_L3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_L3_MASK, X86_DBG_CONTROL_L3_SHIFT)
+#define X86_DBG_CONTROL_L3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_L3_MASK, \
+ X86_DBG_CONTROL_L3_SHIFT)
+
+// Global Breakpoint Enable 3.
+// Enables debug exceptions to occur when the corresponding address breakpoint (DR3) detects a
+// breakpoint condition while executing *any* intel task. This bit is not cleared by the processor.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_G3 1u
+#define X86_DBG_CONTROL_G3_SHIFT 7
+#define X86_DBG_CONTROL_G3_MASK (X86_DBG_CONTROL_G3 << X86_DBG_CONTROL_G3_SHIFT)
+#define X86_DBG_CONTROL_G3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_G3_MASK, X86_DBG_CONTROL_G3_SHIFT)
+#define X86_DBG_CONTROL_G3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_G3_MASK, \
+ X86_DBG_CONTROL_G3_SHIFT)
+
+// Local Enable [Legacy Implementations].
+// Enables exact breakpoints on the while executing the current intel task. This bit is ignored by
+// implementations of the AMD64 architecture.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_LE 1ul
+#define X86_DBG_CONTROL_LE_SHIFT 8
+#define X86_DBG_CONTROL_LE_MASK (X86_DBG_CONTROL_LE << X86_DBG_CONTROL_LE_SHIFT)
+#define X86_DBG_CONTROL_LE_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LE_MASK, X86_DBG_CONTROL_LE_SHIFT)
+#define X86_DBG_CONTROL_LE_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LE_MASK, \
+ X86_DBG_CONTROL_LE_SHIFT)
+
+// Global Enable [Legacy Implementations].
+// Enables exact breakpoints on the while executing *any* intel task. This bit is ignored by
+// implementations of the AMD64 architecture.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_GE 1ul
+#define X86_DBG_CONTROL_GE_SHIFT 9
+#define X86_DBG_CONTROL_GE_MASK (X86_DBG_CONTROL_GE << X86_DBG_CONTROL_GE_SHIFT)
+#define X86_DBG_CONTROL_GE_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_GE_MASK, X86_DBG_CONTROL_GE_SHIFT)
+#define X86_DBG_CONTROL_GE_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_GE_MASK, \
+ X86_DBG_CONTROL_GE_SHIFT)
+
+// General Detect Enable.
+// Whether an attempt to execute a "MOV DR<n>" instruction will trigger a debug exception. This bit
+// is cleared when a #DB handler is entered, so the handler can read/write to those registers.
+// This exception occurs before executing the instruction and DR6.DB is set the the processor.
+// Debuggers can use this bit to prevent the currently executing prgram from interfering with the
+// debug operations.
+// Zircon does not permit to set this bit.
+#define X86_DBG_CONTROL_GD 1ul
+#define X86_DBG_CONTROL_GD_SHIFT 13
+#define X86_DBG_CONTROL_GD_MASK (X86_DBG_CONTROL_GD << X86_DBG_CONTROL_GD_SHIFT)
+#define X86_DBG_CONTROL_GD_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_GD_MASK, X86_DBG_CONTROL_GD_SHIFT)
+#define X86_DBG_CONTROL_GD_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_GD_MASK, \
+ X86_DBG_CONTROL_GD_SHIFT)
+
+// Read/Write 0.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR0).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW0 3ul
+#define X86_DBG_CONTROL_RW0_SHIFT 16
+#define X86_DBG_CONTROL_RW0_MASK (X86_DBG_CONTROL_RW0 << X86_DBG_CONTROL_RW0_SHIFT)
+#define X86_DBG_CONTROL_RW0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW0_MASK, X86_DBG_CONTROL_RW0_SHIFT)
+#define X86_DBG_CONTROL_RW0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW0_MASK, \
+ X86_DBG_CONTROL_RW0_SHIFT)
+
+// Length 0.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR0). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN0 3ul
+#define X86_DBG_CONTROL_LEN0_SHIFT 18
+#define X86_DBG_CONTROL_LEN0_MASK (X86_DBG_CONTROL_LEN0 << X86_DBG_CONTROL_LEN0_SHIFT)
+#define X86_DBG_CONTROL_LEN0_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN0_MASK, \
+ X86_DBG_CONTROL_LEN0_SHIFT)
+#define X86_DBG_CONTROL_LEN0_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN0_MASK, \
+ X86_DBG_CONTROL_LEN0_SHIFT)
+
+// Read/Write 1.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR1).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW1 3ul
+#define X86_DBG_CONTROL_RW1_SHIFT 20
+#define X86_DBG_CONTROL_RW1_MASK (X86_DBG_CONTROL_RW1 << X86_DBG_CONTROL_RW1_SHIFT)
+#define X86_DBG_CONTROL_RW1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW1_MASK, X86_DBG_CONTROL_RW1_SHIFT)
+#define X86_DBG_CONTROL_RW1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW1_MASK, \
+ X86_DBG_CONTROL_RW1_SHIFT)
+
+// Length 1.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR1). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN1 3ul
+#define X86_DBG_CONTROL_LEN1_SHIFT 22
+#define X86_DBG_CONTROL_LEN1_MASK (X86_DBG_CONTROL_LEN1 << X86_DBG_CONTROL_LEN1_SHIFT)
+#define X86_DBG_CONTROL_LEN1_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN1_MASK, \
+ X86_DBG_CONTROL_LEN1_SHIFT)
+#define X86_DBG_CONTROL_LEN1_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN1_MASK, \
+ X86_DBG_CONTROL_LEN1_SHIFT)
+
+// Read/Write 2.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR2).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW2 3ul
+#define X86_DBG_CONTROL_RW2_SHIFT 24
+#define X86_DBG_CONTROL_RW2_MASK (X86_DBG_CONTROL_RW2 << X86_DBG_CONTROL_RW2_SHIFT)
+#define X86_DBG_CONTROL_RW2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW2_MASK, X86_DBG_CONTROL_RW2_SHIFT)
+#define X86_DBG_CONTROL_RW2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW2_MASK, \
+ X86_DBG_CONTROL_RW2_SHIFT)
+
+// Length 2.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR2). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN2 3ul
+#define X86_DBG_CONTROL_LEN2_SHIFT 26
+#define X86_DBG_CONTROL_LEN2_MASK (X86_DBG_CONTROL_LEN2 << X86_DBG_CONTROL_LEN2_SHIFT)
+#define X86_DBG_CONTROL_LEN2_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN2_MASK, \
+ X86_DBG_CONTROL_LEN2_SHIFT)
+#define X86_DBG_CONTROL_LEN2_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN2_MASK, \
+ X86_DBG_CONTROL_LEN2_SHIFT)
+
+// Read/Write 3.
+// Controls the breakpoint conditions used by the corresponding address breakpoint register (DR3).
+// The values are:
+// - 00: Only instruction execution.
+// - 01: Only data write.
+// - 10: Dependant by CR4.DE. Not supported by Zircon.
+// - CR4.DE = 0: Undefined.
+// - CR4.DE = 1: Only on I/0 read/write.
+// - 11: Only on data read/write.
+#define X86_DBG_CONTROL_RW3 3ul
+#define X86_DBG_CONTROL_RW3_SHIFT 28
+#define X86_DBG_CONTROL_RW3_MASK (X86_DBG_CONTROL_RW3 << X86_DBG_CONTROL_RW3_SHIFT)
+#define X86_DBG_CONTROL_RW3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_RW3_MASK, X86_DBG_CONTROL_RW3_SHIFT)
+#define X86_DBG_CONTROL_RW3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_RW3_MASK, \
+ X86_DBG_CONTROL_RW3_SHIFT)
+
+// Length 3.
+// Controls the range used in comparing a memory address with the corresponding address breakpoint
+// register (DR3). The values are:
+// - 00: 1 byte.
+// - 01: 2 byte. DR0 must be 2 byte aligned.
+// - 10: 8 byte. DR0 must be 8 byte aligned.
+// - 11: 4 byte. DR0 must be 4 byte aligned.
+#define X86_DBG_CONTROL_LEN3 3ul
+#define X86_DBG_CONTROL_LEN3_SHIFT 30
+#define X86_DBG_CONTROL_LEN3_MASK (X86_DBG_CONTROL_LEN3 << X86_DBG_CONTROL_LEN3_SHIFT)
+#define X86_DBG_CONTROL_LEN3_GET(reg) \
+ __x86_internal_hw_debug_get_reg_value((reg), X86_DBG_CONTROL_LEN3_MASK, \
+ X86_DBG_CONTROL_LEN3_SHIFT)
+#define X86_DBG_CONTROL_LEN3_SET(reg, value) \
+ __x86_internal_hw_debug_set_reg_value((reg), (value), X86_DBG_CONTROL_LEN3_MASK, \
+ X86_DBG_CONTROL_LEN3_SHIFT)
+
+// Helper functions ================================================================================
+
+inline uint64_t __x86_internal_hw_debug_get_reg_value(uint64_t reg, uint64_t mask, uint64_t shift) {
+ return (reg & mask) >> shift;
+}
+
+inline void __x86_internal_hw_debug_set_reg_value(uint64_t* reg, uint64_t value, uint64_t mask,
+ uint64_t shift) {
+ *reg &= ~mask;
+ *reg |= (value << shift) & mask;
+}
+
+#endif // SYSROOT_ZIRCON_HW_DEBUG_X86_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/gpt.h b/arch/x64/sysroot/include/zircon/hw/gpt.h
index c3112f5..d93a23c 100644
--- a/arch/x64/sysroot/include/zircon/hw/gpt.h
+++ b/arch/x64/sysroot/include/zircon/hw/gpt.h
@@ -2,59 +2,224 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_GPT_H_
+#define SYSROOT_ZIRCON_HW_GPT_H_
+#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
-
#include <zircon/compiler.h>
-#define GPT_MAGIC (0x5452415020494645ull) // 'EFI PART'
+#define GPT_MAGIC (0x5452415020494645ull) // 'EFI PART'
#define GPT_HEADER_SIZE 0x5c
-#define GPT_ENTRY_SIZE 0x80
+#define GPT_ENTRY_SIZE 0x80
#define GPT_GUID_LEN 16
#define GPT_GUID_STRLEN 37
#define GPT_NAME_LEN 72
typedef struct gpt_header {
- uint64_t magic;
- uint32_t revision;
- uint32_t size;
- uint32_t crc32;
- uint32_t reserved0;
- uint64_t current;
- uint64_t backup;
- uint64_t first;
- uint64_t last;
- uint8_t guid[GPT_GUID_LEN];
- uint64_t entries;
- uint32_t entries_count;
- uint32_t entries_size;
- uint32_t entries_crc;
+ uint64_t magic; // Magic number.
+ uint32_t revision; // Revision.
+ uint32_t size; // Size of the header.
+ uint32_t crc32; // Checksum of this header.
+ uint32_t reserved0; // Reserved field.
+ uint64_t current; // Block where this table is stored.
+ uint64_t backup; // Block where other copy of partition table is stored.
+ uint64_t first; // First usable block. Block after primary partition table ends.
+ uint64_t last; // Last usable block. Block before backup partition table starts.
+ uint8_t guid[GPT_GUID_LEN]; // Disk GUID.
+ uint64_t entries; // Starting block where entries for this partition tables are found.
+ // Value equals 2 for primary copy.
+ uint32_t entries_count; // Total number of entries.
+ uint32_t entries_size; // Size of each entry.
+ uint32_t entries_crc; // Checksum of the entire entries array.
} __PACKED gpt_header_t;
-typedef struct gpt_entry {
- uint8_t type[GPT_GUID_LEN];
- uint8_t guid[GPT_GUID_LEN];
- uint64_t first;
- uint64_t last;
- uint64_t flags;
- uint8_t name[GPT_NAME_LEN]; // UTF-16 on disk
-} __PACKED gpt_entry_t;
+static_assert(GPT_HEADER_SIZE == sizeof(gpt_header_t), "Gpt header size invalid");
+typedef struct gpt_entry {
+ uint8_t type[GPT_GUID_LEN];
+ uint8_t guid[GPT_GUID_LEN];
+ uint64_t first;
+ uint64_t last;
+ uint64_t flags;
+ uint8_t name[GPT_NAME_LEN]; // UTF-16 on disk
+} gpt_entry_t;
+
+static_assert(GPT_ENTRY_SIZE == sizeof(gpt_entry_t), "Gpt entry size invalid");
+
+// GUIDs are specified in mixed-endian, to avoid manual errors use this macro.
+// Example usage: GPT_GUID(0x00112233, 0x4455, 0x6677, 0x8899, 0xAABBCCDDEEFF)
+// clang-format off
+#define GPT_GUID(group0, group1, group2, group3, group4) { \
+ /* group0: 4 bytes, little-endian. */ \
+ (group0 >> 0) & 0xFF, \
+ (group0 >> 8) & 0xFF, \
+ (group0 >> 16) & 0xFF, \
+ (group0 >> 24) & 0xFF, \
+ /* group1: 2 bytes, little-endian. */ \
+ (group1 >> 0) & 0xFF, \
+ (group1 >> 8) & 0xFF, \
+ /* group2: 2 bytes, little-endian. */ \
+ (group2 >> 0) & 0xFF, \
+ (group2 >> 8) & 0xFF, \
+ /* group3: 2 bytes, big-endian. */ \
+ (group3 >> 8) & 0xFF, \
+ (group3 >> 0) & 0xFF, \
+ /* group4: 6 bytes, big-endian. */ \
+ (group4 >> 40) & 0xFF, \
+ (group4 >> 32) & 0xFF, \
+ (group4 >> 24) & 0xFF, \
+ (group4 >> 16) & 0xFF, \
+ (group4 >> 8) & 0xFF, \
+ (group4 >> 0) & 0xFF \
+}
+// clang-format on
+
+// == GPT partition definitions ==
+//
+// These are some common partition definitions used across various boards.
+// The general scheme is:
+// |type|: identical for slotted partitions, e.g. zircon_{a,b,r} will all
+// share the same type GUID
+// |guid|: unspecified and generally expected to be random
+// |name|: specific name for uniquely identifying partitions
+//
+// New boards should adopt this scheme when possible, but see below for a
+// slightly different legacy scheme used by existing boards.
+
+// clang-format off
+
+// bootloader_{a,b,r}
+//
+// These partitions are optional and may be used to hold bootloader and/or
+// other firmware images. The format is SoC-specific.
+#define GPT_BOOTLOADER_A_NAME "bootloader_a"
+#define GPT_BOOTLOADER_B_NAME "bootloader_b"
+#define GPT_BOOTLOADER_R_NAME "bootloader_r"
+#define GPT_BOOTLOADER_ABR_TYPE_GUID GPT_GUID(0xfe8a2634, 0x5e2e, 0x46ba, 0x99e3, 0x3a192091a350)
+
+// durable
+//
+// This partition holds mutable data that must remain intact across factory
+// reset. It differs from durable_boot only in that it is larger, ignored by
+// bootloaders, and is expected to have a filesystem.
+//
+// This partition is expected to be written to by Fuchsia during normal
+// operation. It is expected to be read by Fuchsia, but not by any bootloader
+// or firmware. It is expected to have a filesystem with encryption built in.
+// Use of this partition increases attack surface and should be minimized.
+#define GPT_DURABLE_NAME "durable"
+#define GPT_DURABLE_TYPE_GUID GPT_GUID(0xd9fd4535, 0x106c, 0x4cec, 0x8d37, 0xdfc020ca87cb)
+
+// durable_boot
+//
+// This partition holds A/B/R metadata and other very small mutable data that
+// must remain intact across factory reset. There is no filesystem and the
+// content layout is fixed.
+//
+// This partition is expected to be written to by Fuchsia and the main
+// bootloader during normal operation. It is expected to be read by bootloaders
+// very early in boot. It has no encryption or integrity check built in. Use of
+// this partition increases attack surface and should be minimized.
+#define GPT_DURABLE_BOOT_NAME "durable_boot"
+#define GPT_DURABLE_BOOT_TYPE_GUID GPT_GUID(0xa409e16b, 0x78aa, 0x4acc, 0x995c, 0x302352621a41)
+
+// factory
+//
+// This partition holds factory-provisioned data used by the Fuchsia-based
+// system and is read-only.
+//
+// It is expected that this partition is only written in the factory and has a
+// simple file system. It is not encrypted, but is checked for integrity by
+// Fuchsia. Bootloaders and firmware are expected to ignore this partition.
+#define GPT_FACTORY_NAME "factory"
+#define GPT_FACTORY_TYPE_GUID GPT_GUID(0xf95d940e, 0xcaba, 0x4578, 0x9b93, 0xbb6c90f29d3e)
+
+// factory_boot
+//
+// This partition holds factory-provisioned data used by the bootloader and is
+// read-only. It must be small enough to be loaded into memory and verified
+// during boot.
+//
+// It is expected that this partition is only written in the factory and has a
+// simple structured format, not a filesystem. It is not encrypted but is
+// checked for integrity by the verified boot process. It is expected to be read
+// only by the main bootloader, not by Fuchsia.
+#define GPT_FACTORY_BOOT_NAME "factory_boot"
+#define GPT_FACTORY_BOOT_TYPE_GUID GPT_GUID(0x10b8dbaa, 0xd2bf, 0x42a9, 0x98c6, 0xa7c5db3701e7)
+
+// fvm
+//
+// This partition is owned by the Fuchsia Volume Manager. It will be used for
+// both system and user data.
+#define GPT_FVM_NAME "fvm"
+#define GPT_FVM_TYPE_GUID GPT_GUID(0x49fd7cb8, 0xdf15, 0x4e73, 0xb9d9, 0x992070127f0f)
+
+// vbmeta_{a,b,r}
+//
+// These partitions each hold verified boot metadata for a particular A/B/R
+// slot. The format is defined by libavb.
+//
+// These partitions are expected to be written in the factory and during an OTA
+// update. They are expected to be read by the main bootloader and possibly by
+// Fuchsia. They are not encrypted, but are checked for integrity as part of the
+// verified boot process.
+#define GPT_VBMETA_A_NAME "vbmeta_a"
+#define GPT_VBMETA_B_NAME "vbmeta_b"
+#define GPT_VBMETA_R_NAME "vbmeta_r"
+#define GPT_VBMETA_ABR_TYPE_GUID GPT_GUID(0x421a8bfc, 0x85d9, 0x4d85, 0xacda, 0xb64eec0133e9)
+
+// zircon_{a,b,r}
+//
+// These partitions each hold a complete Zircon boot image, including an
+// embedded bootfs image, for a particular A/B/R slot.
+//
+// These partitions are expected to be written in the factory and during an OTA
+// update. They are expected to be read only by the main bootloader. They are
+// not encrypted but are checked for integrity as part of the verified boot
+// process.
+#define GPT_ZIRCON_A_NAME "zircon_a"
+#define GPT_ZIRCON_B_NAME "zircon_b"
+#define GPT_ZIRCON_R_NAME "zircon_r"
+#define GPT_ZIRCON_ABR_TYPE_GUID GPT_GUID(0x9b37fff6, 0x2e58, 0x466a, 0x983a, 0xf7926d0b04e0)
+
+// Microsoft basic data partition
+//
+// These partitions usually contain FAT filesystems. They are mounted by the fat
+// implementation at //src/storage/fuchsia-fatfs.
+// These partitions do not have an expected label.
+#define GPT_MICROSOFT_BASIC_DATA_TYPE_GUID \
+ GPT_GUID(0xebd0a0a2, 0xb9e5, 0x4433, 0x87c0, 0x68b6b72699c7)
+
+// clang-format on
+
+// == Legacy GPT partition definitions ==
+//
+// These definitions instead use the following scheme:
+// |type|: unique for each partition, e.g. zircon_{a,b,r} will each have their
+// own type GUID
+// |guid|: unspecified and generally expected to be random
+// |name|: specific name, can use this or |type| find an individual partition
+
+// clang-format off
+#define GUID_EMPTY_STRING "00000000-0000-0000-0000-000000000000"
#define GUID_EMPTY_VALUE { \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, \
0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
}
+#define GUID_EMPTY_NAME "empty"
+#define GUID_EFI_STRING "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
#define GUID_EFI_VALUE { \
0x28, 0x73, 0x2a, 0xc1, \
0x1f, 0xf8, \
0xd2, 0x11, \
0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b \
}
+#define GUID_EFI_NAME "fuchsia-esp"
// GUID for a system partition
#define GUID_SYSTEM_STRING "606B000B-B7C7-4653-A7D5-B737332C899D"
@@ -64,6 +229,7 @@
0x53, 0x46, \
0xa7, 0xd5, 0xb7, 0x37, 0x33, 0x2c, 0x89, 0x9d \
}
+#define GUID_SYSTEM_NAME "fuchsia-system"
// GUID for a data partition
#define GUID_DATA_STRING "08185F0C-892D-428A-A789-DBEEC8F55E6A"
@@ -73,6 +239,7 @@
0x8a, 0x42, \
0xa7, 0x89, 0xdb, 0xee, 0xc8, 0xf5, 0x5e, 0x6a \
}
+#define GUID_DATA_NAME "fuchsia-data"
// GUID for a installer partition
#define GUID_INSTALL_STRING "48435546-4953-2041-494E-5354414C4C52"
@@ -82,6 +249,7 @@
0x41, 0x20, \
0x49, 0x4E, 0x53, 0x54, 0x41, 0x4C, 0x4C, 0x52 \
}
+#define GUID_INSTALL_NAME "fuchsia-install"
#define GUID_BLOB_STRING "2967380E-134C-4CBB-B6DA-17E7CE1CA45D"
#define GUID_BLOB_VALUE { \
@@ -90,6 +258,7 @@
0xbb, 0x4c, \
0xb6, 0xda, 0x17, 0xe7, 0xce, 0x1c, 0xa4, 0x5d \
}
+#define GUID_BLOB_NAME "fuchsia-blob"
#define GUID_FVM_STRING "41D0E340-57E3-954E-8C1E-17ECAC44CFF5"
#define GUID_FVM_VALUE { \
@@ -98,75 +267,188 @@
0x4e, 0x95, \
0x8c, 0x1e, 0x17, 0xec, 0xac, 0x44, 0xcf, 0xf5 \
}
+#define GUID_FVM_NAME "fuchsia-fvm"
#define GUID_ZIRCON_A_STRING "DE30CC86-1F4A-4A31-93C4-66F147D33E05"
-#define GUID_ZIRCON_A_VALUE { \
- 0x86, 0xcc, 0x30, 0xde, \
- 0x4a, 0x1f, \
- 0x31, 0x4a, \
+#define GUID_ZIRCON_A_VALUE { \
+ 0x86, 0xcc, 0x30, 0xde, \
+ 0x4a, 0x1f, \
+ 0x31, 0x4a, \
0x93, 0xc4, 0x66, 0xf1, 0x47, 0xd3, 0x3e, 0x05, \
}
+#define GUID_ZIRCON_A_NAME "zircon-a"
#define GUID_ZIRCON_B_STRING "23CC04DF-C278-4CE7-8471-897D1A4BCDF7"
-#define GUID_ZIRCON_B_VALUE { \
- 0xdf, 0x04, 0xcc, 0x23, \
- 0x78, 0xc2, \
- 0xe7, 0x4c, \
+#define GUID_ZIRCON_B_VALUE { \
+ 0xdf, 0x04, 0xcc, 0x23, \
+ 0x78, 0xc2, \
+ 0xe7, 0x4c, \
0x84, 0x71, 0x89, 0x7d, 0x1a, 0x4b, 0xcd, 0xf7 \
}
+#define GUID_ZIRCON_B_NAME "zircon-b"
#define GUID_ZIRCON_R_STRING "A0E5CF57-2DEF-46BE-A80C-A2067C37CD49"
-#define GUID_ZIRCON_R_VALUE { \
- 0x57, 0xcf, 0xe5, 0xa0, \
- 0xef, 0x2d, \
- 0xbe, 0x46, \
+#define GUID_ZIRCON_R_VALUE { \
+ 0x57, 0xcf, 0xe5, 0xa0, \
+ 0xef, 0x2d, \
+ 0xbe, 0x46, \
0xa8, 0x0c, 0xa2, 0x06, 0x7c, 0x37, 0xcd, 0x49 \
}
+#define GUID_ZIRCON_R_NAME "zircon-r"
#define GUID_SYS_CONFIG_STRING "4E5E989E-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_SYS_CONFIG_VALUE { \
+#define GUID_SYS_CONFIG_VALUE { \
0x9e, 0x98, 0x5e, 0x4e, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_SYS_CONFIG_NAME "sys-config"
#define GUID_FACTORY_CONFIG_STRING "5A3A90BE-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_FACTORY_CONFIG_VALUE { \
+#define GUID_FACTORY_CONFIG_VALUE { \
0xbe, 0x90, 0x3a, 0x5a, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_FACTORY_CONFIG_NAME "factory-config"
#define GUID_BOOTLOADER_STRING "5ECE94FE-4C86-11E8-A15B-480FCF35F8E6"
-#define GUID_BOOTLOADER_VALUE { \
+#define GUID_BOOTLOADER_VALUE { \
0xfe, 0x94, 0xce, 0x5e, \
0x86, 0x4c, \
0xe8, 0x11, \
0xa1, 0x5b, 0x48, 0x0f, 0xcf, 0x35, 0xf8, 0xe6 \
}
+#define GUID_BOOTLOADER_NAME "bootloader"
#define GUID_TEST_STRING "8B94D043-30BE-4871-9DFA-D69556E8C1F3"
-#define GUID_TEST_VALUE { \
+#define GUID_TEST_VALUE { \
0x43, 0xD0, 0x94, 0x8b, \
0xbe, 0x30, \
- 0x71, 0x38, \
+ 0x71, 0x48, \
0x9d, 0xfa, 0xd6, 0x95, 0x56, 0xe8, 0xc1, 0xf3 \
}
+#define GUID_TEST_NAME "guid-test"
#define GUID_VBMETA_A_STRING "A13B4D9A-EC5F-11E8-97D8-6C3BE52705BF"
-#define GUID_VBMETA_A_VALUE { \
+#define GUID_VBMETA_A_VALUE { \
0x9a, 0x4d, 0x3b, 0xa1, \
0x5f, 0xec, \
- 0xd8, 0x97, \
- 0x6c, 0x3b, 0x6c, 0x3b, 0xe2, 0x27, 0x05, 0xbf \
+ 0xe8, 0x11, \
+ 0x97, 0xd8, 0x6c, 0x3b, 0xe5, 0x27, 0x05, 0xbf \
}
+#define GUID_VBMETA_A_NAME "vbmeta_a"
#define GUID_VBMETA_B_STRING "A288ABF2-EC5F-11E8-97D8-6C3BE52705BF"
-#define GUID_VBMETA_B_VALUE { \
+#define GUID_VBMETA_B_VALUE { \
0xf2, 0xab, 0x88, 0xa2, \
0x5f, 0xec, \
- 0xd8, 0x97, \
- 0x6c, 0x3b, 0x6c, 0x3b, 0xe2, 0x27, 0x05, 0xbf \
+ 0xe8, 0x11, \
+ 0x97, 0xd8, 0x6c, 0x3b, 0xe5, 0x27, 0x05, 0xbf \
}
+#define GUID_VBMETA_B_NAME "vbmeta_b"
+
+#define GUID_VBMETA_R_STRING "6A2460C3-CD11-4E8B-80A8-12CCE268ED0A"
+#define GUID_VBMETA_R_VALUE { \
+ 0xc3, 0x60, 0x24, 0x6a, \
+ 0x11, 0xcd, \
+ 0x8b, 0x4e, \
+ 0x80, 0xa8, 0x12, 0xcc, 0xe2, 0x68, 0xed, 0x0a \
+}
+#define GUID_VBMETA_R_NAME "vbmeta_r"
+
+#define GUID_ABR_META_STRING "1D75395D-F2C6-476B-A8B7-45CC1C97B476"
+#define GUID_ABR_META_VALUE { \
+ 0x5d, 0x39, 0x75, 0x1d, \
+ 0xc6, 0xf2, \
+ 0x6b, 0x47, \
+ 0xa8, 0xb7, 0x45, 0xcc, 0x1c, 0x97, 0xb4, 0x76 \
+}
+#define GUID_ABR_META_NAME "misc"
+
+#define GUID_CROS_KERNEL_STRING "FE3A2A5D-4F32-41A7-B725-ACCC3285A309"
+#define GUID_CROS_KERNEL_VALUE { \
+ 0x5d, 0x2a, 0x3a, 0xfe, \
+ 0x32, 0x4f, \
+ 0xa7, 0x41, \
+ 0xb7, 0x25, 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 \
+}
+#define GUID_CROS_KERNEL_NAME "cros-kernel"
+
+#define GUID_CROS_ROOTFS_STRING "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC"
+#define GUID_CROS_ROOTFS_VALUE { \
+ 0x02, 0xe2, 0xb8, 0x3C, \
+ 0x7e, 0x3b, \
+ 0xdd, 0x47, \
+ 0x8a, 0x3c, 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec \
+}
+#define GUID_CROS_ROOTFS_NAME "cros-rootfs"
+
+#define GUID_CROS_RESERVED_STRING "2E0A753D-9E48-43B0-8337-B15192CB1B5E"
+#define GUID_CROS_RESERVED_VALUE { \
+ 0x3d, 0x75, 0x0a, 0x2e, \
+ 0x48, 0x9e, \
+ 0xb0, 0x43, \
+ 0x83, 0x37, 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e \
+}
+#define GUID_CROS_RESERVED_NAME "cros-reserved"
+
+#define GUID_CROS_FIRMWARE_STRING "CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3"
+#define GUID_CROS_FIRMWARE_VALUE { \
+ 0x8e, 0xe8, 0xb6, 0xca, \
+ 0xf3, 0xab, \
+ 0x02, 0x41, \
+ 0xa0, 0x7a, 0xd4, 0xbb, 0x9b, 0xe3, 0xc1, 0xd3 \
+}
+#define GUID_CROS_FIRMWARE_NAME "cros-firmware"
+
+#define GUID_CROS_DATA_STRING "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
+#define GUID_CROS_DATA_VALUE { \
+ 0xa2, 0xa0, 0xd0, 0xeb, \
+ 0xe5, 0xb9, \
+ 0x33, 0x44, \
+ 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 \
+}
+#define GUID_CROS_DATA_NAME "cros-data"
+
+#define GUID_BIOS_STRING "21686148-6449-6E6F-744E-656564454649"
+#define GUID_BIOS_VALUE { \
+ 0x48, 0x61, 0x68, 0x21, \
+ 0x49, 0x64, \
+ 0x6f, 0x6e, \
+ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 \
+}
+#define GUID_BIOS_NAME "bios"
+
+#define GUID_EMMC_BOOT1_STRING "900B0FC5-90CD-4D4F-84F9-9F8ED579DB88"
+#define GUID_EMMC_BOOT1_VALUE { \
+ 0xc5, 0x0f, 0x0b, 0x90, \
+ 0xcd, 0x90, \
+ 0x4f, 0x4d, \
+ 0x84, 0xf9, 0x9f, 0x8e, 0xd5, 0x79, 0xdb, 0x88 \
+}
+#define GUID_EMMC_BOOT1_NAME "emmc-boot1"
+
+#define GUID_EMMC_BOOT2_STRING "B2B2E8D1-7C10-4EBC-A2D0-4614568260AD"
+#define GUID_EMMC_BOOT2_VALUE { \
+ 0xd1, 0xe8, 0xb2, 0xb2, \
+ 0x10, 0x7c, \
+ 0xbc, 0x4e, \
+ 0xa2, 0xd0, 0x46, 0x14, 0x56, 0x82, 0x60, 0xad \
+}
+#define GUID_EMMC_BOOT2_NAME "emmc-boot2"
+
+#define GUID_LINUX_FILESYSTEM_DATA_STRING "0FC63DAF-8483-4772-8E79-3D69D8477DE4"
+#define GUID_LINUX_FILESYSTEM_DATA_VALUE { \
+ 0xaf, 0x3d, 0xc6, 0x0f, \
+ 0x83, 0x84, \
+ 0x72, 0x47, \
+ 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4 \
+}
+#define GUID_LINUX_FILESYSTEM_DATA_NAME "linux-filesystem"
+
+// clang-format on
+
+#endif // SYSROOT_ZIRCON_HW_GPT_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/i2c.h b/arch/x64/sysroot/include/zircon/hw/i2c.h
index a8f0f4b..e35b6f1 100644
--- a/arch/x64/sysroot/include/zircon/hw/i2c.h
+++ b/arch/x64/sysroot/include/zircon/hw/i2c.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_I2C_H_
+#define SYSROOT_ZIRCON_HW_I2C_H_
#define I2C_CLASS_HID 1
+
+#endif // SYSROOT_ZIRCON_HW_I2C_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/pci.h b/arch/x64/sysroot/include/zircon/hw/pci.h
index 06c7023..7de1bca 100644
--- a/arch/x64/sysroot/include/zircon/hw/pci.h
+++ b/arch/x64/sysroot/include/zircon/hw/pci.h
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_HW_PCI_H_
-#define ZIRCON_HW_PCI_H_
+#ifndef SYSROOT_ZIRCON_HW_PCI_H_
+#define SYSROOT_ZIRCON_HW_PCI_H_
#include <stdint.h>
#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// Structure for passing around PCI address information
typedef struct pci_bdf {
- uint8_t bus_id;
- uint8_t device_id;
- uint8_t function_id;
+ uint8_t bus_id;
+ uint8_t device_id;
+ uint8_t function_id;
} pci_bdf_t;
// TODO(cja): This header is used for the transition of these defines from
@@ -43,8 +43,8 @@
#define PCI_INVALID_VENDOR_ID (0xFFFF)
-#endif // WITH_KERNEL_PCIE
+#endif // WITH_KERNEL_PCIE
-__END_CDECLS;
+__END_CDECLS
-#endif // ZIRCON_HW_PCI_H_
+#endif // SYSROOT_ZIRCON_HW_PCI_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-audio.h b/arch/x64/sysroot/include/zircon/hw/usb-audio.h
deleted file mode 100644
index 7af2994..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-audio.h
+++ /dev/null
@@ -1,524 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS;
-
-////////////////////////////////////////////////////
-//
-// General Audio interface constants
-//
-////////////////////////////////////////////////////
-
-// audio interface subclasses
-#define USB_SUBCLASS_AUDIO_CONTROL 0x01
-#define USB_SUBCLASS_AUDIO_STREAMING 0x02
-#define USB_SUBCLASS_MIDI_STREAMING 0x03
-
-// audio class specific descriptor types
-#define USB_AUDIO_CS_DEVICE 0x21
-#define USB_AUDIO_CS_CONFIGURATION 0x22
-#define USB_AUDIO_CS_STRING 0x23
-#define USB_AUDIO_CS_INTERFACE 0x24
-#define USB_AUDIO_CS_ENDPOINT 0x25
-
-////////////////////////////////////////////////////
-//
-// Audio Control interface constants
-//
-////////////////////////////////////////////////////
-
-// audio class specific AC interface descriptor subtypes
-#define USB_AUDIO_AC_HEADER 0x01
-#define USB_AUDIO_AC_INPUT_TERMINAL 0x02
-#define USB_AUDIO_AC_OUTPUT_TERMINAL 0x03
-#define USB_AUDIO_AC_MIXER_UNIT 0x04
-#define USB_AUDIO_AC_SELECTOR_UNIT 0x05
-#define USB_AUDIO_AC_FEATURE_UNIT 0x06
-#define USB_AUDIO_AC_PROCESSING_UNIT 0x07
-#define USB_AUDIO_AC_EXTENSION_UNIT 0x08
-
-// processing unit process types
-#define USB_AUDIO_UP_DOWN_MIX_PROCESS 0x01
-#define USB_AUDIO_DOLBY_PROLOGIC_PROCESS 0x02
-#define USB_AUDIO_3D_STEREO_EXTENDER_PROCESS 0x03
-#define USB_AUDIO_REVERBERATION_PROCESS 0x04
-#define USB_AUDIO_CHORUS_PROCESS 0x05
-#define USB_AUDIO_DYN_RANGE_COMP_PROCESS 0x06
-
-// audio class specific endpoint descriptor subtypes
-#define USB_AUDIO_EP_GENERAL 0x01
-
-// audio class specific request codes
-#define USB_AUDIO_SET_CUR 0x01
-#define USB_AUDIO_GET_CUR 0x81
-#define USB_AUDIO_SET_MIN 0x02
-#define USB_AUDIO_GET_MIN 0x82
-#define USB_AUDIO_SET_MAX 0x03
-#define USB_AUDIO_GET_MAX 0x83
-#define USB_AUDIO_SET_RES 0x04
-#define USB_AUDIO_GET_RES 0x84
-#define USB_AUDIO_SET_MEM 0x05
-#define USB_AUDIO_GET_MEM 0x85
-#define USB_AUDIO_GET_STAT 0xFF
-
-// terminal control selectors
-#define USB_AUDIO_COPY_PROTECT_CONTROL 0x01
-
-// feature unit control selectors
-#define USB_AUDIO_MUTE_CONTROL 0x01
-#define USB_AUDIO_VOLUME_CONTROL 0x02
-#define USB_AUDIO_BASS_CONTROL 0x03
-#define USB_AUDIO_MID_CONTROL 0x04
-#define USB_AUDIO_TREBLE_CONTROL 0x05
-#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
-#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
-#define USB_AUDIO_DELAY_CONTROL 0x08
-#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
-#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
-
-// feature unit control support bitmasks
-#define USB_AUDIO_FU_BMA_MUTE (1u << 0u)
-#define USB_AUDIO_FU_BMA_VOLUME (1u << 1u)
-#define USB_AUDIO_FU_BMA_BASS (1u << 2u)
-#define USB_AUDIO_FU_BMA_MID (1u << 3u)
-#define USB_AUDIO_FU_BMA_TREBLE (1u << 4u)
-#define USB_AUDIO_FU_BMA_GRAPHIC_EQUALIZER (1u << 5u)
-#define USB_AUDIO_FU_BMA_AUTOMATIC_GAIN (1u << 6u)
-#define USB_AUDIO_FU_BMA_DELAY (1u << 7u)
-#define USB_AUDIO_FU_BMA_BASS_BOOST (1u << 8u)
-#define USB_AUDIO_FU_BMA_LOUDNESS (1u << 9u)
-
-// up/down mix processing unit control selectors
-#define USB_AUDIO_UD_ENABLE_CONTROL 0x01
-#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
-#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
-
-// Dolby Prologic processing unit control selectors
-#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
-#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
-
-// 3D stereo extender processing unit control selectors
-#define USB_AUDIO_3D_ENABLE_CONTROL 0x01
-#define USB_AUDIO_SPACIOUSNESS_CONTROL 0x03
-
-// reverberation processing unit control selectors
-#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
-#define USB_AUDIO_REVERB_LEVEL_CONTROL 0x02
-#define USB_AUDIO_REVERB_TIME_CONTROL 0x03
-#define USB_AUDIO_REVERB_FEEDBACK_CONTROL 0x04
-
-// chorus processing unit control selectors
-#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
-#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
-#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
-#define USB_AUDIO_CHORUS_DEPTH_CONTROL 0x04
-
-// dynamic range compressor processing unit control selectors
-#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
-#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
-#define USB_AUDIO_MAXAMPL_CONTROL 0x03
-#define USB_AUDIO_THRESHOLD_CONTROL 0x04
-#define USB_AUDIO_ATTACK_TIME 0x05
-#define USB_AUDIO_RELEASE_TIME 0x06
-
-// extension unit control selectors
-#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
-
-// endpoint control selectors
-#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
-#define USB_AUDIO_PITCH_CONTROL 0x02
-
-// USB audio terminal types
-#define USB_AUDIO_TERMINAL_USB_UNDEFINED 0x0100
-#define USB_AUDIO_TERMINAL_USB_STREAMING 0x0101
-#define USB_AUDIO_TERMINAL_USB_VENDOR 0x01FF
-#define USB_AUDIO_TERMINAL_INPUT_UNDEFINED 0x0200
-#define USB_AUDIO_TERMINAL_MICROPHONE 0x0201
-#define USB_AUDIO_TERMINAL_DESKTOP_MICROPHONE 0x0202
-#define USB_AUDIO_TERMINAL_PERSONAL_MICROPHONE 0x0203
-#define USB_AUDIO_TERMINAL_OMNI_DIRECTIONAL_MICROPHONE 0x0204
-#define USB_AUDIO_TERMINAL_MICROPHONE_ARRAY 0x0205
-#define USB_AUDIO_TERMINAL_PROCESSING_MICROPHONE_ARRAY 0x0206
-#define USB_AUDIO_TERMINAL_OUTPUT_UNDEFINED 0x0300
-#define USB_AUDIO_TERMINAL_SPEAKER 0x0301
-#define USB_AUDIO_TERMINAL_HEADPHONES 0x0302
-#define USB_AUDIO_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x0303
-#define USB_AUDIO_TERMINAL_DESKTOP_SPEAKER 0x0304
-#define USB_AUDIO_TERMINAL_ROOM_SPEAKER 0x0305
-#define USB_AUDIO_TERMINAL_COMMUNICATION_SPEAKER 0x0306
-#define USB_AUDIO_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x0307
-#define USB_AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED 0x0400
-#define USB_AUDIO_TERMINAL_HANDSET 0x0401
-#define USB_AUDIO_TERMINAL_HEADSET 0x0402
-#define USB_AUDIO_TERMINAL_SPEAKERPHONE 0x0403
-#define USB_AUDIO_TERMINAL_ECHO_SUPPRESSING_SPEAKERPHONE 0x0404
-#define USB_AUDIO_TERMINAL_ECHO_CANCELING_SPEAKERPHONE 0x0405
-#define USB_AUDIO_TERMINAL_TELEPHONY_UNDEFINED 0x0500
-#define USB_AUDIO_TERMINAL_PHONE_LINE 0x0501
-#define USB_AUDIO_TERMINAL_TELEPHONE 0x0502
-#define USB_AUDIO_TERMINAL_DOWN_LINE_PHONE 0x0503
-#define USB_AUDIO_TERMINAL_EXTERNAL_UNDEFINED 0x0600
-#define USB_AUDIO_TERMINAL_ANALOG_CONNECTOR 0x0601
-#define USB_AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE 0x0602
-#define USB_AUDIO_TERMINAL_LINE_CONNECTOR 0x0603
-#define USB_AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR 0x0604
-#define USB_AUDIO_TERMINAL_SPDIF_INTERFACE 0x0605
-#define USB_AUDIO_TERMINAL_1394_DA_STREAM 0x0606
-#define USB_AUDIO_TERMINAL_1394_DV_STREAM_SOUNDTRACK 0x0607
-#define USB_AUDIO_TERMINAL_EMBEDDED_UNDEFINED 0x0700
-#define USB_AUDIO_TERMINAL_LEVEL_CALIBRATION_NOISE_SOURCE 0x0701
-#define USB_AUDIO_TERMINAL_EQUALIZATION_NOISE 0x0702
-#define USB_AUDIO_TERMINAL_CD_PLAYER 0x0703
-#define USB_AUDIO_TERMINAL_DAT 0x0704
-#define USB_AUDIO_TERMINAL_DCC 0x0705
-#define USB_AUDIO_TERMINAL_MINI_DISK 0x0706
-#define USB_AUDIO_TERMINAL_ANALOG_TAPE 0x0707
-#define USB_AUDIO_TERMINAL_PHONOGRAPH 0x0708
-#define USB_AUDIO_TERMINAL_VCR_AUDIO 0x0709
-#define USB_AUDIO_TERMINAL_VIDEO_DISK_AUDIO 0x070A
-#define USB_AUDIO_TERMINAL_DVD_AUDIO 0x070B
-#define USB_AUDIO_TERMINAL_TV_TUNER_AUDIO 0x070C
-#define USB_AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
-#define USB_AUDIO_TERMINAL_CABLE_TUNER_AUDIO 0x070E
-#define USB_AUDIO_TERMINAL_DSS_AUDIO 0x070F
-#define USB_AUDIO_TERMINAL_RADIO_RECEIVER 0x0710
-#define USB_AUDIO_TERMINAL_RADIO_TRANSMITTER 0x0711
-#define USB_AUDIO_TERMINAL_MULTI_TRACK_RECORDER 0x0712
-#define USB_AUDIO_TERMINAL_SYNTHESIZER 0x0713
-
-////////////////////////////////////////////////////
-//
-// Audio streaming interface constants
-//
-////////////////////////////////////////////////////
-
-// Audio stream class-specific AS interface descriptor subtypes
-#define USB_AUDIO_AS_GENERAL 0x01
-#define USB_AUDIO_AS_FORMAT_TYPE 0x02
-#define USB_AUDIO_AS_FORMAT_SPECIFIC 0x03
-
-// wFormatTag values present in the class specific AS header
-// Defined in Section A.1 of USB Device Class Definition for Audio Data Formats
-#define USB_AUDIO_AS_FT_TYPE_I_UNDEFINED 0x0000
-#define USB_AUDIO_AS_FT_PCM 0x0001
-#define USB_AUDIO_AS_FT_PCM8 0x0002
-#define USB_AUDIO_AS_FT_IEEE_FLOAT 0x0003
-#define USB_AUDIO_AS_FT_ALAW 0x0004
-#define USB_AUDIO_AS_FT_MULAW 0x0005
-#define USB_AUDIO_AS_FT_TYPE_II_UNDEFINED 0x1000
-#define USB_AUDIO_AS_FT_MPEG 0x1001
-#define USB_AUDIO_AS_FT_AC3 0x1002
-#define USB_AUDIO_AS_FT_TYPE_III_UNDEFINED 0x2000
-#define USB_AUDIO_AS_FT_IEC1937_AC3 0x2001
-#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L1 0x2002
-#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L23 0x2003
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_EXT 0x2004
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L1_LS 0x2005
-#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L23_LS 0x2006
-
-// Audio stream class-specific format-specific types
-#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
-#define USB_AUDIO_FORMAT_TYPE_I 0x01
-#define USB_AUDIO_FORMAT_TYPE_II 0x02
-#define USB_AUDIO_FORMAT_TYPE_III 0x03
-
-////////////////////////////////////////////////////
-//
-// MIDI streaming interface constants
-//
-////////////////////////////////////////////////////
-
-// MIDI class specific MS interface descriptor subtypes
-#define USB_MIDI_MS_HEADER 0x01
-#define USB_MIDI_IN_JACK 0x02
-#define USB_MIDI_OUT_JACK 0x03
-#define USB_MIDI_ELEMENT 0x04
-
-// MIDI class specific MS endpoint descriptor subtypes
-#define USB_MIDI_MS_GENERAL 0x01
-
-// MIDI IN and OUT jack types
-#define USB_MIDI_JACK_EMBEDDED 0x01
-#define USB_MIDI_JACK_INTERNAL 0x02
-
-// MIDI endpoint control selectors
-#define USB_MIDI_ASSOCIATION_CONTROL 0x01
-
-
-// Top level header structure shared by all USB audio descriptors.
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype;
-} __PACKED usb_audio_desc_header;
-
-// Audio Control Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_HEADER
- uint16_t bcdADC;
- uint16_t wTotalLength;
- uint8_t bInCollection;
- uint8_t baInterfaceNr[];
-} __PACKED usb_audio_ac_header_desc;
-
-// Common header structure shared by all unit and terminal descriptors found in
-// an Audio Control interface descriptor.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_.*_(TERMINAL|UNIT)
- uint8_t bID;
-} __PACKED usb_audio_ac_ut_desc;
-
-// Common header structure shared by all terminal descriptors found in an Audio
-// Control interface descriptor.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_(INPUT|OUTPUT)_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
-} __PACKED usb_audio_ac_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_INPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t iTerminal;
-} __PACKED usb_audio_ac_input_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_OUTPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bSourceID;
- uint8_t iTerminal;
-} __PACKED usb_audio_ac_output_terminal_desc;
-
-// Note: Mixer unit descriptors contain two inlined variable length arrays, each
-// with descriptor data following them. They are therefor described using 3
-// structure definitions which are logically concatenated, but separated by the
-// inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_MIXER_UNIT
- uint8_t bUnitID;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_mixer_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_mixer_unit_desc_1;
-
-typedef struct {
- uint8_t iMixer;
-} __PACKED usb_audio_ac_mixer_unit_desc_2;
-
-// Note: Selector unit descriptors contain an inlined variable length array with
-// descriptor data following it. They are therefor described using 2 structure
-// definitions which are logically concatenated, but separated by the inline
-// array.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_SELECTOR_UNIT
- uint8_t bUnitID;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_selector_unit_desc_0;
-
-typedef struct {
- uint8_t iSelector;
-} __PACKED usb_audio_ac_selector_unit_desc_1;
-
-// Note: Feature unit descriptors contain an inlined variable length array with
-// descriptor data following it. They are therefor described using 2 structure
-// definitions which are logically concatenated, but separated by the inline
-// array.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_FEATURE_UNIT
- uint8_t bUnitID;
- uint8_t bSourceID;
- uint8_t bControlSize;
- uint8_t bmaControls[];
-} __PACKED usb_audio_ac_feature_unit_desc_0;
-
-typedef struct {
- uint8_t iFeature;
-} __PACKED usb_audio_ac_feature_unit_desc_1;
-
-// Note: Processing unit descriptors contain two inlined variable length arrays,
-// each with descriptor data following them. They are therefor described using
-// 3 structure definitions which are logically concatinated, but separated by
-// the inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_PROCESSING_UNIT
- uint8_t bUnitID;
- uint16_t wProcessType;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_processing_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bControlSize;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_processing_unit_desc_1;
-
-typedef struct {
- uint8_t iProcessing;
- // Note: The Process-specific control structure follows this with the
- // structure type determined by wProcessType
- // TODO(johngro) : Define the process specific control structures. As of
- // the 1.0 revision of the USB audio spec, the types to be defined are...
- //
- // ** Up/Down-mix
- // ** Dolby Prologic
- // ** 3D-Stereo Extender
- // ** Reverberation
- // ** Chorus
- // ** Dynamic Range Compressor
-} __PACKED usb_audio_ac_processing_unit_desc_2;
-
-// Note: Extension unit descriptors contain two inlined variable length arrays,
-// each with descriptor data following them. They are therefor described using
-// 3 structure definitions which are logically concatenated, but separated by
-// the inline arrays.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AC_EXTENSION_UNIT
- uint8_t bUnitID;
- uint16_t wExtensionCode;
- uint8_t bNrInPins;
- uint8_t baSourceID[];
-} __PACKED usb_audio_ac_extension_unit_desc_0;
-
-typedef struct {
- uint8_t bNrChannels;
- uint16_t wChannelConfig;
- uint8_t iChannelNames;
- uint8_t bControlSize;
- uint8_t bmControls[];
-} __PACKED usb_audio_ac_extension_unit_desc_1;
-
-typedef struct {
- uint8_t iExtension;
-} __PACKED usb_audio_ac_extension_unit_desc_2;
-
-// Audio Streaming Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_GENERAL
- uint8_t bTerminalLink;
- uint8_t bDelay;
- uint16_t wFormatTag;
-} __PACKED usb_audio_as_header_desc;
-
-typedef struct {
- uint8_t freq[3]; // 24 bit unsigned integer, little-endian
-} __PACKED usb_audio_as_samp_freq;
-
-// Common header used by all format type descriptors
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
- uint8_t bFormatType;
-} __PACKED usb_audio_as_format_type_hdr;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
- uint8_t bFormatType; // USB_AUDIO_FORMAT_TYPE_I
- uint8_t bNrChannels;
- uint8_t bSubFrameSize;
- uint8_t bBitResolution;
- uint8_t bSamFreqType; // number of sampling frequencies
- usb_audio_as_samp_freq tSamFreq[]; // list of sampling frequencies (3 bytes each)
-} __PACKED usb_audio_as_format_type_i_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_AUDIO_EP_GENERAL
- uint8_t bmAttributes;
- uint8_t bLockDelayUnits;
- uint16_t wLockDelay;
-} __PACKED usb_audio_as_isoch_ep_desc;
-
-// MIDI Streaming Interface descriptor definitions
-//
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_MS_HEADER
- uint16_t bcdMSC;
- uint16_t wTotalLength;
-} __PACKED usb_midi_ms_header_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_IN_JACK
- uint8_t bJackType;
- uint8_t bJackID;
- uint8_t iJack;
-} __PACKED usb_midi_ms_in_jack_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_MIDI_OUT_JACK
- uint8_t bJackType;
- uint8_t bJackID;
- uint8_t bNrInputPins;
- uint8_t baSourceID;
- uint8_t baSourcePin;
-} __PACKED usb_midi_ms_out_jack_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_MIDI_MS_GENERAL
- uint8_t bNumEmbMIDIJack;
- uint8_t baAssocJackID[];
-} __PACKED usb_midi_ms_endpoint_desc;
-
-__END_CDECLS;
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-cdc.h b/arch/x64/sysroot/include/zircon/hw/usb-cdc.h
deleted file mode 100644
index f64a422..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-cdc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-
-/* CDC Subclasses for the Communications Interface Class */
-#define USB_CDC_SUBCLASS_DIRECT_LINE 0x01
-#define USB_CDC_SUBCLASS_ABSTRACT 0x02
-#define USB_CDC_SUBCLASS_TELEPHONE 0x03
-#define USB_CDC_SUBCLASS_MULTI_CHANNEL 0x04
-#define USB_CDC_SUBCLASS_CAPI 0x05
-#define USB_CDC_SUBCLASS_ETHERNET 0x06
-#define USB_CDC_SUBCLASS_ATM 0x07
-#define USB_CDC_SUBCLASS_WIRELESS_HANDSET 0x08
-#define USB_CDC_SUBCLASS_DEVICE_MGMT 0x09
-#define USB_CDC_SUBCLASS_MOBILE_DIRECT 0x0A
-#define USB_CDC_SUBCLASS_OBEX 0x0B
-#define USB_CDC_SUBCLASS_ETHERNET_EMU 0x0C
-#define USB_CDC_SUBCLASS_NETWORK_CTRL 0x0D
-
-/* CDC Descriptor SubTypes */
-#define USB_CDC_DST_HEADER 0x00
-#define USB_CDC_DST_CALL_MGMT 0x01
-#define USB_CDC_DST_ABSTRACT_CTRL_MGMT 0x02
-#define USB_CDC_DST_DIRECT_LINE_MGMT 0x03
-#define USB_CDC_DST_TELEPHONE_RINGER 0x04
-#define USB_CDC_DST_TELEPHONE_CALL_REPORTING 0x05
-#define USB_CDC_DST_UNION 0x06
-#define USB_CDC_DST_COUNTRY_SELECTION 0x07
-#define USB_CDC_DST_TELEPHONE_OP_MODES 0x08
-#define USB_CDC_DST_USB_TERMINAL 0x09
-#define USB_CDC_DST_NETWORK_CHANNEL 0x0A
-#define USB_CDC_DST_PROTOCOL_UNIT 0x0B
-#define USB_CDC_DST_EXTENSION_UNIT 0x0C
-#define USB_CDC_DST_MULTI_CHANNEL_MGMT 0x0D
-#define USB_CDC_DST_CAPI_CTRL_MGMT 0x0E
-#define USB_CDC_DST_ETHERNET 0x0F
-#define USB_CDC_DST_ATM_NETWORKING 0x10
-#define USB_CDC_DST_WIRELESS_HANDSET_CTRL 0x11
-#define USB_CDC_DST_MOBILE_DIRECT_LINE 0x12
-#define USB_CDC_DST_MDLM_DETAIL 0x13
-#define USB_CDC_DST_DEVICE_MGMT 0x14
-#define USB_CDC_DST_OBEX 0x15
-#define USB_CDC_DST_COMMAND_SET 0x16
-#define USB_CDC_DST_COMMAND_SET_DETAIL 0x17
-#define USB_CDC_DST_TELEPHONE_CTRL 0x18
-#define USB_CDC_DST_OBEX_SERVICE_ID 0x19
-#define USB_CDC_DST_NCM 0x1A
-
-/* CDC Class-Specific Notification Codes */
-#define USB_CDC_NC_NETWORK_CONNECTION 0x00
-#define USB_CDC_NC_RESPONSE_AVAILABLE 0x01
-#define USB_CDC_NC_SERIAL_STATE 0x20
-#define USB_CDC_NC_CONNECTION_SPEED_CHANGE 0x2A
-
-/* CDC Ethernet Class-Specific Request Codes */
-#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
-#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
-#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
-#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
-#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
-
-/* CDC Class-Specific Requests */
-#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
-#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
-
-__BEGIN_CDECLS;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_HEADER
- uint16_t bcdCDC;
-} __attribute__ ((packed)) usb_cs_header_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_CALL_MGMT
- uint8_t bmCapabilities;
- uint8_t bDataInterface;
-} __attribute__ ((packed)) usb_cs_call_mgmt_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_ABSTRACT_CTRL_MGMT
- uint8_t bmCapabilities;
-} __attribute__ ((packed)) usb_cs_abstract_ctrl_mgmt_interface_descriptor_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
- uint8_t bControlInterface;
- uint8_t bSubordinateInterface[];
-} __attribute__ ((packed)) usb_cs_union_interface_descriptor_t;
-
-// fixed size version of usb_cs_union_interface_descriptor_t
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
- uint8_t bControlInterface;
- uint8_t bSubordinateInterface;
-} __attribute__ ((packed)) usb_cs_union_interface_descriptor_1_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_CDC_DST_ETHERNET
- uint8_t iMACAddress;
- uint32_t bmEthernetStatistics;
- uint16_t wMaxSegmentSize;
- uint16_t wNumberMCFilters;
- uint8_t bNumberPowerFilters;
-} __attribute__ ((packed)) usb_cs_ethernet_interface_descriptor_t;
-
-typedef struct {
- uint8_t bmRequestType;
- uint8_t bNotification;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-} __attribute__ ((packed)) usb_cdc_notification_t;
-
-typedef struct {
- usb_cdc_notification_t notification;
- uint32_t downlink_br;
- uint32_t uplink_br;
- } __attribute__ ((packed)) usb_cdc_speed_change_notification_t;
-
-__END_CDECLS;
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-hid.h b/arch/x64/sysroot/include/zircon/hw/usb-hid.h
deleted file mode 100644
index d8be878..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-hid.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-__BEGIN_CDECLS;
-
-/* HID Request Values */
-#define USB_HID_GET_REPORT 0x01
-#define USB_HID_GET_IDLE 0x02
-#define USB_HID_GET_PROTOCOL 0x03
-#define USB_HID_SET_REPORT 0x09
-#define USB_HID_SET_IDLE 0x0A
-#define USB_HID_SET_PROTOCOL 0x0B
-
-typedef struct {
- uint8_t bDescriptorType;
- uint16_t wDescriptorLength;
-} __attribute__((packed)) usb_hid_descriptor_entry_t;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdHID;
- uint8_t bCountryCode;
- uint8_t bNumDescriptors;
- usb_hid_descriptor_entry_t descriptors[];
-} __attribute__((packed)) usb_hid_descriptor_t;
-
-__END_CDECLS;
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-hub.h b/arch/x64/sysroot/include/zircon/hw/usb-hub.h
deleted file mode 100644
index 2a8b395..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-hub.h
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-__BEGIN_CDECLS;
-
-// Hub request types
-#define USB_RECIP_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
-#define USB_RECIP_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
-
-// Hub requests
-#define USB_HUB_SET_DEPTH 12
-
-// Hub descriptor types
-#define USB_HUB_DESC_TYPE 0x29
-#define USB_HUB_DESC_TYPE_SS 0x2A // for superspeed hubs
-
-// Hub Class Feature Selectors (USB 2.0 spec Table 11.17)
-#define USB_FEATURE_C_HUB_LOCAL_POWER 0
-#define USB_FEATURE_C_HUB_OVER_CURRENT 1
-#define USB_FEATURE_PORT_CONNECTION 0
-#define USB_FEATURE_PORT_ENABLE 1
-#define USB_FEATURE_PORT_SUSPEND 2
-#define USB_FEATURE_PORT_OVER_CURRENT 3
-#define USB_FEATURE_PORT_RESET 4
-#define USB_FEATURE_PORT_LINK_STATE 5
-#define USB_FEATURE_PORT_POWER 8
-#define USB_FEATURE_PORT_LOW_SPEED 9
-#define USB_FEATURE_C_PORT_CONNECTION 16
-#define USB_FEATURE_C_PORT_ENABLE 17
-#define USB_FEATURE_C_PORT_SUSPEND 18
-#define USB_FEATURE_C_PORT_OVER_CURRENT 19
-#define USB_FEATURE_C_PORT_RESET 20
-#define USB_FEATURE_PORT_TEST 21
-#define USB_FEATURE_PORT_INDICATOR 22
-#define USB_FEATURE_PORT_INDICATOR 22
-#define USB_FEATURE_PORT_U1_TIMEOUT 23
-#define USB_FEATURE_PORT_U2_TIMEOUT 24
-#define USB_FEATURE_C_PORT_LINK_STATE 25
-#define USB_FEATURE_C_PORT_CONFIG_ERROR 26
-#define USB_FEATURE_PORT_REMOTE_WAKE_MASK 27
-#define USB_FEATURE_BH_PORT_RESET 28
-#define USB_FEATURE_C_BH_PORT_RESET 29
-#define USB_FEATURE_FORCE_LINKPM_ACCEPT 30
-
-typedef struct {
- uint8_t bDescLength;
- uint8_t bDescriptorType;
- uint8_t bNbrPorts;
- uint16_t wHubCharacteristics;
- uint8_t bPowerOn2PwrGood;
- uint8_t bHubContrCurrent;
- union {
- // USB 2.0
- struct {
- // variable length depending on number of ports
- uint8_t DeviceRemovable[4];
- uint8_t PortPwrCtrlMask[4];
- } __attribute__ ((packed)) hs;
- // USB 3.0
- struct {
- uint8_t bHubHdrDecLat;
- uint16_t wHubDelay;
- uint16_t DeviceRemovable;
- } __attribute__ ((packed)) ss;
- } __attribute__ ((packed));
-} __attribute__ ((packed)) usb_hub_descriptor_t;
-
-typedef struct {
- uint16_t wHubStatus;
- uint16_t wHubChange;
-} __attribute__ ((packed)) usb_hub_status_t;
-
-// wHubStatus bits
-#define USB_HUB_LOCAL_POWER (1 << 0)
-#define USB_HUB_OVER_CURRENT (1 << 1)
-
-typedef struct {
- uint16_t wPortStatus;
- uint16_t wPortChange;
-} __attribute__ ((packed)) usb_port_status_t;
-
-// Port Status bits
-#define USB_PORT_CONNECTION (1 << 0)
-#define USB_PORT_ENABLE (1 << 1)
-#define USB_PORT_SUSPEND (1 << 2) // USB 2.0 only
-#define USB_PORT_OVER_CURRENT (1 << 3)
-#define USB_PORT_RESET (1 << 4)
-#define USB_PORT_POWER (1 << 8) // USB 2.0 only
-#define USB_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
-#define USB_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
-#define USB_PORT_TEST_MODE (1 << 11) // USB 2.0 only
-#define USB_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
-
-// Port Status Changed bits
-#define USB_C_PORT_CONNECTION (1 << 0)
-#define USB_C_PORT_ENABLE (1 << 1) // USB 2.0 only
-#define USB_C_PORT_SUSPEND (1 << 2) // USB 2.0 only
-#define USB_C_PORT_OVER_CURRENT (1 << 3)
-#define USB_C_PORT_RESET (1 << 4)
-#define USB_C_BH_PORT_RESET (1 << 5) // USB 3.0 only
-#define USB_C_PORT_LINK_STATE (1 << 6) // USB 3.0 only
-#define USB_C_PORT_CONFIG_ERROR (1 << 7) // USB 3.0 only
-#define USB_C_PORT_POWER (1 << 8) // USB 2.0 only
-#define USB_C_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
-#define USB_C_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
-#define USB_C_PORT_TEST_MODE (1 << 11) // USB 2.0 only
-#define USB_C_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
-
-__END_CDECLS;
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-mass-storage.h b/arch/x64/sysroot/include/zircon/hw/usb-mass-storage.h
deleted file mode 100644
index f2d1d80..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-mass-storage.h
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-// SCSI commands
-#define UMS_TEST_UNIT_READY 0x00
-#define UMS_REQUEST_SENSE 0x03
-#define UMS_INQUIRY 0x12
-#define UMS_MODE_SELECT6 0x15
-#define UMS_MODE_SENSE6 0x1A
-#define UMS_START_STOP_UNIT 0x1B
-#define UMS_TOGGLE_REMOVABLE 0x1E
-#define UMS_READ_FORMAT_CAPACITIES 0x23
-#define UMS_READ_CAPACITY10 0x25
-#define UMS_READ10 0x28
-#define UMS_WRITE10 0x2A
-#define UMS_SYNCHRONIZE_CACHE 0x35
-#define UMS_MODE_SELECT10 0x55
-#define UMS_MODE_SENSE10 0x5A
-#define UMS_READ16 0x88
-#define UMS_WRITE16 0x8A
-#define UMS_READ_CAPACITY16 0x9E
-#define UMS_READ12 0xA8
-#define UMS_WRITE12 0xAA
-
-// control request values
-#define USB_REQ_RESET 0xFF
-#define USB_REQ_GET_MAX_LUN 0xFE
-
-// error codes for CSW processing
-typedef uint32_t csw_status_t;
-#define CSW_SUCCESS ((csw_status_t)0)
-#define CSW_FAILED ((csw_status_t)1)
-#define CSW_PHASE_ERROR ((csw_status_t)2)
-#define CSW_INVALID ((csw_status_t)3)
-#define CSW_TAG_MISMATCH ((csw_status_t)4)
-
-// signatures in header and status
-#define CBW_SIGNATURE 0x43425355
-#define CSW_SIGNATURE 0x53425355
-
-// transfer lengths
-#define UMS_INQUIRY_TRANSFER_LENGTH 0x24
-#define UMS_REQUEST_SENSE_TRANSFER_LENGTH 0x12
-#define UMS_READ_FORMAT_CAPACITIES_TRANSFER_LENGTH 0xFC
-
-// 6 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint16_t lba; // logical block address
- uint8_t length;
- uint8_t control;
-} __PACKED scsi_command6_t;
-static_assert(sizeof(scsi_command6_t) == 6, "");
-
-// 10 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint32_t lba; // logical block address
- uint8_t misc2;
- uint8_t length_hi; // break length into two pieces to avoid odd alignment
- uint8_t length_lo;
- uint8_t control;
-} __PACKED scsi_command10_t;
-static_assert(sizeof(scsi_command10_t) == 10, "");
-
-// 12 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint32_t lba; // logical block address
- uint32_t length;
- uint8_t misc2;
- uint8_t control;
-} __PACKED scsi_command12_t;
-static_assert(sizeof(scsi_command12_t) == 12, "");
-
-// 16 Byte SCSI command
-// This is big endian
-typedef struct {
- uint8_t opcode;
- uint8_t misc;
- uint64_t lba; // logical block address
- uint32_t length;
- uint8_t misc2;
- uint8_t control;
-} __PACKED scsi_command16_t;
-static_assert(sizeof(scsi_command16_t) == 16, "");
-
-// SCSI Read Capacity 10 payload
-// This is big endian
-typedef struct {
- uint32_t lba;
- uint32_t block_length;
-} __PACKED scsi_read_capacity_10_t;
-static_assert(sizeof(scsi_read_capacity_10_t) == 8, "");
-
-// SCSI Read Capacity 16 payload
-// This is big endian
-typedef struct {
- uint64_t lba;
- uint32_t block_length;
- uint8_t ptype_prot_en; // bit 0: PROT_EN, bits 1-3: P_TYPE
- uint8_t resesrved[19];
-} __PACKED scsi_read_capacity_16_t;
-static_assert(sizeof(scsi_read_capacity_16_t) == 32, "");
-
-// SCSI Mode Sense 6 command
-typedef struct {
- uint8_t opcode; // UMS_MODE_SENSE6
- uint8_t disable_block_desc;
- uint8_t page;
- uint8_t subpage;
- uint8_t allocation_length;
- uint8_t control;
-} __PACKED scsi_mode_sense_6_command_t;
-static_assert(sizeof(scsi_mode_sense_6_command_t) == 6, "");
-
-// SCSI Mode Sense 6 data response
-typedef struct {
- uint8_t mode_data_length;
- uint8_t medium_type;
- uint8_t device_specific_param;
- uint8_t block_desc_length;
-} __PACKED scsi_mode_sense_6_data_t;
-#define MODE_SENSE_DSP_RO 0x80 // bit 7 of device_specific_param: read-only
-
-// Command Block Wrapper
-typedef struct {
- uint32_t dCBWSignature; // CBW_SIGNATURE
- uint32_t dCBWTag;
- uint32_t dCBWDataTransferLength;
- uint8_t bmCBWFlags;
- uint8_t bCBWLUN;
- uint8_t bCBWCBLength;
- uint8_t CBWCB[16];
-} __PACKED ums_cbw_t;
-static_assert(sizeof(ums_cbw_t) == 31, "");
-
-// Command Status Wrapper
-typedef struct {
- uint32_t dCSWSignature; // CSW_SIGNATURE
- uint32_t dCSWTag;
- uint32_t dCSWDataResidue;
- uint8_t bmCSWStatus;
-} __PACKED ums_csw_t;
-static_assert(sizeof(ums_csw_t) == 13, "");
diff --git a/arch/x64/sysroot/include/zircon/hw/usb-video.h b/arch/x64/sysroot/include/zircon/hw/usb-video.h
deleted file mode 100644
index 1ff6e22..0000000
--- a/arch/x64/sysroot/include/zircon/hw/usb-video.h
+++ /dev/null
@@ -1,304 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-// clang-format off
-
-#include <zircon/compiler.h>
-
-__BEGIN_CDECLS;
-
-// video interface subclasses
-#define USB_SUBCLASS_VIDEO_CONTROL 0x01
-#define USB_SUBCLASS_VIDEO_STREAMING 0x02
-#define USB_SUBCLASS_VIDEO_INTERFACE_COLLECTION 0x03
-
-// video class specific descriptor types
-#define USB_VIDEO_CS_DEVICE 0x21
-#define USB_VIDEO_CS_CONFIGURATION 0x22
-#define USB_VIDEO_CS_STRING 0x23
-#define USB_VIDEO_CS_INTERFACE 0x24
-#define USB_VIDEO_CS_ENDPOINT 0x25
-
-// video class specific VC interface descriptor subtypes
-#define USB_VIDEO_VC_HEADER 0x01
-#define USB_VIDEO_VC_INPUT_TERMINAL 0x02
-#define USB_VIDEO_VC_OUTPUT_TERMINAL 0x03
-#define USB_VIDEO_VC_SELECTOR_UNIT 0x04
-#define USB_VIDEO_VC_PROCESSING_UNIT 0x05
-#define USB_VIDEO_VC_EXTENSION_UNIT 0x06
-#define USB_VIDEO_VC_ENCODING_UNIT 0x07
-
-// video class specific VS interface descriptor subtypes
-#define USB_VIDEO_VS_INPUT_HEADER 0x01
-#define USB_VIDEO_VS_OUTPUT_HEADER 0x02
-#define USB_VIDEO_VS_STILL_IMAGE_FRAME 0x03
-#define USB_VIDEO_VS_FORMAT_UNCOMPRESSED 0x04
-#define USB_VIDEO_VS_FRAME_UNCOMPRESSED 0x05
-#define USB_VIDEO_VS_FORMAT_MJPEG 0x06
-#define USB_VIDEO_VS_FRAME_MJPEG 0x07
-#define USB_VIDEO_VS_FORMAT_MPEG2TS 0x0A
-#define USB_VIDEO_VS_FORMAT_DV 0x0C
-#define USB_VIDEO_VS_COLORFORMAT 0x0D
-#define USB_VIDEO_VS_FORMAT_FRAME_BASED 0x10
-#define USB_VIDEO_VS_FRAME_FRAME_BASED 0x11
-#define USB_VIDEO_VS_FORMAT_STREAM_BASED 0x12
-#define USB_VIDEO_VS_FORMAT_H264 0x13
-#define USB_VIDEO_VS_FRAME_H264 0x14
-#define USB_VIDEO_VS_FORMAT_H264_SIMULCAST 0x15
-#define USB_VIDEO_VS_FORMAT_VP8 0x16
-#define USB_VIDEO_VS_FRAME_VP8 0x17
-#define USB_VIDEO_VS_FORMAT_VP8_SIMULCAST 0x18
-
-// video class specific endpoint descriptor subtypes
-#define USB_VIDEO_EP_GENERAL 0x01
-#define USB_VIDEO_EP_ENDPOINT 0x02
-#define USB_VIDEO_EP_INTERRUPT 0x03
-
-// video class specific request codes
-#define USB_VIDEO_SET_CUR 0x01
-#define USB_VIDEO_SET_CUR_ALL 0x11
-#define USB_VIDEO_GET_CUR 0x81
-#define USB_VIDEO_GET_MIN 0x82
-#define USB_VIDEO_GET_MAX 0x83
-#define USB_VIDEO_GET_RES 0x84
-#define USB_VIDEO_GET_LEN 0x85
-#define USB_VIDEO_GET_INFO 0x86
-#define USB_VIDEO_GET_DEF 0x87
-#define USB_VIDEO_GET_CUR_ALL 0x91
-#define USB_VIDEO_GET_MIN_ALL 0x92
-#define USB_VIDEO_GET_MAX_ALL 0x93
-#define USB_VIDEO_GET_RES_ALL 0x94
-#define USB_VIDEO_GET_DEF_ALL 0x97
-
-// video streaming interface control selectors
-#define USB_VIDEO_VS_PROBE_CONTROL 0x01
-#define USB_VIDEO_VS_COMMIT_CONTROL 0x02
-#define USB_VIDEO_VS_STILL_PROBE_CONTROL 0x03
-#define USB_VIDEO_VS_STILL_COMMIT_CONTROL 0x04
-#define USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
-#define USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL 0x06
-#define USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL 0x07
-#define USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
-#define USB_VIDEO_VS_SYNCH_DELAY_CONTROL 0x09
-
-// header for usb_video_vc_* below
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype;
-} __PACKED usb_video_vc_desc_header;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_HEADER
- uint16_t bcdUVC;
- uint16_t wTotalLength;
- uint32_t dwClockFrequency;
- uint8_t bInCollection;
- uint8_t baInterfaceNr[];
-} __PACKED usb_video_vc_header_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_INPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t iTerminal;
-} __PACKED usb_video_vc_input_terminal_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
- uint8_t bTerminalID;
- uint16_t wTerminalType;
- uint8_t bAssocTerminal;
- uint8_t bSourceID;
- uint8_t iTerminal;
-} __PACKED usb_video_vc_output_terminal_desc;
-
-// class specific VC interrupt endpoint descriptor
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_ENDPOINT
- uint8_t bDescriptorSubtype; // USB_ENDPOINT_INTERRUPT
- uint16_t wMaxTransferSize;
-} __PACKED usb_video_vc_interrupt_endpoint_desc;
-
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubtype; // USB_VIDEO_VS_HEADER
- uint8_t bNumFormats;
- uint16_t wTotalLength;
- uint8_t bEndpointAddress;
- uint8_t bmInfo;
- uint8_t bTerminalLink;
- uint8_t bStillCaptureMethod;
- uint8_t bTriggerSupport;
- uint8_t bTriggerUsage;
- uint8_t bControlSize;
- uint8_t bmaControls[];
-} __PACKED usb_video_vs_input_header_desc;
-
-#define GUID_LENGTH 16
-
-// A GUID consists of a:
-// - four-byte integer
-// - two-byte integer
-// - two-byte integer
-// - eight-byte array
-//
-// The string representation uses big endian format, so to convert it
-// to a byte array we need to reverse the byte order of the three integers.
-//
-// See USB Video Class revision 1.5, FAQ section 2.9
-// for GUID Data Structure Layout.
-
-#define USB_VIDEO_GUID_YUY2_STRING "32595559-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_YUY2_VALUE { \
- 0x59, 0x55, 0x59, 0x32, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_NV12_STRING "3231564E-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_NV12_VALUE { \
- 0x4e, 0x56, 0x31, 0x32, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_M420_STRING "3032344D-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_M420_VALUE { \
- 0x4d, 0x34, 0x32, 0x30, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-#define USB_VIDEO_GUID_I420_STRING "30323449-0000-0010-8000-00AA00389B71"
-#define USB_VIDEO_GUID_I420_VALUE { \
- 0x49, 0x34, 0x32, 0x30, \
- 0x00, 0x00, \
- 0x10, 0x00, \
- 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
-}
-
-// USB Video Payload Uncompressed
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_UNCOMPRESSED
- uint8_t bFormatIndex;
- uint8_t bNumFrameDescriptors;
- uint8_t guidFormat[GUID_LENGTH];
- uint8_t bBitsPerPixel;
- uint8_t bDefaultFrameIndex;
- uint8_t bAspectRatioX;
- uint8_t bAspectRatioY;
- uint8_t bmInterfaceFlags;
- uint8_t bCopyProtect;
-} __PACKED usb_video_vs_uncompressed_format_desc;
-
-// USB Video Payload MJPEG
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_MJPEG
- uint8_t bFormatIndex;
- uint8_t bNumFrameDescriptors;
- uint8_t bmFlags;
- uint8_t bDefaultFrameIndex;
- uint8_t bAspectRatioX;
- uint8_t bAspectRatioY;
- uint8_t bmInterfaceFlags;
- uint8_t bCopyProtect;
-} __PACKED usb_video_vs_mjpeg_format_desc;
-
-// Uncompressed and MJPEG formats have the same frame descriptor structure.
-typedef struct {
- uint8_t bLength;
- uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
- uint8_t bDescriptorSubType; // USB_VIDEO_VS_FRAME_UNCOMPRESSED / USB_VIDEO_VS_FRAME_MJPEG
- uint8_t bFrameIndex;
- uint8_t bmCapabilities;
- uint16_t wWidth;
- uint16_t wHeight;
- uint32_t dwMinBitRate;
- uint32_t dwMaxBitRate;
- uint32_t dwMaxVideoFrameBufferSize;
- uint32_t dwDefaultFrameInterval;
- uint8_t bFrameIntervalType;
- uint32_t dwFrameInterval[];
-} __PACKED usb_video_vs_frame_desc;
-
-// Stream negotiation
-#define USB_VIDEO_BM_HINT_FRAME_INTERVAL (1 << 0)
-#define USB_VIDEO_BM_HINT_KEY_FRAME_RATE (1 << 1)
-#define USB_VIDEO_BM_HINT_P_FRAME_RATE (1 << 2)
-#define USB_VIDEO_BM_HINT_COMP_QUALITY (1 << 3)
-#define USB_VIDEO_BM_HINT_COMP_WINDOW_SIZE (1 << 4)
-
-typedef struct {
- uint16_t bmHint;
- uint8_t bFormatIndex;
- uint8_t bFrameIndex;
- uint32_t dwFrameInterval;
- uint16_t wKeyFrameRate;
- uint16_t wPFrameRate;
- uint16_t wCompQuality;
- uint16_t wCompWindowSize;
- uint16_t wDelay;
- uint32_t dwMaxVideoFrameSize;
- uint32_t dwMaxPayloadTransferSize;
- // The following fields are optional.
- uint32_t dwClockFrequency;
- uint8_t bmFramingInfo;
- uint8_t bPreferedVersion;
- uint8_t bMinVersion;
- uint8_t bMaxVersion;
- uint8_t bUsage;
- uint8_t bBitDepthLuma;
- uint8_t bmSettings;
- uint8_t bMaxNumberOfRefFramesPlus1;
- uint16_t bmRateControlModes;
- uint32_t bmLayoutPerStream;
-} __PACKED usb_video_vc_probe_and_commit_controls;
-
-// For accessing payload bmHeaderInfo bitmap
-#define USB_VIDEO_VS_PAYLOAD_HEADER_FID (1 << 0)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_EOF (1 << 1)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_PTS (1 << 2)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_SCR (1 << 3)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_RES (1 << 4)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_STI (1 << 5)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_ERR (1 << 6)
-#define USB_VIDEO_VS_PAYLOAD_HEADER_EOH (1 << 7)
-
-// Common header for all payloads.
-typedef struct {
- uint8_t bHeaderLength;
- uint8_t bmHeaderInfo;
-
-} __PACKED usb_video_vs_payload_header;
-
-typedef struct {
- uint8_t bHeaderLength;
- uint8_t bmHeaderInfo;
- uint32_t dwPresentationTime;
- uint32_t scrSourceTimeClock;
- // Frame number when the source clock was sampled.
- uint16_t scrSourceClockSOFCounter;
-} __PACKED usb_video_vs_uncompressed_payload_header;
-
-__END_CDECLS;
-
diff --git a/arch/x64/sysroot/include/zircon/hw/usb.h b/arch/x64/sysroot/include/zircon/hw/usb.h
index 697f7f0..c62e948 100644
--- a/arch/x64/sysroot/include/zircon/hw/usb.h
+++ b/arch/x64/sysroot/include/zircon/hw/usb.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_HW_USB_H_
+#define SYSROOT_ZIRCON_HW_USB_H_
// clang-format off
@@ -10,7 +11,7 @@
#include <stdint.h>
#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// maximum number of endpoints per device
#define USB_MAX_EPS 32
@@ -59,11 +60,28 @@
#define USB_CLASS_DIAGNOSTIC 0xdc
#define USB_CLASS_WIRELESS 0xe0
#define USB_CLASS_MISC 0xef
+#define USB_CLASS_APPLICATION_SPECIFIC 0xfe
#define USB_CLASS_VENDOR 0xFf
+#define USB_SUBCLASS_COMM_ACM 0x02
+
+#define USB_SUBCLASS_WIRELESS_MISC 0x01
+#define USB_PROTOCOL_WIRELESS_MISC_RNDIS 0x03
+
+#define USB_SUBCLASS_MSC_RNDIS 0x04
+#define USB_PROTOCOL_MSC_RNDIS_ETHERNET 0x01
+
#define USB_SUBCLASS_MSC_SCSI 0x06
#define USB_PROTOCOL_MSC_BULK_ONLY 0x50
+#define USB_SUBCLASS_DFU 0x01
+#define USB_PROTOCOL_DFU 0x02
+
+#define USB_SUBCLASS_VENDOR 0xFF
+#define USB_PROTOCOL_TEST_FTDI 0x01
+#define USB_PROTOCOL_TEST_HID_ONE_ENDPOINT 0x02
+#define USB_PROTOCOL_TEST_HID_TWO_ENDPOINT 0x03
+
/* Descriptor Types */
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
@@ -196,6 +214,9 @@
uint16_t wMaxPacketSize;
uint8_t bInterval;
} __attribute__ ((packed)) usb_endpoint_descriptor_t;
+#define usb_ep_num(ep) ((ep)->bEndpointAddress & USB_ENDPOINT_NUM_MASK)
+// usb_ep_num2() useful with you have bEndpointAddress outside of a descriptor.
+#define usb_ep_num2(addr) ((addr) & USB_ENDPOINT_NUM_MASK)
#define usb_ep_direction(ep) ((ep)->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
#define usb_ep_type(ep) ((ep)->bmAttributes & USB_ENDPOINT_TYPE_MASK)
#define usb_ep_sync_type(ep) ((ep)->bmAttributes & USB_ENDPOINT_SYNCHRONIZATION_MASK)
@@ -207,6 +228,18 @@
typedef struct {
uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_DEVICE_QUALIFIER
+ uint16_t bcdUSB;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bMaxPacketSize0;
+ uint8_t bNumConfigurations;
+ uint8_t bReserved;
+} __attribute__ ((packed)) usb_device_qualifier_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
uint8_t bDescriptorType; // USB_DT_SS_EP_COMPANION
uint8_t bMaxBurst;
uint8_t bmAttributes;
@@ -239,4 +272,18 @@
uint8_t bDescriptorSubType;
} __attribute__ ((packed)) usb_cs_interface_descriptor_t;
-__END_CDECLS;
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_STRING
+ uint16_t wLangIds[127];
+} __attribute__ ((packed)) usb_langid_desc_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_STRING
+ uint16_t code_points[127];
+} __attribute__ ((packed)) usb_string_desc_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/audio.h b/arch/x64/sysroot/include/zircon/hw/usb/audio.h
new file mode 100644
index 0000000..4e68f87
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/audio.h
@@ -0,0 +1,527 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_AUDIO_H_
+#define SYSROOT_ZIRCON_HW_USB_AUDIO_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+////////////////////////////////////////////////////
+//
+// General Audio interface constants
+//
+////////////////////////////////////////////////////
+
+// audio interface subclasses
+#define USB_SUBCLASS_AUDIO_CONTROL 0x01
+#define USB_SUBCLASS_AUDIO_STREAMING 0x02
+#define USB_SUBCLASS_MIDI_STREAMING 0x03
+
+// audio class specific descriptor types
+#define USB_AUDIO_CS_DEVICE 0x21
+#define USB_AUDIO_CS_CONFIGURATION 0x22
+#define USB_AUDIO_CS_STRING 0x23
+#define USB_AUDIO_CS_INTERFACE 0x24
+#define USB_AUDIO_CS_ENDPOINT 0x25
+
+////////////////////////////////////////////////////
+//
+// Audio Control interface constants
+//
+////////////////////////////////////////////////////
+
+// audio class specific AC interface descriptor subtypes
+#define USB_AUDIO_AC_HEADER 0x01
+#define USB_AUDIO_AC_INPUT_TERMINAL 0x02
+#define USB_AUDIO_AC_OUTPUT_TERMINAL 0x03
+#define USB_AUDIO_AC_MIXER_UNIT 0x04
+#define USB_AUDIO_AC_SELECTOR_UNIT 0x05
+#define USB_AUDIO_AC_FEATURE_UNIT 0x06
+#define USB_AUDIO_AC_PROCESSING_UNIT 0x07
+#define USB_AUDIO_AC_EXTENSION_UNIT 0x08
+
+// processing unit process types
+#define USB_AUDIO_UP_DOWN_MIX_PROCESS 0x01
+#define USB_AUDIO_DOLBY_PROLOGIC_PROCESS 0x02
+#define USB_AUDIO_3D_STEREO_EXTENDER_PROCESS 0x03
+#define USB_AUDIO_REVERBERATION_PROCESS 0x04
+#define USB_AUDIO_CHORUS_PROCESS 0x05
+#define USB_AUDIO_DYN_RANGE_COMP_PROCESS 0x06
+
+// audio class specific endpoint descriptor subtypes
+#define USB_AUDIO_EP_GENERAL 0x01
+
+// audio class specific request codes
+#define USB_AUDIO_SET_CUR 0x01
+#define USB_AUDIO_GET_CUR 0x81
+#define USB_AUDIO_SET_MIN 0x02
+#define USB_AUDIO_GET_MIN 0x82
+#define USB_AUDIO_SET_MAX 0x03
+#define USB_AUDIO_GET_MAX 0x83
+#define USB_AUDIO_SET_RES 0x04
+#define USB_AUDIO_GET_RES 0x84
+#define USB_AUDIO_SET_MEM 0x05
+#define USB_AUDIO_GET_MEM 0x85
+#define USB_AUDIO_GET_STAT 0xFF
+
+// terminal control selectors
+#define USB_AUDIO_COPY_PROTECT_CONTROL 0x01
+
+// feature unit control selectors
+#define USB_AUDIO_MUTE_CONTROL 0x01
+#define USB_AUDIO_VOLUME_CONTROL 0x02
+#define USB_AUDIO_BASS_CONTROL 0x03
+#define USB_AUDIO_MID_CONTROL 0x04
+#define USB_AUDIO_TREBLE_CONTROL 0x05
+#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
+#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
+#define USB_AUDIO_DELAY_CONTROL 0x08
+#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
+#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
+
+// feature unit control support bitmasks
+#define USB_AUDIO_FU_BMA_MUTE (1u << 0u)
+#define USB_AUDIO_FU_BMA_VOLUME (1u << 1u)
+#define USB_AUDIO_FU_BMA_BASS (1u << 2u)
+#define USB_AUDIO_FU_BMA_MID (1u << 3u)
+#define USB_AUDIO_FU_BMA_TREBLE (1u << 4u)
+#define USB_AUDIO_FU_BMA_GRAPHIC_EQUALIZER (1u << 5u)
+#define USB_AUDIO_FU_BMA_AUTOMATIC_GAIN (1u << 6u)
+#define USB_AUDIO_FU_BMA_DELAY (1u << 7u)
+#define USB_AUDIO_FU_BMA_BASS_BOOST (1u << 8u)
+#define USB_AUDIO_FU_BMA_LOUDNESS (1u << 9u)
+
+// up/down mix processing unit control selectors
+#define USB_AUDIO_UD_ENABLE_CONTROL 0x01
+#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
+#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
+
+// Dolby Prologic processing unit control selectors
+#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
+#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
+
+// 3D stereo extender processing unit control selectors
+#define USB_AUDIO_3D_ENABLE_CONTROL 0x01
+#define USB_AUDIO_SPACIOUSNESS_CONTROL 0x03
+
+// reverberation processing unit control selectors
+#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
+#define USB_AUDIO_REVERB_LEVEL_CONTROL 0x02
+#define USB_AUDIO_REVERB_TIME_CONTROL 0x03
+#define USB_AUDIO_REVERB_FEEDBACK_CONTROL 0x04
+
+// chorus processing unit control selectors
+#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
+#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
+#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
+#define USB_AUDIO_CHORUS_DEPTH_CONTROL 0x04
+
+// dynamic range compressor processing unit control selectors
+#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
+#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
+#define USB_AUDIO_MAXAMPL_CONTROL 0x03
+#define USB_AUDIO_THRESHOLD_CONTROL 0x04
+#define USB_AUDIO_ATTACK_TIME 0x05
+#define USB_AUDIO_RELEASE_TIME 0x06
+
+// extension unit control selectors
+#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
+
+// endpoint control selectors
+#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
+#define USB_AUDIO_PITCH_CONTROL 0x02
+
+// USB audio terminal types
+#define USB_AUDIO_TERMINAL_USB_UNDEFINED 0x0100
+#define USB_AUDIO_TERMINAL_USB_STREAMING 0x0101
+#define USB_AUDIO_TERMINAL_USB_VENDOR 0x01FF
+#define USB_AUDIO_TERMINAL_INPUT_UNDEFINED 0x0200
+#define USB_AUDIO_TERMINAL_MICROPHONE 0x0201
+#define USB_AUDIO_TERMINAL_DESKTOP_MICROPHONE 0x0202
+#define USB_AUDIO_TERMINAL_PERSONAL_MICROPHONE 0x0203
+#define USB_AUDIO_TERMINAL_OMNI_DIRECTIONAL_MICROPHONE 0x0204
+#define USB_AUDIO_TERMINAL_MICROPHONE_ARRAY 0x0205
+#define USB_AUDIO_TERMINAL_PROCESSING_MICROPHONE_ARRAY 0x0206
+#define USB_AUDIO_TERMINAL_OUTPUT_UNDEFINED 0x0300
+#define USB_AUDIO_TERMINAL_SPEAKER 0x0301
+#define USB_AUDIO_TERMINAL_HEADPHONES 0x0302
+#define USB_AUDIO_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x0303
+#define USB_AUDIO_TERMINAL_DESKTOP_SPEAKER 0x0304
+#define USB_AUDIO_TERMINAL_ROOM_SPEAKER 0x0305
+#define USB_AUDIO_TERMINAL_COMMUNICATION_SPEAKER 0x0306
+#define USB_AUDIO_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x0307
+#define USB_AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED 0x0400
+#define USB_AUDIO_TERMINAL_HANDSET 0x0401
+#define USB_AUDIO_TERMINAL_HEADSET 0x0402
+#define USB_AUDIO_TERMINAL_SPEAKERPHONE 0x0403
+#define USB_AUDIO_TERMINAL_ECHO_SUPPRESSING_SPEAKERPHONE 0x0404
+#define USB_AUDIO_TERMINAL_ECHO_CANCELING_SPEAKERPHONE 0x0405
+#define USB_AUDIO_TERMINAL_TELEPHONY_UNDEFINED 0x0500
+#define USB_AUDIO_TERMINAL_PHONE_LINE 0x0501
+#define USB_AUDIO_TERMINAL_TELEPHONE 0x0502
+#define USB_AUDIO_TERMINAL_DOWN_LINE_PHONE 0x0503
+#define USB_AUDIO_TERMINAL_EXTERNAL_UNDEFINED 0x0600
+#define USB_AUDIO_TERMINAL_ANALOG_CONNECTOR 0x0601
+#define USB_AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE 0x0602
+#define USB_AUDIO_TERMINAL_LINE_CONNECTOR 0x0603
+#define USB_AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR 0x0604
+#define USB_AUDIO_TERMINAL_SPDIF_INTERFACE 0x0605
+#define USB_AUDIO_TERMINAL_1394_DA_STREAM 0x0606
+#define USB_AUDIO_TERMINAL_1394_DV_STREAM_SOUNDTRACK 0x0607
+#define USB_AUDIO_TERMINAL_EMBEDDED_UNDEFINED 0x0700
+#define USB_AUDIO_TERMINAL_LEVEL_CALIBRATION_NOISE_SOURCE 0x0701
+#define USB_AUDIO_TERMINAL_EQUALIZATION_NOISE 0x0702
+#define USB_AUDIO_TERMINAL_CD_PLAYER 0x0703
+#define USB_AUDIO_TERMINAL_DAT 0x0704
+#define USB_AUDIO_TERMINAL_DCC 0x0705
+#define USB_AUDIO_TERMINAL_MINI_DISK 0x0706
+#define USB_AUDIO_TERMINAL_ANALOG_TAPE 0x0707
+#define USB_AUDIO_TERMINAL_PHONOGRAPH 0x0708
+#define USB_AUDIO_TERMINAL_VCR_AUDIO 0x0709
+#define USB_AUDIO_TERMINAL_VIDEO_DISK_AUDIO 0x070A
+#define USB_AUDIO_TERMINAL_DVD_AUDIO 0x070B
+#define USB_AUDIO_TERMINAL_TV_TUNER_AUDIO 0x070C
+#define USB_AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
+#define USB_AUDIO_TERMINAL_CABLE_TUNER_AUDIO 0x070E
+#define USB_AUDIO_TERMINAL_DSS_AUDIO 0x070F
+#define USB_AUDIO_TERMINAL_RADIO_RECEIVER 0x0710
+#define USB_AUDIO_TERMINAL_RADIO_TRANSMITTER 0x0711
+#define USB_AUDIO_TERMINAL_MULTI_TRACK_RECORDER 0x0712
+#define USB_AUDIO_TERMINAL_SYNTHESIZER 0x0713
+
+////////////////////////////////////////////////////
+//
+// Audio streaming interface constants
+//
+////////////////////////////////////////////////////
+
+// Audio stream class-specific AS interface descriptor subtypes
+#define USB_AUDIO_AS_GENERAL 0x01
+#define USB_AUDIO_AS_FORMAT_TYPE 0x02
+#define USB_AUDIO_AS_FORMAT_SPECIFIC 0x03
+
+// wFormatTag values present in the class specific AS header
+// Defined in Section A.1 of USB Device Class Definition for Audio Data Formats
+#define USB_AUDIO_AS_FT_TYPE_I_UNDEFINED 0x0000
+#define USB_AUDIO_AS_FT_PCM 0x0001
+#define USB_AUDIO_AS_FT_PCM8 0x0002
+#define USB_AUDIO_AS_FT_IEEE_FLOAT 0x0003
+#define USB_AUDIO_AS_FT_ALAW 0x0004
+#define USB_AUDIO_AS_FT_MULAW 0x0005
+#define USB_AUDIO_AS_FT_TYPE_II_UNDEFINED 0x1000
+#define USB_AUDIO_AS_FT_MPEG 0x1001
+#define USB_AUDIO_AS_FT_AC3 0x1002
+#define USB_AUDIO_AS_FT_TYPE_III_UNDEFINED 0x2000
+#define USB_AUDIO_AS_FT_IEC1937_AC3 0x2001
+#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L1 0x2002
+#define USB_AUDIO_AS_FT_IEC1937_MPEG1_L23 0x2003
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_EXT 0x2004
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L1_LS 0x2005
+#define USB_AUDIO_AS_FT_IEC1937_MPEG2_L23_LS 0x2006
+
+// Audio stream class-specific format-specific types
+#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
+#define USB_AUDIO_FORMAT_TYPE_I 0x01
+#define USB_AUDIO_FORMAT_TYPE_II 0x02
+#define USB_AUDIO_FORMAT_TYPE_III 0x03
+
+////////////////////////////////////////////////////
+//
+// MIDI streaming interface constants
+//
+////////////////////////////////////////////////////
+
+// MIDI class specific MS interface descriptor subtypes
+#define USB_MIDI_MS_HEADER 0x01
+#define USB_MIDI_IN_JACK 0x02
+#define USB_MIDI_OUT_JACK 0x03
+#define USB_MIDI_ELEMENT 0x04
+
+// MIDI class specific MS endpoint descriptor subtypes
+#define USB_MIDI_MS_GENERAL 0x01
+
+// MIDI IN and OUT jack types
+#define USB_MIDI_JACK_EMBEDDED 0x01
+#define USB_MIDI_JACK_INTERNAL 0x02
+
+// MIDI endpoint control selectors
+#define USB_MIDI_ASSOCIATION_CONTROL 0x01
+
+
+// Top level header structure shared by all USB audio descriptors.
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype;
+} __PACKED usb_audio_desc_header;
+
+// Audio Control Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_HEADER
+ uint16_t bcdADC;
+ uint16_t wTotalLength;
+ uint8_t bInCollection;
+ uint8_t baInterfaceNr[];
+} __PACKED usb_audio_ac_header_desc;
+
+// Common header structure shared by all unit and terminal descriptors found in
+// an Audio Control interface descriptor.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_.*_(TERMINAL|UNIT)
+ uint8_t bID;
+} __PACKED usb_audio_ac_ut_desc;
+
+// Common header structure shared by all terminal descriptors found in an Audio
+// Control interface descriptor.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_(INPUT|OUTPUT)_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+} __PACKED usb_audio_ac_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_INPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t iTerminal;
+} __PACKED usb_audio_ac_input_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_OUTPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bSourceID;
+ uint8_t iTerminal;
+} __PACKED usb_audio_ac_output_terminal_desc;
+
+// Note: Mixer unit descriptors contain two inlined variable length arrays, each
+// with descriptor data following them. They are therefor described using 3
+// structure definitions which are logically concatenated, but separated by the
+// inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_MIXER_UNIT
+ uint8_t bUnitID;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_mixer_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_mixer_unit_desc_1;
+
+typedef struct {
+ uint8_t iMixer;
+} __PACKED usb_audio_ac_mixer_unit_desc_2;
+
+// Note: Selector unit descriptors contain an inlined variable length array with
+// descriptor data following it. They are therefor described using 2 structure
+// definitions which are logically concatenated, but separated by the inline
+// array.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_SELECTOR_UNIT
+ uint8_t bUnitID;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_selector_unit_desc_0;
+
+typedef struct {
+ uint8_t iSelector;
+} __PACKED usb_audio_ac_selector_unit_desc_1;
+
+// Note: Feature unit descriptors contain an inlined variable length array with
+// descriptor data following it. They are therefor described using 2 structure
+// definitions which are logically concatenated, but separated by the inline
+// array.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_FEATURE_UNIT
+ uint8_t bUnitID;
+ uint8_t bSourceID;
+ uint8_t bControlSize;
+ uint8_t bmaControls[];
+} __PACKED usb_audio_ac_feature_unit_desc_0;
+
+typedef struct {
+ uint8_t iFeature;
+} __PACKED usb_audio_ac_feature_unit_desc_1;
+
+// Note: Processing unit descriptors contain two inlined variable length arrays,
+// each with descriptor data following them. They are therefor described using
+// 3 structure definitions which are logically concatenated, but separated by
+// the inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_PROCESSING_UNIT
+ uint8_t bUnitID;
+ uint16_t wProcessType;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_processing_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bControlSize;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_processing_unit_desc_1;
+
+typedef struct {
+ uint8_t iProcessing;
+ // Note: The Process-specific control structure follows this with the
+ // structure type determined by wProcessType
+ // TODO(johngro) : Define the process specific control structures. As of
+ // the 1.0 revision of the USB audio spec, the types to be defined are...
+ //
+ // ** Up/Down-mix
+ // ** Dolby Prologic
+ // ** 3D-Stereo Extender
+ // ** Reverberation
+ // ** Chorus
+ // ** Dynamic Range Compressor
+} __PACKED usb_audio_ac_processing_unit_desc_2;
+
+// Note: Extension unit descriptors contain two inlined variable length arrays,
+// each with descriptor data following them. They are therefor described using
+// 3 structure definitions which are logically concatenated, but separated by
+// the inline arrays.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AC_EXTENSION_UNIT
+ uint8_t bUnitID;
+ uint16_t wExtensionCode;
+ uint8_t bNrInPins;
+ uint8_t baSourceID[];
+} __PACKED usb_audio_ac_extension_unit_desc_0;
+
+typedef struct {
+ uint8_t bNrChannels;
+ uint16_t wChannelConfig;
+ uint8_t iChannelNames;
+ uint8_t bControlSize;
+ uint8_t bmControls[];
+} __PACKED usb_audio_ac_extension_unit_desc_1;
+
+typedef struct {
+ uint8_t iExtension;
+} __PACKED usb_audio_ac_extension_unit_desc_2;
+
+// Audio Streaming Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_GENERAL
+ uint8_t bTerminalLink;
+ uint8_t bDelay;
+ uint16_t wFormatTag;
+} __PACKED usb_audio_as_header_desc;
+
+typedef struct {
+ uint8_t freq[3]; // 24 bit unsigned integer, little-endian
+} __PACKED usb_audio_as_samp_freq;
+
+// Common header used by all format type descriptors
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
+ uint8_t bFormatType;
+} __PACKED usb_audio_as_format_type_hdr;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_AUDIO_AS_FORMAT_TYPE
+ uint8_t bFormatType; // USB_AUDIO_FORMAT_TYPE_I
+ uint8_t bNrChannels;
+ uint8_t bSubFrameSize;
+ uint8_t bBitResolution;
+ uint8_t bSamFreqType; // number of sampling frequencies
+ usb_audio_as_samp_freq tSamFreq[]; // list of sampling frequencies (3 bytes each)
+} __PACKED usb_audio_as_format_type_i_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_AUDIO_EP_GENERAL
+ uint8_t bmAttributes;
+ uint8_t bLockDelayUnits;
+ uint16_t wLockDelay;
+} __PACKED usb_audio_as_isoch_ep_desc;
+
+// MIDI Streaming Interface descriptor definitions
+//
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_MS_HEADER
+ uint16_t bcdMSC;
+ uint16_t wTotalLength;
+} __PACKED usb_midi_ms_header_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_IN_JACK
+ uint8_t bJackType;
+ uint8_t bJackID;
+ uint8_t iJack;
+} __PACKED usb_midi_ms_in_jack_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_MIDI_OUT_JACK
+ uint8_t bJackType;
+ uint8_t bJackID;
+ uint8_t bNrInputPins;
+ uint8_t baSourceID;
+ uint8_t baSourcePin;
+} __PACKED usb_midi_ms_out_jack_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_AUDIO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_MIDI_MS_GENERAL
+ uint8_t bNumEmbMIDIJack;
+ uint8_t baAssocJackID[];
+} __PACKED usb_midi_ms_endpoint_desc;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_AUDIO_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/cdc.h b/arch/x64/sysroot/include/zircon/hw/usb/cdc.h
new file mode 100644
index 0000000..67ac8c7
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/cdc.h
@@ -0,0 +1,150 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_CDC_H_
+#define SYSROOT_ZIRCON_HW_USB_CDC_H_
+
+#include <stdint.h>
+
+// clang-format off
+
+#include <zircon/compiler.h>
+
+/* CDC Subclasses for the Communications Interface Class */
+#define USB_CDC_SUBCLASS_DIRECT_LINE 0x01
+#define USB_CDC_SUBCLASS_ABSTRACT 0x02
+#define USB_CDC_SUBCLASS_TELEPHONE 0x03
+#define USB_CDC_SUBCLASS_MULTI_CHANNEL 0x04
+#define USB_CDC_SUBCLASS_CAPI 0x05
+#define USB_CDC_SUBCLASS_ETHERNET 0x06
+#define USB_CDC_SUBCLASS_ATM 0x07
+#define USB_CDC_SUBCLASS_WIRELESS_HANDSET 0x08
+#define USB_CDC_SUBCLASS_DEVICE_MGMT 0x09
+#define USB_CDC_SUBCLASS_MOBILE_DIRECT 0x0A
+#define USB_CDC_SUBCLASS_OBEX 0x0B
+#define USB_CDC_SUBCLASS_ETHERNET_EMU 0x0C
+#define USB_CDC_SUBCLASS_NETWORK_CTRL 0x0D
+
+/* CDC Descriptor SubTypes */
+#define USB_CDC_DST_HEADER 0x00
+#define USB_CDC_DST_CALL_MGMT 0x01
+#define USB_CDC_DST_ABSTRACT_CTRL_MGMT 0x02
+#define USB_CDC_DST_DIRECT_LINE_MGMT 0x03
+#define USB_CDC_DST_TELEPHONE_RINGER 0x04
+#define USB_CDC_DST_TELEPHONE_CALL_REPORTING 0x05
+#define USB_CDC_DST_UNION 0x06
+#define USB_CDC_DST_COUNTRY_SELECTION 0x07
+#define USB_CDC_DST_TELEPHONE_OP_MODES 0x08
+#define USB_CDC_DST_USB_TERMINAL 0x09
+#define USB_CDC_DST_NETWORK_CHANNEL 0x0A
+#define USB_CDC_DST_PROTOCOL_UNIT 0x0B
+#define USB_CDC_DST_EXTENSION_UNIT 0x0C
+#define USB_CDC_DST_MULTI_CHANNEL_MGMT 0x0D
+#define USB_CDC_DST_CAPI_CTRL_MGMT 0x0E
+#define USB_CDC_DST_ETHERNET 0x0F
+#define USB_CDC_DST_ATM_NETWORKING 0x10
+#define USB_CDC_DST_WIRELESS_HANDSET_CTRL 0x11
+#define USB_CDC_DST_MOBILE_DIRECT_LINE 0x12
+#define USB_CDC_DST_MDLM_DETAIL 0x13
+#define USB_CDC_DST_DEVICE_MGMT 0x14
+#define USB_CDC_DST_OBEX 0x15
+#define USB_CDC_DST_COMMAND_SET 0x16
+#define USB_CDC_DST_COMMAND_SET_DETAIL 0x17
+#define USB_CDC_DST_TELEPHONE_CTRL 0x18
+#define USB_CDC_DST_OBEX_SERVICE_ID 0x19
+#define USB_CDC_DST_NCM 0x1A
+
+/* CDC Class-Specific Notification Codes */
+#define USB_CDC_NC_NETWORK_CONNECTION 0x00
+#define USB_CDC_NC_RESPONSE_AVAILABLE 0x01
+#define USB_CDC_NC_SERIAL_STATE 0x20
+#define USB_CDC_NC_CONNECTION_SPEED_CHANGE 0x2A
+
+/* CDC Ethernet Class-Specific Request Codes */
+#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
+#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
+#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
+#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
+#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
+
+/* CDC Ethernet Packet Filter Modes Bits */
+#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
+#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1)
+#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
+#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
+#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4)
+
+/* CDC Class-Specific Requests */
+#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
+#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
+
+__BEGIN_CDECLS
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_HEADER
+ uint16_t bcdCDC;
+} __attribute__ ((packed)) usb_cs_header_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_CALL_MGMT
+ uint8_t bmCapabilities;
+ uint8_t bDataInterface;
+} __attribute__ ((packed)) usb_cs_call_mgmt_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_ABSTRACT_CTRL_MGMT
+ uint8_t bmCapabilities;
+} __attribute__ ((packed)) usb_cs_abstract_ctrl_mgmt_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
+ uint8_t bControlInterface;
+ uint8_t bSubordinateInterface[];
+} __attribute__ ((packed)) usb_cs_union_interface_descriptor_t;
+
+// fixed size version of usb_cs_union_interface_descriptor_t
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_UNION
+ uint8_t bControlInterface;
+ uint8_t bSubordinateInterface;
+} __attribute__ ((packed)) usb_cs_union_interface_descriptor_1_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DT_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_CDC_DST_ETHERNET
+ uint8_t iMACAddress;
+ uint32_t bmEthernetStatistics;
+ uint16_t wMaxSegmentSize;
+ uint16_t wNumberMCFilters;
+ uint8_t bNumberPowerFilters;
+} __attribute__ ((packed)) usb_cs_ethernet_interface_descriptor_t;
+
+typedef struct {
+ uint8_t bmRequestType;
+ uint8_t bNotification;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+} __attribute__ ((packed)) usb_cdc_notification_t;
+
+typedef struct {
+ usb_cdc_notification_t notification;
+ uint32_t downlink_br;
+ uint32_t uplink_br;
+ } __attribute__ ((packed)) usb_cdc_speed_change_notification_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_CDC_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/dfu.h b/arch/x64/sysroot/include/zircon/hw/usb/dfu.h
new file mode 100644
index 0000000..7ca40f0
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/dfu.h
@@ -0,0 +1,82 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_DFU_H_
+#define SYSROOT_ZIRCON_HW_USB_DFU_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// USB DFU Spec, Rev 1.1
+
+// DFU Class-Specific Request Values
+// Table 3.2
+#define USB_DFU_DETACH 0x00
+#define USB_DFU_DNLOAD 0x01
+#define USB_DFU_UPLOAD 0x02
+#define USB_DFU_GET_STATUS 0x03
+#define USB_DFU_CLR_STATUS 0x04
+#define USB_DFU_GET_STATE 0x05
+#define USB_DFU_ABORT 0x06
+
+// DFU Class-Specific Descriptor Types
+// Table 4.1.3
+#define USB_DFU_CS_FUNCTIONAL 0x21
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_DFU_CS_FUNCTIONAL
+ uint8_t bmAttributes;
+ uint16_t wDetachTimeOut;
+ uint16_t wTransferSize;
+ uint16_t bcdDFUVersion;
+} __PACKED usb_dfu_func_desc_t;
+
+// DFU_GET_STATUS Response
+// Section 6.1.2
+typedef struct {
+ uint8_t bStatus;
+ uint8_t bwPollTimeout[3]; // 24 bit unsigned integer
+ uint8_t bState;
+ uint8_t bString;
+} __PACKED usb_dfu_get_status_data_t;
+
+// DFU Device Status Values
+#define USB_DFU_STATUS_OK 0x00
+#define USB_DFU_STATUS_ERR_TARGET 0x01
+#define USB_DFU_STATUS_ERR_FILE 0x02
+#define USB_DFU_STATUS_ERR_WRITE 0x03
+#define USB_DFU_STATUS_ERR_ERASE 0x04
+#define USB_DFU_STATUS_ERR_CHECK_ERASED 0x05
+#define USB_DFU_STATUS_ERR_PROG 0x06
+#define USB_DFU_STATUS_ERR_VERIFY 0x07
+#define USB_DFU_STATUS_ERR_ADDRESS 0x08
+#define USB_DFU_STATUS_ERR_NOT_DONE 0x09
+#define USB_DFU_STATUS_ERR_FIRMWARE 0x0A
+#define USB_DFU_STATUS_ERR_VENDOR 0x0B
+#define USB_DFU_STATUS_ERR_USER 0x0C
+#define USB_DFU_STATUS_ERR_POR 0x0D
+#define USB_DFU_STATUS_ERR_UNKNOWN 0x0E
+#define USB_DFU_STATUS_ERR_STALLED_PKT 0x0F
+
+// DFU Device State Values
+#define USB_DFU_STATE_APP_IDLE 0x00
+#define USB_DFU_STATE_APP_DETACH 0x01
+#define USB_DFU_STATE_DFU_IDLE 0x02
+#define USB_DFU_STATE_DFU_DNLOAD_SYNC 0x03
+#define USB_DFU_STATE_DFU_DNBUSY 0x04
+#define USB_DFU_STATE_DFU_DNLOAD_IDLE 0x05
+#define USB_DFU_STATE_DFU_MANIFEST_SYNC 0x06
+#define USB_DFU_STATE_DFU_MANIFEST 0x07
+#define USB_DFU_STATE_DFU_MANIFEST_WAIT_RESET 0x08
+#define USB_DFU_STATE_DFU_UPLOAD_IDLE 0x09
+#define USB_DFU_STATE_DFU_ERROR 0x0A
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_DFU_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/hid.h b/arch/x64/sysroot/include/zircon/hw/usb/hid.h
new file mode 100644
index 0000000..97dea4e
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/hid.h
@@ -0,0 +1,46 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_HID_H_
+#define SYSROOT_ZIRCON_HW_USB_HID_H_
+
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+__BEGIN_CDECLS
+
+// clang-format off
+
+// HID Request Values.
+#define USB_HID_GET_REPORT 0x01
+#define USB_HID_GET_IDLE 0x02
+#define USB_HID_GET_PROTOCOL 0x03
+#define USB_HID_SET_REPORT 0x09
+#define USB_HID_SET_IDLE 0x0A
+#define USB_HID_SET_PROTOCOL 0x0B
+
+// HID USB protocols
+#define USB_HID_PROTOCOL_KBD 0x01
+#define USB_HID_PROTOCOL_MOUSE 0x02
+#define USB_HID_SUBCLASS_BOOT 0x01
+
+// clang-format on
+
+typedef struct {
+ uint8_t bDescriptorType;
+ uint16_t wDescriptorLength;
+} __attribute__((packed)) usb_hid_descriptor_entry_t;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t bcdHID;
+ uint8_t bCountryCode;
+ uint8_t bNumDescriptors;
+ usb_hid_descriptor_entry_t descriptors[];
+} __attribute__((packed)) usb_hid_descriptor_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_HID_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/hub.h b/arch/x64/sysroot/include/zircon/hw/usb/hub.h
new file mode 100644
index 0000000..10ed110
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/hub.h
@@ -0,0 +1,120 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_HUB_H_
+#define SYSROOT_ZIRCON_HW_USB_HUB_H_
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+// clang-format off
+
+__BEGIN_CDECLS
+
+// Hub request types
+#define USB_RECIP_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
+#define USB_RECIP_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
+
+// Hub requests
+#define USB_HUB_SET_DEPTH 12
+
+// Hub descriptor types
+#define USB_HUB_DESC_TYPE 0x29
+#define USB_HUB_DESC_TYPE_SS 0x2A // for superspeed hubs
+
+// Hub Class Feature Selectors (USB 2.0 spec Table 11.17)
+#define USB_FEATURE_C_HUB_LOCAL_POWER 0
+#define USB_FEATURE_C_HUB_OVER_CURRENT 1
+#define USB_FEATURE_PORT_CONNECTION 0
+#define USB_FEATURE_PORT_ENABLE 1
+#define USB_FEATURE_PORT_SUSPEND 2
+#define USB_FEATURE_PORT_OVER_CURRENT 3
+#define USB_FEATURE_PORT_RESET 4
+#define USB_FEATURE_PORT_LINK_STATE 5
+#define USB_FEATURE_PORT_POWER 8
+#define USB_FEATURE_PORT_LOW_SPEED 9
+#define USB_FEATURE_C_PORT_CONNECTION 16
+#define USB_FEATURE_C_PORT_ENABLE 17
+#define USB_FEATURE_C_PORT_SUSPEND 18
+#define USB_FEATURE_C_PORT_OVER_CURRENT 19
+#define USB_FEATURE_C_PORT_RESET 20
+#define USB_FEATURE_PORT_TEST 21
+#define USB_FEATURE_PORT_INDICATOR 22
+#define USB_FEATURE_PORT_INDICATOR 22
+#define USB_FEATURE_PORT_U1_TIMEOUT 23
+#define USB_FEATURE_PORT_U2_TIMEOUT 24
+#define USB_FEATURE_C_PORT_LINK_STATE 25
+#define USB_FEATURE_C_PORT_CONFIG_ERROR 26
+#define USB_FEATURE_PORT_REMOTE_WAKE_MASK 27
+#define USB_FEATURE_BH_PORT_RESET 28
+#define USB_FEATURE_C_BH_PORT_RESET 29
+#define USB_FEATURE_FORCE_LINKPM_ACCEPT 30
+
+typedef struct {
+ uint8_t bDescLength;
+ uint8_t bDescriptorType;
+ uint8_t bNbrPorts;
+ uint16_t wHubCharacteristics;
+ uint8_t bPowerOn2PwrGood;
+ uint8_t bHubContrCurrent;
+ union {
+ // USB 2.0
+ struct {
+ // variable length depending on number of ports
+ uint8_t DeviceRemovable[4];
+ uint8_t PortPwrCtrlMask[4];
+ } __attribute__ ((packed)) hs;
+ // USB 3.0
+ struct {
+ uint8_t bHubHdrDecLat;
+ uint16_t wHubDelay;
+ uint16_t DeviceRemovable;
+ } __attribute__ ((packed)) ss;
+ } __attribute__ ((packed));
+} __attribute__ ((packed)) usb_hub_descriptor_t;
+
+typedef struct {
+ uint16_t wHubStatus;
+ uint16_t wHubChange;
+} __attribute__ ((packed)) usb_hub_status_t;
+
+// wHubStatus bits
+#define USB_HUB_LOCAL_POWER (1 << 0)
+#define USB_HUB_OVER_CURRENT (1 << 1)
+
+typedef struct {
+ uint16_t wPortStatus;
+ uint16_t wPortChange;
+} __attribute__ ((packed)) usb_port_status_t;
+
+// Port Status bits
+#define USB_PORT_CONNECTION (1 << 0)
+#define USB_PORT_ENABLE (1 << 1)
+#define USB_PORT_SUSPEND (1 << 2) // USB 2.0 only
+#define USB_PORT_OVER_CURRENT (1 << 3)
+#define USB_PORT_RESET (1 << 4)
+#define USB_PORT_POWER (1 << 8) // USB 2.0 only
+#define USB_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
+#define USB_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
+#define USB_PORT_TEST_MODE (1 << 11) // USB 2.0 only
+#define USB_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
+
+// Port Status Changed bits
+#define USB_C_PORT_CONNECTION (1 << 0)
+#define USB_C_PORT_ENABLE (1 << 1) // USB 2.0 only
+#define USB_C_PORT_SUSPEND (1 << 2) // USB 2.0 only
+#define USB_C_PORT_OVER_CURRENT (1 << 3)
+#define USB_C_PORT_RESET (1 << 4)
+#define USB_C_BH_PORT_RESET (1 << 5) // USB 3.0 only
+#define USB_C_PORT_LINK_STATE (1 << 6) // USB 3.0 only
+#define USB_C_PORT_CONFIG_ERROR (1 << 7) // USB 3.0 only
+#define USB_C_PORT_POWER (1 << 8) // USB 2.0 only
+#define USB_C_PORT_LOW_SPEED (1 << 9) // USB 2.0 only
+#define USB_C_PORT_HIGH_SPEED (1 << 10) // USB 2.0 only
+#define USB_C_PORT_TEST_MODE (1 << 11) // USB 2.0 only
+#define USB_C_PORT_INDICATOR_CONTROL (1 << 12) // USB 2.0 only
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_HW_USB_HUB_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/ums.h b/arch/x64/sysroot/include/zircon/hw/usb/ums.h
new file mode 100644
index 0000000..6640803
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/ums.h
@@ -0,0 +1,159 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_UMS_H_
+#define SYSROOT_ZIRCON_HW_USB_UMS_H_
+
+// clang-format off
+
+// SCSI commands
+#define UMS_TEST_UNIT_READY 0x00
+#define UMS_REQUEST_SENSE 0x03
+#define UMS_INQUIRY 0x12
+#define UMS_MODE_SELECT6 0x15
+#define UMS_MODE_SENSE6 0x1A
+#define UMS_START_STOP_UNIT 0x1B
+#define UMS_TOGGLE_REMOVABLE 0x1E
+#define UMS_READ_FORMAT_CAPACITIES 0x23
+#define UMS_READ_CAPACITY10 0x25
+#define UMS_READ10 0x28
+#define UMS_WRITE10 0x2A
+#define UMS_SYNCHRONIZE_CACHE 0x35
+#define UMS_MODE_SELECT10 0x55
+#define UMS_MODE_SENSE10 0x5A
+#define UMS_READ16 0x88
+#define UMS_WRITE16 0x8A
+#define UMS_READ_CAPACITY16 0x9E
+#define UMS_READ12 0xA8
+#define UMS_WRITE12 0xAA
+
+// control request values
+#define USB_REQ_RESET 0xFF
+#define USB_REQ_GET_MAX_LUN 0xFE
+
+// error codes for CSW processing
+typedef uint32_t csw_status_t;
+#define CSW_SUCCESS ((csw_status_t)0)
+#define CSW_FAILED ((csw_status_t)1)
+#define CSW_PHASE_ERROR ((csw_status_t)2)
+#define CSW_INVALID ((csw_status_t)3)
+#define CSW_TAG_MISMATCH ((csw_status_t)4)
+
+// signatures in header and status
+#define CBW_SIGNATURE 0x43425355
+#define CSW_SIGNATURE 0x53425355
+
+// transfer lengths
+#define UMS_INQUIRY_TRANSFER_LENGTH 0x24
+#define UMS_REQUEST_SENSE_TRANSFER_LENGTH 0x12
+#define UMS_READ_FORMAT_CAPACITIES_TRANSFER_LENGTH 0xFC
+
+// 6 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint16_t lba; // logical block address
+ uint8_t length;
+ uint8_t control;
+} __PACKED scsi_command6_t;
+static_assert(sizeof(scsi_command6_t) == 6, "");
+
+// 10 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint32_t lba; // logical block address
+ uint8_t misc2;
+ uint8_t length_hi; // break length into two pieces to avoid odd alignment
+ uint8_t length_lo;
+ uint8_t control;
+} __PACKED scsi_command10_t;
+static_assert(sizeof(scsi_command10_t) == 10, "");
+
+// 12 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint32_t lba; // logical block address
+ uint32_t length;
+ uint8_t misc2;
+ uint8_t control;
+} __PACKED scsi_command12_t;
+static_assert(sizeof(scsi_command12_t) == 12, "");
+
+// 16 Byte SCSI command
+// This is big endian
+typedef struct {
+ uint8_t opcode;
+ uint8_t misc;
+ uint64_t lba; // logical block address
+ uint32_t length;
+ uint8_t misc2;
+ uint8_t control;
+} __PACKED scsi_command16_t;
+static_assert(sizeof(scsi_command16_t) == 16, "");
+
+// SCSI Read Capacity 10 payload
+// This is big endian
+typedef struct {
+ uint32_t lba;
+ uint32_t block_length;
+} __PACKED scsi_read_capacity_10_t;
+static_assert(sizeof(scsi_read_capacity_10_t) == 8, "");
+
+// SCSI Read Capacity 16 payload
+// This is big endian
+typedef struct {
+ uint64_t lba;
+ uint32_t block_length;
+ uint8_t ptype_prot_en; // bit 0: PROT_EN, bits 1-3: P_TYPE
+ uint8_t resesrved[19];
+} __PACKED scsi_read_capacity_16_t;
+static_assert(sizeof(scsi_read_capacity_16_t) == 32, "");
+
+// SCSI Mode Sense 6 command
+typedef struct {
+ uint8_t opcode; // UMS_MODE_SENSE6
+ uint8_t disable_block_desc;
+ uint8_t page;
+ uint8_t subpage;
+ uint8_t allocation_length;
+ uint8_t control;
+} __PACKED scsi_mode_sense_6_command_t;
+static_assert(sizeof(scsi_mode_sense_6_command_t) == 6, "");
+
+// SCSI Mode Sense 6 data response
+typedef struct {
+ uint8_t mode_data_length;
+ uint8_t medium_type;
+ uint8_t device_specific_param;
+ uint8_t block_desc_length;
+} __PACKED scsi_mode_sense_6_data_t;
+#define MODE_SENSE_DSP_RO 0x80 // bit 7 of device_specific_param: read-only
+
+// Command Block Wrapper
+typedef struct {
+ uint32_t dCBWSignature; // CBW_SIGNATURE
+ uint32_t dCBWTag;
+ uint32_t dCBWDataTransferLength;
+ uint8_t bmCBWFlags;
+ uint8_t bCBWLUN;
+ uint8_t bCBWCBLength;
+ uint8_t CBWCB[16];
+} __PACKED ums_cbw_t;
+static_assert(sizeof(ums_cbw_t) == 31, "");
+
+// Command Status Wrapper
+typedef struct {
+ uint32_t dCSWSignature; // CSW_SIGNATURE
+ uint32_t dCSWTag;
+ uint32_t dCSWDataResidue;
+ uint8_t bmCSWStatus;
+} __PACKED ums_csw_t;
+static_assert(sizeof(ums_csw_t) == 13, "");
+
+#endif // SYSROOT_ZIRCON_HW_USB_UMS_H_
diff --git a/arch/x64/sysroot/include/zircon/hw/usb/video.h b/arch/x64/sysroot/include/zircon/hw/usb/video.h
new file mode 100644
index 0000000..925b5b6
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/hw/usb/video.h
@@ -0,0 +1,308 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_HW_USB_VIDEO_H_
+#define SYSROOT_ZIRCON_HW_USB_VIDEO_H_
+
+// clang-format off
+
+#include <zircon/compiler.h>
+#include <stdint.h>
+
+__BEGIN_CDECLS;
+
+// video interface subclasses
+#define USB_SUBCLASS_VIDEO_CONTROL 0x01
+#define USB_SUBCLASS_VIDEO_STREAMING 0x02
+#define USB_SUBCLASS_VIDEO_INTERFACE_COLLECTION 0x03
+
+// video class specific descriptor types
+#define USB_VIDEO_CS_DEVICE 0x21
+#define USB_VIDEO_CS_CONFIGURATION 0x22
+#define USB_VIDEO_CS_STRING 0x23
+#define USB_VIDEO_CS_INTERFACE 0x24
+#define USB_VIDEO_CS_ENDPOINT 0x25
+
+// video class specific VC interface descriptor subtypes
+#define USB_VIDEO_VC_HEADER 0x01
+#define USB_VIDEO_VC_INPUT_TERMINAL 0x02
+#define USB_VIDEO_VC_OUTPUT_TERMINAL 0x03
+#define USB_VIDEO_VC_SELECTOR_UNIT 0x04
+#define USB_VIDEO_VC_PROCESSING_UNIT 0x05
+#define USB_VIDEO_VC_EXTENSION_UNIT 0x06
+#define USB_VIDEO_VC_ENCODING_UNIT 0x07
+
+// video class specific VS interface descriptor subtypes
+#define USB_VIDEO_VS_INPUT_HEADER 0x01
+#define USB_VIDEO_VS_OUTPUT_HEADER 0x02
+#define USB_VIDEO_VS_STILL_IMAGE_FRAME 0x03
+#define USB_VIDEO_VS_FORMAT_UNCOMPRESSED 0x04
+#define USB_VIDEO_VS_FRAME_UNCOMPRESSED 0x05
+#define USB_VIDEO_VS_FORMAT_MJPEG 0x06
+#define USB_VIDEO_VS_FRAME_MJPEG 0x07
+#define USB_VIDEO_VS_FORMAT_MPEG2TS 0x0A
+#define USB_VIDEO_VS_FORMAT_DV 0x0C
+#define USB_VIDEO_VS_COLORFORMAT 0x0D
+#define USB_VIDEO_VS_FORMAT_FRAME_BASED 0x10
+#define USB_VIDEO_VS_FRAME_FRAME_BASED 0x11
+#define USB_VIDEO_VS_FORMAT_STREAM_BASED 0x12
+#define USB_VIDEO_VS_FORMAT_H264 0x13
+#define USB_VIDEO_VS_FRAME_H264 0x14
+#define USB_VIDEO_VS_FORMAT_H264_SIMULCAST 0x15
+#define USB_VIDEO_VS_FORMAT_VP8 0x16
+#define USB_VIDEO_VS_FRAME_VP8 0x17
+#define USB_VIDEO_VS_FORMAT_VP8_SIMULCAST 0x18
+
+// video class specific endpoint descriptor subtypes
+#define USB_VIDEO_EP_GENERAL 0x01
+#define USB_VIDEO_EP_ENDPOINT 0x02
+#define USB_VIDEO_EP_INTERRUPT 0x03
+
+// video class specific request codes
+#define USB_VIDEO_SET_CUR 0x01
+#define USB_VIDEO_SET_CUR_ALL 0x11
+#define USB_VIDEO_GET_CUR 0x81
+#define USB_VIDEO_GET_MIN 0x82
+#define USB_VIDEO_GET_MAX 0x83
+#define USB_VIDEO_GET_RES 0x84
+#define USB_VIDEO_GET_LEN 0x85
+#define USB_VIDEO_GET_INFO 0x86
+#define USB_VIDEO_GET_DEF 0x87
+#define USB_VIDEO_GET_CUR_ALL 0x91
+#define USB_VIDEO_GET_MIN_ALL 0x92
+#define USB_VIDEO_GET_MAX_ALL 0x93
+#define USB_VIDEO_GET_RES_ALL 0x94
+#define USB_VIDEO_GET_DEF_ALL 0x97
+
+// video streaming interface control selectors
+#define USB_VIDEO_VS_PROBE_CONTROL 0x01
+#define USB_VIDEO_VS_COMMIT_CONTROL 0x02
+#define USB_VIDEO_VS_STILL_PROBE_CONTROL 0x03
+#define USB_VIDEO_VS_STILL_COMMIT_CONTROL 0x04
+#define USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
+#define USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL 0x06
+#define USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL 0x07
+#define USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
+#define USB_VIDEO_VS_SYNCH_DELAY_CONTROL 0x09
+
+// header for usb_video_vc_* below
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype;
+} __PACKED usb_video_vc_desc_header;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_HEADER
+ uint16_t bcdUVC;
+ uint16_t wTotalLength;
+ uint32_t dwClockFrequency;
+ uint8_t bInCollection;
+ uint8_t baInterfaceNr[];
+} __PACKED usb_video_vc_header_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_INPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t iTerminal;
+} __PACKED usb_video_vc_input_terminal_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
+ uint8_t bTerminalID;
+ uint16_t wTerminalType;
+ uint8_t bAssocTerminal;
+ uint8_t bSourceID;
+ uint8_t iTerminal;
+} __PACKED usb_video_vc_output_terminal_desc;
+
+// class specific VC interrupt endpoint descriptor
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_ENDPOINT
+ uint8_t bDescriptorSubtype; // USB_ENDPOINT_INTERRUPT
+ uint16_t wMaxTransferSize;
+} __PACKED usb_video_vc_interrupt_endpoint_desc;
+
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubtype; // USB_VIDEO_VS_HEADER
+ uint8_t bNumFormats;
+ uint16_t wTotalLength;
+ uint8_t bEndpointAddress;
+ uint8_t bmInfo;
+ uint8_t bTerminalLink;
+ uint8_t bStillCaptureMethod;
+ uint8_t bTriggerSupport;
+ uint8_t bTriggerUsage;
+ uint8_t bControlSize;
+ uint8_t bmaControls[];
+} __PACKED usb_video_vs_input_header_desc;
+
+#define GUID_LENGTH 16
+
+// A GUID consists of a:
+// - four-byte integer
+// - two-byte integer
+// - two-byte integer
+// - eight-byte array
+//
+// The string representation uses big endian format, so to convert it
+// to a byte array we need to reverse the byte order of the three integers.
+//
+// See USB Video Class revision 1.5, FAQ section 2.9
+// for GUID Data Structure Layout.
+
+#define USB_VIDEO_GUID_YUY2_STRING "32595559-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_YUY2_VALUE { \
+ 0x59, 0x55, 0x59, 0x32, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_NV12_STRING "3231564E-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_NV12_VALUE { \
+ 0x4e, 0x56, 0x31, 0x32, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_M420_STRING "3032344D-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_M420_VALUE { \
+ 0x4d, 0x34, 0x32, 0x30, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+#define USB_VIDEO_GUID_I420_STRING "30323449-0000-0010-8000-00AA00389B71"
+#define USB_VIDEO_GUID_I420_VALUE { \
+ 0x49, 0x34, 0x32, 0x30, \
+ 0x00, 0x00, \
+ 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 \
+}
+
+// USB Video Payload Uncompressed
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_UNCOMPRESSED
+ uint8_t bFormatIndex;
+ uint8_t bNumFrameDescriptors;
+ uint8_t guidFormat[GUID_LENGTH];
+ uint8_t bBitsPerPixel;
+ uint8_t bDefaultFrameIndex;
+ uint8_t bAspectRatioX;
+ uint8_t bAspectRatioY;
+ uint8_t bmInterfaceFlags;
+ uint8_t bCopyProtect;
+} __PACKED usb_video_vs_uncompressed_format_desc;
+
+// USB Video Payload MJPEG
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FORMAT_MJPEG
+ uint8_t bFormatIndex;
+ uint8_t bNumFrameDescriptors;
+ uint8_t bmFlags;
+ uint8_t bDefaultFrameIndex;
+ uint8_t bAspectRatioX;
+ uint8_t bAspectRatioY;
+ uint8_t bmInterfaceFlags;
+ uint8_t bCopyProtect;
+} __PACKED usb_video_vs_mjpeg_format_desc;
+
+// Uncompressed and MJPEG formats have the same frame descriptor structure.
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType; // USB_VIDEO_CS_INTERFACE
+ uint8_t bDescriptorSubType; // USB_VIDEO_VS_FRAME_UNCOMPRESSED / USB_VIDEO_VS_FRAME_MJPEG
+ uint8_t bFrameIndex;
+ uint8_t bmCapabilities;
+ uint16_t wWidth;
+ uint16_t wHeight;
+ uint32_t dwMinBitRate;
+ uint32_t dwMaxBitRate;
+ uint32_t dwMaxVideoFrameBufferSize;
+ uint32_t dwDefaultFrameInterval;
+ uint8_t bFrameIntervalType;
+ uint32_t dwFrameInterval[];
+} __PACKED usb_video_vs_frame_desc;
+
+// Stream negotiation
+#define USB_VIDEO_BM_HINT_FRAME_INTERVAL (1 << 0)
+#define USB_VIDEO_BM_HINT_KEY_FRAME_RATE (1 << 1)
+#define USB_VIDEO_BM_HINT_P_FRAME_RATE (1 << 2)
+#define USB_VIDEO_BM_HINT_COMP_QUALITY (1 << 3)
+#define USB_VIDEO_BM_HINT_COMP_WINDOW_SIZE (1 << 4)
+
+typedef struct {
+ uint16_t bmHint;
+ uint8_t bFormatIndex;
+ uint8_t bFrameIndex;
+ uint32_t dwFrameInterval;
+ uint16_t wKeyFrameRate;
+ uint16_t wPFrameRate;
+ uint16_t wCompQuality;
+ uint16_t wCompWindowSize;
+ uint16_t wDelay;
+ uint32_t dwMaxVideoFrameSize;
+ uint32_t dwMaxPayloadTransferSize;
+ // The following fields are optional.
+ uint32_t dwClockFrequency;
+ uint8_t bmFramingInfo;
+ uint8_t bPreferedVersion;
+ uint8_t bMinVersion;
+ uint8_t bMaxVersion;
+ uint8_t bUsage;
+ uint8_t bBitDepthLuma;
+ uint8_t bmSettings;
+ uint8_t bMaxNumberOfRefFramesPlus1;
+ uint16_t bmRateControlModes;
+ uint32_t bmLayoutPerStream;
+} __PACKED usb_video_vc_probe_and_commit_controls;
+
+// For accessing payload bmHeaderInfo bitmap
+#define USB_VIDEO_VS_PAYLOAD_HEADER_FID (1 << 0)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_EOF (1 << 1)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_PTS (1 << 2)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_SCR (1 << 3)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_RES (1 << 4)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_STI (1 << 5)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_ERR (1 << 6)
+#define USB_VIDEO_VS_PAYLOAD_HEADER_EOH (1 << 7)
+
+// Common header for all payloads.
+typedef struct {
+ uint8_t bHeaderLength;
+ uint8_t bmHeaderInfo;
+
+} __PACKED usb_video_vs_payload_header;
+
+typedef struct {
+ uint8_t bHeaderLength;
+ uint8_t bmHeaderInfo;
+ uint32_t dwPresentationTime;
+ uint32_t scrSourceTimeClock;
+ // Frame number when the source clock was sampled.
+ uint16_t scrSourceClockSOFCounter;
+} __PACKED usb_video_vs_uncompressed_payload_header;
+
+__END_CDECLS;
+
+
+#endif // SYSROOT_ZIRCON_HW_USB_VIDEO_H_
diff --git a/arch/x64/sysroot/include/zircon/limits.h b/arch/x64/sysroot/include/zircon/limits.h
index 4c691a3..f062d5e 100644
--- a/arch/x64/sysroot/include/zircon/limits.h
+++ b/arch/x64/sysroot/include/zircon/limits.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_LIMITS_H_
-#define ZIRCON_LIMITS_H_
+#ifndef SYSROOT_ZIRCON_LIMITS_H_
+#define SYSROOT_ZIRCON_LIMITS_H_
#include <stdint.h>
#define ZX_PAGE_SHIFT ((uint32_t)12u)
-#define ZX_PAGE_SIZE ((uint32_t)(1u << ZX_PAGE_SHIFT))
+#define ZX_PAGE_SIZE ((uintptr_t)(1u << ZX_PAGE_SHIFT))
#define ZX_PAGE_MASK (ZX_PAGE_SIZE - 1u)
-#endif // ZIRCON_LIMITS_H_
+#endif // SYSROOT_ZIRCON_LIMITS_H_
diff --git a/arch/x64/sysroot/include/zircon/listnode.h b/arch/x64/sysroot/include/zircon/listnode.h
index b987bdf..fb64acf 100644
--- a/arch/x64/sysroot/include/zircon/listnode.h
+++ b/arch/x64/sysroot/include/zircon/listnode.h
@@ -2,303 +2,299 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_LISTNODE_H_
+#define SYSROOT_ZIRCON_LISTNODE_H_
-#include <zircon/compiler.h>
#include <stdbool.h>
#include <stddef.h>
+#include <zircon/compiler.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
#define containerof(ptr, type, member) ((type*)((uintptr_t)(ptr)-offsetof(type, member)))
typedef struct list_node list_node_t;
struct list_node {
- list_node_t* prev;
- list_node_t* next;
+ list_node_t* prev;
+ list_node_t* next;
};
#define LIST_INITIAL_VALUE(list) \
- { &(list), &(list) }
+ { &(list), &(list) }
#define LIST_INITIAL_CLEARED_VALUE \
- { NULL, NULL }
+ { NULL, NULL }
-static inline void list_initialize(list_node_t* list) {
- list->prev = list->next = list;
-}
+static inline void list_initialize(list_node_t* list) { list->prev = list->next = list; }
-static inline void list_clear_node(list_node_t* item) {
- item->prev = item->next = 0;
-}
+static inline void list_clear_node(list_node_t* item) { item->prev = item->next = 0; }
static inline bool list_in_list(const list_node_t* item) {
- if (item->prev == 0 && item->next == 0)
- return false;
- else
- return true;
+ if (item->prev == 0 && item->next == 0)
+ return false;
+ else
+ return true;
}
static inline void list_add_head(list_node_t* list, list_node_t* item) {
- item->next = list->next;
- item->prev = list;
- list->next->prev = item;
- list->next = item;
+ item->next = list->next;
+ item->prev = list;
+ list->next->prev = item;
+ list->next = item;
}
#define list_add_after(entry, new_entry) list_add_head(entry, new_entry)
static inline void list_add_tail(list_node_t* list, list_node_t* item) {
- item->prev = list->prev;
- item->next = list;
- list->prev->next = item;
- list->prev = item;
+ item->prev = list->prev;
+ item->next = list;
+ list->prev->next = item;
+ list->prev = item;
}
#define list_add_before(entry, new_entry) list_add_tail(entry, new_entry)
static inline void list_delete(list_node_t* item) {
- item->next->prev = item->prev;
- item->prev->next = item->next;
- item->prev = item->next = 0;
+ item->next->prev = item->prev;
+ item->prev->next = item->next;
+ item->prev = item->next = 0;
}
static inline void list_replace_node(list_node_t* old_node, list_node_t* new_node) {
- // replace a spot in a list with a new node
- // assumes old_node is part of a list and new_node is not
- new_node->next = old_node->next;
- new_node->prev = old_node->prev;
- old_node->prev = old_node->next = 0;
+ // replace a spot in a list with a new node
+ // assumes old_node is part of a list and new_node is not
+ new_node->next = old_node->next;
+ new_node->prev = old_node->prev;
+ old_node->prev = old_node->next = 0;
- new_node->next->prev = new_node;
- new_node->prev->next = new_node;
+ new_node->next->prev = new_node;
+ new_node->prev->next = new_node;
}
static inline list_node_t* list_remove_head(list_node_t* list) {
- if (list->next != list) {
- list_node_t* item = list->next;
- list_delete(item);
- return item;
- } else {
- return NULL;
- }
+ if (list->next != list) {
+ list_node_t* item = list->next;
+ list_delete(item);
+ return item;
+ } else {
+ return NULL;
+ }
}
-#define list_remove_head_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_remove_head(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_remove_head_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_remove_head(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_remove_tail(list_node_t* list) {
- if (list->prev != list) {
- list_node_t* item = list->prev;
- list_delete(item);
- return item;
- } else {
- return NULL;
- }
+ if (list->prev != list) {
+ list_node_t* item = list->prev;
+ list_delete(item);
+ return item;
+ } else {
+ return NULL;
+ }
}
-#define list_remove_tail_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_remove_tail(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_remove_tail_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_remove_tail(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
-static inline list_node_t* list_peek_head(list_node_t* list) {
- if (list->next != list) {
- return list->next;
- } else {
- return NULL;
- }
+static inline list_node_t* list_peek_head(const list_node_t* list) {
+ if (list->next != list) {
+ return list->next;
+ } else {
+ return NULL;
+ }
}
-#define list_peek_head_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_peek_head(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_peek_head_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_peek_head(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
-static inline list_node_t* list_peek_tail(list_node_t* list) {
- if (list->prev != list) {
- return list->prev;
- } else {
- return NULL;
- }
+static inline list_node_t* list_peek_tail(const list_node_t* list) {
+ if (list->prev != list) {
+ return list->prev;
+ } else {
+ return NULL;
+ }
}
-#define list_peek_tail_type(list, type, element) \
- ({ \
- list_node_t* __nod = list_peek_tail(list); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_peek_tail_type(list, type, element) \
+ ({ \
+ list_node_t* __nod = list_peek_tail(list); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_prev(list_node_t* list, list_node_t* item) {
- if (item->prev != list)
- return item->prev;
- else
- return NULL;
+ if (item->prev != list)
+ return item->prev;
+ else
+ return NULL;
}
-#define list_prev_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_prev(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_prev_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_prev(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_prev_wrap(list_node_t* list, list_node_t* item) {
- if (item->prev != list)
- return item->prev;
- else if (item->prev->prev != list)
- return item->prev->prev;
- else
- return NULL;
+ if (item->prev != list)
+ return item->prev;
+ else if (item->prev->prev != list)
+ return item->prev->prev;
+ else
+ return NULL;
}
-#define list_prev_wrap_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_prev_wrap(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_prev_wrap_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_prev_wrap(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_next(list_node_t* list, list_node_t* item) {
- if (item->next != list)
- return item->next;
- else
- return NULL;
+ if (item->next != list)
+ return item->next;
+ else
+ return NULL;
}
-#define list_next_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_next(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_next_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_next(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
static inline list_node_t* list_next_wrap(list_node_t* list, list_node_t* item) {
- if (item->next != list)
- return item->next;
- else if (item->next->next != list)
- return item->next->next;
- else
- return NULL;
+ if (item->next != list)
+ return item->next;
+ else if (item->next->next != list)
+ return item->next->next;
+ else
+ return NULL;
}
-#define list_next_wrap_type(list, item, type, element) \
- ({ \
- list_node_t* __nod = list_next_wrap(list, item); \
- type* __t; \
- if (__nod) \
- __t = containerof(__nod, type, element); \
- else \
- __t = (type*)0; \
- __t; \
- })
+#define list_next_wrap_type(list, item, type, element) \
+ ({ \
+ list_node_t* __nod = list_next_wrap(list, item); \
+ type* __t; \
+ if (__nod) \
+ __t = containerof(__nod, type, element); \
+ else \
+ __t = (type*)0; \
+ __t; \
+ })
// iterates over the list, node should be list_node_t*
#define list_for_every(list, node) for (node = (list)->next; node != (list); node = node->next)
// iterates over the list in a safe way for deletion of current node
// node and temp_node should be list_node_t*
-#define list_for_every_safe(list, node, temp_node) \
- for (node = (list)->next, temp_node = (node)->next; node != (list); \
- node = temp_node, temp_node = (node)->next)
+#define list_for_every_safe(list, node, temp_node) \
+ for (node = (list)->next, temp_node = (node)->next; node != (list); \
+ node = temp_node, temp_node = (node)->next)
// iterates over the list, entry should be the container structure type *
-#define list_for_every_entry(list, entry, type, member) \
- for ((entry) = containerof((list)->next, type, member); &(entry)->member != (list); \
- (entry) = containerof((entry)->member.next, type, member))
+#define list_for_every_entry(list, entry, type, member) \
+ for ((entry) = containerof((list)->next, type, member); &(entry)->member != (list); \
+ (entry) = containerof((entry)->member.next, type, member))
// iterates over the list in a safe way for deletion of current node
// entry and temp_entry should be the container structure type *
#define list_for_every_entry_safe(list, entry, temp_entry, type, member) \
- for (entry = containerof((list)->next, type, member), \
- temp_entry = containerof((entry)->member.next, type, member); \
- &(entry)->member != (list); \
- entry = temp_entry, temp_entry = containerof((temp_entry)->member.next, type, member))
+ for (entry = containerof((list)->next, type, member), \
+ temp_entry = containerof((entry)->member.next, type, member); \
+ &(entry)->member != (list); \
+ entry = temp_entry, temp_entry = containerof((temp_entry)->member.next, type, member))
static inline bool list_is_empty(const list_node_t* list) {
- return (list->next == list) ? true : false;
+ return (list->next == list) ? true : false;
}
static inline size_t list_length(const list_node_t* list) {
- size_t cnt = 0;
- const list_node_t* node = list;
- list_for_every(list, node) {
- cnt++;
- }
+ size_t cnt = 0;
+ const list_node_t* node = list;
+ list_for_every(list, node) { cnt++; }
- return cnt;
+ return cnt;
}
// Splice the contents of splice_from into the list immediately following pos.
static inline void list_splice_after(list_node_t* splice_from, list_node_t* pos) {
- if (list_is_empty(splice_from)) {
- return;
- }
- splice_from->next->prev = pos;
- splice_from->prev->next = pos->next;
- pos->next->prev = splice_from->prev;
- pos->next = splice_from->next;
- list_initialize(splice_from);
+ if (list_is_empty(splice_from)) {
+ return;
+ }
+ splice_from->next->prev = pos;
+ splice_from->prev->next = pos->next;
+ pos->next->prev = splice_from->prev;
+ pos->next = splice_from->next;
+ list_initialize(splice_from);
}
// Split the contents of list after (but not including) pos, into split_to
// (which should be empty).
-static inline void list_split_after(list_node_t* list, list_node_t* pos,
- list_node_t* split_to) {
- if (pos->next == list) {
- list_initialize(split_to);
- return;
- }
- split_to->prev = list->prev;
- split_to->prev->next = split_to;
- split_to->next = pos->next;
- split_to->next->prev = split_to;
- pos->next = list;
- list->prev = pos;
+static inline void list_split_after(list_node_t* list, list_node_t* pos, list_node_t* split_to) {
+ if (pos->next == list) {
+ list_initialize(split_to);
+ return;
+ }
+ split_to->prev = list->prev;
+ split_to->prev->next = split_to;
+ split_to->next = pos->next;
+ split_to->next->prev = split_to;
+ pos->next = list;
+ list->prev = pos;
}
// Moves all the contents of old_list (which may or may not be empty)
// to new_list (which should be empty).
static inline void list_move(list_node_t* old_list, list_node_t* new_list) {
- list_initialize(new_list);
- list_splice_after(old_list, new_list);
+ list_initialize(new_list);
+ list_splice_after(old_list, new_list);
}
-__END_CDECLS;
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_LISTNODE_H_
diff --git a/arch/x64/sysroot/include/zircon/lookup.h b/arch/x64/sysroot/include/zircon/lookup.h
new file mode 100644
index 0000000..fffa781
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/lookup.h
@@ -0,0 +1,34 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_LOOKUP_H_
+#define SYSROOT_ZIRCON_LOOKUP_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include <zircon/compiler.h>
+
+__BEGIN_CDECLS
+
+struct address {
+ int family;
+ unsigned scopeid;
+ uint8_t addr[16];
+ int sortkey;
+};
+
+/* The limit of 48 results is a non-sharp bound on the number of addresses
+ * that can fit in one 512-byte DNS packet full of v4 results and a second
+ * packet full of v6 results. Due to headers, the actual limit is lower. */
+#define MAXADDRS 48
+
+// This function is used by musl to perform an actual DNS lookup - it takes
+// a name and address family, sends a DNS query, and fills out the addresses
+// and canonical name with the response.
+int _getaddrinfo_from_dns(struct address buf[MAXADDRS], char canon[256], const char* name,
+ int family);
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_LOOKUP_H_
diff --git a/arch/x64/sysroot/include/zircon/pixelformat.h b/arch/x64/sysroot/include/zircon/pixelformat.h
index 8d15c0c..f28f35f 100644
--- a/arch/x64/sysroot/include/zircon/pixelformat.h
+++ b/arch/x64/sysroot/include/zircon/pixelformat.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PIXELFORMAT_H_
-#define ZIRCON_PIXELFORMAT_H_
+#ifndef SYSROOT_ZIRCON_PIXELFORMAT_H_
+#define SYSROOT_ZIRCON_PIXELFORMAT_H_
#include <stdint.h>
@@ -20,7 +20,9 @@
#define ZX_PIXEL_FORMAT_MONO_8 ((zx_pixel_format_t)0x00010007)
#define ZX_PIXEL_FORMAT_GRAY_8 ((zx_pixel_format_t)0x00010007)
#define ZX_PIXEL_FORMAT_NV12 ((zx_pixel_format_t)0x00010008)
-
+#define ZX_PIXEL_FORMAT_RGB_888 ((zx_pixel_format_t)0x00030009)
+#define ZX_PIXEL_FORMAT_ABGR_8888 ((zx_pixel_format_t)0x0004000a)
+#define ZX_PIXEL_FORMAT_BGR_888x ((zx_pixel_format_t)0x0004000b)
#define ZX_PIXEL_FORMAT_BYTES(pf) (((pf) >> 16) & 7)
-#endif // ZIRCON_PIXELFORMAT_H_
+#endif // SYSROOT_ZIRCON_PIXELFORMAT_H_
diff --git a/arch/x64/sysroot/include/zircon/process.h b/arch/x64/sysroot/include/zircon/process.h
index bec8a79..ef2bcb1 100644
--- a/arch/x64/sysroot/include/zircon/process.h
+++ b/arch/x64/sysroot/include/zircon/process.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PROCESS_H_
-#define ZIRCON_PROCESS_H_
+#ifndef SYSROOT_ZIRCON_PROCESS_H_
+#define SYSROOT_ZIRCON_PROCESS_H_
-#include <zircon/types.h>
#include <stdint.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
@@ -32,4 +32,4 @@
__END_CDECLS
-#endif // ZIRCON_PROCESS_H_
+#endif // SYSROOT_ZIRCON_PROCESS_H_
diff --git a/arch/x64/sysroot/include/zircon/processargs.h b/arch/x64/sysroot/include/zircon/processargs.h
index dfc771f..ee99985 100644
--- a/arch/x64/sysroot/include/zircon/processargs.h
+++ b/arch/x64/sysroot/include/zircon/processargs.h
@@ -2,95 +2,95 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_PROCESSARGS_H_
-#define ZIRCON_PROCESSARGS_H_
+#ifndef SYSROOT_ZIRCON_PROCESSARGS_H_
+#define SYSROOT_ZIRCON_PROCESSARGS_H_
+#include <stdint.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
-#include <stdint.h>
__BEGIN_CDECLS
// This is a protocol for passing state to a new process
// via a message in a channel.
-#define ZX_PROCARGS_PROTOCOL ((uint32_t)0x4150585du) // MXPA
+#define ZX_PROCARGS_PROTOCOL ((uint32_t)0x4150585du) // MXPA
#define ZX_PROCARGS_VERSION ((uint32_t)0x0001000u)
typedef struct zx_proc_args zx_proc_args_t;
struct zx_proc_args {
- // Protocol and version identifiers to allow for
- // different process start message protocols and
- // versioning of the same.
- uint32_t protocol;
- uint32_t version;
+ // Protocol and version identifiers to allow for
+ // different process start message protocols and
+ // versioning of the same.
+ uint32_t protocol;
+ uint32_t version;
- // Offset from start of message to handle info
- // array, which contains one uint32_t per handle
- // passed along with the message.
- uint32_t handle_info_off;
+ // Offset from start of message to handle info
+ // array, which contains one uint32_t per handle
+ // passed along with the message.
+ uint32_t handle_info_off;
- // Offset from start of message to arguments and
- // count of arguments. Arguments are provided as
- // a set of null-terminated utf-8 strings, one
- // after the other.
- uint32_t args_off;
- uint32_t args_num;
+ // Offset from start of message to arguments and
+ // count of arguments. Arguments are provided as
+ // a set of null-terminated utf-8 strings, one
+ // after the other.
+ uint32_t args_off;
+ uint32_t args_num;
- // Offset from start of message to environment strings and count of
- // them. Environment entries are provided as a set of null-terminated
- // UTF-8 strings, one after the other. Canonically each string has
- // the form "NAME=VALUE", but nothing enforces this.
- uint32_t environ_off;
- uint32_t environ_num;
+ // Offset from start of message to environment strings and count of
+ // them. Environment entries are provided as a set of null-terminated
+ // UTF-8 strings, one after the other. Canonically each string has
+ // the form "NAME=VALUE", but nothing enforces this.
+ uint32_t environ_off;
+ uint32_t environ_num;
- // Offset from start of message to name strings and count of them.
- // These strings are packed similar to the argument strings,
- // but are referenced by PA_NS_* handle table entries and used
- // to set up namespaces.
- //
- // Specifically: In a handle table entry with PA_HND_TYPE(info)
- // of PA_NS_*, PA_HND_ARG(info) is an index into this name table.
- uint32_t names_off;
- uint32_t names_num;
+ // Offset from start of message to name strings and count of them.
+ // These strings are packed similar to the argument strings,
+ // but are referenced by PA_NS_* handle table entries and used
+ // to set up namespaces.
+ //
+ // Specifically: In a handle table entry with PA_HND_TYPE(info)
+ // of PA_NS_*, PA_HND_ARG(info) is an index into this name table.
+ uint32_t names_off;
+ uint32_t names_num;
};
// Handle Info entries associate a type and optional
// argument with each handle included in the process
// arguments message.
-#define PA_HND(type, arg) (((type)&0xFF)| (((arg)&0xFFFF)<<16))
-#define PA_HND_TYPE(n) ((n) & 0xFF)
-#define PA_HND_SUBTYPE(n) (((n) >> 8) & 0xFF)
-#define PA_HND_ARG(n) (((n) >> 16) & 0xFFFF)
+#define PA_HND(type, arg) (((type)&0xFF) | (((arg)&0xFFFF) << 16))
+#define PA_HND_TYPE(n) ((n)&0xFF)
+#define PA_HND_ARG(n) (((n) >> 16) & 0xFFFF)
// --- Core Runtime Handles ---
// Used by libc init (or equivalent) and dynamic loader
// Handle to our own process.
-#define PA_PROC_SELF 0x01u
+#define PA_PROC_SELF 0x01u
// Handle to the initial thread of our own process.
-#define PA_THREAD_SELF 0x02u
+#define PA_THREAD_SELF 0x02u
-// Handle to a Job object which can be used to make child processes. The
-// Job can be the same as the one used to create this process or it can
+// Handle to a job object which can be used to make child processes.
+//
+// The job can be the same as the one used to create this process or it can
// be different.
-#define PA_JOB_DEFAULT 0x03u
+#define PA_JOB_DEFAULT 0x03u
// Handle to the root of our address space
-#define PA_VMAR_ROOT 0x04u
+#define PA_VMAR_ROOT 0x04u
// Handle to the VMAR used to load the initial program image.
-#define PA_VMAR_LOADED 0x05u
-
+#define PA_VMAR_LOADED 0x05u
// --- Loader Service and VMO Handles ---
// Used by libc init (or equivalent) and dynamic loader
// Service for loading shared libraries.
+//
// See |fuchsia.ldsvc.Loader| for the interface definition.
-#define PA_LDSVC_LOADER 0x10u
+#define PA_LDSVC_LOADER 0x10u
// Handle to the VMO containing the ELF image of the system vDSO. This
// handle is duplicable, transferable, readable, and executable, but not
@@ -100,7 +100,7 @@
// might create or propagate it on to its children so they can do so.
// Each process's own vDSO was mapped in by its creator before the
// process started, its address passed as an argument to entry point.
-#define PA_VMO_VDSO 0x11u
+#define PA_VMO_VDSO 0x11u
// Handle to the VMO used to map the initial thread's stack. This
// handle usually has all rights. The protocol between process creator
@@ -111,53 +111,66 @@
// calling convention for function entry. Thus the new process can
// compute its exact stack bounds by subtracting the size reported by
// this VMO from the (adjusted back up) initial SP value.
-#define PA_VMO_STACK 0x13u
+#define PA_VMO_STACK 0x13u
// VM object handle for the main executable file
-#define PA_VMO_EXECUTABLE 0x14u
+#define PA_VMO_EXECUTABLE 0x14u
// Used by kernel and userboot during startup
-#define PA_VMO_BOOTDATA 0x1Au
+#define PA_VMO_BOOTDATA 0x1Au
// Used by kernel and userboot during startup
-#define PA_VMO_BOOTFS 0x1Bu
+#define PA_VMO_BOOTFS 0x1Bu
// Used by the kernel to export debug information as a file in bootfs. When
// devmgr starts, it looks for handles of this type, and adds them as files in
// /boot/kernel/<vmo-name>.
-#define PA_VMO_KERNEL_FILE 0x1Cu
-
+#define PA_VMO_KERNEL_FILE 0x1Cu
// --- Namespace Handles ---
// A handle which will handle OPEN requests relative
// to a particular path which is specified by the
// nametable entry referred to by the "arg" field
-#define PA_NS_DIR 0x20u
+#define PA_NS_DIR 0x20u
+// --- File Descriptor Handles ---
-// --- FDIO Handles ---
-// Used by libfdio for passing fdtable, fsroot, etc
+// A handle which will be used as a file descriptor.
+#define PA_FD 0x30u
-// Handle types the fdio library uses
-#define PA_FDIO_REMOTE 0x32u
-#define PA_FDIO_LOGGER 0x35u
-#define PA_FDIO_SOCKET 0x36u
+// -- Lifecyle handle --
+//
+// A Handle to a channel on which the process may receive lifecycle events from
+// the ELF runner by serving the |fuchsia.process.Lifecycle| protocol.
+#define PA_LIFECYCLE 0x3Au
// Server endpoint for handling connection to appmgr services.
-#define PA_DIRECTORY_REQUEST 0x3Bu
+#define PA_DIRECTORY_REQUEST 0x3Bu
// Used by devmgr and devhosts
-#define PA_RESOURCE 0x3Fu
+#define PA_RESOURCE 0x3Fu
+// --- Clock handles ---
+//
+// A clock which provides access to UTC. Used by runtimes which are expected to
+// provide access to UTC via their standard libraries.
+//
+#define PA_CLOCK_UTC 0x40u
+
+// --- Resource handles ---
+#define PA_MMIO_RESOURCE 0x50
+#define PA_IRQ_RESOURCE 0x51
+#define PA_IOPORT_RESOURCE 0x52
+#define PA_SMC_RESOURCE 0x53
// --- Various ---
// Handle types for one-off use and prototyping
-#define PA_USER0 0xF0u
-#define PA_USER1 0xF1u
-#define PA_USER2 0xF2u
+#define PA_USER0 0xF0u
+#define PA_USER1 0xF1u
+#define PA_USER2 0xF2u
__END_CDECLS
-#endif // ZIRCON_PROCESSARGS_H_
+#endif // SYSROOT_ZIRCON_PROCESSARGS_H_
diff --git a/arch/x64/sysroot/include/zircon/rights.h b/arch/x64/sysroot/include/zircon/rights.h
index 8c9f021..1cfa768 100644
--- a/arch/x64/sysroot/include/zircon/rights.h
+++ b/arch/x64/sysroot/include/zircon/rights.h
@@ -2,34 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_RIGHTS_H_
-#define ZIRCON_RIGHTS_H_
+#ifndef SYSROOT_ZIRCON_RIGHTS_H_
+#define SYSROOT_ZIRCON_RIGHTS_H_
#include <stdint.h>
typedef uint32_t zx_rights_t;
-#define ZX_RIGHT_NONE ((zx_rights_t)0u)
-#define ZX_RIGHT_DUPLICATE ((zx_rights_t)1u << 0)
-#define ZX_RIGHT_TRANSFER ((zx_rights_t)1u << 1)
-#define ZX_RIGHT_READ ((zx_rights_t)1u << 2)
-#define ZX_RIGHT_WRITE ((zx_rights_t)1u << 3)
-#define ZX_RIGHT_EXECUTE ((zx_rights_t)1u << 4)
-#define ZX_RIGHT_MAP ((zx_rights_t)1u << 5)
-#define ZX_RIGHT_GET_PROPERTY ((zx_rights_t)1u << 6)
-#define ZX_RIGHT_SET_PROPERTY ((zx_rights_t)1u << 7)
-#define ZX_RIGHT_ENUMERATE ((zx_rights_t)1u << 8)
-#define ZX_RIGHT_DESTROY ((zx_rights_t)1u << 9)
-#define ZX_RIGHT_SET_POLICY ((zx_rights_t)1u << 10)
-#define ZX_RIGHT_GET_POLICY ((zx_rights_t)1u << 11)
-#define ZX_RIGHT_SIGNAL ((zx_rights_t)1u << 12)
-#define ZX_RIGHT_SIGNAL_PEER ((zx_rights_t)1u << 13)
-#define ZX_RIGHT_WAIT ((zx_rights_t)1u << 14)
-#define ZX_RIGHT_INSPECT ((zx_rights_t)1u << 15)
-#define ZX_RIGHT_MANAGE_JOB ((zx_rights_t)1u << 16)
-#define ZX_RIGHT_MANAGE_PROCESS ((zx_rights_t)1u << 17)
-#define ZX_RIGHT_MANAGE_THREAD ((zx_rights_t)1u << 18)
-#define ZX_RIGHT_APPLY_PROFILE ((zx_rights_t)1u << 19)
-#define ZX_RIGHT_SAME_RIGHTS ((zx_rights_t)1u << 31)
+#define ZX_RIGHT_NONE ((zx_rights_t)0u)
+#define ZX_RIGHT_DUPLICATE ((zx_rights_t)1u << 0)
+#define ZX_RIGHT_TRANSFER ((zx_rights_t)1u << 1)
+#define ZX_RIGHT_READ ((zx_rights_t)1u << 2)
+#define ZX_RIGHT_WRITE ((zx_rights_t)1u << 3)
+#define ZX_RIGHT_EXECUTE ((zx_rights_t)1u << 4)
+#define ZX_RIGHT_MAP ((zx_rights_t)1u << 5)
+#define ZX_RIGHT_GET_PROPERTY ((zx_rights_t)1u << 6)
+#define ZX_RIGHT_SET_PROPERTY ((zx_rights_t)1u << 7)
+#define ZX_RIGHT_ENUMERATE ((zx_rights_t)1u << 8)
+#define ZX_RIGHT_DESTROY ((zx_rights_t)1u << 9)
+#define ZX_RIGHT_SET_POLICY ((zx_rights_t)1u << 10)
+#define ZX_RIGHT_GET_POLICY ((zx_rights_t)1u << 11)
+#define ZX_RIGHT_SIGNAL ((zx_rights_t)1u << 12)
+#define ZX_RIGHT_SIGNAL_PEER ((zx_rights_t)1u << 13)
+#define ZX_RIGHT_WAIT ((zx_rights_t)1u << 14)
+#define ZX_RIGHT_INSPECT ((zx_rights_t)1u << 15)
+#define ZX_RIGHT_MANAGE_JOB ((zx_rights_t)1u << 16)
+#define ZX_RIGHT_MANAGE_PROCESS ((zx_rights_t)1u << 17)
+#define ZX_RIGHT_MANAGE_THREAD ((zx_rights_t)1u << 18)
+#define ZX_RIGHT_APPLY_PROFILE ((zx_rights_t)1u << 19)
+#define ZX_RIGHT_SAME_RIGHTS ((zx_rights_t)1u << 31)
// Convenient names for commonly grouped rights.
#define ZX_RIGHTS_BASIC (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WAIT | ZX_RIGHT_INSPECT)
@@ -40,88 +40,85 @@
#define ZX_RIGHTS_POLICY (ZX_RIGHT_GET_POLICY | ZX_RIGHT_SET_POLICY)
-#define ZX_DEFAULT_CHANNEL_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_DUPLICATE)) | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | \
- ZX_RIGHT_SIGNAL_PEER)
+#define ZX_DEFAULT_CHANNEL_RIGHTS \
+ ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_DUPLICATE)) | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | \
+ ZX_RIGHT_SIGNAL_PEER)
#define ZX_DEFAULT_EVENT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_SYSTEM_EVENT_LOW_MEMORY_RIGHTS \
+ (ZX_RIGHT_WAIT | ZX_RIGHT_DUPLICATE | ZX_RIGHT_TRANSFER)
+
#define ZX_DEFAULT_EVENTPAIR_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
#define ZX_DEFAULT_FIFO_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO |\
- ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
-#define ZX_DEFAULT_GUEST_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE |\
- ZX_RIGHT_INSPECT | ZX_RIGHT_MANAGE_PROCESS)
+#define ZX_DEFAULT_GUEST_RIGHTS \
+ (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE | ZX_RIGHT_INSPECT | \
+ ZX_RIGHT_MANAGE_PROCESS)
#define ZX_DEFAULT_INTERRUPT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_IO_MAPPING_RIGHTS \
- (ZX_RIGHT_READ | ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_IO_MAPPING_RIGHTS (ZX_RIGHT_READ | ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_JOB_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHTS_POLICY | ZX_RIGHT_ENUMERATE | \
- ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_JOB | ZX_RIGHT_MANAGE_PROCESS)
+#define ZX_DEFAULT_JOB_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHTS_POLICY | ZX_RIGHT_ENUMERATE | \
+ ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_JOB | ZX_RIGHT_MANAGE_PROCESS | \
+ ZX_RIGHT_MANAGE_THREAD)
-#define ZX_DEFAULT_LOG_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_LOG_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_PCI_DEVICE_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
+#define ZX_DEFAULT_MSI_RIGHTS (ZX_RIGHTS_BASIC)
-#define ZX_DEFAULT_PCI_INTERRUPT_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_PCI_DEVICE_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
-#define ZX_DEFAULT_PORT_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO)
+#define ZX_DEFAULT_PCI_INTERRUPT_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_PROCESS_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_ENUMERATE | ZX_RIGHT_DESTROY | \
- ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_PROCESS | ZX_RIGHT_MANAGE_THREAD)
+#define ZX_DEFAULT_PORT_RIGHTS ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO)
+
+#define ZX_DEFAULT_PROCESS_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_ENUMERATE | ZX_RIGHT_DESTROY | \
+ ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_PROCESS | ZX_RIGHT_MANAGE_THREAD)
#define ZX_DEFAULT_RESOURCE_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE |\
- ZX_RIGHT_INSPECT)
+ (ZX_RIGHT_TRANSFER | ZX_RIGHT_DUPLICATE | ZX_RIGHT_WRITE | ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_SOCKET_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_GET_PROPERTY |\
- ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
+#define ZX_DEFAULT_SOCKET_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_GET_PROPERTY | ZX_RIGHT_SET_PROPERTY | \
+ ZX_RIGHT_SIGNAL | ZX_RIGHT_SIGNAL_PEER)
-#define ZX_DEFAULT_THREAD_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY |\
- ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | ZX_RIGHT_MANAGE_THREAD)
+#define ZX_DEFAULT_STREAM_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_PROPERTY | ZX_RIGHT_SIGNAL)
+
+#define ZX_DEFAULT_THREAD_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_DESTROY | ZX_RIGHT_SIGNAL | \
+ ZX_RIGHT_MANAGE_THREAD)
#define ZX_DEFAULT_TIMER_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHT_WRITE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_VCPU_RIGHTS \
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_EXECUTE | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_VCPU_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHT_EXECUTE | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_VMAR_RIGHTS \
- (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
+#define ZX_DEFAULT_VMAR_RIGHTS (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
-#define ZX_DEFAULT_VMO_RIGHTS\
- (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY |\
- ZX_RIGHT_EXECUTE | ZX_RIGHT_MAP | ZX_RIGHT_SIGNAL)
+#define ZX_DEFAULT_VMO_RIGHTS \
+ (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_MAP | ZX_RIGHT_SIGNAL)
-#define ZX_DEFAULT_IOMMU_RIGHTS \
- (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
+#define ZX_DEFAULT_IOMMU_RIGHTS (ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT))
#define ZX_DEFAULT_BTI_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO | ZX_RIGHT_MAP)
+ ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHTS_IO | ZX_RIGHTS_PROPERTY | ZX_RIGHT_MAP)
-#define ZX_DEFAULT_PROFILE_RIGHTS \
- ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHT_APPLY_PROFILE)
+#define ZX_DEFAULT_PROFILE_RIGHTS ((ZX_RIGHTS_BASIC & (~ZX_RIGHT_WAIT)) | ZX_RIGHT_APPLY_PROFILE)
-#define ZX_DEFAULT_PMT_RIGHTS \
- (ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_PMT_RIGHTS (ZX_RIGHT_INSPECT)
-#define ZX_DEFAULT_SUSPEND_TOKEN_RIGHTS \
- (ZX_RIGHT_TRANSFER | ZX_RIGHT_INSPECT)
+#define ZX_DEFAULT_SUSPEND_TOKEN_RIGHTS (ZX_RIGHT_TRANSFER | ZX_RIGHT_INSPECT)
#define ZX_DEFAULT_PAGER_RIGHTS \
- (ZX_RIGHT_INSPECT | ZX_RIGHT_ENUMERATE | ZX_RIGHT_GET_PROPERTY |\
- ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_TRANSFER)
+ (ZX_RIGHT_INSPECT | ZX_RIGHT_GET_PROPERTY | ZX_RIGHT_SET_PROPERTY | ZX_RIGHT_TRANSFER)
-#endif // ZIRCON_RIGHTS_H_
+#define ZX_DEFAULT_EXCEPTION_RIGHTS (ZX_RIGHT_TRANSFER | ZX_RIGHTS_PROPERTY | ZX_RIGHT_INSPECT)
+
+#define ZX_DEFAULT_CLOCK_RIGHTS (ZX_RIGHTS_BASIC | ZX_RIGHTS_IO)
+
+#endif // SYSROOT_ZIRCON_RIGHTS_H_
diff --git a/arch/x64/sysroot/include/zircon/sanitizer.h b/arch/x64/sysroot/include/zircon/sanitizer.h
index 0b0b7a3..c2f2e8e 100644
--- a/arch/x64/sysroot/include/zircon/sanitizer.h
+++ b/arch/x64/sysroot/include/zircon/sanitizer.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SANITIZER_H_
+#define SYSROOT_ZIRCON_SANITIZER_H_
// Interfaces declared in this file are intended for the use of sanitizer
// runtime library implementation code. Each sanitizer runtime works only
@@ -38,14 +39,20 @@
// [shadow_base, shadow_limit) Shadow memory, preallocated.
// [0, shadow_base) Shadow gap, cannot be allocated.
typedef struct saniziter_shadow_bounds {
- uintptr_t shadow_base;
- uintptr_t shadow_limit;
- uintptr_t memory_limit;
+ uintptr_t shadow_base;
+ uintptr_t shadow_limit;
+ uintptr_t memory_limit;
} sanitizer_shadow_bounds_t;
// Returns the shadow bounds for the current process.
sanitizer_shadow_bounds_t __sanitizer_shadow_bounds(void);
+// Fill the shadow memory corresponding to [base, base+size) with |value|. The
+// threshold is used as a hint to determine when to switch to a more efficient
+// mechanism when zero-filling large shadow regions. This assumes that both
+// |base| and |size| are aligned to the shadow multiple.
+void __sanitizer_fill_shadow(uintptr_t base, size_t size, uint8_t value, size_t threshold);
+
// Write logging information from the sanitizer runtime. The buffer
// is expected to be printable text with '\n' ending each line.
// Timestamps and globally unique identifiers of the calling process
@@ -58,7 +65,7 @@
// files and their debugging information. The text can contain markup
// around address values that should be resolved symbolically; see
// TODO(mcgrathr) for the format and details of the post-processor.
-void __sanitizer_log_write(const char *buffer, size_t len);
+void __sanitizer_log_write(const char* buffer, size_t len);
// Runtimes that have binary data to publish (e.g. coverage) use this
// interface. The name describes the data sink that will receive this
@@ -80,16 +87,32 @@
// after this call returns. On success, this yields a read-only VMO
// handle from which the contents associated with that name can be
// read; the caller is responsible for closing this handle.
-zx_status_t __sanitizer_get_configuration(const char* config_name,
- zx_handle_t* out_vmo);
+zx_status_t __sanitizer_get_configuration(const char* config_name, zx_handle_t* out_vmo);
// Changes protection of the code in the range of len bytes starting
// from addr. The writable argument specifies whether the code should
// be made writable or not. This function is only valid on ranges within
// the caller's own code segment.
// TODO(phosek) removes this when the proper debugging interface exists.
-zx_status_t __sanitizer_change_code_protection(uintptr_t addr, size_t len,
- bool writable);
+zx_status_t __sanitizer_change_code_protection(uintptr_t addr, size_t len, bool writable);
+
+// This stops all other threads in the process so memory should be quiescent.
+// Then it makes callbacks for memory regions containing non-const global
+// variables, thread stacks, thread registers, and thread-local storage
+// regions (this includes thread_local variables as well as tss_set or
+// pthread_setspecific values). Each callback is optional; no such callbacks
+// are made if a null function pointer is given. The memory region passed to
+// each callback can be accessed only during that single callback and might no
+// longer be valid once the callback returns. Then it makes a final callback
+// before allowing other threads to resume running normally. If there are
+// problems stopping threads, no memory callbacks will be made and the
+// argument to the final callback will get an error code rather than ZX_OK.
+typedef void sanitizer_memory_snapshot_callback_t(void* mem, size_t len, void* arg);
+void __sanitizer_memory_snapshot(sanitizer_memory_snapshot_callback_t* globals,
+ sanitizer_memory_snapshot_callback_t* stacks,
+ sanitizer_memory_snapshot_callback_t* regs,
+ sanitizer_memory_snapshot_callback_t* tls,
+ void (*done)(zx_status_t, void*), void* arg);
// The "hook" interfaces are functions that the sanitizer runtime library
// can define and libc will call. There are default definitions in libc
@@ -106,17 +129,16 @@
// the initial thread has switched to its real thread stack. Since not
// even all of libc's own constructors have run yet, this should not call
// into libc or other library code.
-__EXPORT void __sanitizer_startup_hook(int argc, char** argv, char** envp,
- void* stack_base, size_t stack_size);
+__EXPORT void __sanitizer_startup_hook(int argc, char** argv, char** envp, void* stack_base,
+ size_t stack_size);
// This is called when a new thread has been created but is not yet
// running. Its C11 thrd_t value has been determined and its stack has
// been allocated. All that remains is to actually start the thread
// running (which can fail only in catastrophic bug situations). Its
// return value will be passed to __sanitizer_thread_create_hook, below.
-__EXPORT void* __sanitizer_before_thread_create_hook(
- thrd_t thread, bool detached, const char* name,
- void* stack_base, size_t stack_size);
+__EXPORT void* __sanitizer_before_thread_create_hook(thrd_t thread, bool detached, const char* name,
+ void* stack_base, size_t stack_size);
// This is called after a new thread has been created or creation has
// failed at the final stage; __sanitizer_before_thread_create_hook has
@@ -128,8 +150,7 @@
// <threads.h> thrd_* value), thread creation has failed and the thread
// details reported to __sanitizer_before_thread_create_hook will be
// freed without the thread ever starting.
-__EXPORT void __sanitizer_thread_create_hook(
- void* hook, thrd_t thread, int error);
+__EXPORT void __sanitizer_thread_create_hook(void* hook, thrd_t thread, int error);
// This is called in each new thread as it starts up. The argument is
// the same one returned by __sanitizer_before_thread_create_hook and
@@ -141,4 +162,10 @@
// The argument is the same one passed to __sanitizer_thread_start_hook.
__EXPORT void __sanitizer_thread_exit_hook(void* hook, thrd_t self);
+// This is called with the argument to _exit and its return value
+// is the actual exit status for the process.
+__EXPORT int __sanitizer_process_exit_hook(int status);
+
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SANITIZER_H_
diff --git a/arch/x64/sysroot/include/zircon/status.h b/arch/x64/sysroot/include/zircon/status.h
index 5d83c72..798d2b0 100644
--- a/arch/x64/sysroot/include/zircon/status.h
+++ b/arch/x64/sysroot/include/zircon/status.h
@@ -15,8 +15,8 @@
//
// For example, zx_status_get_string(ZX_ERR_TIMED_OUT) returns the string
// "ZX_ERR_TIMED_OUT".
-const char* _zx_status_get_string(zx_status_t status);
-const char* zx_status_get_string(zx_status_t status);
+__EXPORT const char* _zx_status_get_string(zx_status_t status);
+__EXPORT const char* zx_status_get_string(zx_status_t status);
#ifdef __cplusplus
}
diff --git a/arch/x64/sysroot/include/zircon/string_view.h b/arch/x64/sysroot/include/zircon/string_view.h
new file mode 100644
index 0000000..f54ff2a
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/string_view.h
@@ -0,0 +1,67 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#pragma once
+
+#include <stddef.h>
+#if __cplusplus >= 201103L && __has_include(<type_traits>)
+#include <type_traits>
+#endif
+
+// This represents a UTF-8 string constant provided by the vDSO itself.
+// This pointer remains valid and the string doesn't change for the
+// life of the process (if not the system).
+//
+// This type exists to be the return value type for vDSO functions.
+// In current machine ABIs, it's returned "for free" in two registers.
+// To a C caller, these functions have ABIs indistinguishable from if
+// they simply returned `const char*` so there is no overhead to
+// supporting the explicit-length API as well as the traditional C
+// string API, though it does require writing out `.c_str` in the
+// source. C++ 17 callers can take advantage of direct coercion to
+// the standard std::string_view and std::u8string_view types, which
+// also allows e.g. direct construction of std::string.
+typedef struct {
+ const char* c_str; // UTF-8, guaranteed to be '\0'-terminated.
+ size_t length; // Length, not including the '\0' terminator.
+
+#ifdef __cplusplus
+ // This is ABI-identical to the usual implementation of std::string_view,
+ // when applied to NUL-terminated C strings. But this API doesn't presume
+ // that std::string_view has a particular implementation or exists at all.
+ // For convenience of use without directly using the C++ standard library
+ // API, a templatized implicit coercion is defined to types that have the
+ // API of std::string_view or std::u8string_view. With the most common
+ // implementations, this coercion will be compiled away to nothing.
+ template <
+ typename _T
+#if __cplusplus >= 201103L && __has_include(<type_traits>)
+ ,
+ typename = typename std::enable_if<sizeof(typename _T::value_type) == sizeof(char)>::type
+#endif
+ >
+ operator _T() {
+ // It's preferable to exclude incompatible types via SFINAE so that
+ // the user's diagnostic experience is exactly as if no coercion
+ // operator existed. SFINAE should exclude this definition when a
+ // C++11 <type_traits> is available to define std::enable_if. If
+ // no standard C++ library header is available, this will provide
+ // a specific diagnostic.
+ static_assert(sizeof(typename _T::value_type) == sizeof(char),
+ "zx_string_view_t can be coerced to C++ 17 std::string_view"
+ " or std::u8string_view or types with equivalent API");
+ return {reinterpret_cast<typename _T::const_pointer>(c_str), length};
+ }
+
+ // Preferably zx_string_view_t values should just be coerced to
+ // std::string_view. But it provides the most minimal aspects of
+ // the equivalent API in case a return value expression is used
+ // directly as `zx_foo_string().data()`, for example.
+ using value_type = char;
+ using const_pointer = const char*;
+ using size_type = size_t;
+ const_pointer data() const { return c_str; }
+ size_type size() const { return length; }
+#endif
+} zx_string_view_t;
diff --git a/arch/x64/sysroot/include/zircon/syscalls.h b/arch/x64/sysroot/include/zircon/syscalls.h
index b5c0057..9e79e55 100644
--- a/arch/x64/sysroot/include/zircon/syscalls.h
+++ b/arch/x64/sysroot/include/zircon/syscalls.h
@@ -2,29 +2,40 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_H_
-#define ZIRCON_SYSCALLS_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_H_
+#define SYSROOT_ZIRCON_SYSCALLS_H_
-#include <zircon/types.h>
-#include <zircon/syscalls/types.h>
-
-#include <zircon/syscalls/pci.h>
+#include <zircon/string_view.h>
#include <zircon/syscalls/object.h>
+#include <zircon/syscalls/pci.h>
#include <zircon/syscalls/profile.h>
+#include <zircon/syscalls/types.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
-#if defined(__clang__)
-#define ZX_SYSCALL_PARAM_ATTR(x) __attribute__((annotate("zx_" #x)))
+#define _ZX_SYSCALL_DECL(name, type, attrs, nargs, arglist, prototype) \
+ extern attrs type zx_##name prototype; \
+ extern attrs type _zx_##name prototype;
+
+#ifdef __clang__
+#define _ZX_SYSCALL_ANNO(attr) __attribute__((attr))
#else
-#define ZX_SYSCALL_PARAM_ATTR(x) // no-op
+#define _ZX_SYSCALL_ANNO(attr) // Nothing for compilers without the support.
#endif
-#include <zircon/syscalls/definitions.h>
+#include <zircon/syscalls/internal/cdecls.inc>
+
+#undef _ZX_SYSCALL_ANNO
+#undef _ZX_SYSCALL_DECL
// Compatibility wrappers for deprecated syscalls also go here, when
// there are any.
+// This DEPRECATED interface is replaced by zx_system_get_version_string.
+zx_status_t zx_system_get_version(char* version, size_t version_size) __LEAF_FN;
+zx_status_t _zx_system_get_version(char* version, size_t version_size) __LEAF_FN;
+
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/clock.h b/arch/x64/sysroot/include/zircon/syscalls/clock.h
new file mode 100644
index 0000000..eab1cd1
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/syscalls/clock.h
@@ -0,0 +1,90 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
+#define SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
+
+#include <zircon/time.h>
+
+// clang-format off
+
+// Argument version identifiers.
+//
+// All zx_clock_* syscalls which fetch or receive a structure's worth of
+// arguments encode a version number in the options field of the syscall. This
+// version field is in the same location and is the same size for each syscall,
+// so a common set of macros may be used for encoding and decoding.
+#define ZX_CLOCK_ARGS_VERSION_SHIFT ((uint64_t)58u)
+#define ZX_CLOCK_ARGS_VERSION_BITS ((uint64_t)6u)
+#define ZX_CLOCK_ARGS_VERSION_MASK \
+ (((((uint64_t)1) << ZX_CLOCK_ARGS_VERSION_BITS) - 1) << ZX_CLOCK_ARGS_VERSION_SHIFT)
+#define ZX_CLOCK_ARGS_VERSION(_N) \
+ (((uint64_t)(_N) << ZX_CLOCK_ARGS_VERSION_SHIFT) & ZX_CLOCK_ARGS_VERSION_MASK)
+
+// Clock creation options.
+#define ZX_CLOCK_OPT_MONOTONIC ((uint64_t)1u << 0)
+#define ZX_CLOCK_OPT_CONTINUOUS ((uint64_t)1u << 1)
+#define ZX_CLOCK_OPT_AUTO_START ((uint64_t)1u << 2)
+
+#define ZX_CLOCK_OPTS_ALL ( \
+ ZX_CLOCK_OPT_MONOTONIC | \
+ ZX_CLOCK_OPT_CONTINUOUS | \
+ ZX_CLOCK_OPT_AUTO_START)
+
+// Clock update flags
+#define ZX_CLOCK_UPDATE_OPTION_VALUE_VALID ((uint64_t)1u << 0)
+#define ZX_CLOCK_UPDATE_OPTION_RATE_ADJUST_VALID ((uint64_t)1u << 1)
+#define ZX_CLOCK_UPDATE_OPTION_ERROR_BOUND_VALID ((uint64_t)1u << 2)
+
+#define ZX_CLOCK_UPDATE_OPTIONS_ALL ( \
+ ZX_CLOCK_UPDATE_OPTION_VALUE_VALID | \
+ ZX_CLOCK_UPDATE_OPTION_RATE_ADJUST_VALID | \
+ ZX_CLOCK_UPDATE_OPTION_ERROR_BOUND_VALID)
+
+// Clock rate adjustment limits
+#define ZX_CLOCK_UPDATE_MIN_RATE_ADJUST ((int32_t)-1000)
+#define ZX_CLOCK_UPDATE_MAX_RATE_ADJUST ((int32_t)1000)
+
+// Special clock error values
+#define ZX_CLOCK_UNKNOWN_ERROR ((uint64_t)0xFFFFFFFFFFFFFFFF)
+
+// clang-format on
+
+typedef struct zx_clock_create_args_v1 {
+ zx_time_t backstop_time;
+} zx_clock_create_args_v1_t;
+
+typedef struct zx_clock_rate {
+ uint32_t synthetic_ticks;
+ uint32_t reference_ticks;
+} zx_clock_rate_t;
+
+typedef struct zx_clock_transformation {
+ int64_t reference_offset;
+ int64_t synthetic_offset;
+ zx_clock_rate_t rate;
+} zx_clock_transformation_t;
+
+typedef struct zx_clock_details_v1 {
+ uint64_t options;
+ zx_time_t backstop_time;
+ zx_clock_transformation_t ticks_to_synthetic;
+ zx_clock_transformation_t mono_to_synthetic;
+ uint64_t error_bound;
+ zx_ticks_t query_ticks;
+ zx_ticks_t last_value_update_ticks;
+ zx_ticks_t last_rate_adjust_update_ticks;
+ zx_ticks_t last_error_bounds_update_ticks;
+ uint32_t generation_counter;
+ uint8_t padding1[4];
+} zx_clock_details_v1_t;
+
+typedef struct zx_clock_update_args_v1 {
+ int32_t rate_adjust;
+ uint8_t padding1[4];
+ int64_t value;
+ uint64_t error_bound;
+} zx_clock_update_args_v1_t;
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_CLOCK_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/debug.h b/arch/x64/sysroot/include/zircon/syscalls/debug.h
index 82ea309..373381f 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/debug.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/debug.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_DEBUG_
-#define ZIRCON_SYSCALLS_DEBUG_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_DEBUG_
+#define SYSROOT_ZIRCON_SYSCALLS_DEBUG_
#include <stdint.h>
#include <zircon/compiler.h>
@@ -14,43 +14,47 @@
// Value for ZX_THREAD_STATE_GENERAL_REGS on x86-64 platforms.
typedef struct zx_thread_state_general_regs {
- uint64_t rax;
- uint64_t rbx;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rsi;
- uint64_t rdi;
- uint64_t rbp;
- uint64_t rsp;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- uint64_t rip;
- uint64_t rflags;
+ uint64_t rax;
+ uint64_t rbx;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rsi;
+ uint64_t rdi;
+ uint64_t rbp;
+ uint64_t rsp;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ uint64_t rip;
+ uint64_t rflags;
+ uint64_t fs_base;
+ uint64_t gs_base;
} zx_thread_state_general_regs_t;
// Value for ZX_THREAD_STATE_FP_REGS on x64. Holds x87 and MMX state.
typedef struct zx_thread_state_fp_regs {
- uint16_t fcw; // Control word.
- uint16_t fsw; // Status word.
- uint8_t ftw; // Tag word.
- uint8_t reserved;
- uint16_t fop; // Opcode.
- uint64_t fip; // Instruction pointer.
- uint64_t fdp; // Data pointer.
+ uint16_t fcw; // Control word.
+ uint16_t fsw; // Status word.
+ uint8_t ftw; // Tag word.
+ uint8_t reserved;
+ uint16_t fop; // Opcode.
+ uint64_t fip; // Instruction pointer.
+ uint64_t fdp; // Data pointer.
- // The x87/MMX state. For x87 the each "st" entry has the low 80 bits used for the register
- // contents. For MMX, the low 64 bits are used. The higher bits are unused.
- __ALIGNED(16)
- struct {
- uint64_t low;
- uint64_t high;
- } st[8];
+ uint8_t padding1[8];
+
+ // The x87/MMX state. For x87 the each "st" entry has the low 80 bits used for the register
+ // contents. For MMX, the low 64 bits are used. The higher bits are unused.
+ __ALIGNED(16)
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } st[8];
} zx_thread_state_fp_regs_t;
// Value for ZX_THREAD_STATE_VECTOR_REGS on x64. Holds SSE and AVX registers.
@@ -58,58 +62,56 @@
// Setting vector registers will only work for threads that have previously executed an
// instruction using the corresponding register class.
typedef struct zx_thread_state_vector_regs {
- // When only 16 registers are supported (pre-AVX-512), zmm[16-31] will be 0.
- // YMM registers (256 bits) are v[0-4], XMM registers (128 bits) are v[0-2].
- struct {
- uint64_t v[8];
- } zmm[32];
+ // When only 16 registers are supported (pre-AVX-512), zmm[16-31] will be 0.
+ // YMM registers (256 bits) are v[0-4], XMM registers (128 bits) are v[0-2].
+ struct {
+ uint64_t v[8];
+ } zmm[32];
- // AVX-512 opmask registers. Will be 0 unless AVX-512 is supported.
- uint64_t opmask[8];
+ // AVX-512 opmask registers. Will be 0 unless AVX-512 is supported.
+ uint64_t opmask[8];
- // SIMD control and status register.
- uint32_t mxcsr;
+ // SIMD control and status register.
+ uint32_t mxcsr;
+
+ uint8_t padding1[4];
} zx_thread_state_vector_regs_t;
// Value for ZX_THREAD_STATE_DEBUG_REGS on x64 platforms.
typedef struct zx_thread_state_debug_regs {
uint64_t dr[4];
// DR4 and D5 are not used.
- uint64_t dr6; // Status register.
- uint64_t dr7; // Control register.
- // TODO(donosoc): These values are deprecated but are still used by zxdb. We debine both values
- // in order to do a soft transition. Delete these values once zxdb has made the
- // update.
- uint64_t dr6_status; // Status register.
- uint64_t dr7_control; // Control register.
+ uint64_t dr6; // Status register.
+ uint64_t dr7; // Control register.
} zx_thread_state_debug_regs_t;
#elif defined(__aarch64__)
// Value for ZX_THREAD_STATE_GENERAL_REGS on ARM64 platforms.
typedef struct zx_thread_state_general_regs {
- uint64_t r[30];
- uint64_t lr;
- uint64_t sp;
- uint64_t pc;
- uint64_t cpsr;
+ uint64_t r[30];
+ uint64_t lr;
+ uint64_t sp;
+ uint64_t pc;
+ uint64_t cpsr;
+ uint64_t tpidr;
} zx_thread_state_general_regs_t;
// Value for ZX_THREAD_STATE_FP_REGS on ARM64 platforms.
// This is unused because vector state is used for all floating point on ARM64.
typedef struct zx_thread_state_fp_regs {
- // Avoids sizing differences for empty structs between C and C++.
- uint32_t unused;
+ // Avoids sizing differences for empty structs between C and C++.
+ uint32_t unused;
} zx_thread_state_fp_regs_t;
// Value for ZX_THREAD_STATE_VECTOR_REGS on ARM64 platforms.
typedef struct zx_thread_state_vector_regs {
- uint32_t fpcr;
- uint32_t fpsr;
- struct {
- uint64_t low;
- uint64_t high;
- } v[32];
+ uint32_t fpcr;
+ uint32_t fpsr;
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } v[32];
} zx_thread_state_vector_regs_t;
// ARMv8-A provides 2 to 16 hardware breakpoint registers.
@@ -122,19 +124,34 @@
// Value for XZ_THREAD_STATE_DEBUG_REGS for ARM64 platforms.
typedef struct zx_thread_state_debug_regs {
struct {
- uint64_t dbgbvr; // HW Breakpoint Value register.
- uint32_t dbgbcr; // HW Breakpoint Control register.
+ uint32_t dbgbcr; // HW Breakpoint Control register.
+ uint8_t padding1[4];
+ uint64_t dbgbvr; // HW Breakpoint Value register.
} hw_bps[AARCH64_MAX_HW_BREAKPOINTS];
// Number of HW Breakpoints in the platform.
// Will be set on read and ignored on write.
- uint8_t hw_bps_count;
+
struct {
- uint64_t dbgwvr; // HW Watchpoint Value register.
- uint32_t dbgwcr; // HW Watchpoint Control register.
+ uint32_t dbgwcr; // HW Watchpoint Control register.
+ uint8_t padding1[4];
+ uint64_t dbgwvr; // HW Watchpoint Value register.
} hw_wps[AARCH64_MAX_HW_WATCHPOINTS];
- // Number of HW Watchpoints in the platform.
+
+ // Faulting Virtual Address for watchpoint exceptions.
+ // Read-only, values are ignored on write.
+ uint64_t far;
+
+ // The esr value since the last exception.
+ // Read-only, values are ignored on write.
+ uint32_t esr;
+
+ // Number of HW Breakpoints/Watchpoints in the platform.
// Will be set on read and ignored on write.
+ uint8_t hw_bps_count;
uint8_t hw_wps_count;
+
+ uint8_t padding1[2];
+
} zx_thread_state_debug_regs_t;
#endif
@@ -149,14 +166,14 @@
// Possible values for "kind" in zx_thread_read_state and zx_thread_write_state.
typedef uint32_t zx_thread_state_topic_t;
-#define ZX_THREAD_STATE_GENERAL_REGS ((uint32_t)0) // zx_thread_state_general_regs_t value.
-#define ZX_THREAD_STATE_FP_REGS ((uint32_t)1) // zx_thread_state_fp_regs_t value.
-#define ZX_THREAD_STATE_VECTOR_REGS ((uint32_t)2) // zx_thread_state_vector_regs_t value.
-#define ZX_THREAD_STATE_DEBUG_REGS ((uint32_t)4) // zx_thread_state_debug_regs_t value.
-#define ZX_THREAD_STATE_SINGLE_STEP ((uint32_t)5) // zx_thread_state_single_step_t value.
-#define ZX_THREAD_X86_REGISTER_FS ((uint32_t)6) // zx_thread_x86_register_fs_t value.
-#define ZX_THREAD_X86_REGISTER_GS ((uint32_t)7) // zx_thread_x86_register_gs_t value.
+#define ZX_THREAD_STATE_GENERAL_REGS ((uint32_t)0) // zx_thread_state_general_regs_t value.
+#define ZX_THREAD_STATE_FP_REGS ((uint32_t)1) // zx_thread_state_fp_regs_t value.
+#define ZX_THREAD_STATE_VECTOR_REGS ((uint32_t)2) // zx_thread_state_vector_regs_t value.
+#define ZX_THREAD_STATE_DEBUG_REGS ((uint32_t)4) // zx_thread_state_debug_regs_t value.
+#define ZX_THREAD_STATE_SINGLE_STEP ((uint32_t)5) // zx_thread_state_single_step_t value.
+#define ZX_THREAD_X86_REGISTER_FS ((uint32_t)6) // zx_thread_x86_register_fs_t value.
+#define ZX_THREAD_X86_REGISTER_GS ((uint32_t)7) // zx_thread_x86_register_gs_t value.
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_DEBUG_
+#endif // SYSROOT_ZIRCON_SYSCALLS_DEBUG_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/definitions.h b/arch/x64/sysroot/include/zircon/syscalls/definitions.h
deleted file mode 100644
index 70da713..0000000
--- a/arch/x64/sysroot/include/zircon/syscalls/definitions.h
+++ /dev/null
@@ -1,1839 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// This is a GENERATED file, see //zircon/system/host/abigen.
-// The license governing this file can be found in the LICENSE file.
-
-extern zx_time_t zx_clock_get(
- zx_clock_t clock_id) __LEAF_FN;
-
-extern zx_time_t _zx_clock_get(
- zx_clock_t clock_id) __LEAF_FN;
-
-extern zx_status_t zx_clock_get_new(
- zx_clock_t clock_id,
- zx_time_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_clock_get_new(
- zx_clock_t clock_id,
- zx_time_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_time_t zx_clock_get_monotonic(
- void) __LEAF_FN;
-
-extern zx_time_t _zx_clock_get_monotonic(
- void) __LEAF_FN;
-
-extern zx_status_t zx_nanosleep(
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_nanosleep(
- zx_time_t deadline) __LEAF_FN;
-
-extern uint64_t zx_ticks_get(
- void) __LEAF_FN;
-
-extern uint64_t _zx_ticks_get(
- void) __LEAF_FN;
-
-extern uint64_t zx_ticks_per_second(
- void) __LEAF_FN __CONST;
-
-extern uint64_t _zx_ticks_per_second(
- void) __LEAF_FN __CONST;
-
-extern zx_time_t zx_deadline_after(
- zx_duration_t nanoseconds) __LEAF_FN;
-
-extern zx_time_t _zx_deadline_after(
- zx_duration_t nanoseconds) __LEAF_FN;
-
-extern zx_status_t zx_clock_adjust(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_clock_t clock_id,
- int64_t offset) __LEAF_FN;
-
-extern zx_status_t _zx_clock_adjust(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_clock_t clock_id,
- int64_t offset) __LEAF_FN;
-
-extern uint32_t zx_system_get_dcache_line_size(
- void) __LEAF_FN __CONST;
-
-extern uint32_t _zx_system_get_dcache_line_size(
- void) __LEAF_FN __CONST;
-
-extern uint32_t zx_system_get_num_cpus(
- void) __LEAF_FN __CONST;
-
-extern uint32_t _zx_system_get_num_cpus(
- void) __LEAF_FN __CONST;
-
-extern zx_status_t zx_system_get_version(
- char* version,
- size_t version_size) __LEAF_FN;
-
-extern zx_status_t _zx_system_get_version(
- char* version,
- size_t version_size) __LEAF_FN;
-
-extern uint64_t zx_system_get_physmem(
- void) __LEAF_FN;
-
-extern uint64_t _zx_system_get_physmem(
- void) __LEAF_FN;
-
-extern zx_status_t zx_system_get_features(
- uint32_t kind,
- ZX_SYSCALL_PARAM_ATTR(features) uint32_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_system_get_features(
- uint32_t kind,
- ZX_SYSCALL_PARAM_ATTR(features) uint32_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_cache_flush(
- const void* addr,
- size_t size,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_cache_flush(
- const void* addr,
- size_t size,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_handle_close(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_handle_close(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_handle_close_many(
- const zx_handle_t* handles,
- size_t num_handles) __LEAF_FN;
-
-extern zx_status_t _zx_handle_close_many(
- const zx_handle_t* handles,
- size_t num_handles) __LEAF_FN;
-
-extern zx_status_t zx_handle_duplicate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_handle_duplicate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_handle_replace(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_handle_replace(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- zx_rights_t rights,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_one(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_signals_t signals,
- zx_time_t deadline,
- zx_signals_t* observed) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_one(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_signals_t signals,
- zx_time_t deadline,
- zx_signals_t* observed) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_many(
- zx_wait_item_t* items,
- size_t count,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_many(
- zx_wait_item_t* items,
- size_t count,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_object_wait_async(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- zx_signals_t signals,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_object_wait_async(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- zx_signals_t signals,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_object_signal(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t _zx_object_signal(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t zx_object_signal_peer(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t _zx_object_signal_peer(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t clear_mask,
- uint32_t set_mask) __LEAF_FN;
-
-extern zx_status_t zx_object_get_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t zx_object_set_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- const void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_property(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t property,
- const void* value,
- size_t value_size) __LEAF_FN;
-
-extern zx_status_t zx_object_set_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t cookie) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t cookie) __LEAF_FN;
-
-extern zx_status_t zx_object_get_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t* cookie) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_cookie(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t scope,
- uint64_t* cookie) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_object_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t topic,
- void* buffer,
- size_t buffer_size,
- size_t* actual_count,
- size_t* avail_count) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t topic,
- void* buffer,
- size_t buffer_size,
- size_t* actual_count,
- size_t* avail_count) __LEAF_FN;
-
-extern zx_status_t zx_object_get_child(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t koid,
- zx_rights_t rights,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_object_get_child(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t koid,
- zx_rights_t rights,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_object_set_profile(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t profile,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_object_set_profile(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t profile,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_channel_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_channel_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_channel_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_read_etc(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_info_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_read_etc(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* bytes,
- zx_handle_info_t* handles,
- uint32_t num_bytes,
- uint32_t num_handles,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* bytes,
- uint32_t num_bytes,
- const zx_handle_t* handles,
- uint32_t num_handles) __LEAF_FN;
-
-extern zx_status_t _zx_channel_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* bytes,
- uint32_t num_bytes,
- const zx_handle_t* handles,
- uint32_t num_handles) __LEAF_FN;
-
-extern zx_status_t zx_channel_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t deadline,
- const zx_channel_call_args_t* args,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_channel_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t deadline,
- const zx_channel_call_args_t* args,
- uint32_t* actual_bytes,
- uint32_t* actual_handles) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_socket_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_socket_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_socket_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t _zx_socket_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t zx_socket_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t _zx_socket_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __LEAF_FN;
-
-extern zx_status_t zx_socket_share(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t socket_to_share) __LEAF_FN;
-
-extern zx_status_t _zx_socket_share(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t socket_to_share) __LEAF_FN;
-
-extern zx_status_t zx_socket_accept(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_socket) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_socket_accept(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_socket) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_socket_shutdown(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_socket_shutdown(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options) __LEAF_FN;
-
-extern void zx_thread_exit(
- void) __LEAF_FN __NO_RETURN;
-
-extern void _zx_thread_exit(
- void) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_thread_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t process,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_thread_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t process,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_thread_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t thread_entry,
- zx_vaddr_t stack,
- uintptr_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t _zx_thread_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t thread_entry,
- zx_vaddr_t stack,
- uintptr_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t zx_thread_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_thread_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_thread_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_thread_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_thread_set_priority(
- int32_t prio) __LEAF_FN;
-
-extern zx_status_t _zx_thread_set_priority(
- int32_t prio) __LEAF_FN;
-
-extern void zx_process_exit(
- int64_t retcode) __LEAF_FN __NO_RETURN;
-
-extern void _zx_process_exit(
- int64_t retcode) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_process_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* proc_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_process_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- const char* name,
- size_t name_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* proc_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_process_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t thread,
- zx_vaddr_t entry,
- zx_vaddr_t stack,
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t _zx_process_start(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t thread,
- zx_vaddr_t entry,
- zx_vaddr_t stack,
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t arg1,
- uintptr_t arg2) __LEAF_FN;
-
-extern zx_status_t zx_process_read_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_process_read_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_process_write_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_process_write_memory(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t proc,
- zx_vaddr_t vaddr,
- const void* buffer,
- size_t buffer_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_job_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_job,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_job_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_job,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_job_set_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- uint32_t options,
- uint32_t topic,
- const void* policy,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t _zx_job_set_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t job,
- uint32_t options,
- uint32_t topic,
- const void* policy,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t zx_task_bind_exception_port(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_task_bind_exception_port(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_task_suspend(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_task_suspend(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_task_suspend_token(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_task_suspend_token(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* token) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_task_resume_from_exception(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_task_resume_from_exception(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_task_kill(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_task_kill(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_event_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_event_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_eventpair_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_eventpair_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_futex_wait(
- const zx_futex_t* value_ptr,
- zx_futex_t current_value,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_futex_owner,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wait(
- const zx_futex_t* value_ptr,
- zx_futex_t current_value,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_futex_owner,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_futex_wake(
- const zx_futex_t* value_ptr,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wake(
- const zx_futex_t* value_ptr,
- uint32_t count) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t zx_futex_wake_single_owner(
- const zx_futex_t* value_ptr) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wake_single_owner(
- const zx_futex_t* value_ptr) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue_single_owner(
- const zx_futex_t* wake_ptr,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue_single_owner(
- const zx_futex_t* wake_ptr,
- zx_futex_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t new_requeue_owner) __LEAF_FN;
-
-extern zx_status_t zx_futex_get_owner(
- const zx_futex_t* value_ptr,
- zx_koid_t* koid) __LEAF_FN;
-
-extern zx_status_t _zx_futex_get_owner(
- const zx_futex_t* value_ptr,
- zx_koid_t* koid) __LEAF_FN;
-
-extern zx_status_t zx_futex_wait_deprecated(
- const zx_futex_t* value_ptr,
- int32_t current_value,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t _zx_futex_wait_deprecated(
- const zx_futex_t* value_ptr,
- int32_t current_value,
- zx_time_t deadline) __LEAF_FN;
-
-extern zx_status_t zx_futex_requeue_deprecated(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- int32_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count) __LEAF_FN;
-
-extern zx_status_t _zx_futex_requeue_deprecated(
- const zx_futex_t* wake_ptr,
- uint32_t wake_count,
- int32_t current_value,
- const zx_futex_t* requeue_ptr,
- uint32_t requeue_count) __LEAF_FN;
-
-extern zx_status_t zx_port_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_port_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_port_queue(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t _zx_port_queue(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t zx_port_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t _zx_port_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_port_packet_t* packet) __LEAF_FN;
-
-extern zx_status_t zx_port_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t source,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t _zx_port_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t source,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t zx_timer_create(
- uint32_t options,
- zx_clock_t clock_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_timer_create(
- uint32_t options,
- zx_clock_t clock_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_timer_set(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_duration_t slack) __LEAF_FN;
-
-extern zx_status_t _zx_timer_set(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t deadline,
- zx_duration_t slack) __LEAF_FN;
-
-extern zx_status_t zx_timer_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_timer_cancel(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create(
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create(
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const void* buffer,
- uint64_t offset,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_get_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t* size) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_get_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t* size) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_set_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_set_size(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_op_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t op,
- uint64_t offset,
- uint64_t size,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_op_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t op,
- uint64_t offset,
- uint64_t size,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vmo_clone(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_clone(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_set_cache_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t cache_policy) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_set_cache_policy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t cache_policy) __LEAF_FN;
-
-extern zx_status_t zx_vmo_replace_as_executable(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmex,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_replace_as_executable(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmex,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_allocate_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- uint64_t offset,
- uint64_t size,
- uint32_t map_flags,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_allocate_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- uint64_t offset,
- uint64_t size,
- uint32_t map_flags,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_map_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- uint32_t map_flags,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_map_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- uint32_t map_flags,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_protect_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len,
- uint32_t prot_flags) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_protect_old(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len,
- uint32_t prot_flags) __LEAF_FN;
-
-extern zx_status_t zx_vmar_allocate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- zx_vm_option_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_allocate(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_vmar,
- zx_vm_option_t options,
- uint64_t offset,
- uint64_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* child_vmar,
- zx_vaddr_t* child_addr) __NONNULL((5, 6)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_vmar_map(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_map(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- uint64_t vmar_offset,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t vmo_offset,
- uint64_t len,
- zx_vaddr_t* mapped_addr) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_unmap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_unmap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t zx_vmar_protect(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_protect(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_vm_option_t options,
- zx_vaddr_t addr,
- uint64_t len) __LEAF_FN;
-
-extern void zx_cprng_draw(
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern void _zx_cprng_draw(
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_cprng_add_entropy(
- const void* buffer,
- size_t len) __LEAF_FN;
-
-extern zx_status_t _zx_cprng_add_entropy(
- const void* buffer,
- size_t len) __LEAF_FN;
-
-extern zx_status_t zx_fifo_create(
- size_t elem_count,
- size_t elem_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((4, 5)) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_create(
- size_t elem_count,
- size_t elem_size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out0,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out1) __NONNULL((4, 5)) __LEAF_FN;
-
-extern zx_status_t zx_fifo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t zx_fifo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- const void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t _zx_fifo_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- size_t elem_size,
- const void* data,
- size_t count,
- size_t* actual_count) __LEAF_FN;
-
-extern zx_status_t zx_profile_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const zx_profile_info_t* profile,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_profile_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const zx_profile_info_t* profile,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_vmar_unmap_handle_close_thread_exit(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmar_handle,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_vmar_unmap_handle_close_thread_exit(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmar_handle,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN;
-
-extern void zx_futex_wake_handle_close_thread_exit(
- const zx_futex_t* value_ptr,
- uint32_t count,
- int32_t new_value,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN __NO_RETURN;
-
-extern void _zx_futex_wake_handle_close_thread_exit(
- const zx_futex_t* value_ptr,
- uint32_t count,
- int32_t new_value,
- ZX_SYSCALL_PARAM_ATTR(handle_release) zx_handle_t handle) __LEAF_FN __NO_RETURN;
-
-extern zx_status_t zx_log_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- const void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_log_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- const void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_log_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_log_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t len,
- void* buffer,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debuglog_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debuglog_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* data,
- uint32_t offset,
- size_t data_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- void* data,
- uint32_t offset,
- size_t data_size,
- size_t* actual) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t action,
- uint32_t options,
- void* ptr) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t action,
- uint32_t options,
- void* ptr) __LEAF_FN;
-
-extern zx_status_t zx_ktrace_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t id,
- uint32_t arg0,
- uint32_t arg1) __LEAF_FN;
-
-extern zx_status_t _zx_ktrace_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t id,
- uint32_t arg0,
- uint32_t arg1) __LEAF_FN;
-
-extern zx_status_t zx_mtrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- uint32_t action,
- uint32_t options,
- void* ptr,
- size_t ptr_size) __LEAF_FN;
-
-extern zx_status_t _zx_mtrace_control(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- uint32_t action,
- uint32_t options,
- void* ptr,
- size_t ptr_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- char* buffer,
- size_t* buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- char* buffer,
- size_t* buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_write(
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_write(
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_debug_send_command(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_debug_send_command(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- const char* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t src_obj,
- uint32_t src_num,
- uint32_t options,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t src_obj,
- uint32_t src_num,
- uint32_t options,
- zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_bind(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_bind(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t* out_timestamp) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_wait(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_time_t* out_timestamp) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_destroy(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_ack(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_ack(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_trigger(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t timestamp) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_trigger(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- zx_time_t timestamp) __LEAF_FN;
-
-extern zx_status_t zx_interrupt_bind_vcpu(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vcpu,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t _zx_interrupt_bind_vcpu(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vcpu,
- uint32_t options) __LEAF_FN;
-
-extern zx_status_t zx_ioports_request(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint16_t io_addr,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t _zx_ioports_request(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint16_t io_addr,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create_contiguous(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bti,
- size_t size,
- uint32_t alignment_log2,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create_contiguous(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bti,
- size_t size,
- uint32_t alignment_log2,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_vmo_create_physical(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- zx_paddr_t paddr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vmo_create_physical(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- zx_paddr_t paddr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_iommu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t type,
- const void* desc,
- size_t desc_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t _zx_iommu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t type,
- const void* desc,
- size_t desc_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((5)) __LEAF_FN;
-
-extern zx_status_t zx_bti_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t iommu,
- uint32_t options,
- uint64_t bti_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_bti_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t iommu,
- uint32_t options,
- uint64_t bti_id,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_bti_pin(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t offset,
- uint64_t size,
- zx_paddr_t* addrs,
- size_t addrs_count,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((8)) __LEAF_FN;
-
-extern zx_status_t _zx_bti_pin(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint64_t offset,
- uint64_t size,
- zx_paddr_t* addrs,
- size_t addrs_count,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((8)) __LEAF_FN;
-
-extern zx_status_t zx_bti_release_quarantine(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_bti_release_quarantine(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_pmt_unpin(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_pmt_unpin(
- ZX_SYSCALL_PARAM_ATTR(handle_release_always) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_framebuffer_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t* format,
- uint32_t* width,
- uint32_t* height,
- uint32_t* stride) __NONNULL((2, 3, 4, 5)) __LEAF_FN;
-
-extern zx_status_t _zx_framebuffer_get_info(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t* format,
- uint32_t* width,
- uint32_t* height,
- uint32_t* stride) __NONNULL((2, 3, 4, 5)) __LEAF_FN;
-
-extern zx_status_t zx_framebuffer_set_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint32_t len,
- uint32_t format,
- uint32_t width,
- uint32_t height,
- uint32_t stride) __LEAF_FN;
-
-extern zx_status_t _zx_framebuffer_set_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t vmo,
- uint32_t len,
- uint32_t format,
- uint32_t width,
- uint32_t height,
- uint32_t stride) __LEAF_FN;
-
-extern zx_status_t zx_pci_get_nth_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t index,
- zx_pcie_device_info_t* out_info,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_get_nth_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t index,
- zx_pcie_device_info_t* out_info,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t zx_pci_enable_bus_master(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool enable) __LEAF_FN;
-
-extern zx_status_t _zx_pci_enable_bus_master(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool enable) __LEAF_FN;
-
-extern zx_status_t zx_pci_reset_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t _zx_pci_reset_device(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle) __LEAF_FN;
-
-extern zx_status_t zx_pci_config_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t* out_val) __LEAF_FN;
-
-extern zx_status_t _zx_pci_config_read(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t* out_val) __LEAF_FN;
-
-extern zx_status_t zx_pci_config_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t val) __LEAF_FN;
-
-extern zx_status_t _zx_pci_config_write(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint16_t offset,
- size_t width,
- uint32_t val) __LEAF_FN;
-
-extern zx_status_t zx_pci_cfg_pio_rw(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint8_t bus,
- uint8_t dev,
- uint8_t func,
- uint8_t offset,
- uint32_t* val,
- size_t width,
- bool write) __LEAF_FN;
-
-extern zx_status_t _zx_pci_cfg_pio_rw(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint8_t bus,
- uint8_t dev,
- uint8_t func,
- uint8_t offset,
- uint32_t* val,
- size_t width,
- bool write) __LEAF_FN;
-
-extern zx_status_t zx_pci_get_bar(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t bar_num,
- zx_pci_bar_t* out_bar,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_get_bar(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t bar_num,
- zx_pci_bar_t* out_bar,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_pci_map_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- int32_t which_irq,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_map_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- int32_t which_irq,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out_handle) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_pci_query_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t* out_max_irqs) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_pci_query_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t* out_max_irqs) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_pci_set_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t requested_irq_count) __LEAF_FN;
-
-extern zx_status_t _zx_pci_set_irq_mode(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t mode,
- uint32_t requested_irq_count) __LEAF_FN;
-
-extern zx_status_t zx_pci_init(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_pci_init_arg_t* init_buf,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t _zx_pci_init(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_pci_init_arg_t* init_buf,
- uint32_t len) __LEAF_FN;
-
-extern zx_status_t zx_pci_add_subtract_io_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool mmio,
- uint64_t base,
- uint64_t len,
- bool add) __LEAF_FN;
-
-extern zx_status_t _zx_pci_add_subtract_io_range(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- bool mmio,
- uint64_t base,
- uint64_t len,
- bool add) __LEAF_FN;
-
-extern zx_status_t zx_pc_firmware_tables(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_paddr_t* acpi_rsdp,
- zx_paddr_t* smbios) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t _zx_pc_firmware_tables(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_paddr_t* acpi_rsdp,
- zx_paddr_t* smbios) __NONNULL((2, 3)) __LEAF_FN;
-
-extern zx_status_t zx_smc_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_smc_parameters_t* parameters,
- zx_smc_result_t* out_smc_result) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t _zx_smc_call(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- const zx_smc_parameters_t* parameters,
- zx_smc_result_t* out_smc_result) __NONNULL((3)) __LEAF_FN;
-
-extern zx_status_t zx_resource_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_rsrc,
- uint32_t options,
- uint64_t base,
- size_t size,
- const char* name,
- size_t name_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* resource_out) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t _zx_resource_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t parent_rsrc,
- uint32_t options,
- uint64_t base,
- size_t size,
- const char* name,
- size_t name_size,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* resource_out) __NONNULL((7)) __LEAF_FN;
-
-extern zx_status_t zx_guest_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* guest_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t _zx_guest_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* guest_handle,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* vmar_handle) __NONNULL((3, 4)) __LEAF_FN;
-
-extern zx_status_t zx_guest_set_trap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t _zx_guest_set_trap(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- zx_vaddr_t addr,
- size_t size,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t guest,
- uint32_t options,
- zx_vaddr_t entry,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_create(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t guest,
- uint32_t options,
- zx_vaddr_t entry,
- ZX_SYSCALL_PARAM_ATTR(handle_acquire) zx_handle_t* out) __NONNULL((4)) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_resume(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_port_packet_t* packet) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_resume(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- zx_port_packet_t* packet) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t vector) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_interrupt(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t vector) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_read_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_vcpu_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_vcpu_write_state(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t handle,
- uint32_t kind,
- const void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_system_mexec(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t kernel,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bootimage) __LEAF_FN;
-
-extern zx_status_t _zx_system_mexec(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t kernel,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t bootimage) __LEAF_FN;
-
-extern zx_status_t zx_system_mexec_payload_get(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t _zx_system_mexec_payload_get(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- void* buffer,
- size_t buffer_size) __LEAF_FN;
-
-extern zx_status_t zx_system_powerctl(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t cmd,
- const zx_system_powerctl_arg_t* arg) __LEAF_FN;
-
-extern zx_status_t _zx_system_powerctl(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t resource,
- uint32_t cmd,
- const zx_system_powerctl_arg_t* arg) __LEAF_FN;
-
-extern zx_status_t zx_pager_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(pager) zx_handle_t* out_pager) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t _zx_pager_create(
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(pager) zx_handle_t* out_pager) __NONNULL((2)) __LEAF_FN;
-
-extern zx_status_t zx_pager_create_vmo(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t pager,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(out_pager_vmo) zx_handle_t* out_pager_vmo) __NONNULL((6)) __LEAF_FN;
-
-extern zx_status_t _zx_pager_create_vmo(
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t pager,
- ZX_SYSCALL_PARAM_ATTR(handle_use) zx_handle_t port,
- uint64_t key,
- uint64_t size,
- uint32_t options,
- ZX_SYSCALL_PARAM_ATTR(out_pager_vmo) zx_handle_t* out_pager_vmo) __NONNULL((6)) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_0(
- void) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_0(
- void) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_1(
- int a) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_1(
- int a) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_2(
- int a,
- int b) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_2(
- int a,
- int b) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_3(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_3(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_4(
- int a,
- int b,
- int c,
- int d) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_4(
- int a,
- int b,
- int c,
- int d) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_5(
- int a,
- int b,
- int c,
- int d,
- int e) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_5(
- int a,
- int b,
- int c,
- int d,
- int e) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_6(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_6(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_7(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_7(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_8(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g,
- int h) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_8(
- int a,
- int b,
- int c,
- int d,
- int e,
- int f,
- int g,
- int h) __LEAF_FN;
-
-extern zx_status_t zx_syscall_test_wrapper(
- int a,
- int b,
- int c) __LEAF_FN;
-
-extern zx_status_t _zx_syscall_test_wrapper(
- int a,
- int b,
- int c) __LEAF_FN;
-
-
diff --git a/arch/x64/sysroot/include/zircon/syscalls/exception.h b/arch/x64/sysroot/include/zircon/syscalls/exception.h
index 4ddf2fb..6191e0f 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/exception.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/exception.h
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_EXCEPTION_H_
-#define ZIRCON_SYSCALLS_EXCEPTION_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
+#define SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
#include <zircon/compiler.h>
-#include <zircon/syscalls/port.h>
#include <zircon/types.h>
__BEGIN_CDECLS
@@ -14,63 +13,60 @@
// ask clang format not to mess up the indentation:
// clang-format off
-// This bit is set for synthetic exceptions to distinguish them from
-// architectural exceptions.
-// Note: Port packet types provide 8 bits to distinguish the exception type.
-// See zircon/port.h.
-#define ZX_EXCP_SYNTH ((uint8_t)0x80)
+// The following exception values were chosen for historical reasons.
-// The kind of an exception.
-// Exception types are a subset of port packet types. See zircon/port.h.
-
-// These are architectural exceptions.
+// Architectural exceptions.
+//
// Depending on the exception, further information can be found in
// |report.context.arch|.
-// General exception not covered by another value.
-#define ZX_EXCP_GENERAL ZX_PKT_TYPE_EXCEPTION(0)
-#define ZX_EXCP_FATAL_PAGE_FAULT ZX_PKT_TYPE_EXCEPTION(1)
-#define ZX_EXCP_UNDEFINED_INSTRUCTION ZX_PKT_TYPE_EXCEPTION(2)
-#define ZX_EXCP_SW_BREAKPOINT ZX_PKT_TYPE_EXCEPTION(3)
-#define ZX_EXCP_HW_BREAKPOINT ZX_PKT_TYPE_EXCEPTION(4)
-#define ZX_EXCP_UNALIGNED_ACCESS ZX_PKT_TYPE_EXCEPTION(5)
+#define ZX_EXCP_GENERAL ((uint32_t) 0x008u)
+#define ZX_EXCP_FATAL_PAGE_FAULT ((uint32_t) 0x108u)
+#define ZX_EXCP_UNDEFINED_INSTRUCTION ((uint32_t) 0x208u)
+#define ZX_EXCP_SW_BREAKPOINT ((uint32_t) 0x308u)
+#define ZX_EXCP_HW_BREAKPOINT ((uint32_t) 0x408u)
+#define ZX_EXCP_UNALIGNED_ACCESS ((uint32_t) 0x508u)
// Synthetic exceptions.
+// These bits are set for synthetic exceptions to distinguish them from
+// architectural exceptions.
+#define ZX_EXCP_SYNTH ((uint32_t) 0x8000u)
+
// A thread is starting.
-// This exception is sent to debuggers only (ZX_EXCEPTION_PORT_TYPE_DEBUGGER).
-// The thread is paused until it is resumed by the debugger
-// with zx_task_resume_from_exception.
-#define ZX_EXCP_THREAD_STARTING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 0)
+// This exception is sent to debuggers only (ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER).
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_THREAD_STARTING ((uint32_t) 0x008u | ZX_EXCP_SYNTH)
// A thread is exiting.
-// This exception is sent to debuggers only (ZX_EXCEPTION_PORT_TYPE_DEBUGGER).
+// This exception is sent to debuggers only (ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER).
// This exception is different from ZX_EXCP_GONE in that a debugger can
// still examine thread state.
-// The thread is paused until it is resumed by the debugger
-// with zx_task_resume_from_exception.
-#define ZX_EXCP_THREAD_EXITING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 1)
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_THREAD_EXITING ((uint32_t) 0x108u | ZX_EXCP_SYNTH)
// This exception is generated when a syscall fails with a job policy
// error (for example, an invalid handle argument is passed to the
// syscall when the ZX_POL_BAD_HANDLE policy is enabled) and
-// ZX_POL_ACTION_EXCEPTION is set for the policy. The thread that
-// invoked the syscall may be resumed with zx_task_resume_from_exception.
-#define ZX_EXCP_POLICY_ERROR ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 2)
+// ZX_POL_ACTION_EXCEPTION is set for the policy.
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_POLICY_ERROR ((uint32_t) 0x208u | ZX_EXCP_SYNTH)
// A process is starting.
// This exception is sent to job debuggers only
-// (ZX_EXCEPTION_PORT_TYPE_JOB_DEBUGGER).
-// The initial thread is paused until it is resumed by the debugger with
-// zx_task_resume_from_exception.
-#define ZX_EXCP_PROCESS_STARTING ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH | 3)
+// (ZX_EXCEPTION_CHANNEL_TYPE_JOB_DEBUGGER).
+// The thread that generates this exception is paused until it the debugger
+// handles the exception.
+#define ZX_EXCP_PROCESS_STARTING ((uint32_t) 0x308u | ZX_EXCP_SYNTH)
typedef uint32_t zx_excp_type_t;
-// Assuming |excp| is an exception type, return non-zero if it is an
-// architectural exception.
-#define ZX_EXCP_IS_ARCH(excp) \
- (((excp) & (ZX_PKT_TYPE_EXCEPTION(ZX_EXCP_SYNTH) & ~ZX_PKT_TYPE_MASK)) == 0)
+// Assuming |excp| is an exception type, the following returns true if the
+// type is architectural.
+#define ZX_EXCP_IS_ARCH(excp) (((excp) & ZX_EXCP_SYNTH) == 0)
typedef struct zx_x86_64_exc_data {
uint64_t vector;
@@ -80,6 +76,7 @@
typedef struct zx_arm64_exc_data {
uint32_t esr;
+ uint8_t padding1[4];
uint64_t far;
} zx_arm64_exc_data_t;
@@ -90,7 +87,10 @@
struct {
union {
zx_x86_64_exc_data_t x86_64;
- zx_arm64_exc_data_t arm_64;
+ struct {
+ zx_arm64_exc_data_t arm_64;
+ uint8_t padding1[8];
+ };
} u;
} arch;
} zx_exception_context_t;
@@ -110,26 +110,27 @@
zx_exception_context_t context;
} zx_exception_report_t;
-// Options for zx_task_resume_from_exception()
-#define ZX_RESUME_TRY_NEXT ((uint32_t)2)
-// Indicates that instead of resuming from the faulting instruction we instead
-// let the next exception handler in the search order, if any, process the
-// exception. If there are no more then the entire process is killed.
+// Basic info sent along with the handle over an exception channel.
+typedef struct zx_exception_info {
+ zx_koid_t pid;
+ zx_koid_t tid;
+ zx_excp_type_t type;
+ uint8_t padding1[4];
+} zx_exception_info_t;
-// Options for zx_task_bind_exception_port.
-#define ZX_EXCEPTION_PORT_DEBUGGER ((uint32_t)1)
-// When binding an exception port to a process, set the process's debugger
-// exception port.
+// Options for zx_create_exception_channel.
+// When creating an exception channel, use the task's debug channel.
+#define ZX_EXCEPTION_CHANNEL_DEBUGGER ((uint32_t)1)
-// The type of exception port a thread may be waiting for a response from.
-// These values are reported in zx_info_thread_t.wait_exception_port_type.
-#define ZX_EXCEPTION_PORT_TYPE_NONE ((uint32_t)0u)
-#define ZX_EXCEPTION_PORT_TYPE_DEBUGGER ((uint32_t)1u)
-#define ZX_EXCEPTION_PORT_TYPE_THREAD ((uint32_t)2u)
-#define ZX_EXCEPTION_PORT_TYPE_PROCESS ((uint32_t)3u)
-#define ZX_EXCEPTION_PORT_TYPE_JOB ((uint32_t)4u)
-#define ZX_EXCEPTION_PORT_TYPE_JOB_DEBUGGER ((uint32_t)5u)
+// The type of exception handler a thread may be waiting for a response from.
+// These values are reported in zx_info_thread_t.wait_exception_channel_type.
+#define ZX_EXCEPTION_CHANNEL_TYPE_NONE ((uint32_t)0u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_DEBUGGER ((uint32_t)1u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_THREAD ((uint32_t)2u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_PROCESS ((uint32_t)3u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_JOB ((uint32_t)4u)
+#define ZX_EXCEPTION_CHANNEL_TYPE_JOB_DEBUGGER ((uint32_t)5u)
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_EXCEPTION_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_EXCEPTION_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/hypervisor.h b/arch/x64/sysroot/include/zircon/syscalls/hypervisor.h
index a62de92..f574d4e 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/hypervisor.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/hypervisor.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
+#define SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
#include <assert.h>
@@ -27,41 +28,51 @@
// Structure to read and write VCPU state.
typedef struct zx_vcpu_state {
#if __aarch64__
- uint64_t x[31];
- uint64_t sp;
- // Contains only the user-controllable upper 4-bits (NZCV).
- uint32_t cpsr;
+ uint64_t x[31];
+ uint64_t sp;
+ // Contains only the user-controllable upper 4-bits (NZCV).
+ uint32_t cpsr;
+ uint8_t padding1[4];
#elif __x86_64__
- uint64_t rax;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rbx;
- uint64_t rsp;
- uint64_t rbp;
- uint64_t rsi;
- uint64_t rdi;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- // Contains only the user-controllable lower 32-bits.
- uint64_t rflags;
+ uint64_t rax;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rbx;
+ uint64_t rsp;
+ uint64_t rbp;
+ uint64_t rsi;
+ uint64_t rdi;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ // Contains only the user-controllable lower 32-bits.
+ uint64_t rflags;
#endif
} zx_vcpu_state_t;
// Structure to read and write VCPU state for IO ports.
typedef struct zx_vcpu_io {
- uint8_t access_size;
- union {
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
- uint8_t data[4];
+ uint8_t access_size;
+ uint8_t padding1[3];
+ union {
+ struct {
+ uint8_t u8;
+ uint8_t padding2[3];
};
+ struct {
+ uint16_t u16;
+ uint8_t padding3[2];
+ };
+ uint32_t u32;
+ uint8_t data[4];
+ };
} zx_vcpu_io_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_HYPERVISOR_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc b/arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc
new file mode 100644
index 0000000..63510b9
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc
@@ -0,0 +1,1090 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// WARNING: THIS FILE IS MACHINE GENERATED BY //tools/kazoo. DO NOT EDIT.
+
+#ifndef _ZX_SYSCALL_DECL
+#error "<zircon/syscalls.h> is the public API header"
+#endif
+
+_ZX_SYSCALL_DECL(bti_create, zx_status_t, /* no attributes */, 4,
+ (iommu, options, bti_id, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t iommu,
+ uint32_t options,
+ uint64_t bti_id,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(bti_pin, zx_status_t, /* no attributes */, 8,
+ (handle, options, vmo, offset, size, addrs, num_addrs, pmt), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint64_t offset,
+ uint64_t size,
+ zx_paddr_t* addrs,
+ size_t num_addrs,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* pmt))
+
+_ZX_SYSCALL_DECL(bti_release_quarantine, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(cache_flush, zx_status_t, /* no attributes */, 3,
+ (addr, size, options), (
+ const void* addr,
+ size_t size,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(channel_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(channel_read, zx_status_t, /* no attributes */, 8,
+ (handle, options, bytes, handles, num_bytes, num_handles, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("FuchsiaUnchecked")) zx_handle_t handle,
+ uint32_t options,
+ void* bytes,
+ _ZX_SYSCALL_ANNO(acquire_handle("FuchsiaUnchecked")) zx_handle_t* handles,
+ uint32_t num_bytes,
+ uint32_t num_handles,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_read_etc, zx_status_t, /* no attributes */, 8,
+ (handle, options, bytes, handles, num_bytes, num_handles, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* bytes,
+ zx_handle_info_t* handles,
+ uint32_t num_bytes,
+ uint32_t num_handles,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_write, zx_status_t, /* no attributes */, 6,
+ (handle, options, bytes, num_bytes, handles, num_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* bytes,
+ uint32_t num_bytes,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) const zx_handle_t* handles,
+ uint32_t num_handles))
+
+_ZX_SYSCALL_DECL(channel_write_etc, zx_status_t, /* no attributes */, 6,
+ (handle, options, bytes, num_bytes, handles, num_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* bytes,
+ uint32_t num_bytes,
+ zx_handle_disposition_t* handles,
+ uint32_t num_handles))
+
+_ZX_SYSCALL_DECL(channel_call, zx_status_t, /* no attributes */, 6,
+ (handle, options, deadline, args, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t deadline,
+ const zx_channel_call_args_t* args,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(channel_call_etc, zx_status_t, /* no attributes */, 6,
+ (handle, options, deadline, args, actual_bytes, actual_handles), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t deadline,
+ zx_channel_call_etc_args_t* args,
+ uint32_t* actual_bytes,
+ uint32_t* actual_handles))
+
+_ZX_SYSCALL_DECL(clock_get, zx_status_t, /* no attributes */, 2,
+ (clock_id, out), (
+ zx_clock_t clock_id,
+ zx_time_t* out))
+
+_ZX_SYSCALL_DECL(clock_get_monotonic, zx_time_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(clock_adjust, zx_status_t, /* no attributes */, 3,
+ (handle, clock_id, offset), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_clock_t clock_id,
+ int64_t offset))
+
+_ZX_SYSCALL_DECL(clock_create, zx_status_t, /* no attributes */, 3,
+ (options, args, out), (
+ uint64_t options,
+ const void* args,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(clock_read, zx_status_t, /* no attributes */, 2,
+ (handle, now), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t* now))
+
+_ZX_SYSCALL_DECL(clock_get_details, zx_status_t, /* no attributes */, 3,
+ (handle, options, details), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t options,
+ void* details))
+
+_ZX_SYSCALL_DECL(clock_update, zx_status_t, /* no attributes */, 3,
+ (handle, options, args), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t options,
+ const void* args))
+
+_ZX_SYSCALL_DECL(cprng_draw, void, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(cprng_add_entropy, zx_status_t, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debug_read, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ char* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(debug_write, zx_status_t, /* no attributes */, 2,
+ (buffer, buffer_size), (
+ const char* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debug_send_command, zx_status_t, /* no attributes */, 3,
+ (resource, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ const char* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debuglog_create, zx_status_t, /* no attributes */, 3,
+ (resource, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(debuglog_write, zx_status_t, /* no attributes */, 4,
+ (handle, options, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(debuglog_read, zx_status_t, /* no attributes */, 4,
+ (handle, options, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(event_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(eventpair_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(exception_get_thread, zx_status_t, /* no attributes */, 2,
+ (handle, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(exception_get_process, zx_status_t, /* no attributes */, 2,
+ (handle, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(fifo_create, zx_status_t, /* no attributes */, 5,
+ (elem_count, elem_size, options, out0, out1), (
+ size_t elem_count,
+ size_t elem_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(fifo_read, zx_status_t, /* no attributes */, 5,
+ (handle, elem_size, data, data_size, actual_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ size_t elem_size,
+ void* data,
+ size_t data_size,
+ size_t* actual_count))
+
+_ZX_SYSCALL_DECL(fifo_write, zx_status_t, /* no attributes */, 5,
+ (handle, elem_size, data, count, actual_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ size_t elem_size,
+ const void* data,
+ size_t count,
+ size_t* actual_count))
+
+_ZX_SYSCALL_DECL(framebuffer_get_info, zx_status_t, /* no attributes */, 5,
+ (resource, format, width, height, stride), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t* format,
+ uint32_t* width,
+ uint32_t* height,
+ uint32_t* stride))
+
+_ZX_SYSCALL_DECL(framebuffer_set_range, zx_status_t, /* no attributes */, 7,
+ (resource, vmo, len, format, width, height, stride), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint32_t len,
+ uint32_t format,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride))
+
+_ZX_SYSCALL_DECL(futex_wait, zx_status_t, /* no attributes */, 4,
+ (value_ptr, current_value, new_futex_owner, deadline), (
+ const zx_futex_t* value_ptr,
+ zx_futex_t current_value,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_futex_owner,
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(futex_wake, zx_status_t, /* no attributes */, 2,
+ (value_ptr, wake_count), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count))
+
+_ZX_SYSCALL_DECL(futex_requeue, zx_status_t, /* no attributes */, 6,
+ (value_ptr, wake_count, current_value, requeue_ptr, requeue_count, new_requeue_owner), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count,
+ zx_futex_t current_value,
+ const zx_futex_t* requeue_ptr,
+ uint32_t requeue_count,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_requeue_owner))
+
+_ZX_SYSCALL_DECL(futex_wake_single_owner, zx_status_t, /* no attributes */, 1,
+ (value_ptr), (
+ const zx_futex_t* value_ptr))
+
+_ZX_SYSCALL_DECL(futex_requeue_single_owner, zx_status_t, /* no attributes */, 5,
+ (value_ptr, current_value, requeue_ptr, requeue_count, new_requeue_owner), (
+ const zx_futex_t* value_ptr,
+ zx_futex_t current_value,
+ const zx_futex_t* requeue_ptr,
+ uint32_t requeue_count,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t new_requeue_owner))
+
+_ZX_SYSCALL_DECL(futex_get_owner, zx_status_t, /* no attributes */, 2,
+ (value_ptr, koid), (
+ const zx_futex_t* value_ptr,
+ zx_koid_t* koid))
+
+_ZX_SYSCALL_DECL(guest_create, zx_status_t, /* no attributes */, 4,
+ (resource, options, guest_handle, vmar_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* guest_handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* vmar_handle))
+
+_ZX_SYSCALL_DECL(guest_set_trap, zx_status_t, /* no attributes */, 6,
+ (handle, kind, addr, size, port_handle, key), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ zx_vaddr_t addr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port_handle,
+ uint64_t key))
+
+_ZX_SYSCALL_DECL(handle_close, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(handle_close_many, zx_status_t, /* no attributes */, 2,
+ (handles, num_handles), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) const zx_handle_t* handles,
+ size_t num_handles))
+
+_ZX_SYSCALL_DECL(handle_duplicate, zx_status_t, /* no attributes */, 3,
+ (handle, rights, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(handle_replace, zx_status_t, /* no attributes */, 3,
+ (handle, rights, out), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(interrupt_create, zx_status_t, /* no attributes */, 4,
+ (src_obj, src_num, options, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t src_obj,
+ uint32_t src_num,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(interrupt_bind, zx_status_t, /* no attributes */, 4,
+ (handle, port_handle, key, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port_handle,
+ uint64_t key,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(interrupt_wait, zx_status_t, /* no attributes */, 2,
+ (handle, out_timestamp), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t* out_timestamp))
+
+_ZX_SYSCALL_DECL(interrupt_destroy, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(interrupt_ack, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(interrupt_trigger, zx_status_t, /* no attributes */, 3,
+ (handle, options, timestamp), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_time_t timestamp))
+
+_ZX_SYSCALL_DECL(interrupt_bind_vcpu, zx_status_t, /* no attributes */, 3,
+ (handle, vcpu, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vcpu,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(iommu_create, zx_status_t, /* no attributes */, 5,
+ (resource, type, desc, desc_size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t type,
+ const void* desc,
+ size_t desc_size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(ioports_request, zx_status_t, /* no attributes */, 3,
+ (resource, io_addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint16_t io_addr,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(ioports_release, zx_status_t, /* no attributes */, 3,
+ (resource, io_addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint16_t io_addr,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(job_create, zx_status_t, /* no attributes */, 3,
+ (parent_job, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_job,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(job_set_policy, zx_status_t, /* no attributes */, 5,
+ (handle, options, topic, policy, policy_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint32_t topic,
+ const void* policy,
+ uint32_t policy_size))
+
+_ZX_SYSCALL_DECL(job_set_critical, zx_status_t, /* no attributes */, 3,
+ (job, options, process), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t job,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t process))
+
+_ZX_SYSCALL_DECL(ktrace_read, zx_status_t, /* no attributes */, 5,
+ (handle, data, offset, data_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ void* data,
+ uint32_t offset,
+ size_t data_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(ktrace_control, zx_status_t, /* no attributes */, 4,
+ (handle, action, options, ptr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t action,
+ uint32_t options,
+ void* ptr))
+
+_ZX_SYSCALL_DECL(ktrace_write, zx_status_t, /* no attributes */, 4,
+ (handle, id, arg0, arg1), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t id,
+ uint32_t arg0,
+ uint32_t arg1))
+
+_ZX_SYSCALL_DECL(nanosleep, zx_status_t, /* no attributes */, 1,
+ (deadline), (
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(ticks_get, zx_ticks_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(ticks_per_second, zx_ticks_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(deadline_after, zx_time_t, /* no attributes */, 1,
+ (nanoseconds), (
+ zx_duration_t nanoseconds))
+
+_ZX_SYSCALL_DECL(vmar_unmap_handle_close_thread_exit, zx_status_t, /* no attributes */, 4,
+ (vmar_handle, addr, size, close_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmar_handle,
+ zx_vaddr_t addr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t close_handle))
+
+_ZX_SYSCALL_DECL(futex_wake_handle_close_thread_exit, void, __NO_RETURN, 4,
+ (value_ptr, wake_count, new_value, close_handle), (
+ const zx_futex_t* value_ptr,
+ uint32_t wake_count,
+ int32_t new_value,
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t close_handle))
+
+_ZX_SYSCALL_DECL(msi_allocate, zx_status_t, /* no attributes */, 3,
+ (handle, count, out_allocation), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t count,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_allocation))
+
+_ZX_SYSCALL_DECL(msi_create, zx_status_t, /* no attributes */, 6,
+ (handle, options, msi_id, vmo, vmo_offset, out_interrupt), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint32_t msi_id,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ size_t vmo_offset,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_interrupt))
+
+_ZX_SYSCALL_DECL(mtrace_control, zx_status_t, /* no attributes */, 6,
+ (handle, kind, action, options, ptr, ptr_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ uint32_t action,
+ uint32_t options,
+ void* ptr,
+ size_t ptr_size))
+
+_ZX_SYSCALL_DECL(object_wait_one, zx_status_t, /* no attributes */, 4,
+ (handle, signals, deadline, observed), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_signals_t signals,
+ zx_time_t deadline,
+ zx_signals_t* observed))
+
+_ZX_SYSCALL_DECL(object_wait_many, zx_status_t, /* no attributes */, 3,
+ (items, num_items, deadline), (
+ zx_wait_item_t* items,
+ size_t num_items,
+ zx_time_t deadline))
+
+_ZX_SYSCALL_DECL(object_wait_async, zx_status_t, /* no attributes */, 5,
+ (handle, port, key, signals, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port,
+ uint64_t key,
+ zx_signals_t signals,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(object_signal, zx_status_t, /* no attributes */, 3,
+ (handle, clear_mask, set_mask), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t clear_mask,
+ uint32_t set_mask))
+
+_ZX_SYSCALL_DECL(object_signal_peer, zx_status_t, /* no attributes */, 3,
+ (handle, clear_mask, set_mask), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t clear_mask,
+ uint32_t set_mask))
+
+_ZX_SYSCALL_DECL(object_get_property, zx_status_t, /* no attributes */, 4,
+ (handle, property, value, value_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t property,
+ void* value,
+ size_t value_size))
+
+_ZX_SYSCALL_DECL(object_set_property, zx_status_t, /* no attributes */, 4,
+ (handle, property, value, value_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t property,
+ const void* value,
+ size_t value_size))
+
+_ZX_SYSCALL_DECL(object_get_info, zx_status_t, /* no attributes */, 6,
+ (handle, topic, buffer, buffer_size, actual, avail), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t topic,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual,
+ size_t* avail))
+
+_ZX_SYSCALL_DECL(object_get_child, zx_status_t, /* no attributes */, 4,
+ (handle, koid, rights, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t koid,
+ zx_rights_t rights,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(object_set_profile, zx_status_t, /* no attributes */, 3,
+ (handle, profile, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t profile,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(pager_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(pager_create_vmo, zx_status_t, /* no attributes */, 6,
+ (pager, options, port, key, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t port,
+ uint64_t key,
+ uint64_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(pager_detach_vmo, zx_status_t, /* no attributes */, 2,
+ (pager, vmo), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo))
+
+_ZX_SYSCALL_DECL(pager_supply_pages, zx_status_t, /* no attributes */, 6,
+ (pager, pager_vmo, offset, length, aux_vmo, aux_offset), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager_vmo,
+ uint64_t offset,
+ uint64_t length,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t aux_vmo,
+ uint64_t aux_offset))
+
+_ZX_SYSCALL_DECL(pager_op_range, zx_status_t, /* no attributes */, 6,
+ (pager, op, pager_vmo, offset, length, data), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager,
+ uint32_t op,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t pager_vmo,
+ uint64_t offset,
+ uint64_t length,
+ uint64_t data))
+
+_ZX_SYSCALL_DECL(pc_firmware_tables, zx_status_t, /* no attributes */, 3,
+ (handle, acpi_rsdp, smbios), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_paddr_t* acpi_rsdp,
+ zx_paddr_t* smbios))
+
+_ZX_SYSCALL_DECL(pci_get_nth_device, zx_status_t, /* no attributes */, 4,
+ (handle, index, out_info, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t index,
+ zx_pcie_device_info_t* out_info,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_enable_bus_master, zx_status_t, /* no attributes */, 2,
+ (handle, enable), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t enable))
+
+_ZX_SYSCALL_DECL(pci_reset_device, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(pci_config_read, zx_status_t, /* no attributes */, 4,
+ (handle, offset, width, out_val), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint16_t offset,
+ size_t width,
+ uint32_t* out_val))
+
+_ZX_SYSCALL_DECL(pci_config_write, zx_status_t, /* no attributes */, 4,
+ (handle, offset, width, val), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint16_t offset,
+ size_t width,
+ uint32_t val))
+
+_ZX_SYSCALL_DECL(pci_cfg_pio_rw, zx_status_t, /* no attributes */, 8,
+ (handle, bus, dev, func, offset, val, width, write), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint8_t bus,
+ uint8_t dev,
+ uint8_t func,
+ uint8_t offset,
+ uint32_t* val,
+ size_t width,
+ uint32_t write))
+
+_ZX_SYSCALL_DECL(pci_get_bar, zx_status_t, /* no attributes */, 4,
+ (handle, bar_num, out_bar, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t bar_num,
+ zx_pci_bar_t* out_bar,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_map_interrupt, zx_status_t, /* no attributes */, 3,
+ (handle, which_irq, out_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ int32_t which_irq,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_handle))
+
+_ZX_SYSCALL_DECL(pci_query_irq_mode, zx_status_t, /* no attributes */, 3,
+ (handle, mode, out_max_irqs), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mode,
+ uint32_t* out_max_irqs))
+
+_ZX_SYSCALL_DECL(pci_set_irq_mode, zx_status_t, /* no attributes */, 3,
+ (handle, mode, requested_irq_count), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mode,
+ uint32_t requested_irq_count))
+
+_ZX_SYSCALL_DECL(pci_init, zx_status_t, /* no attributes */, 3,
+ (handle, init_buf, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_pci_init_arg_t* init_buf,
+ uint32_t len))
+
+_ZX_SYSCALL_DECL(pci_add_subtract_io_range, zx_status_t, /* no attributes */, 5,
+ (handle, mmio, base, len, add), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t mmio,
+ uint64_t base,
+ uint64_t len,
+ uint32_t add))
+
+_ZX_SYSCALL_DECL(pmt_unpin, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(port_create, zx_status_t, /* no attributes */, 2,
+ (options, out), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(port_queue, zx_status_t, /* no attributes */, 2,
+ (handle, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(port_wait, zx_status_t, /* no attributes */, 3,
+ (handle, deadline, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t deadline,
+ zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(port_cancel, zx_status_t, /* no attributes */, 3,
+ (handle, source, key), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t source,
+ uint64_t key))
+
+_ZX_SYSCALL_DECL(process_exit, void, __NO_RETURN, 1,
+ (retcode), (
+ int64_t retcode))
+
+_ZX_SYSCALL_DECL(process_create, zx_status_t, /* no attributes */, 6,
+ (job, name, name_size, options, proc_handle, vmar_handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t job,
+ const char* name,
+ size_t name_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* proc_handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* vmar_handle))
+
+_ZX_SYSCALL_DECL(process_start, zx_status_t, /* no attributes */, 6,
+ (handle, thread, entry, stack, arg1, arg2), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t thread,
+ zx_vaddr_t entry,
+ zx_vaddr_t stack,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t arg1,
+ uintptr_t arg2))
+
+_ZX_SYSCALL_DECL(process_read_memory, zx_status_t, /* no attributes */, 5,
+ (handle, vaddr, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t vaddr,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(process_write_memory, zx_status_t, /* no attributes */, 5,
+ (handle, vaddr, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t vaddr,
+ const void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(profile_create, zx_status_t, /* no attributes */, 4,
+ (root_job, options, profile, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t root_job,
+ uint32_t options,
+ const zx_profile_info_t* profile,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(resource_create, zx_status_t, /* no attributes */, 7,
+ (parent_rsrc, options, base, size, name, name_size, resource_out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_rsrc,
+ uint32_t options,
+ uint64_t base,
+ size_t size,
+ const char* name,
+ size_t name_size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* resource_out))
+
+_ZX_SYSCALL_DECL(smc_call, zx_status_t, /* no attributes */, 3,
+ (handle, parameters, out_smc_result), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const zx_smc_parameters_t* parameters,
+ zx_smc_result_t* out_smc_result))
+
+_ZX_SYSCALL_DECL(socket_create, zx_status_t, /* no attributes */, 3,
+ (options, out0, out1), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out0,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out1))
+
+_ZX_SYSCALL_DECL(socket_write, zx_status_t, /* no attributes */, 5,
+ (handle, options, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(socket_read, zx_status_t, /* no attributes */, 5,
+ (handle, options, buffer, buffer_size, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ void* buffer,
+ size_t buffer_size,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(socket_shutdown, zx_status_t, /* no attributes */, 2,
+ (handle, options), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options))
+
+_ZX_SYSCALL_DECL(stream_create, zx_status_t, /* no attributes */, 4,
+ (options, vmo, seek, out_stream), (
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ zx_off_t seek,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out_stream))
+
+_ZX_SYSCALL_DECL(stream_writev, zx_status_t, /* no attributes */, 5,
+ (handle, options, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ const zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_writev_at, zx_status_t, /* no attributes */, 6,
+ (handle, options, offset, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_off_t offset,
+ const zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_readv, zx_status_t, /* no attributes */, 5,
+ (handle, options, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_readv_at, zx_status_t, /* no attributes */, 6,
+ (handle, options, offset, vector, num_vector, actual), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ zx_off_t offset,
+ zx_iovec_t* vector,
+ size_t num_vector,
+ size_t* actual))
+
+_ZX_SYSCALL_DECL(stream_seek, zx_status_t, /* no attributes */, 4,
+ (handle, whence, offset, out_seek), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_stream_seek_origin_t whence,
+ int64_t offset,
+ zx_off_t* out_seek))
+
+_ZX_SYSCALL_DECL(system_get_dcache_line_size, uint32_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_num_cpus, uint32_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_version_string, zx_string_view_t, __CONST, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_physmem, uint64_t, /* no attributes */, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(system_get_features, zx_status_t, /* no attributes */, 2,
+ (kind, features), (
+ uint32_t kind,
+ uint32_t* features))
+
+_ZX_SYSCALL_DECL(system_get_event, zx_status_t, /* no attributes */, 3,
+ (root_job, kind, event), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t root_job,
+ uint32_t kind,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* event))
+
+_ZX_SYSCALL_DECL(system_mexec, zx_status_t, /* no attributes */, 3,
+ (resource, kernel_vmo, bootimage_vmo), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t kernel_vmo,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t bootimage_vmo))
+
+_ZX_SYSCALL_DECL(system_mexec_payload_get, zx_status_t, /* no attributes */, 3,
+ (resource, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(system_powerctl, zx_status_t, /* no attributes */, 3,
+ (resource, cmd, arg), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ uint32_t cmd,
+ const zx_system_powerctl_arg_t* arg))
+
+_ZX_SYSCALL_DECL(task_suspend, zx_status_t, /* no attributes */, 2,
+ (handle, token), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* token))
+
+_ZX_SYSCALL_DECL(task_suspend_token, zx_status_t, /* no attributes */, 2,
+ (handle, token), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* token))
+
+_ZX_SYSCALL_DECL(task_create_exception_channel, zx_status_t, /* no attributes */, 3,
+ (handle, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(task_kill, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(thread_exit, void, __NO_RETURN, 0,
+ (), (void))
+
+_ZX_SYSCALL_DECL(thread_create, zx_status_t, /* no attributes */, 5,
+ (process, name, name_size, options, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t process,
+ const char* name,
+ size_t name_size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(thread_start, zx_status_t, /* no attributes */, 5,
+ (handle, thread_entry, stack, arg1, arg2), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t thread_entry,
+ zx_vaddr_t stack,
+ uintptr_t arg1,
+ uintptr_t arg2))
+
+_ZX_SYSCALL_DECL(thread_read_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(thread_write_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(timer_create, zx_status_t, /* no attributes */, 3,
+ (options, clock_id, out), (
+ uint32_t options,
+ zx_clock_t clock_id,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(timer_set, zx_status_t, /* no attributes */, 3,
+ (handle, deadline, slack), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_time_t deadline,
+ zx_duration_t slack))
+
+_ZX_SYSCALL_DECL(timer_cancel, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(vcpu_create, zx_status_t, /* no attributes */, 4,
+ (guest, options, entry, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t guest,
+ uint32_t options,
+ zx_vaddr_t entry,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vcpu_resume, zx_status_t, /* no attributes */, 2,
+ (handle, packet), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_port_packet_t* packet))
+
+_ZX_SYSCALL_DECL(vcpu_interrupt, zx_status_t, /* no attributes */, 2,
+ (handle, vector), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t vector))
+
+_ZX_SYSCALL_DECL(vcpu_read_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vcpu_write_state, zx_status_t, /* no attributes */, 4,
+ (handle, kind, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t kind,
+ const void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmar_allocate, zx_status_t, /* no attributes */, 6,
+ (parent_vmar, options, offset, size, child_vmar, child_addr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t parent_vmar,
+ zx_vm_option_t options,
+ size_t offset,
+ size_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* child_vmar,
+ zx_vaddr_t* child_addr))
+
+_ZX_SYSCALL_DECL(vmar_destroy, zx_status_t, /* no attributes */, 1,
+ (handle), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle))
+
+_ZX_SYSCALL_DECL(vmar_map, zx_status_t, /* no attributes */, 7,
+ (handle, options, vmar_offset, vmo, vmo_offset, len, mapped_addr), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vm_option_t options,
+ size_t vmar_offset,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmo,
+ uint64_t vmo_offset,
+ size_t len,
+ zx_vaddr_t* mapped_addr))
+
+_ZX_SYSCALL_DECL(vmar_unmap, zx_status_t, /* no attributes */, 3,
+ (handle, addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vaddr_t addr,
+ size_t len))
+
+_ZX_SYSCALL_DECL(vmar_protect, zx_status_t, /* no attributes */, 4,
+ (handle, options, addr, len), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ zx_vm_option_t options,
+ zx_vaddr_t addr,
+ size_t len))
+
+_ZX_SYSCALL_DECL(vmar_op_range, zx_status_t, /* no attributes */, 6,
+ (handle, op, address, size, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t op,
+ zx_vaddr_t address,
+ size_t size,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_create, zx_status_t, /* no attributes */, 3,
+ (size, options, out), (
+ uint64_t size,
+ uint32_t options,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_read, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, offset, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ void* buffer,
+ uint64_t offset,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_write, zx_status_t, /* no attributes */, 4,
+ (handle, buffer, offset, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ const void* buffer,
+ uint64_t offset,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_get_size, zx_status_t, /* no attributes */, 2,
+ (handle, size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t* size))
+
+_ZX_SYSCALL_DECL(vmo_set_size, zx_status_t, /* no attributes */, 2,
+ (handle, size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint64_t size))
+
+_ZX_SYSCALL_DECL(vmo_op_range, zx_status_t, /* no attributes */, 6,
+ (handle, op, offset, size, buffer, buffer_size), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t op,
+ uint64_t offset,
+ uint64_t size,
+ void* buffer,
+ size_t buffer_size))
+
+_ZX_SYSCALL_DECL(vmo_create_child, zx_status_t, /* no attributes */, 5,
+ (handle, options, offset, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t options,
+ uint64_t offset,
+ uint64_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_set_cache_policy, zx_status_t, /* no attributes */, 2,
+ (handle, cache_policy), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t handle,
+ uint32_t cache_policy))
+
+_ZX_SYSCALL_DECL(vmo_replace_as_executable, zx_status_t, /* no attributes */, 3,
+ (handle, vmex, out), (
+ _ZX_SYSCALL_ANNO(release_handle("Fuchsia")) zx_handle_t handle,
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t vmex,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_create_contiguous, zx_status_t, /* no attributes */, 4,
+ (bti, size, alignment_log2, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t bti,
+ size_t size,
+ uint32_t alignment_log2,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
+_ZX_SYSCALL_DECL(vmo_create_physical, zx_status_t, /* no attributes */, 4,
+ (resource, paddr, size, out), (
+ _ZX_SYSCALL_ANNO(use_handle("Fuchsia")) zx_handle_t resource,
+ zx_paddr_t paddr,
+ size_t size,
+ _ZX_SYSCALL_ANNO(acquire_handle("Fuchsia")) zx_handle_t* out))
+
diff --git a/arch/x64/sysroot/include/zircon/syscalls/iommu.h b/arch/x64/sysroot/include/zircon/syscalls/iommu.h
index e567175..414320d 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/iommu.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/iommu.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
+#define SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
#include <assert.h>
-#include <zircon/compiler.h>
#include <stdbool.h>
#include <stdint.h>
+#include <zircon/compiler.h>
__BEGIN_CDECLS
@@ -19,77 +20,78 @@
// Data structures for creating a dummy IOMMU instance
typedef struct zx_iommu_desc_dummy {
- uint8_t reserved;
+ uint8_t reserved;
} zx_iommu_desc_dummy_t;
-
// Data structures for creating an Intel IOMMU instance
// This scope represents a single PCI endpoint device
#define ZX_IOMMU_INTEL_SCOPE_ENDPOINT 0
// This scope represents a PCI-PCI bridge. The bridge and all of its downstream
// devices will be included in this scope.
-#define ZX_IOMMU_INTEL_SCOPE_BRIDGE 1
+#define ZX_IOMMU_INTEL_SCOPE_BRIDGE 1
// TODO(teisenbe): Investigate FIDL for this. Multiple embedded lists seems
// right up its alley.
typedef struct zx_iommu_desc_intel_scope {
- uint8_t type;
- // The bus number of the first bus decoded by the host bridge this scope is attached to.
- uint8_t start_bus;
- // Number of bridges (including the host bridge) between host bridge and the
- // device.
- uint8_t num_hops;
- // The device number and function numbers of the bridges along the way,
- // ending with the device itself.
- // |dev_func[0]| is the address on |start_bus| of the first bridge in the
- // path (excluding the host bridge). |dev_func[num_hops-1]| is the address
- // of the the device itself.
- uint8_t dev_func[5];
+ uint8_t type;
+ // The bus number of the first bus decoded by the host bridge this scope is attached to.
+ uint8_t start_bus;
+ // Number of bridges (including the host bridge) between host bridge and the
+ // device.
+ uint8_t num_hops;
+ // The device number and function numbers of the bridges along the way,
+ // ending with the device itself.
+ // |dev_func[0]| is the address on |start_bus| of the first bridge in the
+ // path (excluding the host bridge). |dev_func[num_hops-1]| is the address
+ // of the device itself.
+ uint8_t dev_func[5];
} zx_iommu_desc_intel_scope_t;
typedef struct zx_iommu_desc_intel_reserved_memory {
- uint64_t base_addr; // Physical address of the base of reserved memory.
- uint64_t len; // Number of bytes of reserved memory.
+ uint64_t base_addr; // Physical address of the base of reserved memory.
+ uint64_t len; // Number of bytes of reserved memory.
- // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
- uint8_t scope_bytes;
+ // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
+ uint8_t scope_bytes;
- uint8_t _reserved[7]; // Padding
+ uint8_t _reserved[7]; // Padding
- // This is a list of all devices that need access to this memory range.
- //
- // zx_iommu_desc_intel_scope_t scopes[num_scopes];
+ // This is a list of all devices that need access to this memory range.
+ //
+ // zx_iommu_desc_intel_scope_t scopes[num_scopes];
} zx_iommu_desc_intel_reserved_memory_t;
typedef struct zx_iommu_desc_intel {
- uint64_t register_base; // Physical address of registers
- uint16_t pci_segment; // The PCI segment associated with this IOMMU
+ uint64_t register_base; // Physical address of registers
+ uint16_t pci_segment; // The PCI segment associated with this IOMMU
- // If true, this IOMMU has all PCI devices in its segment under its scope.
- // In this case, the list of scopes acts as a blacklist.
- bool whole_segment;
+ // If false, scopes[] represents all PCI devices in this segment managed by this IOMMU.
+ // If true, scopes[] represents all PCI devices in this segment *not* managed by this IOMMU.
+ bool whole_segment;
- // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
- uint8_t scope_bytes;
+ // The number of bytes of zx_iommu_desc_intel_scope_t's that follow this descriptor.
+ uint8_t scope_bytes;
- // The number of bytes of zx_iommu_desc_intel_reserved_memory_t's that follow the scope
- // list.
- uint16_t reserved_memory_bytes;
+ // The number of bytes of zx_iommu_desc_intel_reserved_memory_t's that follow the scope
+ // list.
+ uint16_t reserved_memory_bytes;
- uint8_t _reserved[2]; // Padding
+ uint8_t _reserved[2]; // Padding
- // If |whole_segment| is false, this is a list of all devices managed by
- // this IOMMU. If |whole_segment| is true, this is a list of all devices on
- // this segment *not* managed by this IOMMU. It has a total length in bytes of
- // |scope_bytes|.
- //
- // zx_iommu_desc_intel_scope_t scopes[];
+ // If |whole_segment| is false, this is a list of all devices managed by
+ // this IOMMU. If |whole_segment| is true, this is a list of all devices on
+ // this segment *not* managed by this IOMMU. It has a total length in bytes of
+ // |scope_bytes|.
+ //
+ // zx_iommu_desc_intel_scope_t scopes[];
- // A list of all BIOS-reserved memory regions this IOMMU needs to translate.
- // It has a total length in bytes of |reserved_memory_bytes|.
- //
- // zx_iommu_desc_intel_reserved_memory_t reserved_mem[];
+ // A list of all BIOS-reserved memory regions this IOMMU needs to translate.
+ // It has a total length in bytes of |reserved_memory_bytes|.
+ //
+ // zx_iommu_desc_intel_reserved_memory_t reserved_mem[];
} zx_iommu_desc_intel_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_IOMMU_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/log.h b/arch/x64/sysroot/include/zircon/syscalls/log.h
index e89d9c5..c6af1d9 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/log.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/log.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_LOG_H_
+#define SYSROOT_ZIRCON_SYSCALLS_LOG_H_
#include <zircon/types.h>
@@ -10,13 +11,14 @@
// Defines and structures for zx_log_*()
typedef struct zx_log_record {
- uint32_t reserved;
- uint16_t datalen;
- uint16_t flags;
- zx_time_t timestamp;
- uint64_t pid;
- uint64_t tid;
- char data[];
+ uint32_t rollout;
+ uint16_t datalen;
+ uint8_t severity;
+ uint8_t flags;
+ zx_time_t timestamp;
+ uint64_t pid;
+ uint64_t tid;
+ char data[];
} zx_log_record_t;
// ask clang format not to mess up the indentation:
@@ -24,32 +26,26 @@
#define ZX_LOG_RECORD_MAX 256
-// Common Log Levels
-#define ZX_LOG_ERROR (0x0001)
-#define ZX_LOG_WARN (0x0002)
-#define ZX_LOG_INFO (0x0004)
-
-// Verbose log levels
-#define ZX_LOG_TRACE (0x0010)
-#define ZX_LOG_SPEW (0x0020)
-
-// Custom Log Levels
-#define ZX_LOG_DEBUG1 (0x0100)
-#define ZX_LOG_DEBUG2 (0x0200)
-#define ZX_LOG_DEBUG3 (0x0400)
-#define ZX_LOG_DEBUG4 (0x0800)
+// Log Levels
+#define ZX_LOG_TRACE (0x10)
+#define ZX_LOG_DEBUG (0x20)
+#define ZX_LOG_INFO (0x30)
+#define ZX_LOG_WARNING (0x40)
+#define ZX_LOG_ERROR (0x50)
+#define ZX_LOG_FATAL (0x60)
// Filter Flags
// Do not forward this message via network
// (for logging in network core and drivers)
-#define ZX_LOG_LOCAL (0x1000)
+#define ZX_LOG_LOCAL (0x10)
-#define ZX_LOG_LEVEL_MASK (0x0FFF)
-#define ZX_LOG_FLAGS_MASK (0xFFFF)
+#define ZX_LOG_FLAGS_MASK (0x10)
// Options
#define ZX_LOG_FLAG_READABLE 0x40000000
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_LOG_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/object.h b/arch/x64/sysroot/include/zircon/syscalls/object.h
index 33e2e90..81414d5 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/object.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/object.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_OBJECT_H_
-#define ZIRCON_SYSCALLS_OBJECT_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
+#define SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
#include <zircon/types.h>
@@ -12,6 +12,9 @@
// ask clang format not to mess up the indentation:
// clang-format off
+// Help macro for building versioned topics. Version is the upper 4 bits and starts counting at 0.
+#define __ZX_INFO_TOPIC(t, v) ((zx_object_info_topic_t) ((t) | ((v) << 28)))
+
// Valid topics for zx_object_get_info.
typedef uint32_t zx_object_info_topic_t;
#define ZX_INFO_NONE ((zx_object_info_topic_t) 0u)
@@ -26,7 +29,8 @@
#define ZX_INFO_THREAD_EXCEPTION_REPORT ((zx_object_info_topic_t) 11u) // zx_exception_report_t[1]
#define ZX_INFO_TASK_STATS ((zx_object_info_topic_t) 12u) // zx_info_task_stats_t[1]
#define ZX_INFO_PROCESS_MAPS ((zx_object_info_topic_t) 13u) // zx_info_maps_t[n]
-#define ZX_INFO_PROCESS_VMOS ((zx_object_info_topic_t) 14u) // zx_info_vmo_t[n]
+#define ZX_INFO_PROCESS_VMOS_V1 __ZX_INFO_TOPIC(14u, 0) // zx_info_vmo_t[n]
+#define ZX_INFO_PROCESS_VMOS __ZX_INFO_TOPIC(14u, 1) // zx_info_vmo_t[n]
#define ZX_INFO_THREAD_STATS ((zx_object_info_topic_t) 15u) // zx_info_thread_stats_t[1]
#define ZX_INFO_CPU_STATS ((zx_object_info_topic_t) 16u) // zx_info_cpu_stats_t[n]
#define ZX_INFO_KMEM_STATS ((zx_object_info_topic_t) 17u) // zx_info_kmem_stats_t[1]
@@ -35,11 +39,27 @@
#define ZX_INFO_BTI ((zx_object_info_topic_t) 20u) // zx_info_bti_t[1]
#define ZX_INFO_PROCESS_HANDLE_STATS ((zx_object_info_topic_t) 21u) // zx_info_process_handle_stats_t[1]
#define ZX_INFO_SOCKET ((zx_object_info_topic_t) 22u) // zx_info_socket_t[1]
-#define ZX_INFO_VMO ((zx_object_info_topic_t) 23u) // zx_info_vmo_t[1]
+#define ZX_INFO_VMO_V1 __ZX_INFO_TOPIC(23u, 0) // zx_info_vmo_t[1]
+#define ZX_INFO_VMO __ZX_INFO_TOPIC(23u, 1) // zx_info_vmo_t[1]
+#define ZX_INFO_JOB ((zx_object_info_topic_t) 24u) // zx_info_job_t[1]
+#define ZX_INFO_TIMER ((zx_object_info_topic_t) 25u) // zx_info_timer_t[1]
+#define ZX_INFO_STREAM ((zx_object_info_topic_t) 26u) // zx_info_stream_t[1]
+#define ZX_INFO_HANDLE_TABLE ((zx_object_info_topic_t) 27u) // zx_info_handle_extended_t[n]
+#define ZX_INFO_MSI ((zx_object_info_topic_t) 28u) // zx_info_msi_t[1]
+#define ZX_INFO_GUEST_STATS ((zx_object_info_topic_t) 29u) // zx_info_guest_stats_t[1]
+#define ZX_INFO_TASK_RUNTIME ((zx_object_info_topic_t) 30u) // zx_info_task_runtime_t[1]
-typedef uint32_t zx_obj_props_t;
-#define ZX_OBJ_PROP_NONE ((zx_obj_props_t)0u)
-#define ZX_OBJ_PROP_WAITABLE ((zx_obj_props_t)1u)
+// Return codes set when a task is killed.
+#define ZX_TASK_RETCODE_SYSCALL_KILL ((int64_t) -1024) // via zx_task_kill().
+#define ZX_TASK_RETCODE_OOM_KILL ((int64_t) -1025) // by the OOM killer.
+#define ZX_TASK_RETCODE_POLICY_KILL ((int64_t) -1026) // by the Job policy.
+#define ZX_TASK_RETCODE_VDSO_KILL ((int64_t) -1027) // by the VDSO.
+#define ZX_TASK_RETCODE_EXCEPTION_KILL ((int64_t) -1028) // Exception not handled.
+#define ZX_TASK_RETCODE_CRITICAL_PROCESS_KILL ((int64_t) -1029) // by a critical process.
+
+// Sentinel indicating an invalid or missing CPU.
+#define ZX_INFO_INVALID_CPU ((uint32_t)0xFFFFFFFFu)
+
typedef struct zx_info_handle_basic {
// The unique id assigned by kernel to the object referenced by the
@@ -61,11 +81,46 @@
// not change even if the related object no longer exists.
zx_koid_t related_koid;
- // Set to ZX_OBJ_PROP_WAITABLE if the object referenced by the
- // handle can be waited on; zero otherwise.
- zx_obj_props_t props;
+ uint32_t reserved;
+
+ uint8_t padding1[4];
} zx_info_handle_basic_t;
+typedef struct zx_info_handle_extended {
+ // The object type: channel, event, socket, etc.
+ zx_obj_type_t type;
+
+ // The handle value which is only valid for the process which
+ // was passed to ZX_INFO_HANDLE_TABLE.
+ zx_handle_t handle_value;
+
+ // The immutable rights assigned to the handle. Two handles that
+ // have the same koid and the same rights are equivalent and
+ // interchangeable.
+ zx_rights_t rights;
+
+ uint32_t reserved;
+
+ // The unique id assigned by kernel to the object referenced by the
+ // handle.
+ zx_koid_t koid;
+
+ // If the object referenced by the handle is related to another (such
+ // as the other end of a channel, or the parent of a job) then
+ // |related_koid| is the koid of that object, otherwise it is zero.
+ // This relationship is immutable: an object's |related_koid| does
+ // not change even if the related object no longer exists.
+ zx_koid_t related_koid;
+
+ // If the object referenced by the handle has a peer, like the
+ // other end of a channel, then this is the koid of the process
+ // which currently owns it. This value is not stable; the process
+ // can change the owner at any moment.
+ //
+ // This is currently unimplemented and contains 0.
+ zx_koid_t peer_owner_koid;
+} zx_info_handle_extended_t;
+
typedef struct zx_info_handle_count {
// The number of outstanding handles to a kernel object.
uint32_t handle_count;
@@ -73,12 +128,12 @@
typedef struct zx_info_process_handle_stats {
// The number of outstanding handles to kernel objects of each type.
- uint32_t handle_count[64];
+ uint32_t handle_count[ZX_OBJ_TYPE_UPPER_BOUND];
} zx_info_process_handle_stats_t;
typedef struct zx_info_process {
// The process's return code; only valid if |exited| is true.
- // Guaranteed to be non-zero if the process was killed by |zx_task_kill|.
+ // If the process was killed, it will be one of the ZX_TASK_RETCODE values.
int64_t return_code;
// True if the process has ever left the initial creation state,
@@ -90,8 +145,70 @@
// True if a debugger is attached to the process.
bool debugger_attached;
+
+ uint8_t padding1[5];
} zx_info_process_t;
+typedef struct zx_info_job {
+ // The job's return code; only valid if |exited| is true.
+ // If the process was killed, it will be one of the ZX_TASK_RETCODE values.
+ int64_t return_code;
+
+ // If true, the job has exited and |return_code| is valid.
+ bool exited;
+
+ // True if the ZX_PROP_JOB_KILL_ON_OOM was set.
+ bool kill_on_oom;
+
+ // True if a debugger is attached to the job.
+ bool debugger_attached;
+
+ uint8_t padding1[5];
+} zx_info_job_t;
+
+typedef struct zx_info_timer {
+ // The options passed to zx_timer_create().
+ uint32_t options;
+
+ uint8_t padding1[4];
+
+ // The deadline with respect to ZX_CLOCK_MONOTONIC at which the timer will
+ // fire next.
+ //
+ // This value will be zero if the timer is not set to fire.
+ zx_time_t deadline;
+
+ // Specifies a range from deadline - slack to deadline + slack during which
+ // the timer is allowed to fire. The system uses this parameter as a hint to
+ // coalesce nearby timers.
+ //
+ // The precise coalescing behavior is controlled by the options parameter
+ // specified when the timer was created.
+ //
+ // This value will be zero if the timer is not set to fire.
+ zx_duration_t slack;
+} zx_info_timer_t;
+
+typedef struct zx_info_stream {
+ // The options passed to zx_stream_create().
+ uint32_t options;
+
+ uint8_t padding1[4];
+
+ // The current seek offset.
+ //
+ // Used by zx_stream_readv and zx_stream_writev to determine where to read
+ // and write the stream.
+ zx_off_t seek;
+
+ // The current size of the stream.
+ //
+ // The number of bytes in the stream that store data. The stream itself
+ // might have a larger capacity to avoid reallocating the underlying storage
+ // as the stream grows or shrinks.
+ uint64_t content_size;
+} zx_info_stream_t;
+
typedef uint32_t zx_thread_state_t;
typedef struct zx_info_thread {
@@ -99,15 +216,32 @@
zx_thread_state_t state;
// If |state| is ZX_THREAD_STATE_BLOCKED_EXCEPTION, the thread has gotten
- // an exception and is waiting for the exception to be handled by the
- // specified port.
- // The value is one of ZX_EXCEPTION_PORT_TYPE_*.
- uint32_t wait_exception_port_type;
+ // an exception and is waiting for the exception response from the specified
+ // handler.
+
+ // The value is one of ZX_EXCEPTION_CHANNEL_TYPE_*.
+ uint32_t wait_exception_channel_type;
+
+ // CPUs this thread may be scheduled on, as specified by
+ // a profile object applied to this thread.
+ //
+ // The kernel may not internally store invalid CPUs in the mask, so
+ // this may not exactly match the mask applied to the thread for
+ // CPUs beyond what the system is able to use.
+ zx_cpu_set_t cpu_affinity_mask;
} zx_info_thread_t;
typedef struct zx_info_thread_stats {
// Total accumulated running time of the thread.
zx_duration_t total_runtime;
+
+ // CPU number that this thread was last scheduled on, or ZX_INFO_INVALID_CPU
+ // if the thread has never been scheduled on a CPU. By the time this call
+ // returns, the thread may have been scheduled elsewhere, so this
+ // information should only be used as a hint or for statistics.
+ uint32_t last_scheduled_cpu;
+
+ uint8_t padding1[4];
} zx_info_thread_stats_t;
// Statistics about resources (e.g., memory) used by a task. Can be relatively
@@ -155,12 +289,22 @@
// The number of bytes in the device's address space (UINT64_MAX if 2^64).
uint64_t aspace_size;
+
+ // The count of the pinned memory object tokens. Requesting this count is
+ // racy, so this should only be used for informative reasons.
+ uint64_t pmo_count;
+
+ // The count of the quarantined pinned memory object tokens. Requesting this count is
+ // racy, so this should only be used for informative reasons.
+ uint64_t quarantine_count;
} zx_info_bti_t;
typedef struct zx_info_socket {
// The options passed to zx_socket_create().
uint32_t options;
+ uint8_t padding1[4];
+
// The maximum size of the receive buffer of a socket, in bytes.
//
// The receive buffer may become full at a capacity less than the maximum
@@ -199,6 +343,7 @@
// MMU flags for the mapping.
// Bitwise OR of ZX_VM_PERM_{READ,WRITE,EXECUTE} values.
zx_vm_option_t mmu_flags;
+ uint8_t padding1[4];
// koid of the mapped VMO.
zx_koid_t vmo_koid;
// Offset into the above VMO.
@@ -232,6 +377,7 @@
size_t depth;
// The type of this entry; indicates which union entry is valid.
zx_info_maps_type_t type;
+ uint8_t padding1[4];
union {
zx_info_maps_mapping_t mapping;
// No additional fields for other types.
@@ -256,7 +402,10 @@
// if (ZX_INFO_VMO_TYPE(f) == ZX_INFO_VMO_TYPE_PAGED)
#define ZX_INFO_VMO_TYPE(flags) ((flags) & (1u<<0))
-// The VMO is a clone, and is a copy-on-write clone.
+// The VMO is resizable.
+#define ZX_INFO_VMO_RESIZABLE (1u<<1)
+
+// The VMO is a child, and is a copy-on-write clone.
#define ZX_INFO_VMO_IS_COW_CLONE (1u<<2)
// When reading a list of VMOs pointed to by a process, indicates that the
@@ -268,6 +417,14 @@
// the VMO.
#define ZX_INFO_VMO_VIA_MAPPING (1u<<4)
+// The VMO is a pager owned VMO created by zx_pager_create_vmo or is
+// a clone of a VMO with this flag set. Will only be set on VMOs with
+// the ZX_INFO_VMO_TYPE_PAGED flag set.
+#define ZX_INFO_VMO_PAGER_BACKED (1u<<5)
+
+// The VMO is contiguous
+#define ZX_INFO_VMO_CONTIGUOUS (1u<<6)
+
// Describes a VMO. For mapping information, see |zx_info_maps_t|.
typedef struct zx_info_vmo {
// The koid of this VMO.
@@ -301,6 +458,8 @@
// Bitwise OR of ZX_INFO_VMO_* values.
uint32_t flags;
+ uint8_t padding1[4];
+
// If |ZX_INFO_VMO_TYPE(flags) == ZX_INFO_VMO_TYPE_PAGED|, the amount of
// memory currently allocated to this VMO; i.e., the amount of physical
// memory it consumes. Undefined otherwise.
@@ -310,15 +469,83 @@
// Undefined otherwise.
zx_rights_t handle_rights;
- // VMO creation options. This is a bitmask of
- // kResizable = (1u << 0);
- // kContiguous = (1u << 1);
- uint32_t create_options;
-
// VMO mapping cache policy. One of ZX_CACHE_POLICY_*
uint32_t cache_policy;
+
+ // Amount of kernel memory, in bytes, allocated to track metadata
+ // associated with this VMO.
+ uint64_t metadata_bytes;
+
+ // Running counter of the number of times the kernel, without user request,
+ // performed actions on this VMO that would have caused |committed_bytes| to
+ // report a different value.
+ uint64_t committed_change_events;
} zx_info_vmo_t;
+typedef struct zx_info_vmo_v1 {
+ zx_koid_t koid;
+ char name[ZX_MAX_NAME_LEN];
+ uint64_t size_bytes;
+ zx_koid_t parent_koid;
+ size_t num_children;
+ size_t num_mappings;
+ size_t share_count;
+ uint32_t flags;
+ uint8_t padding1[4];
+ uint64_t committed_bytes;
+ zx_rights_t handle_rights;
+ uint32_t cache_policy;
+} zx_info_vmo_v1_t;
+
+typedef struct zx_info_guest_stats {
+ uint32_t cpu_number;
+ uint32_t flags;
+
+ uint64_t vm_entries;
+ uint64_t vm_exits;
+#ifdef __aarch64__
+ uint64_t wfi_wfe_instructions;
+ uint64_t instruction_aborts;
+ uint64_t data_aborts;
+ uint64_t system_instructions;
+ uint64_t smc_instructions;
+ uint64_t interrupts;
+#else
+ uint64_t interrupts;
+ uint64_t interrupt_windows;
+ uint64_t cpuid_instructions;
+ uint64_t hlt_instructions;
+ uint64_t control_register_accesses;
+ uint64_t io_instructions;
+ uint64_t rdmsr_instructions;
+ uint64_t wrmsr_instructions;
+ uint64_t ept_violations;
+ uint64_t xsetbv_instructions;
+ uint64_t pause_instructions;
+ uint64_t vmcall_instructions;
+#endif
+} zx_info_guest_stats_t;
+
+// Info on the runtime of a task.
+typedef struct zx_info_task_runtime {
+ // The total amount of time this task and its children were running.
+ // * Threads include only their own runtime.
+ // * Processes include the runtime for all of their threads (including threads that previously
+ // exited).
+ // * Jobs include the runtime for all of their processes (including processes that previously
+ // exited).
+ zx_duration_t cpu_time;
+
+ // The total amount of time this task and its children were queued to run.
+ // * Threads include only their own queue time.
+ // * Processes include the queue time for all of their threads (including threads that
+ // previously exited).
+ // * Jobs include the queue time for all of their processes (including processes that previously
+ // exited).
+ zx_duration_t queue_time;
+} zx_info_task_runtime_t;
+
+
// kernel statistics per cpu
// TODO(cpu), expose the deprecated stats via a new syscall.
typedef struct zx_info_cpu_stats {
@@ -399,6 +626,19 @@
char name[ZX_MAX_NAME_LEN];
} zx_info_resource_t;
+typedef struct zx_info_msi {
+ // The target adress for write transactions.
+ uint64_t target_addr;
+ // The data that the device will write when triggering an IRQ.
+ uint32_t target_data;
+ // The first IRQ in the allocated block.
+ uint32_t base_irq_id;
+ // The number of IRQs in the allocated block.
+ uint32_t num_irq;
+ // The number of outstanding interrupt objects created off this Msi object.
+ uint32_t interrupt_count;
+} zx_info_msi_t;
+
#define ZX_INFO_CPU_STATS_FLAG_ONLINE (1u<<0)
// Object properties.
@@ -422,6 +662,19 @@
// Argument is the base address of the vDSO mapping (or zero), a uintptr_t.
#define ZX_PROP_PROCESS_VDSO_BASE_ADDRESS ((uint32_t) 6u)
+// Whether the dynamic loader should issue a debug trap when loading a shared library,
+// either initially or when running (e.g. dlopen).
+//
+// See docs/reference/syscalls/object_get_property.md
+// See third_party/ulib/musl/ldso/dynlink.c.
+#define ZX_PROP_PROCESS_BREAK_ON_LOAD ((uint32_t) 7u)
+
+// The process's context id as recorded by h/w instruction tracing, a uintptr_t.
+// On X86 this is the cr3 value.
+// TODO(dje): Wasn't sure whether the gaps in property numbers are unusable
+// due to being old dleeted values. For now I just picked something.
+#define ZX_PROP_PROCESS_HW_TRACE_CONTEXT_ID ((uint32_t) 8u)
+
// Argument is a size_t.
#define ZX_PROP_SOCKET_RX_THRESHOLD 12u
#define ZX_PROP_SOCKET_TX_THRESHOLD 13u
@@ -429,6 +682,21 @@
// Terminate this job if the system is low on memory.
#define ZX_PROP_JOB_KILL_ON_OOM 15u
+// Exception close behavior.
+#define ZX_PROP_EXCEPTION_STATE 16u
+
+// The size of the content in a VMO, in bytes.
+//
+// The content size of a VMO can be larger or smaller than the actual size of
+// the VMO.
+//
+// Argument is a uint64_t.
+#define ZX_PROP_VMO_CONTENT_SIZE 17u
+
+// How an exception should be handled.
+// See //docs/concepts/kernel/exceptions.md.
+#define ZX_PROP_EXCEPTION_STRATEGY 18u
+
// Basic thread states, in zx_info_thread_t.state.
#define ZX_THREAD_STATE_NEW ((zx_thread_state_t) 0x0000u)
#define ZX_THREAD_STATE_RUNNING ((zx_thread_state_t) 0x0001u)
@@ -449,11 +717,22 @@
#define ZX_THREAD_STATE_BLOCKED_WAIT_ONE ((zx_thread_state_t) 0x0603u)
#define ZX_THREAD_STATE_BLOCKED_WAIT_MANY ((zx_thread_state_t) 0x0703u)
#define ZX_THREAD_STATE_BLOCKED_INTERRUPT ((zx_thread_state_t) 0x0803u)
+#define ZX_THREAD_STATE_BLOCKED_PAGER ((zx_thread_state_t) 0x0903u)
// Reduce possibly-more-precise state to a basic state.
// Useful if, for example, you want to check for BLOCKED on anything.
#define ZX_THREAD_STATE_BASIC(n) ((n) & 0xff)
+// How a thread should behave when the current exception is closed.
+// ZX_PROP_EXCEPTION_STATE values.
+#define ZX_EXCEPTION_STATE_TRY_NEXT 0u
+#define ZX_EXCEPTION_STATE_HANDLED 1u
+
+// How an exception should be handled
+// ZX_PROP_EXCEPTION_STRATEGY values.
+#define ZX_EXCEPTION_STRATEGY_FIRST_CHANCE 0u
+#define ZX_EXCEPTION_STRATEGY_SECOND_CHANCE 1u
+
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_OBJECT_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_OBJECT_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/pci.h b/arch/x64/sysroot/include/zircon/syscalls/pci.h
index b97f1c3..d1049c2 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/pci.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/pci.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PCI_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PCI_H_
#include <zircon/types.h>
@@ -32,7 +33,10 @@
size_t size;
union {
uintptr_t addr;
- zx_handle_t handle;
+ struct {
+ zx_handle_t handle;
+ uint8_t padding1[4];
+ };
};
} zx_pci_bar_t;
@@ -50,6 +54,8 @@
uint8_t bus_id;
uint8_t dev_id;
uint8_t func_id;
+
+ uint8_t padding1;
} zx_pcie_device_info_t;
#define ZX_PCI_MAX_BUSSES (256u)
@@ -84,6 +90,10 @@
[ZX_PCI_MAX_FUNCTIONS_PER_DEVICE]
[ZX_PCI_MAX_LEGACY_IRQ_PINS];
+// We support up to 224 IRQs on a system, this is the maximum supported by
+// LAPICs (today) so this should be a safe number.
+#define ZX_PCI_MAX_IRQS 224
+
typedef struct zx_pci_init_arg {
zx_pci_irq_swizzle_lut_t dev_pin_to_global_irq;
@@ -92,7 +102,8 @@
uint32_t global_irq;
bool level_triggered;
bool active_high;
- } irqs[64];
+ uint8_t padding1[2];
+ } irqs[ZX_PCI_MAX_IRQS];
uint32_t addr_window_count;
struct {
@@ -102,6 +113,7 @@
uint8_t bus_end;
uint8_t cfg_space_type;
bool has_ecam;
+ uint8_t padding1[4];
} addr_windows[];
} zx_pci_init_arg_t;
@@ -118,3 +130,5 @@
#define ZX_PCIE_IRQ_MODE_MSI_X ((zx_pci_irq_mode_t) 3u)
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_PCI_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/policy.h b/arch/x64/sysroot/include/zircon/syscalls/policy.h
index f7061ce..158c604 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/policy.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/policy.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
+#define SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
#include <zircon/types.h>
@@ -13,18 +14,33 @@
// Policy is applied for the conditions that are not
// specified by the parent job policy.
-#define ZX_JOB_POL_RELATIVE 0u
+#define ZX_JOB_POL_RELATIVE 0u
// Policy is either applied as-is or the syscall fails.
-#define ZX_JOB_POL_ABSOLUTE 1u
+#define ZX_JOB_POL_ABSOLUTE 1u
// Basic policy topic.
-#define ZX_JOB_POL_BASIC 0u
+#define ZX_JOB_POL_BASIC_V1 0u
+#define ZX_JOB_POL_BASIC_V2 0x01000000u
-// Input structure to use with ZX_JOB_POL_BASIC.
-typedef struct zx_policy_basic {
+// Timer slack policy topic.
+#define ZX_JOB_POL_TIMER_SLACK 1u
+
+// Input structure to use with ZX_JOB_POL_BASIC_V1.
+typedef struct zx_policy_basic_v1 {
uint32_t condition;
uint32_t policy;
-} zx_policy_basic_t;
+} zx_policy_basic_v1_t;
+
+// Input structure to use with ZX_JOB_POL_BASIC_V2.
+typedef struct zx_policy_basic_v2 {
+ uint32_t condition;
+ uint32_t action;
+ uint32_t flags;
+} zx_policy_basic_v2_t;
+
+#define ZX_JOB_POL_BASIC ZX_JOB_POL_BASIC_V1
+typedef struct zx_policy_basic_v1 zx_policy_basic;
+typedef struct zx_policy_basic_v1 zx_policy_basic_t;
// Conditions handled by job policy.
#define ZX_POL_BAD_HANDLE 0u
@@ -40,16 +56,34 @@
#define ZX_POL_NEW_FIFO 10u
#define ZX_POL_NEW_TIMER 11u
#define ZX_POL_NEW_PROCESS 12u
+#define ZX_POL_NEW_PROFILE 13u
+#define ZX_POL_AMBIENT_MARK_VMO_EXEC 14u
#ifdef _KERNEL
-#define ZX_POL_MAX 13u
+#define ZX_POL_MAX 15u
#endif
// Policy actions.
-// ZX_POL_ACTION_ALLOW and ZX_POL_ACTION_DENY can be ORed with ZX_POL_ACTION_EXCEPTION.
-// ZX_POL_ACTION_KILL implies ZX_POL_ACTION_DENY.
#define ZX_POL_ACTION_ALLOW 0u
#define ZX_POL_ACTION_DENY 1u
-#define ZX_POL_ACTION_EXCEPTION 2u
-#define ZX_POL_ACTION_KILL 5u
+#define ZX_POL_ACTION_ALLOW_EXCEPTION 2u
+#define ZX_POL_ACTION_DENY_EXCEPTION 3u
+#define ZX_POL_ACTION_KILL 4u
+#ifdef _KERNEL
+#define ZX_POL_ACTION_MAX 5u
+#endif
+
+// Policy override.
+#define ZX_POL_OVERRIDE_ALLOW 0u
+#define ZX_POL_OVERRIDE_DENY 1u
+
+
+// Input structure to use with ZX_JOB_POL_TIMER_SLACK.
+typedef struct zx_policy_timer_slack {
+ zx_duration_t min_slack;
+ uint32_t default_mode;
+ uint8_t padding1[4];
+} zx_policy_timer_slack_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_POLICY_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/port.h b/arch/x64/sysroot/include/zircon/syscalls/port.h
index 10bc39b..06b3b6a 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/port.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/port.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_SYSCALLS_PORT_H_
-#define ZIRCON_SYSCALLS_PORT_H_
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PORT_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PORT_H_
#include <zircon/compiler.h>
#include <zircon/types.h>
@@ -13,140 +13,162 @@
// clang-format off
// zx_object_wait_async() options
+// Do not use ZX_WAIT_ASYNC_ONCE. It is now superfluous and will be removed.
#define ZX_WAIT_ASYNC_ONCE ((uint32_t)0u)
-#define ZX_WAIT_ASYNC_REPEATING ((uint32_t)1u)
+#define ZX_WAIT_ASYNC_TIMESTAMP ((uint32_t)1u)
// packet types. zx_port_packet_t::type
#define ZX_PKT_TYPE_USER ((uint8_t)0x00u)
#define ZX_PKT_TYPE_SIGNAL_ONE ((uint8_t)0x01u)
-#define ZX_PKT_TYPE_SIGNAL_REP ((uint8_t)0x02u)
+// 0x02 was previously used for "ZX_PKT_TYPE_SIGNAL_REP".
#define ZX_PKT_TYPE_GUEST_BELL ((uint8_t)0x03u)
#define ZX_PKT_TYPE_GUEST_MEM ((uint8_t)0x04u)
#define ZX_PKT_TYPE_GUEST_IO ((uint8_t)0x05u)
#define ZX_PKT_TYPE_GUEST_VCPU ((uint8_t)0x06u)
#define ZX_PKT_TYPE_INTERRUPT ((uint8_t)0x07u)
-#define ZX_PKT_TYPE_EXCEPTION(n) ((uint32_t)(0x08u | (((n) & 0xFFu) << 8)))
+#define ZX_PKT_TYPE_PAGE_REQUEST ((uint8_t)0x09u)
// For options passed to port_create
#define ZX_PORT_BIND_TO_INTERRUPT ((uint32_t)(0x1u << 0))
#define ZX_PKT_TYPE_MASK ((uint32_t)0x000000FFu)
-#define ZX_PKT_IS_USER(type) ((type) == ZX_PKT_TYPE_USER)
-#define ZX_PKT_IS_SIGNAL_ONE(type) ((type) == ZX_PKT_TYPE_SIGNAL_ONE)
-#define ZX_PKT_IS_SIGNAL_REP(type) ((type) == ZX_PKT_TYPE_SIGNAL_REP)
-#define ZX_PKT_IS_GUEST_BELL(type) ((type) == ZX_PKT_TYPE_GUEST_BELL)
-#define ZX_PKT_IS_GUEST_MEM(type) ((type) == ZX_PKT_TYPE_GUEST_MEM)
-#define ZX_PKT_IS_GUEST_IO(type) ((type) == ZX_PKT_TYPE_GUEST_IO)
-#define ZX_PKT_IS_GUEST_VCPU(type) ((type) == ZX_PKT_TYPE_GUEST_VCPU)
-#define ZX_PKT_IS_INTERRUPT(type) ((type) == ZX_PKT_TYPE_INTERRUPT)
-#define ZX_PKT_IS_EXCEPTION(type) (((type) & ZX_PKT_TYPE_MASK) == ZX_PKT_TYPE_EXCEPTION(0))
+#define ZX_PKT_IS_USER(type) ((type) == ZX_PKT_TYPE_USER)
+#define ZX_PKT_IS_SIGNAL_ONE(type) ((type) == ZX_PKT_TYPE_SIGNAL_ONE)
+#define ZX_PKT_IS_GUEST_BELL(type) ((type) == ZX_PKT_TYPE_GUEST_BELL)
+#define ZX_PKT_IS_GUEST_MEM(type) ((type) == ZX_PKT_TYPE_GUEST_MEM)
+#define ZX_PKT_IS_GUEST_IO(type) ((type) == ZX_PKT_TYPE_GUEST_IO)
+#define ZX_PKT_IS_GUEST_VCPU(type) ((type) == ZX_PKT_TYPE_GUEST_VCPU)
+#define ZX_PKT_IS_INTERRUPT(type) ((type) == ZX_PKT_TYPE_INTERRUPT)
+#define ZX_PKT_IS_PAGE_REQUEST(type) ((type) == ZX_PKT_TYPE_PAGE_REQUEST)
// zx_packet_guest_vcpu_t::type
#define ZX_PKT_GUEST_VCPU_INTERRUPT ((uint8_t)0)
#define ZX_PKT_GUEST_VCPU_STARTUP ((uint8_t)1)
+
+// zx_packet_page_request_t::command
+#define ZX_PAGER_VMO_READ ((uint16_t) 0)
+#define ZX_PAGER_VMO_COMPLETE ((uint16_t) 1)
// clang-format on
// port_packet_t::type ZX_PKT_TYPE_USER.
typedef union zx_packet_user {
- uint64_t u64[4];
- uint32_t u32[8];
- uint16_t u16[16];
- uint8_t c8[32];
+ uint64_t u64[4];
+ uint32_t u32[8];
+ uint16_t u16[16];
+ uint8_t c8[32];
} zx_packet_user_t;
-// port_packet_t::type ZX_PKT_TYPE_SIGNAL_ONE and ZX_PKT_TYPE_SIGNAL_REP.
+// port_packet_t::type ZX_PKT_TYPE_SIGNAL_ONE.
typedef struct zx_packet_signal {
- zx_signals_t trigger;
- zx_signals_t observed;
- uint64_t count;
- uint64_t reserved0;
- uint64_t reserved1;
+ zx_signals_t trigger;
+ zx_signals_t observed;
+ uint64_t count;
+ uint64_t timestamp;
+ uint64_t reserved1;
} zx_packet_signal_t;
-typedef struct zx_packet_exception {
- uint64_t pid;
- uint64_t tid;
- uint64_t reserved0;
- uint64_t reserved1;
-} zx_packet_exception_t;
-
typedef struct zx_packet_guest_bell {
- zx_gpaddr_t addr;
- uint64_t reserved0;
- uint64_t reserved1;
- uint64_t reserved2;
+ zx_gpaddr_t addr;
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_guest_bell_t;
typedef struct zx_packet_guest_mem {
- zx_gpaddr_t addr;
+ zx_gpaddr_t addr;
#if __aarch64__
- uint8_t access_size;
- bool sign_extend;
- uint8_t xt;
- bool read;
- uint64_t data;
- uint64_t reserved;
+ uint8_t access_size;
+ bool sign_extend;
+ uint8_t xt;
+ bool read;
+ uint8_t padding1[4];
+ uint64_t data;
+ uint64_t reserved;
#elif __x86_64__
// NOTE: x86 instructions are guaranteed to be 15 bytes or fewer.
#define X86_MAX_INST_LEN 15u
- uint8_t inst_len;
- uint8_t inst_buf[X86_MAX_INST_LEN];
- uint8_t default_operand_size;
- uint8_t reserved[7];
+ uint8_t inst_len;
+ uint8_t inst_buf[X86_MAX_INST_LEN];
+ // This is the default operand size as determined by the CS and EFER register (Volume 3,
+ // Section 5.2.1). If operating in 64-bit mode then near branches and all instructions, except
+ // far branches, that implicitly reference the RSP will actually have a default operand size of
+ // 64-bits (Volume 2, Section 2.2.1.7), and not the 32-bits that will be given here.
+ uint8_t default_operand_size;
+ uint8_t reserved[7];
#endif
} zx_packet_guest_mem_t;
typedef struct zx_packet_guest_io {
- uint16_t port;
- uint8_t access_size;
- bool input;
- union {
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
- uint8_t data[4];
+ uint16_t port;
+ uint8_t access_size;
+ bool input;
+ union {
+ struct {
+ uint8_t u8;
+ uint8_t padding1[3];
};
- uint64_t reserved0;
- uint64_t reserved1;
- uint64_t reserved2;
+ struct {
+ uint16_t u16;
+ uint8_t padding2[2];
+ };
+ uint32_t u32;
+ uint8_t data[4];
+ };
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_guest_io_t;
typedef struct zx_packet_guest_vcpu {
- union {
- struct {
- uint64_t mask;
- uint8_t vector;
- } interrupt;
- struct {
- uint64_t id;
- zx_gpaddr_t entry;
- } startup;
- };
- uint8_t type;
- uint64_t reserved;
+ union {
+ struct {
+ uint64_t mask;
+ uint8_t vector;
+ uint8_t padding1[7];
+ } interrupt;
+ struct {
+ uint64_t id;
+ zx_gpaddr_t entry;
+ } startup;
+ };
+ uint8_t type;
+ uint8_t padding1[7];
+ uint64_t reserved;
} zx_packet_guest_vcpu_t;
typedef struct zx_packet_interrupt {
- zx_time_t timestamp;
+ zx_time_t timestamp;
+ uint64_t reserved0;
+ uint64_t reserved1;
+ uint64_t reserved2;
} zx_packet_interrupt_t;
+typedef struct zx_packet_page_request {
+ uint16_t command;
+ uint16_t flags;
+ uint32_t reserved0;
+ uint64_t offset;
+ uint64_t length;
+ uint64_t reserved1;
+} zx_packet_page_request_t;
+
typedef struct zx_port_packet {
- uint64_t key;
- uint32_t type;
- int32_t status;
- union {
- zx_packet_user_t user;
- zx_packet_signal_t signal;
- zx_packet_exception_t exception;
- zx_packet_guest_bell_t guest_bell;
- zx_packet_guest_mem_t guest_mem;
- zx_packet_guest_io_t guest_io;
- zx_packet_guest_vcpu_t guest_vcpu;
- zx_packet_interrupt_t interrupt;
- };
+ uint64_t key;
+ uint32_t type;
+ zx_status_t status;
+ union {
+ zx_packet_user_t user;
+ zx_packet_signal_t signal;
+ zx_packet_guest_bell_t guest_bell;
+ zx_packet_guest_mem_t guest_mem;
+ zx_packet_guest_io_t guest_io;
+ zx_packet_guest_vcpu_t guest_vcpu;
+ zx_packet_interrupt_t interrupt;
+ zx_packet_page_request_t page_request;
+ };
} zx_port_packet_t;
__END_CDECLS
-#endif // ZIRCON_SYSCALLS_PORT_H_
+#endif // SYSROOT_ZIRCON_SYSCALLS_PORT_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/profile.h b/arch/x64/sysroot/include/zircon/syscalls/profile.h
index 10ed499..5abf561 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/profile.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/profile.h
@@ -2,36 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
+#define SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
+#include <zircon/syscalls/scheduler.h>
#include <zircon/types.h>
__BEGIN_CDECLS
-// ask clang format not to mess up the indentation:
-// clang-format off
+#define ZX_PRIORITY_LOWEST 0
+#define ZX_PRIORITY_LOW 8
+#define ZX_PRIORITY_DEFAULT 16
+#define ZX_PRIORITY_HIGH 24
+#define ZX_PRIORITY_HIGHEST 31
-#define ZX_PROFILE_INFO_SCHEDULER 1
-
-typedef struct zx_profile_scheduler {
- int32_t priority;
- uint32_t boost;
- uint32_t deboost;
- uint32_t quantum;
-} zx_profile_scheduler_t;
-
-#define ZX_PRIORITY_LOWEST 0
-#define ZX_PRIORITY_LOW 8
-#define ZX_PRIORITY_DEFAULT 16
-#define ZX_PRIORITY_HIGH 24
-#define ZX_PRIORITY_HIGHEST 31
+#define ZX_PROFILE_INFO_FLAG_PRIORITY (1 << 0)
+#define ZX_PROFILE_INFO_FLAG_CPU_MASK (1 << 1)
+#define ZX_PROFILE_INFO_FLAG_DEADLINE (1 << 2)
typedef struct zx_profile_info {
- uint32_t type; // one of ZX_PROFILE_INFO_
- union {
- zx_profile_scheduler_t scheduler;
+ // A bitmask of ZX_PROFILE_INFO_FLAG_* values. Specifies which fields
+ // below have been specified. Other fields are considered unset.
+ uint32_t flags;
+
+ uint8_t padding1[4];
+
+ union {
+ struct {
+ // Scheduling priority. |flags| must have ZX_PROFILE_INFO_FLAG_PRIORITY set.
+ int32_t priority;
+
+ uint8_t padding2[20];
};
+
+ // Scheduling deadline. |flags| must have ZX_PROFILE_INFO_FLAG_DEADLINE set.
+ zx_sched_deadline_params_t deadline_params;
+ };
+
+ // CPUs that threads may be scheduled on. |flags| must have
+ // ZX_PROFILE_INFO_FLAG_CPU_MASK set.
+ zx_cpu_set_t cpu_affinity_mask;
} zx_profile_info_t;
-
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_PROFILE_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/resource.h b/arch/x64/sysroot/include/zircon/syscalls/resource.h
index 6defbda..9243d17 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/resource.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/resource.h
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
+#define SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
#include <stdint.h>
-
#include <zircon/compiler.h>
// Resources that require a region allocator to handle exclusive reservations
@@ -14,21 +14,23 @@
// bookkeeping. It's important that ZX_RSRC_KIND_COUNT is defined for each
// architecture to properly allocate only the bookkeeping necessary.
//
-// TODO(ZX-2419): Don't expose ZX_RSRC_KIND_COUNT to userspace
+// TODO(fxbug.dev/32272): Don't expose ZX_RSRC_KIND_COUNT to userspace
typedef uint32_t zx_rsrc_kind_t;
-#define ZX_RSRC_KIND_MMIO ((zx_rsrc_kind_t)0u)
-#define ZX_RSRC_KIND_IRQ ((zx_rsrc_kind_t)1u)
-#define ZX_RSRC_KIND_IOPORT ((zx_rsrc_kind_t)2u)
-#define ZX_RSRC_KIND_HYPERVISOR ((zx_rsrc_kind_t)3u)
-#define ZX_RSRC_KIND_ROOT ((zx_rsrc_kind_t)4u)
-#define ZX_RSRC_KIND_VMEX ((zx_rsrc_kind_t)5u)
-#define ZX_RSRC_KIND_SMC ((zx_rsrc_kind_t)6u)
-#define ZX_RSRC_KIND_COUNT ((zx_rsrc_kind_t)7u)
+#define ZX_RSRC_KIND_MMIO ((zx_rsrc_kind_t)0u)
+#define ZX_RSRC_KIND_IRQ ((zx_rsrc_kind_t)1u)
+#define ZX_RSRC_KIND_IOPORT ((zx_rsrc_kind_t)2u)
+#define ZX_RSRC_KIND_HYPERVISOR ((zx_rsrc_kind_t)3u)
+#define ZX_RSRC_KIND_ROOT ((zx_rsrc_kind_t)4u)
+#define ZX_RSRC_KIND_VMEX ((zx_rsrc_kind_t)5u)
+#define ZX_RSRC_KIND_SMC ((zx_rsrc_kind_t)6u)
+#define ZX_RSRC_KIND_COUNT ((zx_rsrc_kind_t)7u)
typedef uint32_t zx_rsrc_flags_t;
-#define ZX_RSRC_FLAG_EXCLUSIVE ((zx_rsrc_flags_t)0x00010000u)
-#define ZX_RSRC_FLAGS_MASK ((zx_rsrc_flags_t)ZX_RSRC_FLAG_EXCLUSIVE)
+#define ZX_RSRC_FLAG_EXCLUSIVE ((zx_rsrc_flags_t)0x00010000u)
+#define ZX_RSRC_FLAGS_MASK ((zx_rsrc_flags_t)ZX_RSRC_FLAG_EXCLUSIVE)
-#define ZX_RSRC_EXTRACT_KIND(x) ((x) & 0x0000FFFF)
-#define ZX_RSRC_EXTRACT_FLAGS(x) ((x) & 0xFFFF0000)
+#define ZX_RSRC_EXTRACT_KIND(x) ((x)&0x0000FFFF)
+#define ZX_RSRC_EXTRACT_FLAGS(x) ((x)&0xFFFF0000)
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_RESOURCE_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/scheduler.h b/arch/x64/sysroot/include/zircon/syscalls/scheduler.h
new file mode 100644
index 0000000..c119562
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/syscalls/scheduler.h
@@ -0,0 +1,36 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
+
+#include <zircon/compiler.h>
+#include <zircon/time.h>
+
+__BEGIN_CDECLS
+
+// Parameters for deadline scheduler profiles.
+//
+// At minimum, the following relation must hold:
+//
+// 0 < capacity <= relative_deadline <= period
+//
+// Additional restrictions on the range and granularity of the parameters may be
+// enforced, which can vary from system to system.
+//
+typedef struct zx_sched_deadline_params {
+ // The worst case execution time of the deadline work per interarrival period.
+ zx_duration_t capacity;
+
+ // The worst case finish time of the deadline work, relative to the beginning
+ // of the current interarrival period.
+ zx_duration_t relative_deadline;
+
+ // The worst case interarrival period of the deadline work.
+ zx_duration_t period;
+} zx_sched_deadline_params_t;
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SCHEDULER_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/smc.h b/arch/x64/sysroot/include/zircon/syscalls/smc.h
index 5c8f9ba..93f1761 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/smc.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/smc.h
@@ -2,37 +2,46 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SMC_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SMC_H_
#include <zircon/types.h>
__BEGIN_CDECLS
+// Silicon Partner.
+#define ARM_SMC_SERVICE_CALL_NUM_SIP_SERVICE_BASE 0x02
+#define ARM_SMC_SERVICE_CALL_NUM_SIP_SERVICE_LENGTH 0x01
#define ARM_SMC_SERVICE_CALL_NUM_TRUSTED_OS_BASE 0x32
#define ARM_SMC_SERVICE_CALL_NUM_TRUSTED_OS_LENGTH 0xE
#define ARM_SMC_SERVICE_CALL_NUM_MAX 0x3F
#define ARM_SMC_SERVICE_CALL_NUM_MASK 0x3F
#define ARM_SMC_SERVICE_CALL_NUM_SHIFT 24
#define ARM_SMC_GET_SERVICE_CALL_NUM_FROM_FUNC_ID(func_id) \
- (((func_id) >> ARM_SMC_SERVICE_CALL_NUM_SHIFT) & ARM_SMC_SERVICE_CALL_NUM_MASK)
+ (((func_id) >> ARM_SMC_SERVICE_CALL_NUM_SHIFT) & ARM_SMC_SERVICE_CALL_NUM_MASK)
typedef struct zx_smc_parameters {
- uint32_t func_id;
- uint64_t arg1;
- uint64_t arg2;
- uint64_t arg3;
- uint64_t arg4;
- uint64_t arg5;
- uint64_t arg6;
- uint16_t client_id;
- uint16_t secure_os_id;
+ uint32_t func_id;
+ uint8_t padding1[4];
+ uint64_t arg1;
+ uint64_t arg2;
+ uint64_t arg3;
+ uint64_t arg4;
+ uint64_t arg5;
+ uint64_t arg6;
+ uint16_t client_id;
+ uint16_t secure_os_id;
+ uint8_t padding2[4];
} zx_smc_parameters_t;
typedef struct zx_smc_result {
- uint64_t arg0;
- uint64_t arg1;
- uint64_t arg2;
- uint64_t arg3;
+ uint64_t arg0;
+ uint64_t arg1;
+ uint64_t arg2;
+ uint64_t arg3;
+ uint64_t arg6; // at least one implementation uses it as a way to return session_id.
} zx_smc_result_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SMC_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/system.h b/arch/x64/sysroot/include/zircon/syscalls/system.h
index c58de1d..b54d443 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/system.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/system.h
@@ -2,36 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
+#define SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
#include <zircon/types.h>
__BEGIN_CDECLS
// Commands used by zx_system_powerctl()
-#define ZX_SYSTEM_POWERCTL_ENABLE_ALL_CPUS 1u
+#define ZX_SYSTEM_POWERCTL_ENABLE_ALL_CPUS 1u
#define ZX_SYSTEM_POWERCTL_DISABLE_ALL_CPUS_BUT_PRIMARY 2u
-#define ZX_SYSTEM_POWERCTL_ACPI_TRANSITION_S_STATE 3u
-#define ZX_SYSTEM_POWERCTL_X86_SET_PKG_PL1 4u
-#define ZX_SYSTEM_POWERCTL_REBOOT 5u
-#define ZX_SYSTEM_POWERCTL_REBOOT_BOOTLOADER 6u
-#define ZX_SYSTEM_POWERCTL_REBOOT_RECOVERY 7u
-#define ZX_SYSTEM_POWERCTL_SHUTDOWN 8u
+#define ZX_SYSTEM_POWERCTL_ACPI_TRANSITION_S_STATE 3u
+#define ZX_SYSTEM_POWERCTL_X86_SET_PKG_PL1 4u
+#define ZX_SYSTEM_POWERCTL_REBOOT 5u
+#define ZX_SYSTEM_POWERCTL_REBOOT_BOOTLOADER 6u
+#define ZX_SYSTEM_POWERCTL_REBOOT_RECOVERY 7u
+#define ZX_SYSTEM_POWERCTL_SHUTDOWN 8u
typedef struct zx_system_powerctl_arg {
- union {
- struct {
- uint8_t target_s_state; // Value between 1 and 5 indicating which S-state
- uint8_t sleep_type_a; // Value from ACPI VM (SLP_TYPa)
- uint8_t sleep_type_b; // Value from ACPI VM (SLP_TYPb)
- } acpi_transition_s_state;
- struct {
- uint32_t power_limit; // PL1 value in milliwatts
- uint32_t time_window; // PL1 time window in microseconds
- uint8_t clamp; // PL1 clamping enable
- uint8_t enable; // PL1 enable
- } x86_power_limit;
+ union {
+ struct {
+ struct {
+ uint8_t target_s_state; // Value between 1 and 5 indicating which S-state
+ uint8_t sleep_type_a; // Value from ACPI VM (SLP_TYPa)
+ uint8_t sleep_type_b; // Value from ACPI VM (SLP_TYPb)
+ } acpi_transition_s_state;
+ uint8_t padding1[9];
};
+ struct {
+ uint32_t power_limit; // PL1 value in milliwatts
+ uint32_t time_window; // PL1 time window in microseconds
+ uint8_t clamp; // PL1 clamping enable
+ uint8_t enable; // PL1 enable
+ uint8_t padding2[2];
+ } x86_power_limit;
+ };
} zx_system_powerctl_arg_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_SYSTEM_H_
diff --git a/arch/x64/sysroot/include/zircon/syscalls/types.h b/arch/x64/sysroot/include/zircon/syscalls/types.h
index a5a69c8..b7910f2 100644
--- a/arch/x64/sysroot/include/zircon/syscalls/types.h
+++ b/arch/x64/sysroot/include/zircon/syscalls/types.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
+#define SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
#include <zircon/compiler.h>
@@ -20,3 +21,5 @@
typedef struct zx_smc_result zx_smc_result_t;
__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_SYSCALLS_TYPES_H_
diff --git a/arch/x64/sysroot/include/zircon/testonly-syscalls.h b/arch/x64/sysroot/include/zircon/testonly-syscalls.h
new file mode 100644
index 0000000..d994d86
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/testonly-syscalls.h
@@ -0,0 +1,30 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_TESTONLY_SYSCALLS_H_
+#define SYSROOT_ZIRCON_TESTONLY_SYSCALLS_H_
+
+#include <zircon/syscalls.h>
+
+__BEGIN_CDECLS
+
+// Make sure this matches <zircon/syscalls.h>.
+#define _ZX_SYSCALL_DECL(name, type, attrs, nargs, arglist, prototype) \
+ extern attrs type zx_##name prototype; \
+ extern attrs type _zx_##name prototype;
+
+#ifdef __clang__
+#define _ZX_SYSCALL_ANNO(attr) __attribute__((attr))
+#else
+#define _ZX_SYSCALL_ANNO(attr) // Nothing for compilers without the support.
+#endif
+
+#include <zircon/syscalls/internal/testonly-cdecls.inc>
+
+#undef _ZX_SYSCALL_ANNO
+#undef _ZX_SYSCALL_DECL
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_ONLY_SYSCALLS_H_
diff --git a/arch/x64/sysroot/include/zircon/threads.h b/arch/x64/sysroot/include/zircon/threads.h
index 937a9f9..2cfdd7e 100644
--- a/arch/x64/sysroot/include/zircon/threads.h
+++ b/arch/x64/sysroot/include/zircon/threads.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_THREADS_H_
+#define SYSROOT_ZIRCON_THREADS_H_
#include <threads.h>
#include <zircon/compiler.h>
@@ -19,19 +20,37 @@
// Converts a threads.h-style status value to an |zx_status_t|.
static inline zx_status_t __PURE thrd_status_to_zx_status(int thrd_status) {
- switch (thrd_status) {
+ switch (thrd_status) {
case thrd_success:
- return ZX_OK;
+ return ZX_OK;
case thrd_nomem:
- return ZX_ERR_NO_MEMORY;
+ return ZX_ERR_NO_MEMORY;
case thrd_timedout:
- return ZX_ERR_TIMED_OUT;
+ return ZX_ERR_TIMED_OUT;
case thrd_busy:
- return ZX_ERR_SHOULD_WAIT;
+ return ZX_ERR_SHOULD_WAIT;
default:
case thrd_error:
- return ZX_ERR_INTERNAL;
- }
+ return ZX_ERR_INTERNAL;
+ }
}
__END_CDECLS
+
+#ifdef __cplusplus
+
+#if __has_include(<thread>)
+
+#include <thread>
+
+// Get the zx_handle_t corresponding to the std::thread::native_handle() value.
+// See `thrd_get_zx_handle` (above) for constraints on the returned handle.
+// Using this API avoids any assumptions about std::thread::native_handle_type
+// corresponding exactly to thrd_t or any other particular type.
+zx_handle_t native_thread_get_zx_handle(std::thread::native_handle_type);
+
+#endif // __has_include(<thread>)
+
+#endif // __cplusplus
+
+#endif // SYSROOT_ZIRCON_THREADS_H_
diff --git a/arch/x64/sysroot/include/zircon/time.h b/arch/x64/sysroot/include/zircon/time.h
index a075d89..33f5452 100644
--- a/arch/x64/sysroot/include/zircon/time.h
+++ b/arch/x64/sysroot/include/zircon/time.h
@@ -1,96 +1,184 @@
-// Copyright 2018 The Fuchsia Authors
-//
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file or at
-// https://opensource.org/licenses/MIT
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-#pragma once
+#ifndef SYSROOT_ZIRCON_TIME_H_
+#define SYSROOT_ZIRCON_TIME_H_
+#include <stdint.h>
#include <zircon/compiler.h>
-#include <zircon/types.h>
-// These functions perform overflow-safe time arithmetic, clamping to ZX_TIME_INFINITE in case of
-// overflow and ZX_TIME_INFINITE_PAST in case of underflow.
+#if __has_include(<time.h>)
+#include <time.h>
+#endif
+
+__BEGIN_CDECLS
+
+// absolute time in nanoseconds (generally with respect to the monotonic clock)
+typedef int64_t zx_time_t;
+// a duration in nanoseconds
+typedef int64_t zx_duration_t;
+// a duration in hardware ticks
+typedef int64_t zx_ticks_t;
+
+#define ZX_TIME_INFINITE INT64_MAX
+#define ZX_TIME_INFINITE_PAST INT64_MIN
+
+// These functions perform overflow-safe time arithmetic and unit conversion, clamping to
+// ZX_TIME_INFINITE in case of overflow and ZX_TIME_INFINITE_PAST in case of underflow.
//
// C++ code should use zx::time and zx::duration instead.
//
-// The naming scheme is zx_<first argument>_<operation>_<second argument>.
+// For arithmetic the naming scheme is:
+// zx_<first argument>_<operation>_<second argument>
//
-// TODO(maniscalco): Consider expanding the set of operations to include division, modulo, unit
-// conversion, and floating point math.
+// For unit conversion the naming scheme is:
+// zx_duration_from_<unit of argument>
+//
+// TODO(maniscalco): Consider expanding the set of operations to include division, modulo, and
+// floating point math.
__CONSTEXPR static inline zx_time_t zx_time_add_duration(zx_time_t time, zx_duration_t duration) {
- zx_time_t x = 0;
- if (unlikely(add_overflow(time, duration, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_time_t x = 0;
+ if (unlikely(add_overflow(time, duration, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_time_t zx_time_sub_duration(zx_time_t time, zx_duration_t duration) {
- zx_time_t x = 0;
- if (unlikely(sub_overflow(time, duration, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
-
+ zx_time_t x = 0;
+ if (unlikely(sub_overflow(time, duration, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_time_sub_time(zx_time_t time1, zx_time_t time2) {
- zx_duration_t x = 0;
- if (unlikely(sub_overflow(time1, time2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(sub_overflow(time1, time2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_add_duration(zx_duration_t dur1,
zx_duration_t dur2) {
- zx_duration_t x = 0;
- if (unlikely(add_overflow(dur1, dur2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(add_overflow(dur1, dur2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_sub_duration(zx_duration_t dur1,
zx_duration_t dur2) {
- zx_duration_t x = 0;
- if (unlikely(sub_overflow(dur1, dur2, &x))) {
- if (x >= 0) {
- return ZX_TIME_INFINITE_PAST;
- } else {
- return ZX_TIME_INFINITE;
- }
+ zx_duration_t x = 0;
+ if (unlikely(sub_overflow(dur1, dur2, &x))) {
+ if (x >= 0) {
+ return ZX_TIME_INFINITE_PAST;
+ } else {
+ return ZX_TIME_INFINITE;
}
- return x;
+ }
+ return x;
}
__CONSTEXPR static inline zx_duration_t zx_duration_mul_int64(zx_duration_t duration,
int64_t multiplier) {
- zx_duration_t x = 0;
- if (unlikely(mul_overflow(duration, multiplier, &x))) {
- if ((duration > 0 && multiplier > 0) || (duration < 0 && multiplier < 0)) {
- return ZX_TIME_INFINITE;
- } else {
- return ZX_TIME_INFINITE_PAST;
- }
+ zx_duration_t x = 0;
+ if (unlikely(mul_overflow(duration, multiplier, &x))) {
+ if ((duration > 0 && multiplier > 0) || (duration < 0 && multiplier < 0)) {
+ return ZX_TIME_INFINITE;
+ } else {
+ return ZX_TIME_INFINITE_PAST;
}
- return x;
+ }
+ return x;
}
+
+__CONSTEXPR static inline int64_t zx_nsec_from_duration(zx_duration_t n) { return n; }
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_nsec(int64_t n) {
+ return zx_duration_mul_int64(1, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_usec(int64_t n) {
+ return zx_duration_mul_int64(1000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_msec(int64_t n) {
+ return zx_duration_mul_int64(1000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_sec(int64_t n) {
+ return zx_duration_mul_int64(1000000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_min(int64_t n) {
+ return zx_duration_mul_int64(60000000000, n);
+}
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_hour(int64_t n) {
+ return zx_duration_mul_int64(3600000000000, n);
+}
+
+#if __has_include(<time.h>)
+
+__CONSTEXPR static inline zx_duration_t zx_duration_from_timespec(struct timespec ts) {
+ return zx_duration_add_duration(zx_duration_from_sec(ts.tv_sec),
+ zx_duration_from_nsec(ts.tv_nsec));
+}
+
+__CONSTEXPR static inline struct timespec zx_timespec_from_duration(zx_duration_t duration) {
+ const struct timespec ts = {
+ (time_t)(duration / 1000000000),
+ (long int)(duration % 1000000000),
+ };
+ return ts;
+}
+
+__CONSTEXPR static inline zx_time_t zx_time_from_timespec(struct timespec ts) {
+ // implicit converstion of the return type (zx_time_t and zx_duration_t are the same)
+ return zx_duration_from_timespec(ts);
+}
+
+__CONSTEXPR static inline struct timespec zx_timespec_from_time(zx_time_t time) {
+ // implicit conversion of the parameter type (zx_time_t and zx_duration_t are the same)
+ return zx_timespec_from_duration(time);
+}
+
+#endif // __has_include(<time.h>)
+
+// Similar to the functions above, these macros perform overflow-safe unit conversion. Prefer to use
+// the functions above instead of these macros.
+#define ZX_NSEC(n) (__ISCONSTANT(n) ? ((zx_duration_t)(1LL * (n))) : (zx_duration_from_nsec(n)))
+#define ZX_USEC(n) (__ISCONSTANT(n) ? ((zx_duration_t)(1000LL * (n))) : (zx_duration_from_usec(n)))
+#define ZX_MSEC(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(1000000LL * (n))) : (zx_duration_from_msec(n)))
+#define ZX_SEC(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(1000000000LL * (n))) : (zx_duration_from_sec(n)))
+#define ZX_MIN(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(60LL * 1000000000LL * (n))) : (zx_duration_from_min(n)))
+#define ZX_HOUR(n) \
+ (__ISCONSTANT(n) ? ((zx_duration_t)(3600LL * 1000000000LL * (n))) : (zx_duration_from_hour(n)))
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_TIME_H_
diff --git a/arch/x64/sysroot/include/zircon/tls.h b/arch/x64/sysroot/include/zircon/tls.h
index acacef1..91a6f43 100644
--- a/arch/x64/sysroot/include/zircon/tls.h
+++ b/arch/x64/sysroot/include/zircon/tls.h
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_TLS_
-#define ZIRCON_TLS_
+#ifndef SYSROOT_ZIRCON_TLS_
+#define SYSROOT_ZIRCON_TLS_
// These constants are part of the C/C++ ABI known to compilers for
// *-fuchsia targets. These are offsets from the thread pointer.
// This file must be includable in assembly files.
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__i386__)
-#define ZX_TLS_STACK_GUARD_OFFSET 0x10
-#define ZX_TLS_UNSAFE_SP_OFFSET 0x18
+#define ZX_TLS_STACK_GUARD_OFFSET 0x10
+#define ZX_TLS_UNSAFE_SP_OFFSET 0x18
#elif defined(__aarch64__)
-#define ZX_TLS_STACK_GUARD_OFFSET (-0x10)
-#define ZX_TLS_UNSAFE_SP_OFFSET (-0x8)
+#define ZX_TLS_STACK_GUARD_OFFSET (-0x10)
+#define ZX_TLS_UNSAFE_SP_OFFSET (-0x8)
#else
@@ -26,4 +26,4 @@
#endif
-#endif // ZIRCON_TLS_
+#endif // SYSROOT_ZIRCON_TLS_
diff --git a/arch/x64/sysroot/include/zircon/types.h b/arch/x64/sysroot/include/zircon/types.h
index 6f93626..5832d95 100644
--- a/arch/x64/sysroot/include/zircon/types.h
+++ b/arch/x64/sysroot/include/zircon/types.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ZIRCON_TYPES_H_
-#define ZIRCON_TYPES_H_
+#ifndef SYSROOT_ZIRCON_TYPES_H_
+#define SYSROOT_ZIRCON_TYPES_H_
#include <stdbool.h>
#include <stddef.h>
@@ -12,6 +12,7 @@
#include <zircon/errors.h>
#include <zircon/limits.h>
#include <zircon/rights.h>
+#include <zircon/time.h>
#ifndef __cplusplus
#ifndef _KERNEL
@@ -33,26 +34,12 @@
typedef uint32_t zx_handle_t;
-#define ZX_HANDLE_INVALID ((zx_handle_t)0)
+#define ZX_HANDLE_INVALID ((zx_handle_t)0)
+#define ZX_HANDLE_FIXED_BITS_MASK ((zx_handle_t)0x3)
// See errors.h for the values zx_status_t can take.
typedef int32_t zx_status_t;
-// absolute time in nanoseconds (generally with respect to the monotonic clock)
-typedef int64_t zx_time_t;
-// a duration in nanoseconds
-typedef int64_t zx_duration_t;
-// a duration in hardware ticks
-typedef uint64_t zx_ticks_t;
-#define ZX_TIME_INFINITE INT64_MAX
-#define ZX_TIME_INFINITE_PAST INT64_MIN
-#define ZX_NSEC(n) ((zx_duration_t)(1LL * (n)))
-#define ZX_USEC(n) ((zx_duration_t)(1000LL * (n)))
-#define ZX_MSEC(n) ((zx_duration_t)(1000000LL * (n)))
-#define ZX_SEC(n) ((zx_duration_t)(1000000000LL * (n)))
-#define ZX_MIN(n) (ZX_SEC(n) * 60LL)
-#define ZX_HOUR(n) (ZX_MIN(n) * 60LL)
-
// clock ids
typedef uint32_t zx_clock_t;
#define ZX_CLOCK_MONOTONIC ((zx_clock_t)0)
@@ -107,7 +94,7 @@
#define ZX_USER_SIGNAL_6 ((zx_signals_t)1u << 30)
#define ZX_USER_SIGNAL_7 ((zx_signals_t)1u << 31)
-// Cancelation (handle was closed while waiting with it)
+// Cancellation (handle was closed while waiting with it)
#define ZX_SIGNAL_HANDLE_CLOSED __ZX_OBJECT_HANDLE_CLOSED
// Event
@@ -124,22 +111,18 @@
#define ZX_CHANNEL_WRITABLE __ZX_OBJECT_WRITABLE
#define ZX_CHANNEL_PEER_CLOSED __ZX_OBJECT_PEER_CLOSED
+// Clock
+#define ZX_CLOCK_STARTED __ZX_OBJECT_SIGNAL_4
+
// Socket
#define ZX_SOCKET_READABLE __ZX_OBJECT_READABLE
#define ZX_SOCKET_WRITABLE __ZX_OBJECT_WRITABLE
#define ZX_SOCKET_PEER_CLOSED __ZX_OBJECT_PEER_CLOSED
#define ZX_SOCKET_PEER_WRITE_DISABLED __ZX_OBJECT_SIGNAL_4
#define ZX_SOCKET_WRITE_DISABLED __ZX_OBJECT_SIGNAL_5
-#define ZX_SOCKET_CONTROL_READABLE __ZX_OBJECT_SIGNAL_6
-#define ZX_SOCKET_CONTROL_WRITABLE __ZX_OBJECT_SIGNAL_7
-#define ZX_SOCKET_ACCEPT __ZX_OBJECT_SIGNAL_8
-#define ZX_SOCKET_SHARE __ZX_OBJECT_SIGNAL_9
#define ZX_SOCKET_READ_THRESHOLD __ZX_OBJECT_SIGNAL_10
#define ZX_SOCKET_WRITE_THRESHOLD __ZX_OBJECT_SIGNAL_11
-// Deprecated
-#define ZX_SOCKET_READ_DISABLED ZX_SOCKET_PEER_WRITE_DISABLED
-
// Fifo
#define ZX_FIFO_READABLE __ZX_OBJECT_READABLE
#define ZX_FIFO_WRITABLE __ZX_OBJECT_WRITABLE
@@ -149,8 +132,9 @@
#define ZX_TASK_TERMINATED __ZX_OBJECT_SIGNALED
// Job
-#define ZX_JOB_NO_PROCESSES __ZX_OBJECT_SIGNALED
+#define ZX_JOB_TERMINATED __ZX_OBJECT_SIGNALED
#define ZX_JOB_NO_JOBS __ZX_OBJECT_SIGNAL_4
+#define ZX_JOB_NO_PROCESSES __ZX_OBJECT_SIGNAL_5
// Process
#define ZX_PROCESS_TERMINATED __ZX_OBJECT_SIGNALED
@@ -173,28 +157,15 @@
// global kernel object id.
// Note: kernel object ids use 63 bits, with the most significant bit being zero.
// The remaining values (msb==1) are for use by programs and tools that wish to
-// create koids for artificial objets.
+// create koids for artificial objects.
typedef uint64_t zx_koid_t;
#define ZX_KOID_INVALID ((uint64_t) 0)
#define ZX_KOID_KERNEL ((uint64_t) 1)
-
-// Transaction ID and argument types for zx_channel_call.
-typedef uint32_t zx_txid_t;
-
-typedef struct zx_channel_call_args {
- const void* wr_bytes;
- const zx_handle_t* wr_handles;
- void *rd_bytes;
- zx_handle_t* rd_handles;
- uint32_t wr_num_bytes;
- uint32_t wr_num_handles;
- uint32_t rd_num_bytes;
- uint32_t rd_num_handles;
-} zx_channel_call_args_t;
+// The first non-reserved koid. The first 1024 are reserved.
+#define ZX_KOID_FIRST ((uint64_t) 1024)
// Maximum number of wait items allowed for zx_object_wait_many()
-// TODO(ZX-1349) Re-lower this.
-#define ZX_WAIT_MANY_MAX_ITEMS ((size_t)16)
+#define ZX_WAIT_MANY_MAX_ITEMS ((size_t)64)
// Structure for zx_object_wait_many():
typedef struct zx_wait_item {
@@ -204,10 +175,11 @@
} zx_wait_item_t;
// VM Object creation options
-#define ZX_VMO_NON_RESIZABLE ((uint32_t)1u)
+#define ZX_VMO_RESIZABLE ((uint32_t)1u << 1)
// VM Object opcodes
#define ZX_VMO_OP_COMMIT ((uint32_t)1u)
+// Keep value in sync with ZX_VMAR_OP_DECOMMIT.
#define ZX_VMO_OP_DECOMMIT ((uint32_t)2u)
#define ZX_VMO_OP_LOCK ((uint32_t)3u)
#define ZX_VMO_OP_UNLOCK ((uint32_t)4u)
@@ -216,10 +188,26 @@
#define ZX_VMO_OP_CACHE_INVALIDATE ((uint32_t)7u)
#define ZX_VMO_OP_CACHE_CLEAN ((uint32_t)8u)
#define ZX_VMO_OP_CACHE_CLEAN_INVALIDATE ((uint32_t)9u)
+#define ZX_VMO_OP_ZERO ((uint32_t)10u)
+
+// VMAR opcodes
+// Keep value in sync with ZX_VMO_OP_DECOMMIT.
+#define ZX_VMAR_OP_DECOMMIT ((uint32_t)2u)
+#define ZX_VMAR_OP_MAP_RANGE ((uint32_t)3u)
+
+// Pager opcodes
+#define ZX_PAGER_OP_FAIL ((uint32_t)1u)
// VM Object clone flags
-#define ZX_VMO_CLONE_COPY_ON_WRITE ((uint32_t)1u << 0)
-#define ZX_VMO_CLONE_NON_RESIZEABLE ((uint32_t)1u << 1)
+#define ZX_VMO_CHILD_SNAPSHOT ((uint32_t)1u << 0)
+#define ZX_VMO_CHILD_SNAPSHOT_AT_LEAST_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_RESIZABLE ((uint32_t)1u << 2)
+#define ZX_VMO_CHILD_SLICE ((uint32_t)1u << 3)
+#define ZX_VMO_CHILD_NO_WRITE ((uint32_t)1u << 5)
+// Old clone flags that are on the path to deprecation.
+#define ZX_VMO_CLONE_COPY_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_COPY_ON_WRITE ((uint32_t)1u << 4)
+#define ZX_VMO_CHILD_PRIVATE_PAGER_COPY ((uint32_t)1u << 4)
typedef uint32_t zx_vm_option_t;
// Mapping flags to vmar routines
@@ -235,7 +223,33 @@
#define ZX_VM_CAN_MAP_EXECUTE ((zx_vm_option_t)(1u << 9))
#define ZX_VM_MAP_RANGE ((zx_vm_option_t)(1u << 10))
#define ZX_VM_REQUIRE_NON_RESIZABLE ((zx_vm_option_t)(1u << 11))
+#define ZX_VM_ALLOW_FAULTS ((zx_vm_option_t)(1u << 12))
+#define ZX_VM_OFFSET_IS_UPPER_LIMIT ((zx_vm_option_t)(1u << 13))
+#define ZX_VM_ALIGN_BASE 24
+#define ZX_VM_ALIGN_1KB ((zx_vm_option_t)(10u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2KB ((zx_vm_option_t)(11u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4KB ((zx_vm_option_t)(12u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_8KB ((zx_vm_option_t)(13u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_16KB ((zx_vm_option_t)(14u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_32KB ((zx_vm_option_t)(15u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_64KB ((zx_vm_option_t)(16u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_128KB ((zx_vm_option_t)(17u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_256KB ((zx_vm_option_t)(18u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_512KB ((zx_vm_option_t)(19u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_1MB ((zx_vm_option_t)(20u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2MB ((zx_vm_option_t)(21u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4MB ((zx_vm_option_t)(22u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_8MB ((zx_vm_option_t)(23u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_16MB ((zx_vm_option_t)(24u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_32MB ((zx_vm_option_t)(25u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_64MB ((zx_vm_option_t)(26u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_128MB ((zx_vm_option_t)(27u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_256MB ((zx_vm_option_t)(28u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_512MB ((zx_vm_option_t)(29u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_1GB ((zx_vm_option_t)(30u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_2GB ((zx_vm_option_t)(31u << ZX_VM_ALIGN_BASE))
+#define ZX_VM_ALIGN_4GB ((zx_vm_option_t)(32u << ZX_VM_ALIGN_BASE))
// virtual address
typedef uintptr_t zx_vaddr_t;
@@ -250,14 +264,22 @@
// offset
typedef uint64_t zx_off_t;
+// vectorized I/O
+typedef struct zx_iovec {
+ void* buffer;
+ size_t capacity;
+} zx_iovec_t;
+
// Maximum string length for kernel names (process name, thread name, etc)
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
#define ZX_MAX_NAME_LEN ((size_t)32u)
// Buffer size limits on the cprng syscalls
#define ZX_CPRNG_DRAW_MAX_LEN ((size_t)256u)
#define ZX_CPRNG_ADD_ENTROPY_MAX_LEN ((size_t)256u)
-// interrupt bind flags
+// interrupt_create flags
#define ZX_INTERRUPT_REMAP_IRQ ((uint32_t)0x1u)
#define ZX_INTERRUPT_MODE_DEFAULT ((uint32_t)0u << 1)
#define ZX_INTERRUPT_MODE_EDGE_LOW ((uint32_t)1u << 1)
@@ -268,35 +290,58 @@
#define ZX_INTERRUPT_MODE_MASK ((uint32_t)0xe)
#define ZX_INTERRUPT_VIRTUAL ((uint32_t)0x10)
+// interrupt_bind flags
+#define ZX_INTERRUPT_BIND ((uint32_t)0x0u)
+#define ZX_INTERRUPT_UNBIND ((uint32_t)0x1u)
+
// Preallocated virtual interrupt slot, typically used for signaling interrupt threads to exit.
#define ZX_INTERRUPT_SLOT_USER ((uint32_t)62u)
// interrupt wait slots must be in the range 0 - 62 inclusive
#define ZX_INTERRUPT_MAX_SLOTS ((uint32_t)62u)
+// msi_create flags
+#define ZX_MSI_MODE_MSI_X ((uint32_t)0x1u)
+
// PCI interrupt handles use interrupt slot 0 for the PCI hardware interrupt
#define ZX_PCI_INTERRUPT_SLOT ((uint32_t)0u)
// Channel options and limits.
#define ZX_CHANNEL_READ_MAY_DISCARD ((uint32_t)1u)
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
#define ZX_CHANNEL_MAX_MSG_BYTES ((uint32_t)65536u)
#define ZX_CHANNEL_MAX_MSG_HANDLES ((uint32_t)64u)
+// Fifo limits.
+#define ZX_FIFO_MAX_SIZE_BYTES ZX_PAGE_SIZE
+
// Socket options and limits.
-// These options can be passed to zx_socket_shutdown()
+// These options can be passed to zx_socket_shutdown().
#define ZX_SOCKET_SHUTDOWN_WRITE ((uint32_t)1u << 0)
#define ZX_SOCKET_SHUTDOWN_READ ((uint32_t)1u << 1)
#define ZX_SOCKET_SHUTDOWN_MASK (ZX_SOCKET_SHUTDOWN_WRITE | ZX_SOCKET_SHUTDOWN_READ)
-// These can be passed to zx_socket_create()
+// These can be passed to zx_socket_create().
#define ZX_SOCKET_STREAM ((uint32_t)0u)
#define ZX_SOCKET_DATAGRAM ((uint32_t)1u << 0)
-#define ZX_SOCKET_HAS_CONTROL ((uint32_t)1u << 1)
-#define ZX_SOCKET_HAS_ACCEPT ((uint32_t)1u << 2)
-#define ZX_SOCKET_CREATE_MASK (ZX_SOCKET_DATAGRAM | ZX_SOCKET_HAS_CONTROL | ZX_SOCKET_HAS_ACCEPT)
+#define ZX_SOCKET_CREATE_MASK (ZX_SOCKET_DATAGRAM)
-// These can be passed to zx_socket_read() and zx_socket_write().
-#define ZX_SOCKET_CONTROL ((uint32_t)1u << 2)
+// These can be passed to zx_socket_read().
+#define ZX_SOCKET_PEEK ((uint32_t)1u << 3)
+
+// These can be passed to zx_stream_create().
+#define ZX_STREAM_MODE_READ ((uint32_t)1u << 0)
+#define ZX_STREAM_MODE_WRITE ((uint32_t)1u << 1)
+#define ZX_STREAM_CREATE_MASK (ZX_STREAM_MODE_READ | ZX_STREAM_MODE_WRITE)
+
+// These can be passed to zx_stream_writev().
+#define ZX_STREAM_APPEND ((uint32_t)1u << 0)
+
+typedef uint32_t zx_stream_seek_origin_t;
+#define ZX_STREAM_SEEK_ORIGIN_START ((zx_stream_seek_origin_t)0u)
+#define ZX_STREAM_SEEK_ORIGIN_CURRENT ((zx_stream_seek_origin_t)1u)
+#define ZX_STREAM_SEEK_ORIGIN_END ((zx_stream_seek_origin_t)2u)
// Flags which can be used to to control cache policy for APIs which map memory.
#define ZX_CACHE_POLICY_CACHED ((uint32_t)0u)
@@ -316,11 +361,15 @@
#define ZX_TIMER_SLACK_LATE ((uint32_t)2u)
// Bus Transaction Initiator options.
-#define ZX_BTI_PERM_READ ((uint32_t)1u << 0)
-#define ZX_BTI_PERM_WRITE ((uint32_t)1u << 1)
-#define ZX_BTI_PERM_EXECUTE ((uint32_t)1u << 2)
-#define ZX_BTI_COMPRESS ((uint32_t)1u << 3)
-#define ZX_BTI_CONTIGUOUS ((uint32_t)1u << 4)
+#define ZX_BTI_PERM_READ ((uint32_t)1u << 0)
+#define ZX_BTI_PERM_WRITE ((uint32_t)1u << 1)
+#define ZX_BTI_PERM_EXECUTE ((uint32_t)1u << 2)
+#define ZX_BTI_COMPRESS ((uint32_t)1u << 3)
+#define ZX_BTI_CONTIGUOUS ((uint32_t)1u << 4)
+
+// Job options.
+// These options can be passed to zx_job_set_critical().
+#define ZX_JOB_CRITICAL_PROCESS_RETCODE_NONZERO ((uint32_t)1u << 0)
typedef uint32_t zx_obj_type_t;
@@ -349,8 +398,25 @@
#define ZX_OBJ_TYPE_PMT ((zx_obj_type_t)26u)
#define ZX_OBJ_TYPE_SUSPEND_TOKEN ((zx_obj_type_t)27u)
#define ZX_OBJ_TYPE_PAGER ((zx_obj_type_t)28u)
-#define ZX_OBJ_TYPE_LAST ((zx_obj_type_t)29u)
+#define ZX_OBJ_TYPE_EXCEPTION ((zx_obj_type_t)29u)
+#define ZX_OBJ_TYPE_CLOCK ((zx_obj_type_t)30u)
+#define ZX_OBJ_TYPE_STREAM ((zx_obj_type_t)31u)
+#define ZX_OBJ_TYPE_MSI_ALLOCATION ((zx_obj_type_t)32u)
+#define ZX_OBJ_TYPE_MSI_INTERRUPT ((zx_obj_type_t)33u)
+// System ABI commits to having no more than 64 object types.
+//
+// See zx_info_process_handle_stats_t for an example of a binary interface that
+// depends on having an upper bound for the number of object types.
+#define ZX_OBJ_TYPE_UPPER_BOUND ((zx_obj_type_t)64u)
+
+typedef uint32_t zx_system_event_type_t;
+#define ZX_SYSTEM_EVENT_OUT_OF_MEMORY ((zx_system_event_type_t)1u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_CRITICAL ((zx_system_event_type_t)2u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_WARNING ((zx_system_event_type_t)3u)
+#define ZX_SYSTEM_EVENT_MEMORY_PRESSURE_NORMAL ((zx_system_event_type_t)4u)
+
+// Used in channel_read_etc.
typedef struct zx_handle_info {
zx_handle_t handle;
zx_obj_type_t type;
@@ -358,6 +424,45 @@
uint32_t unused;
} zx_handle_info_t;
+typedef uint32_t zx_handle_op_t;
+
+#define ZX_HANDLE_OP_MOVE ((zx_handle_op_t)0u)
+#define ZX_HANDLE_OP_DUPLICATE ((zx_handle_op_t)1u)
+
+// Used in channel_write_etc.
+typedef struct zx_handle_disposition {
+ zx_handle_op_t operation;
+ zx_handle_t handle;
+ zx_obj_type_t type;
+ zx_rights_t rights;
+ zx_status_t result;
+} zx_handle_disposition_t;
+
+// Transaction ID and argument types for zx_channel_call.
+typedef uint32_t zx_txid_t;
+
+typedef struct zx_channel_call_args {
+ const void* wr_bytes;
+ const zx_handle_t* wr_handles;
+ void *rd_bytes;
+ zx_handle_t* rd_handles;
+ uint32_t wr_num_bytes;
+ uint32_t wr_num_handles;
+ uint32_t rd_num_bytes;
+ uint32_t rd_num_handles;
+} zx_channel_call_args_t;
+
+typedef struct zx_channel_call_etc_args {
+ const void* wr_bytes;
+ zx_handle_disposition_t* wr_handles;
+ void *rd_bytes;
+ zx_handle_info_t* rd_handles;
+ uint32_t wr_num_bytes;
+ uint32_t wr_num_handles;
+ uint32_t rd_num_bytes;
+ uint32_t rd_num_handles;
+} zx_channel_call_etc_args_t;
+
// The ZX_VM_FLAG_* constants are to be deprecated in favor of the ZX_VM_*
// versions.
#define ZX_VM_FLAG_PERM_READ ((uint32_t)1u << 0)
@@ -373,6 +478,24 @@
#define ZX_VM_FLAG_MAP_RANGE ((uint32_t)1u << 10)
#define ZX_VM_FLAG_REQUIRE_NON_RESIZABLE ((uint32_t)1u << 11)
+// CPU masks specifying sets of CPUs.
+//
+// We currently are limited to systems with 512 CPUs or less.
+// TODO(fxbug.dev/7802): This must be manually kept in sync with zx_common.fidl.
+// Eventually (some of) this file will be generated from //zircon/vdso.
+#define ZX_CPU_SET_MAX_CPUS 512
+#define ZX_CPU_SET_BITS_PER_WORD 64
+
+typedef struct zx_cpu_set {
+ // The |N|'th CPU is considered in the CPU set if the bit:
+ //
+ // cpu_mask[N / ZX_CPU_SET_BITS_PER_WORD]
+ // & (1 << (N % ZX_CPU_SET_BITS_PER_WORD))
+ //
+ // is set.
+ uint64_t mask[ZX_CPU_SET_MAX_CPUS / ZX_CPU_SET_BITS_PER_WORD];
+} zx_cpu_set_t;
+
#ifdef __cplusplus
// We cannot use <stdatomic.h> with C++ code as _Atomic qualifier defined by
// C11 is not valid in C++11. There is not a single standard name that can
@@ -389,7 +512,8 @@
typedef atomic_int zx_futex_t;
#endif
#endif
+typedef int zx_futex_storage_t;
__END_CDECLS
-#endif // ZIRCON_TYPES_H_
+#endif // SYSROOT_ZIRCON_TYPES_H_
diff --git a/arch/x64/sysroot/include/zircon/utc.h b/arch/x64/sysroot/include/zircon/utc.h
new file mode 100644
index 0000000..180fd50
--- /dev/null
+++ b/arch/x64/sysroot/include/zircon/utc.h
@@ -0,0 +1,71 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYSROOT_ZIRCON_UTC_H_
+#define SYSROOT_ZIRCON_UTC_H_
+
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// Accessors for the Zircon-specific UTC clock reference maintained by the
+// language runtime
+
+// zx_utc_reference_get
+//
+// Returns a handle to the currently assigned UTC clock, or ZX_HANDLE_INVALID if
+// no such clock currently exists. The handle returned has borrow semantics,
+// and should never be directly closed by the user. If a program wishes to take
+// ownership of the clock, it should do so using |zx_utc_reference_swap|.
+//
+// Thread safety is the responsibility of the user. In particular, if a clock
+// is fetched by a user using |zx_utc_reference_get|, but then the clock is
+// swapped out using |zx_utc_reference_swap| and the original clock is closed,
+// then the initial clock handle returned is now invalid and could result in a
+// use-after-close situation. It is the user's responsibility to avoid these
+// situations.
+//
+zx_handle_t _zx_utc_reference_get(void);
+zx_handle_t zx_utc_reference_get(void);
+
+// zx_utc_reference_swap
+//
+// Atomically swap the clock handle provided with the current UTC reference.
+//
+// Upon success, the runtime takes ownership of the handle provided by
+// |new_utc_reference| and returns the previous clock handle to the caller via
+// |prev_utc_reference_out|, or ZX_HANDLE_INVALID if no clock was currently
+// assigned. The clock returned via swap is now owned by the caller.
+//
+// In the case of failure, the handle passed in by new_utc_reference will be
+// consumed, and the clock held by the runtime will remain unchanged.
+//
+// Clock handles provided to libc via zx_utc_reference_swap must have read rights
+// or they will be rejected.
+//
+// Parameters:
+// new_utc_reference : A handle to the clock to install as the UTC reference.
+// Ownership of this handle will _always_ be consumed
+// by zx_utc_reference_swap.
+// prev_utc_reference_out : Either the handle to the previous UTC clock (success
+// case), or ZX_HANDLE_INVALID in the case of failure.
+// If a valid handle is returned in this out parameter,
+// it is _always_ owned by the caller after the call.
+// It is illegal to pass NULL for this parameter.
+//
+//
+// Return Values:
+// If a new clock reference is being provided, the return value of
+// |zx_utc_reference_swap| will be the result of a |zx_clock_read| call made to
+// verify the clock. If ZX_HANDLE_INVALID was passed in order to uninstall a
+// reference clock, the function cannot fail and will always return ZX_OK.
+//
+zx_status_t _zx_utc_reference_swap(zx_handle_t new_utc_reference,
+ zx_handle_t* prev_utc_reference_out) __NONNULL((2));
+zx_status_t zx_utc_reference_swap(zx_handle_t new_utc_reference,
+ zx_handle_t* prev_utc_reference_out) __NONNULL((2));
+
+__END_CDECLS
+
+#endif // SYSROOT_ZIRCON_UTC_H_
diff --git a/arch/x64/sysroot/lib/Scrt1.o b/arch/x64/sysroot/lib/Scrt1.o
index ca35323..2a0286c 100644
--- a/arch/x64/sysroot/lib/Scrt1.o
+++ b/arch/x64/sysroot/lib/Scrt1.o
Binary files differ
diff --git a/arch/x64/sysroot/lib/libc.so b/arch/x64/sysroot/lib/libc.so
index 4989bef..f74a2c3 100755
--- a/arch/x64/sysroot/lib/libc.so
+++ b/arch/x64/sysroot/lib/libc.so
Binary files differ
diff --git a/arch/x64/sysroot/lib/libzircon.so b/arch/x64/sysroot/lib/libzircon.so
index 49b147a..26c8f72 100755
--- a/arch/x64/sysroot/lib/libzircon.so
+++ b/arch/x64/sysroot/lib/libzircon.so
Binary files differ
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 0000000..aa2e88c
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,13 @@
+# Documentation
+
+## General
+
+For general information about this SDK, see the [root README](../README.md).
+
+
+## Workflows
+
+- [Creating and deploying Fuchsia packages](packages.md)
+- [Communicating with target devices](devices.md)
+- [Creating and consuming logs](logging.md)
+- [Debugging native code](debugger.md)
diff --git a/docs/bootserver.md b/docs/bootserver.md
index a61d09b..d8ebb67 100644
--- a/docs/bootserver.md
+++ b/docs/bootserver.md
@@ -1,22 +1,47 @@
# Bootserver
The `bootserver` host tool can be used to pave, netboot or boot Fuchsia on a
-target device. This tool is very likely to go away in the short future with
-a replacement being currently implemented.
-
+target device. It serves the needed image artifacts to the device, as well
+as performs validations that the images/device are both valid and
+compatible. Lastly, it signals the device to begin the boot process.
## x64
-To pave and boot on an `x64` target, run:
+### Generic
+
+To pave and boot on a generic `x64` target, run:
```
-bootserver --efi "<IMAGE_PATH>/local.esp.blk" --fvm "<IMAGE_PATH>/fvm.sparse.blk" --kernc "<IMAGE_PATH>/zircon.vboot" --zircona "<IMAGE_PATH>/fuchsia.zbi" "<IMAGE_PATH>/fuchsia.zbi" -1
+bootserver \
+ --boot "$IMAGES_PATH/fuchsia.zbi" \
+ --bootloader "$IMAGES_PATH/fuchsia.esp.blk" \
+ --fvm "$IMAGES_PATH/obj/build/images/fvm.sparse.blk" \
+ --zircona "$IMAGES_PATH/fuchsia.zbi" \
+ --zirconr "$IMAGES_PATH/zedboot.zbi"
```
+### Chromebook
+
+To pave and boot on a `chromebook` target, run:
+
+
+```
+bootserver \
+ --boot "$IMAGES_PATH/fuchsia.zbi" \
+ --fvm "$IMAGES_PATH/obj/build/images/fvm.sparse.blk" \
+ --zircona "$IMAGES_PATH/fuchsia.zbi.vboot" \
+ --zirconr "$IMAGES_PATH/zedboot.vboot"
+```
+
+
## arm64
To pave and boot on an `arm64` target, run:
```
-bootserver --fvm "<IMAGE_PATH>/obj/build/images/fvm.sparse.blk" --zircona "<IMAGE_PATH>/fuchsia.zbi" --zirconb "<IMAGE_PATH>/fuchsia.zbi" -1
+bootserver \
+ --boot "$IMAGES_PATH/fuchsia.zbi" \
+ --fvm "$IMAGES_PATH/obj/build/images/fvm.sparse.blk" \
+ --zircona "$IMAGES_PATH/fuchsia.zbi" \
+ --zirconr "$IMAGES_PATH/zedboot.zbi"
```
diff --git a/docs/compilation.md b/docs/compilation.md
new file mode 100644
index 0000000..dcf9c71
--- /dev/null
+++ b/docs/compilation.md
@@ -0,0 +1,41 @@
+# Compiling C/C++ code
+
+The present document compiles a list of guidelines, recommendations, and
+expectations around the topic of compiling C and C++ code against the Core SDK.
+
+
+## Sysroot
+
+The Fuchsia sysroot for a given target architecture is available under
+`//arch/<architecture>/sysroot`.
+That directory contains a complete sysroot and may be used with any tool that
+accepts a `--sysroot` flag.
+
+
+## Prebuilts
+
+All prebuilts have C linkage.
+
+### Debug symbols
+
+Debug symbols for all prebuilts are available under `//.build-id`, which follows
+a [standard convention][build-id].
+
+
+## Compilation parameters
+
+- C++ sources are compatible with both C++14 and C++17.
+
+### Warning flags
+
+The following flags are guaranteed to not generate any warning:
+- `-Wall`
+- `-Wextra-semi`
+- `-Wnewline-eof`
+- `-Wshadow`
+
+The following flags may generate warnings:
+- `-Wdeprecated-declarations`
+
+
+[build-id]: https://fedoraproject.org/wiki/Releases/FeatureBuildId#Find_files_by_build_ID
diff --git a/docs/debugger.md b/docs/debugger.md
new file mode 100644
index 0000000..65a4966
--- /dev/null
+++ b/docs/debugger.md
@@ -0,0 +1,45 @@
+# Debugger (zxdb)
+
+Zxdb is a console debugger for native code compiled with DWARF symbols (C, C++
+and Rust). The frontend runs on the host computer and connects to the on-device
+`debug_agent`. This document describes how to set up these processes.
+
+## Running the agent
+
+The `debug_agent` is run on the target device along with the port number that
+it should listen to for incoming client connections. Typically this command
+will be run from a console after [ssh-ing](ssh.md) in to the system:
+
+```
+run fuchsia-pkg://fuchsia.com/debug_agent#meta/debug_agent.cmx --port=2345
+```
+
+## Connecting the client
+
+The `zxdb` client program is run on the host computer. It can be connected to
+the `debug_agent` via the interactive `connect` debugger command or it can
+automatically connect based on a command-line flag. Both IPv4 and IPv6
+addresses are supported (see [device discovery](device_discovery.md) to find
+the address). The port should match the port number passed to the agent.
+
+```
+zxdb -c "[f370::5051:ff:1e53:589a%qemu]:2345"
+```
+
+### Connecting via a script
+
+Scripts may want to automatically launch the agent and client automatically.
+The script should wait for the port to be open on the target system before
+launching the client. Automatic retry is not yet implemented in the client.
+
+To clean up the debug agent gracefully when the client exits, pass the
+`--quit-agent-on-exit` command-line flag to the client.
+
+## Specifying symbol paths
+
+The debugger expects unstripped ELF files to be available on the local host
+system. Symbols on the target are not used. The location where the local build
+stores symbols must be passed to the `zxdb` client.
+
+For more information on how to specify symbol paths, see [set the symbol
+location](/docs/development/debugger/README.md#set-symbol-location)
diff --git a/docs/device_discovery.md b/docs/device_discovery.md
new file mode 100644
index 0000000..3906f3a
--- /dev/null
+++ b/docs/device_discovery.md
@@ -0,0 +1,61 @@
+# `device-finder`
+
+`device-finder` is the command line tool for device discovery. It uses mDNS to
+find Fuchsia devices.
+
+Currently only Linux is supported. For Mac users see the section
+[for Mac Users](#for_mac_users).
+
+## For Linux Users
+
+### Finding all Devices
+
+The simplest way to get all the devices on the network by their address is to
+run
+
+```
+$ ./device-finder list
+192.168.42.156
+```
+
+This will give you the addresses of all Fuchsia devices on the network. If you'd
+like to get their hostnames as well as their addresses, you can include the
+`-full` flag.
+
+### Finding devices by hostname
+
+If you'd like to find your device by its unique hostname (e.g.
+`lunch-feta-stool-woozy`) you can use the `resolve` command:
+
+```
+$ ./device-finder resolve lunch-feta-stool-woozy
+192.168.42.156
+```
+
+### Finding the Interface Connected to the Device
+
+To find the interface connected to the device, include the `-local` flag to
+either the `list` command or the `resolve` command, which will give you the
+address that the Fuchsia device can use to connect to your host.
+
+## For Mac Users
+
+For those on Mac hosts, you can use the included `dns-sd` command to find your
+device. Here's an example command along with the output you should see when a
+device is on your network:
+
+```
+$ dns-sd -B _fuchsia._udp .
+Browsing for _fuchsia._udp
+DATE: ---Fri 14 Dec 2018---
+15:28:21.447 ...STARTING...
+Timestamp A/R Flags if Domain Service Type Instance Name
+15:28:21.448 Add 2 7 local. _fuchsia._udp. quake-agile-lurk-even
+```
+
+Mac does not support the equivalent of a `local` flag as described above in the
+`device-finder` docs.
+
+## For additional help
+
+For additional help using any of the `device-finder` subcommands, run the subcommand with the `-help` flag.
diff --git a/docs/devices.md b/docs/devices.md
new file mode 100644
index 0000000..c28d982
--- /dev/null
+++ b/docs/devices.md
@@ -0,0 +1,29 @@
+# Working with target devices
+
+## Connecting to a device
+
+Fuchsia target devices must be connected to a host device via a network link.
+SSH is the protocol for communications over that link, as described in
+[this document](ssh.md).
+
+### Getting the device address
+
+Getting the Fuchsia device address can be done using mDNS. Methods for device
+discovery are outlined in [this document](device_discovery.md)
+
+## Flashing a device
+
+In order to flash a device, start a [bootserver](bootserver.md) on the host and
+restart the device into its bootloader.
+
+## Installing software onto a device
+
+The unit of installation on Fuchsia is a package.
+For information on how to push packages to a Fuchsia device, see the
+[this document](packages.md).
+
+## Getting logs from a device
+
+In order to retrieve logs from a device, open a shell on the device and run the
+`log_listener` command, which provides various filtering knobs. See
+[this page](logging.md) for more details.
diff --git a/docs/logging.md b/docs/logging.md
new file mode 100644
index 0000000..660e448
--- /dev/null
+++ b/docs/logging.md
@@ -0,0 +1,27 @@
+# Logging
+
+The preferred way to publish logs is to use the `syslog` API, currently
+available for C in `//pkg/syslog`.
+
+The library provides the ability to tag logs so that they can later be filtered
+upon retrieval.
+
+In order to get logs from a device, open a shell on the device as described in
+[this document](ssh.md) and run:
+```
+$ log_listener
+```
+
+To view specifics logs, add a tag specification:
+```
+$ log_listener --tag foobar
+```
+
+## Symbolization
+
+`//tools/symbolize` should be used to symbolize stack traces. It should be
+pointed to the `.build-id` directory at the root of the SDK, where debug symbols
+are hosted:
+```
+tools/symbolize --build-id-dir .build-id
+```
diff --git a/docs/low_level.json b/docs/low_level.json
index 55793d6..4f48575 100644
--- a/docs/low_level.json
+++ b/docs/low_level.json
@@ -1,10 +1,16 @@
{
"docs": [
- "docs/ssh.md",
- "docs/bootserver.md",
- "docs/packages.md"
- ],
- "name": "low_level",
- "root": "docs",
+ "README.md",
+ "docs/README.md",
+ "docs/bootserver.md",
+ "docs/compilation.md",
+ "docs/debugger.md",
+ "docs/device_discovery.md",
+ "docs/devices.md",
+ "docs/logging.md",
+ "docs/packages.md",
+ "docs/ssh.md"
+ ],
+ "name": "low_level",
"type": "documentation"
}
\ No newline at end of file
diff --git a/docs/metadata_schemas.json b/docs/metadata_schemas.json
index 7eaf414..d460e24 100644
--- a/docs/metadata_schemas.json
+++ b/docs/metadata_schemas.json
@@ -1,18 +1,18 @@
{
"docs": [
- "meta/schemas/cc_prebuilt_library.json",
- "meta/schemas/cc_source_library.json",
- "meta/schemas/common.json",
- "meta/schemas/dart_library.json",
- "meta/schemas/documentation.json",
- "meta/schemas/fidl_library.json",
- "meta/schemas/host_tool.json",
- "meta/schemas/image.json",
- "meta/schemas/loadable_module.json",
- "meta/schemas/manifest.json",
+ "meta/schemas/cc_prebuilt_library.json",
+ "meta/schemas/cc_source_library.json",
+ "meta/schemas/common.json",
+ "meta/schemas/dart_library.json",
+ "meta/schemas/data.json",
+ "meta/schemas/device_profile.json",
+ "meta/schemas/documentation.json",
+ "meta/schemas/fidl_library.json",
+ "meta/schemas/host_tool.json",
+ "meta/schemas/loadable_module.json",
+ "meta/schemas/manifest.json",
"meta/schemas/sysroot.json"
- ],
- "name": "metadata_schemas",
- "root": "docs",
+ ],
+ "name": "metadata_schemas",
"type": "documentation"
}
\ No newline at end of file
diff --git a/docs/musl_license.json b/docs/musl_license.json
new file mode 100644
index 0000000..e2121e9
--- /dev/null
+++ b/docs/musl_license.json
@@ -0,0 +1,7 @@
+{
+ "docs": [
+ "COPYRIGHT.musl"
+ ],
+ "name": "musl_license",
+ "type": "documentation"
+}
\ No newline at end of file
diff --git a/docs/open_source.json b/docs/open_source.json
new file mode 100644
index 0000000..376bda4
--- /dev/null
+++ b/docs/open_source.json
@@ -0,0 +1,9 @@
+{
+ "docs": [
+ "AUTHORS",
+ "LICENSE",
+ "PATENTS"
+ ],
+ "name": "open_source",
+ "type": "documentation"
+}
\ No newline at end of file
diff --git a/docs/packages.md b/docs/packages.md
index eece00a..b230a7f 100644
--- a/docs/packages.md
+++ b/docs/packages.md
@@ -6,60 +6,156 @@
_To be added..._
-## Building a package
+## Working with packages
-The majority of this process relies on a tool called `pm` which is available
-under `//tools`.
-This document describes the various steps to generate a package. For more
-details about each step, see `pm`'s help messages.
+The majority of these instructions rely on the `pm` tool which is available
+in `//tools`.
-The initial step is to create a manifest file `$MANIFEST_FILE` describing the
-contents of the package.
-The manifest is a mere list of lines of the form `destination=source`, where
-`source` is the path to the file on the host machine and `destination` the
-location of that file in the final package.
+This document describes the various steps to build and install a package:
-The manifest must include at least one line for the package identity file:
-```
-meta/package=path/to/generated/package.json
-```
-This identity file should contain the following data:
-```
-{
- "name": "<package name",
- "version": "<package version>"
-}
-```
-That file can be created using the `pm init` command.
+* [Build a package](#build-package)
+* [Publish a package](#publish-package)
+* [Install a package](#install-package)
+* [Run a component from an installed package](#run-component)
-From this point on, we are going to use `$PACKAGE_DIR` to denote a staging dir
-where the package is going to be built.
+For more details about each step, see `pm`'s help messages.
-First, we need to initialize the package with:
-```
-pm -o $PACKAGE_DIR -n $PACKAGE_NAME init
-```
+### Build a package {#build-package}
-In order to create the package, a signing key is required. You may provide your
-own key or generate one at `$SIGNING_KEY` with:
-```
-pm -o $PACKAGE_DIR -k $SIGNING_KEY genkey
-```
-_TODO: add more details about signing keys, possibly in pm's help_
+To build a package:
-The next step is to generate an archive with the package's metadata:
-```
-pm -o $PACKAGE_DIR -k $SIGNING_KEY -m $MANIFEST_FILE build
-```
-This will create the metadata archive at `$PACKAGE_DIR/meta.far`.
+1. Create the package ID file:
-Finally, we put it all together to generate the package itself:
-```
-pm -o $PACKAGE_DIR -k $SIGNING_KEY -m $MANIFEST_FILE archive
-```
-This will create the package archive at `$PACKAGE_DIR/$PACKAGE_NAME-0.far`.
-Note that this step needs to be re-run if the contents of the package change.
+ Note: `$PACKAGE_DIR` is a staging directory where the package
+ is built.
-## Deploying a package
+ ```
+ pm -o $PACKAGE_DIR -n $PACKAGE_NAME init
+ ```
-_To be added..._
+ This generates the package ID file implicitly as
+ `$PACKAGE_DIR/meta/package`. Set `$PACKAGE_ID_FILE` accordingly
+ for use in subsequent steps:
+
+ ```
+ export PACKAGE_ID_FILE=${PACKAGE_DIR}/meta/package
+ ```
+
+ `$PACKAGE_ID_FILE` will contain the following data:
+
+ ```
+ {
+ "name": "<package name>",
+ "version": "<package version>"
+ }
+ ```
+
+2. Create the manifest file, `$MANIFEST_FILE`, that provides the path to
+ the package ID file. Each line of a manifest file maps a single file that
+ is contained in the package and is in the form of `destination=source` where:
+
+ * `destination` is the path to the file in the final package
+ * `source` is the path to the file on the host machine
+
+ The manifest file must include at least one line for the package ID file like
+ this:
+
+ ```
+ meta/package=<package ID file>
+ ```
+
+3. Generate the package metadata archive:
+
+ ```
+ pm -o $PACKAGE_DIR -m $MANIFEST_FILE build
+ ```
+
+ This creates the metadata archive at `$PACKAGE_DIR/meta.far`.
+
+4. Create the package archive `$PACKAGE_ARCHIVE`:
+
+ ```
+ pm -o $PACKAGE_DIR -m $MANIFEST_FILE archive
+ ```
+
+ This command creates the package archive implicitly as
+ `$PACKAGE_DIR/$PACKAGE_NAME-0.far`. Set `$PACKAGE_ARCHIVE` accordingly
+ for use in subsequent steps:
+
+ ```
+ export PACKAGE_ARCHIVE=${PACKAGE_DIR}/${PACKAGE_NAME}-0.far
+ ```
+
+ If the contents of the package change, you need to re-run the
+ `pm -o $PACKAGE_DIR -m $MANIFEST_FILE archive` command.
+
+You have successfully built a package. You are now ready to publish the package.
+
+### Publish a package {#publish-package}
+
+To publish a package:
+
+1. Initialize a directory, `$REPO`, that serves as a packages repository:
+
+ ```
+ pm newrepo -repo $REPO
+ ```
+
+ This creates a directory structure named `$REPO` that is ready for
+ publishing packages.
+
+2. Publish packages to the repository `$REPO`:
+
+ ```
+ pm publish -a -r $REPO -f $PACKAGE_ARCHIVE
+ ```
+
+ `pm publish` parses `$PACKAGE_ARCHIVE` and publishes the package in the
+ provided `$REPO` directory. If you run this command multiple times with
+ different package archives, `pm publish` publishes the packages to the same
+ repository. New versions of a same package can be published using the same
+ command.
+
+You have successfully published a package. You are now ready to install a
+package.
+
+### Install a package {#install-package}
+
+To install a package:
+
+1. Start the package server:
+
+ ```
+ pm serve -repo $REPO
+ ```
+
+ By default, this starts an amber server on the host machine at port `8083`.
+
+2. (On the target device) Add the new repository as an update source with
+ `amberctl`:
+
+ ```
+ amberctl add_repo_cfg -n $REPO -f http://$HOST_ADDRESS:8083/config.json
+ ```
+
+ If the component is not already on the system, `amberctl` installs the package.
+ If the package already exists, `amberctl` installs any package updates.
+
+You have successfully installed or updated the package. You are now ready to
+run a component from the installed package.
+
+### Run a component from an installed package {#run-component}
+
+To run a component published in a package:
+
+1. (On the target device) Run:
+
+ Note: `$COMPONENT_URI` is in this form
+ `fuchsia-pkg://${REPO}/${PACKAGE_NAME}#meta/<component name>.cmx`.
+
+ ```
+ run $COMPONENT_URI
+ ```
+
+You have successfully run a component from the installed package.
+
diff --git a/docs/ssh.md b/docs/ssh.md
index b884d2a..3426c5b 100644
--- a/docs/ssh.md
+++ b/docs/ssh.md
@@ -1,3 +1,59 @@
# SSH
-_Content to be added soon!_
+SSH is the supported protocol for communication between a Fuchsia target device
+and a host device.
+This document describes how to properly set up an SSH connection between these
+devices.
+
+## Prerequisites
+
+On the host side, a proper SSH distribution is required.
+
+A public/private keypair is also needed.
+It may be generated via the `ssh-keygen` command, or extracted from the running
+SSH agent via `ssh-add -L`.
+
+## Provisioning a device
+
+There are two options for installing the public key onto the target.
+
+### By installing it during paving (preferred)
+
+Follow the instruction for [paving](bootserver.md) the target device, and add an
+extra argument to the `bootserver` call pointing to the public key:
+```
+$ bootserver --authorized-keys $PUBLIC_KEY <other args>
+```
+
+### By modifying the Fuchsia image directly
+
+The `fuchsia.zbi` image may be modified to include the public key using the
+`zbi` tool:
+```
+$ zbi -o $FUCHSIA_DOT_ZBI -e data/ssh/authorized_keys=$PUBLIC_KEY
+```
+
+Note that this method is mainly designed for situations where paving is not
+necessarily an efficient option (e.g. testing on an emulator).
+Use with care.
+
+## Connecting to a device
+
+Provided that the address of the target device is known as `$TARGET_ADDRESS`,
+open a shell on that device with:
+```
+$ ssh -i $PRIVATE_KEY fuchsia@$TARGET_ADDRESS
+```
+
+Note that if you got the key from your SSH agent, or if the key is in a well
+known location (`$SSH_HOME`) under a well known name (`id_*`), you may omit the
+`-i` argument.
+
+Note also that the host keys for a Fuchsia target device are generated at first
+boot, meaning that every time the device gets paved the keys are going to
+change.
+You may want to disable host key checking when connecting to a Fuchsia device to
+avoid running into errors by adding the following flags:
+```
+-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
+```
diff --git a/fidl/fuchsia.bluetooth.gatt/client.fidl b/fidl/fuchsia.bluetooth.gatt/client.fidl
deleted file mode 100644
index fad056b..0000000
--- a/fidl/fuchsia.bluetooth.gatt/client.fidl
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.gatt;
-
-using fuchsia.bluetooth;
-
-interface RemoteService {
- // Returns the characteristics and characteristic descriptors that belong to
- // this service.
- 1: DiscoverCharacteristics() -> (fuchsia.bluetooth.Status status, vector<Characteristic> characteristics);
-
- // Reads the value of the characteristic with |id| and returns it in the
- // reply. If |status| indicates an error |value| will be empty.
- //
- // If the characteristic has a long value (i.e. larger than the current MTU)
- // this method will return only the first (MTU - 1) bytes of the value. Use
- // ReadLongCharacteristic() to read larger values or starting at a non-zero
- // offset.
- 2: ReadCharacteristic(uint64 id) -> (fuchsia.bluetooth.Status status, vector<uint8> value);
-
- // Reads the complete value of a characteristic with the given |id|. This
- // procedure should be used if the characteristic is known to have a value
- // that can not be read in a single request.
- //
- // Returns up to |max_bytes| octets of the characteristic value starting at
- // the given |offset|.
- //
- // This may return an error if:
- // a. |max_bytes| is 0;
- // b. The |offset| is invalid;
- // c. The characteristic does not have a long value;
- // d. The server does not support the long read procedure.
- 3: ReadLongCharacteristic(uint64 id, uint16 offset, uint16 max_bytes) -> (fuchsia.bluetooth.Status status, vector<uint8> value);
-
- // Writes |value| to the characteristic with |id|. The ATT protocol method is
- // selected based on the input parameters and properties of the
- // characteristic:
- //
- // a. If |value| fits within a single ATT request (based on the current MTU)
- // and |offset| is 0, the "Write Characteristic Value" procedure will be
- // used.
- // b. If |value| is value cannot fit within a single ATT request or a
- // non-zero |offset| is requested, the "Write Long Characteristic Value"
- // procedure will be used.
- // c. If the characteristic does not claim to support the selected
- // procedure, the request will fail with ErrorCode.NotSupported.
- 4: WriteCharacteristic(uint64 id, uint16 offset, vector<uint8> value) -> (fuchsia.bluetooth.Status status);
-
- // Writes |value| to the characteristic with |id| without soliciting an
- // acknowledgement from the peer. This method has no response and its delivery
- // cannot be confirmed.
- 5: WriteCharacteristicWithoutResponse(uint64 id, vector<uint8> value);
-
- // Reads the value of the characteristic descriptor with |id| and returns it
- // in the reply. If |status| indicates an error, |value| can be ignored.
- //
- // If the descriptor has a long value (i.e. larger than the current MTU)
- // this method will return only the first (MTU - 1) bytes of the value. Use
- // ReadLongDescriptor() to read larger values or starting at a non-zero
- // offset.
- 6: ReadDescriptor(uint64 id) -> (fuchsia.bluetooth.Status status, vector<uint8> value);
-
- // Reads the complete value of a characteristic descriptor with the given |id|.
- // This procedure should be used if the descriptor is known to have a value
- // that can not be read in a single request.
- //
- // Returns up to |max_bytes| octets of the characteristic value starting at
- // the given |offset|.
- //
- // This may return an error if:
- // a. |max_bytes| is 0;
- // b. The |offset| is invalid;
- // c. The server does not support the long read procedure.
- 7: ReadLongDescriptor(uint64 id, uint16 offset, uint16 max_bytes) -> (fuchsia.bluetooth.Status status, vector<uint8> value);
-
- // Writes |value| to the characteristic descriptor with |id|. This operation
- // may return an error if:
- // a. The size of |value| exceeds the current MTU.
- // b. |id| refers to an internally reserved descriptor type (e.g. the Client
- // Characteristic Configuration descriptor).
- 8: WriteDescriptor(uint64 id, vector<uint8> value) -> (fuchsia.bluetooth.Status status);
-
- // Subscribe or unsubscribe to notifications/indications from the characteristic with
- // the given |id|. Notifications or indications will be enabled if |enable| is
- // true or disabled if |enable| is false and they have been enabled for this
- // client.
- //
- // Either notifications or indications will be enabled depending on
- // characteristic properties. Indications will be preferred if they are
- // supported.
- //
- // This operation fails if the characteristic does not have the "notify" or
- // "indicate" property or does not contain a Client Characteristic
- // Configuration descriptor.
- //
- // On success, the OnCharacteristicValueUpdated event will be sent whenever
- // the peer sends a notification or indication. The local host will
- // automically confirm indications.
- 9: NotifyCharacteristic(uint64 id, bool enable) -> (fuchsia.bluetooth.Status status);
-
- // Events:
- // Called when a characteristic value notification or indication is received.
- 1001: -> OnCharacteristicValueUpdated(uint64 id, vector<uint8> value);
-};
-
-interface Client {
- // Enumerates services found on the peer that this Client represents. Results
- // can be restricted by specifying a list of UUIDs in |uuids|. The returned
- // ServiceInfo structures will contain only basic information about each
- // service and the |characteristics| and |includes| fields will be null.
- //
- // To further interact with services, clients must obtain a RemoteService
- // handle by calling ConnectToService().
- 1: ListServices(vector<string>? uuids) -> (fuchsia.bluetooth.Status status, vector<ServiceInfo> services);
-
- // Connects the RemoteService with the given identifier.
- 2: ConnectToService(uint64 id, request<RemoteService> service);
-};
diff --git a/fidl/fuchsia.bluetooth.gatt/meta.json b/fidl/fuchsia.bluetooth.gatt/meta.json
deleted file mode 100644
index 03eebd2..0000000
--- a/fidl/fuchsia.bluetooth.gatt/meta.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "deps": [
- "fuchsia.bluetooth"
- ],
- "files": [
- "fidl/fuchsia.bluetooth.gatt/client.fidl",
- "fidl/fuchsia.bluetooth.gatt/server.fidl",
- "fidl/fuchsia.bluetooth.gatt/types.fidl"
- ],
- "name": "fuchsia.bluetooth.gatt",
- "root": "fidl/fuchsia.bluetooth.gatt",
- "sources": [
- "fidl/fuchsia.bluetooth.gatt/client.fidl",
- "fidl/fuchsia.bluetooth.gatt/server.fidl",
- "fidl/fuchsia.bluetooth.gatt/types.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.bluetooth.gatt/server.fidl b/fidl/fuchsia.bluetooth.gatt/server.fidl
deleted file mode 100644
index db0599e..0000000
--- a/fidl/fuchsia.bluetooth.gatt/server.fidl
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.gatt;
-
-using fuchsia.bluetooth;
-
-// Interface for responding to requests on a local service.
-interface LocalServiceDelegate {
- // Notifies the delegate when a remote device with |peer_id| enables or
- // disables notifications or indications on the characteristic with the given
- // |characteristic_id|.
- 1: OnCharacteristicConfiguration(uint64 characteristic_id, string peer_id,
- bool notify, bool indicate);
-
- // Called when a remote device issues a request to read the value of the
- // of the characteristic or descriptor with given identifier. The delegate
- // must respond to the request by returning the characteristic value. If the
- // read request resulted in an error it should be returned in |error_code|.
- // On success, |error_code| should be set to NO_ERROR and a |value| should be
- // provided.
- 2: OnReadValue(uint64 id, int32 offset) -> (vector<uint8>? value, ErrorCode status);
-
- // Called when a remote device issues a request to write the value of the
- // characteristic or descriptor with the given identifier.
- 3: OnWriteValue(uint64 id, uint16 offset, vector<uint8> value) -> (ErrorCode status);
-
- // Called when a remote device issues a request to write the value of the
- // characteristic with the given identifier. This can be called on a
- // characteristic with the WRITE_WITHOUT_RESPONSE property.
- 4: OnWriteWithoutResponse(uint64 id, uint16 offset, vector<uint8> value);
-};
-
-// Interface for communicating with a published service.
-interface LocalService {
- // Removes the service that this interface instance corresponds to. Does
- // nothing if the service is already removed.
- 1: RemoveService();
-
- // Sends a notification carrying the |value| of the characteristic with the
- // given |characteristic_id| to the device with |peer_id|.
- //
- // If |confirm| is true, then this method sends an indication instead. If the
- // peer fails to confirm the indication, the link between the peer and the
- // local adapter will be closed.
- //
- // This method has no effect if the peer has not enabled notifications or
- // indications on the requested characteristic.
- 2: NotifyValue(uint64 characteristic_id, string peer_id, vector<uint8> value, bool confirm);
-};
-
-[Discoverable]
-interface Server {
- // Publishes the given service so that it is available to all remote peers.
- // A LocalServiceDelegate must be provided over which to receive service requests.
- //
- // The caller must assign distinct identifiers to the characteristics and
- // descriptors listed in |info|. These identifiers will be used in requests
- // sent to |delegate|.
- //
- // |service| can be used to interact with the pubished service. If this
- // service cannot be published then the handle for |service| will be closed.
- //
- // Returns the success or failure status of the call and a unique identifier
- // that can be used to unregister the service.
- 1: PublishService(ServiceInfo info, LocalServiceDelegate delegate, request<LocalService> service) -> (fuchsia.bluetooth.Status status);
-};
diff --git a/fidl/fuchsia.bluetooth.gatt/types.fidl b/fidl/fuchsia.bluetooth.gatt/types.fidl
deleted file mode 100644
index 894e956..0000000
--- a/fidl/fuchsia.bluetooth.gatt/types.fidl
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.gatt;
-
-// Codes that can be returned in the |protocol_error_code| field of a
-// bluetooth.Error.
-enum ErrorCode {
- // Indicates that the operation was successful.
- NO_ERROR = 0;
-
- // Indicates that the offset used in a read or write request exceeds the
- // bounds of the value.
- INVALID_OFFSET = 1;
-
- // Indicates that the value given in a write request would exceed the maximum
- // length allowed for the destionation characteristic or descriptor.
- INVALID_VALUE_LENGTH = 2;
-
- // Indicates that a read or write request is not permitted.
- NOT_PERMITTED = 3;
-};
-
-// Represents encryption, authentication, and authorization permissions that can
-// be assigned to a specific access permission.
-struct SecurityRequirements {
- // If true, the physical link must be encrypted to access this attribute.
- bool encryption_required;
-
- // If true, the physical link must be authenticated to access this
- // attribute.
- bool authentication_required;
-
- // If true, the client needs to be authorized before accessing this
- // attribute.
- bool authorization_required;
-};
-
-// Specifies the access permissions for a specific attribute value.
-struct AttributePermissions {
- // Specifies whether or not an attribute has the read permission. If null,
- // then the attribute value cannot be read. Otherwise, it can be read only if
- // the permissions specified in the Permissions struct are satisfied.
- SecurityRequirements? read;
-
- // Specifies whether or not an attribute has the write permission. If null,
- // then the attribute value cannot be written. Otherwise, it be written only
- // if the permissions specified in the Permissions struct are satisfied.
- SecurityRequirements? write;
-
- // Specifies the security requirements for a client to subscribe to
- // notifications or indications on a characteristic. A characteristic's
- // support for notifications or indiciations is specified using the NOTIFY and
- // INDICATE characteristic properties. If a local characteristic has one of
- // these properties then this field can not be null. Otherwise, this field
- // must be left as null.
- //
- // This field is ignored for Descriptors.
- SecurityRequirements? update;
-};
-
-// Possible values for the characteristic properties bitfield. These specify the
-// GATT procedures that are allowed for a particular characteristic.
-const uint32 kPropertyBroadcast = 1;
-const uint32 kPropertyRead = 2;
-const uint32 kPropertyWriteWithoutResponse = 4;
-const uint32 kPropertyWrite = 8;
-const uint32 kPropertyNotify = 16;
-const uint32 kPropertyIndicate = 32;
-const uint32 kPropertyAuthenticatedSignedWrites = 64;
-const uint32 kPropertyReliableWrite = 256;
-const uint32 kPropertyWritableAuxiliaries= 512;
-
-// Represents a local or remote GATT service.
-struct ServiceInfo {
- // Uniquely identifies this GATT service. This value will be ignored for local
- // services. Remote services will always have an identifier.
- uint64 id;
-
- // Indicates whether this is a primary or secondary service.
- bool primary;
-
- // The 128-bit UUID that identifies the type of this service. This is a string
- // in the canonical 8-4-4-4-12 format.
- string type;
-
- // The characteristics of this service.
- vector<Characteristic>? characteristics;
-
- // Ids of other services that are included by this service.
- vector<uint64>? includes;
-};
-
-// Represents a local or remote GATT characteristic.
-struct Characteristic {
- // Uniquely identifies this characteristic within a service.
- uint64 id;
-
- // The 128-bit UUID that identifies the type of this characteristic. This is a
- // string in the canonical 8-4-4-4-12 format.
- string type;
-
- // The characteristic properties bitfield. See kProperty* above for possible
- // values.
- uint32 properties;
-
- // The attribute permissions of this characteristic. For remote
- // characteristics, this value will be null until the permissions are
- // discovered via read and write requests.
- //
- // For local characteristics, this value is mandatory.
- AttributePermissions? permissions;
-
- // The descriptors of this characteristic.
- vector<Descriptor>? descriptors;
-};
-
-// Represents a local or remote GATT characteristic descriptor.
-struct Descriptor {
- // Uniquely identifies this descriptor within the characteristic that it
- // belongs to.
- uint64 id;
-
- // The 128-bit UUID that identifies the type of this descriptor. This is a
- // string in the canonical 8-4-4-4-12 format.
- string type;
-
- // The attribute permissions of this descriptor. For remote
- // descriptors, this value will be null until the permissions are
- // discovered via read and write requests.
- //
- // For local descriptors, this value is mandatory.
- AttributePermissions? permissions;
-};
diff --git a/fidl/fuchsia.bluetooth.le/central.fidl b/fidl/fuchsia.bluetooth.le/central.fidl
deleted file mode 100644
index e0756ea..0000000
--- a/fidl/fuchsia.bluetooth.le/central.fidl
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.le;
-
-using fuchsia.bluetooth;
-using fuchsia.bluetooth.gatt;
-
-[Discoverable]
-interface Central {
- // Returns the list of peripherals that are known to the system from previous scan, connection,
- // and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
- // be present on the peripheral.
- //
- // This method only returns peripherals (i.e. connectable devices).
- 1: GetPeripherals(vector<string>? service_uuids) -> (vector<RemoteDevice> peripherals);
-
- // Returns information about a single peripheral that is known to the system from previous scan,
- // connection, and/or bonding procedures based on its unique identifier. Returns null if
- // |identifier| is not recognized.
- 2: GetPeripheral(string identifier) -> (RemoteDevice? peripheral);
-
- // Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
- // reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
- // |filter| will replace the existing session's filter.
- //
- // If |filter| is null or empty (i.e. none of its fields has been populated) then the delegate
- // will be notified for all discoverable devices that are found. This is not recommended; clients
- // should generally filter results by at least one of |filter.service_uuids|,
- // |filter.service_data|, and/or |filter.manufacturer_identifier|.
- 3: StartScan(ScanFilter? filter) -> (fuchsia.bluetooth.Status status);
-
- // Terminate a previously started scan session.
- 4: StopScan();
-
- // Creates a connection to the peripheral device with the given identifier.
- // Returns the status of the operation in |status|.
- //
- // On success, |gatt_client| will be bound and can be used for GATT client
- // role procedures. On failure, |gatt_client| will be closed and |status| will
- // indicate an error.
- 5: ConnectPeripheral(string identifier, request<fuchsia.bluetooth.gatt.Client> gatt_client) -> (fuchsia.bluetooth.Status status);
-
- // Disconnects this Central's connection to the peripheral with the given identifier.
- 6: DisconnectPeripheral(string identifier) -> (fuchsia.bluetooth.Status status);
-
- // Called when the scan state changes, e.g. when a scan session terminates due to a call to
- // Central.StopScan() or another unexpected condition.
- 101: -> OnScanStateChanged(bool scanning);
-
- // Called for each peripheral/broadcaster that is discovered during a scan session. |rssi|
- // contains the received signal strength of the advertising packet that generated this event, if
- // available.
- 102: -> OnDeviceDiscovered(RemoteDevice device);
-
- // Called when this Central's connection to a peripheral with the given identifier is terminated.
- 103: -> OnPeripheralDisconnected(string identifier);
-};
diff --git a/fidl/fuchsia.bluetooth.le/meta.json b/fidl/fuchsia.bluetooth.le/meta.json
deleted file mode 100644
index db45f8e..0000000
--- a/fidl/fuchsia.bluetooth.le/meta.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "deps": [
- "fuchsia.bluetooth",
- "fuchsia.bluetooth.gatt"
- ],
- "files": [
- "fidl/fuchsia.bluetooth.le/central.fidl",
- "fidl/fuchsia.bluetooth.le/peripheral.fidl",
- "fidl/fuchsia.bluetooth.le/types.fidl"
- ],
- "name": "fuchsia.bluetooth.le",
- "root": "fidl/fuchsia.bluetooth.le",
- "sources": [
- "fidl/fuchsia.bluetooth.le/central.fidl",
- "fidl/fuchsia.bluetooth.le/peripheral.fidl",
- "fidl/fuchsia.bluetooth.le/types.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.bluetooth.le/peripheral.fidl b/fidl/fuchsia.bluetooth.le/peripheral.fidl
deleted file mode 100644
index 0653825..0000000
--- a/fidl/fuchsia.bluetooth.le/peripheral.fidl
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.le;
-
-using fuchsia.bluetooth;
-
-[Discoverable]
-interface Peripheral {
- // Starts sending advertisements based on the given parameters.
- // - |advertising_data|: The advertising data that should be included in the payload.
- // - |scan_result|: The scan result that will be returned when the advertisement is
- // scanned. Setting this will mark the advertisement set as scannable.
- // - |connectable|: when true, this advertisement will be marked as connectable.
- // NOTE: connections can be made to a GATT server even if this is not set.
- // - |interval_ms|: The requested interval to advertise this set at in milliseconds.
- // minimum 20, maximum 10,000,000 (almost 3 hours). A reasonable
- // default is 1 second (1000).
- // - |anonymous|: if true, the address of this device will not be included
- //
- // If the |tx_power_level| is set in either AdvertisingData, it will be replaced with
- // the actual TX Power level reported by the adapter, or included in the extended header
- // of the Advertising PDU to save advertising space.
- //
- // If |scan_result| and |advertising_data| are both set, legacy advertising will be used,
- // which limits the size of the advertising data.
- //
- // This request will fail if:
- // - The |service_uuids| field of |advertising_data| contains a UUID that does not match
- // a GATT service that was previously registered by this application;
- // - If the provided advertising data cannot fit within the advertising payload MTU that
- // is supported on the current platform and parameters.
- // - If |anonymous| advertising is requested but the controller cannot support it.
- 1: StartAdvertising(AdvertisingData advertising_data, AdvertisingData? scan_result,
- bool connectable, uint32 interval_ms, bool anonymous)
- -> (fuchsia.bluetooth.Status status, string? advertisement_id);
-
- // Stop a an advertising session that was previously started by this application.
- 2: StopAdvertising(string advertisement_id) -> (fuchsia.bluetooth.Status status);
-
- // Called when a remote central device has connected to a connectable advertisement.
- // Provides a GATT client handle which can be used to interact with GATT service
- // on the central device.
- //
- // When this is called, the Advertisement will have stopped, and StartAdvertising
- // should be called again to re-start advertising when the peripheral can accept
- // another connection.
- //
- // Note: Centrals can connect to the local device and interact with the GATT server
- // from an application without Peripheral.StartAdvertising() being called.
- 101: -> OnCentralConnected(string advertisement_id, RemoteDevice central);
-
- // Called when a remote central previously connected to this application is disconnected.
- 102: -> OnCentralDisconnected(string device_id);
-};
diff --git a/fidl/fuchsia.bluetooth.le/types.fidl b/fidl/fuchsia.bluetooth.le/types.fidl
deleted file mode 100644
index 88f1dd1..0000000
--- a/fidl/fuchsia.bluetooth.le/types.fidl
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth.le;
-
-using fuchsia.bluetooth;
-using fuchsia.bluetooth.gatt;
-
-struct ServiceDataEntry {
- string uuid;
- vector<uint8> data;
-};
-
-struct ManufacturerSpecificDataEntry {
- uint16 company_id;
- vector<uint8> data;
-};
-
-// Represents advertising and scan response data advertised by a broadcaster or peripheral.
-struct AdvertisingData {
- // Name of the device.
- string? name;
-
- // The radio transmission power level reported in the advertisement.
- fuchsia.bluetooth.Int8? tx_power_level;
-
- // The appearance reported in the advertisemet.
- fuchsia.bluetooth.UInt16? appearance;
-
- // List of service UUIDs reported in the advertisement.
- vector<string>? service_uuids;
-
- // Service data included in the advertisement.
- vector<ServiceDataEntry>? service_data;
-
- // Manufacturer specific data entries.
- vector<ManufacturerSpecificDataEntry>? manufacturer_specific_data;
-
- // Service UUIDs that were solicited in the advertisement. Peripherals can invite centrals that
- // expose certain services to connect to them using service solicitation.
- vector<string>? solicited_service_uuids;
-
- // URIs included in the advertising packet.
- // These are full URIs (they are encoded/decoded automatically)
- vector<string>? uris;
-};
-
-// Represents a remote Bluetooth Low Energy device. A RemoteDevice can represent a central,
-// broadcaster, or peripheral based on the API from which it was received.
-struct RemoteDevice {
- // Identifier that uniquely identifies this device on the current system.
- string identifier;
-
- // Whether or not this device is connectable. Non-connectable devices are typically acting in the
- // LE broadcaster role.
- bool connectable;
-
- // The last known RSSI of this device, if known.
- fuchsia.bluetooth.Int8? rssi;
-
- // Advertising data broadcast by this device if this device is a broadcaster or peripheral.
- AdvertisingData? advertising_data;
-};
-
-// Filter parameters for use during a scan. A discovered peripheral or broadcaster will be reported
-// to applications only if it satisfies all of the provided filter parameters. Null fields will be
-// ignored.
-struct ScanFilter {
- // Filter based on advertised service UUIDs. A peripheral that advertises at least one of the
- // entries in |service_uuids| will satisfy this filter.
- vector<string>? service_uuids;
-
- // Filter based on service data containing one of the given UUIDs.
- vector<string>? service_data_uuids;
-
- // Filter based on a company identifier present in the manufacturer data. If this filter parameter
- // is set, then the advertising payload must contain manufacturer specific data with the provided
- // company identifier to satisfy this filter.
- fuchsia.bluetooth.UInt16? manufacturer_identifier;
-
- // Filter based on whether or not a device is connectable. For example, a client that is only
- // interested in peripherals that it can connect to can set this to true. Similarly a client can
- // scan only for braodcasters by setting this to false.
- fuchsia.bluetooth.Bool? connectable;
-
- // Filter results based on a portion of the advertised device name.
- string? name_substring;
-
- // Filter results based on the path loss of the radio wave. A device that matches this filter must
- // satisfy the following:
- // 1. Radio transmission power level and received signal strength must be available for the path
- // loss calculation;
- // 2. The calculated path loss value must be less than, or equal to, |max_path_loss|.
- fuchsia.bluetooth.Int8? max_path_loss;
-};
diff --git a/fidl/fuchsia.bluetooth/meta.json b/fidl/fuchsia.bluetooth/meta.json
deleted file mode 100644
index 359eef6..0000000
--- a/fidl/fuchsia.bluetooth/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.bluetooth/status.fidl",
- "fidl/fuchsia.bluetooth/nullables.fidl"
- ],
- "name": "fuchsia.bluetooth",
- "root": "fidl/fuchsia.bluetooth",
- "sources": [
- "fidl/fuchsia.bluetooth/status.fidl",
- "fidl/fuchsia.bluetooth/nullables.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.bluetooth/nullables.fidl b/fidl/fuchsia.bluetooth/nullables.fidl
deleted file mode 100644
index f5bcb42..0000000
--- a/fidl/fuchsia.bluetooth/nullables.fidl
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth;
-
-// Nullable primitive types:
-
-struct Bool {
- bool value;
-};
-
-struct Int8 {
- int8 value;
-};
-
-struct UInt16 {
- uint16 value;
-};
diff --git a/fidl/fuchsia.bluetooth/status.fidl b/fidl/fuchsia.bluetooth/status.fidl
deleted file mode 100644
index 8a49c31..0000000
--- a/fidl/fuchsia.bluetooth/status.fidl
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.bluetooth;
-
-enum ErrorCode {
- UNKNOWN = 0;
- FAILED = 1;
- CANCELED = 2;
- IN_PROGRESS = 3;
- TIMED_OUT = 4;
- NOT_FOUND = 5;
- NOT_SUPPORTED = 6;
- BLUETOOTH_NOT_AVAILABLE = 7;
- BAD_STATE = 8;
- INVALID_ARGUMENTS = 9;
- ALREADY = 10;
- PROTOCOL_ERROR = 11;
-};
-
-// Represents an error result returned from an asynchronous operation.
-struct Error {
- // Represents a high-level error code. If this is set to ErrorCode.PROTOCOL_ERROR, then
- // |protocol_error_code| will represent a Bluetooth protocol error code. The specific
- // protocol that caused the error will be context-specific, e.g. GATT interfaces will
- // return ATT protocol error codes.
- ErrorCode error_code;
-
- // Protocol error code. The value of this field is relevant only if |error_code| is set to
- // ErrorCode.PROTOCOL_ERROR.
- uint32 protocol_error_code;
-
- // Human-readable description of the error.
- string? description;
-};
-
-// Represents the result of an asynchronous operation.
-struct Status {
- // |error| will be null if this represents a "success" status, i.e. no error has occurred.
- Error? error;
-};
diff --git a/fidl/fuchsia.developer.tiles/meta.json b/fidl/fuchsia.developer.tiles/meta.json
deleted file mode 100644
index fec0444..0000000
--- a/fidl/fuchsia.developer.tiles/meta.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "deps": [
- "fuchsia.math",
- "fuchsia.ui.app"
- ],
- "files": [
- "fidl/fuchsia.developer.tiles/tiles.fidl"
- ],
- "name": "fuchsia.developer.tiles",
- "root": "fidl/fuchsia.developer.tiles",
- "sources": [
- "fidl/fuchsia.developer.tiles/tiles.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.developer.tiles/tiles.fidl b/fidl/fuchsia.developer.tiles/tiles.fidl
deleted file mode 100644
index f38b474..0000000
--- a/fidl/fuchsia.developer.tiles/tiles.fidl
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.developer.tiles;
-
-using fuchsia.math;
-using fuchsia.ui.app;
-
-[Discoverable]
-interface Controller {
- // Instantiates a component by its URL and adds a tile backed by that component's ViewProvider.
- // Returns a key for the tile that can be used for resizing or removing the tile, or 0 on failure.
- 1: AddTileFromURL(string url, bool allow_focus, vector<string>? args) -> (uint32 key);
-
- // Adds a tile backed by a view from the view provider.
- // Returns a key for the tile that can be used for resizing or removing the tile, or 0 on failure.
- 2: AddTileFromViewProvider(string url, fuchsia.ui.app.ViewProvider provider) -> (uint32 key);
-
- // Removes the tile with the given key.
- 3: RemoveTile(uint32 key);
-
- // Returns a list of tiles.
- 5: ListTiles() -> (vector<uint32> keys, vector<string> urls, vector<fuchsia.math.SizeF> sizes, vector<bool> focusabilities);
-};
diff --git a/fidl/fuchsia.fonts/font_provider.fidl b/fidl/fuchsia.fonts/font_provider.fidl
deleted file mode 100644
index 4b08fca..0000000
--- a/fidl/fuchsia.fonts/font_provider.fidl
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.fonts;
-
-using fuchsia.mem;
-
-enum Slant {
- UPRIGHT = 1;
- ITALIC = 2;
- OBLIQUE = 3;
-};
-
-enum FallbackGroup {
- NONE = 0;
- SERIF = 1;
- SANS_SERIF = 2;
- MONOSPACE = 3;
- CURSIVE = 4;
- FANTASY = 5;
-};
-
-// Disables font fallback. The service won't try to search fallback font set if
-// there is no requested font family or if it doesn't contain requested
-// character.
-const uint32 REQUEST_FLAG_NO_FALLBACK = 1;
-
-// Disables approximate style matching. The service will only return font that
-// matches the requested style exactly.
-const uint32 REQUEST_FLAG_EXACT_MATCH = 2;
-
-struct Request {
- // Desired font family name, e.g. "Roboto". Font family search is
- // case-insensitive. In case when there is no specified family or the
- // specified family doesn't have glyph for the requested |character| then
- // a font from another family may be returned. This behavior can be disabled
- // using REQUEST_FLAG_NO_FALLBACK.
- string:128? family;
-
- // For example, 400 is normal, 700 is bold.
- uint32 weight = 400;
-
- // Numeric values matching OS/2 & Windows Metrics usWidthClass table.
- // https://www.microsoft.com/typography/otspec/os2.htm
- // For example, 5 is normal.
- uint32 width = 5;
-
- Slant slant = UPRIGHT;
-
- // BCP47 language tags in order of preference. See
- // https://tools.ietf.org/html/bcp47 .
- vector<string:35>:8? language;
-
- // Codepoint for the character that must be present in the returned font or 0.
- // Caller that specify this field are expected to extract character set from
- // the result and cache it in order to avoid calling the API more than
- // necessary.
- uint32 character = 0;
-
- // Fallback group preference. Caller can leave this field set to NONE. In
- // that case the font provider will use fallback group of the specified font
- // family.
- FallbackGroup fallback_group = NONE;
-
- uint32 flags = 0;
-};
-
-struct Response {
- fuchsia.mem.Buffer buffer;
-
- // Buffer identifier for the buffer. Responses with the same buffer_id are
- // guaranteed to contain the same data in the buffer. Clients may use this
- // value to detect if they already have the font cached in parsed form.
- uint32 buffer_id;
-
- // Font index within `buffer`. Used for font formats that may contain more
- // than one font per file, e.g. TTC (TrueType Collection).
- uint32 font_index;
-};
-
-struct Style {
- uint32 weight;
- uint32 width;
- Slant slant;
-};
-
-// Information about font family that can be requested using GetFamilyInfo().
-struct FamilyInfo {
- // Canonical font family name. Note that this may be different from the
- // value passed to GetFamilyInfo() because GetFamilyInfo() also resolves
- // font aliases and ignores case. For example GetFamilyInfo("robotoslab")
- // will FamilyInfo.name = "Robot Slab".
- string:128 name;
-
- // Unordered list of all available styles in the family.
- vector<Style>:300 styles;
-};
-
-[Discoverable]
-interface Provider {
- // Returns font that matches specified |request|.
- 1: GetFont(Request request) -> (Response? response);
-
- // Returns information for the specified font family or null if there is
- // no family with the specified name. This function respects family name
- // aliases and ignores case, so request for "robotoSLAB" will return
- // FamilyInfo for "Roboto Slab".
- 2: GetFamilyInfo(string:128 family) -> (FamilyInfo? family_info);
-};
diff --git a/fidl/fuchsia.fonts/meta.json b/fidl/fuchsia.fonts/meta.json
deleted file mode 100644
index f67297b..0000000
--- a/fidl/fuchsia.fonts/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.fonts/font_provider.fidl"
- ],
- "name": "fuchsia.fonts",
- "root": "fidl/fuchsia.fonts",
- "sources": [
- "fidl/fuchsia.fonts/font_provider.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.images/encoded_image.fidl b/fidl/fuchsia.images/encoded_image.fidl
deleted file mode 100644
index 18384a6..0000000
--- a/fidl/fuchsia.images/encoded_image.fidl
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.images;
-
-struct EncodedImage {
- // The vmo.
- handle<vmo> vmo;
- // The size of the image in the vmo in bytes.
- uint64 size;
-};
diff --git a/fidl/fuchsia.images/image_info.fidl b/fidl/fuchsia.images/image_info.fidl
deleted file mode 100644
index 865e43e..0000000
--- a/fidl/fuchsia.images/image_info.fidl
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.images;
-
-// Specifies how pixels are represented in the image buffer.
-enum PixelFormat {
- // BGRA_8
- //
- // A 32-bit four-component unsigned integer format.
- // Byte order: B, G, R, A (little-endian ARGB packed 32-bit word).
- // Equivalent to Skia |kBGRA_8888_SkColorType| color type.
- // Equivalent to Zircon |ARGB_8888| pixel format on little-endian arch.
- BGRA_8 = 0;
-
- // YUY2
- //
- // 4:2:2 (2x down-sampled UV horizontally; full res UV vertically)
- //
- // A 32-bit component that contains information for 2 pixels:
- // Byte order: Y1, U, Y2, V
- // Unpacks to 2 RGB pixels, where RGB1 = func(Y1, U, V)
- // and RGB2 = func(Y2, U, V)
- // Equivalent to YUV422
- YUY2 = 1;
-
- // NV12
- //
- // 4:2:0 (2x down-sampled UV in both directions)
- //
- // Offset 0:
- // 8 bit per pixel Y plane with bytes YYY.
- // Offset height * stride:
- // 8 bit UV data interleaved bytes as UVUVUV.
- //
- // Y plane has line stride >= width.
- //
- // In this context, both width and height are required to be even.
- //
- // The UV data is separated into "lines", with each "line" having same byte
- // width as a line of Y data, and same "line" stride as Y data's line stride.
- // The UV data has height / 2 "lines".
- //
- // In converting to RGB, the UV data gets up-scaled by 2x in both directions
- // overall. This comment is intentionally silent on exactly how UV up-scaling
- // phase/filtering/signal processing works, as it's a complicated topic that
- // can vary by implementation, typically trading off speed and quality of the
- // up-scaling. See comments in relevant conversion code for approach taken
- // by any given convert path. The precise relative phase of the UV data is
- // not presently conveyed.
- NV12 = 2;
-
- // YV12
- //
- // Like I420, except with V and U swapped.
- //
- // 4:2:0 (2x down-sampled UV in both directions)
- //
- // Offset 0:
- // 8 bit per pixel Y plane with bytes YYY.
- // Offset height * stride:
- // 8 bit V data with uv_stride = stride / 2
- // Offset height * stride + uv_stride * height / 2:
- // 8 bit U data with uv_stride = stride / 2
- //
- // Y plane has line stride >= width.
- //
- // Both width and height are required to be even.
- YV12 = 3;
-};
-
-// Specifies how pixel color information should be interpreted.
-enum ColorSpace {
- SRGB = 0;
-};
-
-// Specifies how pixels are arranged in memory.
-enum Tiling {
- // Pixels are packed linearly.
- // Equivalent to |VK_IMAGE_TILING_LINEAR|.
- LINEAR = 0;
-
- // Pixels are packed in a GPU-dependent optimal format.
- // Equivalent to |VK_IMAGE_TILING_OPTIMAL|.
- GPU_OPTIMAL = 1;
-};
-
-// Specifies how alpha information should be interpreted.
-enum AlphaFormat {
- // Image is considered to be opaque. Alpha channel is ignored.
- // Blend function is: src.RGB
- OPAQUE = 0;
- // Color channels have been premultiplied by alpha.
- // Blend function is: src.RGB + (dest.RGB * (1 - src.A))
- PREMULTIPLIED = 1;
- // Color channels have not been premultiplied by alpha.
- // Blend function is: (src.RGB * src.A) + (dest.RGB * (1 - src.A))
- NON_PREMULTIPLIED = 2;
-};
-
-enum Transform {
- // Pixels are displayed normally.
- NORMAL = 0;
-
- // Pixels are mirrored left-right.
- FLIP_HORIZONTAL = 1;
-
- // Pixels are flipped vertically.
- FLIP_VERTICAL = 2;
-
- // Pixels are flipped vertically and mirrored left-right.
- FLIP_VERTICAL_AND_HORIZONTAL = 3;
-};
-
-// Information about a graphical image (texture) including its format and size.
-struct ImageInfo {
- // Specifies if the image should be mirrored before displaying.
- Transform transform = NORMAL;
-
- // The width and height of the image in pixels.
- uint32 width;
- uint32 height;
-
- // The number of bytes per row in the image buffer.
- uint32 stride;
-
- // The pixel format of the image.
- PixelFormat pixel_format = BGRA_8;
-
- // The pixel color space.
- ColorSpace color_space = SRGB;
-
- // The pixel arrangement in memory.
- Tiling tiling = LINEAR;
-
- // Specifies the interpretion of the alpha channel, if one exists.
- AlphaFormat alpha_format = OPAQUE;
-};
diff --git a/fidl/fuchsia.images/image_pipe.fidl b/fidl/fuchsia.images/image_pipe.fidl
deleted file mode 100644
index 440be61..0000000
--- a/fidl/fuchsia.images/image_pipe.fidl
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.images;
-
-// ImagePipe is a mechanism for streaming shared images between a producer
-// and a consumer which may be running in different processes.
-//
-// Conceptually, the image pipe maintains a table of image resources supplied
-// by the producer into which graphical content may be stored as well as a
-// presentation queue containing a sequence of images which the producer has
-// asked the consumer to present.
-//
-// The presentation queue is initially empty.
-//
-// Each entry in the presentation queue consists of an image together with a
-// pair of optional synchronization fences:
-// - Acquire fence: signaled by the producer when the image is ready to be consumed
-// - Release fence: signaled by the consumer when the image is free to be freed or
-// modified by the producer
-//
-// The producer performs the following sequence of steps to present content:
-// - Allocate and add some number of images (often 2 or 3) to the image pipe
-// to establish a pool using |AddImage()|.
-// - Obtain the next available image from the pool.
-// - Ask the consumer to enqueue an image for presentation and provide fences
-// using |PresentImage()|.
-// - Start rendering the image.
-// - Signal the image's acquire fence when rendering is complete.
-// - Loop to present more image, listen for signals on release fences to recycle
-// images back into the pool.
-//
-// The consumer performs the following sequence of steps for each image which
-// is enqueued in the presentation queue:
-// - Await signals on the image's acquire fence.
-// - If the fence wait cannot be satisfied or if some other error is detected,
-// close the image pipe.
-// Otherwise, begin presenting the image's content.
-// - Retire the previously presented image (if any) from the presentation queue
-// and signal its release fence when no longer needed.
-// - Continue presenting the same image until the next one is ready. Loop.
-//
-// If the producer wants to close the image pipe, it should:
-// - Close its side of the connection.
-// - Wait on all release fences for buffers that it has submitted with
-// |PresentImage()|.
-// - Proceed with resource cleanup.
-//
-// When the consumer detects the image pipe has closed, it should:
-// - Stop using/presenting any images from the pipe.
-// - Unmap all VMOs associated with the images in the pipe.
-// - Close all handles to the VMOs.
-// - Signal all release fences for presented and queued buffers.
-// - Close all handles to fences.
-// - Close its side of the connection.
-//
-// When either party detects that a fence has been abandoned (remotely closed
-// without being signaled) it should assume that the associated image is in
-// an indeterminate state. This will typically happen when the other party
-// (or one of its delegates) has crashed. The safest course of action is to
-// close the image pipe, release all resources which were shared with the
-// other party, and re-establish the connection to recover.
-interface ImagePipe {
- // Adds an image resource to image pipe.
- //
- // The |memory| is the handle of a memory object which contains the image
- // data. It is valid to create multiple images backed by the same memory
- // object; they may even overlap. Consumers must detect this and handle
- // it accordingly. The |offset_bytes| indicates the offset within the
- // memory object at which the image data begins. The |size_bytes|
- // indicates the amount of memory from |memory| that should be utilized.
- // The type of memory stored in the VMO is |memory_type| (e.g. GPU memory,
- // host memory).
- //
- // The following errors will cause the connection to be closed:
- // - |image_id| is already registered
- // - |image_info| represents a format not supported by the consumer
- // - |memory| is not a handle for a readable VMO
- // - the image data expected at |offset_bytes| according to the |image_info|
- // exceeds the memory object's bounds
- 1: AddImage(uint32 image_id, ImageInfo image_info,
- handle<vmo> memory, uint64 offset_bytes, uint64 size_bytes, MemoryType memory_type);
-
- // Removes an image resource from the pipe.
- //
- // The |image_id| is detached from the image resource and is free to be
- // reused to add a new image resource.
- //
- // Removing an image from the image pipe does not affect the presentation
- // queue or the currently presented image.
- //
- // The producer must wait for all release fences associated with the image to
- // be signaled before freeing or modifying the underlying memory object since
- // the image may still be in use in the presentation queue.
- //
- // The following errors will cause the connection to be closed:
- // - |image_id| does not reference a currently registered image resource
- 2: RemoveImage(uint32 image_id);
-
- // Enqueues the specified image for presentation by the consumer.
- //
- // The |acquire_fences| are a set of fences which must all be signaled by the
- // producer before the consumer presents the image.
- // The |release_fences| are set of fences which must all be signaled by the
- // consumer before it is safe for the producer to free or modify the image.
- // |presentation_time| specifies the time on or after which the
- // client would like the enqueued operations should take visible effect
- // (light up pixels on the screen), expressed in nanoseconds in the
- // |CLOCK_MONOTONIC| timebase. Desired presentation times must be
- // monotonically non-decreasing.
- //
- // |presentation_info| returns timing information about the submitted frame
- // and future frames (see presentation_info.fidl).
- //
- // The following errors will cause the connection to be closed:
- // - |image_id| does not reference a currently registered image resource
- 3: PresentImage(uint32 image_id, uint64 presentation_time,
- vector<handle<event>> acquire_fences, vector<handle<event>> release_fences)
- -> (PresentationInfo presentation_info);
-};
diff --git a/fidl/fuchsia.images/memory_type.fidl b/fidl/fuchsia.images/memory_type.fidl
deleted file mode 100644
index 889271c..0000000
--- a/fidl/fuchsia.images/memory_type.fidl
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.images;
-
-// Specifies the type of VMO's memory.
-enum MemoryType {
- // VMO is regular host CPU memory.
- HOST_MEMORY = 0;
-
- // VMO can be imported as a VkDeviceMemory by calling VkAllocateMemory with a
- // VkImportMemoryFuchsiaHandleInfoKHR wrapped in a VkMemoryAllocateInfo.
- VK_DEVICE_MEMORY = 1;
-};
diff --git a/fidl/fuchsia.images/meta.json b/fidl/fuchsia.images/meta.json
deleted file mode 100644
index 2f3af13..0000000
--- a/fidl/fuchsia.images/meta.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.images/encoded_image.fidl",
- "fidl/fuchsia.images/image_info.fidl",
- "fidl/fuchsia.images/image_pipe.fidl",
- "fidl/fuchsia.images/memory_type.fidl",
- "fidl/fuchsia.images/presentation_info.fidl"
- ],
- "name": "fuchsia.images",
- "root": "fidl/fuchsia.images",
- "sources": [
- "fidl/fuchsia.images/encoded_image.fidl",
- "fidl/fuchsia.images/image_info.fidl",
- "fidl/fuchsia.images/image_pipe.fidl",
- "fidl/fuchsia.images/memory_type.fidl",
- "fidl/fuchsia.images/presentation_info.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.images/presentation_info.fidl b/fidl/fuchsia.images/presentation_info.fidl
deleted file mode 100644
index 8b2f464..0000000
--- a/fidl/fuchsia.images/presentation_info.fidl
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.images;
-
-// Information returned by methods such as |ImagePipe.PresentImage()| and
-// |Session.Present()|, when the consumer begins preparing the first frame
-// which includes the presented content.
-struct PresentationInfo {
- // The actual time at which the enqueued operations are anticipated to take
- // visible effect, expressed in nanoseconds in the |CLOCK_MONOTONIC|
- // timebase.
- //
- // This value increases monotonically with each new frame, typically in
- // increments of the |presentation_interval|.
- uint64 presentation_time;
-
- // The nominal amount of time which is anticipated to elapse between
- // successively presented frames, expressed in nanoseconds. When rendering
- // to a display, the interval will typically be derived from the display
- // refresh rate.
- //
- // This value is non-zero. It may vary from time to time, such as when
- // changing display modes.
- uint64 presentation_interval;
-};
diff --git a/fidl/fuchsia.io/io.fidl b/fidl/fuchsia.io/io.fidl
deleted file mode 100644
index 7b3b5ba..0000000
--- a/fidl/fuchsia.io/io.fidl
+++ /dev/null
@@ -1,401 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.io;
-
-using zx;
-
-// Interfaces which may be returned by NodeInfo, an object
-// returned when calling Open or Describe:
-
-// The default protocol, interface information must be acquired some
-// other way.
-struct Service {
- uint8 reserved;
-};
-
-// The object may be cast to interface 'File'.
-struct FileObject {
- handle<event>? event;
-};
-
-// The object may be cast to interface 'Directory'.
-struct DirectoryObject {
- uint8 reserved;
-};
-
-// The object is accompanied by a pipe.
-struct Pipe {
- handle<socket> socket;
-};
-
-// The object is accompanied by a VMO.
-struct Vmofile {
- handle<vmo> vmo;
- uint64 offset;
- uint64 length;
-};
-
-// The object may be cast to interface 'Device'.
-struct Device {
- handle<event>? event;
-};
-
-// Describes how the connection to the Object should be handled, as well as
-// how to interpret the optional handle.
-union NodeInfo {
- Service service;
- FileObject file;
- DirectoryObject directory;
- Pipe pipe;
- Vmofile vmofile;
- Device device;
-};
-
-// Can read from target object.
-const uint32 OPEN_RIGHT_READABLE = 0x00000001;
-// Can write to target object.
-const uint32 OPEN_RIGHT_WRITABLE = 0x00000002;
-// Connection can mount/umount filesystem.
-const uint32 OPEN_RIGHT_ADMIN = 0x00000004;
-
-// Create the object if it doesn't exist.
-const uint32 OPEN_FLAG_CREATE = 0x00010000;
-// (with Create) Fail if the object already exists.
-const uint32 OPEN_FLAG_CREATE_IF_ABSENT = 0x00020000;
-// Truncate the object before usage.
-const uint32 OPEN_FLAG_TRUNCATE = 0x00040000;
-// Return an error if the target object is not a directory.
-const uint32 OPEN_FLAG_DIRECTORY = 0x00080000;
-// Seek to the end of the object before all writes.
-const uint32 OPEN_FLAG_APPEND = 0x00100000;
-// If the object is a mount point, open the local directory.
-const uint32 OPEN_FLAG_NO_REMOTE = 0x00200000;
-// Open a reference to the object, not the object itself.
-const uint32 OPEN_FLAG_NODE_REFERENCE = 0x00400000;
-// Requests that an "OnOpen" event is sent, with
-// a non-null NodeInfo (if the open is successful).
-// Implies "OPEN_FLAG_STATUS".
-const uint32 OPEN_FLAG_DESCRIBE = 0x00800000;
-// Requests that an "OnOpen" event is sent.
-const uint32 OPEN_FLAG_STATUS = 0x01000000;
-
-// Node defines the minimal interface for entities which can be accessed in a filesystem.
-[Layout="Simple", FragileBase]
-interface Node {
- // Create another connection to the same remote object.
- Clone(uint32 flags, request<Node> object);
-
- // Terminates connection with object.
- Close() -> (zx.status s);
-
- // Returns extra information about the type of the object.
- // If the |Describe| operation fails, the connection is closed.
- Describe() -> (NodeInfo info);
-
- // An event produced eagerly by a fidl server if requested
- // by open flags.
- // Indicates the success or failure of the open operation,
- // and optionally describes the object.
- // If the status is |ZX_OK| and |OPEN_FLAG_DESCRIBE| was passed
- // to open, |info| contains descriptive information about
- // the object (the same as would be returned by |Describe|),
- // otherwise it is null.
- -> OnOpen(zx.status s, NodeInfo? info);
-
- // Synchronizes updates to the node to the underlying media, if it exists.
- Sync() -> (zx.status s);
-
- // Acquire information about the node.
- GetAttr() -> (zx.status s, NodeAttributes attributes);
-
- // Update information about the node.
- SetAttr(uint32 flags, NodeAttributes attributes) -> (zx.status s);
-
- // Deprecated. Only for use with compatibility with devhost.
- Ioctl(uint32 opcode, uint64 max_out, vector<handle>:MAX_IOCTL_HANDLES handles, vector<uint8>:MAX_BUF in)
- -> (zx.status s, vector<handle>:MAX_IOCTL_HANDLES handles, vector<uint8>:MAX_BUF out);
-};
-
-// Bits reserved for posix protections. Native fuchsia filesystems
-// are not required to set bits contained within MODE_PROTECTION_MASK,
-// but filesystems that wish to do so may refer to sys/stat.h for their
-// definitions.
-const uint32 MODE_PROTECTION_MASK = 0x00FFF;
-// Bits indicating node type. The canonical mechanism to check
-// for a node type is to take 'mode', bitwise and it with the
-// MODE_TYPE_MASK, and check exact equality against a mode type.
-const uint32 MODE_TYPE_MASK = 0xFF000;
-const uint32 MODE_TYPE_DIRECTORY = 0x04000;
-const uint32 MODE_TYPE_BLOCK_DEVICE = 0x06000;
-const uint32 MODE_TYPE_FILE = 0x08000;
-const uint32 MODE_TYPE_SOCKET = 0x0C000;
-const uint32 MODE_TYPE_SERVICE = 0x10000;
-
-// NodeAttributes defines generic information about a filesystem node.
-struct NodeAttributes {
- // Protection bits and node type information describe in 'mode'.
- uint32 mode;
- // A filesystem-unique ID.
- uint64 id;
- // Node size, in bytes.
- uint64 content_size;
- // Space needed to store node (possibly larger than size), in bytes.
- uint64 storage_size;
- // Hard link count.
- uint64 link_count;
- // Time of creation (may be updated manually after creation) in ns since Unix epoch, UTC.
- uint64 creation_time;
- // Time of last modification in ns since Unix epoch, UTC.
- uint64 modification_time;
-};
-
-const uint64 MAX_IOCTL_HANDLES = 2;
-const uint64 MAX_BUF = 8192;
-const uint64 MAX_PATH = 4096;
-const uint64 MAX_FILENAME = 255;
-
-// The fields of 'attributes' which are used to update the Node are indicated
-// by the 'flags' argument.
-const uint32 NODE_ATTRIBUTE_FLAG_CREATION_TIME = 0x00000001;
-const uint32 NODE_ATTRIBUTE_FLAG_MODIFICATION_TIME = 0x00000002;
-
-// Update the Seek offset.
-enum SeekOrigin : uint32 {
- // Seek from the start of the file.
- START = 0;
- // Seek from the current position in the file.
- CURRENT = 1;
- // Seek from the end of the file.
- END = 2;
-};
-
-// VMO access rights.
-const uint32 VMO_FLAG_READ = 0x00000001;
-const uint32 VMO_FLAG_WRITE = 0x00000002;
-const uint32 VMO_FLAG_EXEC = 0x00000004;
-
-// Require a copy-on-write clone of the underlying VMO.
-// The request should fail if the VMO is not cloned.
-// May not be supplied with fuchsia_io_VMO_FLAG_EXACT.
-const uint32 VMO_FLAG_PRIVATE = 0x00010000;
-
-// Require an exact (non-cloned) handle to the underlying VMO.
-// The request should fail if a handle to the exact VMO
-// is not returned.
-// May not be supplied with VMO_FLAG_PRIVATE.
-const uint32 VMO_FLAG_EXACT = 0x00020000;
-
-// File defines the interface of a node which contains a flat layout of data.
-[Layout = "Simple"]
-interface File : Node {
- // Read 'count' bytes at the seek offset.
- // The seek offset is moved forward by the number of bytes read.
- Read(uint64 count) -> (zx.status s, vector<uint8>:MAX_BUF data);
-
- // Read 'count' bytes at the provided offset.
- // Does not affect the seek offset.
- ReadAt(uint64 count, uint64 offset) -> (zx.status s, vector<uint8>:MAX_BUF data);
-
- // Write data at the seek offset.
- // The seek offset is moved forward by the number of bytes written.
- Write(vector<uint8>:MAX_BUF data) -> (zx.status s, uint64 actual);
-
- // Write data to the provided offset.
- // Does not affect the seek offset.
- WriteAt(vector<uint8>:MAX_BUF data, uint64 offset) -> (zx.status s, uint64 actual);
-
- Seek(int64 offset, SeekOrigin start) -> (zx.status s, uint64 offset);
-
- // Shrink the file size to 'length' bytes.
- Truncate(uint64 length) -> (zx.status s);
-
- // Acquire the Directory::Open rights and flags used to access this file.
- GetFlags() -> (zx.status s, uint32 flags);
-
- // Change the Directory::Open flags used to access the file.
- // Supported flags which can be turned on / off:
- // - OPEN_FLAG_APPEND
- SetFlags(uint32 flags) -> (zx.status s);
-
- // Acquire a VMO representing this file, if there is one, with the
- // requested access rights.
- GetVmo(uint32 flags) -> (zx.status s, handle<vmo>? vmo);
-};
-
-// Dirent type information associated with the results of ReadDirents.
-const uint8 DIRENT_TYPE_UNKNOWN = 0;
-const uint8 DIRENT_TYPE_DIRECTORY = 4;
-const uint8 DIRENT_TYPE_BLOCK_DEVICE = 6;
-const uint8 DIRENT_TYPE_FILE = 8;
-const uint8 DIRENT_TYPE_SOCKET = 12;
-const uint8 DIRENT_TYPE_SERVICE = 16;
-
-// Nodes which do not have ino values should return this value
-// from Readdir and GetAttr.
-const uint64 INO_UNKNOWN = 0xFFFFFFFFFFFFFFFF;
-
-// Indicates the directory being watched has been deleted.
-const uint8 WATCH_EVENT_DELETED = 0;
-// Indicates a node has been created (either new or moved) into a directory.
-const uint8 WATCH_EVENT_ADDED = 1;
-// Identifies a node has been removed (either deleted or moved) from the directory.
-const uint8 WATCH_EVENT_REMOVED = 2;
-// Identifies a node already existed in the directory when watching started.
-const uint8 WATCH_EVENT_EXISTING = 3;
-// Identifies that no more WATCH_EVENT_EXISTING events will be sent.
-const uint8 WATCH_EVENT_IDLE = 4;
-
-// The following are bitmasks corresponding to the "watch events".
-// They may be used as arguments to the Directory Watch method, to
-// specify which events should receive notifications.
-const uint32 WATCH_MASK_DELETED = 0x00000001;
-const uint32 WATCH_MASK_ADDED = 0x00000002;
-const uint32 WATCH_MASK_REMOVED = 0x00000004;
-const uint32 WATCH_MASK_EXISTING = 0x00000008;
-const uint32 WATCH_MASK_IDLE = 0x00000010;
-const uint32 WATCH_MASK_ALL = 0x0000001F;
-
-// WARNING(ZX-2645): Unused.
-//
-// WatchedEvent describes events returned from a DirectoryWatcher.
-struct WatchedEvent {
- uint8 event;
- uint8 len;
- vector<uint8>:MAX_FILENAME name;
-};
-
-// WARNING(ZX-2645): Unused.
-//
-// DirectoryWatcher transmits messages from a filesystem server
-// about events happening in the filesystem. Clients can register
-// new watchers using the Directory "Watch" method, where they can
-// filter which events they want to receive notifications for.
-[Layout = "Simple"]
-interface DirectoryWatcher {
- // TODO(smklein): Convert this to a vector of WatchedEvents, when possible.
- OnEvent(vector<uint8>:MAX_BUF events);
-};
-
-// Directory defines a node which is capable of containing other Objects.
-[Layout = "Simple", FragileBase]
-interface Directory : Node {
- // Open a new object relative to this directory object.
- Open(uint32 flags, uint32 mode, string:MAX_PATH path, request<Node> object);
-
- // Remove an object relative to this directory object.
- Unlink(string:MAX_PATH path) -> (zx.status s);
-
- // Reads a collection of variably sized dirents into a buffer.
- // The number of dirents in a directory may be very large: akin to
- // calling read multiple times on a file, directories have a seek
- // offset which is updated on subsequent calls to ReadDirents.
- //
- // These dirents are of the form:
- // struct dirent {
- // // Describes the inode of the entry.
- // uint64 ino;
- // // Describes the length of the dirent name.
- // uint8 size;
- // // Describes the type of the entry. Aligned with the
- // // POSIX d_type values. Use DIRENT_TYPE_* constants.
- // uint8 type;
- // // Unterminated name of entry.
- // char name[0];
- // }
- ReadDirents(uint64 max_bytes) -> (zx.status s, vector<uint8>:MAX_BUF dirents);
-
- // Reset the directory seek offset.
- Rewind() -> (zx.status s);
-
- // Acquire a token to a Directory which can be used to identify
- // access to it at a later point in time.
- GetToken() -> (zx.status s, handle? token);
-
- // Within the directory, rename an object named src to the name dst, in
- // a directory represented by token.
- Rename(string:MAX_PATH src, handle dst_parent_token, string:MAX_PATH dst) -> (zx.status s);
-
- // Within the directory, create a link to an object named src by the name
- // dst, within a directory represented by token.
- Link(string:MAX_PATH src, handle dst_parent_token, string:MAX_PATH dst) -> (zx.status s);
-
- // Watches a directory, receiving events of added messages on the
- // watcher request channel.
- //
- // The "watcher" handle will send messages of the form:
- // struct {
- // uint8 event;
- // uint8 len;
- // char name[];
- // };
- // Where names are NOT null-terminated.
- //
- // This API is unstable; in the future, watcher will be a "DirectoryWatcher" client.
- //
- // Mask specifies a bitmask of events to observe.
- // Options must be zero; it is reserved.
- Watch(uint32 mask, uint32 options, handle<channel> watcher) -> (zx.status s);
-};
-
-const uint32 MOUNT_CREATE_FLAG_REPLACE = 0x00000001;
-
-const uint64 MAX_FS_NAME_BUFFER = 32;
-
-struct FilesystemInfo {
- // The number of data bytes which may be stored in a filesystem.
- uint64 total_bytes;
- // The number of data bytes which are in use by the filesystem.
- uint64 used_bytes;
- // The number of nodes which may be stored in the filesystem.
- uint64 total_nodes;
- // The number of nodes used by the filesystem.
- uint64 used_nodes;
- // The amount of space which may be allocated from the underlying
- // volume manager. If unsupported, this will be zero.
- uint64 free_shared_pool_bytes;
- // A unique identifier for this filesystem instance. Will not be preserved
- // across reboots.
- uint64 fs_id;
- // The size of a single filesystem block.
- uint32 block_size;
- // The maximum length of a filesystem name.
- uint32 max_filename_size;
- // A unique identifier for the type of the underlying filesystem.
- uint32 fs_type;
- uint32 padding;
- // TODO(smklein): Replace this field with a string when supported
- // by the "Simple" interface. At the moment, name is a fixed-size,
- // null-terminated buffer.
- array<int8>:MAX_FS_NAME_BUFFER name;
-};
-
-// DirectoryAdmin defines a directory which is capable of handling
-// administrator tasks within the filesystem.
-[Layout = "Simple"]
-interface DirectoryAdmin : Directory {
- // Mount a channel representing a remote filesystem onto this directory.
- // All future requests to this node will be forwarded to the remote filesytem.
- // To re-open a node without forwarding to the remote target, the node
- // should be opened with OPEN_FLAG_NO_RMOTE.
- Mount(Directory remote) -> (zx.status s);
-
- // Atomically create a directory with a provided path, and mount the
- // remote handle to the newly created directory.
- MountAndCreate(Directory remote, string:MAX_FILENAME name, uint32 flags) -> (zx.status s);
-
- // Unmount this filesystem. After this function returns successfully,
- // all connections to the filesystem will be terminated.
- Unmount() -> (zx.status s);
-
- // Detach a node which was previously attached to this directory
- // with Mount.
- UnmountNode() -> (zx.status s, Directory? remote);
-
- // Query the filesystem for filesystem-specific information.
- QueryFilesystem() -> (zx.status s, FilesystemInfo? info);
-
- // Acquire the path to the device backing this filesystem, if there is one.
- GetDevicePath() -> (zx.status s, string:MAX_PATH? path);
-};
diff --git a/fidl/fuchsia.io/meta.json b/fidl/fuchsia.io/meta.json
deleted file mode 100644
index d1eddc4..0000000
--- a/fidl/fuchsia.io/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.io/io.fidl"
- ],
- "name": "fuchsia.io",
- "root": "fidl/fuchsia.io",
- "sources": [
- "fidl/fuchsia.io/io.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ldsvc/ldsvc.fidl b/fidl/fuchsia.ldsvc/ldsvc.fidl
deleted file mode 100644
index d0dbc34..0000000
--- a/fidl/fuchsia.ldsvc/ldsvc.fidl
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ldsvc;
-
-using zx;
-
-// See //zircon/docs/program_loading.md for a more complete
-// description of this and related process bootstrapping protocols, and
-// for specifics about the default global loader service's
-// interpretation of names, paths, and configurations.
-
-// WARNING: This interface is manually implemented in libldmsg.a. Please
-// update that implementation if you change this protocol.
-
-[Layout = "Simple"]
-interface Loader {
- // Cleanly shutdown the connection to the Loader service.
- 1: Done();
-
- // The dynamic linker sends |object_name| and gets back a VMO
- // handle containing the file.
- 2: LoadObject(string:1024 object_name) -> (zx.status rv, handle<vmo>? object);
-
- // The program loader sends the script |interpreter_name| from
- // hashbang and gets back a VMO to execute in place of the script.
- 3: LoadScriptInterpreter(string:1024 interpreter_name) -> (zx.status rv, handle<vmo>? object);
-
- // The dynamic linker sends a |config| identifying its load
- // configuration. This is intended to affect how later
- // |LoadObject| requests decide what particular implementation
- // file to supply for a given name.
- 4: Config(string:1024 config) -> (zx.status rv);
-
- // Obtain a new loader service connection.
- 5: Clone(request<Loader> loader) -> (zx.status rv);
-
- // The program runtime sends a string naming a |data_sink| and
- // transfers the sole handle to a VMO containing the |data| it
- // wants published there. The |data_sink| string identifies a
- // type of data, and the VMO's object name can specifically
- // identify the data set in this VMO. The client must transfer
- // the only handle to the VMO (which prevents the VMO being
- // resized without the receiver's knowledge), but it might still
- // have the VMO mapped in and continue to write data to it. Code
- // instrumentation runtimes use this to deliver large binary trace
- // results.
- //
- // This is intended to be a developer-oriented feature and might
- // not ordinarily be available in production runs.
- 7: DebugPublishDataSink(string:1024 data_sink, handle<vmo> data) -> (zx.status rv);
-
- // The program runtime names a |config_name| referring to a debug
- // configuration of some kind and gets back a VMO to read
- // configuration data from. The sanitizer runtimes use this to
- // allow large options text to be stored in a file rather than
- // passed directly in environment strings.
- //
- // This is intended to be a developer-oriented feature and might
- // not ordinarily be available in production runs.
- 8: DebugLoadConfig(string:1024 config_name) -> (zx.status rv, handle<vmo>? config);
-};
diff --git a/fidl/fuchsia.ldsvc/meta.json b/fidl/fuchsia.ldsvc/meta.json
deleted file mode 100644
index 5d0a840..0000000
--- a/fidl/fuchsia.ldsvc/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.ldsvc/ldsvc.fidl"
- ],
- "name": "fuchsia.ldsvc",
- "root": "fidl/fuchsia.ldsvc",
- "sources": [
- "fidl/fuchsia.ldsvc/ldsvc.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.logger/logger.fidl b/fidl/fuchsia.logger/logger.fidl
deleted file mode 100644
index 28744c9..0000000
--- a/fidl/fuchsia.logger/logger.fidl
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.logger;
-
-using zx;
-
-enum LogLevelFilter : int8 {
- NONE = -1;
- INFO = 0;
- WARN = 1;
- ERROR = 2;
- FATAL = 3;
-};
-
-// Max tags that can be passed to filter by listener.
-const uint8 MAX_TAGS = 5;
-
-// Max tag length that can be passed to filter by listener.
-const uint8 MAX_TAG_LEN_BYTES = 63;
-
-struct LogFilterOptions {
- bool filter_by_pid;
- uint64 pid;
-
- bool filter_by_tid;
- uint64 tid;
-
- // If more than zero, logs would be filtered based on verbosity and
- // |min_severity| would be ignored.
- uint8 verbosity;
-
- LogLevelFilter min_severity;
-
- // If non-empty, return all messages which contain at least one specified
- // tag. If empty, messages will not be filtered by tag.
- // Passed tags should not be more than |MAX_TAG_LEN_BYTES| bytes in length
- // and max tags can be |MAX_TAGS|.
- // Listener would be discarded if the limit is not followed.
- vector<string>:MAX_TAGS tags;
-};
-
-// Max tags that will be attached to a LogMessage.
-const uint8 MAX_TAGS_PER_LOG_MESSAGE = 5;
-
-struct LogMessage {
- uint64 pid;
- uint64 tid;
- // Nanoseconds since the system was powered on, aka ZX_CLOCK_MONOTONIC.
- // https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/clock_get.md#supported-clock-ids
- zx.time time;
- int32 severity;
-
- // See //zircon/system/ulib/syslog/include/syslog/wire_format.h. As messages
- // can be served out of order, this should only be logged if more than last
- // count.
- uint32 dropped_logs;
- vector<string>:MAX_TAGS_PER_LOG_MESSAGE tags;
- string msg;
-};
-
-// Interface for LogListener to register to listen to logs.
-[Discoverable]
-interface Log {
- // Listens to new log entries by calling Log() on |log_listener|.
- // A null |options| indicates no filtering is requested.
- 1: Listen(LogListener log_listener, LogFilterOptions? options);
-
- // Dumps all cached logs by calling LogMany() followed by Done() on
- // |log_listener|.
- // A null |options| indicates no filtering is requested.
- 2: DumpLogs(LogListener log_listener, LogFilterOptions? options);
-};
-
-// Interface to get and listen to socket from syslogger
-[Discoverable]
-interface LogSink {
- // Client connects to send logs over socket
- 1: Connect(handle<socket> socket);
-};
-
-const uint64 MAX_LOG_MANY_SIZE_BYTES = 16384;
-
-interface LogListener {
- // Called for single messages.
- 1: Log(LogMessage log);
-
- // Called when |Log| service is serving cached logs.
- // Max logs size per call is |MAX_LOG_MANY_SIZE_BYTES| bytes.
- 2: LogMany(vector<LogMessage> log);
-
- // Called in the case |DumpLogs()| function of |Log| service was called and
- // all cached logs have been dispatched to this listener.
- 3: Done();
-};
diff --git a/fidl/fuchsia.logger/meta.json b/fidl/fuchsia.logger/meta.json
deleted file mode 100644
index 3f4a950..0000000
--- a/fidl/fuchsia.logger/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.logger/logger.fidl"
- ],
- "name": "fuchsia.logger",
- "root": "fidl/fuchsia.logger",
- "sources": [
- "fidl/fuchsia.logger/logger.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.math/math.fidl b/fidl/fuchsia.math/math.fidl
deleted file mode 100644
index b0e7838..0000000
--- a/fidl/fuchsia.math/math.fidl
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.math;
-
-struct Point {
- int32 x;
- int32 y;
-};
-
-struct PointF {
- float32 x;
- float32 y;
-};
-
-struct Point3F {
- float32 x;
- float32 y;
- float32 z;
-};
-
-struct Size {
- int32 width;
- int32 height;
-};
-
-struct SizeF {
- float32 width;
- float32 height;
-};
-
-struct Rect {
- int32 x;
- int32 y;
- int32 width;
- int32 height;
-};
-
-struct RectF {
- float32 x;
- float32 y;
- float32 width;
- float32 height;
-};
-
-struct RRectF {
- float32 x;
- float32 y;
- float32 width;
- float32 height;
- float32 top_left_radius_x;
- float32 top_left_radius_y;
- float32 top_right_radius_x;
- float32 top_right_radius_y;
- float32 bottom_left_radius_x;
- float32 bottom_left_radius_y;
- float32 bottom_right_radius_x;
- float32 bottom_right_radius_y;
-};
-
-struct Transform {
- // Row major order.
- array<float32>:16 matrix;
-};
-
-struct Inset {
- int32 top;
- int32 right;
- int32 bottom;
- int32 left;
-};
-
-struct InsetF {
- float32 top;
- float32 right;
- float32 bottom;
- float32 left;
-};
diff --git a/fidl/fuchsia.math/meta.json b/fidl/fuchsia.math/meta.json
deleted file mode 100644
index 277f3a2..0000000
--- a/fidl/fuchsia.math/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.math/math.fidl"
- ],
- "name": "fuchsia.math",
- "root": "fidl/fuchsia.math",
- "sources": [
- "fidl/fuchsia.math/math.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.media/audio.fidl b/fidl/fuchsia.media/audio.fidl
deleted file mode 100644
index 46386f9..0000000
--- a/fidl/fuchsia.media/audio.fidl
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-// Ordinal range: 0x0700-0x7ff
-[Discoverable]
-interface Audio {
- 0x0701: CreateAudioRenderer(request<AudioRenderer> audio_renderer_request);
-
- // Create an AudioCapturer which either captures from the current default
- // audio input device, or loops-back from the current default audio output
- // device based on value passed for the the loopback flag.
- //
- // TODO(mpuryear): Get rid of the loopback flag ASAP. Routing decisions (and
- // security surrounding routing decisions) should be much more sophisticated
- // than this. This is just a placeholder until we have a design in place.
- // Eventually, I suspect that all of this will move up into the audio policy
- // manager and application clients will obtain AudioCapturers from and control
- // through the policy manager.
- 0x0702: CreateAudioCapturer(request<AudioCapturer> audio_capturer_request,
- bool loopback);
-
- // System Gain and Mute
- // TODO(mpuryear): remove this systemwide setting once device-centric settings
- // are plumbed into the system UI. Also, device-centric (and certainly
- // systemwide settings) should be moved out of the accessible-to-all public
- // audio interface and relocated to a more restrictive interface that is only
- // accessible by clients with the appropriate privileges (such as system
- // configuration API, or the governor of audio policy).
- //
- // Mirroring device-centric gain and mute stages, Fuchsia's systemwide Gain
- // and Mute settings are fully independent. Changing the value of one does not
- // change the value of the other. Both have the ability to silence a system
- // (or a device, in the case of device Gain/Mute). If Mute is true, or if Gain
- // is kMutedGain, the system is silenced regardless of the other. Similarly,
- // one's value does not restrict the other's possible values in any way.
- //
- // Sets the system-wide gain in decibels. |db| values are clamped to the range
- // -160db to 0db, inclusive. This setting is applied to all audio output
- // devices. Audio input devices are unaffected. System Gain changes do not
- // affect the System Mute state.
- 0x0703: SetSystemGain(float32 gain_db);
-
- // Sets/clears the systemwide 'Mute' state for audio output devices. Audio
- // input devices are unaffected. Changes to the System Mute state do not
- // affect the value of System Gain.
- 0x0704: SetSystemMute(bool muted);
-
- // Provides current values for the systemwide Gain and Mute.
- // When a client connects to Audio, the system enqueues an action (to be
- // executed once the system regains control) to send this newly-connected
- // client a callback with the current systemwide Gain|Mute settings. Further,
- // upon any change to the systemwide Gain|Mute values, the system will trigger
- // all registered callbacks, notifying clients of the new values.
- //
- // Calls to SetSystemMute or SetSystemGain that do NOT result in a change to
- // these values (e.g. calling SetSystemMute(false) when Mute is already false)
- // will not cause the callbacks to be triggered.
- //
- // During and immediately following connecting to Audio, it is essential that
- // clients keep in mind the fundamental single-threaded nature of FIDL.
- // Specifically, if a newly-connected client registers a SystemGainMuteChanged
- // callback before returning, that client will (once the system has subsequent
- // opportunity) be notified via callback of the Gain|Mute settings at the time
- // the connection was established. If however a newly-connected client returns
- // from a FIDL message dispatch (returning control to the FIDL dispatcher),
- // then that client subsequently registers this callback, the client has no
- // way to learn the current Gain|Mute settings until they actually change.
- 0x0705: -> SystemGainMuteChanged(float32 gain_db, bool muted);
-
- 0x0706: SetRoutingPolicy(AudioOutputRoutingPolicy policy);
-};
-
-// A placeholder for various types of simple routing policies. This should be
-// replaced when routing policy moves to a more centralized policy manager.
-enum AudioOutputRoutingPolicy {
- // AudioRenderers are always connected to all audio outputs which currently
- // in the plugged state (eg; have a connector attached to them)
- ALL_PLUGGED_OUTPUTS = 0;
-
- // AudioRenderers are only connected to the output stream which most
- // recently entered the plugged state. AudioRenderers move around from output to
- // output as streams are published/unpublished and become plugged/unplugged.
- //
- // This is the initial setting for audio output routing.
- LAST_PLUGGED_OUTPUT = 1;
-};
-
-// Permitted ranges for AudioRenderer and AudioCapturer
-const uint32 MIN_PCM_CHANNEL_COUNT = 1;
-const uint32 MAX_PCM_CHANNEL_COUNT = 8;
-const uint32 MIN_PCM_FRAMES_PER_SECOND = 1000;
-const uint32 MAX_PCM_FRAMES_PER_SECOND = 192000;
diff --git a/fidl/fuchsia.media/audio_capturer.fidl b/fidl/fuchsia.media/audio_capturer.fidl
deleted file mode 100644
index 84890e2..0000000
--- a/fidl/fuchsia.media/audio_capturer.fidl
+++ /dev/null
@@ -1,307 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-// AudioCapturer
-//
-// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
-// CreateAudioCapturer method, which may be used by clients to capture audio from
-// either the current default audio input device, or the current default audio
-// output device depending on the flags passed during creation.
-//
-// TODO(mpuryear): Routing policy needs to become more capable than this.
-// Clients will need to be able to request sets of inputs/outputs/renderers,
-// make changes to theses sets, have their requests vetted by policy (do they
-// have the permission to capture this private stream, do they have the
-// permission to capture at this frame rate, etc...). Eventually, this
-// functionality will need to be expressed at the AudioPolicy level, not here.
-//
-// ** Format support **
-//
-// See (Get|Set)StreamType below. By default, the captured stream type will be
-// initially determined by the currently configured stream type of the source
-// that the AudioCapturer was bound to at creation time. Users may either fetch this
-// type using GetStreamType, or they may choose to have the media
-// resampled/converted to a type of their choosing by calling SetStreamType.
-// Note: the stream type may only be set while the system is not running,
-// meaning that there are no pending capture regions (specified using CaptureAt)
-// and that the system is not currently running in 'async' capture mode.
-//
-// ** Buffers and memory management **
-//
-// Audio data is captured into a shared memory buffer (a VMO) supplied by the
-// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
-// following requirements related to the management of the payload buffer.
-//
-// ++ The payload buffer must be supplied before any capture operation may
-// start. Any attempt to start capture (via either CaptureAt or
-// StartAsyncCapture) before a payload buffer has been established is an
-// error.
-// ++ The payload buffer may not be changed while there are any capture
-// operations pending.
-// ++ The stream type may not be changed after the payload buffer has been set.
-// ++ The payload buffer must be an integral number of audio frame sizes (in
-// bytes)
-// ++ When running in 'async' mode (see below), the payload buffer must be at
-// least as large as twice the frames_per_packet size specified during
-// StartAsyncCapture.
-// ++ The handle to the payload buffer supplied by the user must be readable,
-// writable, and mappable.
-// ++ Users should always treat the payload buffer as read-only.
-//
-// ** Synchronous vs. Asynchronous capture mode **
-//
-// The AudioCapturer interface can be used in one of two mutually exclusive
-// modes: Synchronous and Asynchronous. A description of each mode and their
-// tradeoffs is given below.
-//
-// (TODO(mpuryear): can we come up with better names than these? Both are
-// really async modes under the hood).
-//
-// ** Synchronous mode **
-//
-// By default, AudioCapturer instances are running in 'sync' mode. They will
-// only capture data when a user supplies at least one region to capture into
-// using the CaptureAt method. Regions supplied in this way will be filled in
-// the order that they are received and returned to the client as StreamPackets
-// via the return value of the CaptureAt method. If an AudioCapturer instance
-// has data to capture, but no place to put it (because there are no more
-// pending regions to fill), the next payload generated will indicate that their
-// has been an overflow by setting the Discontinuity flag on the next produced
-// StreamPacket. Synchronous mode may not be used in conjunction with
-// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
-// the system still regions supplied by CaptureAt waiting to be filled.
-//
-// If a user has supplied regions to be filled by the AudioCapturer instance in
-// the past, but wishes to reclaim those regions, they may do so using the
-// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
-// all pending regions to be returned, but with NO_TIMESTAMP as their
-// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
-// timestamps and discontinuity flags. After a DiscardAllPackets operation,
-// an OnEndOfStream event will be produced. While an AudioCapturer will never
-// overwrite any region of the payload buffer after a completed region is
-// returned, it may overwrite the unfilled portions of a partially filled
-// buffer which has been returned as a result of a flDiscardAllPacketsush
-// operation.
-//
-// ** Asynchronous mode **
-//
-// While running in 'async' mode, clients do not need to explicitly supply
-// regions of the shared buffer to be filled by the AudioCapturer instance.
-// Instead, a client enters into 'async' mode by calling StartAsyncCapture and
-// supplying a callback interface, and a number of frames to capture
-// per-callback. Once running in async mode, the AudioCapturer instance will
-// choose regions of the payload buffer to capture into, capture the specified
-// number of frames, then deliver those frames as StreamPackets using the
-// OnPacketCapture FIDL event. Users may stop capturing are return the
-// AudioCapturer instance to 'sync' mode using the StopAsyncCapture method.
-//
-// It is considered an error to attempt any of the following operations.
-//
-// ++ To attempt to enter 'async' capture mode when no payload buffer has been
-// established.
-// ++ To specify a number of frames to capture per payload which does not permit
-// at least two contiguous capture payloads to exist in the established
-// shared payload buffer simultaneously.
-// ++ To send a region to capture into using the CaptureAt method while the
-// AudioCapturer instance is running in 'async' mode.
-// ++ To attempt to call DiscardAllPackets while the AudioCapturer instance is running
-// in 'async' mode.
-// ++ To attempt to re-start 'async' mode capturing without having first
-// stopped.
-// ++ To attempt any operation except for SetGain while in the process of
-// stopping.
-//
-// ** Synchronizing with a StopAsyncCapture operation **
-//
-// Stopping asynchronous capture mode and returning to synchronous capture mode
-// is an operation which takes time. Aside from SetGain, users may not call any
-// other methods on the AudioCapturer interface after calling StopAsyncCapture
-// (including calling StopAsyncCapture again) until after the stop operation has
-// completed. Because of this, it is important for users to be able to
-// synchronize with the stop operation. Two mechanisms are provided for doing
-// so.
-//
-// The first is to use the StopAsyncCaptureWithCallback method. When the user's
-// callback has been called, they can be certain that stop operation is complete
-// and that the AudioCapturer instance has returned to synchronous operation
-// mode.
-//
-// TODO(mpuryear): Fix obsolete docs.
-// The second way to determine that a stop operation has completed is to use the
-// flags on the packets which get delivered via the user-supplied
-// AudioCapturerCallback interface after calling StopAsyncCapture. When
-// asked to stop, any partially filled packet will be returned to the user, and
-// the final packet returned will always have the end-of-stream flag (kFlagsEos)
-// set on it to indicate that this is the final frame in the sequence. If
-// there is no partially filled packet to return, the AudioCapturer will
-// synthesize an empty packet with no timestamp, and offset/length set to zero,
-// in order to deliver a packet with the end-of-stream flag set on it. Once
-// users have seen the end-of-stream flag after calling stop, the AudioCapturer
-// has finished the stop operation and returned to synchronous operating mode.
-//
-// ** Timing and Overflows **
-//
-// All media packets produced by an AudioCapturer instance will have their PTS
-// field filled out with the capture time of the audio expressed as a timestamp
-// given by the CLOCK_MONOTONIC timeline. Note: this timestamp is actually a
-// capture timestamp, not a presentation timestamp (it is more of a CTS than a
-// PTS) and is meant to represent the underlying system's best estimate of the
-// capture time of the first frame of audio, including all outboard and hardware
-// introduced buffering delay. As a result, all timestamps produced by an
-// AudioCapturer should be expected to be in the past relative to 'now' on the
-// CLOCK_MONOTONIC timeline.
-//
-// TODO(mpuryear): Specify the way in which timestamps relative to a different
-// clock (such as an audio domain clock) may be delivered to a client.
-//
-// The one exception to the "everything has an explicit timestamp" rule is when
-// discarding submitted regions while operating in synchronous mode. Discarded
-// packets have no data in them, but FIDL demands that all pending
-// method-return-value callbacks be executed. Because of this, the regions will
-// be returned to the user, but their timestamps will be set to
-// kNoTimestamp, and their payload sizes will be set to zero. Any
-// partially filled payload will have a valid timestamp, but a payload size
-// smaller than originally requested. The final discarded payload (if there
-// were any to discard) will be followed by an OnEndOfStream event.
-//
-// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
-// the first frame of audio contained in the second packet was capture exactly
-// one nominal frame time after the final frame of audio in the first packet.
-// If this relationship does not hold, the second StreamPacket will have the
-// 'kFlagDiscontinuous' flag set in it's flags field.
-//
-// Even though explicit timestamps are provided on every StreamPacket produced,
-// users who have very precise timing requirements are encouraged to always
-// reason about time by counting frames delivered since the last discontinuity
-// instead of simply using the raw capture timestamps. This is because the
-// explicit timestamps written on continuous packets may have a small amount of
-// rounding error based on whether or not the units of the capture timeline
-// (CLOCK_MONOTONIC) are divisible by the chosen audio frame rate.
-//
-// Users should always expect the first StreamPacket produced by an AudioCapturer
-// to have the discontinuous flag set on it (as there is no previous packet to
-// be continuous with). Similarly, the first StreamPacket after a
-// DiscardAllPackets or a Stop/Start cycle will always be discontinuous. After
-// that, there are only two reasons that a StreamPacket will ever be
-// discontinuous.
-//
-// 1) The user is operating an synchronous mode and does not supply regions to
-// be filled quickly enough. If the next continuous frame of data has not
-// been captured by the time it needs to be purged from the source buffers,
-// an overflow has occurred and the AudioCapturer will flag the next captured
-// region as discontinuous.
-// 2) The user is operating in asynchronous mode and some internal error
-// prevents the AudioCapturer instance from capturing the next frame of audio
-// in a continuous fashion. This might be high system load or a hardware
-// error, but in general it is something which should never normally happen.
-// In practice, however, if it does, the next produced packet will be flagged
-// as being discontinuous.
-//
-// ** Synchronous vs. Asynchronous Trade-offs **
-//
-// The choice of operating in synchronous vs. asynchronous mode is up to the
-// user, and depending on the user's requirements, there are some advantages and
-// disadvantages to each choice.
-//
-// Synchronous mode requires only a single Zircon channel under the hood and can
-// achieve some small savings because of this. In addition, the user has
-// complete control over the buffer management. Users specify exactly where
-// audio will be captured to and in what order. Because of this, if users do
-// not need to always be capturing, it is simple to stop and restart the capture
-// later (just by ceasing to supply packets, then resuming later on). Payloads
-// do not need to be uniform in size either, clients may specify payloads of
-// whatever granularity is appropriate.
-//
-// The primary downside of operating in synchronous mode is that two messages
-// will need to be sent for every packet to be captured. One to inform the
-// AudioCapturer of the instance to capture into, and one to inform the user
-// that the packet has been captured. This may end up increasing overhead and
-// potentially complicating client designs.
-//
-// Asynchronous mode has the advantage requiring only 1/2 of the messages,
-// however, when operating in 'async' mode, AudioCapturer instances have no way
-// of knowing if a user is processing the StreamPackets being sent in a timely
-// fashion, and no way of automatically detecting an overflow condition. Users
-// of 'async' mode should be careful to use a buffer large enough to ensure that
-// they will be able to process their data before an AudioCapturer will be
-// forced to overwrite it.
-//
-// ** Future Directions (aka TODOs) **
-//
-// ++ Consider adding a 'zero message' capture mode where the AudioCapturer
-// simply supplies a linear transformation and some buffer parameters (max
-// audio hold time) each time that it is started in 'async' mode, or each
-// time an internal overflow occurs in 'async' mode. Based on this
-// information, client should know where the capture write pointer is at all
-// times as a function of the transformation removing the need to send any
-// buffer position messages. This would reduce the operational overhead just
-// about as low as it could go, and could allow for the lowest possible
-// latency for capture clients. OTOH - it might be better to achieve this
-// simply by allowing clients to be granted direct, exclusive access to the
-// driver level of capture if no resampling, reformatting, or sharing is
-// needed.
-// ++ Consider providing some mechanism by which users may specify the exact
-// time at which they want to capture data.
-// ++ Allow for more complex routing/mixing/AEC scenarios and place this under
-// the control of the policy manager.
-// ++ Define and enforce access permissions and downsampling requirements for
-// sensitive content. Enforce using the policy manager.
-// ++ Consider allowing the mixer to produce compressed audio.
-//
-// Ordinal range: 0x0500-0x5ff
-[FragileBase]
-interface AudioCapturer : StreamBufferSet, StreamSource {
- // Sets the stream type of the stream to be delivered. Causes the source
- // material to be reformatted/resampled if needed in order to produce the
- // requested stream type. Note that the stream type may not be changed after
- // the payload buffer has been established.
- 0x0501: SetPcmStreamType(AudioStreamType stream_type);
-
- // Explicitly specify a region of the shared payload buffer for the audio
- // input to capture into.
- 0x0502: CaptureAt(uint32 payload_buffer_id, uint32 payload_offset,
- uint32 frames) -> (StreamPacket captured_packet);
-
- // Place the AudioCapturer into 'async' capture mode and begin to produce packets
- // of exactly 'frames_per_packet' number of frames each. The
- // OnPacketProduced event (of StreamSink) will be used to inform the client of
- // produced packets.
- 0x0503: StartAsyncCapture(uint32 frames_per_packet);
-
- // Stop capturing in 'async' capture mode and (optionally) deliver a
- // callback that may be used by the client if explicit synchronization
- // is needed.
- 0x0504: StopAsyncCapture() -> ();
- 0x0505: StopAsyncCaptureNoReply();
-
- // Binds to the gain control for this AudioCapturer.
- 0x0506: BindGainControl(request<GainControl> gain_control_request);
-
- /////////////////////////////////////////////////////////////////////////////
- // StreamBufferSet methods
- // See stream.fidl.
-
- /////////////////////////////////////////////////////////////////////////////
- // StreamSource methods
- // See stream.fidl.
-
- /////////////////////////////////////////////////////////////////////////////
- // Methods to be deprecated
- // These methods will go away.
-
- // Gets the currently configured stream type. Note: for an AudioCapturer which was
- // just created and has not yet had its stream type explicitly set, this will
- // retrieve the stream type -- at the time the AudioCapturer was created -- of the
- // source (input or looped-back output) to which the AudioCapturer is bound.
- //
- // TODO(mpuryear): Get rid of this. Eventually, AudioCapturers will be bindable to
- // a set of inputs/outputs/renderers, so the concept of a "native" stream type
- // will go away. Mechanisms will need to be put in place to allow users to
- // enumerate the configuration of these bind-able endpoints (and perhaps to
- // exercise control over them), but it will be the user of the AudioCapturer's job
- // to specify the format they want.
- 0xffff: GetStreamType() -> (StreamType stream_type);
-};
diff --git a/fidl/fuchsia.media/audio_device_enumerator.fidl b/fidl/fuchsia.media/audio_device_enumerator.fidl
deleted file mode 100644
index 807b5c6..0000000
--- a/fidl/fuchsia.media/audio_device_enumerator.fidl
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-const uint32 AudioGainInfoFlag_Mute = 0x01;
-const uint32 AudioGainInfoFlag_AgcSupported = 0x02;
-const uint32 AudioGainInfoFlag_AgcEnabled = 0x04;
-
-struct AudioGainInfo {
- float32 gain_db;
- uint32 flags;
-};
-
-struct AudioDeviceInfo {
- string name;
- string unique_id;
- uint64 token_id;
- bool is_input;
-
- // TODO(mpuryear): Verify whether or not we want to leave this stuff in place
- // or not. Technically it is not needed (all of these things could be
- // queried), but it seems like useful information to send during device
- // enumeration as it saves a user a round trip to the server and eliminates
- // any need to have extra states in a user's state machine when trying to
- // figure out the current state of a device during initial enumeration.
- AudioGainInfo gain_info;
- bool is_default;
-};
-
-const uint32 SetAudioGainFlag_GainValid = 0x01;
-const uint32 SetAudioGainFlag_MuteValid = 0x02;
-const uint32 SetAudioGainFlag_AgcValid = 0x04;
-
-[Discoverable]
-interface AudioDeviceEnumerator {
- // Obtain the list of currently active audio devices.
- 100: GetDevices() -> (vector<AudioDeviceInfo> devices);
-
- // Events sent when devices are added or removed, or when properties of a
- // device change.
- //
- // TODO(mpuryear): Should we have a set of filters which control which of these
- // events a user receives?
- //
- // Pro: Having filters like this removes the need for the server to send
- // messages to clients who don't care. In particular, it seems likely that a
- // client who just called SetDeviceGain will not care about the
- // OnDeviceGainChanged event being fired.
- //
- // Con: Having filters like this means that the server needs to maintain a bit
- // more per-client state.
- 110: -> OnDeviceAdded(AudioDeviceInfo device);
- 111: -> OnDeviceRemoved(uint64 device_token);
- 112: -> OnDeviceGainChanged(uint64 device_token, AudioGainInfo gain_info);
- 113: -> OnDefaultDeviceChanged(uint64 old_default_token,
- uint64 new_default_token);
-
- // Gain/Mute/AGC control
- //
- // Note that each of these operations requires a device_token in order to
- // target the proper input/output.
- //
- // The Get command returns the device_token
- // of the device whose gain is being reported, or ZX_KOID_INVALID in the case
- // that the requested device_token was invalid or the device had been removed
- // from the system before the Get command could be processed.
- //
- // Set commands which are given an invalid device token are ignored and have
- // no effect on the system. In addition, users do not need to control all of
- // the gain settings for an audio device with each call. Only the settings
- // with a corresponding flag set in the set_flags parameter will be affected.
- // For example, passing SetAudioGainFlag_MuteValid will cause a SetDeviceGain
- // call to care only about the mute setting in the gain_info structure, while
- // passing (SetAudioGainFlag_GainValid | SetAudioGainFlag_MuteValid) will
- // cause both the mute and the gain status to be changed simultaneously.
- 200: GetDeviceGain(uint64 device_token)
- -> (uint64 device_token, AudioGainInfo gain_info);
- 201: SetDeviceGain(uint64 device_token,
- AudioGainInfo gain_info,
- uint32 set_flags);
-
- // Default Device
- //
- // Fetch the device ID of the current default input or output device, or
- // ZX_KOID_INVALID if no such device exists.
- //
- // TODO(mpuryear): solidify the concept of "default" device. Right now, it
- // basically means the device which would be chosen as the destination of an
- // AudioRenderer stream (or the source for an AudioCapturer stream), in the
- // absence of...
- //
- // 1) Any manual routing configuration imposed by the user.
- // 2) Any property based routing decision made by the audio service.
- //
- // Currently, this translates to "the default inputs/output will be the last
- // plugged input/output". As the human level logic which drives the audio
- // routing policy evolves and becomes more complicated, this will probably
- // change.
- 300: GetDefaultInputDevice() -> (uint64 device_token);
- 301: GetDefaultOutputDevice() -> (uint64 device_token);
-};
diff --git a/fidl/fuchsia.media/audio_renderer.fidl b/fidl/fuchsia.media/audio_renderer.fidl
deleted file mode 100644
index 525eee1..0000000
--- a/fidl/fuchsia.media/audio_renderer.fidl
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-//
-// AudioRenderers can be in one of two states at any point in time, either
-// the configurable state or the operational state. A renderer is considered
-// to be operational any time it has packets queued and waiting to be
-// rendered; otherwise it is considered to be in the configurable state. When an
-// AudioRenderer has entered the operational state of its life, any attempt to
-// call a config method in the interface is considered to be illegal and will
-// result in termination of the interface's connection to the audio service.
-//
-// If an AudioRenderer must be reconfigured, it is best practice to always call
-// `DiscardAllPackets` on the AudioRenderer, before starting to reconfigure it.
-//
-
-// Ordinal range: 0x0600-0x6ff
-[FragileBase]
-interface AudioRenderer : StreamBufferSet, StreamSink {
- // Sets the type of the stream to be delivered by the client. Using this
- // method implies that the stream encoding is AUDIO_ENCODING_LPCM.
- 0x0601: SetPcmStreamType(AudioStreamType type);
-
- // Sets the stream type to be delivered by the client. This method is used for
- // compressed pass-through. The media_specific field must be of type audio.
- // NOTE: Not currently implemented.
- 0x0602: SetStreamType(StreamType type);
-
- // Sets the units used by the presentation (media) timeline. By default, PTS
- // units are nanoseconds (as if this were called with values of 1e9 and 1).
- 0x0603: SetPtsUnits(uint32 tick_per_second_numerator,
- uint32 tick_per_second_denominator);
-
- // Sets the maximum threshold (in frames) between an explicit PTS (user-
- // provided) and an expected PTS (determined using interpolation). Beyond this
- // threshold, a stream is no longer considered 'continuous' by the renderer.
- //
- // Defaults to RoundUp((AudioFPS/PTSTicksPerSec) / 2.0) / AudioFPS
- // Most users should not need to change this value from its default.
- //
- // Example:
- // A user is playing back 48KHz audio from a container, which also contains
- // video and needs to be synchronized with the audio. The timestamps are
- // provided explicitly per packet by the container, and expressed in mSec
- // units. This means that a single tick of the media timeline (1 mSec)
- // represents exactly 48 frames of audio. The application in this scenario
- // delivers packets of audio to the AudioRenderer, each with exactly 470
- // frames of audio, and each with an explicit timestamp set to the best
- // possible representation of the presentation time (given this media clock's
- // resolution). So, starting from zero, the timestamps would be..
- //
- // [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
- //
- // In this example, attempting to use the presentation time to compute the
- // starting frame number of the audio in the packet would be wrong the
- // majority of the time. The first timestamp is correct (by definition), but
- // it will be 24 packets before the timestamps and frame numbers come back
- // into alignment (the 24th packet would start with the 11280th audio frame
- // and have a PTS of exactly 235).
- //
- // One way to fix this situation is to set the PTS continuity threshold
- // (henceforth, CT) for the stream to be equal to 1/2 of the time taken by the
- // number of frames contained within a single tick of the media clock, rounded
- // up. In this scenario, that would be 24.0 frames of audio, or 500 uSec.
- // Any packets whose expected PTS was within +/-CT frames of the explicitly
- // provided PTS would be considered to be a continuation of the previous frame
- // of audio.
- //
- // Other possible uses:
- // Users who are scheduling audio explicitly, relative to a clock which has
- // not been configured as the reference clock, can use this value to control
- // the maximum acceptable synchronization error before a discontinuity is
- // introduced. E.g., if a user is scheduling audio based on a recovered common
- // media clock, and has not published that clock as the reference clock, and
- // they set the CT to 20mSec, then up to 20mSec of drift error can accumulate
- // before the AudioRenderer deliberately inserts a presentation discontinuity
- // to account for the error.
- //
- // Users whose need to deal with a container where their timestamps may be
- // even less correct than +/- 1/2 of a PTS tick may set this value to
- // something larger. This should be the maximum level of inaccuracy present
- // in the container timestamps, if known. Failing that, it could be set to
- // the maximum tolerable level of drift error before absolute timestamps are
- // explicitly obeyed. Finally, a user could set this number to a very large
- // value (86400.0 seconds, for example) to effectively cause *all* timestamps
- // to be ignored after the first, thus treating all audio as continuous with
- // previously delivered packets. Conversely, users who wish to *always*
- // explicitly schedule their audio packets exactly may specify a CT of 0.
- //
- 0x0604: SetPtsContinuityThreshold(float32 threshold_seconds);
-
- // Set the reference clock used to control playback rate.
- //
- // TODO(mpuryear): refine this type when we solidly define what a clock handle
- // is/looks like. Also should we allow users to lock their rates to CLOCK_MONO
- // instead of following the default (perhaps dynamic) system rate?
- 0x0605: SetReferenceClock(handle reference_clock);
-
- // Immediately put the AudioRenderer into a playing state. Start the advance
- // of the media timeline, using specific values provided by the caller (or
- // default values if not specified). In an optional callback, return the
- // timestamp values ultimately used -- these set the ongoing relationship
- // between the media and reference timelines (i.e., how to translate between
- // the domain of presentation timestamps, and the realm of local system time).
- //
- // Local system time is specified in units of nanoseconds; media_time is
- // specified in the units defined by the user in the `SetPtsUnits` function,
- // or nanoseconds if `SetPtsUnits` is not called.
- //
- // The act of placing an AudioRenderer into the playback state establishes a
- // relationship between 1) the user-defined media (or presentation) timeline
- // for this particular AudioRenderer, and 2) the real-world system reference
- // timeline. To communicate how to translate between timelines, the Play()
- // callback provides an equivalent timestamp in each time domain. The first
- // value ('reference_time') is given in terms of the local system clock; the
- // second value ('media_time') is what media instant exactly corresponds to
- // that local time. Restated, the frame at 'media_time' in the audio stream
- // should be presented at system local time 'reference_time'.
- //
- // Note: on calling this API, media_time immediately starts advancing. It is
- // possible, although uncommon, for a caller to specify a system time that is
- // far in the past, or far into the future. This, along with the specified
- // media time, is simply used to determine what media time corresponds to
- // 'now', and THAT media time is then intersected with presentation
- // timestamps of packets already submitted, to determine which media frames
- // should be presented next.
- //
- // With the corresponding reference_time and media_time values, a user can
- // translate arbitrary time values from one timeline into the other. After
- // calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
- // given the 'ref_start' and 'media_start' values from `Play()`, then for any
- // 'ref_time':
- //
- // media_time = ( (ref_time - ref_start) / 1e9
- // * (pts_per_sec_numerator / pts_per_sec_denominator) )
- // + media_start
- //
- // Conversely, for any presentation timestamp 'media_time':
- //
- // ref_time = ( (media_time - media_start)
- // * (pts_per_sec_denominator / pts_per_sec_numerator)
- // * 1e9 )
- // + ref_start
- //
- // Users, depending on their use case, may optionally choose not to specify
- // one or both of these timestamps. A timestamp may be omitted by supplying
- // the special value 'kNoTimestamp'. The AudioRenderer automatically deduces
- // any omitted timestamp value using the following rules:
- //
- // Reference Time
- // If 'reference_time' is omitted, the AudioRenderer will select a "safe"
- // reference time to begin presentation, based on the minimum lead times for
- // the output devices that are currently bound to this AudioRenderer. For
- // example, if an AudioRenderer is bound to an internal audio output
- // requiring at least 3 mSec of lead time, and an HDMI output requiring at
- // least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
- // is omitted) select a reference time 80 mSec from now.
- //
- // Media Time
- // If media_time is omitted, the AudioRenderer will select one of two values.
- // - If the AudioRenderer is resuming from the paused state, and packets have
- // not been discarded since being paused, then the AudioRenderer will use a
- // media_time corresponding to the instant at which the presentation became
- // paused.
- // - If the AudioRenderer is being placed into a playing state for the first
- // time following startup or a 'discard packets' operation, the initial
- // media_time will be set to the PTS of the first payload in the pending
- // packet queue. If the pending queue is empty, initial media_time will be
- // set to zero.
- //
- // Return Value
- // When requested, the AudioRenderer will return the 'reference_time' and
- // 'media_time' which were selected and used (whether they were explicitly
- // specified or not) in the return value of the play call.
- //
- // Examples
- // 1. A user has queued some audio using `SendPacket` and simply wishes them
- // to start playing as soon as possible. The user may call Play without
- // providing explicit timestamps -- `Play(kNoTimestamp, kNoTimestamp)`.
- //
- // 2. A user has queued some audio using `SendPacket`, and wishes to start
- // playback at a specified 'reference_time', in sync with some other media
- // stream, either initially or after discarding packets. The user would call
- // `Play(reference_time, kNoTimestamp)`.
- //
- // 3. A user has queued some audio using `SendPacket`. The first of these
- // packets has a PTS of zero, and the user wishes playback to begin as soon as
- // possible, but wishes to skip all of the audio content between PTS 0 and PTS
- // 'media_time'. The user would call `Play(kNoTimestamp, media_time)`.
- //
- // 4. A user has queued some audio using `SendPacket` and want to present this
- // media in synch with another player in a different device. The coordinator
- // of the group of distributed players sends an explicit message to each
- // player telling them to begin presentation of audio at PTS 'media_time', at
- // the time (based on the group's shared reference clock) 'reference_time'.
- // Here the user would call `Play(reference_time, media_time)`.
- //
- // TODO(mpuryear): Define behavior in the case that a user calls `Play` while
- // the system is already playing. We should probably do nothing but return a
- // valid correspondence pair in response -- unless both reference and media
- // times are provided (and do not equate to the current timeline
- // relationship), in which case we should introduce a discontinuity.
- //
- // TODO(mpuryear): Collapse these if we ever have optional retvals in FIDL
- 0x0606: Play(int64 reference_time, int64 media_time)
- -> (int64 reference_time, int64 media_time);
- 0x0607: PlayNoReply(int64 reference_time, int64 media_time);
-
- // Immediately put the AudioRenderer into the paused state and then report the
- // relationship between the media and reference timelines which was
- // established (if requested).
- //
- // TODO(mpuryear): Define behavior in the case that a user calls `Pause` while
- // the system is already in the paused state. We should probably do nothing
- // but provide a valid correspondence pair in response.
- //
- // TODO(mpuryear): Collapse these if we ever have optional retvals in FIDL
- 0x0608: Pause() -> (int64 reference_time, int64 media_time);
- 0x0609: PauseNoReply();
-
- // Enable or disable notifications about changes to the minimum clock lead
- // time (in nanoseconds) for this AudioRenderer. Calling this method with
- // 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
- // event with the current minimum lead time for the AudioRenderer. If the
- // value changes, an `OnMinLeadTimeChanged` event will be raised with the new
- // value. This behavior will continue until the user calls
- // `EnableMinLeadTimeEvents(false)`.
- //
- // The minimum clock lead time is the amount of time ahead of the reference
- // clock's understanding of "now" that packets needs to arrive (relative to
- // the playback clock transformation) in order for the mixer to be able to mix
- // packet. For example...
- //
- // ++ Let the PTS of packet X be P(X)
- // ++ Let the function which transforms PTS -> RefClock be R(p) (this function
- // is determined by the call to Play(...)
- // ++ Let the minimum lead time be MLT
- //
- // If R(P(X)) < RefClock.Now() + MLT
- // Then the packet is late, and some (or all) of the packet's payload will
- // need to be skipped in order to present the packet at the scheduled time.
- //
- // TODO(mpuryear): What should the units be here? Options include...
- //
- // 1) Normalized to nanoseconds (this is the current API)
- // 2) Reference clock units (what happens if the reference clock changes?)
- // 3) PTS units (what happens when the user changes the PTS units?)
- //
- // TODO(mpuryear): Should `EnableMinLeadTimeEvents` have an optional -> ()
- // return value for synchronization purposes? Probably not; users should be
- // able to send a disable request and clear their event handler if they no
- // longer want notifications. Their in-process dispatcher framework can handle
- // draining and dropping any lead time changed events that were already in
- // flight when the disable message was sent.
- //
- 0x060a: EnableMinLeadTimeEvents(bool enabled);
- 0x060b: -> OnMinLeadTimeChanged(int64 min_lead_time_nsec);
-
- // TODO(mpuryear): Eliminate this method when possible. Right now, it is used
- // by code requiring synchronous FIDL interfaces to talk to AudioRenderers.
- 0x060c: GetMinLeadTime() -> (int64 min_lead_time_nsec);
-
- // Binds to the gain control for this AudioRenderer.
- 0x060d: BindGainControl(request<GainControl> gain_control_request);
-
- /////////////////////////////////////////////////////////////////////////////
- // StreamBufferSet methods
- // See stream.fidl.
-
- /////////////////////////////////////////////////////////////////////////////
- // StreamSink methods
- // See stream.fidl.
-
- // TODO(mpuryear): Spec methods/events which can be used for unintentional
- // discontinuity/underflow detection.
- //
- // TODO(mpuryear): Spec methods/events which can be used to report routing
- // changes. (Presuming that they belong at this level at all; they may belong
- // on some sort of policy object).
- //
- // TODO(mpuryear): Spec methods/events which can be used to report policy
- // induced gain/ducking changes. (Presuming that they belong at this level at
- // all; they may belong on some sort of policy object).
-};
diff --git a/fidl/fuchsia.media/gain_control.fidl b/fidl/fuchsia.media/gain_control.fidl
deleted file mode 100644
index a9f2b6d..0000000
--- a/fidl/fuchsia.media/gain_control.fidl
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-enum AudioRamp : uint16 {
- // Amplitude scale changes evenly ("straight-line") across the ramp duration.
- SCALE_LINEAR = 1;
-
- // Additional ramp shapes (easings) may be added in the future, perhaps
- // including logarithmic (i.e. linear wrt dB), cubic (in/out/inout) or others.
-};
-
-// Ordinal range: 0x0100-0x1ff
-interface GainControl {
- // Sets the gain in decibels.
- 0x0101: SetGain(float32 gain_db);
-
- // Smoothly change gain from its current value to specified value, over the
- // specified duration (in milliseconds). If 'duration_ns' is 0, gain changes
- // immediately. Otherwise, the gain changes only while the stream is running.
- //
- // Any active or pending ramp is cancelled by subsequent call to SetGain.
- //
- // There can be at most 1 active ramp at any time. Any active or pending ramp
- // is replaced by a later call to SetGainWithRamp (even if duration is 0). In
- // this case gain would ramps directly from its most recent (mid-ramp) value
- // to the newly-specified one, over the new duration, using the new easing.
- //
- // Usage example (using time in seconds):
- // Time 0
- // SetGainWithRamp(MUTED_GAIN_DB, 0, SCALE_LINEAR) // Ramp 1
- // SetGainWithRamp(0.0f, ZX_SEC(4), SCALE_LINEAR) // Ramp 2
- // Time 3
- // PlayNoReply(kNoTimestamp, any_media_time)
- // Time 4
- // PauseNoReply()
- // Time 7
- // PlayNoReply(kNoTimestamp, any_media_time)
- // Time 8
- // SetGainWithRamp(MUTED_GAIN_DB, ZX_SEC(1), SCALE_LINEAR) // Ramp 3
- //
- //
- // Time 0: Ramp 1 completes immediately, changing the gain to MUTED_GAIN_DB.
- // Ramp 2 is pending, since we are not in playback.
- // Time 3, Ramp 2 begins ramping from MUTED_GAIN_DB to 0 dB (scale 0.0=>1.0).
- // Time 4: Ramp 2 pauses (3s remain). Per SCALE_LINEAR, scale is approx 0.25.
- // Time 7: Ramp 2 resumes from most recent value toward the target.
- // Time 8: Ramp 3 replaces Ramp 2 and starts from current scale (approx 0.5).
- // Time 9: Ramp 3 completes; current scale value is now 0.0 (MUTED_GAIN_DB).
- //
- 0x0102: SetGainWithRamp(float32 gain_db,
- int64 duration_ns,
- AudioRamp rampType);
-
- // Sets the mute value. Ramping and Mute are fully independent, although of
- // course they both affect the scalingthat is applied to the audio stream(s).
- 0x0103: SetMute(bool muted);
-
- // Provides current gain/mute values to those who register for notification.
- //
- // TODO(mpuryear): provide ramp-related values in this event, as well.
- //
- // TODO(mpuryear): notify upon ramp milestones (not just SetGain/Mute) --
- // upon the start/pause/restart/completion of an active ramp?
- 0x0104: -> OnGainMuteChanged(float32 gain_db, bool muted);
-};
-
-const float32 MUTED_GAIN_DB = -160.0;
-
-const float32 MAX_GAIN_DB = 24.0;
diff --git a/fidl/fuchsia.media/meta.json b/fidl/fuchsia.media/meta.json
deleted file mode 100644
index 6619b07..0000000
--- a/fidl/fuchsia.media/meta.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.media/audio.fidl",
- "fidl/fuchsia.media/audio_capturer.fidl",
- "fidl/fuchsia.media/audio_device_enumerator.fidl",
- "fidl/fuchsia.media/audio_renderer.fidl",
- "fidl/fuchsia.media/gain_control.fidl",
- "fidl/fuchsia.media/stream.fidl",
- "fidl/fuchsia.media/stream_type.fidl"
- ],
- "name": "fuchsia.media",
- "root": "fidl/fuchsia.media",
- "sources": [
- "fidl/fuchsia.media/audio.fidl",
- "fidl/fuchsia.media/audio_capturer.fidl",
- "fidl/fuchsia.media/audio_device_enumerator.fidl",
- "fidl/fuchsia.media/audio_renderer.fidl",
- "fidl/fuchsia.media/gain_control.fidl",
- "fidl/fuchsia.media/stream.fidl",
- "fidl/fuchsia.media/stream_type.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.media/stream.fidl b/fidl/fuchsia.media/stream.fidl
deleted file mode 100644
index a8b871b..0000000
--- a/fidl/fuchsia.media/stream.fidl
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-// Manages a set of payload buffers for a stream.
-// Ordinal range: 0x0200-0x2ff
-[FragileBase]
-interface StreamBufferSet {
- // Adds a payload buffer for stream packets. StreamPacket structs reference
- // a payload buffer by ID using the StreamPacket.payload_buffer_id field.
- 0x0201: AddPayloadBuffer(uint32 id, handle<vmo> payload_buffer);
-
- // Removes a payload buffer.
- 0x0202: RemovePayloadBuffer(uint32 id);
-};
-
-// Consumes a stream of packets.
-// Ordinal range: 0x0300-03ff
-[FragileBase]
-interface StreamSink {
- // Sends a packet to this object. The response is sent when this object is
- // done with the associated payload memory.
- 0x0301: SendPacket(StreamPacket packet) -> ();
-
- // Sends a packet to this object. This interface doesn't define how the client
- // knows when the sink is done with the associated payload memory. The
- // inheriting interface must define that.
- 0x0302: SendPacketNoReply(StreamPacket packet);
-
- // Indicates the stream has ended.
- 0x0303: EndOfStream();
-
- // Discards packets previously sent via SendPacket or SendPacketNoReply.
- 0x0304: DiscardAllPackets() -> ();
- 0x0305: DiscardAllPacketsNoReply();
-};
-
-// Produces a stream of packets.
-// Ordinal range: 0x0400-04ff
-[FragileBase]
-interface StreamSource {
- // Delivers a packet produced by this object. Each packet delivered via this
- // event must be released with a call to ReleasePacket.
- 0x0401: -> OnPacketProduced(StreamPacket packet);
-
- // Indicates that the stream has ended.
- 0x0402: -> OnEndOfStream();
-
- // Releases a packet delivered via OnPacketProduced.
- 0x0403: ReleasePacket(StreamPacket packet);
-
- // Discards queued packets.
- 0x0404: DiscardAllPackets() -> ();
- 0x0405: DiscardAllPacketsNoReply();
-};
-
-// A StreamSink that uses StreamBufferSet for buffer management.
-interface SimpleStreamSink : StreamSink, StreamBufferSet {
- ////////////////////////////////////////////////////////////////////////////
- // StreamBufferSet methods
-
- ////////////////////////////////////////////////////////////////////////////
- // StreamSink methods
-};
-
-// Describes a packet consumed by StreamSink or produced by StreamSource.
-struct StreamPacket {
- // Time at which the packet is to be presented, according to the presentation
- // clock.
- int64 pts = NO_TIMESTAMP;
-
- // ID of the payload buffer used for this packet. When this struct is used
- // with StreamBufferSet, this field is the ID of a payload buffer provided
- // via StreamBufferSet.AddPayloadBuffer. Other interfaces may define other
- // semantics for this field.
- uint32 payload_buffer_id;
-
- // Offset of the packet payload in the payload buffer.
- uint64 payload_offset;
-
- // Size in bytes of the payload.
- uint64 payload_size;
-
- // A collection of flags (see constants below) describing properties of this
- // packet.
- uint32 flags = 0;
-
- // The buffer configuration associated with this packet. The semantics of
- // this field depend on the the interface with which this struct is used.
- // In many contexts, this field is not used.
- uint64 buffer_config = 0;
-
- // The stream associated with this packet. The semantics of this field
- // depend on the the interface with which this struct is used. In many
- // contexts, this field is not used.
- uint64 stream_id = 0;
-};
-
-const uint32 STREAM_PACKET_FLAG_KEY_FRAME = 0x01;
-const uint32 STREAM_PACKET_FLAG_DROPPABLE = 0x02;
-const uint32 STREAM_PACKET_FLAG_DISCONTINUITY = 0x04;
-
-const int64 NO_TIMESTAMP = 0x7fffffffffffffff;
diff --git a/fidl/fuchsia.media/stream_type.fidl b/fidl/fuchsia.media/stream_type.fidl
deleted file mode 100644
index e37e010..0000000
--- a/fidl/fuchsia.media/stream_type.fidl
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.media;
-
-// Describes the type of an elementary stream.
-struct StreamType {
- // Medium-specific type information.
- MediumSpecificStreamType medium_specific;
-
- // Encoding (see constants below).
- string encoding;
-
- // Encoding-specific parameters.
- vector<uint8>? encoding_parameters;
-};
-
-// A union of all medium-specific stream type structs.
-union MediumSpecificStreamType {
- AudioStreamType audio;
- VideoStreamType video;
- TextStreamType text;
- SubpictureStreamType subpicture;
-};
-
-const string MEDIA_ENCODING_UNSUPPORTED = "fuchsia.media.unsupported";
-
-const string AUDIO_ENCODING_AAC = "fuchsia.media.aac";
-const string AUDIO_ENCODING_AMRNB = "fuchsia.media.amrnb";
-const string AUDIO_ENCODING_AMRWB = "fuchsia.media.amrwb";
-const string AUDIO_ENCODING_APTX = "fuchsia.media.aptx";
-const string AUDIO_ENCODING_FLAC = "fuchsia.media.flac";
-const string AUDIO_ENCODING_GSMMS = "fuchsia.media.gsmms";
-const string AUDIO_ENCODING_LPCM = "fuchsia.media.lpcm";
-const string AUDIO_ENCODING_MP3 = "fuchsia.media.mp3";
-const string AUDIO_ENCODING_PCMALAW = "fuchsia.media.pcmalaw";
-const string AUDIO_ENCODING_PCMMULAW = "fuchsia.media.pcmmulaw";
-const string AUDIO_ENCODING_SBC = "fuchsia.media.sbc";
-const string AUDIO_ENCODING_VORBIS = "fuchsia.media.vorbis";
-
-const string VIDEO_ENCODING_H263 = "fuchsia.media.h263";
-const string VIDEO_ENCODING_H264 = "fuchsia.media.h264";
-const string VIDEO_ENCODING_MPEG4 = "fuchsia.media.mpeg4";
-const string VIDEO_ENCODING_THEORA = "fuchsia.media.theora";
-const string VIDEO_ENCODING_UNCOMPRESSED = "fuchsia.media.uncompressed_video";
-const string VIDEO_ENCODING_VP3 = "fuchsia.media.vp3";
-const string VIDEO_ENCODING_VP8 = "fuchsia.media.vp8";
-const string VIDEO_ENCODING_VP9 = "fuchsia.media.vp9";
-
-///////////////////////////////////////////////////////////////////////////////
-// Audio
-
-// Describes the type of an audio elementary stream.
-struct AudioStreamType {
- AudioSampleFormat sample_format;
- uint32 channels;
- uint32 frames_per_second;
- // TODO(mpuryear): Add channel config.
-};
-
-enum AudioSampleFormat {
- // 8-bit unsigned samples, sample size 1 byte.
- UNSIGNED_8 = 1;
-
- // 16-bit signed samples, host-endian, sample size 2 bytes.
- SIGNED_16 = 2;
-
- // 24-bit signed samples in 32 bits, host-endian, sample size 4 bytes.
- SIGNED_24_IN_32 = 3;
-
- // 32-bit floating-point samples, sample size 4 bytes.
- FLOAT = 4;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// Video
-
-// Describes the type of a video elementary stream.
-struct VideoStreamType {
- VideoProfile profile;
- // TODO(dalesat): Use fuchsia.images.PixelFormat.
- PixelFormat pixel_format;
- // TODO(dalesat): Use fuchsia.images.ColorSpace.
- ColorSpace color_space;
- uint32 width;
- uint32 height;
- uint32 coded_width;
- uint32 coded_height;
- uint32 pixel_aspect_ratio_width;
- uint32 pixel_aspect_ratio_height;
- // TODO(dalesat): Change to single line_stride value for all planes.
- vector<uint32> line_stride;
- // TODO(dalesat): Remove.
- vector<uint32> plane_offset;
-};
-
-// TODO(dalesat): Blindly copied from Chromium, revisit.
-enum VideoProfile {
- UNKNOWN = 0;
- NOT_APPLICABLE = 1;
- H264_BASELINE = 2;
- H264_MAIN = 3;
- H264_EXTENDED = 4;
- H264_HIGH = 5;
- H264_HIGH10 = 6;
- H264_HIGH422 = 7;
- H264_HIGH444_PREDICTIVE = 8;
- H264_SCALABLE_BASELINE = 9;
- H264_SCALABLE_HIGH = 10;
- H264_STEREO_HIGH = 11;
- H264_MULTIVIEW_HIGH = 12;
-};
-
-// TODO(dalesat): Replace with fuchsia.images.PixelFormat.
-enum PixelFormat {
- UNKNOWN = 0;
- I420 = 1; // 12bpp YUV planar 1x1 Y, 2x2 UV samples, a.k.a. YU12.
- YV12 = 2; // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
- YV16 = 3; // 16bpp YVU planar 1x1 Y, 2x1 VU samples.
- YV12A = 4; // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples.
- YV24 = 5; // 24bpp YUV planar, no subsampling.
- NV12 = 6; // 12bpp with Y plane followed by a 2x2 interleaved UV plane.
- NV21 = 7; // 12bpp with Y plane followed by a 2x2 interleaved VU plane.
- UYVY = 8; // 16bpp interleaved 2x1 U, 1x1 Y, 2x1 V, 1x1 Y samples.
- YUY2 = 9; // 16bpp interleaved 1x1 Y, 2x1 U, 1x1 Y, 2x1 V samples.
- ARGB = 10; // 32bpp ARGB, 1 plane.
- XRGB = 11; // 24bpp XRGB, 1 plane.
- RGB24 = 12; // 24bpp BGR, 1 plane.
- RGB32 = 13; // 32bpp BGRA, 1 plane.
- MJPEG = 14; // MJPEG compressed.
- MT21 = 15;
-};
-
-// TODO(dalesat): Replace with fuchsia.images.ColorSpace.
-enum ColorSpace {
- UNKNOWN = 0;
- NOT_APPLICABLE = 1;
- JPEG = 2;
- HD_REC709 = 3;
- SD_REC601 = 4;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// Text
-
-struct TextStreamType {
- // TODO(dalesat): Define.
- uint8 dummy;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// Subpicture
-
-struct SubpictureStreamType {
- // TODO(dalesat): Define.
- uint8 dummy;
-};
diff --git a/fidl/fuchsia.mediacodec/codec.fidl b/fidl/fuchsia.mediacodec/codec.fidl
deleted file mode 100644
index e5f2bcc..0000000
--- a/fidl/fuchsia.mediacodec/codec.fidl
+++ /dev/null
@@ -1,1315 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.mediacodec;
-
-// See codec.md for detailed interface documentation. The comments here are a
-// summary only. Client implementers should see codec.md for more detail on any
-// message that doesn't seem sufficiently-described here. Codec server
-// implementers should probably read codec.md before implementing.
-
-// Overview of operation:
-//
-// 1. Create
-// * create via CodecFactory - see CodecFactory
-// 2. Get input constraints
-// * OnInputConstraints() - sent unsolicited by codec shortly after codec
-// creation.
-// 3. Provide input buffers
-// * SetInputBufferSettings() / AddInputBuffer()
-// 4. Deliver input data
-// * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
-// possibly working through all input packets repeatedly before...
-// 5. Get output constraints and format
-// * OnOutputConfig() - may be delivered as early as before
-// OnInputConstraints() by some codecs, but a client must tolerate as late
-// as after substantial input data has been delivered including lots of
-// input packet recycling via OnFreeInputPacket().
-// * This message can arrive more than once before the first output data.
-// 6. Provide output buffers
-// * SetOutputBufferSettings() / AddOutputBuffer()
-// 7. Data flows, with optional EndOfStream
-// * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
-// OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
-//
-// It's possible to re-use a Codec instance for another stream, and doing so
-// can sometimes skip over re-allocation of buffers. This can be a useful thing
-// to do for cases like seeking to a new location - at the Codec interface that
-// can look like switching to a new stream.
-
-// CodecBufferConstraints
-//
-// This struct helps ensure that packet count and buffer space are sufficient
-// to avoid major problems. For example, a video decoder needs sufficient
-// video frame buffers to hold all potential reference frames concurrently +
-// one more video buffer to decode into. Else, the whole video decode pipe can
-// easily deadlock.
-//
-// The secondary purpose of this struct is to help ensure that packet count and
-// buffer space are sufficient to achieve reasonably performant operation.
-//
-// There are separate instances of this struct for codec input and codec output.
-struct CodecBufferConstraints {
- // This is a version number the server sets on the constraints to allow the
- // server to determine when the client has caught up with the latest
- // constraints sent by the server. The server won't emit output data until
- // the client has configured output settings and buffers with a
- // buffer_constraints_version_ordinal >= the latest
- // buffer_constraints_version_ordinal that had
- // buffer_constraints_action_required true. See
- // buffer_constraints_action_required comments for more.
- //
- // A buffer_constraints_version_ordinal of 0 is not permitted, to simplify
- // initial state handling. Other than 0, both odd and even version ordinals
- // are allowed (in constrast to the stream_lifetime_ordinal, neither the
- // client nor server ever has a reason to consider the latest version to be
- // stale, so there would be no benefit to disallowing even values).
- uint64 buffer_constraints_version_ordinal;
-
- // default_settings
- //
- // These settings are "default" settings, not "recommended" settings.
- //
- // These "default" settings can be passed to SetInputBufferSettings() /
- // SetOutputBufferSettings() as-is without modification, but a client doing
- // that must still obey the semantics of packet_count_for_client, despite the
- // codec server not having any way to really know the proper setting for
- // that field.
- //
- // For CodecBufferConstraints fields whose names end in "recommended", the
- // default_settings will have the corresponding setting field set to that
- // recommended value.
- //
- // The codec promises that these default settings as-is (except for
- // buffer_lifetime_ordinal) are guaranteed to
- // satisfy the constraints indicated by the other fields of
- // CodecBufferConstraints. While client-side checking that these
- // settings are within the constraints is likely unnecessary in the client,
- // the client should still check that these values are within client-side
- // reasonable-ness bounds before using these values, to avoid letting a codec
- // server cause problems for the client.
- //
- // This structure will always have single_buffer_mode false. See
- // single_buffer_mode_allowed for whether single_buffer_mode true is allowed.
- //
- // The client must set the buffer_lifetime_ordinal field to a proper value
- // before sending back to the server. The 0 initially in this field will be
- // rejected by the server if sent back as-is. See comments on
- // CodecPortBufferSettings.buffer_lifetime_ordinal.
- CodecPortBufferSettings default_settings;
-
- // For uncompresesd video, separate and complete frames, each in its own
- // separate buffer (buffer-per-packet mode), is always a requirement.
-
- // per_packet_buffer_bytes.*:
- //
- // These per-packet buffer bytes constraints apply to both buffer-per-packet
- // mode and single-buffer mode (see single_buffer_mode). If
- // buffer-per-packet mode, the constraints apply to each buffer separately.
- // If single-buffer mode, the constraints need to be multiplied by the number
- // of packets to determine the constraints on the single buffer.
-
- // per_packet_buffer_bytes_min:
- //
- // If a client is using buffer per packet mode, each buffer must be at least
- // this large. If a client is using single-buffer mode, the one buffer must
- // be at least per_packet_buffer_bytes_min * packet_count_for_codec_min in
- // size.
- uint32 per_packet_buffer_bytes_min;
- // Must be >= per_packet_buffer_bytes_min. Delivering more than
- // this per input packet might not perform any better, and in fact might
- // perform worse.
- uint32 per_packet_buffer_bytes_recommended;
- // Must be >= per_packet_buffer_bytes_recommended. Can be 0xFFFFFFFF if there
- // is no explicitly-enforced limit.
- uint32 per_packet_buffer_bytes_max;
-
- // Minimum number of packet_count_for_codec.
- //
- // Re. input and output:
- //
- // This is a strict min for packet_count_for_codec, but a client can use more
- // packets overall if the client wants to, by using a larger value for
- // packet_count_for_codec and/or using a non-zero packets_for_client. A good
- // reason to do the former would be if the client might tend to deliver a few
- // not-very-full buffers occasionally - or to have a few extra packets within
- // which to satisfy codec_input_bytes_min. A good reason to do the latter
- // would be if a client needs to hold onto some packets for any "extra"
- // duration.
- //
- // If a client specifies a larger packet_count_for_codec value than
- // packet_count_for_codec_min, a server is permitted (but not encouraged) to
- // not make progress until packet_count_for_codec are with the server,
- // not merely packet_count_for_codec_min.
- //
- // For decoder input and audio encoder input: The packet_count_for_codec_min
- // may or may not contain enough data to allow the codec to make progress
- // without copying into an internal side buffer. If there isn't enough data
- // delivered in packet_count_for_codec_min packets to permit progress, the
- // codec must copy into its own side buffer internally to make progress.
- //
- // If a client intends to use extra packets for client-side purposes, the
- // client should specify the extra packets in packets_for_client instead of
- // packet_count_for_codec, but packet_count_for_codec must still be >=
- // packet_count_for_codec_min.
- //
- // See codec.md for more on packet_count_for_codec_min.
- uint32 packet_count_for_codec_min;
-
- // This must be at least packet_count_for_codec_min and at most
- // packet_count_for_codec_recommended_max.
- //
- // This value is likely to be used as-is by most clients, so if having one
- // additional packet is a big performance win in a large percentage of
- // scenarios, it can be good for the server to include that additional packet
- // in this value.
- uint32 packet_count_for_codec_recommended;
-
- // This can be the same as packet_count_for_codec_max or can be lower.
- // Values above this value and <= packet_count_for_codec_max are not
- // recommended by the codec, but should still work given sufficient resoures
- // available to both the client and the codec.
- uint32 packet_count_for_codec_recommended_max;
-
- // This can be 0xFFFFFFFF if there's no codec-enforced max, but codecs are
- // encouraged to set a large but still plausibly-workable max, and clients
- // are encouraged to request a number of packets that isn't excessively large
- // for the client's scenario.
- uint32 packet_count_for_codec_max;
-
- // Normally this would be an implicit 0, but for now we have a min so we can
- // force the total number of packets to be a specific number that we know
- // works for the moment.
- uint32 packet_count_for_client_min;
-
- // packet_count_for_client_max
- //
- // The client must set packet_count_for_client to be <=
- // packet_count_for_client_max.
- //
- // This value must be at least 1. This can be 0xFFFFFFFF if there's no
- // codec-enforced max. Clients are encouraged to request a number of
- // packets that isn't excessively large for the client's scenario.
- uint32 packet_count_for_client_max;
-
- // single_buffer_mode_allowed false allows a codec that's not required to
- // support single-buffer mode for a given input or output the ability to
- // decline to support single-buffer mode on that input/output.
- //
- // All encoder output, regardless of audio or video: server support for
- // single-buffer mode is optional. Please see codec.md for all the rules
- // regarding single-buffer mode on output before using single-buffer mode on
- // an output.
- //
- // Audio decoder output: server support for single-buffer mode is required.
- //
- // Video decoder output: There is little reason for a video decoder to
- // support single-buffer mode on output. Nearly all video decoders will set
- // this to false for their output.
- //
- // All decoder inputs: Servers must support single-buffer mode on input. The
- // client is responsible for managing the input buffer space such that
- // filling an input packet doesn't over-write any portion of an input packet
- // already in flight to the codec.
- //
- // Encoder inputs: Server support for single-buffer mode on encoder input is
- // optional. This is more often useful for audio than for video.
- //
- // Support for buffer-per-packet mode is always required on both input and
- // output, regardless of codec type.
- bool single_buffer_mode_allowed;
-
- // If true, the buffers need to be physically contiguous pages, such as can be
- // allocated using zx_vmo_create_contiguous().
- bool is_physically_contiguous_required;
- // VERY TEMPORARY HACK / KLUDGE - we want the BufferAllocator (or one of the
- // participant drivers that needs physically contiguous buffers) to call
- // zx_vmo_create_contiguous(), definitely not the Codec client, but until the
- // BufferAllocator can be reached from a driver, this is to grant the client
- // special powers it really shouldn't have, very temporarily until
- // BufferAllocator is hooked up properly at which point this can be removed.
- // Strictly speaking we could reverse which end allocates buffers in the Codec
- // interface to avoid this hack even before BufferAllocator, but the overall
- // path seems shorter if we jump directly from this to using BufferAllocator.
- handle? very_temp_kludge_bti_handle;
-};
-
-// CodecOutputConfig
-//
-// The codec-controlled output configuration, including both
-// CodecBufferConstraints for the output and CodecFormatDetails for the output.
-//
-// TODO(dustingreen): Need a better name for this struct, but still short
-// hopefully. It's stuff the codec gets to control, not the client. It's
-// different than output buffer settings, which the client does get to control
-// to some extent. It's different than any configurable output settings the
-// client might specifiy for output of an encoder.
-struct CodecOutputConfig {
- // A client which always immediately re-configures output buffers on reciept
- // of OnOutputConfig() with buffer_constraints_action_required true can safely
- // ignore this field.
- //
- // A client is permitted to ignore an OnOutputConfig() message even with
- // buffer_constraints_action_required true if the client knows the server has
- // already been told to discard the remainder of the stream with the same
- // stream_lifetime_ordinal or if this stream_lifetime_ordinal field is set to
- // 0. The server is required to re-send needed output config via
- // OnOutputConfig() with new stream_lifetime_ordinal and
- // buffer_constraints_action_required true, if the the most recent completed
- // server-side output config isn't what the server wants/needs yet for the
- // new stream.
- uint64 stream_lifetime_ordinal;
-
- // buffer_constraints_action_required
- //
- // When the buffer constraints are delivered, they indicate whether action is
- // required. A false value here permits delivery of constraints which are
- // fresher without forcing a buffer reconfiguration. If this is false, a
- // client cannot assume that it's safe to immediately re-configure output
- // buffers. If this is true, the client can assume it's safe to immediately
- // configure output buffers once.
- //
- // A client is permitted to ignore buffer constraint versions which have
- // buffer_constraints_action_required false. The server is not permitted to
- // change buffer_constraints_action_required from false to true for the same
- // buffer_constraints_version_ordinal.
- //
- // For each configuration, a client must use new buffers, never buffers that
- // were prevoiusly used for anything else, and never buffers previously used
- // for any other Codec purposes. This rule exists for multiple good reasons,
- // relevant to both mid-stream changes, and changes on stream boundaries.
- // A client should just use new buffers each time.
- //
- // When this is true, the server has already de-refed as many low-level
- // output buffers as the server can while still performing efficient
- // transition to the new buffers and will de-ref the rest asap. A Sync() is
- // not necessary to achieve non-overlap of resource usage to the extent
- // efficiently permitted by the formats involved.
- //
- // If buffer_constraints_action_required is true, the server _must_ not
- // deliver more output data until after output buffers have been configured
- // (or re-configured) by the client.
- //
- // See codec.md for more on buffer_constraints_action_required.
- bool buffer_constraints_action_required;
- CodecBufferConstraints buffer_constraints;
-
- // format_details
- //
- // It's up to the client to determine if a change in
- // format_details.format_details_version_ordinal implies any client action is
- // required, based on particular fields in format_details vs. any old value.
- // The server guarantees that if the format has changed, then
- // format_details.format_details_version_ordinal will change, but a change to
- // format_details.format_details_version_ordinal does not guarantee that the
- // format details actually changed. Servers are strongly encouraged to not
- // change format_details.format_details_version_ordinal other than before the
- // first output data of a stream unless there is a real mid-stream format
- // change in the stream. Unnecessary mid-stream format changes can cause
- // simpler clients that have no need to handle mid-stream format changes to
- // just close the channel. Format changes before the first output data of a
- // stream are not "mid-stream" in this context - those can be useful for
- // stream format detection / setup reasons.
- //
- // Note that in case output buffers don't really need to be re-configured
- // despite a format change, a server is encouraged, but not required, to
- // set buffer_constraints_action_required false on the message that conveys
- // the new format details. Simpler servers may just treat the whole output
- // situation as one big thing and demand output buffer reconfiguration on any
- // change in the output situation.
- //
- // A client may or may not actually handle a new buffer_constraints with
- // buffer_constraints_action_required false, but the client should always
- // track the latest format_details.
- //
- // An updated format_details is ordered with respect to emitted output
- // packets, and applies to all subsequent packets until the next
- // format_details with larger version_ordinal. A simple client that does not
- // intend to handle mid-stream format changes should still keep track of the
- // most recently received format_details until the first output packet
- // arrives, then lock down the format details, handle those format details,
- // and verify that any format_details.format_details_version_ordinal received
- // from the server is the same as the locked-down format_details, until the
- // client is done with the stream. Even such a simple client must tolerate
- // format_details.format_details_version_ordinal changing multiple times
- // before the start of data output from a stream (any stream - the first
- // stream or a subsequent stream). This allows a codec to request that
- // output buffers and output format be configured speculatively, and for the
- // output config to be optionally adjusted by the server before the first
- // data output from a stream after the server knows everything it needs to
- // know to fully establish the initial output format details. This
- // simplifies codec server implementation, and allows a clever codec server
- // to guess it's output config for lower latency before any input data, while
- // still being able to fix the output config (including format details) if
- // the guess turns out to be wrong.
- //
- // Whether the format_details.format_details_version_ordinal will actually
- // change mid-stream is a per-codec and per-stream detail that is not
- // specified in comments here, and in most cases also depends on whether the
- // format changes on the input to the codec. Probably it'll be fairly common
- // for a client to use a format which technically supports mid-stream format
- // change, but the client happens to know that none of the streams the client
- // intends to process will ever have a mid-stream format change.
- CodecFormatDetails format_details;
-};
-
-// Default values for input and output
-// CodecBufferConstraints.default_settings.packet_count_for_codec.
-//
-// These are defined as "const" in FIDL to avoid all server implementations
-// needing to separately define their own values, and these should be
-// reasonable as default values, but strictly speaking this is not intended to
-// promise that this value won't change from build to build. If a client cares
-// about a specific number, the client should separately define what that
-// number is and ensure that CodecPortBufferSettings.packet_count_for_client is
-// at least large enough.
-//
-// In contrast to packet_count_for_client, the packet_count_for_codec is much
-// more codec-specific, so this file has no numbers for that - each codec will
-// set those as appropriate for the specific codec.
-//
-// These are not "recommended" values, only "default" values, in the sense that
-// the codec doesn't really know what the correct setting for these values is
-// for a given client, and if the default is not appropriate for a client,
-// large problems could result such as deadlock. See the comments on
-// packet_count_for_client.
-//
-// Despite these defaults, every client should ideally care about the
-// packet_count_for_client setting and should ensure that the setting is at
-// least large enough to cover the number of packets the client might ever need
-// to camp on for any non-transient duration concurrently. The defaults are
-// only intended to be plausible for some clients, not all clients.
-//
-// One for the client to be filling and one in transit.
-const uint32 kDefaultInputPacketCountForClient = 2;
-// One for the client to be rendering, and one in transit.
-const uint32 kDefaultOutputPacketCountForClient = 2;
-
-// For input, this is the default on a fairly arbitrary basis.
-//
-// TODO(dustingreen): Do we want the default for audio encoding to be
-// single_buffer_mode true instead? If so, we may split this up by audio/video
-// encoder/decoder.
-const bool kDefaultInputIsSingleBufferMode = false;
-const bool kDefaultOutputIsSingleBufferMode = false;
-
-// CodecPortBufferSettings
-//
-// See relevant corresponding constraints in CodecBufferConstraints. The
-// settings must satisfy the constraints.
-//
-// The client informs the codec of these settings and then separately informs
-// the codec of each buffer.
-//
-// TODO(dustingreen): Rename from CodecPortBufferSettings to CodecBufferSettings
-// in a separate CL (after some other stuff is out of the way first).
-struct CodecPortBufferSettings {
- // buffer_lifetime_ordinal
- //
- // The containing message starts a new buffer_lifetime_ordinal.
- //
- // There is a separate buffer_lifetime_ordinal for input vs. output.
- //
- // Re-use of the same value is not allowed. Values must be odd. Values must
- // only increase (increasing by more than 2 is permitted).
- //
- // A buffer_lifetime_ordinal lifetime starts at SetInputBufferSettings() or
- // SetOutputBufferSettings(), and ends at the the earlier of
- // CloseCurrentStream() with release_input_buffers/release_output_buffers set
- // or SetOutputBufferSettings() with new buffer_lifetime_ordinal in the case
- // of mid-stream output config change.
- //
- // See codec.md for more on buffer_lifetime_ordinal.
- uint64 buffer_lifetime_ordinal;
-
- // buffer_constraints_version_ordinal
- //
- // This value indicates which version of constraints the client is/was aware
- // of so far.
- //
- // For input, this must always be 0 because constraints don't change for
- // input (settings can change, but there's no settings vs current constraints
- // synchronization issue on input).
- //
- // For output, this allows the server to know when the client is sufficiently
- // caught up before the server will generate any more output.
- //
- // When there is no active stream, a client is permitted to re-configure
- // buffers again using the same buffer_constraints_version_ordinal.
- //
- // See codec.md for more on buffer_constraints_version_ordinal.
- uint64 buffer_constraints_version_ordinal;
-
- // The total packet count is split into two pieces to disambiguate how many
- // packets are allocated for the client to hold onto for whatever reason, vs.
- // how many packets are allocated for the server to hold onto for whatever
- // reason.
- //
- // Extra packets to provide slack for peformance reasons can be in either
- // category, but typically packet_count_for_codec_recommended will already
- // include any performance-relevant slack for the server's benefit.
-
- // packet_count_for_codec
- //
- // How many packets the client is allocating for the codec server's use.
- // This must be >= CodecBufferConstraints.packet_count_for_codec_min. If
- // constraints change such that this would no longer be true, the server will
- // send an OnOutputConfig() event.
- //
- // The codec server is allowed to demand that all of packet_count_for_codec
- // become free before making further progress, even if
- // packet_count_for_codec is > packet_count_for_codec_min.
- //
- // A reasonable value for this is
- // CodecBufferConstraints.packet_count_for_codec_recommended.
- //
- // See codec.md for more on packet_count_for_codec.
- uint32 packet_count_for_codec;
-
- // packet_count_for_client
- //
- // This must be at least 1. The server will close the channel if this is 0.
- //
- // How many packets the client is allocating for the client's use. The
- // client may hold onto this many packets for arbitrarily-long duration
- // without handing these packets to the codec, and despite doing so, the
- // codec will continue to make progress and function normally without getting
- // stuck. The client holding onto additional packets transiently is ok, but
- // the client needs to hand those additional packets back to the codec
- // eventually if the client wants the codec to make further progress.
- //
- // In addition to this value needing to include at least as many packets as
- // the client ever intends to concurrently camp on indefinitely, any extra
- // slack to benefit client-side performance should also be included here.
- //
- // A typical value for this could be at least 2, but it depends strongly on
- // client implementation and overall client buffering goals. It is up to the
- // client to determine how many packets are needed in this category by any
- // parts of the overall system that will be holding onto packets for any
- // reason. Those parts of the system should have a documented and possibly
- // queryable defined value to help determine this number. Setting this value
- // lower than it actaully needs to be can result in the codec not making
- // progress as it sits waiting for packets, with the client unable to recycle
- // any more packets to the codec. That situation can be difficult to
- // diagnose, while excessively-large values here are wasteful, so care is
- // warranted to set this value properly.
- uint32 packet_count_for_client;
-
- // per_packet_buffer_bytes
- //
- // In buffer-per-packet mode, we require that each buffer have usable bytes
- // equal to per_packet_buffer_bytes. Use of differently-sized low-level
- // buffers is possible, but the size of the portion used via the Codec
- // interface per CodecBuffer must be the same for all the buffers.
- //
- // In single-buffer mode, we require the portion of the low-level buffer used
- // via the Codec interface to be size (packet_count_for_codec +
- // packet_count_for_client) * per_packet_buffer_bytes.
- //
- // TODO(dustingreen): determine if we need to relax these restrictions a bit
- // for convenience when using gralloc video buffers.
- uint32 per_packet_buffer_bytes;
-
- // If true, there is only one buffer with index 0 which all packets
- // implicitly refer to. If false, the packet_index and buffer_index are 1:1,
- // and each packet refers to its corresponding buffer.
- //
- // While it's possible to set up single_buffer_mode false with each buffer
- // referring to the same underlying VMO, single_buffer_mode true is more
- // efficient for that case since only one mapping is created.
- bool single_buffer_mode;
-};
-
-// CodecBuffer
-//
-// The CodecBuffer struct represents a pre-configured buffer.
-//
-// Both input and output uses CodecBuffer(s), but the two sets of buffers are
-// separate.
-//
-// The client uses SetInputBufferSettings() + AddInputBuffer() * N to inform
-// the codec about all the input buffers.
-//
-// The client uses SetOutputBufferSettings() + AddOutputBuffer() * N to inform
-// the codec about all the output buffers.
-//
-// When single_buffer_mode is true, there is only buffer_index 0 shared by all
-// CodecPacket(s) of the relevant input or output. When single_buffer_mode is
-// false, the buffer_index equals the packet_index.
-struct CodecBuffer {
- // When using AddOutputBuffer()/AddInputBuffer(), this must match the
- // buffer_lifetime_ordinal of the most recent
- // SetOutputBufferSettings()/SetInputBufferSettings().
- uint64 buffer_lifetime_ordinal;
-
- // Buffers must be added via AddOutputBuffer() / AddInputBuffer() in order by
- // buffer_index, and the buffer_index is always equal to 0 or equal to the
- // packet_index (depending on single_buffer_mode true or false), but it's
- // still nice to have CodecBuffer include the buffer_index if only for easier
- // debugging.
- uint32 buffer_index;
-
- // For each new buffer_lifetime_ordinal, a client must use new low-level
- // buffers. This rule exists for multiple very good reasons, and is relevant
- // to mid-stream changes, changes on stream boundaries, and both input and
- // output buffers. A new buffer_lifetime_ordinal needs new low-level
- // buffers, not just new CodecBuffer(s). If you find yourself copying
- // compressed input data into new low-level input buffers solely due to this
- // rule, consider asking the source of the data for the ability to directly
- // fill new VMOs. The rule exists for good reasons, even for input buffers.
- //
- // The previous paragraph does not prohibit carving up VMOs into sub-pieces
- // and using different sub-pieces as different CodecBuffer(s), with some VMOs
- // used for more than one CodecBuffer and possibly others used for only one
- // CodecBuffer. While this is permitted and enables some optimizations, it's
- // not expected to be particularly common.
- //
- // See codec.md for more on CodecBufferData, and more on why we never re-use
- // the same low-level buffers for different buffer_lifetime_ordinal(s).
- CodecBufferData data;
-};
-
-// CodecBufferData
-//
-// For the moment, a VMO per buffer is the only type of buffer.
-//
-// This is extremely likely to change significantly when adding gralloc stuff,
-// but the idea with this union is to have a struct per logical way of storing
-// the data. Any multi-domain storage within a gralloc buffer will likely be
-// only indirectly represented here.
-union CodecBufferData {
- CodecBufferDataVmo vmo;
-
- // TODO(dustingreen): add the gralloc way
-};
-
-// CodecBufferDataVmo
-//
-// Details for a buffer backed by a VMO.
-struct CodecBufferDataVmo {
- // The same VMO can be used by more than one CodecBuffer (only of the same
- // buffer_lifetime_ordinal), but each vmo_handle must be a separate handle.
- handle<vmo> vmo_handle;
-
- // Offset within the VMO of the first usable byte. Must be < the VMO's size
- // in bytes.
- uint64 vmo_usable_start;
-
- // VMO-relative offset that's one past the last usable byte. This can point
- // one byte beyond the end of the VMO if desired. In other words, this can
- // be equal to the VMO's size, to indicate that the last byte of the VMO is
- // usable (and possibly many byte before that, depending on
- // vmo_usable_start).
- uint64 vmo_usable_size;
-};
-
-// CodecPacketHeader
-//
-// When referring to a free packet, we use CodecPacketHeader alone instead of
-// CodecPacket, since while a packet is free it doesn't really have meaningful
-// offset or length etc.
-//
-// A populated CodecPacket also has a CodecPacketHeader.
-struct CodecPacketHeader {
- // This is which buffer configuration lifetime this header is referring to.
- //
- // A packet_index is only really meaningful with respect to a particular
- // buffer_lifetime_ordinal.
- //
- // See CodecPortBufferSettings.buffer_lifetime_ordinal.
- //
- // For QueueInputPacket(), a server receiving a buffer_lifetime_ordinal that
- // isn't the current input buffer_lifetime_ordinal will close the channel.
- //
- // For OnFreeInputPacket() and RecycleOutputPacket(), the reciever (client or
- // server) must ignore a message with stale buffer_lifetime_ordinal.
- uint64 buffer_lifetime_ordinal;
-
- // The overall set of packet_index values is densely packed from 0..count-1
- // for input and output separately. They can be queued in any order.
- //
- // Both the client and server should validate the packet_index against the
- // known bound and disconnect if it's out of bounds.
- //
- // When running in buffer-per-packet mode, the packet_index is also the
- // buffer index. When running in single-buffer mode, the buffer index is
- // always 0 referring to the single buffer.
- //
- // The packet_index values don't imply anything about order of use of
- // packets. The client should not expect the ordering to remain the same over
- // time - the codec is free to hold on to an input or output packet for a
- // while during which other packet_index values may be used multiple times.
- //
- // For a given properly-functioning Codec instance, packet_index values will
- // be unique among concurrently-outstanding packets. Servers should validate
- // that a client isn't double-using a packet and clients should validate as
- // necessary to avoid undefined or unexpected client behavior.
- uint32 packet_index;
-};
-
-// CodecPacket
-//
-// A CodecPacket represents a chunk of input or output data to or from a codec.
-//
-// codec output:
-// While the CodecPacket is outstanding with the client via OnOutputPacket(),
-// the codec will avoid modifying the referenced output data. After the client
-// calls RecycleOutputPacket(packet_index), the codec is notified that the
-// client is again ok with the referenced data changing.
-//
-// codec input:
-// The client initially has all packet_index(es) available to fill, and later
-// gets packet_index(s) that are again ready to fill via OnFreeInputPacket().
-// The client must not modify the referenced data in between QueueInputPacket()
-// and OnFreeInputPacket().
-struct CodecPacket {
- CodecPacketHeader header;
-
- // Which buffer this packet refers to. For single-buffer mode this will
- // always be 0, but for multi-buffer mode, a given in-flight interval of a
- // packet can refer to any buffer. The packet has an associated buffer only
- // while the packet is in-flight, not while the packet is free.
- //
- // The default value makes accidental inappropriate use of index 0 less
- // likely (will tend to complain in an obvious way if not filled out instead
- // of a non-obvious data corruption when decoding buffer 0 repeatedly instead
- // of the correct buffers).
- uint32 buffer_index = 0x80000000;
-
- // stream_lifetime_ordinal
- //
- // The value 1 is the lowest permitted value after codec creation. Values
- // sent by the client must be odd. Values must only increase.
- //
- // A stream_lifetime_ordinal represents the lifetime of a stream. All
- // messages that are specific to a stream have the stream_lifetime_ordinal
- // value and the value is the same for all messages relating to a given
- // stream.
- //
- // See codec.md for more on stream_lifetime_ordinal.
- uint64 stream_lifetime_ordinal;
-
- // start_offset and valid_length_bytes
- //
- // Which part of the relevant buffer is this packet using. These are valid
- // for input data that's in-flight to the codec, and are valid for output data
- // from the codec.
- //
- // For compressed formats and uncompressed audio, the data in
- // [start_offset, start_offset + valid_length_bytes) is the contiguously valid
- // data refered to by this packet.
- //
- // For uncompressed video frames, CodecFormatDetails is the primary means of
- // determining which bytes are relevant. The offsets in CodecFormatDetails
- // are relative to the start_offset here. The valid_length_bytes must be
- // large enough to include the full last line of pixel data, including the
- // full line stride of the last line (not just the width in pixels of the
- // last line).
- //
- // Despite these being filled out, some uncompressed video buffers are of
- // types that are not readable by the CPU. These fields being here don't
- // imply there's any way for the CPU to read an uncompressed frame.
- //
- // TODO(dustingreen): Do we have any reason to require that these be filled
- // out for opaque uncompressed video frames that the CPU can't read? In that
- // case do we want to require them just so they can be potentially passed on
- // to a HW renderer in case the HW renderer has any use for them? Or more
- // likely, it may just be that these tend to refer to the whole size of an
- // uncompressed buffer, with format_details taking care of specifying which
- // bytes are actually relevant.
- uint32 start_offset;
-
- // valid_length_bytes
- //
- // This must be > 0.
- //
- // The semantics for valid data per packet vary depending on data type as
- // follows.
- //
- // uncompressed video - A video frame can't be split across packets. Each
- // packet is one video frame.
- //
- // uncompressed audio - Regardless of float or int, linear or uLaw, or number
- // of channels, a packet must contain an non-negative number of complete
- // audio frames, where a single audio frame consists of data for all the
- // channels for the same single point in time. Any codec-specific internal
- // details re. lower rate sampling for LFE channel or the like should be
- // hidden by the Codec server implementation.
- //
- // compressed data input - A packet must contain at least one byte of data.
- // See also codec_input_bytes_min. Splitting AUs at arbitrary byte
- // boundaries is permitted, including at boundaries that are in AU headers.
- //
- // compressed data output - The codec is not required to fully fill each
- // output packet's buffer.
- uint32 valid_length_bytes;
-
- // This value is not strictly speaking a timestamp. It is an arbitrary
- // unsigned 64-bit number that, under some circumstances, will be passed by a
- // codec unmodified from an input packet to the exactly-corresponding output
- // packet.
- //
- // For timestamp_ish values to be propagated from input to output the
- // following conditions must be true:
- // * promise_separate_access_units_on_input must be true
- // * has_timestamp_ish must be true for a given input packet, to have that
- // timestamp_ish value (potentially) propagate through to an output
- // * the Codec instance itself decides (async) that the input packet
- // generates an output packet - if a given input never generates an output
- // packet then the timestamp_ish value on the input will never show up on
- // any output packet - depending on the characteristics of the input and
- // output formats, and whether a decoder is willing to join mid-stream, etc
- // this can be more or less likely to occur, but clients should be written
- // to accomodate timestamp_ish values that are fed on input but never show
- // up on output, at least to a reasonable degree (not crashing, not
- // treating as an error).
- //
- // See codec.md for more on timestamp_ish.
- bool has_timestamp_ish;
- uint64 timestamp_ish;
-
- // start_access_unit
- //
- // If promise_separate_access_units_on_input (TODO(dustingreen): or any
- // similar mode for output) is true, this bool must be set appropriately
- // depending on whether byte 0 _is_ or _is not_ the start of an access unit.
- // The client is required to know, and required to set this boolean properly.
- // The server is allowed to infer that when this boolean is false, byte 0 is
- // the first byte of a continuation of a previously-started AU. (The byte at
- // start_offset is "byte 0".)
- //
- // If promise_separate_access_units_on_input is false, this boolean is
- // ignored.
- bool start_access_unit;
-
- // known_end_access_unit
- //
- // A client is never required to set this boolean to true.
- //
- // If promise_separate_access_units_on_input is true, for input data, this
- // boolean must be false if the last byte of this packet is not the last byte
- // of an AU, and this boolean _may_ be true if the last byte of this packet
- // is the last byte of an AU. A client delivering one AU at a time that's
- // interested in the lowest possible latency via the decoder should set this
- // boolean to true when it can be set to true.
- //
- // If promise_separate_access_units_on_input is false, this boolean is
- // ignored.
- bool known_end_access_unit;
-};
-
-// Codec
-//
-// The Codec interface exists to anchor the configuration of input and output
-// buffers, and depending on Codec server hosting strategy, the Codec inteface
-// can, in some configurations, be 1:1 with a codec isolate (process),
-// especially when using SW codecs. The Codec can be used to process up to one
-// stream at a time.
-//
-// Descriptions of actions taken by methods of this interface and the states of
-// things are given as if the methods are synchronously executed by the codec
-// server, but in reality, as is typical of FIDL interfaces, the message
-// processing is async. The states described are to be read as the state from
-// the client's point of view unless otherwise stated. Events coming back from
-// the server are of course delivered async, and a client that processes more
-// than one stream per Codec instance needs to care whether a given event is
-// from the current stream vs. some older soon-to-be-gone stream.
-//
-// The Sync() method's main purpose is to enable the client to robustly prevent
-// having both old and new buffers allocated in the system at the same time,
-// since media buffers can be significantly large, depending. The Sync() method
-// achieves this by only delivering it's response when all previous calls to
-// the Codec interface have actually taken effect in the StreamControl ordering
-// domain. Sync() can also be used to wait for the codec server to catch up if
-// there's a possibility that a client might otherwise get too far ahead of the
-// Codec server, by for example requesting creation of a large number of
-// streams in a row. It can also be used during debugging to ensure that a
-// codec server hasn't gotten stuck. Calling Sync() is entirely optional and
-// never required for correctness - only potentially required to de-overlap
-// resource usage.
-//
-// Semi-trusted Codec server - SW decoders run in an isolate (with very few
-// capabilities) just in case the decoding SW has a vulnerability which could
-// be used to take over the Codec server. Clients of the codec interface using
-// decoders and processing streams of separate security contexts, to a greater
-// extent than some other interfaces, need to protect themselves against
-// invalid server behavior, such as double-free of a packet_index and any other
-// invalid server behavior. Having fed in compressed data of one security
-// context, don't place too much trust in a single Codec instance to not mix
-// data among any buffers that Codec server has ever been told about. Instead,
-// create separate Codec instances for use by security-separate client-side
-// contexts. While the picture for HW-based decoders looks somewhat different
-// and is out of scope of this paragraph, the client should always use separate
-// Codec instances for security-separate client-side contexts.
-interface Codec {
- // EnableOnStreamFailed()
- //
- // Permit the server to use OnStreamFailed() instead of the server just
- // closing the whole Codec channel on stream failure.
- //
- // If the server hasn't seen this message by the time a stream fails, the
- // server will close the Codec channel instead of sending OnStreamFailed().
- 1: EnableOnStreamFailed();
-
- // OnStreamFailed()
- //
- // The stream has failed, but the Codec instance is still usable for a new
- // stream.
- //
- // This message is only ever sent by the server if the client previously sent
- // EnableOnStreamFailed(). If the client didn't send EnableOnStreamFailed()
- // then the server closes the Codec channel instead.
- //
- // Codec server implementations are encouraged to handle stream errors (and
- // ideally to also report them via error_ bools of OnOutputPacket() and
- // OnOutputEndOfStream()) without failing the whole stream, but if a codec
- // server is unable to do that, but still can cleanly contain the failure to
- // the stream, the codec server can (assuming EnableOnStreamFailed() was
- // called) use OnStreamFailed() to indicate the stream failure to the client
- // without closing the Codec channel.
- //
- // An ideal Codec server handles problems with input data without sending
- // this message, but sending this message is preferred vs. closing the server
- // end of the Codec channel if the Codec server can 100% reliably contain the
- // stream failure to the stream, without any adverse impact to any later
- // stream.
- //
- // No further messages will arrive from the server regarding the failed
- // stream. This includes any OnOutputEndOfStream() that the client would
- // have otherwise expected.
- //
- // TODO(dustingreen): Add at least an error_message string and _maybe_ a
- // zx_status_t, though that might tend to encourage mis-use of zx_status_t so
- // maybe just error_message for quicker debugging on the client side. Also
- // plumb from CodecAdapterH264 and similar.
- 2: -> OnStreamFailed(uint64 stream_lifetime_ordinal);
-
- // OnInputConstraints()
- //
- // The server sends this shortly after Codec creation to indicate input
- // buffer constraints. The "min" and "max" input constraints don't change
- // for the life of the Codec.
- //
- // The "max" values for buffer size and count are large enough to support the
- // most demanding format the server supports on input. The "recommended"
- // values should be workable for use with the input CodecFormatDetails
- // conveyed during Codec creation. The "recommended" values are not
- // necessarily suitable if the client uses QueueInputFormatDetails() to
- // change the input format. In that case it's up to the client to determine
- // suitable values, either by creating a new Codec instance instead, or
- // knowing suitable values outside the scope of this protocol.
- //
- // See comments on CodecBufferConstraints.
- //
- // This message is guaranteed to be sent unsolicited to the Codec client
- // during or shortly after Codec creation. Clients should not depend on this
- // being the very first message to arrive at the client. OnOutputConfig()
- // may be sent first by some codecs that already know their initial output
- // config without any input data, to encourage (but not stictly require) the
- // client to configure output buffers before feeding the first input, to
- // avoid a wasteful OnOutputConfig() being generated for that first stream if
- // the client has started configuring output but isn't done configuring
- // output before the client sends the first input data for the first stream.
- // A client is free to ignore OnOutputConfig() with a stale
- // stream_lifetime_ordinal, but handling OnOutputConfig() with
- // stream_lifetime_ordinal 0 (if any are sent) can help reduce latency to
- // first output. See OnOutputConfig() for more details.
- //
- // The "min" and "max" input constraints are guaranteed not to change for a
- // given Codec instance. The "recommended" values may effectively change
- // when the server processes QueueInputFormatDetails(). There is not any way
- // in the protocol short of creating a new Codec instance for the client to
- // get those new "recommended" values.
- //
- // TODO(dustingreen): Maybe provide a way for the client to get updated
- // "recommended" values for input, maybe only on request rather than via this
- // event, to keep things simpler for simpler clients. Maybe separate the
- // recommendations from the constraints.
- 3: -> OnInputConstraints(CodecBufferConstraints input_constraints);
-
- // SetInputBufferSettings() and AddInputBuffer()
- //
- // Configuring input buffers consists of calling SetInputBufferSettings()
- // followed by a number of calls to AddInputBuffer() equal to the number of
- // buffers set via SetInputBufferSettings(). In buffer-per-packet mode, this
- // is the same as the number of packets. In single-buffer mode, this is 1.
- //
- // After OnInputConstraints(), the client uses these two methods to set up
- // input buffers and packets.
- //
- // Configuring input buffers is required before QueueInputPacket().
- //
- // The client can also re-set-up input buffers any time there is no current
- // stream. The client need not wait until all previously-set-up input
- // buffers are with the client via OnFreeInputPacket(). The old
- // buffer_lifetime_ordinal just ends. See codec.md for more info on "buffer
- // lifetime".
- //
- // The recommended way to de-overlap resource usage (when/if the client wants
- // to) is to send CloseCurrentStream() with release_input_buffers true then
- // send Sync() and wait for its response before allocating any new buffers.
- // How to cause other parts of the system to release their references on
- // low-level buffers is outside the scope of this interface.
- //
- // This call ends any previous buffer_lifetime_ordinal, and starts a new one.
- 4: SetInputBufferSettings(CodecPortBufferSettings input_settings);
-
- // The client is required to add all the input buffers before sending any
- // message that starts a new stream else the codec will close the Codec
- // channel.
- //
- // When the last buffer is added with this message, all the input packets
- // effectively jump from non-existent to free with the client. The Codec
- // will not generate an OnFreeInputPacket() for each new input packet. The
- // client can immediately start sending QueueInputPacket() after sending the
- // last AddInputBuffer().
- 5: AddInputBuffer(CodecBuffer buffer);
-
- // OnOutputConfig()
- //
- // This event informs the client of new output config. The server will send
- // at least one of these messages before the first output packet of a stream,
- // but that message might not have buffer_constraints_action_required true.
- //
- // If buffer_constraints_action_required is true and the
- // stream_lifetime_ordinal matches the current stream, the client must react
- // by configuring or re-configuring output buffers.
- //
- // Some clients may prefer not to support mid-stream output config changes,
- // but even those clients are required to process OnOutputConfig() messages
- // up to the first output packet of each stream, as OnOutputConfig() is used
- // for stream format detection as well as for potential mid-stream output
- // config changes.
- //
- // For more on OnOutputConfig(), see cocec.md.
- 6: -> OnOutputConfig(CodecOutputConfig output_config);
-
- // SetOutputBufferSettings() and AddOutputBuffer()
- //
- // These are not permitted until after the first OnOutputConfig().
- //
- // Roughly speaking, these messages are sent in response to OnOutputConfig()
- // with buffer_constraints_action_required true.
- //
- // Configuring output buffers consists of calling SetOutputBufferSettings()
- // followed by a number of calls to AddOutputBuffer() equal to the number of
- // buffers set via SetOutputBufferSettings(). In buffer-per-packet mode, this
- // is the same as the number of packets. In single-buffer mode, this is 1.
- //
- // Configuring output buffers is _required_ after OnOutputConfig() is
- // received by the client with buffer_constraints_action_required true and
- // stream_lifetime_ordinal equal to the client's current
- // stream_lifetime_ordinal (even if there is an active stream), and is
- // _permitted_ any time there is no current stream.
- //
- // For more on SetOutputBufferSettings() and AddOutputBuffer(), see codec.md.
- 7: SetOutputBufferSettings(CodecPortBufferSettings output_settings);
- 8: AddOutputBuffer(CodecBuffer buffer);
-
- // FlushEndOfStreamAndCloseStream()
- //
- // This message is optional.
- //
- // This message is only valid after QueueInputEndOfStream() for this stream.
- // The stream_lifetime_ordinal input parameter must match the
- // stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
- // will close the channel.
- //
- // A client can use this message to flush through (not discard) the last
- // input data of a stream so that the codec server generates corresponding
- // output data for all the input data before the server moves on to the next
- // stream, without forcing the client to wait for OnOutputEndOfStream()
- // before queueing data of another stream.
- //
- // The difference between QueueInputEndOfStream() and
- // FlushEndOfStreamAndCloseStream(): QueueInputEndOfStream() is a promise
- // from the client that there will not be any more input data for the stream
- // (and this info is needed by some codecs for the codec to ever emit the very
- // last output data). The QueueInputEndOfStream() having been sent doesn't
- // prevent the client from later completely discarding the rest of the
- // current stream by closing the current stream (with or without a stream
- // switch). In contrast, FlushEndOfStreamAndCloseStream() is a request from
- // the client that all the previously-queued input data be processed
- // including the logical "EndOfStream" showing up as OnOutputEndOfStream()
- // (in success case) before moving on to any newer stream - this essentially
- // changes the close-stream handling from discard to flush-through for this
- // stream only.
- //
- // A client using this message can start providing input data for a new
- // stream without that causing discard of old stream data. That's the purpose
- // of this message - to allow a client to flush through (not discard) the old
- // stream's last data (instead of the default when closing or switching
- // streams which is discard).
- //
- // Because the old stream is not done processing yet and the old stream's
- // data is not being discarded, the client must be prepared to continue to
- // process OnOutputConfig() messages until the stream_lifetime_ordinal is
- // done. The client will know the stream_lifetime_ordinal is done when
- // OnOutputEndOfStream(), OnStreamFailed(), or the Codec channel closes.
- //
- // For more on FlushEndOfStreamAndCloseStream(), see codec.md.
- 9: FlushEndOfStreamAndCloseStream(uint64 stream_lifetime_ordinal);
-
- // CloseCurrentStream()
- //
- // This "closes" the current stream, leaving no current stream. In addition,
- // this message can optionally release input buffers or output buffers.
- //
- // If there has never been any active stream, the stream_lifetime_ordinal must
- // be zero or the server will close the channel. If there has been an active
- // stream, the stream_lifetime_ordinal must be the most recent active stream
- // whether that stream is still active or not. Else the server will close the
- // channel.
- //
- // Multiple of this message without any new active stream in between is not
- // to be considered an error, which allows a client to use this message to
- // close the current stream to stop wasting processing power on a stream the
- // user no longer cares about, then later decide that buffers should be
- // released and send this message again with release_input_buffers and/or
- // release_output_buffers true to get the buffers released, if the client is
- // interested in trying to avoid overlap in resource usage between old
- // buffers and new buffers (not all clients are).
- //
- // See also Sync().
- //
- // For more on CloseCurrentStream(), see codec.md.
- 10: CloseCurrentStream(
- uint64 stream_lifetime_ordinal,
- bool release_input_buffers,
- bool release_output_buffers);
-
- // Sync() -> ()
- //
- // On completion, all previous Codec calls have done what they're going to do
- // server-side, _except_ for processing of data queued using
- // QueueInputPacket().
- //
- // The main purpose of this call is to enable the client to wait until
- // CloseCurrentStream() with release_input_buffers and/or
- // release_output_buffers set to true to take effect, before the client
- // allocates new buffers and re-sets-up input and/or output buffers. This
- // de-overlapping of resource usage can be worthwhile for media buffers which
- // can consume resource types whose overall pools aren't necessarily vast in
- // comparsion to resources consumed. Especially if a client is reconfiguring
- // buffers multiple times.
- //
- // Note that Sync() prior to allocating new media buffers is not alone
- // sufficient to achieve non-overlap of media buffer resource usage system
- // wide, but it can be a useful part of achieving that.
- //
- // The Sync() transits the Output ordering domain and the StreamControl
- // ordering domain, but not the InputData ordering domain. For more on
- // ordering domains see codec.md.
- //
- // This request can be used to avoid hitting kMaxInFlightStreams which is
- // presently 10. A client that stays <= 8 in-flight streams will comfortably
- // stay under the limit of 10. While the protocol permits repeated
- // SetInputBufferSettings() and the like, a client that spams the channel
- // can expect that the channel will just close if the server or the channel
- // itself gets too far behind.
- 11: Sync() -> ();
-
- // OnOutputPacket()
- //
- // This is how the codec emits an output packet to the codec client.
- //
- // Order is significant.
- //
- // The client should eventually call RecycleOutputPacket() (possibly after
- // switching streams multiple times), unless the buffer_lifetime_ordinal has
- // moved on. A stream change doesn't change which packets are busy with
- // the client vs. free with the server. See "packet lifetime" in codec.md for
- // more.
- //
- // The relevant buffer is buffer 0 if running in single-buffer mode, or the
- // buffer index is the same as packet_index if running in buffer-per-packet
- // mode.
- //
- // For low-level buffer types that support it, a Codec is free to emit an
- // output packet before the low-level buffer actually has any usable data in
- // the buffer, with the mechanism for signalling the presence of data
- // separate from the OnOutputPacket() message. For such low-level buffer
- // types, downstream consumers of data from the emitted packet must
- // participate in the low-level buffer signalling mechanism to know when it's
- // safe to consume the data. This is most likely to be relevant when using a
- // video decoder and gralloc-style buffers.
- //
- // The error_ bool(s) allow (but do not require) a Codec server to report
- // errors that happen during an AU or between AUs.
- //
- // The scope of error_detected_before starts at the end of the last delivered
- // output packet on this stream, or the start of stream if there were no
- // previous output packets on this stream. The scope ends at the start of
- // the output_packet.
- //
- // The error_detected_before bool is separate so that discontinuities can be
- // indicated separately from whether the current packet is damaged.
- //
- // The scope of error_detected_during is from the start to the end of this
- // output_packet.
- 12: -> OnOutputPacket(
- CodecPacket output_packet,
- bool error_detected_before,
- bool error_detected_during);
-
- // RecycleOutputPacket()
- //
- // After the client is done with an output packet, the client needs to tell
- // the codec that the output packet can be re-used for more output, via this
- // method.
- //
- // It's not permitted to recycle an output packet that's already free with the
- // codec server. It's permitted but discouraged for a client to recycle an
- // output packet that has been deallocated by an explicit or implicit output
- // buffer de-configuration(). See buffer_lifetime_ordinal for more on that.
- // A server must ignore any such stale RecycleOutputPacket() calls.
- //
- // For more on RecycleOutputPacket(), see codec.md.
- 13: RecycleOutputPacket(CodecPacketHeader available_output_packet);
-
- // OnOutputEndOfStream()
- //
- // After QueueInputEndOfStream() is sent by the Codec client, within a
- // reasonable duration the corresponding OnOutputEndOfStream() will be sent by
- // the Codec server. Similar to QueueInputEndOfStream(),
- // OnOutputEndOfStream() is sent a maximum of once per stream.
- //
- // No more stream data for this stream will be sent after this message. All
- // input data for this stream was processed.
- //
- // While a Codec client is not required to QueueInputEndOfStream() (unless
- // the client wants to use FlushEndOfStreamAndCloseStream()), if a Codec
- // server receives QueueInputEndOfStream(), and the client hasn't closed the
- // stream, the Codec server must generate a corresponding
- // OnOutputEndOfStream() if nothing went wrong, or must send
- // OnStreamFailed(), or must close the server end of the Codec channel. An
- // ideal Codec server would handle and report stream errors via the error_
- // flags and complete stream processing without sending OnStreamFailed(), but
- // in any case, the above-listed options are the only ways that an
- // OnOutputEndOfStream() won't happen after QueueInputEndOfStream().
- //
- // There will be no more OnOutputPacket() or OnOutputConfig() messages for
- // this stream_lifetime_ordinal after this message - if a server doesn't
- // follow this rule, a client should close the Codec channel.
- //
- // The error_detected_before bool has the same semantics as the
- // error_detected_before bool in OnOutputPacket().
- 14: -> OnOutputEndOfStream(
- uint64 stream_lifetime_ordinal,
- bool error_detected_before);
-
- //
- // Stream specific messages:
- //
-
- // QueueInputFormatDetails()
- //
- // If the input format details are still the same as specified during Codec
- // creation, this message is unnecessary and does not need to be sent.
- //
- // If the stream doesn't exist yet, this message creates the stream.
- //
- // All servers must permit QueueInputFormatDetails() at the start of a stream
- // without failing, as long as the new format is supported by the Codec
- // instance. Technically this allows for a server to only support the exact
- // input format set during Codec creation, and that is by design. A client
- // that tries to switch formats and gets a Codec channel failure should try
- // again one more time with a fresh Codec instance created with CodecFactory
- // using the new input format during creation, before giving up.
- //
- // These format details override the format details
- // specified during codec creation for this stream only. The next stream will
- // default back to the format details set during codec creation.
- //
- // For now, QueueInputFormatDetails() sent mid-stream will fail the Codec
- // channel. Clients shouldn't do this for now.
- //
- // This message is permitted at the start of the first stream (just like at
- // the start of any stream). The format specified need not match what was
- // specified during codec creation, but if it doesn't match, the Codec channel
- // might close as described above.
- 15: QueueInputFormatDetails(
- uint64 stream_lifetime_ordinal, CodecFormatDetails format_details);
-
- // QueueInputPacket()
- //
- // This message queues input data to the codec for processing.
- //
- // If the stream doesn't exist yet, this message creates the new stream.
- //
- // The client is required to be willing to send QueueInputPacket() prior to
- // the server's first OnOutputConfig(), and is permitted to start a new stream
- // without output buffers configured yet.
- //
- // The client must continue to deliver input data via this message even if the
- // codec has not yet generated the first OnOutputConfig(), and even if the
- // Codec is generating OnFreeInputPacket() for previously-queued input
- // packets. The input data must continue as long as there are free packets
- // to be assured that the server will ever generate the first
- // OnOutputConfig().
- //
- // For more on QueueInputPacket(), see codec.md.
- 16: QueueInputPacket(CodecPacket packet);
-
- // OnFreeInputPacket()
- //
- // The server sends this message when the codec is done consuming this packet
- // and the packet can be re-filled by the client.
- //
- // This is not sent for all packets when a new buffer_lifetime_ordinal starts
- // as in that case all the packets are initially free with the client.
- //
- // See comments on QueueInputBuffer() and "packet lifetime" in codec.md for
- // for description of buffer lifetime and packet lifetime.
- //
- // After receiving the available input buffer via this event, the codec
- // client can call later call QueueInputBuffer with appropriate offset and
- // length set.
- //
- // TODO(dustingreen): At the moment, there is no guarantee re. the order of
- // these messages with respect to the order of QueueInputPacket(), but at
- // least for decoders, it might be worthwhile to require that servers preserve
- // the order vs. QueueInputPacket(), to make it easier to feed input from a
- // ring buffer or similar. For audio encoders it might still make sense. For
- // video encoders probably not.
- 17: -> OnFreeInputPacket(CodecPacketHeader free_input_packet);
-
- // Inform the server that all QueueInputPacket() messages for this stream
- // have been sent.
- //
- // If the stream isn't closed first (by the client, or by OnStreamFailed(), or
- // Codec channel closing), there will later be a corresponding
- // OnOutputEndOfStream().
- //
- // The corresponding OnOutputEndOfStream() message will be generated only if
- // the server finishes processing the stream before the server sees the
- // client close the stream (such as by starting a new stream). A way to
- // force the server to finish the stream before closing is to use
- // FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
- // new stream. Another way to force the server to finish the stream before
- // closing is to wait for the OnOutputEndOfStream() before taking any action
- // that closes the stream.
- //
- // In addition to serving as an "EndOfStream" marker to make it obvious
- // client-side when all input data has been processed, if a client never
- // sends QueueInputEndOfStream(), no amount of waiting will necessarily
- // result in all input data getting processed through to the output. Some
- // codecs have some internally-delayed data which only gets pushed through by
- // additional input data _or_ by this EndOfStream marker. In that sense,
- // this message can be viewed as a flush-through at InputData domain level,
- // but the flush-through only takes effect if the codec even gets that far
- // before the stream is just closed at StreamControl domain level. This
- // message is not alone sufficient to act as an overall flush-through at
- // StreamControl level. For that, send this message first and then send
- // FlushEndOfStreamAndCloseStream() (at which point it becomes possible to
- // queue input data for a new stream without causing discard of this older
- // stream's data), or wait for the OnOutputEndOfStream() before closing the
- // current stream.
- //
- // If a client sends QueueInputPacket(), QueueInputFormatDetails(),
- // QueueInputEndOfStream() for this stream after the first
- // QueueInputEndOfStream() for this stream, a server should close the Codec
- // channel.
- 18: QueueInputEndOfStream(uint64 stream_lifetime_ordinal);
-};
diff --git a/fidl/fuchsia.mediacodec/codec_common.fidl b/fidl/fuchsia.mediacodec/codec_common.fidl
deleted file mode 100644
index d1e7a7c..0000000
--- a/fidl/fuchsia.mediacodec/codec_common.fidl
+++ /dev/null
@@ -1,511 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.mediacodec;
-
-// Value
-//
-// Generic "value" for use within generic "Parameter" struct.
-union Value {
- bool bool_value;
- uint64 uint64_value;
- int64 int64_value;
- string string_value;
- // Prefer using codec_oob_bytes instead.
- vector<uint8> bytes_value;
-};
-
-// Parameter
-//
-// Generic parameter.
-//
-// We want to minimize use of this generic "Parameter" structure by natively
-// defining as many codec-specific parameter semantics as we can.
-//
-// TODO: When possible, describe the very limited scenarios in which it would
-// still be reasonable to use a generic Parameter.
-struct Parameter {
- // Some indication of the scope of applicability of this Parameter.
- string scope;
- // Specific name of this parameter, without the scope prefix.
- string name;
- // The particular value of this parameter.
- Value value;
-};
-
-// CodecFormatDetails
-//
-// The purpose of CodecFormatDetails is to fill in additional details not
-// conveyed via other means.
-//
-// TODO(dustingreen): Where at all possible, definitions for the concepts
-// within CodecFormatDetails should go in media_types.fidl or another location
-// that's widely shared. Maybe some encoder settings could remain
-// codec-specific.
-//
-// For decoders input, the format details tend to be fairly sparse, since most
-// compressed formats tend to be mostly self-describing.
-//
-// For decoder output and encoder input, the format details need to include all
-// the out-of-band information regarding the uncompressed data, which tends not
-// to be self-describing.
-//
-// For encoder output, we also include in CodecFormatDetails some additional
-// encoding parameters which are needed to configure the encoder. These are not
-// really needed by any downstream decoder under most circumstances, but these
-// encoder config settings are legitimate optional format details, so we use
-// the same overall structure, but name them "Encoder" to make it more obvious
-// that these are mostly relevant to the encoder. A downstream consumer could
-// potentially benefit from knowing these settings, but most won't look at them.
-//
-// Settings that are completely redundant with the data in the format itself
-// should not be in a required field here. Some encoder parameters may also be
-// represented in codec_oob_bytes on the output of an encoder - a downstream
-// consumer can assume the codec_oob_bytes are correct and not check for whether
-// encoder settings are present or consistent.
-//
-// With some exceptions made for encoder settings on output of an encoder, this
-// stuff should be limited to things we need to know to properly process the
-// data which we can't already determine from the data itself, and which isn't
-// already covered by a format's defined OOB binary config blob, which is
-// conveyed in codec_oob_bytes.
-//
-// TODO(dustingreen): Consider whether to split encoder settings into a
-// separate struct - the main counter-argument would be if a consumer
-// immediately downstream of an encoder may have good reason to know encoder
-// settings to help process the data. For example, the nominal bit-rate.
-
-// Compressed formats tend to be much more self-describing than uncompressed
-// formats. (The "self" in "self-describing" includes the codec_oob_bytes.)
-//
-// Most decoders can have CodecFormatDetails.domain null.
-
-// AudioCompressedFormat
-//
-// Format details relevant to compressed audio, mostly for encoder settings.
-//
-// Unless otherwise specified in a comment on a field in this structure,
-// CodecFormatDetails.domain is null for a decoder. A sub-structure whose name
-// ends in "Encoder" is for encoder output settings.
-//
-// TODO(dustingreen): Consider whether splitting encoder settings out separately
-// would be better.
-union AudioCompressedFormat {
- // For an aac encoder, this field has settings the encoder needs which are
- // specific to AAC encoding.
- AudioCompressedFormatAacEncoder aac;
-};
-
-enum AudioBitrateMode {
- // Used mainly when a client is configuring an encoder's output format. May
- // also be present in an OnOutputConfig() message from an encoder, but should
- // not be relied upon to be present by any consumer downstream of an encoder.
- UNSPECIFIED = 0;
- CBR = 1;
- VBR = 2;
-};
-
-// AudioCompressedFormatAacEncoder
-//
-// Encoder settings for an AAC encoder.
-struct AudioCompressedFormatAacEncoder {
- // In SetOutputConfig():
- //
- // If zero, an encoder should generate 256 kbps, and a consumer should not
- // assume any particular bitrate.
- //
- // If not zero, the encoder should not exceed this bitrate. In CBR the
- // encoder should use the highest available bitrate that doesn't exceed this
- // value, or if there is no such bitrate, the lowest available bitrate. In
- // VBR, the encoder should stay at or below this bitrate.
- //
- // In VBR it's left up to the encoder to choose a reasonable ratio between
- // max bits per second and min bits per second, with the aim in VBR being
- // constant perceived quality.
- //
- // In OnOutputConfig():
- //
- // In CBR, the nominal bits per second. In VBR, the nominal max bits per
- // second.
- uint32 bits_per_second;
-
- // In SetOutputConfig():
- //
- // If UNSPECIFIED, up to the encoder. If CBR or VBR, a hint to the encoder
- // to use that mode.
- //
- // In OnOutputConfig():
- //
- // Actual mode being used. UNSPECIFIED means the source is not specifying
- // which mode.
- AudioBitrateMode bitrate_mode;
-
- // TODO(dustingreen): AAC profile settings.
-};
-
-// AudioPcmMode
-//
-// TODO(dustingreen): Keep or discard any non-linear formats for purposes of the
-// Codec interface?
-enum AudioPcmMode {
- // 16 bit signed int linear or 32 bit float linear, for now
- // 1-N channels ok, with "A.B" channels designated as A+B channel_count - the
- // channel map is separately specified. So 5.1 becomes channel_count 6.
- LINEAR = 0;
- // G.711 8 bit format-defined waveform semantics
- // 1 channel
- ALAW = 1;
- // G.711 8 bit format-defined waveform semantics
- // 1 channel
- MULAW = 2;
-};
-
-// AudioChannelId
-//
-// Used in specifying which audio channel is for which speaker location / type.
-//
-// TODO(dustingreen): Do we need more channel IDs than this?
-//
-// TODO(dustingreen): Check with mpuryear@ re. naming consistency for "S" vs.
-// "R" as we move these to a common definition. Also the ordering of LS/RS vs.
-// LR/RR - probably LR/RR being first would make more sense re. how channels
-// get added incrementally, but changing the order would no longer match
-// Android's ordering.
-enum AudioChannelId {
- SKIP = 0; // unused channel
- LF = 1; // left front
- RF = 2; // right front
- CF = 3; // center front
- LS = 4; // left surround
- RS = 5; // right surround
- LFE = 6; // low frequency effects
- CS = 7; // back surround
- LR = 8; // left rear
- RR = 9; // right rear
- // This is the last explicitly-defined value + 1. This name will be
- // re-defined in future if we add more defined channel IDs above.
- END_DEFINED = 10;
- // This is where format-specific (or ad-hoc) channel ID values should go, to
- // avoid colliding with any additional values allocated above. The values
- // here are not guaranteed to avoid collision across different formats.
- EXTENDED_CHANNEL_ID_BASE = 0x6f000000;
- // Extended channel IDs should be <= Max.
- MAX = 0x7fffffff;
-};
-
-// PcmFormat
-//
-// PCM audio format details.
-//
-// TODO(dustingreen): Discuss with mpuryear@ re. where definitions for these
-// details go and make sure the common details can specify at least this much.
-struct PcmFormat {
- // Implicit details:
- // * For bits_per_sample > 8, host-endian is implied.
- // * At least for now, for channel_count >= 2, interleaved layout is
- // implied.
-
- AudioPcmMode pcm_mode;
-
- // bits_per_sample
- //
- // A "sample" is for a single channel.
- //
- // For example, CD quality is 16. See PcmMode comments, as the mode
- // constrains this value.
- uint32 bits_per_sample;
-
- // frames_per_second
- //
- // A "frame" is one datapoint (one "sample") for each channel. Each channel
- // is sampled this many times per second. For example, CD quality is 44100.
- uint32 frames_per_second;
-
- // channel_map
- //
- // channel_map.size() is the channel count. See PcmMode comments, as some
- // modes constrain the channel count to 1.
- //
- // Values from AudioChannelId should be used if they are suitable.
- //
- // If a channel has no suitable AudioChannelId, an ad-hoc value can be used in
- // a range starting from AudioChannel_ExtendedChannelIdBase.
- vector<AudioChannelId>:16 channel_map;
-
- // TODO(dustingreen): Add unsigned 8 bit, float 32 bit, maybe others. FWIW,
- // AOSP appears to support signed 16 bit, unsigned 8 bit, and float 32 bit
- // under "Pcm", AFAICT based on OMX_NUMERICALDATATYPE and ACodec.cpp code.
-};
-
-// AudioUncompressedFormat
-//
-// Uncompressed audio format details.
-union AudioUncompressedFormat {
- PcmFormat pcm;
-};
-
-// AudioFormat
-//
-// Audio format details.
-union AudioFormat {
- AudioCompressedFormat compressed;
- AudioUncompressedFormat uncompressed;
-};
-
-// VideoCompressedFormat
-//
-// Compressed video format details.
-//
-// Mostly encoder settings will go under here.
-//
-// If a compressed video format is missing any fields here other than encoder
-// settings, it's because it's a good format and is already self-describing
-// given the mime_type + format-defined codec_oob_bytes as appropriate +
-// in-band data.
-union VideoCompressedFormat {
- // TODO(dustingreen): Any compressed video formats that aren't sufficiently
- // self-describing to select and create a Codec instance to decode it?
-
- // TODO(dustingreen): temp field to make the compiler happy until we have at
- // least one real field.
- uint32 temp_field_todo_remove;
-};
-
-// VideoUncompressedFormatSpecificDetails
-//
-// Extended format-specific uncompressed video format details.
-//
-// TODO(dustingreen): Switch to FIDL table instead.
-union VideoUncompressedFormatSpecificDetails {
- // TODO(dustingreen): Which formats that we care about really require special
- // format-specific details here?
-
- // TODO(dustingreen): temp field to make the compiler happy until we have at
- // least one real field.
- uint32 temp_field_todo_remove;
-};
-
-enum VideoColorSpace {
- // TODO(dustingreen): add to this list
- INVALID = 0;
-};
-
-// VideoUncompressedFormat
-//
-// Uncompressed video format details.
-//
-// TODO(dustingreen): Integrate with a system-wide structure for this purpose.
-struct VideoUncompressedFormat {
- // fourcc
- //
- // A human-readable fourcc like RGBA should be 0x41424752 in the fourcc field
- // (regardless of host endian-ness). Note that the R (first character) of the
- // fourcc is in the low-order byte of this fourcc field.
- //
- // There are some fourcc codes that don't format nicely as a string. While I
- // don't foresee any use of any of the purely numeric fourcc codes (not
- // corresponding to packed ascii character values), those would be stored
- // such that their numeric value has it's low-order byte in the low-order
- // byte of this fourcc value. So a fourcc with "hex value" 0x00000001 would
- // have the numeric value 1 in this field.
- //
- // The endian-ness of fourcc values stored in files or in network packets is
- // outside the scope of these comments, other than to state that regardless
- // of the source of the fourcc code and the order that storage / transmission
- // format stores these bytes, a human-readable fourcc should have its
- // human-read first ascii character value in the low order byte of this
- // field.
- uint32 fourcc;
-
- // For formats with different planes having different resolution, this is the
- // resolution of the highest-resolution plane(s). Else it's the resolution
- // of all the planes.
- uint32 primary_width_pixels;
- uint32 primary_height_pixels;
-
- // For formats where the seconary planes are the same resolution, these fields
- // will be the same as primary_width_pixels and primary_height_pixels. For
- // formats with smaller secondary resolutions, these indicate that resolution.
- uint32 secondary_width_pixels;
- uint32 secondary_height_pixels;
-
- // Planar means the various planes are separately stored in their own chunks
- // of memory.
- bool planar;
-
- // If a format is swizzled, the swizzling parameters are not directly here.
- bool swizzled;
-
- uint32 primary_line_stride_bytes;
- // Formats with the same stride for all planes will have this field equal to
- // primary_line_stride_bytes.
- uint32 secondary_line_stride_bytes;
-
- // R or Y
- uint32 primary_start_offset;
- // G or U
- uint32 secondary_start_offset;
- // B or V
- uint32 tertiary_start_offset;
-
- uint32 primary_pixel_stride;
- // For formats with the same pixel stride for all planes, this field will be
- // equal to primary_pixel_stride.
- uint32 secondary_pixel_stride;
-
- // These override the primary_width_pixels and primary_height_pixels for
- // purposes of display (but not for purposes of determining the pixel layout
- // in memory). These can crop on the right and bottom. These must be <= the
- // corresponding coded dimension.
- //
- // This value must be <= primary_width_pixels.
- uint32 primary_display_width_pixels;
- // This value must be <= primary_height_pixels.
- uint32 primary_display_height_pixels;
-
- // The pixel_aspect_ratio_width : pixel_aspect_ratio_height is the pixel
- // aspect ratio (AKA sample aspect ratio aka SAR) for the luma (AKA Y)
- // samples. A pixel_aspect_ratio of 1:1 mean square pixels. A
- // pixel_aspect_ratio of 2:1 would mean pixels that are displayed twice as
- // wide as they are tall. Codec implementation should ensure these two values
- // are relatively prime by reducing the fraction (dividing both by GCF) if
- // necessary.
- //
- // When has_pixel_aspect_ratio == false, pixel_aspect_ratio_width and
- // pixel_aspect_ratio_height will both be 1, but in that case the
- // pixel_aspect_ratio_width : pixel_aspect_ratio_height of 1:1 is just a very
- // weak suggestion re. reasonable-ish handling, not in any way authoritative.
- // In this case (or in any case really) the receiver of this message may have
- // other OOB means to determine the actual pixel_aspect_ratio.
- bool has_pixel_aspect_ratio = false;
- uint32 pixel_aspect_ratio_width = 1;
- uint32 pixel_aspect_ratio_height = 1;
-
- // TODO(dustingreen): Currently this assumes 8 bits per channel, but we'll
- // need fields to indicate more bits per pixel such as 10 or 12 bits per
- // pixel. Also, potentially a way to indicate different number of bits per
- // channel for 565 16 bit RGB + packing details. Also, potentially
- // endian-ness.
- //
- // TODO(dustingreen): Also, an easy way to get a template
- // VideoUncompressedFormat that's pre-populated with reasonably-plausible
- // values, based on a fourcc or enum value + maybe primary resolution.
-
- VideoUncompressedFormatSpecificDetails special_formats;
-};
-
-// VideoFormat
-//
-// Video (compress or uncompressed) format details.
-union VideoFormat {
- VideoCompressedFormat compressed;
- VideoUncompressedFormat uncompressed;
-};
-
-// DomainFormat
-//
-// Domain-specific format details (audio or video, compressed or uncompressed).
-union DomainFormat {
- AudioFormat audio;
- VideoFormat video;
-};
-
-const uint64 kMaxCodecOobBytesSize = 8192;
-
-// CodecFormatDetails
-//
-// This describes/details the format on input or output of a codec (separate
-// instances for input vs. output).
-struct CodecFormatDetails {
- // Particular instances of CodecFormatDetails will set this field to make it
- // easier for a receiver to determine if any part of the format has changed
- // vs. the last CodecFormatDetails received for the same context.
- uint64 format_details_version_ordinal;
-
- // "mime_type" strings used by particular decoders / encoders so far:
- //
- // SW AAC decoder:
- // * input:
- // * "audio/aac-adts" - ATDS AAC; self-contained format, but
- // implementation for now requires codec_oob_bytes to contain
- // AudioSpecificConfig() reconstructed from ADTS header data - see also
- // make_AudioSpecificConfig_from_ADTS_header() for now.
- // * output:
- // * "audio/raw" - stereo linear 16 bit integer PCM
- //
- // TODO(dustingreen): avoid requiring codec_oob_bytes when using SoftAAC2.cpp
- // for AAC ADTS.
- //
- // TODO(dustingreen): Add non-ADTS AAC support (which naturally needs
- // codec_oob_bytes).
- //
- // TODO(dustingreen): Consider "pseudo_mime_type", or an enum, + "domain"
- // details as needed instead, since calling this "mime_type" could lead to
- // confusion.
- string mime_type;
-
- // Some codecs have their own binary codec configuration structure. For those
- // codecs we allow that binary structure to be directly conveyed to the codec
- // here.
- //
- // audio/aac - this is an AudioSpecificConfig().
- // audio/aac-adts - this is not set.
- // TODO(dustingreen): make the audio/aac-adts statement true soon. At the
- // moment we set this with make_AudioSpecificConfig_from_ADTS_header(), but
- // that should not be the client's job for ADTS.
- //
- // For some formats whose "ES" data format is self-contained, or for which
- // there is no format-defined binary OOB config, this is null.
- //
- // A server can close the channel if the count of bytes is >
- // kMaxCodecOobBytesSize or is larger than makes any sense for the codec. If
- // any codec actually needs more than kMaxCodecOobBytesSize bytes here, we
- // could potentially increase this restriction some, but this interface isn't
- // designed to support codec OOB config blobs that approach
- // ZX_CHANNEL_MAX_MSG_BYTES.
- vector<uint8>? codec_oob_bytes;
-
- // Decoder input format:
- //
- // If a format is not self-describing given the mime_type and a
- // format-spec-defined codec_oob_bytes, this domain field can be set to
- // provide the additional compressed-format-specific details. This is
- // expected to be fairly rare, so most compressed input formats will have
- // only the mime_type and possibly codec_oob_bytes set, with domain typically
- // null. If an encoder is upstream however, domain may be set to convey the
- // encoder settings that were used, but a decoder consumer doesn't need to
- // look at those.
- //
- // Encoder output format:
- //
- // The encoder's compressed data output typically needs some configuration
- // (provided in this field) that's convenient to provide in a form that's not
- // codec_oob_bytes, and the codec can convert that config to codec_oob_bytes
- // on encoder output via OnOutputConfig(). We retain these encoder settings
- // in the output CodecFormatDetails to allow for cases where a downstream
- // consumer knowing the encoder settings could be useful.
- //
- // TODO(dustingreen): Decide if we want to retain this, or if we'd prefer to
- // split out config settings and maybe only represent a few encoder settings
- // as best-effort optional aux data, like bitrate.
- //
- // Encoder input format / decoder output format:
- //
- // This field contains fairly detailed information re. uncompressed data
- // format details, which tends to _not_ be self-describing in-band.
- DomainFormat? domain;
-
- // See comments above on Parameter. At the time we lock relevant FIDL
- // interfaces, there should be zero use of this field outside tests, but this
- // is here in case we need to allow a codec client to convey additional config
- // parameters to/from a codec which we didn't anticipate before locking.
- //
- // If there are any known "official" exceptions to the previous paragraph,
- // we'll list them here by corresponding mime_type (none so far):
- // * "<mime_type>" - <usage_description>
- //
- // For codecs that define their own codec-specific config/OOB data, put that
- // in codec_oob_bytes above instead of this field.
- vector<Parameter>? pass_through_parameters;
-};
diff --git a/fidl/fuchsia.mediacodec/codec_factory.fidl b/fidl/fuchsia.mediacodec/codec_factory.fidl
deleted file mode 100644
index 6fad411..0000000
--- a/fidl/fuchsia.mediacodec/codec_factory.fidl
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.mediacodec;
-
-// CreateDecoder_Params
-//
-// Input parameters for creating a decoder (audio or video).
-//
-// TODO(dustingreen): Switch this to a FIDL table instead when possible.
-struct CreateDecoder_Params {
- // Input mime type for a decoder.
- //
- // The recognized mime types for now:
- // audio/aac
- // input_details.codec_oob_bytes must be an AudioSpecificConfig() as defined
- // by AAC spec.
- // audio/aac-adts
- // On a temporary basis, input_details.codec_oob_bytes must be an
- // AudioSpecificConfig() extracted from the ADTS stream data by the client.
- // This is temporary. Later, codec_oob_bytes will be ignored and allowed to
- // be null. On a temporary basis, see
- // make_AudioSpecificConfig_from_ADTS_header() for some self-contained
- // conversion code.
- // TODO(dustingreen): fix this up server side and make most of this
- // paragraph go away, possibly by also parsing ADTS before it hits OMX
- // since the parsing code there doesn't tolerate split ADTS headers.
- CodecFormatDetails input_details;
-
- // The settings below nail down more details.
-
- // This must be true in order for the client to be permitted to put a
- // timestamp on an input packet, which is in turn required to get any
- // timestamps on any output packets.
- //
- // It is always legal to provide separate Access Units (henceforth AUs) to a
- // decoder, but this boolean must be true for a decoder to accept and
- // propagate timestamp values.
- //
- // This must be true when creating a video encoder, or the CodecFactory
- // channel will close.
- bool promise_separate_access_units_on_input = false;
-
- // "require" fields:
- //
- // Specifying any of these "require" fields can result in failure to get a
- // Codec if there's no suitable codec. None of these correspond to any
- // required features of a codec server.
- //
- // TODO(dustingreen): implement filtering codecs based on these fields.
-
- // Require that the selected codec be capable of accepting input where
- // AUs are not separated into separate packets.
- //
- // This does not imply that the decoder can find the start of the first AU;
- // for that see require_can_find_start. This does not imply that the decoder
- // can re-sync on its own if the stream data is damaged; for that see
- // require_can_re_sync.
- //
- // If both promise_separate_access_units_on_input and
- // require_can_stream_bytes_input are true, the CodecFactory channel will
- // close.
- //
- // If this is false, the client must feed separate AUs on the fuchsia.ui.input. This
- // must be false for a video encoder, and if true the CodecFactory channel
- // will close.
- //
- // Unless a client demands a decoder capable of taking concatenated AUs
- // (require_can_stream_bytes_input true), the client must feed a decoder
- // separate AUs. This means the client cannot have parts of two separate AUs
- // in the same packet, unless require_can_stream_bytes_input is true.
- bool require_can_stream_bytes_input = false;
-
- // A decoder is allowed to be capable of streaming bytes but not capable of
- // searching for the start of the first usable AU. To require both, set both
- // require_can_stream_bytes_input and require_can_find_start. Setting
- // require_can_find_start without require_can_stream_bytes_input is invalid.
- //
- // With require_can_stream_bytes_input true but require_can_find_start false,
- // the client must start the first packet with the start of an AU, but can
- // send a stream of bytes after that.
- bool require_can_find_start = false;
-
- // On problematic input data, all decoders are expected to at least be able to
- // close the channel rather than getting stuck in a failed and/or broken
- // state.
- //
- // A decoder returned from a request with require_can_re_sync is potentially
- // able to handle damaged input without closing the Codec channel. Such a
- // Codec is encouraged, but not required, to also satisfy requirements of
- // require_report_all_detected_errors.
- bool require_can_re_sync = false;
-
- // Sometimes a client would rather fail an overall use of a decoder than fail
- // to notice data corruption. For such scenarios, the client can specify
- // require_report_all_detected_errors. For any codec returned from a
- // request with require_report_all_detected_errors set, on detection of
- // any input data corruption the codec will report in one or more of these
- // ways:
- // * closing the Codec channel
- // * OnStreamFailed()
- // * error_detected_before
- // * error_detected_during
- //
- // If false, a codec may silently skip past corrupted input data.
- //
- // No decoder can detect all corruption, because some corruption can look like
- // valid stream data. This requirement is only to request a codec that
- // is written to attempt to detect _and report_ input stream corruption.
- //
- // This flag is not intended to be 100% bulletproof. If a client needs robust
- // assurance that _all_ detectable stream corruption is _always_ detected,
- // this flag is not enough of a guarantee to achieve that. Since some stream
- // corruption is inherently non-detectable in any case, such a client should
- // consider using stronger techniques upstream to ensure that corruption can
- // be detected with the needed probability very close to 1.
- //
- // This flag being true doesn't imply anything about whether the codec will
- // discard damaged data vs. producing corresponding damaged output. Only that
- // the codec will set error_detected_* bools to true when appropriate.
- //
- // Regardless of this setting, not all timstamp_ish values provided on input
- // are guaranteed to show up on ouput.
- bool require_report_all_detected_errors = false;
-
- // If true, require that the returned codec is HW-accelerated.
- bool require_hw = false;
-
- // permit_lack_of_split_header_handling
- //
- // This field is a temporary field that will be going away.
- //
- // TODO(dustingreen): Remove this field once we're down to zero codecs with
- // problems handling split headers.
- //
- // By default, a Codec instance is required to handle "split headers", meaning
- // that a client is allowed to deliver parts of an AU one byte at a time,
- // including parts near the beginning of the AU, and the codec is required to
- // tolerate and handle that properly. However, unfortunately not all codecs
- // properly support split headers. If a client is willing to permit such a
- // codec to be used, the client can set this to true. Clients are not
- // encouraged to set this, but setting it may be necessary to find a codec for
- // some formats _for now_. If a client sets this to true, the client should
- // deliver data of each AU with many contiguous non-split bytes from the start
- // of each AU. The client is not strictly required to deliver one AU at a
- // time, only to ensure that either all the AU bytes are in a single packet or
- // that many bytes at the start of each AU are in a single packet.
- //
- // The specification for how a client should use this and how a client should
- // behave if setting this to true is intentionally vague, because lack of
- // support for header splitting is not ideal, and is expected to be
- // temporary, and all codecs should handle split headers in the long run.
- // The main intent of this field is to avoid giving an innocent client using
- // default value of false here a codec that can't properly handle split
- // headers. This is not an attempt at a mechanism to fully work around a
- // codec that doesn't handle split headers.
- //
- // TODO(dustingreen): In the near term, wire this up so that SoftAAC2.cpp
- // used for ADTS is not selected when this field is false, even if there is
- // no other suitable codec. In the long term, fix or work around the header
- // handling behavior of SoftAAC2 when used in ADTS mode (and any other
- // similar issues in other codecs) and remove this field.
- bool permit_lack_of_split_header_handling = false;
-};
-
-enum CodecType {
- DECODER = 0;
- ENCODER = 1;
-};
-
-struct CodecDescription {
- // Decoder or encoder.
- CodecType codec_type;
- // The mime type of the compressed format. For decoders this is the mime
- // type of the input. For encoders, this is the mime type of the output.
- string mime_type;
-
- // TODO(dustingreen): All these fields should be optional.
- //
- // TODO(dustingreen): Re-evaluate this for encoders.
- //
- // For each of these fields, the default is the most-capable setting, but if a
- // codec doesn't support the most-capable behavior, then the codec must
- // override the default.
- bool can_stream_bytes_input = true;
- bool can_find_start = true;
- bool can_re_sync = true;
- bool will_report_all_detected_errors = true;
- bool is_hw = true;
- bool split_header_handling = true;
-};
-
-// CodecFactory
-//
-// The purpose of the media::CodecFactory interface is to create media::Codec
-// instances.
-//
-// The interface methods don't attempt to homogenize all codec types, preferring
-// to have a separate dedicated message for decoders. TBD whether calls for
-// creating encoders will split up audio vs. video encoders, or be combined.
-//
-// Each create request is self-contained, in the sense that the interface is not
-// stateful between create requests.
-[Discoverable]
-interface CodecFactory {
- // Driver-based local CodecFactory(s) will send this once shortly after the
- // main CodecFactory connects to the driver-local CodecFactory.
- //
- // For now, the main CodecFactory will not send this.
- //
- // A SW-based local CodecFactory(s) will not send this event.
- //
- // Each codec in the list must be separately-described, for clean aggregation.
- 1: -> OnCodecList(vector<CodecDescription> codecs);
-
- // Rough sequence to create a decoder:
- //
- // factory = ConnectToEnvironmentService(CodecFactory);
- // CreateDecoder_Params params;
- // [fill out params]
- // CreateDecoder(params, decoder_request);
- //
- // See use_media_decoder code for more detail.
- //
- // TODO(dustingreen): More detail in this comment block.
-
- // Requests:
-
- // CreateDecoder:
- //
- // decoder_params - See CreateDecoder_Params comments for required
- // and optional parameters for creating a decoder.
- //
- // decoder - a Codec.NewRequest() which will hopefully be connected to
- // a Codec server, or the Codec channel will get closed if no suitable codec
- // can be found. We don't return any additional Codec-specific status here
- // because finding the Codec is allowed to be fully async, so we don't
- // necessarily yet know on return from this method which Codec will be
- // selected, if any.
- 2: CreateDecoder(
- CreateDecoder_Params decoder_params,
- request<Codec> decoder);
-
- // TODO(dustingreen):
- // CreateAudioEncoder
- // CreateVideoEncoder
- // (or combined)
-};
diff --git a/fidl/fuchsia.mediacodec/meta.json b/fidl/fuchsia.mediacodec/meta.json
deleted file mode 100644
index 9f9f144..0000000
--- a/fidl/fuchsia.mediacodec/meta.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.mediacodec/codec_common.fidl",
- "fidl/fuchsia.mediacodec/codec_factory.fidl",
- "fidl/fuchsia.mediacodec/codec.fidl"
- ],
- "name": "fuchsia.mediacodec",
- "root": "fidl/fuchsia.mediacodec",
- "sources": [
- "fidl/fuchsia.mediacodec/codec_common.fidl",
- "fidl/fuchsia.mediacodec/codec_factory.fidl",
- "fidl/fuchsia.mediacodec/codec.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.mem/buffer.fidl b/fidl/fuchsia.mem/buffer.fidl
deleted file mode 100644
index ff281cc..0000000
--- a/fidl/fuchsia.mem/buffer.fidl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.mem;
-
-struct Buffer {
- // The vmo.
- handle<vmo> vmo;
-
- // The size of the data in the vmo. This size must be smaller than the
- // physical size of the vmo.
- uint64 size;
-};
diff --git a/fidl/fuchsia.mem/meta.json b/fidl/fuchsia.mem/meta.json
deleted file mode 100644
index f12f499..0000000
--- a/fidl/fuchsia.mem/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.mem/buffer.fidl"
- ],
- "name": "fuchsia.mem",
- "root": "fidl/fuchsia.mem",
- "sources": [
- "fidl/fuchsia.mem/buffer.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.net.http/client.fidl b/fidl/fuchsia.net.http/client.fidl
deleted file mode 100644
index 945a453..0000000
--- a/fidl/fuchsia.net.http/client.fidl
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.http;
-
-using fuchsia.mem;
-
-// An error occurred during the HTTP transaction.
-struct Error {
- // The numerical error code.
- //
- // These error codes coorespond to
- // <https://fuchsia.googlesource.com/garnet/+/master/bin/network/net_error_list.h>
- int32 code;
-
- // A textual description of the error in en-US.
- string? description;
-};
-
-// An HTTP header field.
-struct Header {
- // The name of the header field.
- vector<uint8> name;
-
- // The value of the header field.
- vector<uint8> value;
-};
-
-// The body of either an HTTP request or an HTTP response.
-union Body {
- // A buffer that will contain the complete request or response body.
- fuchsia.mem.Buffer buffer;
-
- // A socket that will contain the streaming request or response body.
- handle<socket> stream;
-};
-
-// Specify the cache behavior of the request.
-enum CacheMode {
- // Default behavior.
- DEFAULT = 0;
-
- // The HTTP request will bypass the local cache and will have a
- // 'Cache-Control: nocache' header added in that causes any proxy servers
- // to also not satisfy the request from their cache. This has the effect
- // of forcing a full end-to-end fetch.
- BYPASS_CACHE = 1;
-
- // The HTTP request will fail if it cannot serve the requested resource
- // from the cache (or some equivalent local store).
- ONLY_FROM_CACHE = 2;
-};
-
-// Specify the mechanism used to return the response body.
-//
-// Streaming the response can be more efficient if the response body is large
-// and can be processed incrementally (e.g., by an image decoder).
-//
-// Buffering the response can be more efficient if the response body is in cache
-// and the cache entry can be directly mapped into the resulting buffer.
-enum ResponseBodyMode {
- // The complete response body should be returned in the |buffer| field of
- // the response body.
- //
- // The loader MAY abort the transation if the buffer size exceeds an
- // implementation-defined limit.
- BUFFER = 0;
-
- // The response body should be streamed through the |stream| field of the
- // response body.
- STREAM = 1;
-};
-
-// An HTTP request.
-struct Request {
- // The HTTP method if applicable.
- string method = "GET";
-
- // The URL to load.
- vector<uint8> url;
-
- // Additional HTTP request headers.
- vector<Header>? headers;
-
- // The payload for the request body. For HTTP requests, the method must be set
- // to "POST" or "PUT". If a buffer is used for the body, a Content-Length
- // header will automatically be added.
- Body? body;
-
- // The loader will cancel the request if the peer for this event is closed.
- //
- // When this happens, the loader will send a Response with the appropriate
- // error code.
- handle<eventpair>? event;
-
- // The cache behavior for the request.
- CacheMode cache_mode = DEFAULT;
-
- // The response body mode.
- ResponseBodyMode response_body_mode = BUFFER;
-};
-
-// A description of the redirect the server requested.
-//
-// The semantics of an HTTP redirect vary according to the status code use to
-// generate the redirect. This structure ensures that the loader and its client
-// agree on the interpretation of the redirect response from the server.
-struct RedirectTarget {
- // The HTTP method the server suggested for the redirect.
- string method;
-
- // The URL the server suggested for the redirect.
- vector<uint8> url;
-
- // The referrer the server suggested for the redirect.
- vector<uint8> referrer;
-};
-
-// A response to an HTTP request.
-struct Response {
- // If the response resulted in a network level error, this field will be set.
- Error? error;
-
- // The response body.
- Body? body;
-
- // The final URL of the response, after redirects have been followed.
- vector<uint8>? url;
-
- // The HTTP status code.
- //
- // 0 if not applicable.
- uint32 status_code;
-
- // The HTTP status line.
- string? status_line;
-
- // The HTTP response headers.
- vector<Header>? headers;
-
- // The MIME type of the response body.
- string? mime_type;
-
- // The character set of the response body.
- string? charset;
-};
-
-// An HTTP loader.
-//
-// The loader can service many HTTP requests concurrently. The loader tracks all
-// the outstanding requests and will cancel them all if the client closes the
-// loader interface.
-[Discoverable]
-interface Loader {
- // Initiate the given HTTP request, follow redirects, and return the final
- // response.
- //
- // The loader will follow redirects (up to an implementation-defined limit)
- // and return the final response as a reply to this message. To cancel the
- // request, either close the loader interface or close the peer to the |event|
- // included in the |request|.
- 1: Fetch(Request request) -> (Response response);
-
- // Initiate the given HTTP request and return all intermediate responses to
- // the given client.
- //
- // Unlike |Fetch|, |Start| does not automatically follow all redirects.
- // Instead, each individual response along the redirect chain is delivered to
- // the |LoaderClient|.
- 2: Start(Request request, LoaderClient client);
-};
-
-// A client interface used with |Loader.Start|.
-//
-// Closing the underlying channel will cancel the associated HTTP transaction.
-interface LoaderClient {
- // Called by the loader when the loader receives an HTTP response.
- //
- // If the server has requested a redirect, then |redirect| will be non-null
- // and describe the target the server requested. To follow the redirect, reply
- // to this message. To not follow the redirect, close the underlying channel.
- 1: OnResponse(Response response, RedirectTarget? redirect) -> ();
-};
diff --git a/fidl/fuchsia.net.http/meta.json b/fidl/fuchsia.net.http/meta.json
deleted file mode 100644
index 024fdfe..0000000
--- a/fidl/fuchsia.net.http/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.net.http/client.fidl"
- ],
- "name": "fuchsia.net.http",
- "root": "fidl/fuchsia.net.http",
- "sources": [
- "fidl/fuchsia.net.http/client.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.net.oldhttp/http_error.fidl b/fidl/fuchsia.net.oldhttp/http_error.fidl
deleted file mode 100644
index db39ed6..0000000
--- a/fidl/fuchsia.net.oldhttp/http_error.fidl
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-struct HttpError {
- int32 code;
- string? description;
-};
diff --git a/fidl/fuchsia.net.oldhttp/http_header.fidl b/fidl/fuchsia.net.oldhttp/http_header.fidl
deleted file mode 100644
index 5e5f48f..0000000
--- a/fidl/fuchsia.net.oldhttp/http_header.fidl
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-struct HttpHeader {
- string name;
- string value;
-};
diff --git a/fidl/fuchsia.net.oldhttp/http_service.fidl b/fidl/fuchsia.net.oldhttp/http_service.fidl
deleted file mode 100644
index 8e960a7..0000000
--- a/fidl/fuchsia.net.oldhttp/http_service.fidl
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-[Discoverable]
-interface HttpService {
- 1: CreateURLLoader(request<URLLoader> loader);
-};
diff --git a/fidl/fuchsia.net.oldhttp/meta.json b/fidl/fuchsia.net.oldhttp/meta.json
deleted file mode 100644
index 1078f70..0000000
--- a/fidl/fuchsia.net.oldhttp/meta.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "deps": [
- "fuchsia.mem",
- "fuchsia.netstack"
- ],
- "files": [
- "fidl/fuchsia.net.oldhttp/http_error.fidl",
- "fidl/fuchsia.net.oldhttp/http_header.fidl",
- "fidl/fuchsia.net.oldhttp/http_service.fidl",
- "fidl/fuchsia.net.oldhttp/url_body.fidl",
- "fidl/fuchsia.net.oldhttp/url_loader.fidl",
- "fidl/fuchsia.net.oldhttp/url_request.fidl",
- "fidl/fuchsia.net.oldhttp/url_response.fidl"
- ],
- "name": "fuchsia.net.oldhttp",
- "root": "fidl/fuchsia.net.oldhttp",
- "sources": [
- "fidl/fuchsia.net.oldhttp/http_error.fidl",
- "fidl/fuchsia.net.oldhttp/http_header.fidl",
- "fidl/fuchsia.net.oldhttp/http_service.fidl",
- "fidl/fuchsia.net.oldhttp/url_body.fidl",
- "fidl/fuchsia.net.oldhttp/url_loader.fidl",
- "fidl/fuchsia.net.oldhttp/url_request.fidl",
- "fidl/fuchsia.net.oldhttp/url_response.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.net.oldhttp/url_body.fidl b/fidl/fuchsia.net.oldhttp/url_body.fidl
deleted file mode 100644
index d0bb9b2..0000000
--- a/fidl/fuchsia.net.oldhttp/url_body.fidl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-using fuchsia.mem;
-
-union URLBody {
- // A socket that will contain the streaming request or response body.
- handle<socket> stream;
- // A shared buffer that will contain the complete request or response body.
- fuchsia.mem.Buffer buffer;
-};
diff --git a/fidl/fuchsia.net.oldhttp/url_loader.fidl b/fidl/fuchsia.net.oldhttp/url_loader.fidl
deleted file mode 100644
index 4f44c0c..0000000
--- a/fidl/fuchsia.net.oldhttp/url_loader.fidl
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-struct URLLoaderStatus {
- // If the loader has failed due to a network level error, this field will be
- // set.
- HttpError? error;
-
- // Set to true if the URLLoader is still working. Set to false once an error
- // is encountered or the response body is completely copied to the response
- // body stream.
- bool is_loading;
-
- // TODO(darin): Add further details about the stages of loading (e.g.,
- // "resolving host") that happen prior to receiving bytes.
-};
-
-interface URLLoader {
- // Loads the given |request|, asynchronously producing |response|. Consult
- // |response| to determine if the request resulted in an error, was
- // redirected, or has a response body to be consumed.
- 1: Start(URLRequest request) -> (URLResponse response);
-
- // If the request passed to |Start| had |auto_follow_redirects| set to false,
- // then upon receiving an URLResponse with a non-NULL |redirect_url| field,
- // |FollowRedirect| may be called to load the URL indicated by the redirect.
- 2: FollowRedirect() -> (URLResponse response);
-
- // Query status about the URLLoader.
- 3: QueryStatus() -> (URLLoaderStatus status);
-};
diff --git a/fidl/fuchsia.net.oldhttp/url_request.fidl b/fidl/fuchsia.net.oldhttp/url_request.fidl
deleted file mode 100644
index 999675e..0000000
--- a/fidl/fuchsia.net.oldhttp/url_request.fidl
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-// Specify the cache behavior of the request.
-enum CacheMode {
- // Default behavior.
- DEFAULT = 0;
-
- // The HTTP request will bypass the local cache and will have a
- // 'Cache-Control: nocache' header added in that causes any proxy servers
- // to also not satisfy the request from their cache. This has the effect
- // of forcing a full end-to-end fetch.
- BYPASS_CACHE = 1;
-
- // The HTTP request will fail if it cannot serve the requested resource
- // from the cache (or some equivalent local store).
- ONLY_FROM_CACHE = 2;
-};
-
-// Specify the mechanism used to return the response body.
-enum ResponseBodyMode {
- // The complete response body should be returned in the |buffer| field of
- // the response body.
- BUFFER = 0;
- // The response body should be streamed through the |stream| field of the
- // response body.
- STREAM = 1;
- // The response body may be returned as a buffer or stream.
- BUFFER_OR_STREAM = 2;
-};
-
-struct URLRequest {
- // The URL to load.
- string url;
-
- // The HTTP method if applicable.
- string method = "GET";
-
- // Additional HTTP request headers.
- vector<HttpHeader>? headers;
-
- // The payload for the request body. For HTTP requests, the method must be set
- // to "POST" or "PUT". If a buffer is used for the body, a Content-Length
- // header will automatically be added.
- URLBody? body;
-
- // The buffer size of the socket returned in URLResponse's |body| member.
- // A value of 0 indicates that the default buffer size should be used. This
- // value is just a suggestion. The URLLoader may choose to ignore this value.
- uint32 response_body_buffer_size = 0;
-
- // If set to true, then redirects will be automatically followed. Otherwise,
- // when a redirect is encounterd, FollowRedirect must be called to proceed.
- bool auto_follow_redirects = false;
-
- // The cache behavior for the request.
- CacheMode cache_mode = DEFAULT;
-
- // The response body mode.
- ResponseBodyMode response_body_mode = STREAM;
-};
diff --git a/fidl/fuchsia.net.oldhttp/url_response.fidl b/fidl/fuchsia.net.oldhttp/url_response.fidl
deleted file mode 100644
index e8667ca..0000000
--- a/fidl/fuchsia.net.oldhttp/url_response.fidl
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net.oldhttp;
-
-struct URLResponse {
- // If the response resulted in a network level error, this field will be set.
- HttpError? error;
-
- // The response body.
- URLBody? body;
-
- // The final URL of the response, after redirects have been followed.
- string? url;
-
- // The HTTP status code. 0 if not applicable.
- uint32 status_code;
-
- // The HTTP status line.
- string? status_line;
-
- // The HTTP response headers.
- vector<HttpHeader>? headers;
-
- // The MIME type of the response body.
- string? mime_type;
-
- // The character set of the response body.
- string? charset;
-
- // These fields are set to non-NULL if this response corresponds to a
- // redirect. Call the |FollowRedirect| method on the URLLoader instance to
- // follow this redirect.
- string? redirect_method;
- string? redirect_url;
- string? redirect_referrer;
-};
diff --git a/fidl/fuchsia.net/connectivity.fidl b/fidl/fuchsia.net/connectivity.fidl
deleted file mode 100644
index 671cb9d..0000000
--- a/fidl/fuchsia.net/connectivity.fidl
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net;
-
-[Discoverable]
-interface Connectivity {
- 1: -> OnNetworkReachable(bool reachable);
-};
diff --git a/fidl/fuchsia.net/meta.json b/fidl/fuchsia.net/meta.json
deleted file mode 100644
index 4c6f872..0000000
--- a/fidl/fuchsia.net/meta.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.net/connectivity.fidl",
- "fidl/fuchsia.net/net.fidl",
- "fidl/fuchsia.net/socket.fidl"
- ],
- "name": "fuchsia.net",
- "root": "fidl/fuchsia.net",
- "sources": [
- "fidl/fuchsia.net/connectivity.fidl",
- "fidl/fuchsia.net/net.fidl",
- "fidl/fuchsia.net/socket.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.net/net.fidl b/fidl/fuchsia.net/net.fidl
deleted file mode 100644
index b881862..0000000
--- a/fidl/fuchsia.net/net.fidl
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net;
-
-// IPv4Address is expressed in network byte order, so the most significant byte
-// ("127" in the address "127.0.0.1") will be at index 0.
-struct IPv4Address {
- array<uint8>:4 addr;
-};
-
-// IPv6Address is expressed in network byte order, so the most significant byte
-// ("ff" in the address "ff02::1") will be at index 0.
-struct IPv6Address {
- array<uint8>:16 addr;
-};
-
-union IpAddress {
- IPv4Address ipv4;
- IPv6Address ipv6;
-};
-
-struct Subnet {
- // The IPv4 or IPv6 address. Only the |prefix_len| most significant bits may be set in |addr|;
- // all bits in the host portion of the address must be zero.
- IpAddress addr;
-
- // The prefix length of the netmask. E.g. for 192.168.1.0/24, the prefix
- // length is 24, corresponding to a netmask of 255.255.255.0.
- // For IPv4, prefix_len must be in the range [0, 32].
- // For IPv6, prefix_len must be in the range [0, 128].
- uint8 prefix_len;
-};
diff --git a/fidl/fuchsia.net/socket.fidl b/fidl/fuchsia.net/socket.fidl
deleted file mode 100644
index 34b8f23..0000000
--- a/fidl/fuchsia.net/socket.fidl
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.net;
-
-// Legacy interface to create a socket
-enum SocketDomain {
- inet = 2;
- inet6 = 10;
-};
-
-enum SocketType {
- stream = 1;
- dgram = 2;
-};
-
-enum SocketProtocol {
- ip = 0;
- icmp = 1;
- tcp = 6;
- udp = 17;
- ipv6 = 41;
- icmpv6 = 58;
-};
-
-enum AddrInfoStatus {
- ok = 0;
- // invalid flags
- bad_flags = 1;
- // missing node name or service name
- no_name = 2;
- // temporary failure
- again = 3;
- // non-recoverable failure
- fail = 4;
- // no address found for node name
- no_data = 5;
- // argument buffer overflow
- buffer_overflow = 6;
- // system error
- system_error = 7;
-};
-
-struct AddrInfoHints {
- int32 flags;
- int32 family;
- int32 sock_type;
- int32 protocol;
-};
-
-struct AddrStorage {
- array<uint8>:16 val;
- uint32 len;
-};
-
-struct AddrInfo {
- int32 flags;
- int32 family;
- int32 sock_type;
- int32 protocol;
- AddrStorage addr; // TODO(tamird): use vector<uint8>:16 addr when we can?
- uint16 port;
-};
-
-[Discoverable, Layout = "Simple"]
-interface LegacySocketProvider {
- 1: OpenSocket(SocketDomain domain, SocketType type, SocketProtocol protocol)
- -> (handle<socket>? s, int32 status);
- 2: GetAddrInfo(string:256? node, string:256? service, AddrInfoHints? hints)
- -> (AddrInfoStatus status, uint32 nres, array<AddrInfo>:4 res);
- // TODO(tamird): change (nres, res) to a vector once we can.
-};
diff --git a/fidl/fuchsia.netstack/meta.json b/fidl/fuchsia.netstack/meta.json
deleted file mode 100644
index 90d68f4..0000000
--- a/fidl/fuchsia.netstack/meta.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "deps": [
- "fuchsia.net",
- "zircon.ethernet"
- ],
- "files": [
- "fidl/fuchsia.netstack/netstack.fidl"
- ],
- "name": "fuchsia.netstack",
- "root": "fidl/fuchsia.netstack",
- "sources": [
- "fidl/fuchsia.netstack/netstack.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.netstack/netstack.fidl b/fidl/fuchsia.netstack/netstack.fidl
deleted file mode 100644
index 1b582f4..0000000
--- a/fidl/fuchsia.netstack/netstack.fidl
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.netstack;
-
-using fuchsia.net;
-using zircon.ethernet;
-using zx;
-
-enum Protocol {
- UNSPECIFIED = 0;
- UDP = 1;
- TCP = 2;
-};
-
-enum Status {
- OK = 0;
- UNKNOWN_ERROR = 1;
- DNS_ERROR = 2;
- PARSE_ERROR = 3;
- IPV4_ONLY = 4;
- UNKNOWN_INTERFACE = 5;
-};
-
-struct NetErr {
- Status status;
- string message;
-};
-
-struct NetTrafficStats {
- // See network interface stats in Linux for future ideas:
- // https://chromium.googlesource.com/native_client/linux-headers-for-nacl/+/2dc04f8190a54defc0d59e693fa6cff3e8a916a9/include/linux/if_link.h#7
-
- uint64 pkts_total;
- uint64 pkts_echo_req; // request
- uint64 pkts_echo_rep; // reply
- uint64 pkts_echo_req_v6; // request
- uint64 pkts_echo_rep_v6; // reply
-
- uint64 bytes_total;
-};
-
-struct NetInterfaceStats {
- // Placeholder for all statistics regarding the network interface,
- // including, but not limited to traffic itself.
-
- int64 up_since; // Unix epoch.
-
- NetTrafficStats rx;
- NetTrafficStats tx;
-};
-
-struct IpStats {
- uint64 packets_received;
- uint64 invalid_addresses_received;
- uint64 packets_delivered;
- uint64 packets_sent;
- uint64 outgoing_packet_errors;
-};
-
-struct TcpStats {
- uint64 active_connection_openings;
- uint64 passive_connection_openings;
- uint64 failed_connection_attempts;
- uint64 valid_segments_received;
- uint64 invalid_segments_received;
- uint64 segments_sent;
- uint64 resets_sent;
-};
-
-struct UdpStats {
- uint64 packets_received;
- uint64 unknown_port_errors;
- uint64 receive_buffer_errors;
- uint64 malformed_packets_received;
- uint64 packets_sent;
-};
-
-// Mirrors tcpip.Stats in third_party/netstack/tcpip/tcpip.go.
-struct AggregateStats {
- uint64 unknown_protocol_received_packets;
- uint64 malformed_received_packets;
- uint64 dropped_packets;
- IpStats ip_stats;
- TcpStats tcp_stats;
- UdpStats udp_stats;
-};
-
-struct InterfaceConfig {
- string name;
- IpAddressConfig ip_address_config;
-};
-
-union IpAddressConfig {
- fuchsia.net.Subnet static_ip;
- bool dhcp;
-};
-
-// https://linux.die.net/man/7/netdevice
-struct NetInterface {
- uint32 id;
- uint32 flags;
- uint32 features;
- uint32 configuration;
- string name;
- fuchsia.net.IpAddress addr;
- fuchsia.net.IpAddress netmask;
- fuchsia.net.IpAddress broadaddr;
- vector<fuchsia.net.Subnet> ipv6addrs;
- vector<uint8> hwaddr;
-};
-
-// Flags for NetInterface.flags.
-const uint32 NetInterfaceFlagUp = 0x01; // Set if the interface is up.
-const uint32 NetInterfaceFlagDhcp = 0x02; // Set if DHCP is enabled.
-
-struct RouteTableEntry {
- fuchsia.net.IpAddress destination;
- fuchsia.net.IpAddress netmask;
- fuchsia.net.IpAddress gateway;
- uint32 nicid;
-};
-
-struct SocketAddress {
- fuchsia.net.IpAddress addr;
- uint16 port;
-};
-
-[Discoverable]
-interface Netstack {
- // Finds the port number from a given service name and protocol. [service] can be a
- // number like "42", or a service name like "http". If [protocol] is UNSPECIFIED,
- // the service is checked for TCP first, then UDP.
- 2: GetPortForService(string service, Protocol protocol) -> (uint16 port);
-
- // Finds the IP address for a given host name and port. This may issue network
- // requests via DNS to look up domain names. E.g.
- // GetAddress("example.com", 80) -> [{142.42.42.1}]
- 3: GetAddress(string address, uint16 port) -> (vector<SocketAddress> addresses, NetErr err);
-
- // Returns the list of registered network interfaces.
- 4: GetInterfaces() -> (vector<NetInterface> interfaces);
-
- // DEPRECATED: see devicesettings.fidl
- // Returns the netstack's node name.
- // 5: GetNodeName() -> (string node_name);
-
- // Don't use this for read-modify-write. Use StartRouteTableTransaction instead.
- 5: GetRouteTable() -> (vector<RouteTableEntry> rt);
-
- // TODO (porce): Separate interfaces.
- 6: GetStats(uint32 nicid) -> (NetInterfaceStats stats);
-
- // Get stats for all NICs on the stack.
- 7: GetAggregateStats() -> (AggregateStats stats);
-
- // Sets the status (up or down) for the interface with the given nicid.
- 8: SetInterfaceStatus(uint32 nicid, bool enabled);
-
- // DEPRECATED: Use StartRouteTableTransaction and SetRouteTable from there.
- // 9: SetRouteTable(vector<RouteTableEntry> rt);
-
- // Sets the address for the interface with the given nicid.
- // Masks off addr.PrefixLen bits from addr.Addr to set the subnet.
- 10: SetInterfaceAddress(uint32 nicid, fuchsia.net.IpAddress addr, uint8 prefixLen) -> (NetErr result);
-
- // Removes the address for the interface with the given nicid.
- // Masks off addr.PrefixLen bits from addr.Addr to set the subnet.
- 15: RemoveInterfaceAddress(uint32 nicid, fuchsia.net.IpAddress addr, uint8 prefixLen) -> (NetErr result);
-
- 11: SetDhcpClientStatus(uint32 nicid, bool enabled) -> (NetErr result);
-
- 12: BridgeInterfaces(vector<uint32> nicids) -> (NetErr result);
-
- // TODO(NET-1263): remove once we can use the ResolverAdmin interface
- 16: SetNameServers(vector<fuchsia.net.IpAddress> servers);
-
- 17: AddEthernetDevice(string topological_path, InterfaceConfig interfaceConfig, zircon.ethernet.Device device);
-
- // Begin a route transaction for atomically getting and setting the route
- // table. Returns true if a transaction can be started.
- 18: StartRouteTableTransaction(request<RouteTableTransaction> routeTableTransaction) -> (zx.status status);
-
- 0x1000: -> OnInterfacesChanged(vector<NetInterface> interfaces);
-};
-
-// When Commit is called, the most recent SetRouteTable will be
-// committed to the route tables. Commit may be called multiple times.
-[Discoverable]
-interface RouteTableTransaction {
- 1: GetRouteTable() -> (vector<RouteTableEntry> rt);
-
- 2: SetRouteTable(vector<RouteTableEntry> rt);
-
- 3: Commit() -> (zx.status status);
-};
diff --git a/fidl/fuchsia.process/launcher.fidl b/fidl/fuchsia.process/launcher.fidl
deleted file mode 100644
index 5415894..0000000
--- a/fidl/fuchsia.process/launcher.fidl
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.process;
-
-using fuchsia.io;
-using zx;
-
-struct HandleInfo {
- // The handle to use for this argument.
- handle handle;
-
- // Process argument identifier, from <zircon/processargs.h>.
- uint32 id;
-};
-
-struct NameInfo {
- // Path at which to install the associated directory.
- //
- // Must be an absolute path (i.e., start with '/').
- string path;
-
- // The associated directory.
- fuchsia.io.Directory directory;
-};
-
-struct LaunchInfo {
- // The executable to run in the process.
- handle<vmo> executable;
-
- // The job in which to create the process.
- handle<job> job;
-
- // The name to assign to the created process.
- string name;
-};
-
-struct LaunchResult {
- // A status code describing the result of the launch.
- zx.status status;
-
- // A string describing the failure.
- //
- // Non-null when |status| is an error.
- string? error_message;
-
- // The process that was launched.
- //
- // Present when |status| is ZX_OK.
- handle<process>? process;
-};
-
-struct ProcessStartData {
- // The process that was created.
- handle<process> process;
-
- // The vmar object that was created when the process was created.
- //
- // See <https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/process_create.md>.
- handle<vmar> root_vmar;
-
- // The initial thread for the process.
- //
- // Should be passed to |zx_process_start| when starting the process.
- handle<thread> thread;
-
- // The address of the initial entry point in the process.
- //
- // Should be passed to |zx_process_start| when starting the process.
- uint64 entry;
-
- // The stack pointer value for the initial thread of the process.
- //
- // Should be passed to |zx_process_start| when starting the process.
- uint64 sp;
-
- // The bootstrap channel to pass to the process on startup.
- //
- // Should be passed to |zx_process_start| when starting the process.
- handle<channel> bootstrap;
-
- // The base address of the vDSO to pass to the process on startup.
- //
- // Should be passed to |zx_process_start| when starting the process.
- uint64 vdso_base;
-
- // The base load address of the ELF file loaded.
- //
- // Most often used by debuggers or other tools that inspect the process.
- uint64 base;
-};
-
-struct CreateWithoutStartingResult {
- // A status code describing the result of the launch.
- zx.status status;
-
- // A string describing the failure.
- //
- // Non-null when |status| is an error.
- string? error_message;
-
- // Data describing the process that was created.
- //
- // Non-null when |status| is ZX_OK.
- ProcessStartData? data;
-};
-
-[Discoverable]
-interface Launcher {
- // Creates and starts the process described by |info|.
- //
- // After processing this message, the |Launcher| is reset to its initial
- // state and is ready to launch another process.
- 1: Launch(LaunchInfo info) -> (LaunchResult result);
-
- // Creates the process described by |info| but does not start it.
- //
- // After processing this message, the |Launcher| is reset to its initial
- // state and is ready to launch another process.
- //
- // The caller is responsible for calling |zx_process_start| using the data
- // in |ProcessStartData| to actually start the process.
- 2: CreateWithoutStarting(LaunchInfo info) -> (CreateWithoutStartingResult result);
-
- // Adds the given arguments to the command-line for the process.
- //
- // Calling this method multiple times concatenattes the arguments.
- 10: AddArgs(vector<string> args);
-
- // Adds the given variables to the environment variables for the process.
- //
- // Calling this method multiple times concatenates the variables.
- 11: AddEnvirons(vector<string> environ);
-
- // Adds the given names to the namespace for the process.
- //
- // The paths in the namespace must be non-overlapping. See
- // <https://fuchsia.googlesource.com/docs/+/master/the-book/namespaces.md> for details.
- //
- // Calling this method multiple times concatenates the names.
- 12: AddNames(vector<NameInfo> names);
-
- // Adds the given handles to the startup handles for the process.
- //
- // Calling this method multiple times concatenates the handles.
- 13: AddHandles(vector<HandleInfo> handles);
-};
diff --git a/fidl/fuchsia.process/meta.json b/fidl/fuchsia.process/meta.json
deleted file mode 100644
index 5f06c40..0000000
--- a/fidl/fuchsia.process/meta.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "deps": [
- "fuchsia.io",
- "fuchsia.ldsvc"
- ],
- "files": [
- "fidl/fuchsia.process/launcher.fidl",
- "fidl/fuchsia.process/resolver.fidl"
- ],
- "name": "fuchsia.process",
- "root": "fidl/fuchsia.process",
- "sources": [
- "fidl/fuchsia.process/launcher.fidl",
- "fidl/fuchsia.process/resolver.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.process/resolver.fidl b/fidl/fuchsia.process/resolver.fidl
deleted file mode 100644
index 780f8f9..0000000
--- a/fidl/fuchsia.process/resolver.fidl
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.process;
-
-using fuchsia.ldsvc;
-using zx;
-
-const uint32 MAX_RESOLVE_NAME = 2048;
-
-[Discoverable, Layout = "Simple"]
-interface Resolver {
- // Resolves the given |name| to an |executable| and an shared library loader.
- //
- // If present, the |executable| is suitable for use as the |executable|
- // property of |LaunchInfo|. If present, the |ldsvc| is suitable for use as
- // the PA_LDSVC_LOADER handle when launching the process.
- //
- // For example, the resolver might locate the given |name| inside a package
- // and return the executable binary from the package as well as a shared
- // library loader scoped to that package.
- 1: Resolve(string:MAX_RESOLVE_NAME name) -> (zx.status status,
- handle<vmo>? executable,
- fuchsia.ldsvc.Loader? ldsvc);
-};
diff --git a/fidl/fuchsia.simplecamera/meta.json b/fidl/fuchsia.simplecamera/meta.json
deleted file mode 100644
index 8370c5b..0000000
--- a/fidl/fuchsia.simplecamera/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [
- "fuchsia.images"
- ],
- "files": [
- "fidl/fuchsia.simplecamera/simple_camera.fidl"
- ],
- "name": "fuchsia.simplecamera",
- "root": "fidl/fuchsia.simplecamera",
- "sources": [
- "fidl/fuchsia.simplecamera/simple_camera.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.simplecamera/simple_camera.fidl b/fidl/fuchsia.simplecamera/simple_camera.fidl
deleted file mode 100644
index f551fde..0000000
--- a/fidl/fuchsia.simplecamera/simple_camera.fidl
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.simplecamera;
-
-using fuchsia.images;
-
-// Simple camera interface. This will be deprecated when
-// CameraManager replaces it.
-[Discoverable]
-interface SimpleCamera {
- // Connect to a camera using the first enumerated format.
- // The device opened will be /dev/class/camera/camera_id
- 1: ConnectToCamera(uint32 camera_id, fuchsia.images.ImagePipe image_pipe);
-};
diff --git a/fidl/fuchsia.sys/component_controller.fidl b/fidl/fuchsia.sys/component_controller.fidl
deleted file mode 100644
index 42e20ec..0000000
--- a/fidl/fuchsia.sys/component_controller.fidl
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-enum TerminationReason {
- // The channel closed without giving a termination reason.
- UNKNOWN = 0;
- // Component ran and exited with a given return_code.
- EXITED = 1;
- // The given URL given to launch was invalid.
- URL_INVALID = 2;
- // The requested package could not be found.
- PACKAGE_NOT_FOUND = 3;
- // An internal error happened during the launch process.
- INTERNAL_ERROR = 4;
- // Process creation failed.
- PROCESS_CREATION_ERROR = 5;
- // A Runner failed to start.
- RUNNER_FAILED = 6;
- // A Runner terminated while attempting to run a component.
- RUNNER_TERMINATED = 7;
- // Attempted to use an unsupported feature.
- UNSUPPORTED = 8;
-};
-
-// An interface for controlling components.
-//
-// Closing this interface implicitly kills the controlled component unless
-// the |Detach| method has been called.
-//
-// If the component exits, this interface will be closed.
-//
-// Typically obtained via |Launcher.CreateComponent|.
-interface ComponentController {
- // Terminates the component.
- //
- // This ComponentController connection is closed when the component has
- // terminated.
- 1: Kill();
-
- // Decouples the lifetime of the component from this controller.
- //
- // After calling |Detach|, the component will not be implicitly killed when
- // this interface is closed.
- 2: Detach();
-
- // DEPRECATED: Use OnTerminated instead of Wait().
- // 3: Wait()
-
- // Event that is triggered when the component is terminated.
- //
- // This event provides the return code of the process and reason for
- // its termination. The return_code is only valid if the termination
- // reason is EXITED. If the termination reason is not EXITED, the
- // return code is guaranteed not to be 0.
- 4: -> OnTerminated(int64 return_code, TerminationReason termination_reason);
-
- // Event that is triggered when the component's output directory is mounted.
- //
- // This event will not be triggered for every component, only those that
- // serve a directory over their PA_DIRECTORY_REQUEST handle.
- 5: -> OnDirectoryReady();
-};
diff --git a/fidl/fuchsia.sys/environment.fidl b/fidl/fuchsia.sys/environment.fidl
deleted file mode 100644
index 2bbf1b3..0000000
--- a/fidl/fuchsia.sys/environment.fidl
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// Maximum length for an environment label.
-const uint32 kLabelMaxLength = 32;
-
-struct EnvironmentOptions {
- // True if this environment should inherit services provided by the
- // parent environment.
- bool inherit_parent_services;
- // True if components in this environment can share a runner provided
- // by the parent environment. If false, a new runner will be started
- // in this environment for components.
- bool allow_parent_runners;
- // True if this environment should be killed first in out of memory
- // situations by setting the ZX_PROP_JOB_KILL_ON_OOM property on this
- // environment's job.
- bool kill_on_oom;
-};
-
-// An interface for managing a set of applications.
-//
-// Applications run inside environments, which provide ambient services and
-// support for their lifecycle.
-[Discoverable] interface Environment {
- // Creates a new environment nested inside this environment.
- //
- // When applications are created inside the nested environment using the
- // environment's |Launcher|, the environment requests the
- // environment services from |host_directory| before passing those services to
- // the newly created application in its |StartupInfo|.
- //
- // The |controller| can be used to control the lifecycle of the created
- // environment. If an |EnvironmentController|'s interface is
- // request, the environment will be killed when the interface is closed.
- //
- // The |label| is an optional name to associate with the environment for
- // diagnostic purposes. The label will be truncated if it is longer
- // than |kLabelMaxLength|.
- //
- // |additional_services|, which may be empty, contains a list of services
- // that the environment provides, which are hosted by
- // |additional_services.host_directory|. If |options.inherit_parent_services|
- // is false, |host_directory| must provide a |Loader| service if it wishes to
- // allow new components to be loaded in the new environment.
- //
- // |options| provides additional options, see |EnvironmentOptions| for
- // details.
- 1: CreateNestedEnvironment(request<Environment> environment,
- request<EnvironmentController>? controller,
- string? label,
- ServiceList? additional_services,
- EnvironmentOptions options);
-
- // Gets the Launcher associated with this environment.
- //
- // Applications created using this application launcher will be given the
- // environment services provided by this environment's |host_directory|.
- 2: GetLauncher(request<Launcher> launcher);
-
- // Gets a superset of services provided by this environment's
- // |host_directory|.
- 3: GetServices(request<ServiceProvider> services);
-
- // Gets a superset of services provided by this environment's
- // |host_directory|.
- 4: GetDirectory(handle<channel> directory_request);
-};
diff --git a/fidl/fuchsia.sys/environment_controller.fidl b/fidl/fuchsia.sys/environment_controller.fidl
deleted file mode 100644
index c886c6b..0000000
--- a/fidl/fuchsia.sys/environment_controller.fidl
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// An interface for controlling an environment.
-//
-// Closing this interface implicitly kills the controlled environment unless
-// the |Detach| method has been called.
-//
-// If the environment is destroyed, this interface will be closed.
-//
-// Typically obtained via |Environment.CreateNestedEnvironment|.
-interface EnvironmentController {
- // Terminates the environment.
- //
- // When an |Environment| is terminated, all applications launched
- // in the environment (and in all transitively nested environments) are also
- // killed.
- 1: Kill() -> ();
-
- // Decouples the lifetime of the environment from this controller.
- //
- // After calling |Detach|, the environment will not be implicitly killed when
- // this interface is closed.
- 2: Detach();
-
- // Event that is triggered when the environment is created.
- 3: -> OnCreated();
-};
diff --git a/fidl/fuchsia.sys/flat_namespace.fidl b/fidl/fuchsia.sys/flat_namespace.fidl
deleted file mode 100644
index fe8bdb9..0000000
--- a/fidl/fuchsia.sys/flat_namespace.fidl
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-struct FlatNamespace {
- // The mount point for each of the directories below.
- //
- // For example, ["/pkg", "/svc"].
- vector<string> paths;
-
- // The directories mounted at each path in the namespace.
- vector<handle<channel>> directories;
-};
diff --git a/fidl/fuchsia.sys/job_provider.fidl b/fidl/fuchsia.sys/job_provider.fidl
deleted file mode 100644
index dbdbe7d..0000000
--- a/fidl/fuchsia.sys/job_provider.fidl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// An interface for providing a job handle. Instances of this interface are
-// created in the context of an already-identified realm, so there is no need
-// to explicitly identify the realm below.
-[Discoverable]
-interface JobProvider {
- // Gets the root job associated with the realm.
- 1: GetJob() -> (handle<job> job);
-};
diff --git a/fidl/fuchsia.sys/launcher.fidl b/fidl/fuchsia.sys/launcher.fidl
deleted file mode 100644
index 0df4415..0000000
--- a/fidl/fuchsia.sys/launcher.fidl
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// An FDIO file descriptor.
-// TODO(abarth): Use the real FDIO declaration once FDIO converts to FIDL2.
-struct FileDescriptor {
- // The FDIO types of the handle (e.g., FA_FDIO_REMOTE).
- int32 type0;
- int32 type1;
- int32 type2;
-
- // The handles for the file descriptor (e.g., a channel).
- handle? handle0;
- handle? handle1;
- handle? handle2;
-};
-
-// Information used to create an instance of a component and obtain
-// services from it.
-struct LaunchInfo {
- // The location from which to retrieve this component.
- //
- // This field will probably be replaced with a stronger notion of identity,
- // such as an unforgeable token. This field is included in this iteration to
- // ease the transition from the previous component interfaces.
- string url;
-
- // The arguments to be provided to the component.
- vector<string>? arguments;
-
- // The file descriptor to use for stdout.
- //
- // If null, the component will use the default stdout for the environment.
- FileDescriptor? out;
-
- // The file descriptor to use for stderr.
- //
- // If null, the component will use the default stderr for the environment.
- FileDescriptor? err;
-
- // The interface request for a Directory that is passed through to the
- // component and arrives in the component as its |directory_request|
- // interface request.
- handle<channel>? directory_request;
-
- // A custom namespace that can be appended to the namespace generated by
- // appmgr and provided to this component.
- // Adding a mount point at standard paths like 'pkg' or 'svc' will be ignored.
- // HACK(alhaad): Adding mount points for deprecated default directories like
- // '/data' will override the default.
- FlatNamespace? flat_namespace;
-
- // A list of services to be added to this component's svc namespace. These
- // services are in addition to those coming from Environment.
- ServiceList? additional_services;
-};
-
-struct ServiceList {
- // A list of services that can be requested from |provider|.
- vector<string> names;
-
- // A service provider to get the services listed in |names| from.
- ServiceProvider? provider;
-
- // A channel to the directory hosting the services in |names|.
- // TODO(CP-124): Support |host_directory| for CreateComponent and deprecate
- // |provider|.
- handle<channel>? host_directory;
-};
-
-// An interface for creating component instances.
-//
-// Typically obtained via |Environment.GetLauncher|.
-[Discoverable]
-interface Launcher {
- // Creates a new instance of the component described by |launch_info|.
- //
- // The component instance is created in the |Environment|
- // associated with this |Launcher|. When creating the component,
- // the environment requests the environment services for this component from
- // its |EnvironmentHost|.
- //
- // The |controller| can be used to control the lifecycle of the created
- // component instance. If an |ComponentController|'s interface is
- // requested, the component instance is killed when the interface is closed.
- 1: CreateComponent(LaunchInfo launch_info,
- request<ComponentController>? controller);
-};
diff --git a/fidl/fuchsia.sys/loader.fidl b/fidl/fuchsia.sys/loader.fidl
deleted file mode 100644
index c8ed6ab..0000000
--- a/fidl/fuchsia.sys/loader.fidl
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// An interface for loading from pacakges.
-[Discoverable]
-interface Loader {
- // LoadUrl a package by url.
- 1: LoadUrl(string url) -> (Package? package);
-};
diff --git a/fidl/fuchsia.sys/meta.json b/fidl/fuchsia.sys/meta.json
deleted file mode 100644
index 35dee7e..0000000
--- a/fidl/fuchsia.sys/meta.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "deps": [
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.sys/component_controller.fidl",
- "fidl/fuchsia.sys/environment.fidl",
- "fidl/fuchsia.sys/environment_controller.fidl",
- "fidl/fuchsia.sys/flat_namespace.fidl",
- "fidl/fuchsia.sys/job_provider.fidl",
- "fidl/fuchsia.sys/launcher.fidl",
- "fidl/fuchsia.sys/loader.fidl",
- "fidl/fuchsia.sys/runner.fidl",
- "fidl/fuchsia.sys/service_provider.fidl"
- ],
- "name": "fuchsia.sys",
- "root": "fidl/fuchsia.sys",
- "sources": [
- "fidl/fuchsia.sys/component_controller.fidl",
- "fidl/fuchsia.sys/environment.fidl",
- "fidl/fuchsia.sys/environment_controller.fidl",
- "fidl/fuchsia.sys/flat_namespace.fidl",
- "fidl/fuchsia.sys/job_provider.fidl",
- "fidl/fuchsia.sys/launcher.fidl",
- "fidl/fuchsia.sys/loader.fidl",
- "fidl/fuchsia.sys/runner.fidl",
- "fidl/fuchsia.sys/service_provider.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.sys/runner.fidl b/fidl/fuchsia.sys/runner.fidl
deleted file mode 100644
index dfa10e4..0000000
--- a/fidl/fuchsia.sys/runner.fidl
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-using fuchsia.mem;
-
-// Information given to components at startup.
-//
-// For ELF binaries, this information is provided in the initialization message
-// given to libc by fuchsia.process.Launcher.
-struct StartupInfo {
- // The launch info for the to start.
- LaunchInfo launch_info;
-
- // The namespace in which to run the component.
- FlatNamespace flat_namespace;
-
- // Key string value string map of the component's program metadata, obtained
- // from its component manifest.
- vector<ProgramMetadata>? program_metadata;
-
- // TODO(abarth): Add more fields to this struct relating to component and
- // environment identity.
-};
-
-// Program information about a component.
-struct ProgramMetadata {
- // Key for program metadata pair. E.g. "binary" for an ELF binary component,
- // or "data" for a flutter/dart component.
- string key;
-
- // Value for program metadata pair. E.g. "bin/app" for a "binary" key, or
- // "data/foo" for a flutter/dart component.
- string value;
-};
-
-// A binary representation of a component.
-//
-// Typically provided to |Runner.StartComponent| when starting a
-// component.
-struct Package {
- // A read-only binary representation of the component. For example, if the
- // component is intended to run in the Dart virtual machine, this data might
- // contain a dartx package.
- fuchsia.mem.Buffer? data;
-
- // A directory containing the contents of the package. For example, if the
- // component is stored in pkgfs, this directory will be the pkgfs directory
- // containing the package.
- handle<channel>? directory;
-
- // Resolved URL of the component. This is the url specified in startup_info
- // after following redirects and resolving relative paths.
- string resolved_url;
-};
-
-// An interface for running components.
-//
-// Typically exposed by components that provide execution environments for
-// particular classes of programs. For example, the Dart virtual machine exposes
-// this interface to run Dart programs.
-[Discoverable]
-interface Runner {
- // Execute the given component.
- //
- // Upon startup, the component is to be given the information in
- // |startup_info|, but the mechanism by which the component receives that
- // information is up to the component runner.
- //
- // The |controller| interface request typically originates from the
- // |Launcher.CreateComponent| message that caused this
- // component to be started.
- 1: StartComponent(Package package,
- StartupInfo startup_info,
- request<ComponentController>? controller);
-};
diff --git a/fidl/fuchsia.sys/service_provider.fidl b/fidl/fuchsia.sys/service_provider.fidl
deleted file mode 100644
index be2ef12..0000000
--- a/fidl/fuchsia.sys/service_provider.fidl
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sys;
-
-// An interface through which a client may request services from a host.
-// Instances of this interface are created within the context of an
-// already-identified client and host pair, so there is no need to explicitly
-// identify the client or host in the methods below.
-//
-// This interface is deprecated. Services should be published as directory
-// entries instead, just like files.
-// TODO(ZX-1358): Point to the FIDL interface for file I/O once RIO is migrated.
-interface ServiceProvider {
- // Asks the host to provide the service identified by |service_name| through
- // the |channel| endpoint supplied by the caller. If the host is not willing
- // or able to provide the requested service, it should close the |channel|.
- 1: ConnectToService(string service_name, handle<channel> channel);
-};
diff --git a/fidl/fuchsia.sysinfo/meta.json b/fidl/fuchsia.sysinfo/meta.json
deleted file mode 100644
index 98fb975..0000000
--- a/fidl/fuchsia.sysinfo/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.sysinfo/sysinfo.fidl"
- ],
- "name": "fuchsia.sysinfo",
- "root": "fidl/fuchsia.sysinfo",
- "sources": [
- "fidl/fuchsia.sysinfo/sysinfo.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.sysinfo/sysinfo.fidl b/fidl/fuchsia.sysinfo/sysinfo.fidl
deleted file mode 100644
index 4cfd790..0000000
--- a/fidl/fuchsia.sysinfo/sysinfo.fidl
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.sysinfo;
-
-using zx;
-
-const uint8 SYSINFO_BOARD_NAME_LEN = 32;
-
-enum InterruptControllerType {
- UNKNOWN = 0;
- APIC = 1;
- GIC_V2 = 2;
- GIC_V3 = 3;
-};
-
-struct InterruptControllerInfo {
- InterruptControllerType type;
-};
-
-[Layout = "Simple"]
-interface Device {
- // Return the root job handle.
- 1: GetRootJob() -> (zx.status status, handle<job>? job);
-
- // Return the root resource (with only ZX_RIGHT_ENUMERATE and ZX_RIGHT_TRANSFER).
- 2: GetRootResource() -> (zx.status status, handle<resource>? resource);
-
- // Return the hypervisor resource (with only ZX_RIGHT_TRANSFER).
- 3: GetHypervisorResource() -> (zx.status status, handle<resource>? resource);
-
- // Return the board name for the platform we are running on.
- 4: GetBoardName() -> (zx.status status, string:SYSINFO_BOARD_NAME_LEN? name);
-
- // Return interrupt controller information.
- 5: GetInterruptControllerInfo() -> (zx.status status, InterruptControllerInfo? info);
-};
diff --git a/fidl/fuchsia.ui.app/meta.json b/fidl/fuchsia.ui.app/meta.json
deleted file mode 100644
index 1b67046..0000000
--- a/fidl/fuchsia.ui.app/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [
- "fuchsia.sys"
- ],
- "files": [
- "fidl/fuchsia.ui.app/view_provider.fidl"
- ],
- "name": "fuchsia.ui.app",
- "root": "fidl/fuchsia.ui.app",
- "sources": [
- "fidl/fuchsia.ui.app/view_provider.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.app/view_provider.fidl b/fidl/fuchsia.ui.app/view_provider.fidl
deleted file mode 100644
index 0e1dbda..0000000
--- a/fidl/fuchsia.ui.app/view_provider.fidl
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.app;
-
-using fuchsia.sys;
-
-// NOTE: This is likely not the ViewProvider you are looking for! This is
-// the new ViewProvider interface that will be deprecating the old one soon.
-// The old ViewProvider is in fuchsia.ui.viewsv1.ViewProvider.
-// TODO(SCN-589): Remove this when old ViewProvider is deleted.
-//
-// ViewProvider is the standard mechanism for two modules to each obtain half
-// of a shared eventpair token. The shared token is a capability allowing the
-// modules to ask Scenic to create a ViewHolder/View pair. The resulting
-// View and ViewHolder are linked together until either one is destroyed.
-//
-// Modules are free to use any other mechanism to agree upon the shared
-// eventpair token, and use this to create the linked ViewHolder/View.
-// ViewProvider is given for the convenience of clients that don't require
-// a more complex implementation.
-[Discoverable]
-interface ViewProvider {
- // Creates a new View under the control of the ViewProvider.
- //
- // |token| is one half of the shared eventpair which will bind the new View
- // to its associated ViewHolder. The ViewProvider will use |token| to
- // create its internal View representation. The caller is expected to use
- // its half to create corresponding ViewHolder object.
- //
- // |incoming_services| allows clients to request services from the
- // ViewProvider implementation. |outgoing_services| allows clients to
- // provide services of their own to the ViewProvider implementation.
- //
- // Clients can embed a ViewHolder (and by proxy the paired View) into their
- // scene graph by using |Node.AddChild()|. The ViewHolder cannot itself
- // have any children. A ViewProvider implementation can nest scene objects
- // within its View by using |View.AddChild()|. The View itself
- // cannot be a child of anything.
- //
- // Modules can use these mechanisms to establish a distributed,
- // inter-process scene graph.
- 1: CreateView(handle<eventpair> token,
- request<fuchsia.sys.ServiceProvider>? incoming_services,
- fuchsia.sys.ServiceProvider? outgoing_services);
-};
diff --git a/fidl/fuchsia.ui.gfx/commands.fidl b/fidl/fuchsia.ui.gfx/commands.fidl
deleted file mode 100644
index a780347..0000000
--- a/fidl/fuchsia.ui.gfx/commands.fidl
+++ /dev/null
@@ -1,724 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-using fuchsia.mem;
-
-// Commands that are used to modify the state of a |Session|.
-// TODO(SCN-237): reorder Command definitions to match the order in this union.
-union Command {
- CreateResourceCmd create_resource;
- ReleaseResourceCmd release_resource;
- ExportResourceCmd export_resource;
- ImportResourceCmd import_resource;
-
- // Tagging commands.
- SetTagCmd set_tag;
-
- // Grouping commands.
- DetachCmd detach;
-
- // Spatial commands.
- SetTranslationCmd set_translation;
- SetScaleCmd set_scale;
- SetRotationCmd set_rotation;
- SetAnchorCmd set_anchor;
- SetSizeCmd set_size;
- SetOpacityCmd set_opacity;
-
- SendSizeChangeHintCmdHACK send_size_change_hint_hack;
-
- // Node-specific commands.
- AddChildCmd add_child; // TODO: Should we require a DetachCmd before
- // re-parenting?
- AddPartCmd add_part;
- DetachChildrenCmd detach_children;
- SetShapeCmd set_shape;
- SetMaterialCmd set_material;
- SetClipCmd set_clip;
- SetHitTestBehaviorCmd set_hit_test_behavior;
- SetViewPropertiesCmd set_view_properties;
- TakeSnapshotCmdHACK take_snapshot_cmd;
-
- // Camera and lighting commands.
- SetCameraCmd set_camera;
- SetCameraTransformCmd set_camera_transform;
- SetCameraProjectionCmd set_camera_projection;
- SetStereoCameraProjectionCmd set_stereo_camera_projection;
- SetCameraPoseBufferCmd set_camera_pose_buffer;
- SetLightColorCmd set_light_color;
- SetLightDirectionCmd set_light_direction;
- AddLightCmd add_light;
- DetachLightCmd detach_light;
- DetachLightsCmd detach_lights;
-
- SetTextureCmd set_texture;
- SetColorCmd set_color;
-
- // Mesh commands.
- BindMeshBuffersCmd bind_mesh_buffers;
-
- // Layer and renderer commands.
- AddLayerCmd add_layer;
- RemoveLayerCmd remove_layer;
- RemoveAllLayersCmd remove_all_layers;
- SetLayerStackCmd set_layer_stack;
- SetRendererCmd set_renderer;
- SetRendererParamCmd set_renderer_param;
-
- // Events.
- SetEventMaskCmd set_event_mask;
-
- // Diagnostic commands.
- SetLabelCmd set_label;
-
- // Debugging commands.
- SetDisableClippingCmd set_disable_clipping;
-
- // TODO(SCN-1026): Remove this.
- SetImportFocusCmd set_import_focus;
-};
-
-// Instructs the compositor to create the specified |Resource|, and to register
-// it in a table so that it can be referenced by subsequent commands.
-struct CreateResourceCmd {
- // An ID that is currently not used within the session.
- uint32 id;
- ResourceArgs resource;
-};
-
-// Releases the client's reference to the resource; it is then illegal to use
-// the ID in subsequent Commands. Other references to the resource may exist,
-// so releasing the resource does not result in its immediate destruction; it is
-// only destroyed once the last reference is released. For example, the
-// resource may be required to render an in-progress frame, or it may be
-// referred to by another resource). However, the ID will be immediately
-// unregistered, and may be reused to create a new resource.
-struct ReleaseResourceCmd {
- // ID of the resource to be dereferenced.
- uint32 id;
-};
-
-// Create an external reference to the specified resource, which can then be
-// imported into another Session by passing a handle to |token|'s peer to
-// ImportResourceCmd; see that comment for more details.
-//
-// The importing client is typically in a different process than the exporter.
-// No specific mechanism is provided for transferring a token from an exporter
-// to an importer; collaborators may choose any out-of-band API they wish to do
-// so.
-struct ExportResourceCmd {
- uint32 id;
- handle<eventpair> token;
-};
-
-// Import a resource that was exported via ExportResourceCmd(). |token| is
-// a handle to the eventpair peer that was used to export the resource, and
-// |spec| describes the type of the imported resource, and the commands which
-// can legally be applied to it. Afterward, |id| can be used to refer to the
-// resource in an Command, similarly (but not identically: see below) to a
-// resource that was created in the session. For example, you can add children
-// to an imported EntityNode via AddChildCmd.
-//
-// However, note that the importer does not gain full access to the imported
-// resource, but rather to an attenuated subset of its capabilities. For
-// example, you cannot use a DetachCmd to detach an imported EntityNode from
-// its parent.
-//
-// Unlike ExportResourceCmd, there is no configurable timeout. There is an
-// expectation that the exported resource will become available in a short
-// amount of time. TODO: this needs elaboration... e.g. we might notify via the
-// SessionListener when we know that the link will never be made (e.g. if the
-// peer of the import token is destroyed).
-//
-// TODO: describe how the imported resource behaves if the exported resource
-// isn't yet available, or becomes unavailable (e.g. an imported Material might
-// act as a plain white texture).
-struct ImportResourceCmd {
- uint32 id;
- handle<eventpair> token;
- ImportSpec spec;
-};
-
-// Maximum length for a resource label.
-const uint32 kLabelMaxLength = 32;
-
-// Sets/clears a label to help developers identify the purpose of the resource
-// when using diagnostic tools.
-//
-// The label serves no functional purpose in the scene graph. It exists only
-// to help developers understand its structure. The scene manager may truncate
-// or discard labels at will.
-//
-// Constraints:
-// - The label's maximum length is |kLabelMaxLength| characters.
-// - Setting the label to an empty string clears it.
-struct SetLabelCmd {
- uint32 id;
- string label;
-};
-
-// Add a node as a child to another node.
-//
-// Constraints:
-// - |id| refs a Node with the has_children characteristic.
-// - |child_id| refs any Node.
-//
-// Discussion:
-// The child node is first removed from its existing parent, as if DetachCmd
-// was applied first.
-struct AddChildCmd {
- uint32 node_id;
- uint32 child_id;
-};
-
-// Add a node as a part of another node. The implications of being a part
-// rather than a child differ based on the type of the part. However, one
-// implication is constant: removing all of a node's children (e.g. via
-// DetachChildrenCmd) does not affect its parts. This is similar to the
-// "shadow DOM" in a web browser: the controls of a <video> element are
-// implemented as using the shadow DOM, and do no show up amongst the children
-// of that element.
-//
-// Constraints:
-// - |id| refs a Node with the has_parts characteristic.
-// - |part_id| refs any Node.
-//
-// Discussion:
-// The part node is first removed from its existing parent, as if DetachCmd
-// was applied first.
-struct AddPartCmd {
- uint32 node_id;
- uint32 part_id;
-};
-
-interface SnapshotCallbackHACK {
- 1: OnData(fuchsia.mem.Buffer data);
-};
-
-struct TakeSnapshotCmdHACK {
- uint32 node_id;
- SnapshotCallbackHACK callback;
-};
-
-// Detaches a parentable object from its parent (e.g. a node from a parent node,
-// or a layer from a layer stack). It is illegal to apply this command to a
-// non-parentable object. No-op if the target object currently has no parent.
-//
-// Constraints:
-// - |id| refs a parentable object
-//
-// Discussion:
-// For nodes, this command will detach a node from its parent, regardless of
-// whether it is a part or a child of its parent.
-struct DetachCmd {
- uint32 id;
-};
-
-// Detaches all of a node's children (but not its parts).
-struct DetachChildrenCmd {
- uint32 node_id;
-};
-
-// Sets/clears a node's tag value.
-//
-// A session can apply a tag value to any node to which it has access, including
-// imported nodes. These tags are private to the session and cannot be read
-// or modified by other sessions. When multiple sessions import the same node,
-// each session will only observe its own tag values.
-//
-// Hit test results for a session only include nodes which the session has
-// tagged with a non-zero value. Therefore a session can use tag values to
-// associate nodes with their functional purpose when picked.
-//
-// Constraints:
-// - |node_id| refs a |Node|.
-// - |tag_value| is the tag value to assign, or 0 to remove the tag.
-struct SetTagCmd {
- uint32 node_id;
- uint32 tag_value;
-};
-
-// Sets a Resource's (typically a Node's) translation.
-//
-// Constraints:
-// - |id| refs a Resource with the has_transform characteristic.
-struct SetTranslationCmd {
- uint32 id;
- Vector3Value value;
-};
-
-// Sets a Resource's (typically a Node's) scale.
-//
-// Constraints:
-// - |id| refs a Resource with the has_transform characteristic.
-struct SetScaleCmd {
- uint32 id;
- Vector3Value value;
-};
-
-// Sets a Resource's (typically a Node's) rotation.
-//
-// Constraints:
-// - |id| refs a Resource with the has_transform characteristic.
-struct SetRotationCmd {
- uint32 id;
- QuaternionValue value;
-};
-
-// Sets a Resource's (typically a Node's) anchor point.
-//
-// Constraints:
-// - |id| refs a Resource with the has_transform characteristic.
-struct SetAnchorCmd {
- uint32 id;
- Vector3Value value;
-};
-
-// Sets an object's size.
-//
-// Constraints:
-// - |id| refs a resizeable object.
-// - some objects that support this command may have additional constraints
-// (e.g. in some cases |depth| must be zero).
-struct SetSizeCmd {
- uint32 id;
- Vector2Value value;
-};
-
-// Sends a hint about a pending size change to the given node and all nodes
-// below. This is generally sent before an animation.
-//
-// |width_change_factor| and |height_change_factor| is how much bigger or smaller
-// the item is expected to be in the near future. This one number encapsulate
-// both changes in scale, as well as changes to layout width and height.
-struct SendSizeChangeHintCmdHACK {
- uint32 node_id;
- float32 width_change_factor;
- float32 height_change_factor;
-};
-
-// Sets a node's opacity.
-//
-// Constraints:
-// - |node_id| refs a |Node| with the has_opacity characteristic.
-// - |opacity| is in the range [0, 1].
-struct SetOpacityCmd {
- uint32 node_id;
- float32 opacity;
-};
-
-// Sets/clears a node's shape.
-//
-// Constraints:
-// - |node_id| refs a |Node| with the has_shape characteristic.
-// - |shape_id| refs a |Shape|, or nothing.
-// - if this command causes the target to have both a |Shape| and a |Material|,
-// then these must be compatible with each other (see README.md regarding
-// "Shape/Material Compatibility").
-// TODO: add "Shape/Material Compatibility section"
-//
-// Discussion:
-// In order to be painted, a node requires both a |Shape| and a |Material|.
-// Without a material, a node can still participate in hit-testing and clipping.
-// Without a shape, a node cannot do any of the above.
-struct SetShapeCmd {
- uint32 node_id;
- uint32 shape_id;
-};
-
-// Sets/clears a node's material.
-//
-// Constraints:
-// - |node_id| refs a |Node| with the has_material characteristic.
-// - |material_id| refs a |Material|, or nothing.
-// - if this command causes the target to have both a |Shape| and a |Material|,
-// then these must be compatible with each other (see README.md regarding
-// "Shape/Material Compatibility").
-// TODO: add "Shape/Material Compatibility section"
-//
-// Discussion:
-// In order to be painted, a node requires both a |Shape| and a |Material|.
-// Without a material, a node can still participate in hit-testing and clipping.
-// Without a shape, a node cannot do any of the above.
-struct SetMaterialCmd {
- uint32 node_id;
- uint32 material_id;
-};
-
-// Sets/clears a node's clip.
-//
-// Constraints:
-// - |node_id| refs a |Node| with the has_clip characteristic.
-// - |clip_id| a |Node| with the is_clip characteristic, or nothing. If the
-// referenced node is not rooted, then it will have no effect (since its
-// full world-transform cannot be determined).
-// - |clip_to_self| If false, children are only clipped to the region specified
-// by |clip_id|. If true, children are additionally clipped to the node's
-// shape (as determined by its ShapeNode parts).
-//
-// Discussion:
-// If a node has a clip, it will be applied to both the parts and the children
-// of the node. Under some circumstances (TBD), a clip will not be applicable
-// to a node; in such cases it will be as though no clip has been specified for
-// the node.
-// TODO: elaborate on the circumstances under which a clip is inapplicable.
-// For example, consider a 3D space that looks through a portal into a 2D space
-// that uses a clip for a circular reveal. It would not be meaningful to clip
-// objects on the outside (i.e. in the 3D space).
-struct SetClipCmd {
- uint32 node_id;
- uint32 clip_id;
- bool clip_to_self;
-};
-
-// Sets a node's hit test behavior.
-//
-// Discussion:
-// By default, hit testing is performed on the node's content, its parts,
-// and its children.
-struct SetHitTestBehaviorCmd {
- uint32 node_id;
- HitTestBehavior hit_test_behavior;
-};
-
-// Sets the properties for a ViewHolder's attached View.
-//
-// Constraints:
-// - |view_holder_id| refs a |ViewHolder|.
-struct SetViewPropertiesCmd {
- uint32 view_holder_id;
- ViewProperties properties;
-};
-
-// Sets a renderer's camera.
-//
-// Constraints:
-// - |renderer_id| refs a |Renderer|.
-// - |camera_id| refs a |Camera|, or stops rendering by passing zero.
-// - |matrix| is a value or variable of type kMatrix4x4.
-struct SetCameraCmd {
- uint32 renderer_id;
- uint32 camera_id;
-};
-
-// Sets a camera's view matrix.
-// This operation can be applied to both Cameras and StereoCameras.
-//
-// Constraints:
-// - |camera_id| refs a |Camera|.
-// - |eye_position| is the position of the eye.
-// - |eye_look_at| is the point is the scene the that eye is pointed at.
-// - |eye_up| defines the camera's "up" vector.
-struct SetCameraTransformCmd {
- uint32 camera_id;
- Vector3Value eye_position;
- Vector3Value eye_look_at;
- Vector3Value eye_up;
-};
-
-// Sets a camera's projection matrix.
-// This operation cannot be applied to a StereoCamera.
-//
-// Constraints:
-// - |camera_id| refs a |Camera| that is not a |StereoCamera|.
-// - |fovy| is the Y-axis field of view, in radians.
-//
-// NOTE: A default orthographic projection is specified by setting |fovy| to
-// zero. In this case, the camera transform is ignored.
-struct SetCameraProjectionCmd {
- uint32 camera_id;
- FloatValue fovy; // Y-axis field of view, in radians.
-};
-
-// Sets a StereoCamera's projection matrices.
-// This operation can only be applied to a StereoCamera.
-//
-// Constraints:
-// - |camera_id| refs a |StereoCamera|.
-// - |left_projection| is the projection matrix for the left eye.
-// - |right_projection| is the projection matrix for the right eye.
-//
-// These projection matrices may also contain a transform in camera space for
-// their eye if needed.
-struct SetStereoCameraProjectionCmd {
- uint32 camera_id;
- Matrix4Value left_projection;
- Matrix4Value right_projection;
-};
-
-// Sets the "pose buffer" for the camera identified by |camera_id|.
-// This operation can be applied to both Cameras and StereoCameras.
-//
-// This will override any position and rotation set for the camera and will
-// make it take its position and rotation from the pose buffer each frame
-// based on the presentation time for that frame.
-//
-// A pose buffer represents a ring buffer of poses for a fixed number of time
-// points in the future. Each entry in the buffer identified by |buffer_id| is
-// a quaternion and a position layed out as follows:
-//
-// struct Pose {
-// // Quaternion
-// float32 a;
-// float32 b;
-// float32 c;
-// float32 d;
-//
-// // Position
-// float32 x;
-// float32 y;
-// float32 z;
-//
-// // Reserved/Padding
-// byte[4] reserved;
-// }
-//
-// The buffer can be thought of as a packed array of |num_entries| Pose structs
-// and is required to be at least num_entries * sizeof(Pose) bytes.
-//
-// The quaternions and positions are specified in the space of the camera's
-// parent node.
-//
-// |base_time| is a base time point expressed in nanoseconds in the
-// |CLOCK_MONOTONIC| timebase and |time_interval| is the time in nanoseconds
-// between entries in the buffer. |base_time| must be in the past.
-//
-// For a given point in time |t| expressed in nanoseconds in the
-// |CLOCK_MONOTONIC| timebase the index of the corresponding pose in
-// the pose buffer can be computed as follows:
-//
-// index(t) = ((t - base_time) / time_interval) % num_entries
-//
-// poses[index(t)] is valid for t over the time interval (t - time_interval, t]
-// and should be expected to updated continuously without synchronization
-// for the duration of that interval. If a single pose value is needed for
-// multiple non-atomic operations a value should be latched and stored outside
-// the pose buffer.
-//
-// Because the poses are not protected by any synchronization primitives it is
-// possible that when a pose is latched it will be only partially updated, and
-// the pose being read will contain some components from the pose before it is
-// updated and some components from the updated pose. The safety of using these
-// "torn" poses relies on two things:
-//
-// 1) Sequential poses written to poses[index(t)] are very similar to each
-// other numerically, so that if some components are taken from the first and
-// some are taken from another the result is numerically similar to both
-//
-// 2) The space of positions and quaternions is locally flat at the scale of
-// changes between sequential updates, which guarantees that two poses which
-// are numerically similar also represent semantically similar poses (i.e.
-// there are no discontinuities which will cause a small numerical change in
-// the position or quaterninon to cause a large change in the encoded pose)
-// For positions this is guaranteed because Scenic uses a Euclidean 3-space
-// which is globally flat and for quaternions this is guaranteed because
-// quaternions encode rotation as points on a unit 4-sphere, and spheres are
-// locally flat. For more details on the encoding of rotations in quaterions
-// see https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
-//
-// This commanderation is intended for late latching camera pose to support
-// low-latency motion-tracked rendering.
-struct SetCameraPoseBufferCmd {
- uint32 camera_id;
- uint32 buffer_id;
- uint32 num_entries;
- int64 base_time;
- uint64 time_interval;
-};
-
-// Sets the color of the Light identified by |light_id|.
-struct SetLightColorCmd {
- uint32 light_id;
- ColorRgbValue color;
-};
-
-// Sets the direction of the DirectionalLight identified by |light_id|.
-struct SetLightDirectionCmd {
- uint32 light_id;
- Vector3Value direction;
-};
-
-// Adds the light specified by |light_id| specified by |light_id| to the scene
-// identified by |scene_id|.
-struct AddLightCmd {
- uint32 scene_id;
- uint32 light_id;
-};
-
-// Detach the light specified by |light_id| from the scene that it is attached
-// to, if any.
-struct DetachLightCmd {
- uint32 light_id;
-};
-
-// Detach all lights from the scene specified by |scene_id|.
-struct DetachLightsCmd {
- uint32 scene_id;
-};
-
-// Sets/clears a material's texture.
-//
-// Constraints:
-// - |material_id| refs a |Material|.
-// - |texture_id| refs a |Image|, |ImagePipe|, or nothing.
-//
-// If no texture is provided (i.e. |texture_id| is zero), a solid color is used.
-// If a texture is provided, then the value sampled from the texture is
-// multiplied by the color.
-struct SetTextureCmd {
- uint32 material_id;
- uint32 texture_id; // Refers to an Image resource. May be zero (no texture).
-};
-
-// Sets a material's color.
-//
-// Constraints:
-// - |material_id| refs a |Material|.
-//
-// If a texture is set on the material, then the value sampled from the texture
-// is multiplied by the color.
-struct SetColorCmd {
- uint32 material_id;
- ColorRgbaValue color;
-};
-
-// Set a mesh's indices and vertices.
-//
-// |mesh_id| refs the Mesh to be updated.
-// |index_buffer_id| refs a Buffer that contains the mesh indices.
-// |index_format| defines how the index buffer data is to be interpreted.
-// |index_offset| number of bytes from the start of the index Buffer.
-// |index_count| number of indices.
-// |vertex_buffer_id| refs a Buffer that contains the mesh vertices.
-// |vertex_format| defines how the vertex buffer data is to be interpreted.
-// |vertex_offset| number of bytes from the start of the vertex Buffer.
-// |vertex_count| number of vertices.
-// |bounding_box| must contain all vertices within the specified range.
-//
-// The MeshVertexFormat defines which per-vertex attributes are provided by the
-// mesh, and the size of each attribute (and therefore the size of each vertex).
-// The attributes are ordered within the vertex in the same order that they
-// appear within the MeshVertexFormat struct. For example, if the values are
-// kVector3, kNone and kVector2, then:
-// - each vertex has a position and UV-coordinates, but no surface normal.
-// - the 3D position occupies bytes 0-11 (3 dimensions * 4 bytes per float32).
-// - the UV coords occupy bytes 12-19, since no surface normal is provided.
-enum MeshIndexFormat {
- // TODO(SCN-275): only kUint32 is currently supported.
- kUint16 = 1;
- kUint32 = 2;
-};
-
-struct MeshVertexFormat {
- // kVector2 or kVector3.
- ValueType position_type;
- // kVector2 or kVector3 (must match position_type), or kNone.
- ValueType normal_type;
- // kVector2 or kNone.
- ValueType tex_coord_type;
-};
-
-struct BindMeshBuffersCmd {
- uint32 mesh_id;
- uint32 index_buffer_id;
- MeshIndexFormat index_format;
- uint64 index_offset;
- uint32 index_count;
- uint32 vertex_buffer_id;
- MeshVertexFormat vertex_format;
- uint64 vertex_offset;
- uint32 vertex_count;
- BoundingBox bounding_box;
-};
-
-// Add a layer to a layer stack.
-// Constraints:
-// - |layer_stack_id| refs a |LayerStack|.
-// - |layer_id| refs a |Layer|.
-// - The layer must not already belong to a different stack; it must first be
-// detached.
-struct AddLayerCmd {
- uint32 layer_stack_id;
- uint32 layer_id;
-};
-
-// Remove a layer from a layer stack.
-// Constraints:
-// - |layer_stack_id| refs a |LayerStack|.
-// - |layer_id| refs a |Layer|.
-// - The layer must belong to this stack.
-struct RemoveLayerCmd {
- uint32 layer_stack_id;
- uint32 layer_id;
-};
-
-// Remove all layers from a layer stack.
-// Constraints
-// - |layer_stack_id| refs a |LayerStack|.
-struct RemoveAllLayersCmd {
- uint32 layer_stack_id;
-};
-
-// Set a compositor's layer stack, replacing the current stack (if any).
-// Constraints:
-// - |compositor_id| refs a |DisplayCompositor| or |ImagePipeCompositor|.
-// - |layer_stack_id| refs a |LayerStack|.
-struct SetLayerStackCmd {
- uint32 compositor_id;
- uint32 layer_stack_id;
-};
-
-// Set a layer's renderer, replacing the current renderer (if any).
-// Constraints:
-// - |layer_id| refs a |Layer|.
-// - |renderer_id| refs a |Renderer|.
-struct SetRendererCmd {
- uint32 layer_id;
- uint32 renderer_id;
-};
-
-// Sets a parameter that affects how a renderer renders a scene.
-//
-// |renderer_id| refs the Renderer that is being modified.
-// |param| describes the parameter that should be set, and to what.
-struct SetRendererParamCmd {
- uint32 renderer_id;
- RendererParam param;
-};
-
-// Sets which events a resource should deliver to the session listener.
-// This command replaces any prior event mask for the resource.
-//
-// The initial event mask for a resource is zero, meaning no events are
-// reported.
-//
-// Constraints:
-// - |resource_id| is a valid resource id
-// - |event_mask| is zero or a combination of |k*EventMask| bits OR'ed together.
-struct SetEventMaskCmd {
- uint32 id;
- uint32 event_mask;
-};
-
-// Set whether clipping should be disabled for the specified renderer. For a
-// newly-created renderer, clipping will NOT be disabled (i.e. it will be
-// enabled).
-//
-// NOTE: this disables visual clipping only; objects are still clipped for the
-// purposes of hit-testing.
-//
-// |renderer_id| refs the target renderer.
-// |disable_clipping| specifies whether the clipping should be disabled.
-struct SetDisableClippingCmd {
- uint32 renderer_id;
- bool disable_clipping;
-};
-
-// TODO(SCN-1026): Remove this.
-struct SetImportFocusCmd {
- uint32 id;
- bool focusable;
-};
diff --git a/fidl/fuchsia.ui.gfx/display_info.fidl b/fidl/fuchsia.ui.gfx/display_info.fidl
deleted file mode 100644
index 1fb1cc2..0000000
--- a/fidl/fuchsia.ui.gfx/display_info.fidl
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// Provides information about a display.
-struct DisplayInfo {
- // The size of the display, in physical pixels.
- uint32 width_in_px;
- uint32 height_in_px;
-};
diff --git a/fidl/fuchsia.ui.gfx/events.fidl b/fidl/fuchsia.ui.gfx/events.fidl
deleted file mode 100644
index 98a2495..0000000
--- a/fidl/fuchsia.ui.gfx/events.fidl
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// Reports metrics information.
-// This event type is only reported for node resources.
-const uint32 kMetricsEventMask = 1;
-const uint32 kSizeChangeHintEventMask = 2;
-
-// These are all of the types of events which can be reported by a |Session|.
-// Use |SetEventMaskCmd| to enable event delivery for a resource.
-union Event {
- // Events which are controlled by a mask.
- MetricsEvent metrics;
-
- SizeChangeHintEvent size_change_hint;
-
- // Events which are always delivered, regardless of mask.
- ImportUnboundEvent import_unbound;
- ViewConnectedEvent view_connected;
- ViewDisconnectedEvent view_disconnected;
- ViewHolderDisconnectedEvent view_holder_disconnected;
- ViewAttachedToSceneEvent view_attached_to_scene;
- ViewDetachedFromSceneEvent view_detached_from_scene;
- ViewPropertiesChangedEvent view_properties_changed;
- ViewStateChangedEvent view_state_changed;
-};
-
-// Provides rendering target metrics information about the specified node.
-//
-// This event is delivered when the following conditions are true:
-// - The node is a descendant of a |Scene|.
-// - The node has |kMetricsEventMask| set to an enabled state.
-// - The node's metrics have changed since they were last delivered, or since
-// |kMetricsEventMask| transitioned from a disabled state to an enabled state.
-//
-// Subscribe to this event to receive information about the scale factors you
-// should apply when generating textures for your nodes.
-struct MetricsEvent {
- uint32 node_id;
- Metrics metrics;
-};
-
-// Delivered in response to a size change hint from a parent node
-// (SendSizeChangeHintCmd).
-//
-// This event is delivered when the following conditions are true:
-// - The node has |kSizeChangeEventMask| set to an enabled state.
-// - A parent node has sent a SendSizeChangeHintCmd.
-//
-// Subscribe to this event to receive information about how large textures you
-// will need in the near future for your nodes. The canonical use case is to
-// pre-allocate memory to avoid repeated re-allocations.
-struct SizeChangeHintEvent {
- uint32 node_id;
- float32 width_change_factor;
- float32 height_change_factor;
-};
-
-// Delivered when the imported resource with the given ID is no longer bound to
-// its host resource, or if the imported resource can not be bound because
-// the host resource is not available.
-struct ImportUnboundEvent {
- uint32 resource_id;
-};
-
-// Delivered to a ViewHolder's Session when its peer View is connected.
-struct ViewConnectedEvent {
- uint32 view_holder_id;
-};
-
-// Delivered to a ViewHolder's Session when its peer View is disconnected or
-// destroyed.
-//
-// If the View is destroyed before the connection is established, then this
-// event will be delivered immediately when the ViewHolder attempts to connect.
-struct ViewDisconnectedEvent {
- uint32 view_holder_id;
-};
-
-// Delivered to a View's Session when its peer ViewHolder is disconnected or
-// destroyed.
-//
-// If the ViewHolder is destroyed before the connection is established, then
-// this event will be delivered immediately when the View attempts to connect.
-struct ViewHolderDisconnectedEvent {
- uint32 view_id;
-};
-
-// Delivered to a View's Session when the parent ViewHolder for the given View
-// becomes a part of a Scene.
-//
-// A ViewHolder is considered to be part of a Scene if there is an unbroken
-// chain of parent-child relationships between the Scene node and the
-// ViewHolder node.
-struct ViewAttachedToSceneEvent {
- uint32 view_id;
- ViewProperties properties;
-};
-
-// Delivered to a View's Session when the parent ViewHolder for the given View
-// is no longer part of a scene.
-//
-// This can happen if the ViewHolder is detached directly from the scene, or
-// if one of its parent nodes is.
-//
-// A ViewHolder is considered to be part of a Scene if there is an unbroken
-// chain of parent-child relationships between the Scene node and the
-// ViewHolder node.
-struct ViewDetachedFromSceneEvent {
- uint32 view_id;
-};
-
-// Delivered when the parent ViewHolder for the given View makes a change to
-// the View's properties.
-struct ViewPropertiesChangedEvent {
- uint32 view_id;
- ViewProperties properties;
-};
-
-// Delivered to a ViewHolder's Session when its peer View's state has changed.
-struct ViewStateChangedEvent {
- uint32 view_holder_id;
- ViewState state;
-};
diff --git a/fidl/fuchsia.ui.gfx/hit.fidl b/fidl/fuchsia.ui.gfx/hit.fidl
deleted file mode 100644
index d96a44c..0000000
--- a/fidl/fuchsia.ui.gfx/hit.fidl
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// Describes where a hit occurred within the content of a node tagged
-// by this session.
-//
-// To compute the point of intersection within the node's local coordinate
-// system, perform the following calculation using the ray which was
-// originally passed to |Session.HitTest()|.
-//
-// hit_point = ray.origin + (hit.distance * ray.direction)
-// local_point = hit.inverse_transform * hit_point
-struct Hit {
- // The node's tag value.
- uint32 tag_value;
-
- // The origin of the ray that was used for the hit test, in the hit
- // node's coordinate system.
- vec4 ray_origin;
-
- // The direction of the ray that was used for the hit test, in the hit
- // node's coordinate system.
- vec4 ray_direction;
-
- // The inverse transformation matrix which maps the coordinate system of
- // the node at which the hit test was initiated into the local coordinate
- // system of the node which was hit.
- mat4 inverse_transform;
-
- // The distance from the ray's origin to the closest point of intersection
- // in multiples of the ray's direction vector.
- float32 distance;
-};
diff --git a/fidl/fuchsia.ui.gfx/meta.json b/fidl/fuchsia.ui.gfx/meta.json
deleted file mode 100644
index cc5b23e..0000000
--- a/fidl/fuchsia.ui.gfx/meta.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "deps": [
- "fuchsia.images",
- "fuchsia.math",
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.ui.gfx/commands.fidl",
- "fidl/fuchsia.ui.gfx/display_info.fidl",
- "fidl/fuchsia.ui.gfx/events.fidl",
- "fidl/fuchsia.ui.gfx/hit.fidl",
- "fidl/fuchsia.ui.gfx/nodes.fidl",
- "fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl",
- "fidl/fuchsia.ui.gfx/renderer.fidl",
- "fidl/fuchsia.ui.gfx/resources.fidl",
- "fidl/fuchsia.ui.gfx/shapes.fidl",
- "fidl/fuchsia.ui.gfx/types.fidl"
- ],
- "name": "fuchsia.ui.gfx",
- "root": "fidl/fuchsia.ui.gfx",
- "sources": [
- "fidl/fuchsia.ui.gfx/commands.fidl",
- "fidl/fuchsia.ui.gfx/display_info.fidl",
- "fidl/fuchsia.ui.gfx/events.fidl",
- "fidl/fuchsia.ui.gfx/hit.fidl",
- "fidl/fuchsia.ui.gfx/nodes.fidl",
- "fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl",
- "fidl/fuchsia.ui.gfx/renderer.fidl",
- "fidl/fuchsia.ui.gfx/resources.fidl",
- "fidl/fuchsia.ui.gfx/shapes.fidl",
- "fidl/fuchsia.ui.gfx/types.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.gfx/nodes.fidl b/fidl/fuchsia.ui.gfx/nodes.fidl
deleted file mode 100644
index 33e46c7..0000000
--- a/fidl/fuchsia.ui.gfx/nodes.fidl
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// These are the types of nodes that can be created within a Mozart |Session|.
-//
-// All nodes have an associated transform, which distinguishes them from mere
-// resources. Nodes may also have one or more node Characteristics:
-//
-// These are characteristics that each type of |Node| either has or doesn't.
-// These constrain operations that reference nodes; violations will cause the
-// |Session| connection to be closed. For example, |NodeAddChildOp| must target
-// a node with the "has_children" characteristic. These characteristics are not
-// explicitly reflected in the Session API; instead, they must be enforced by
-// implementations of the API.
-// - has_children: The node can contain other nodes as children.
-// - has_parent: The node can be a child of another node. If this is false,
-// the node can only be a direct descendant of its containing scene.
-// - has_parts: The node can contain other nodes as parts. All parts must be
-// from the same session as their parent.
-// - has_clip: The node can contain a clip node as a child.
-// - is_clip: The node can clip other nodes.
-// - has_shape: The node can contain ShapeNodes as children.
-// - has_material: The node can have a Material resource applied to it.
-
-// Characteristics:
-// - has_parent
-// - has_shape
-// - has_material
-struct ShapeNodeArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 unused = 0;
-};
-
-// Characteristics:
-// - has_parent
-// - is_clip
-// - has_parts
-struct ClipNodeArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 unused = 0;
-};
-
-// Characteristics:
-// - has_transform
-// - has_parent
-// - has_children
-// - has_parts
-// - has_opacity
-struct OpacityNodeArgs {
- uint32 unused = 0;
-};
-
-// Characteristics:
-// - has_transform
-// - has_children
-// - has_parent
-// - has_parts
-// - has_clip
-struct EntityNodeArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 unused = 0;
-};
diff --git a/fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl b/fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl
deleted file mode 100644
index 8fcadc1..0000000
--- a/fidl/fuchsia.ui.gfx/pose_buffer_provider.fidl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-[Discoverable]
-// A minimal fidl interface to allow sourcing the contents of a PoseBuffer from another service.
-interface PoseBufferProvider {
- // Sets the PoseBuffer and the parameters PoseBufferProvider will use to fill that PoseBuffer.
- // Setting this when it is already set will replace the previously set parameters with the new
- // parameters, which will release the provider's reference to the buffer.
- 1: SetPoseBuffer(handle<vmo> buffer, uint32 num_entries, int64 base_time, uint64 time_interval);
-};
diff --git a/fidl/fuchsia.ui.gfx/renderer.fidl b/fidl/fuchsia.ui.gfx/renderer.fidl
deleted file mode 100644
index 6bcbd22..0000000
--- a/fidl/fuchsia.ui.gfx/renderer.fidl
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// These are all of the types of parameters that can be set to configure a
-// |Renderer|.
-union RendererParam {
- ShadowTechnique shadow_technique;
- RenderFrequency render_frequency;
-};
-
-// Represents the shadow algorithm that the |Renderer| should use when lighting
-// the scene.
-enum ShadowTechnique {
- // No shadows.
- UNSHADOWED = 0;
- // Default. Screen-space, depth-buffer based shadows; SSDO-ish.
- SCREEN_SPACE = 1;
- // Basic shadow map.
- SHADOW_MAP = 2;
- // Moment shadow map (see http://momentsingraphics.de).
- MOMENT_SHADOW_MAP = 3;
-};
-
-enum RenderFrequency {
- // Render only on when requested (i.e. when something triggers it).
- // Default behavior.
- WHEN_REQUESTED = 0;
- // Render one frame after another regardless of it it's needed.
- CONTINUOUSLY = 1;
-};
diff --git a/fidl/fuchsia.ui.gfx/resources.fidl b/fidl/fuchsia.ui.gfx/resources.fidl
deleted file mode 100644
index 095eb69..0000000
--- a/fidl/fuchsia.ui.gfx/resources.fidl
+++ /dev/null
@@ -1,260 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-using fuchsia.images;
-
-// These are all of the types of resources that can be created within a
-// |Session|.
-union ResourceArgs {
- // Memory resources.
- MemoryArgs memory;
- ImageArgs image;
- ImagePipeArgs image_pipe;
- BufferArgs buffer;
-
- // Views.
- ViewArgs view;
- ViewHolderArgs view_holder;
-
- // Shapes (see shapes.fidl).
- RectangleArgs rectangle;
- RoundedRectangleArgs rounded_rectangle;
- CircleArgs circle;
- MeshArgs mesh;
-
- // Nodes (see nodes.fidl).
- ShapeNodeArgs shape_node;
- ClipNodeArgs clip_node;
- EntityNodeArgs entity_node;
- OpacityNodeArgs opacity_node;
-
- // Materials.
- MaterialArgs material;
-
- // Layers.
- CompositorArgs compositor;
- DisplayCompositorArgs display_compositor;
- ImagePipeCompositorArgs image_pipe_compositor;
- LayerStackArgs layer_stack;
- LayerArgs layer;
-
- // Scene representation and display.
- SceneArgs scene;
- CameraArgs camera;
- StereoCameraArgs stereo_camera;
- RendererArgs renderer;
-
- // Lighting.
- AmbientLightArgs ambient_light;
- DirectionalLightArgs directional_light;
-
- // A value that can be used in place of a constant value.
- VariableArgs variable;
-};
-
-struct ImagePipeArgs {
- request<fuchsia.images.ImagePipe> image_pipe_request;
-};
-
-// |Memory| is a |Resource| that wraps a client-provided Zircon vmo to register
-// it with Scenic.
-// TODO: specify resizing behavior. Who can resize? Client/Scenic/both/none?
-struct MemoryArgs {
- // The VMO which backs this memory.
- handle<vmo> vmo;
-
- // The amount of memory from |vmo| that should be utilized.
- uint64 allocation_size;
-
- // The type of memory stored in the VMO, namely whether it's GPU memory or
- // host memory.
- fuchsia.images.MemoryType memory_type;
-};
-
-// An image mapped to a range of a |Memory| resource.
-// TODO: more precise and extensive docs.
-struct ImageArgs {
- fuchsia.images.ImageInfo info;
-
- uint32 memory_id; // id of a |Memory| resource
- uint32 memory_offset; // byte offset of image within |Memory| resource
-};
-
-// A buffer mapped to a range of |Memory|.
-struct BufferArgs {
- uint32 memory_id; // id of a |Memory| resource
- uint32 memory_offset; // byte offset of buffer within |Memory| resource
- uint32 num_bytes;
-};
-
-// Represents a transform space which serves as a container for Nodes. The
-// Nodes will have the Views' coordinate transform applied to their own, in
-// addition to being clipped to the Views' bounding box.
-// See |ViewProperties|.
-//
-// Each View is linked to a paired ViewHolder via a shared token.
-//
-// Usually the View and its associated ViewHolder exist in separate processes,
-// allowing a distributed scene graph to be constructed.
-struct ViewArgs {
- handle<eventpair> token;
- string? debug_name;
-};
-
-// Represents a proxy for a View which can be added to a scene graph in order
-// to embed the View within it.
-//
-// Each ViewHolder is linked to a paired View via a shared token.
-//
-// Usually the ViewHolder and its associated View exist in separate processes,
-// allowing a distributed scene graph to be constructed.
-struct ViewHolderArgs {
- handle<eventpair> token;
- string? debug_name;
-};
-
-// A Compositor draws its |LayerStack| into a framebuffer provided by its
-// attached |Display|, if any. If no display is attached, nothing is rendered.
-// TODO(SCN-452): there is currently no way to create/attach a display.
-struct CompositorArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// A DisplayCompositor draws its attached |LayerStack| into an image that is
-// presented on a display.
-struct DisplayCompositorArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// An ImagePipeCompositor draws its attached |LayerStack| into an image that is
-// presented on an image-pipe.
-struct ImagePipeCompositorArgs {
- fuchsia.images.ImagePipe target;
-};
-
-// A LayerStack is a stack of layers that are attached to a Compositor, which
-// draws them in order of increasing Z-order (or rather, presents the illusion
-// of drawing them in that order: it may apply any optimizations that don't
-// affect the output).
-//
-// Supported commands:
-// - AddLayer
-struct LayerStackArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// Supported commands:
-// - Detach
-// - SetCamera
-// - SetColor
-// - SetTexture
-// - SetSize (depth must be zero)
-// - SetSize
-// - SetTranslation (z component determines the relative Z-ordering of layers)
-// - SetRotation (must rotate around Z-axis)
-// - SetScale
-//
-// A layer is not drawn unless it has a camera, texture, or color.
-struct LayerArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// A Scene is the root of a scene-graph, and defines the rendering environment
-// (lighting, etc.) for the tree of nodes beneath it. The following commands
-// may be applied to a Scene (public/fidl/fuchsia.ui.gfx/commands.fidl):
-// - Add/RemoveLight
-// - AddChild
-struct SceneArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// A Camera is used to render a Scene from a particular viewpoint. This is
-// achieved by setting a Renderer to use the camera. The following operations
-// may be applied to a Camera (see ops.fidl):
-// - SetCameraTransform
-// - SetCameraProjection
-// - SetCameraPoseBuffer
-struct CameraArgs {
- // The scene that the camera is viewing.
- uint32 scene_id;
-};
-
-// A StereoCamera is a Camera that renders the scene in side-by-side stereo.
-// The following operations may be applied to a StereoCamera but not a Camera:
-// - SetStereoCameraProjection
-// Additionally, any operation which can be applied to a Camera can also be
-// applied to a StereoCamera.
-struct StereoCameraArgs {
- // The scene that the camera is viewing.
- uint32 scene_id;
-};
-
-// A Renderer renders a Scene via a Camera. The following operations may be
-// applied to a Renderer (see ops.fidl):
-// - SetCamera
-// - SetRendererParam
-struct RendererArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// An AmbientLight is a Light that is is assumed to be everywhere in the scene,
-// in all directions.
-//
-// The following commands may be applied to an AmbientLight
-// (public/fidl/fuchsia.ui.gfx/commands.fidl):
-// - SetLightColor
-struct AmbientLightArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// A DirectionalLight is a Light that is emitted from a point at infinity.
-//
-// Although the light is directional, the light has some amount of angular
-// dispersion (i.e., the light is not fully columnated). For simplicity, we
-// assume the dispersion of the light source is symmetric about the light's
-// primary direction.
-//
-// The following commands may be applied to a DirectionalLight
-// (public/fidl/fuchsia.ui.gfx/commands.fidl):
-// - SetLightColor
-// - SetDirection
-struct DirectionalLightArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-// Simple texture-mapped material.
-//
-// Commands that can be performed later:
-// SetTextureCmd will set the texture, or it can be left as zero (no
-// texture).
-// The texture can be an Image or ImagePipe.
-// SetColorCmd will set the color.
-struct MaterialArgs {
- // TODO(SCN-694): Clean up dummy args.
- uint32 dummy = 0;
-};
-
-struct VariableArgs {
- ValueType type;
- Value initial_value; // Must match type. Must not be a variable_id.
-};
-
-// Describes an exported resource that is to be imported by an
-// ImportResourceCmd.
-//
-// NOTE: Currently just an enum of importable resource types, but may later be
-// expanded to express concepts like "meshes with a particular vertex format".
-enum ImportSpec {
- NODE = 0;
-};
diff --git a/fidl/fuchsia.ui.gfx/shapes.fidl b/fidl/fuchsia.ui.gfx/shapes.fidl
deleted file mode 100644
index 5734af1..0000000
--- a/fidl/fuchsia.ui.gfx/shapes.fidl
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-// The shapes defined in this file can be used to define the rendered shape of
-// an |ObjectNode|, and to define the clip region of a |ClipNode|.
-
-// Rectangle centered at (0,0).
-struct RectangleArgs {
- Value width; // float32
- Value height; // float32
-};
-
-// RoundedRectangle centered at (0,0). Legal parameter values must satisfy the
-// constraint that the flat sides of the rectangle have non-negative length.
-// In other words, the following constraints must hold:
-// - top_left_radius + top_right_radius <= width
-// - bottom_left_radius + bottom_right_radius <= width
-// - top_left_radius + bottom_left_radius <= height
-// - top_right_radius + bottom_right_radius <= height
-struct RoundedRectangleArgs {
- Value width; // float32
- Value height; // float32
- Value top_left_radius; // float32
- Value top_right_radius; // float32
- Value bottom_right_radius; // float32
- Value bottom_left_radius; // float32
-};
-
-struct CircleArgs {
- Value radius; // float32
-};
-
-// A Mesh cannot be rendered until it has been bound to vertex/index buffers;
-// see BindMeshBuffersCmd.
-struct MeshArgs {
- uint8 dummy;
-};
diff --git a/fidl/fuchsia.ui.gfx/types.fidl b/fidl/fuchsia.ui.gfx/types.fidl
deleted file mode 100644
index d470e5b..0000000
--- a/fidl/fuchsia.ui.gfx/types.fidl
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.gfx;
-
-struct vec2 {
- float32 x;
- float32 y;
-};
-
-struct vec3 {
- float32 x;
- float32 y;
- float32 z;
-};
-
-struct vec4 {
- float32 x;
- float32 y;
- float32 z;
- float32 w;
-};
-
-struct mat4 {
- // Column major order.
- array<float32>:16 matrix;
-};
-
-// TODO(MZ-238): use float32s instead of uint8.
-struct ColorRgba {
- uint8 red;
- uint8 green;
- uint8 blue;
- uint8 alpha;
-};
-
-struct ColorRgb {
- float32 red;
- float32 green;
- float32 blue;
-};
-
-struct Quaternion {
- float32 x;
- float32 y;
- float32 z;
- float32 w;
-};
-
-struct FactoredTransform {
- vec3 translation;
- vec3 scale;
- // Point around which rotation and scaling occur.
- vec3 anchor;
- Quaternion rotation;
-};
-
-union Value {
- float32 vector1;
- vec2 vector2;
- vec3 vector3;
- vec4 vector4;
- mat4 matrix4x4;
- ColorRgba color_rgba;
- ColorRgb color_rgb;
- // Degrees of counter-clockwise rotation in the XY plane.
- float32 degrees;
- Quaternion quaternion;
- FactoredTransform transform;
- // ID of a value-producing resource (an animation or an expression).
- // The type of this value matches the type produced by the named resource.
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a float32, and |value| is ignored.
-struct FloatValue {
- float32 value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a vec2, and |value| is ignored.
-struct Vector2Value {
- vec2 value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a vec3, and |value| is ignored.
-struct Vector3Value {
- vec3 value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a vec4, and |value| is ignored.
-struct Vector4Value {
- vec4 value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a vec4, and |value| is ignored.
-struct Matrix4Value {
- mat4 value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a ColorRgb, and |value| is ignored.
-struct ColorRgbValue {
- ColorRgb value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a ColorRgba, and |value| is ignored.
-struct ColorRgbaValue {
- ColorRgba value;
- uint32 variable_id;
-};
-
-// A value that is specified explicitly by |value| if |variable_id| is zero,
-// or is the value produced by the resource identified by |variable_id|, e.g.
-// an animation or expression. In the latter case, the value produced by the
-// resource must be a Quaternion, and |value| is ignored.
-struct QuaternionValue {
- Quaternion value;
- uint32 variable_id;
-};
-
-enum ValueType {
- kNone = 0;
- kVector1 = 1;
- kVector2 = 2;
- kVector3 = 3;
- kVector4 = 4;
- kMatrix4 = 5;
- kColorRgb = 6;
- kColorRgba = 7;
- kQuaternion = 8;
- kFactoredTransform = 9;
-};
-
-// Describes how nodes interact with hit testings.
-enum HitTestBehavior {
- // Apply hit testing to the node's content, its parts, and its children.
- kDefault = 0;
-
- // Suppress hit testing of the node and everything it contains.
- kSuppress = 1;
-};
-
-// Rendering target metrics associated with a node.
-// See also |MetricsEvent|.
-struct Metrics {
- // The ratio between the size of one logical pixel within the node's local
- // coordinate system and the size of one physical pixel of the rendering
- // target.
- //
- // This scale factors change in relation to the resolution of the rendering
- // target and the scale transformations applied by containing nodes.
- // They are always strictly positive and non-zero.
- //
- // For example, suppose the rendering target is a high resolution display
- // with a device pixel ratio of 2.0 meaning that each logical pixel
- // within the model corresponds to two physical pixels of the display.
- // Assuming no scale transformations affect the node, then its metrics event
- // will report a scale factor of 2.0.
- //
- // Building on this example, if instead the node's parent applies a
- // scale transformation of 0.25 to the node, then the node's metrics event
- // will report a scale factor of 0.5 indicating that the node should render
- // its content at a reduced resolution and level of detail since a smaller
- // area of physical pixels (half the size in each dimension) will be rendered.
- float32 scale_x;
- float32 scale_y;
- float32 scale_z;
-};
-
-// Represents an axis-aligned bounding box. If any of the dimensions has a
-// negative extent (e.g. max.x < min.x) then the bounding box is treated as
-// empty.
-struct BoundingBox {
- vec3 min;
- vec3 max;
-};
-
-// Represents the properties for a View.
-struct ViewProperties {
- // The View's bounding box extents can be defined as:
- // { bounding_box.min - inset_from_min, bounding_box.max + inset_from_max }
- // Content contained within the View is clipped to this bounding box.
- //
- // TODO(SCN-819): should we just have a vec3 extent instead of a bounding box
- // with a potentially non-zero min?
- BoundingBox bounding_box;
-
- // |insets_from_min| and |insets_from_max| specify the distances between the
- // view's bounding box and that of its parent.
- vec3 inset_from_min;
- vec3 inset_from_max;
-
- // Whether the View can receive a focus event; default is true. When
- // false, and this View is eligible to receive a focus event, no
- // focus/unfocus event is actually sent to any View.
- bool focus_change = true;
-
- // Whether the View allows geometrically underlying Views to receive input;
- // default is true. When false, Scenic does not send input events to
- // underlying Views.
- bool downward_input = true;
-};
-
-// Represents the state of a View in Scenic.
-struct ViewState {
- // Whether the View is rendering. Default is false. Delivered to the View's
- // corresponding ViewHolder after the View's first frame render request.
- bool is_rendering;
-};
diff --git a/fidl/fuchsia.ui.input/commands.fidl b/fidl/fuchsia.ui.input/commands.fidl
deleted file mode 100644
index 098ccb0..0000000
--- a/fidl/fuchsia.ui.input/commands.fidl
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-union Command {
- // Commands for conveying input events to a |Session|.
- // Structs defined in input_events.fidl.
- SendKeyboardInputCmd send_keyboard_input;
- SendPointerInputCmd send_pointer_input;
-
- // Command to enable/disable delivery of hard keyboard events.
- SetHardKeyboardDeliveryCmd set_hard_keyboard_delivery;
-
- // Command to enable/disable parallel delivery of input events.
- SetParallelDispatchCmd set_parallel_dispatch;
-};
-
-struct SendKeyboardInputCmd {
- uint32 compositor_id;
- KeyboardEvent keyboard_event; // Defined in input_events.fidl
-};
-
-struct SendPointerInputCmd {
- uint32 compositor_id;
- PointerEvent pointer_event; // Defined in input_events.fidl
-};
-
-// Typically, clients should receive text inputs from an IME.
-//
-// For cases where no IME mediation is desired (such as a game application),
-// this command requests Scenic to deliver hard keyboard events to the client.
-//
-// By default, Scenic will *not* deliver hard keyboard events to a client.
-struct SetHardKeyboardDeliveryCmd {
- bool delivery_request;
-};
-
-// Typically, clients that participate in the hit test should receive input
-// events in parallel. This behavior is required for gesture disambiguation.
-//
-// This command, typically set by the root presenter, allows disabling parallel
-// dispatch; it is part of the input v2 transition work.
-// TODO(SCN-1047): Remove after gesture disambiguation is implemented.
-struct SetParallelDispatchCmd {
- bool parallel_dispatch;
-};
diff --git a/fidl/fuchsia.ui.input/ime_service.fidl b/fidl/fuchsia.ui.input/ime_service.fidl
deleted file mode 100644
index 3ee5b58..0000000
--- a/fidl/fuchsia.ui.input/ime_service.fidl
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// The service provided by an IME
-[Discoverable]
-interface ImeService {
- 1: GetInputMethodEditor(KeyboardType keyboard_type,
- InputMethodAction action,
- TextInputState initial_state,
- InputMethodEditorClient client,
- request<InputMethodEditor> editor);
- 2: ShowKeyboard();
- 3: HideKeyboard();
- 4: InjectInput(InputEvent event);
-};
-
-// Onscreen keyboard containers connect to this to know when a keyboard
-// should be shown or hidden.
-[Discoverable]
-interface ImeVisibilityService {
- 1: -> OnKeyboardVisibilityChanged(bool visible);
-};
diff --git a/fidl/fuchsia.ui.input/input_connection.fidl b/fidl/fuchsia.ui.input/input_connection.fidl
deleted file mode 100644
index 497fff1..0000000
--- a/fidl/fuchsia.ui.input/input_connection.fidl
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// TODO(jeffbrown): Redesign input event representation later.
-
-// The input connection service allows a view to receive input events
-// such as key presses and pointer movements.
-
-// This service can be retrieved from the |View| service provider.
-//
-// TODO(jeffbrown): Elaborate this. Particularly need to think about
-// how to handle focus and gestures.
-[Discoverable]
-interface InputConnection {
- // Sets the listener for receiving input events.
- //
- // If |listener| is null, then the previously set listener is removed.
- 1: SetEventListener(InputListener? listener);
-
- // Retrieves an |InputMethodEditor| to handle text editing.
- 2: GetInputMethodEditor(KeyboardType keyboard_type,
- InputMethodAction action,
- TextInputState initial_state,
- InputMethodEditorClient client,
- request<InputMethodEditor> editor);
- 3: ShowKeyboard();
- 4: HideKeyboard();
-};
-
-// An interface applications may implement to receive events from an
-// input connection.
-// TODO(MZ-33): This should include hit testing and an input arena.
-[Discoverable]
-interface InputListener {
- // Called to deliver an input event.
- //
- // The |consumed| result should indicate whether the input event was
- // consumed by the connection. If |consumed| is false, the system may
- // apply default behavior of its own in response to the event.
- 1: OnEvent(InputEvent event) -> (bool consumed);
-};
diff --git a/fidl/fuchsia.ui.input/input_device_registry.fidl b/fidl/fuchsia.ui.input/input_device_registry.fidl
deleted file mode 100644
index 84fca87..0000000
--- a/fidl/fuchsia.ui.input/input_device_registry.fidl
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// Service to receive input events.
-//
-// Input devices can describe their capabilities using |DeviceDescriptor|
-// and register themselves with the |InputDeviceRegistry|.
-[Discoverable]
-interface InputDeviceRegistry {
- // Register a device with the capabilities described by |DeviceDescriptor|
- 1: RegisterDevice(DeviceDescriptor descriptor, request<InputDevice> input_device);
-};
-
-interface InputDevice {
- // Dispatch an |InputReport| from the device |token|
- 1: DispatchReport(InputReport report);
-};
diff --git a/fidl/fuchsia.ui.input/input_dispatcher.fidl b/fidl/fuchsia.ui.input/input_dispatcher.fidl
deleted file mode 100644
index 744bf1b..0000000
--- a/fidl/fuchsia.ui.input/input_dispatcher.fidl
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// TODO(jeffbrown): Redesign input event representation later.
-
-// The input dispatcher service allows the component which owns and controls
-// a view tree to dispatch input events to the views that it contains.
-//
-// This service can be retrieved from the |ViewTree| service provider.
-//
-// TODO(jeffbrown): Elaborate how input devices are registered with the
-// dispatcher so that applications can query their capabilities and distinguish
-// input coming from multiple sources concurrently.
-[Discoverable]
-interface InputDispatcher {
- // Dispatches an event through the view tree. The dispatcher will deliver
- // the event to the appropriate views based on the current state of the
- // tree, such as focus and the structure of the scene graph.
- //
- // The dispatcher expects the stream of events that it receives to be
- // internally consistent. For example, each pointer down must be matched
- // by a corresponding pointer up.
- //
- // It is an error to supply an inconsistent stream events to the dispatcher;
- // the connection will be closed.
- //
- // TODO(jeffbrown): Is this the right policy? It would certainly help
- // diagnose faults earlier.
- // TODO(jeffbrown): Decide whether there should be a way to track the
- // progress of input events. For testing purposes it is often desirable
- // to block the test until a sequence of events have been delivered and
- // handled. However these same mechanisms have proven to be brittle in
- // the past so it might be better to solve the problem some other way.
- 1: DispatchEvent(InputEvent event);
-};
diff --git a/fidl/fuchsia.ui.input/input_event_constants.fidl b/fidl/fuchsia.ui.input/input_event_constants.fidl
deleted file mode 100644
index 3131664..0000000
--- a/fidl/fuchsia.ui.input/input_event_constants.fidl
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// Keyboard modifiers
-const uint32 kModifierCapsLock = 1;
-const uint32 kModifierLeftShift = 2;
-const uint32 kModifierRightShift = 4;
-const uint32 kModifierShift = 6; // (kModifierLeftShift | kModifierRightShift);
-const uint32 kModifierLeftControl = 8;
-const uint32 kModifierRightControl = 16;
-const uint32 kModifierControl = 24; // (kModifierLeftControl | kModifierRightControl);
-const uint32 kModifierLeftAlt = 32;
-const uint32 kModifierRightAlt = 64;
-const uint32 kModifierAlt = 96; // (kModifierLeftAlt | kModifierRightAlt);
-const uint32 kModifierLeftSuper = 128;
-const uint32 kModifierRightSuper = 256;
-const uint32 kModifierSuper = 384; // (kModifierLeftSuper | kModifierRightSuper);
-
-// Mouse buttons
-const uint32 kMousePrimaryButton = 1;
-const uint32 kMouseSecondaryButton = 2;
-const uint32 kMouseTertiaryButton = 4;
-
-// Stylus buttons
-const uint32 kStylusPrimaryButton = 1;
-const uint32 kStylusSecondaryButton = 2;
-
-// end-no-format
diff --git a/fidl/fuchsia.ui.input/input_events.fidl b/fidl/fuchsia.ui.input/input_events.fidl
deleted file mode 100644
index fb3c386..0000000
--- a/fidl/fuchsia.ui.input/input_events.fidl
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2014 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-enum KeyboardEventPhase {
- // When key is pressed down.
- PRESSED = 0;
- // When key is released.
- RELEASED = 1;
- // This key |PRESSED| is not directed to this input client anymore.
- CANCELLED = 2;
- // Whether this is an automatically generated key repeat
- REPEAT = 3;
-};
-
-// |KeyboardEvent| represents event generated by a user's interaction with a
-// keyboard.
-//
-// Those events are triggered by distinct pressed state changes of the keys.
-//
-// The state transitions should be as follows:
-// PRESSED -> (REPEAT ->) RELEASED
-// or
-// PRESSED -> (REPEAT ->) CANCELLED
-//
-// The input system will repeat those events automatically when a code_point is
-// available.
-struct KeyboardEvent {
- // Time the event was delivered. The time is in nanoseconds and corresponds
- // to the uptime of the machine.
- uint64 event_time;
-
- uint32 device_id;
-
- KeyboardEventPhase phase;
-
- // Keyboard HID Usage
- // See https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
- uint32 hid_usage;
-
- // The unicode code point represented by this key event, if any.
- // Dead keys are represented as Unicode combining characters.
- //
- // If there is no unicode code point, this value is zero.
- uint32 code_point;
-
- // Key modifiers as defined by the different kModifier constants such as
- // |kModifierCapsLock| currently pressed
- uint32 modifiers;
-};
-
-enum PointerEventType {
- // A touch-based pointer device.
- TOUCH = 0;
-
- // A pointer device with a stylus.
- STYLUS = 1;
-
- // A pointer device with a stylus that has been inverted.
- INVERTED_STYLUS = 2;
-
- // A pointer device without a stylus.
- MOUSE = 3;
-};
-
-enum PointerEventPhase {
- // The device has started tracking the pointer.
- //
- // For example, the pointer might be hovering above the device, having not yet
- // made contact with the surface of the device.
- ADD = 0;
-
- // The pointer has moved with respect to the device while not in contact with
- // the device.
- HOVER = 1;
-
- // The pointer has made contact with the device.
- //
- // For |MOUSE| devices, this is triggered when the primary button is pressed
- // down to emulate a touch on the screen.
- DOWN = 2;
-
- // The pointer has moved with respect to the device while in contact with the
- // device.
- MOVE = 3;
-
- // The pointer has stopped making contact with the device.
- //
- // For |MOUSE| devices, this is triggered when the primary button is
- // released.
- UP = 4;
-
- // The device is no longer tracking the pointer.
- //
- // For example, the pointer might have drifted out of the device's hover
- // detection range or might have been disconnected from the system entirely.
- REMOVE = 5;
-
- // The input from the pointer is no longer directed towards this receiver.
- CANCEL = 6;
-
- // TODO: add phases to indicate button press / release
-};
-
-// Pointers represent raw data about the user's interaction with the screen.
-//
-// The state transitions should be as follows:
-// ADD (-> HOVER) -> DOWN -> MOVE -> UP (-> HOVER) -> REMOVE
-//
-// At any point after the initial ADD, a transition to CANCEL is also possible.
-struct PointerEvent {
- // Time the event was delivered. The time is in nanoseconds and corresponds
- // to the uptime of the machine.
- uint64 event_time;
-
- uint32 device_id;
-
- uint32 pointer_id;
-
- PointerEventType type;
-
- PointerEventPhase phase;
-
- // |x| and |y| are in the coordinate system of the View.
- float32 x;
- float32 y;
-
- // TODO(jpoichet) float32 vx;
- // TODO(jpoichet) float32 vy;
-
- float32 radius_major;
- float32 radius_minor;
- // TODO(jpoichet) float32 orientation;
- // TODO(jpoichet) float32 tilt;
- // TODO(jpoichet) float32 altitude;
- // TODO(jpichet) float32 amplitude;
-
- // Currently pressed buttons as defined the kButton constants such as
- // |kMousePrimaryButton|
- uint32 buttons;
-};
-
-struct FocusEvent {
- // Time the event was delivered. The time is in nanoseconds and corresponds
- // to the uptime of the machine.
- uint64 event_time;
-
- // Whether the view has gained input focused or not.
- bool focused;
-};
-
-union InputEvent {
- PointerEvent pointer;
- KeyboardEvent keyboard;
- FocusEvent focus;
-};
diff --git a/fidl/fuchsia.ui.input/input_reports.fidl b/fidl/fuchsia.ui.input/input_reports.fidl
deleted file mode 100644
index 0cff1e2..0000000
--- a/fidl/fuchsia.ui.input/input_reports.fidl
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// Descriptors are used to describe the capabilities of an input device.
-//
-// Devices can have multiple descriptors of multiple kinds, for example:
-// |KeyboardDescriptor|, |MouseDescriptor|, |StylusDescriptor|,
-// |TouchscreenDescriptor| and |SensorDescriptor|
-//
-// An input device will generate |InputReport| corresponding to the
-// capabilities of that device listed in its descriptor.
-// For instance a input device with a |KeyboardDescriptor| will generate
-// |KeyboardReport| when a key is pressed on the keyboard.
-
-// Describe a |Range| of values
-struct Range {
- int32 min;
- int32 max;
-};
-
-struct RangeF {
- float32 min;
- float32 max;
-};
-
-enum AxisScale {
- LINEAR = 0;
- LOGARITHMIC = 1;
-};
-
-// An |Axis| is defined as a |range| and |resolution|.
-struct Axis {
- Range range;
- int32 resolution = 1;
- AxisScale scale = LINEAR;
-};
-
-struct AxisF {
- RangeF range;
- float32 resolution = 1.0;
- AxisScale scale = LINEAR;
-};
-
-// |ButtonsDescriptor| describes the buttons.
-struct ButtonsDescriptor {
- // The list of buttons available.
- uint32 buttons;
-};
-
-// Keyboards
-
-// |KeyboardDescriptor| describes the capabilities of a keyboard.
-struct KeyboardDescriptor {
- // The list of HID keyboard usages that this keyboard can generate.
- vector<uint32> keys;
-};
-
-// |KeyboardReport| lists the keys currently pressed down.
-struct KeyboardReport {
- // |pressed_keys| is the list of HID usage that are currently pressed down on
- // the keyboard.
- vector<uint32> pressed_keys;
-};
-
-// Mouse
-
-// |MouseDescriptor| describes the capabilities of a mouse.
-struct MouseDescriptor {
- // The range of relative X and Y movement which can be described by a mouse
- // report.
- Axis rel_x;
- Axis rel_y;
-
- // The range of relative vertical and horizontal scroll which can be
- // described by a mouse report.
- Axis? vscroll;
- Axis? hscroll;
-
- // The list of HID mouse usages that this mouse can generate.
- uint32 buttons;
-};
-
-// |MouseReport| gives the relative mouvement of the mouse and currently
-// pressed buttons.
-struct MouseReport {
- // Relative X and Y positional displacement.
- int32 rel_x;
- int32 rel_y;
-
- // Relative horizontal and vertical scrolling displacement.
- int32 rel_hscroll;
- int32 rel_vscroll;
-
- // buttons currently down
- uint32 pressed_buttons;
-};
-
-// Stylus
-
-// |Stylus| describes the capabilities of a stylus.
-struct StylusDescriptor {
- // Ranges for the |x| and |y| axis of the stylus.
- Axis x;
- Axis y;
-
- // Range for the pressure of the tip
- Axis? pressure;
-
- bool is_invertible = false;
-
- // The list of HID button usages that this stylus can generate.
- uint32 buttons;
-};
-
-// |StylusReport| describes the current state of the stylus.
-struct StylusReport {
- // Current position of the stylus within the range described in
- // |StylusDescriptor|
- int32 x;
- int32 y;
-
- // Pressure applied on the stylus tip
- uint32 pressure;
-
- // Whether the stylus has made contact with the surface.
- bool is_in_contact;
-
- // Whether the stylus is within range. If |is_in_contact| is false, then the stylus
- // is hovering.
- bool in_range;
-
- // Whether the stylus is thought to be inverted.
- bool is_inverted;
-
- // List of buttons currently pressed down.
- uint32 pressed_buttons;
-};
-
-// Touchscreen
-
-// |TouchscreenDescriptor| describes the capabilities of a touchscreen.
-struct TouchscreenDescriptor {
- // Ranges of the |x| and |y| axis.
- Axis x;
- Axis y;
- uint32 max_finger_id;
-};
-
-// |Touch| describes one touch on a touchscreen, which should correspond to
-// one finger.
-struct Touch {
- // Identifier for a finger that is down.
- // Note: |finger_id| might not be sequential and will range from 0 to
- // |max_finger_id|
- uint32 finger_id;
-
- // Location within the axis defined in |TouchscreenDescriptor|
- int32 x;
- int32 y;
-
- // Area pressed.
- uint32 width;
- uint32 height;
-};
-
-// |TouchscreenReport| describes the current touches recorded by the touchscreen
-// and holds a |Touch| per finger down.
-struct TouchscreenReport {
- vector<Touch> touches;
-};
-
-// Motion Sensors
-
-// Descriptive categories for sensor devices.
-// We assume that each (SensorType,SensorLocation) pair is unique to the system.
-
-enum SensorType {
- ACCELEROMETER = 0;
- GYROSCOPE = 1;
- MAGNETOMETER = 2;
- LIGHTMETER = 3;
-};
-
-enum SensorLocation {
- UNKNOWN = 0;
- BASE = 1;
- LID = 2;
-};
-
-// |SensorDescriptor| describes the capabilities of a sensor device. It does
-// not capture properties that can be changed after initialization, such as the
-// current sampling frequency.
-struct SensorDescriptor {
- SensorType type;
- SensorLocation loc;
-
- // Min and max sampling frequencies for a sensor.
- uint32 min_sampling_freq;
- uint32 max_sampling_freq;
- // Max number of sensor events that could be in hardware FIFO.
- uint32 fifo_max_event_count;
-
- // Physical range of a specific sensor.
- // Accelerometer ranges are given in Gs.
- // Gyroscope ranges are given in deg/s.
- // Magnetometer ranges are given in multiples of 1/16 uT.
- // Light meter ranges can be given in Lux or units not specified.
- int32 phys_min;
- int32 phys_max;
-};
-
-// |SensorReport| describes the sensor event delivered from the event stream.
-union SensorReport {
- array<int16>:3 vector;
- uint16 scalar;
-};
-
-// |ButtonsReport| describes the buttons event delivered from the event stream.
-union ButtonsReport {
- // Volume changes +1/-1 for volume up/down, this is a relative value.
- int8 volume;
- bool mic_mute;
-};
-
-// Device and Report
-
-struct DeviceInfo {
- uint32 vendor_id;
- uint32 product_id;
- uint32 version;
- string name;
-};
-
-// |DeviceDescriptor| describes one input device.
-struct DeviceDescriptor {
- DeviceInfo? device_info;
- KeyboardDescriptor? keyboard;
- ButtonsDescriptor? buttons;
- MouseDescriptor? mouse;
- StylusDescriptor? stylus;
- TouchscreenDescriptor? touchscreen;
- SensorDescriptor? sensor;
-};
-
-// |InputReport| is an input |report| triggered by an input device.
-struct InputReport {
- // |event_time| is in nanoseconds when the event was recorded.
- uint64 event_time;
-
- KeyboardReport? keyboard;
- ButtonsReport? buttons;
- MouseReport? mouse;
- StylusReport? stylus;
- TouchscreenReport? touchscreen;
- SensorReport? sensor;
-};
diff --git a/fidl/fuchsia.ui.input/meta.json b/fidl/fuchsia.ui.input/meta.json
deleted file mode 100644
index 7054d90..0000000
--- a/fidl/fuchsia.ui.input/meta.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.ui.input/commands.fidl",
- "fidl/fuchsia.ui.input/ime_service.fidl",
- "fidl/fuchsia.ui.input/input_connection.fidl",
- "fidl/fuchsia.ui.input/input_device_registry.fidl",
- "fidl/fuchsia.ui.input/input_dispatcher.fidl",
- "fidl/fuchsia.ui.input/input_event_constants.fidl",
- "fidl/fuchsia.ui.input/input_events.fidl",
- "fidl/fuchsia.ui.input/input_reports.fidl",
- "fidl/fuchsia.ui.input/text_editing.fidl",
- "fidl/fuchsia.ui.input/text_input.fidl",
- "fidl/fuchsia.ui.input/usages.fidl"
- ],
- "name": "fuchsia.ui.input",
- "root": "fidl/fuchsia.ui.input",
- "sources": [
- "fidl/fuchsia.ui.input/commands.fidl",
- "fidl/fuchsia.ui.input/ime_service.fidl",
- "fidl/fuchsia.ui.input/input_connection.fidl",
- "fidl/fuchsia.ui.input/input_device_registry.fidl",
- "fidl/fuchsia.ui.input/input_dispatcher.fidl",
- "fidl/fuchsia.ui.input/input_event_constants.fidl",
- "fidl/fuchsia.ui.input/input_events.fidl",
- "fidl/fuchsia.ui.input/input_reports.fidl",
- "fidl/fuchsia.ui.input/text_editing.fidl",
- "fidl/fuchsia.ui.input/text_input.fidl",
- "fidl/fuchsia.ui.input/usages.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.input/text_editing.fidl b/fidl/fuchsia.ui.input/text_editing.fidl
deleted file mode 100644
index 73759a1..0000000
--- a/fidl/fuchsia.ui.input/text_editing.fidl
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// Whether a TextPosition is visually upstream or downstream of its offset.
-//
-// For example, when a text position exists at a line break, a single offset has
-// two visual positions, one prior to the line break (at the end of the first
-// line) and one after the line break (at the start of the second line). A text
-// affinity disambiguates between those cases. (Something similar happens with
-// between runs of bidirectional text.)
-enum TextAffinity {
- // The position has affinity for the upstream side of the text position.
- //
- // For example, if the offset of the text position is a line break, the
- // position represents the end of the first line.
- UPSTREAM = 0;
-
- // The position has affinity for the downstream side of the text position.
- //
- // For example, if the offset of the text position is a line break, the
- // position represents the start of the second line.
- DOWNSTREAM = 1;
-};
-
-// A range of characters in a string of text.
-struct TextRange {
- // The index of the first UTF-16 character in the range.
- //
- // If |start| and |end| are both -1, the text range is empty.
- int64 start = -1;
-
- // The next index after the UTF-16 characters in this range.
- //
- // If |start| and |end| are both -1, the text range is empty.
- int64 end = -1;
-};
-
-// A range of text that represents a selection.
-//
-// Text selection is always directional. Direction should be determined by
-// comparing base and extent.
-struct TextSelection {
- // The offset at which the selection originates.
- //
- // Might be larger than, smaller than, or equal to extent.
- int64 base;
-
- // The offset at which the selection terminates.
- //
- // When the user uses the arrow keys to adjust the selection, this is the
- // value that changes. Similarly, if the current theme paints a caret on one
- // side of the selection, this is the location at which to paint the caret.
- //
- // Might be larger than, smaller than, or equal to base.
- int64 extent;
-
- // If the the text range is collapsed and has more than one visual location
- // (e.g., occurs at a line break), which of the two locations to use when
- // painting the caret.
- TextAffinity affinity;
-};
diff --git a/fidl/fuchsia.ui.input/text_input.fidl b/fidl/fuchsia.ui.input/text_input.fidl
deleted file mode 100644
index 6d38423..0000000
--- a/fidl/fuchsia.ui.input/text_input.fidl
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-enum KeyboardType {
- TEXT = 0;
- NUMBER = 1;
- PHONE = 2;
- DATETIME = 3;
-};
-
-enum InputMethodAction {
- UNSPECIFIED = 0;
- NONE = 1;
- GO = 2;
- SEARCH = 3;
- SEND = 4;
- NEXT = 5;
- DONE = 6;
- PREVIOUS = 7;
-};
-
-// The current text, selection, and composing state for editing a run of text.
-struct TextInputState {
- // Current state revision to avoid race conditions.
- uint32 revision;
-
- // The current text being edited.
- string text;
-
- // The range of text that is currently selected.
- TextSelection selection;
-
- // The range of text that is still being composed.
- TextRange composing;
-};
-
-// A interface for interacting with a text input control.
-interface InputMethodEditor {
- 1: SetKeyboardType(KeyboardType keyboard_type);
- 2: SetState(TextInputState state);
- 3: InjectInput(InputEvent event);
-
- // TODO(TEXT-19): remove these in a later change, after PlatformView has been
- // switched over to open/close on the input_connection_ instead.
- 4: Show();
- 5: Hide();
-};
-
-// An interface to receive information from |TextInputService|.
-interface InputMethodEditorClient {
- 1: DidUpdateState(TextInputState state, InputEvent? event);
- 2: OnAction(InputMethodAction action);
-};
diff --git a/fidl/fuchsia.ui.input/usages.fidl b/fidl/fuchsia.ui.input/usages.fidl
deleted file mode 100644
index 2fd70e1..0000000
--- a/fidl/fuchsia.ui.input/usages.fidl
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.input;
-
-// Common mouse buttons report constants
-const uint32 kMouseButtonPrimary = 1;
-const uint32 kMouseButtonSecondary = 2;
-const uint32 kMouseButtonTertiary = 4;
-
-// Common stylus buttons report constants
-const uint32 kStylusBarrel = 1;
-
-// Used as mask bits (2^N) against ButtonDescriptor.buttons.
-const uint32 kVolumeUp = 1;
-const uint32 kVolumeDown = 2;
-const uint32 kMicMute = 4;
diff --git a/fidl/fuchsia.ui.policy/display_usage.fidl b/fidl/fuchsia.ui.policy/display_usage.fidl
deleted file mode 100644
index 79f820f..0000000
--- a/fidl/fuchsia.ui.policy/display_usage.fidl
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.policy;
-
-// Describes the intended usage of the display.
-enum DisplayUsage {
- kUnknown = 0;
- // Display is held in one or both hands.
- kHandheld = 1;
- // Display is used well within arm's reach.
- kClose = 2;
- // Display is used at arm's reach.
- kNear = 3;
- // Display is used beyond arm's reach.
- kMidrange = 4;
- // Display is used well beyond arm's reach.
- kFar = 5;
-};
diff --git a/fidl/fuchsia.ui.policy/meta.json b/fidl/fuchsia.ui.policy/meta.json
deleted file mode 100644
index 424455e..0000000
--- a/fidl/fuchsia.ui.policy/meta.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "deps": [
- "fuchsia.ui.gfx",
- "fuchsia.ui.input",
- "fuchsia.ui.viewsv1token"
- ],
- "files": [
- "fidl/fuchsia.ui.policy/display_usage.fidl",
- "fidl/fuchsia.ui.policy/presentation.fidl",
- "fidl/fuchsia.ui.policy/presenter.fidl"
- ],
- "name": "fuchsia.ui.policy",
- "root": "fidl/fuchsia.ui.policy",
- "sources": [
- "fidl/fuchsia.ui.policy/display_usage.fidl",
- "fidl/fuchsia.ui.policy/presentation.fidl",
- "fidl/fuchsia.ui.policy/presenter.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.policy/presentation.fidl b/fidl/fuchsia.ui.policy/presentation.fidl
deleted file mode 100644
index c6d3dcc..0000000
--- a/fidl/fuchsia.ui.policy/presentation.fidl
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.policy;
-
-using fuchsia.ui.gfx;
-using fuchsia.ui.input;
-
-// |Presentation.CaptureKeyboardEvent| will consume this listener interface and
-// call |OnEvent| when the registered keyboard event occurs.
-interface KeyboardCaptureListenerHACK {
- 1: OnEvent(fuchsia.ui.input.KeyboardEvent event);
-};
-
-// |Presentation.CapturePointerEvent| will consume this listener interface and
-// call |OnEvent| when a pointer event occurs.
-interface PointerCaptureListenerHACK {
- 1: OnPointerEvent(fuchsia.ui.input.PointerEvent event);
-};
-
-// Allows clients of Presenter.Present() to control a presentation.
-// Experimental.
-[Discoverable]
-interface Presentation {
- // Enable or disable clipping for the Scenic renderer associated with the
- // presentation.
- 1: EnableClipping(bool enabled);
-
- 2: UseOrthographicView();
- 3: UsePerspectiveView();
-
- // Set parameters such as the shadow algorithm used to render the scene.
- // NOTE: a single param would be better than an array; see TO-529.
- 4: SetRendererParams(vector<fuchsia.ui.gfx.RendererParam> params);
-
- // Override the intended usage of the display.
- 5: SetDisplayUsage(DisplayUsage usage);
-
- // Rotates the display.
- 11: SetDisplayRotation(float32 display_rotation_degrees, bool animate);
-
- // Override the dimensions of the display. Values must be less than the actual
- // size of the display. If either of the values are 0, then they are ignored
- // and the actual size of the display is used.
- 7: SetDisplaySizeInMm(float32 width_in_mm, float32 height_in_mm);
-
- // This call exists so that base shell can capture hotkeys and do special
- // things with it (e.g., switch a session shell). Phase and modifiers are always
- // matched, and valid (non-zero) code points are matched. If there is no
- // valid code point, the filter will match against the hid usage value.
- // The full KeyboardEvent is supplied to |listener|'s OnEvent.
- // TODO: Figure out the feasibility of this feature and the best place to put
- // it.
- 6: CaptureKeyboardEventHACK(fuchsia.ui.input.KeyboardEvent event_to_capture,
- KeyboardCaptureListenerHACK listener);
-
- // This call exists so that base shell can capture pointer events.
- // TODO: Figure out the feasibility of this feature and the best place to put
- // it. This call will be replaced by gesture disambiguation system in future.
- 10: CapturePointerEventsHACK(PointerCaptureListenerHACK listener);
-
- // TODO(SCN-650): Determine better place for PresentationMode API.
- 8: GetPresentationMode() -> (PresentationMode mode);
- 9: SetPresentationModeListener(PresentationModeListener listener);
-};
-
-// Screen modes that can be detected via sensor data.
-// N.B. We use accelerometers to measure gravity when at rest, so detection is
-// limited to earth-relative orientations.
-enum PresentationMode {
- CLOSED = 0;
- LAPTOP = 1;
- TABLET = 2;
- TENT = 3;
-};
-
-// Tell client that the screen mode has changed, according to sensors.
-// N.B. There can be a race where the actual mode continues to change, after
-// the listener has been notified. The client must call GetPresentationMode(),
-// which will return the latest detected mode.
-interface PresentationModeListener {
- 1: OnModeChanged();
-};
diff --git a/fidl/fuchsia.ui.policy/presenter.fidl b/fidl/fuchsia.ui.policy/presenter.fidl
deleted file mode 100644
index f712643..0000000
--- a/fidl/fuchsia.ui.policy/presenter.fidl
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.policy;
-
-using fuchsia.ui.gfx;
-using fuchsia.ui.viewsv1token;
-
-// The Presenter service provides a way for applications to ask that a
-// specified view be added to a view tree, leaving any window management
-// concerns up to the discretion of the presenter implementation.
-//
-// TODO(SCN-599): this will be replaced by Presenter2
-[Discoverable]
-interface Presenter {
- 1: Present2(handle<eventpair> view_owner_token, request<Presentation>? presentation_request);
-
- // Sets new default renderer params and forces them on for the duration of the
- // presenter's lifetime. Only applies to any subsequent calls to Present().
- // Used for testing.
- 2: HACK_SetRendererParams(bool enable_clipping, vector<fuchsia.ui.gfx.RendererParam> params);
-
- // Set the input path. Root presenter will send to ViewManager (legacy) or Scenic.
- 3: HACK_SetInputPath(bool use_legacy);
-
- // Query the input path. Return true if ViewManager receives input.
- 4: HACK_QueryInputPath() -> (bool use_legacy);
-};
-
-// The Presenter service provides a way for applications to ask that a
-// specified view be added to a view tree, leaving any window management
-// concerns up to the discretion of the presenter implementation.
-//
-// TODO(SCN-595): this is the new presenter interface, which will be renamed
-// to Presenter after the original is deleted.
-[Discoverable]
-interface Presenter2 {
- // Usage: the client creates a pair of eventpairs and uses one to create a
- // View in their Scenic session. The other eventpair is passed to this
- // method as |view_holder_token|; the Presenter2 service will use this to
- // create a ViewHolder which is embedded within an appropriate Scenic scene,
- // such that the client View it will receive input events, etc.
- 1: PresentView(handle<eventpair> view_holder_token, request<Presentation>? presentation_request);
-};
diff --git a/fidl/fuchsia.ui.scenic/commands.fidl b/fidl/fuchsia.ui.scenic/commands.fidl
deleted file mode 100644
index 46c54f3..0000000
--- a/fidl/fuchsia.ui.scenic/commands.fidl
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.scenic;
-
-using fuchsia.ui.gfx;
-using fuchsia.ui.input;
-using fuchsia.ui.vectorial;
-using fuchsia.ui.views;
-
-union Command {
- fuchsia.ui.gfx.Command gfx;
- fuchsia.ui.vectorial.Command vectorial;
- fuchsia.ui.views.Command views;
- fuchsia.ui.input.Command input;
-};
diff --git a/fidl/fuchsia.ui.scenic/events.fidl b/fidl/fuchsia.ui.scenic/events.fidl
deleted file mode 100644
index f296622..0000000
--- a/fidl/fuchsia.ui.scenic/events.fidl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.scenic;
-
-using fuchsia.ui.input;
-using fuchsia.ui.gfx;
-
-union Event {
- fuchsia.ui.gfx.Event gfx;
- fuchsia.ui.input.InputEvent input;
- Command unhandled;
-};
diff --git a/fidl/fuchsia.ui.scenic/meta.json b/fidl/fuchsia.ui.scenic/meta.json
deleted file mode 100644
index 26d9f49..0000000
--- a/fidl/fuchsia.ui.scenic/meta.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "deps": [
- "fuchsia.images",
- "fuchsia.ui.gfx",
- "fuchsia.ui.input",
- "fuchsia.ui.vectorial",
- "fuchsia.ui.views",
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.ui.scenic/commands.fidl",
- "fidl/fuchsia.ui.scenic/events.fidl",
- "fidl/fuchsia.ui.scenic/scenic.fidl",
- "fidl/fuchsia.ui.scenic/session.fidl"
- ],
- "name": "fuchsia.ui.scenic",
- "root": "fidl/fuchsia.ui.scenic",
- "sources": [
- "fidl/fuchsia.ui.scenic/commands.fidl",
- "fidl/fuchsia.ui.scenic/events.fidl",
- "fidl/fuchsia.ui.scenic/scenic.fidl",
- "fidl/fuchsia.ui.scenic/session.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.scenic/scenic.fidl b/fidl/fuchsia.ui.scenic/scenic.fidl
deleted file mode 100644
index 74a88cc..0000000
--- a/fidl/fuchsia.ui.scenic/scenic.fidl
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.scenic;
-
-using fuchsia.images;
-using fuchsia.mem;
-using fuchsia.ui.gfx;
-
-// Scenic.TakeScreenshot() returns a raw BGRA formatted image in this struct.
-struct ScreenshotData {
- fuchsia.images.ImageInfo info;
- fuchsia.mem.Buffer data;
-};
-
-[Discoverable]
-interface Scenic {
- // Create a new Session, which is the primary way to interact with Mozart.
- 1: CreateSession(request<Session> session, SessionListener? listener);
-
- // Get information about the SceneManager's primary display.
- // TODO(MZ-453): in the future there will probably be a DisplayManager, and
- // info about which displays to use will be provided to the SceneManager.
- 2: GetDisplayInfo() -> (fuchsia.ui.gfx.DisplayInfo info);
- // Gets an event signaled with displayOwnedSignal or displayNotOwnedSignal
- // when display ownership changes.
- 3: GetDisplayOwnershipEvent() -> (handle<event> ownership_event);
-
- // Take a screenshot and return the data in |img_data|. |img_data| will
- // not contain BGRA data if |success| is false.
- // TODO(SCN-678): The permissions here are too wide (anyone can take a
- // screenshot), we should narrow them.
- 4: TakeScreenshot() -> (ScreenshotData img_data, bool success);
-};
-
-const uint32 displayOwnedSignal = 0x02000000;
-const uint32 displayNotOwnedSignal = 0x01000000;
diff --git a/fidl/fuchsia.ui.scenic/session.fidl b/fidl/fuchsia.ui.scenic/session.fidl
deleted file mode 100644
index a1dcdbf..0000000
--- a/fidl/fuchsia.ui.scenic/session.fidl
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.scenic;
-
-using fuchsia.images;
-using fuchsia.ui.gfx;
-
-// Client use Sessions to interact with a Mozart instance by enqueuing commands
-// that create or modify resources.
-interface Session {
- 1: Enqueue(vector<Command> cmds);
-
- // Present all previously enqueued operations. In order to pipeline the
- // preparation of the resources required to render the scene, two lists of
- // fences (implemented as events) are passed.
- //
- // SCHEDULING PRESENTATION
- //
- // |presentation_time| specifies the time on or after which the
- // client would like the enqueued operations should take visible effect
- // (light up pixels on the screen), expressed in nanoseconds in the
- // |CLOCK_MONOTONIC| timebase. Desired presentation times must be
- // monotonically non-decreasing.
- //
- // Using a desired presentation time in the present or past (such as 0)
- // schedules enqueued operations to take visible effect as soon as possible
- // (during the next frame to be prepared).
- //
- // Using a desired presentation time in the future schedules the enqueued
- // operations to take visible effect as closely as possible to or after
- // the stated time (but no earlier).
- //
- // Each rendered frame has a target presentation time. Before rendering
- // a frame, the scene manager applies all enqueued operations associated
- // with all prior calls to |Present()| whose desired presentation time
- // is on or before the frame's target presentation time.
- //
- // The |Present()| method does not return until the scene manager begins
- // preparing the first frame which includes its presented content.
- // Upon return, the |PresentationInfo| provides timing information for the
- // frame which includes the presented content.
- //
- // To present new content on each successive frame, wait for |Present()|
- // to return before calling |Present()| again with content for the next
- // frame.
- //
- // It is also possible to enqueue and present successive frames of content
- // all at once with increasing desired presentation times, incrementing by
- // |PresentationInfo.presentation_interval| for each one.
- //
- // Animation updates are also coordinated in terms of presentation time.
- //
- // TODO(jeffbrown): Defining presentation time in terms of |CLOCK_MONOTONIC|
- // simplifies synchronization across subsystems but it might be too simple.
- // We should consider using a synthetic timebase and describing its relation
- // to other clocks separately. That would make it possible to present
- // content (animations, media, and UI) in "slow mode" simply by varying the
- // timing relation, assuming clients play along.
- //
- // SYNCHRONIZATION
- //
- // |acquire_fences| are used by Mozart to wait until all of the session's
- // resources are ready to render (or to allow downstream components, such as
- // the Vulkan driver, to wait for these resources).
- //
- // For example, Fuchsia's Vulkan driver allows an zx::event to be obtained
- // from a VkSemaphore. This allows a Mozart client to submit a Vulkan command
- // buffer to generate images/meshes/etc., and instructing Vulkan to signal a
- // VkSemaphore when it is done. By inserting the zx::event corresponding to
- // this semaphore into |acquire_fences|, the client allows Mozart to submit work
- // to the Vulkan driver without waiting on the CPU for the event to be
- // signalled.
- //
- // |release_fences| is a list of events that will be signalled by Mozart when
- // the updated session state has been fully committed: future frames will be
- // rendered using this state, and all frames generated using previous session
- // states have been fully-rendered and presented to the display.
- //
- // Together, |acquire_fences| and |release_fences| are intended to allow clients
- // to implement strategies such as double-buffering. For example, a client
- // might do the following in the Scenic subsystem:
- // 1) create two Image with resource IDs #1 and #2.
- // 2) create two Materials with resource IDs #3 and #4, which respectively
- // use Images #1 and #2 as their texture.
- // 3) create a tree of Nodes and attach them to the scene.
- // 4) set one of the nodes above, say #5, to use Material #3.
- // 5) submit a Vulkan command-buffer which renders into Image #1, and
- // will signal a VkSemaphore.
- // 6) call Present() with one acquire-fence (obtained from the VkSemaphore
- // above) and one newly-created release-fence.
- //
- // After the steps above, Mozart will use the committed session state to render
- // frames whenever necessary. When the client wants to display something
- // different than Image #1, it would do something similar to steps 4) to 6):
- // 7) set Node #5 to use Material #4.
- // 8) submit a Vulkan command-buffer which renders into Image #1, and
- // will signal a VkSemaphore.
- // 9) call Present() with one acquire-fence (obtained from the VkSemaphore
- // above) and one newly-created release-fence.
- //
- // Finally, to continually draw new content, the client could repeat steps
- // 4) to 9), with one important difference: step 5) must wait on the event
- // signalled by step 9). Otherwise, it might render into Image #1 while that
- // image is still being used by Mozart to render a frame. Similarly, step 8)
- // must wait on the event signalled by step 6).
- //
- // The scenario described above uses one acquire-fence and one release-fence,
- // but it is easy to imagine cases that require more. For example, in addition
- // to using Vulkan to render into Images #1 and #2, the client might also
- // upload other resources to Vulkan on a different VkQueue, which would
- // would signal a separate semaphore, and therefore require an additional
- // acquire-fence.
- //
- // Note: |acquire_fences| and |release_fences| are only necessary to synchronize
- // access to memory (and other external resources). Any modification to
- // resources made via the Session API are automatically synchronized.
- //
- // TODO(MZ-400): document invariants that apply to |presentation_info|. Is it
- // strong enough to guarantee that receiving the response means that all
- // previously-enqueued Commands have been applied? Or does it need to be stronger,
- // e.g. that all frames based on previous presentations are completely done,
- // and subsequent frames will be rendered based on the most recent presented
- // content?
- 2: Present(uint64 presentation_time,
- vector<handle<event>> acquire_fences, vector<handle<event>> release_fences)
- -> (fuchsia.images.PresentationInfo presentation_info);
-
- // TODO(MZ-422) Remove these methods from the FIDL; they should just be
- // exposed to View Manager directly using a C++ interface.
- 3: HitTest(uint32 node_id, fuchsia.ui.gfx.vec3 ray_origin, fuchsia.ui.gfx.vec3 ray_direction)
- -> (vector<fuchsia.ui.gfx.Hit>? hits);
- 4: HitTestDeviceRay(fuchsia.ui.gfx.vec3 ray_origin, fuchsia.ui.gfx.vec3 ray_direction)
- -> (vector<fuchsia.ui.gfx.Hit>? hits);
-
- // Set an optional debug name for the session. The debug name will be
- // output in things such as logging and trace events.
- 5: SetDebugName(string debug_name);
-};
-
-// Listens for events which occur within the session.
-interface SessionListener {
- // Called when an error has occurred and the session will be torn down.
- 1: OnScenicError(string error);
-
- // Called to deliver a batch of one or more events to the listener.
- // Use |SetEventMaskCmd| to enable event delivery for a resource.
- 2: OnScenicEvent(vector<Event> events);
-};
diff --git a/fidl/fuchsia.ui.vectorial/commands.fidl b/fidl/fuchsia.ui.vectorial/commands.fidl
deleted file mode 100644
index 7067240..0000000
--- a/fidl/fuchsia.ui.vectorial/commands.fidl
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.vectorial;
-
-union Command {
- bool placeHolder;
-};
diff --git a/fidl/fuchsia.ui.vectorial/events.fidl b/fidl/fuchsia.ui.vectorial/events.fidl
deleted file mode 100644
index 14fddb0..0000000
--- a/fidl/fuchsia.ui.vectorial/events.fidl
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.vectorial;
-
-union Event {
- bool placeHolder;
-};
diff --git a/fidl/fuchsia.ui.vectorial/meta.json b/fidl/fuchsia.ui.vectorial/meta.json
deleted file mode 100644
index 4bd6fc0..0000000
--- a/fidl/fuchsia.ui.vectorial/meta.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.ui.vectorial/commands.fidl",
- "fidl/fuchsia.ui.vectorial/events.fidl"
- ],
- "name": "fuchsia.ui.vectorial",
- "root": "fidl/fuchsia.ui.vectorial",
- "sources": [
- "fidl/fuchsia.ui.vectorial/commands.fidl",
- "fidl/fuchsia.ui.vectorial/events.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.views/commands.fidl b/fidl/fuchsia.ui.views/commands.fidl
deleted file mode 100644
index f138081..0000000
--- a/fidl/fuchsia.ui.views/commands.fidl
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.views;
-
-union Command {
- CreateViewCmd create_view;
- CreateViewHolderCmd create_view_holder;
-
- AddChildViewCmd add_child_view;
- RemoveChildViewCmd remove_child_view;
-};
-
-struct CreateViewCmd {
- uint32 id;
- handle<eventpair> token;
-};
-
-struct CreateViewHolderCmd {
- uint32 id;
- handle<eventpair> token;
-};
-
-struct AddChildViewCmd {
- uint32 view_id;
- uint32 view_holder_id;
-};
-
-struct RemoveChildViewCmd {
- uint32 view_id;
- uint32 view_holder_id;
-};
diff --git a/fidl/fuchsia.ui.views/events.fidl b/fidl/fuchsia.ui.views/events.fidl
deleted file mode 100644
index f737e57..0000000
--- a/fidl/fuchsia.ui.views/events.fidl
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.views;
-
-using fuchsia.ui.gfx;
-
-union Event {
- ChildViewAttachedEvent child_view_attached;
- ChildViewUnavailableEvent child_view_unavailable;
-};
-
-// Called when a child view is attached.
-struct ChildViewAttachedEvent {
- uint32 view_holder_id;
-};
-
-// Called when a child view has become unavailable.
-//
-// A child may become unavailable for many reasons such being unregistered
-// by its application, abnormal termination of its application, or
-// cycles being introduced in the view tree.
-//
-// To complete removal of an unavailable child, this view component must
-// call RemoveChild() on its view with |child_key|.
-//
-// The implementation should invoke the callback once the event has
-// been handled.
-struct ChildViewUnavailableEvent {
- uint32 view_holder_id;
-};
diff --git a/fidl/fuchsia.ui.views/meta.json b/fidl/fuchsia.ui.views/meta.json
deleted file mode 100644
index 2408d9a..0000000
--- a/fidl/fuchsia.ui.views/meta.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "deps": [
- "fuchsia.sys",
- "fuchsia.math",
- "fuchsia.ui.gfx",
- "fuchsia.ui.input"
- ],
- "files": [
- "fidl/fuchsia.ui.views/commands.fidl",
- "fidl/fuchsia.ui.views/events.fidl"
- ],
- "name": "fuchsia.ui.views",
- "root": "fidl/fuchsia.ui.views",
- "sources": [
- "fidl/fuchsia.ui.views/commands.fidl",
- "fidl/fuchsia.ui.views/events.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl b/fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl
deleted file mode 100644
index 6dc7c77..0000000
--- a/fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.ui.gfx;
-using fuchsia.ui.scenic;
-using fuchsia.math;
-
-// This is a temporary solution to expose hit testing to the accessibility manager before the
-// scenic refactor.
-// TODO(SCN-845) A new hit test API will be exposed after the refactor.
-//
-// DO NOT USE!
-
-[Discoverable]
-interface AccessibilityViewInspector {
- // Provides a FIDL interface to expose the hit test mechanism from view manager.
- 1: PerformHitTest(ViewTreeToken token, fuchsia.math.Point3F origin,
- fuchsia.math.Point3F direction) -> (vector<fuchsia.ui.gfx.Hit> hits);
-};
diff --git a/fidl/fuchsia.ui.viewsv1/meta.json b/fidl/fuchsia.ui.viewsv1/meta.json
deleted file mode 100644
index 8726e16..0000000
--- a/fidl/fuchsia.ui.viewsv1/meta.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "deps": [
- "fuchsia.math",
- "fuchsia.sys",
- "fuchsia.ui.gfx",
- "fuchsia.ui.scenic",
- "fuchsia.ui.viewsv1token",
- "fuchsia.mem"
- ],
- "files": [
- "fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl",
- "fidl/fuchsia.ui.viewsv1/view_containers.fidl",
- "fidl/fuchsia.ui.viewsv1/view_manager.fidl",
- "fidl/fuchsia.ui.viewsv1/view_properties.fidl",
- "fidl/fuchsia.ui.viewsv1/view_provider.fidl",
- "fidl/fuchsia.ui.viewsv1/view_snapshot.fidl",
- "fidl/fuchsia.ui.viewsv1/view_tree_token.fidl",
- "fidl/fuchsia.ui.viewsv1/view_trees.fidl",
- "fidl/fuchsia.ui.viewsv1/views.fidl"
- ],
- "name": "fuchsia.ui.viewsv1",
- "root": "fidl/fuchsia.ui.viewsv1",
- "sources": [
- "fidl/fuchsia.ui.viewsv1/accessibility_view_inspector.fidl",
- "fidl/fuchsia.ui.viewsv1/view_containers.fidl",
- "fidl/fuchsia.ui.viewsv1/view_manager.fidl",
- "fidl/fuchsia.ui.viewsv1/view_properties.fidl",
- "fidl/fuchsia.ui.viewsv1/view_provider.fidl",
- "fidl/fuchsia.ui.viewsv1/view_snapshot.fidl",
- "fidl/fuchsia.ui.viewsv1/view_tree_token.fidl",
- "fidl/fuchsia.ui.viewsv1/view_trees.fidl",
- "fidl/fuchsia.ui.viewsv1/views.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.viewsv1/view_containers.fidl b/fidl/fuchsia.ui.viewsv1/view_containers.fidl
deleted file mode 100644
index 9c44d8c..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_containers.fidl
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.mem;
-
-using fuchsia.ui.viewsv1token;
-
-// A view container is an interface exposed by |View| and |ViewTree| to
-// manage their child views. Although |View| may have any number of children,
-// a |ViewTree| can have at most one (its root view).
-//
-// EMBEDDING
-//
-// The following steps are required to embed another view as a child:
-//
-// 1. Obtain the |ViewOwner| belonging to the view you would like to embed.
-// The means for doing this is not specified by the view system.
-// You might create another view of your own to embed or connect to
-// another application using a mechanism such as |ViewProvider| (or
-// any suitable agreed-upon protocol) to create the view to embed.
-//
-// 2. Call |AddChild()| to add the view you would like to embed and assign
-// it a unique key.
-//
-// 3. Call |SetChildProperties()| to provide layout parameters and other
-// properties for the new child using the same key that was provided
-// to |AddChild()|.
-//
-// 4. Watch for the child becoming unavailable, as reported by
-// |OnChildUnavailable()|, which indicates that the child is no longer
-// in a usable state (perhaps the application which provided it has
-// stopped). When this happens, you are still responsible for calling
-// |RemoveChild()| to remove the child and discard any state that your
-// view has associated with it.
-//
-// VIEW PROPERTIES AND LAYOUT
-//
-// The container controls the presentation of its children by setting
-// |ViewProperties| for each of them. View properties include layout
-// information and other parameters the child needs to know to participate
-// in the view hierarchy.
-//
-// The container must set properties for each of its children after adding
-// them, as otherwise the children cannot be rendered (since they lack enough
-// context to know what to draw).
-interface ViewContainer {
- // Sets the view container listener, or null to remove.
- 1: SetListener(ViewContainerListener? listener);
-
- // Adds the view referenced by |child_view_owner| as a child and assigns
- // it the provided |child_key| to identify it among its children.
- // The container may remove the child later by passing the same |child_key|
- // to |RemoveChild()|.
- //
- // This method takes ownership of the view.
- //
- // It is important for the container to choose locally unique values for
- // |child_key| to ensure that each child can be distinguished even as
- // more children are added or removed. We recommend using a simple
- // counter which is incremented on each (re-)addition.
- //
- // If the child becomes unavailable at any time prior to being removed
- // then an |OnChildUnavailable()| message will be sent.
- //
- // If |child_view_owner| refers to a view which is already unavailable or
- // if adding the view would create a cycle in the view tree then the
- // call proceeds as if it succeeded but an |OnChildUnavailable()| message
- // will be sent.
- //
- // If |child_view_owner| refers to a view which already has a container or is
- // the root of a view tree then an |OnChildUnavailable()| message will
- // be sent to its old container or root and the the view will be
- // (re-)added to its new container as usual. This special case also
- // applies when the specified view is already a child of this view, in which
- // case the behavior is similar to the view having been transferred to
- // some other container and then back again.
- //
- // Note that an unavailable child will remain in its container's list of
- // children until its container explicitly calls |RemoveChild()| to remove
- // it.
- //
- // |host_import_token| is an import token which the view manager will
- // use to import the node to which the child view's content should
- // be attached.
- //
- // To establish the graphical embedding relation, the container view
- // must create an event pair, bind one endpoint to an |ExportResourceOp|
- // associated with the node to which the child's content nodes will be
- // attached as descendants, and pass the other endpoint to this method as
- // |host_import_token|.
- //
- // It is an error to add a view whose |child_key| already appears
- // in the view's list of children; the connection will be closed.
- //
- // It is an error to add more than one child to a |ViewTree|'s container;
- // it can only have at most one child (its root).
- //
- // This method is deprecated in favor of the eventpair-based one below.
- // TODO(SCN-1018): Remove this.
- 2: AddChild(uint32 child_key,
- fuchsia.ui.viewsv1token.ViewOwner child_view_owner,
- handle<eventpair> host_import_token);
-
- 3: AddChild2(uint32 child_key,
- handle<eventpair> view_holder_token,
- handle<eventpair> host_import_token);
-
- // Removes the view referenced by |child_key| from the view's
- // list of children.
- //
- // If |transferred_view_owner| is not null, associates it with the
- // previously added child to allow it to be transferred elsewhere or
- // closes the |transferred_view_owner| channel if there was none.
- //
- // It is an error to remove a view whose |child_key| does not appear
- // in the container's list of children; the connection will be closed.
- //
- // This method is deprecated in favor of the eventpair-based one below.
- // TODO(SCN-1018): Remove this.
- 4: RemoveChild(uint32 child_key,
- request<fuchsia.ui.viewsv1token.ViewOwner>? transferred_view_owner);
-
- 5: RemoveChild2(uint32 child_key,
- handle<eventpair>? transferred_view_holder_token);
-
- // Sets view properties for the child, such as layout constraints.
- //
- // This method must be called at least once after a child is added to
- // set the view's properties before it can be rendered. Rendering for
- // children without properties is blocked until properties are set.
- //
- // The |child_view_properties| specifies the properties for the child, or
- // null to remove the properties from the child which will cause rendering
- // of the child's scene to be blocked until new properties are set.
- //
- // It is an error to specify a |child_key| that does not appear in
- // the container's list of children; the connection will be closed.
- //
- // It is an error to specify malformed |child_view_properties| such
- // as invalid layout properties; the connection will be closed.
- 6: SetChildProperties(uint32 child_key, ViewProperties? child_view_properties);
-
- // WIP API
- // Sends a hint about a pending size change to the given node and all nodes
- // below. This is generally sent before an animation.
- //
- // |width_change_factor| and |height_change_factor| is how much bigger or smaller
- // the item is expected to be in the near future. This one number encapsulate
- // both changes in scale, as well as changes to layout width and height.
- //
- // It is an error to specify a |child_key| that does not appear in
- // the container's list of children; the connection will be closed.
- //
- 7: SendSizeChangeHintHACK(uint32 child_key, float32 width_change_factor,
- float32 height_change_factor);
-
- // Request the child view to get input focus for key events.
- 8: RequestFocus(uint32 child_key);
-
- // Request the snapshot of the child view.
- 9: RequestSnapshotHACK(uint32 child_key)-> (fuchsia.mem.Buffer data);
-};
-
-// An interface clients may implement to receive events from a view container.
-interface ViewContainerListener {
- // Called when a child view is attached along with embedding information.
- //
- // This method will be called at most once after the child is added.
- //
- // The implementation should invoke the callback once the event has
- // been handled.
- 1: OnChildAttached(uint32 child_key, ViewInfo child_view_info) -> ();
-
- // Called when a child view has become unavailable.
- //
- // A child may become unavailable for many reasons such being unregistered
- // by its application, abnormal termination of its application, or
- // cycles being introduced in the view tree.
- //
- // To complete removal of an unavailable child, this view component must
- // call RemoveChild() on its view with |child_key|.
- //
- // The implementation should invoke the callback once the event has
- // been handled.
- 2: OnChildUnavailable(uint32 child_key) -> ();
-
- // TODO(jeffbrown): Once we figure out measurement, add a |OnChildResized|
- // event or similar to allow the container to get the size along with the
- // scene version.
-};
-
-// Provides embedding information about a view for use by its container.
-//
-// This information is valid until the container removes the view.
-struct ViewInfo {
- // There is currently no information here but we have preserved the
- // plumbing for now. May remove later.
- uint8 dummy;
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_manager.fidl b/fidl/fuchsia.ui.viewsv1/view_manager.fidl
deleted file mode 100644
index 5013d8b..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_manager.fidl
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.ui.scenic;
-using fuchsia.ui.viewsv1token;
-
-// Maximum length for a view or view tree label.
-const uint32 kLabelMaxLength = 32;
-
-// The view manager manages trees of views which represent user interface
-// components.
-//
-// Applications create views to describe user interface components
-// to present content to the user and support user interaction.
-//
-// The system creates a view tree to hold the root of a view hierarchy
-// containing views from various applications.
-//
-// Refer to |View| and |ViewTree| for more information about these objects.
-[Discoverable]
-interface ViewManager {
-
- // Gets the scenic instance associated with this view manager.
- // All graphical content for this view manager's views and view trees
- // must come from sessions created by this |scenic| instance.
- 1: GetScenic(request<fuchsia.ui.scenic.Scenic> scenic);
-
- // Creates a view.
- //
- // The |view| is used to configure the view and interact with its
- // local environment.
- //
- // The |view_owner| is used as a transferable reference which can
- // be passed to the view's intended container as part of a request to
- // add the view as a child. The view manager itself does not describe
- // how this interaction should take place, only that ownership should
- // eventually be passed back through the container's view interface
- // as an argument to |View.AddChild()|.
- //
- // The |view_listener| is used to receive events from the view.
- //
- // The |label| is an optional name to associate with the view for
- // diagnostic purposes. The label will be truncated if it is longer
- // than |kLabelMaxLength|.
- //
- // |parent_export_token| is an export token which the view manager
- // will use to export the node to which the view's content should be
- // attached.
- //
- // To present graphical content, the view must obtain a |Session| from
- // |Mozart|, create an event pair, bind one endpoint to an
- // |ImportResourceOp| using |ImportSpec.NODE|, attach its content nodes as
- // descendants of the imported node, and pass the other endpoint of the
- // event pair to this method as |parent_export_token|.
- //
- // To destroy the view and cause it to be removed from the view tree,
- // simply close the |view|, |view_listener|, or |view_owner| channels.
- //
- // This method is deprecated in favor of the eventpair-based one below.
- // TODO(SCN-1018): Remove this.
- 2: CreateView(request<View> view,
- request<fuchsia.ui.viewsv1token.ViewOwner> view_owner,
- ViewListener view_listener,
- handle<eventpair> parent_export_token,
- string? label);
-
- 3: CreateView2(request<View> view,
- handle<eventpair> view_token,
- ViewListener view_listener,
- handle<eventpair> parent_export_token,
- string? label);
-
- // Creates a view tree.
- //
- // The |view_tree| is used to configure the view tree and interact
- // with the views it contains.
- //
- // The |view_tree_listener| is used to receive events from the view tree.
- //
- // The |label| is an optional name to associate with the view tree for
- // diagnostic purposes. The label will be truncated if it is longer
- // than |kLabelMaxLength|.
- //
- // To destroy the view tree simply close the |view_tree| or
- // |view_tree_listener| channels.
- 4: CreateViewTree(request<ViewTree> view_tree,
- ViewTreeListener view_tree_listener,
- string? label);
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_properties.fidl b/fidl/fuchsia.ui.viewsv1/view_properties.fidl
deleted file mode 100644
index 3d106a1..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_properties.fidl
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.math;
-
-// Parameters and contextual information for a view provided by its container.
-//
-// When a container sets properties for its children, any properties which
-// are set to null are inherited from the container's own ancestors.
-struct ViewProperties {
- ViewLayout? view_layout;
- CustomFocusBehavior? custom_focus_behavior;
-};
-
-struct CustomFocusBehavior {
- bool allow_focus = true;
-};
-
-// Provides layout constraints for a view.
-//
-// TODO(jeffbrown): Decide how measurement should be performed. Perhaps
-// bring back |BoxConstraints| or introduce some other protocol just for
-// measurement.
-struct ViewLayout {
- // The size of the view in logical pixels.
- // Must be non-negative.
- fuchsia.math.SizeF size;
-
- // The inset of the view in logical pixels.
- // Must be non-negative.
- fuchsia.math.InsetF inset;
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_provider.fidl b/fidl/fuchsia.ui.viewsv1/view_provider.fidl
deleted file mode 100644
index 0545653..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_provider.fidl
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.sys;
-using fuchsia.ui.viewsv1token;
-
-// Provides a View upon request.
-//
-// Applications should implement and expose this service so that they can
-// expose views to be embedded into other applications.
-[Discoverable]
-interface ViewProvider {
- // Creates and registers a view with the view manager and returns its
- // view owner which may subsequently be passed to |View.AddChild()|
- // to attach the view to a view hierarchy.
- //
- // Implementors of this interface are responsible for creating the view
- // and forwarding the |view_owner| interface request to
- // |ViewManager.CreateView()|.
- //
- // The caller may request services from the created view via the |services|
- // service provider.
- 1: CreateView(request<fuchsia.ui.viewsv1token.ViewOwner> view_owner,
- request<fuchsia.sys.ServiceProvider>? services);
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_snapshot.fidl b/fidl/fuchsia.ui.viewsv1/view_snapshot.fidl
deleted file mode 100644
index a5100d4..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_snapshot.fidl
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.ui.viewsv1token;
-using fuchsia.mem;
-
-// Defines an interface to take view snapshots.
-[Discoverable]
-interface ViewSnapshot {
- // TODO(SCN-1019): Use zx::eventpair instead of koid.
- // Takes a snapshot of a view and returns it in a callback.
- //
- // The |view_koid| identifies the view whose snapshot needs to be taken.
- //
- // The callback is invoked with the VMO buffer containing the snapshot.
- // If successful, the buffer size is non-zero, otherwise it is 0.
- 1: TakeSnapshot(uint64 view_koid) ->
- (fuchsia.mem.Buffer snapshot);
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_tree_token.fidl b/fidl/fuchsia.ui.viewsv1/view_tree_token.fidl
deleted file mode 100644
index 3fb8a7a..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_tree_token.fidl
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-// A view tree token is an opaque transferable reference to a view tree.
-//
-// The ViewManager provides each view tree with a unique view tree token when
-// it is registered. The token can subsequently be passed to other
-// applications and used as a way to refer to the tree.
-//
-// View tree tokens should be kept secret and should only be shared with
-// trusted services.
-//
-// TODO(jeffbrown): This implementation is a temporary placeholder until
-// we provide a way to create tokens which cannot be forged.
-struct ViewTreeToken {
- uint32 value;
-};
diff --git a/fidl/fuchsia.ui.viewsv1/view_trees.fidl b/fidl/fuchsia.ui.viewsv1/view_trees.fidl
deleted file mode 100644
index 7a159bf..0000000
--- a/fidl/fuchsia.ui.viewsv1/view_trees.fidl
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.sys;
-
-// A view tree is a top-level container for a hierarchy of views.
-// Each view is intended to operate independently from others and will
-// generally correspond to discrete interactive spaces such as separate
-// displays or isolated environments in a multi-user system.
-//
-// Within a view tree, certain global invariants may be enforced such as
-// ensuring that only one view has focus at a time.
-//
-// View trees will typically be created by system components responsible
-// for managing the overall user interface rather than end-user applications.
-//
-// LIFECYCLE
-//
-// Use |ViewManager.CreateViewTree()| to create a view tree. The client
-// uses the |ViewTree| interface to manage the view tree's content
-// and implements the |ViewTreeListener| interface to handle events.
-//
-// To destroy a view tree, simply close the |ViewTree| channel.
-//
-// SETTING A ROOT VIEW
-//
-// Use |GetContainer()| to obtain an interface for manipulating the root view.
-//
-// See |ViewContainer| for more information.
-//
-// GETTING SERVICES
-//
-// The view tree's |fuchsia::sys::ServiceProvider| offers access to many services
-// which are not directly expressed by the |ViewTree| interface itself, such
-// as input, accessiblity, and editing capabilities.
-//
-// For example, perform the following actions to dispatch input events:
-//
-// 1. Call |GetServiceProvider()| to obtain the view's service provider.
-//
-// 2. Ask the service provider for its |InputDispatcher|.
-//
-// 3. Send input events to the dispatcher for delivery to views.
-interface ViewTree {
- // Gets the view tree's token.
- 1: GetToken() -> (ViewTreeToken token);
-
- // Gets a service provider to access services which are associated with
- // the view tree such as input, accessibility and editing capabilities.
- // The view tree service provider is private to the view tree and should
- // not be shared with anyone else.
- //
- // See |InputDispatcher|.
- 2: GetServiceProvider(request<fuchsia.sys.ServiceProvider> service_provider);
-
- // Gets an interface for managing the view tree's root.
- 3: GetContainer(request<ViewContainer> container);
-};
-
-// An interface clients may implement to receive events from a view tree.
-interface ViewTreeListener {
- // There are currently no events defined but we have preserved the
- // plumbing for the future when ViewContainer will merge into ViewTree
- // along with its listener.
-};
diff --git a/fidl/fuchsia.ui.viewsv1/views.fidl b/fidl/fuchsia.ui.viewsv1/views.fidl
deleted file mode 100644
index 09cc345..0000000
--- a/fidl/fuchsia.ui.viewsv1/views.fidl
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1;
-
-using fuchsia.sys;
-using fuchsia.ui.viewsv1token;
-
-// A view is a graphical user interface component which is responsible
-// for drawing and supporting user interactions in the area of the screen
-// that it occupies.
-//
-// A view may also act as a container for other views (known as the
-// view's children) which it may freely layout and position anywhere
-// within its bounds to form a composite user interface. The hierarchy
-// of views thus formed is called a view tree.
-//
-// LIFECYCLE
-//
-// Use |ViewManager.CreateView()| to create a view. The application
-// uses the |View| interface to manage the view's content and implements
-// the |ViewListener| interface to handle events.
-//
-// To destroy a view, simply close the |View| channel.
-//
-// ADDING CHILD VIEWS
-//
-// Use |GetContainer()| to obtain an interface for manipulating child views.
-//
-// See |ViewContainer| for more information.
-//
-// GETTING SERVICES
-//
-// The view's |fuchsia::sys::ServiceProvider| offers access to many services which
-// are not directly expressed by the |View| interface itself, such
-// as input, accessiblity, and editing capabilities.
-//
-// For example, perform the following actions to receive input events:
-//
-// 1. Call |GetServiceProvider()| to obtain the view's service provider.
-//
-// 2. Ask the service provider for its |InputConnection|.
-//
-// 3. Set listeners on the input connection to receive events.
-interface View {
- // Gets a service provider to access services which are associated with
- // the view such as input, accessibility and editing capabilities.
- // The view service provider is private to the view and should not be
- // shared with anyone else.
- //
- // See |InputConnection|.
- 1: GetServiceProvider(request<fuchsia.sys.ServiceProvider> service_provider);
-
- // This is a way for an app to offer services that are associated with a
- // particular view. Used to expose services to the compositor
- //
- // In particular this should be used to let know which view is implementing
- // the ability to show an IME
- //
- // |service_names| should contain a list of service names as defined with the
- // FIDL syntax [Discoverable]
- //
- // The list of services will be used by the compositor to filter service
- // providers when looking for a particular service.
- 2: OfferServiceProvider(fuchsia.sys.ServiceProvider service_provider,
- vector<string> service_names);
-
- // Gets an interface for managing the view's children.
- 3: GetContainer(request<ViewContainer> container);
-};
-
-// An interface clients may implement to receive events from a view.
-interface ViewListener {
- // Called when the view receives new properties from its ancestors.
- // Initially the view has no properties so this method will be called
- // as soon as properties first become available and whenever they change
- // thereafter.
- 1: OnPropertiesChanged(ViewProperties properties) -> ();
-};
diff --git a/fidl/fuchsia.ui.viewsv1token/meta.json b/fidl/fuchsia.ui.viewsv1token/meta.json
deleted file mode 100644
index 37151df..0000000
--- a/fidl/fuchsia.ui.viewsv1token/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.ui.viewsv1token/view_token.fidl"
- ],
- "name": "fuchsia.ui.viewsv1token",
- "root": "fidl/fuchsia.ui.viewsv1token",
- "sources": [
- "fidl/fuchsia.ui.viewsv1token/view_token.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.ui.viewsv1token/view_token.fidl b/fidl/fuchsia.ui.viewsv1token/view_token.fidl
deleted file mode 100644
index 005b36b..0000000
--- a/fidl/fuchsia.ui.viewsv1token/view_token.fidl
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.ui.viewsv1token;
-
-// A view owner allows linking its associated view into a view hierarchy.
-//
-// This interface is only intended to be used as a token, analogous to how
-// Scenic View/ViewHolder resources use eventpairs as tokens.
-interface ViewOwner {};
diff --git a/fidl/fuchsia.wlan.minstrel/meta.json b/fidl/fuchsia.wlan.minstrel/meta.json
deleted file mode 100644
index 544ee40..0000000
--- a/fidl/fuchsia.wlan.minstrel/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl"
- ],
- "name": "fuchsia.wlan.minstrel",
- "root": "fidl/fuchsia.wlan.minstrel",
- "sources": [
- "fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl b/fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl
deleted file mode 100644
index 7e1cbd1..0000000
--- a/fidl/fuchsia.wlan.minstrel/wlan_minstrel.fidl
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.wlan.minstrel;
-
-struct Peers {
- vector<array<uint8>:6> peers;
-};
-
-// LINT.IfChange
-struct StatsEntry {
- uint16 tx_vector_idx;
- string tx_vec_desc;
- uint64 success_cur;
- uint64 attempts_cur;
- float32 probability;
- float32 cur_tp;
- uint64 success_total;
- uint64 attempts_total;
- uint64 probes_total;
-};
-
-struct Peer {
- array<uint8>:6 mac_addr;
- uint16 max_tp;
- uint16 max_probability;
- uint16 basic_highest;
- uint16 basic_max_probability;
- uint64 probes;
- vector<StatsEntry> entries;
-};
-// LINT.ThenChange(//garnet/drivers/wlan/wlan/minstrel.h)
diff --git a/fidl/fuchsia.wlan.mlme/meta.json b/fidl/fuchsia.wlan.mlme/meta.json
deleted file mode 100644
index 58c5962..0000000
--- a/fidl/fuchsia.wlan.mlme/meta.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "deps": [
- "fuchsia.wlan.stats",
- "fuchsia.wlan.minstrel"
- ],
- "files": [
- "fidl/fuchsia.wlan.mlme/wlan_mlme.fidl",
- "fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl"
- ],
- "name": "fuchsia.wlan.mlme",
- "root": "fidl/fuchsia.wlan.mlme",
- "sources": [
- "fidl/fuchsia.wlan.mlme/wlan_mlme.fidl",
- "fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.wlan.mlme/wlan_mlme.fidl b/fidl/fuchsia.wlan.mlme/wlan_mlme.fidl
deleted file mode 100644
index 0f731c0..0000000
--- a/fidl/fuchsia.wlan.mlme/wlan_mlme.fidl
+++ /dev/null
@@ -1,934 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.wlan.mlme;
-
-// Stub types for communicating between the wlan service and the MLME drivers. Based on the 802.11
-// MLME SAP interface (IEEE Std 802.11-2016 section 6.3).
-
-// TODO(NET-631): restore the commented out enum aliases
-
-// MLME-SCAN.request (IEEE Std 802.11-2016 6.3.3.2)
-
-enum BSSTypes {
- INFRASTRUCTURE = 1;
- PERSONAL = 2;
- INDEPENDENT = 3;
- MESH = 4;
- ANY_BSS = 5;
- //LAST = ANY_BSS;
-};
-
-enum ScanTypes {
- ACTIVE = 1;
- PASSIVE = 2;
- //LAST = PASSIVE;
-};
-
-// LINT analyzer keyword intended for humans:
-// LINT.IfChange
-
-enum PHY {
- HR = 1; // IEEE 802.11b, used for DSSS, HR/DSSS, ERP-DSSS/CCK
- ERP = 2; // IEEE 802.11a/g, used for ERP-OFDM
- HT = 3; // IEEE 802.11n
- VHT = 4; // IEEE 802.11ac
- HEW = 5; // IEEE 802.11ax
-};
-
-enum CBW { // Channel Bandwidth
- CBW20 = 0;
- CBW40 = 1;
- //CBW40ABOVE = CBW40;
- CBW40BELOW = 2;
- CBW80 = 3;
- CBW160 = 4;
- CBW80P80 = 5;
-
- CBW_COUNT = 6;
-};
-
-struct WlanChan {
- uint8 primary;
- CBW cbw;
- uint8 secondary80;
-};
-
-enum Band : uint8 {
- WLAN_BAND_2GHZ = 0;
- WLAN_BAND_5GHZ = 1;
- WLAN_BAND_COUNT = 2;
-};
-
-// LINT.ThenChange(//garnet/lib/wlan/protocol/include/wlan/protocol/info.h)
-
-struct ScanRequest {
- uint64 txn_id;
- BSSTypes bss_type;
- array<uint8>:6 bssid;
- vector<uint8>:32 ssid;
- ScanTypes scan_type;
- uint32 probe_delay; // in TimeUnits
- vector<uint8>? channel_list;
- uint32 min_channel_time; // in TimeUnits
- uint32 max_channel_time; // in TimeUnits
- // RequestInformation
- vector<vector<uint8>:32>? ssid_list;
- // ChannelUsage
- // AccessNetworkType
- // HESSID
- // Mesh ID
- // DiscoveryMode
- // VendorSpecificInfo
-};
-
-
-// MLME-SCAN.confirm (IEEE Std 802.11-2016 6.3.3.3)
-
-// IEEE Std 802.11-2016, 9.4.1.4
-struct CapabilityInfo {
- bool ess;
- bool ibss;
- bool cf_pollable;
- bool cf_poll_req;
- bool privacy;
- bool short_preamble;
- bool spectrum_mgmt;
- bool qos;
- bool short_slot_time;
- bool apsd;
- bool radio_msmt;
- bool delayed_block_ack;
- bool immediate_block_ack;
-};
-
-// IEEE Std 802.11-2016, 9.4.2.56
-
-enum ChanWidthSet : uint8 {
- TWENTY_ONLY = 0;
- TWENTY_FORTY = 1;
-};
-
-enum SmPowerSave : uint8 {
- STATIC = 0;
- DYNAMIC = 1;
- RESERVED = 2;
- DISABLED = 3;
-};
-
-enum MaxAmsduLen : uint8 {
- OCTETS_3839 = 0;
- OCTETS_7935 = 1;
-};
-
-struct HtCapabilityInfo {
- bool ldpc_coding_cap;
- uint8 chan_width_set; // see enum ChanWidthSet
- uint8 sm_power_save; // see enum SmPowerSave
- bool greenfield;
- bool short_gi_20;
- bool short_gi_40;
- bool tx_stbc;
- uint8 rx_stbc;
- bool delayed_block_ack;
- uint8 max_amsdu_len; // see enum MaxAmsduLen
- bool dsss_in_40;
- bool intolerant_40;
- bool lsig_txop_protect;
-};
-
-enum MinMpduStartSpacing : uint8 {
- NO_RESTRICT = 0;
- QUARTER_USEC = 1;
- HALF_USEC = 2;
- ONE_USEC = 3;
- TWO_USEC = 4;
- FOUR_USEC = 5;
- EIGHT_USEC = 6;
- SIXTEEN_USEC = 7;
-};
-
-struct AmpduParams {
- uint8 exponent;
- uint8 min_start_spacing; // see enum MinMpduStartSpacing
-};
-
-// SupportedMcsSet
-// IEEE Std 802.11-2016, 9.4.2.56.4 Table 9-164
-struct SupportedMcsSet {
- // Names are deviated from //garnet/lib/wlan/common/include/wlan/common/element.h's class SupportedMcsSet
- uint64 rx_mcs_set; // bitmask indicating MCS 0-63 support
- // MCS 64-76 not supported
- uint16 rx_highest_rate; // Mbps
- bool tx_mcs_set_defined;
- bool tx_rx_diff;
- uint8 tx_max_ss; // Actual count, different from IEEE spec
- bool tx_ueqm; // Transmit Unequal Modulation
-};
-
-// HtExtCapabilities
-// IEEE Std 802.11-2016, 9.4.2.56.5 Table 9-165
-enum PcoTransitionTime : uint8 {
- PCO_RESERVED = 0; // Often translated as "No transition".
- PCO_400_USEC = 1;
- PCO_1500_USEC = 2;
- PCO_5000_USEC = 3;
-};
-
-enum McsFeedback : uint8 {
- MCS_NOFEEDBACK = 0;
- MCS_RESERVED = 1;
- MCS_UNSOLICIED = 2;
- MCS_BOTH = 3;
-};
-
-struct HtExtCapabilities {
- bool pco;
- uint8 pco_transition; // see enum PcoTransitionTime
- uint8 mcs_feedback; // see enum McsFeedback
- bool htc_ht_support;
- bool rd_responder;
-};
-
-// TxBfCapability
-// IEEE Std 802.11-2016, 9.4.2.56.6 Table 9-166
-enum Calibration : uint8 {
- CALIBRATION_NONE = 0;
- CALIBRATION_RESPOND_NOINITIATE = 1;
- CALIBRATION_RESERVED = 2;
- CALIBRATION_RESPOND_INITIATE = 3;
-};
-
-enum Feedback : uint8 {
- // Shared for csi_feedback, noncomp_feedback, comp_feedback
- FEEDBACK_NONE = 0;
- FEEDBACK_DELAYED = 1;
- FEEDBACK_IMMEDIATE = 2;
- FEEDBACK_DELAYED_IMMEDIATE = 3;
-};
-
-enum MinGroup : uint8 {
- MIN_GROUP_ONE = 0; // Meaning no grouping
- MIN_GROUP_ONE_TWO = 1;
- MIN_GROUP_ONE_FOUR = 2;
- MIN_GROUP_ONE_TWO_FOUR = 3;
-};
-
-struct TxBfCapability {
- bool implicit_rx;
- bool rx_stag_sounding;
- bool tx_stag_sounding;
- bool rx_ndp;
- bool tx_ndp;
- bool implicit;
- uint8 calibration; // see enum Calibration
- bool csi; // Explicit CsI Transmit Beamforming
- bool noncomp_steering; // Explicit Noncompressed Steering
- bool comp_steering; // Explicit Compressed Steering
- uint8 csi_feedback; // see enum Feedback
- uint8 noncomp_feedback; // see enum Feedback
- uint8 comp_feedback; // see enum Feedback
- uint8 min_grouping; // see enum MinGroup
- uint8 csi_antennas; // Actual count, different from IEEE spec
- uint8 noncomp_steering_ants; // Actual count, different from IEEE spec
- uint8 comp_steering_ants; // Actual count, different from IEEE spec
- uint8 csi_rows; // Actual count, different from IEEE spec
- uint8 chan_estimation; // Actual count, different from IEEE spec
-};
-
-// IEEE Std 802.11-2016, 9.4.2.56.7 Table 9-167
-struct AselCapability {
- bool asel;
- bool csi_feedback_tx_asel; // Explicit CSI Feedback Based Transmit ASEL
- bool ant_idx_feedback_tx_asel;
- bool explicit_csi_feedback;
- bool antenna_idx_feedback;
- bool rx_asel;
- bool tx_sounding_ppdu;
-};
-
-struct HtCapabilities {
- // Note, a minimum granuality of adding fields selectively is
- // a group of BitField structure, as defined in element.h
- HtCapabilityInfo ht_cap_info;
- AmpduParams ampdu_params;
- SupportedMcsSet mcs_set;
- HtExtCapabilities ht_ext_cap;
- TxBfCapability txbf_cap;
- AselCapability asel_cap;
-};
-
-// HT Operation Element
-// IEEE Std 802.11-2016 9.4.2.57 Table 9-168
-
-// HTOperationInfo
-enum SecChanOffset : uint8 {
- SECONDARY_NONE = 0; // No secondary channel
- SECONDARY_ABOVE = 1; // Secondary channel is above the primary channel
- RESERVED = 2;
- SECONDARY_BELOW = 3; // Secondary channel is below the primary channel
-};
-
-enum StaChanWidth : uint8 {
- TWENTY = 0; // 20 MHz
- ANY = 1; // Any in the Supported Channel Width set
-};
-
-enum HtProtect : uint8 {
- NONE = 0;
- NONMEMBER = 1;
- TWENTY_MHZ = 2;
- NON_HT_MIXED = 3;
-};
-
-struct HTOperationInfo {
- uint8 secondary_chan_offset; // see enum SecChanOffset
- uint8 sta_chan_width; // see enum StaChanWidth
- bool rifs_mode;
- uint8 ht_protect; // see enum HtProtect
- bool nongreenfield_present; // Nongreenfield HT STAs present
- bool obss_non_ht; // OBSS Non-HT STAs present
- uint8 center_freq_seg2; // VHT
- bool dual_beacon;
- bool dual_cts_protect;
- bool stbc_beacon;
- bool lsig_txop_protect;
- bool pco_active;
- bool pco_phase;
-};
-
-struct HtOperation {
- uint8 primary_chan; // Primary 20 MHz channel.
- HTOperationInfo ht_op_info;
- SupportedMcsSet basic_mcs_set;
-};
-
-enum MaxMpduLen : uint8 {
- OCTETS_3895 = 0;
- OCTETS_7991 = 1;
- OCTETS_11454 = 2;
-};
-
-enum VhtLinkAdaptation : uint8 {
- NO_FEEDBACK = 0;
- // 1 reserved
- UNSOLICITED = 2;
- BOTH = 3;
-};
-
-// IEEE Std 802.11-2016, 9.4.2.158.2
-struct VhtCapabilitiesInfo {
- uint8 max_mpdu_len; // see enum MaxMpduLen
- uint8 supported_cbw_set;
- bool rx_ldpc;
- bool sgi_cbw80;
- bool sgi_cbw160;
- bool tx_stbc;
- uint8 rx_stbc; // number of spatial streams supported. [0, 4] are valid. [5, 7] are reserved.
- bool su_bfer;
- bool su_bfee;
- uint8 bfee_sts; // Maximum number of STS - 1, if su_bfee is true. Reserved otherwise.
- uint8 num_sounding;
- bool mu_bfer;
- bool mu_bfee;
- bool txop_ps;
- bool htc_vht;
- uint8 max_ampdu_exp;
- uint8 link_adapt; // see enum VhtLinkAdaptation
- bool rx_ant_pattern;
- bool tx_ant_pattern;
- uint8 ext_nss_bw;
-};
-
-enum VhtMcs : uint8 {
- SET_0_TO_7 = 0;
- SET_0_TO_8 = 1;
- SET_0_TO_9 = 2;
- SET_NONE = 3;
-};
-
-// IEEE Std 802.11-2016 9.4.2.158.3
-struct VhtMcsNss {
- array<uint8>:8 rx_max_mcs; // idx 0 for ss1, .. idx 7 for ss8. See enum VhtMcs
- uint16 rx_max_data_rate; // Mbps
- uint8 max_nsts;
-
- array<uint8>:8 tx_max_mcs; // idx 0 for ss1, .. idx 7 for ss8. See enum VhtMcs
- uint16 tx_max_data_rate; // Mbps
- bool ext_nss_bw;
-};
-
-// IEEE Std 802.11-2016, Figure 9-562
-struct BasicVhtMcsNss {
- array<uint8>:8 max_mcs; // idx 0 for ss1, .. idx 7 for ss8. See enum VhtMcs
-};
-
-// IEEE Std 802.11-2016 9.5.2.158
-struct VhtCapabilities {
- VhtCapabilitiesInfo vht_cap_info;
- VhtMcsNss vht_mcs_nss;
-};
-
-// IEEE Std 802.11-2016 deprecates the use of CBW_160, CBW_80P80
-enum VhtCbw : uint8 {
- CBW_20_40 = 0;
- CBW_80_160_80P80 = 1;
- CBW_160 = 2;
- CBW_80P80 = 3;
-};
-
-// IEEE Std 802.11-2016 9.5.2.159
-struct VhtOperation {
- uint8 vht_cbw; // see enum VhtCbw
- uint8 center_freq_seg0; // channel number
- uint8 center_freq_seg1; // channel number
- BasicVhtMcsNss basic_mcs;
-};
-
-// IEEE Std 802.11-2016 6.3.3.3.2
-struct BSSDescription {
- array<uint8>:6 bssid;
-
- vector<uint8>:32 ssid;
-
- BSSTypes bss_type;
- uint16 beacon_period; // in TU
- uint8 dtim_period;
- uint64 timestamp;
- uint64 local_time;
-
- CapabilityInfo cap;
- vector<uint8> basic_rate_set; // in 0.5 Mbps, valid value: 1-127. See Table 9-78 for 126, 127.
- vector<uint8> op_rate_set; // in 0.5 Mbps, valid value: 1-127. See Table 9-78 for 126, 127.
- vector<uint8>? country;
-
- // TODO(hahnr): This field represents an IE and should thus be named RSNE.
- vector<uint8>? rsn;
-
- int16 rcpi_dbmh; // 0.5 step dBm. Do not use encoding from IEEE Std 802.11-2016 9.4.2.38.
- int16 rsni_dbh; // 0.5 step dB. Do not use encoding from IEEE Std 802.11-2016 9.4.2.41.
-
- HtCapabilities? ht_cap;
- HtOperation? ht_op;
-
- VhtCapabilities? vht_cap;
- VhtOperation? vht_op;
-
- // List up non-standard, Fuchsia only parameters
- WlanChan chan;
- int8 rssi_dbm; // dBm
-};
-
-enum ScanResultCodes {
- SUCCESS = 0;
- NOT_SUPPORTED = 1;
- INVALID_ARGS = 2;
- INTERNAL_ERROR = 3;
-};
-
-struct ScanResult {
- uint64 txn_id;
- BSSDescription bss;
-};
-
-struct ScanEnd {
- uint64 txn_id;
- ScanResultCodes code;
-};
-
-// MLME-JOIN.request (IEEE Std 802.11-2016, 6.3.4.2)
-
-struct JoinRequest {
- BSSDescription selected_bss;
- uint32 join_failure_timeout;
- uint32 nav_sync_delay;
- vector<uint16> op_rate_set;
-
- // Combined with what MLME knows about the device capabilities,
- // following parameters determine what to be advertised to the peer
- // (in AssociationRequest). Effectively this way replaces the following
- // fields originally defined in MLME-JOIN.request
- // - Capability Information
- // - HT Capabilities
- // - VHT Capabilities
- // - Extended Capabilities
- PHY phy;
- CBW cbw;
-};
-
-// MLME-JOIN.confirm (IEEE Std 802.11-2016, 6.3.4.3)
-
-enum JoinResultCodes {
- SUCCESS = 0;
- JOIN_FAILURE_TIMEOUT = 1;
- //LAST = JOIN_FAILURE_TIMEOUT;
-};
-
-struct JoinConfirm {
- JoinResultCodes result_code;
-};
-
-// MLME-AUTHENTICATE.request (IEEE Std 802.11-2016, 6.3.5.2)
-
-enum AuthenticationTypes {
- OPEN_SYSTEM = 1;
- SHARED_KEY = 2;
- FAST_BSS_TRANSITION = 3;
- SAE = 4;
- //LAST = SAE;
-};
-
-struct AuthenticateRequest {
- array<uint8>:6 peer_sta_address;
- AuthenticationTypes auth_type;
- uint32 auth_failure_timeout;
-
- // etc
-};
-
-// MLME-AUTHENTICATE.confirm (IEEE Std 802.11-2016, 6.3.5.3)
-
-enum AuthenticateResultCodes {
- SUCCESS = 0;
- REFUSED = 1;
- ANTI_CLOGGING_TOKEN_REQUIRED = 2;
- FINITE_CYCLIC_GROUP_NOT_SUPPORTED = 3;
- AUTHENTICATION_REJECTED = 4;
- AUTH_FAILURE_TIMEOUT = 5;
- //LAST = AUTH_FAILURE_TIMEOUT;
-};
-
-struct AuthenticateConfirm {
- array<uint8>:6 peer_sta_address;
- AuthenticationTypes auth_type;
- AuthenticateResultCodes result_code;
-
- // etc
-};
-
-// MLME-AUTHENTICATE.indication (IEEE Std 802.11-2016, 6.3.5.4)
-
-struct AuthenticateIndication {
- array<uint8>:6 peer_sta_address;
- AuthenticationTypes auth_type;
-
- // etc
-};
-
-// MLME-AUTHENTICATE.response (IEEE Std 802.11-2016, 6.3.5.5)
-
-struct AuthenticateResponse {
- array<uint8>:6 peer_sta_address;
- AuthenticateResultCodes result_code;
-
- // etc
-};
-
-// MLME-DEAUTHENTICATE.request (IEEE Std 802.11-2016, 6.3.6.2)
-
-// IEEE Std 802.11-2016, 9.4.1.7, Table 9-45
-enum ReasonCode : uint16 {
- // 0 Reserved
- UNSPECIFIED_REASON = 1;
- INVALID_AUTHENTICATION = 2;
- LEAVING_NETWORK_DEAUTH = 3;
- REASON_INACTIVITY = 4;
- NO_MORE_STAS = 5;
- INVALID_CLASS2_FRAME = 6;
- INVALID_CLASS3_FRAME = 7;
- LEAVING_NETWORK_DISASSOC = 8;
- NOT_AUTHENTICATED = 9;
- UNACCEPTABLE_POWER_CA = 10;
- UNACCEPTABLE_SUPPORTED_CHANNELS = 11;
- BSS_TRANSITION_DISASSOC = 12;
- REASON_INVALID_ELEMENT = 13;
- MIC_FAILURE = 14;
- FOURWAY_HANDSHAKE_TIMEOUT = 15;
- GK_HANDSHAKE_TIMEOUT = 16;
- HANDSHAKE_ELEMENT_MISMATCH = 17;
- REASON_INVALID_GROUP_CIPHER = 18;
- REASON_INVALID_PAIRWISE_CIPHER = 19;
- REASON_INVALID_AKMP = 20;
- UNSUPPORTED_RSNE_VERSION = 21;
- INVALID_RSNE_CAPABILITIES = 22;
- IEEE802_1_X_AUTH_FAILED = 23;
- REASON_CIPHER_OUT_OF_POLICY = 24;
- TDLS_PEER_UNREACHABLE = 25;
- TDLS_UNSPECIFIED_REASON = 26;
- SSP_REQUESTED_DISASSOC = 27;
- NO_SSP_ROAMING_AGREEMENT = 28;
- BAD_CIPHER_OR_AKM = 29;
- NOT_AUTHORIZED_THIS_LOCATION = 30;
- SERVICE_CHANGE_PRECLUDES_TS = 31;
- UNSPECIFIED_QOS_REASON = 32;
- NOT_ENOUGH_BANDWIDTH = 33;
- MISSING_ACKS = 34;
- EXCEEDED_TXOP = 35;
- STA_LEAVING = 36;
- // Values 37 and 38 are overloaded but should be clear from context.
- END_TS_BA_DLS = 37;
- UNKNOWN_TS_BA = 38;
- TIMEOUT = 39;
- // 40-44 Reserved
- PEERKEY_MISMATCH = 45;
- PEER_INITIATED = 46;
- AP_INITIATED = 47;
- REASON_INVALID_FT_ACTION_FRAME_COUNT = 48;
- REASON_INVALID_PMKID = 49;
- REASON_INVALID_MDE = 50;
- REASON_INVALID_FTE = 51;
- MESH_PEERING_CANCELED = 52;
- MESH_MAX_PEERS = 53;
- MESH_CONFIGURATION_POLICY_VIOLATION = 54;
- MESH_CLOSE_RCVD = 55;
- MESH_MAX_RETRIES = 56;
- MESH_CONFIRM_TIMEOUT = 57;
- MESH_INVALID_GTK = 58;
- MESH_INCONSISTENT_PARAMETERS = 59;
- MESH_INVALID_SECURITY_CAPABILITY = 60;
- MESH_PATH_ERROR_NO_PROXY_INFORMATION = 61;
- MESH_PATH_ERROR_NO_FORWARDING_INFORMATION = 62;
- MESH_PATH_ERROR_DESTINATION_UNREACHABLE = 63;
- MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS = 64;
- MESH_CHANNEL_SWITCH_REGULATORY_REQUIREMENTS = 65;
- MESH_CHANNEL_SWITCH_UNSPECIFIED = 66;
- // 67 - 65535 Reserved
-};
-
-struct DeauthenticateRequest {
- array <uint8>:6 peer_sta_address;
- // TODO(tkilbourn): define a ReasonCode enum for FIDL
- ReasonCode reason_code;
- // VendorSpecificInfo
-};
-
-// MLME-DEAUTHENTICATE.confirm (IEEE Std 802.11-2016, 6.3.6.3)
-
-struct DeauthenticateConfirm {
- array <uint8>:6 peer_sta_address;
-};
-
-// MLME-DEAUTHENTICATE.indication (IEEE Std 802.11-2016, 6.3.6.4)
-
-struct DeauthenticateIndication {
- array<uint8>:6 peer_sta_address;
- // TODO(tkilbourn): define a ReasonCode enum for FIDL
- ReasonCode reason_code;
- // VendorSpecificInfo
-};
-
-// MLME-ASSOCIATE.request (IEEE Std 802.11-2016, 6.3.7.2)
-
-struct AssociateRequest {
- array<uint8>:6 peer_sta_address;
- // TODO(hahnr): This field represents an IE and should thus be named RSNE.
- vector<uint8>? rsn;
-
- // etc
-};
-
-// MLME-ASSOCIATE.confrm (IEEE Std 802.11-2016, 6.3.7.3)
-
-enum AssociateResultCodes {
- SUCCESS = 0;
- REFUSED_REASON_UNSPECIFIED = 1;
- REFUSED_NOT_AUTHENTICATED = 2;
- REFUSED_CAPABILITIES_MISMATCH = 3;
- REFUSED_EXTERNAL_REASON = 4;
- REFUSED_AP_OUT_OF_MEMORY = 5;
- REFUSED_BASIC_RATES_MISMATCH = 6;
- REJECTED_EMERGENCY_SERVICES_NOT_SUPPORTED = 7;
- REFUSED_TEMPORARILY = 8;
-};
-
-struct AssociateConfirm {
- AssociateResultCodes result_code;
- // CapabilityInformation
- uint16 association_id;
-
- // etc
-};
-
-// MLME-ASSOCIATE.indication (IEEE Std 802.11-2016, 6.3.7.4)
-
-struct AssociateIndication {
- array<uint8>:6 peer_sta_address;
- // CapabilityInformation
- uint16 listen_interval;
- vector<uint8>? ssid;
- // OperationalRateSet
- // BSSMembershipSelectorSet
- vector<uint8>? rsn;
-
- // etc
-};
-
-// MLME-ASSOCIATE.response (IEEE Std 802.11-2016, 6.3.7.5)
-
-struct AssociateResponse {
- array<uint8>:6 peer_sta_address;
- AssociateResultCodes result_code;
- uint16 association_id;
-
- // etc
-};
-
-// MLME-DISASSOCIATE.request (IEEE Std 802.11-2016, 6.3.9.1)
-
-struct DisassociateRequest {
- array<uint8>:6 peer_sta_address;
- // TODO(tkilbourn): define a ReasonCode enum for FIDL
- uint16 reason_code;
- // VendorSpecificInfo
-};
-
-// MLME-DISASSOCIATE.confirm (IEEE Std 802.11-2016, 6.3.9.2)
-
-struct DisassociateConfirm {
- int32 status;
-};
-
-// MLME-DISASSOCIATE.indication (IEEE Std 802.11-2016, 6.3.9.3)
-
-struct DisassociateIndication {
- array<uint8>:6 peer_sta_address;
- // TODO(tkilbourn): define a ReasonCode enum for FIDL
- uint16 reason_code;
- // VendorSpecificInfo
-};
-
-// MLME-RESET.request (IEEE Std 802.11-2016, 6.3.10.2)
-
-struct ResetRequest {
- array<uint8>:6 sta_address;
- bool set_default_mib;
-};
-
-// MLME-START.request (IEEE Std 802.11-2016, 6.3.11.2)
-
-struct StartRequest {
- vector<uint8>:32 ssid;
- BSSTypes bss_type;
- uint16 beacon_period; // in TU
- uint8 dtim_period;
-
- // Temporary field to support AP channel selection until
- // MLME-CHANNELSWITCH.request is supported.
- uint8 channel;
-
- vector<uint8>:32 mesh_id;
-
- // TODO(hahnr): Add additional elements.
-
- // Although MLME-START.request is used to start a BSS, IEEE does not include an RSNE in this
- // primitive. However, IEEE doesn't define any other primitive to configure the RSN after its
- // BSS was started. The RSNE must be available when the BSS is started, and thus, this is the
- // right place to transfer the RSNE to the MLME.
- vector<uint8>? rsne;
-};
-
-// MLME-START.confirm (IEEE Std 802.11-2016, 6.3.11.3)
-
-enum StartResultCodes {
- SUCCESS = 0;
- BSS_ALREADY_STARTED_OR_JOINED = 1;
- RESET_REQUIRED_BEFORE_START = 2;
- NOT_SUPPORTED = 3;
- INTERNAL_ERROR = 4;
-};
-
-struct StartConfirm {
- StartResultCodes result_code;
-};
-
-// MLME-STOP.request (IEEE Std 802.11-2016, 6.3.12.2)
-
-struct StopRequest {
- vector<uint8>:32 ssid;
-};
-
-// MLME-SETKEYS.request (IEEE Std 802.11-2016 6.3.19.1)
-
-
-enum KeyType {
- GROUP = 1;
- PAIRWISE = 2;
- PEER_KEY = 3;
- IGTK = 4;
-};
-
-struct SetKeyDescriptor {
- // Specs specify a bit string, we use byte array.
- vector<uint8> key;
- uint16 key_id;
- KeyType key_type;
- array<uint8>:6 address;
- array<uint8>:8 rsc;
- array<uint8>:3 cipher_suite_oui;
- uint8 cipher_suite_type;
-};
-
-struct SetKeysRequest {
- vector<SetKeyDescriptor> keylist;
-};
-
-// MLME-DELETEKEYS.request (IEEE Std 802.11-2016 6.3.20.1)
-
-struct DeleteKeyDescriptor {
- uint16 key_id;
- KeyType key_type;
- array<uint8>:6 address;
-};
-
-struct DeleteKeysRequest {
- vector<DeleteKeyDescriptor> keylist;
-};
-
-// MLME-EAPOL.request (IEEE Std 802.11-2016 6.3.22.1)
-
-struct EapolRequest {
- array<uint8>:6 src_addr;
- array<uint8>:6 dst_addr;
- vector<uint8> data;
-};
-
-// MLME-EAPOL.confirm (IEEE Std 802.11-2016 6.3.22.2)
-
-enum EapolResultCodes {
- SUCCESS = 0;
- TRANSMISSION_FAILURE = 1;
- //LAST = TRANSMISSION_FAILURE;
-};
-
-struct EapolConfirm {
- EapolResultCodes result_code;
-};
-
-// IEEE Std 802.11-2016, 9.4.2.98
-struct MeshConfiguration {
- uint8 active_path_sel_proto_id;
- uint8 active_path_sel_metric_id;
- uint8 congest_ctrl_method_id;
- uint8 sync_method_id;
- uint8 auth_proto_id;
- uint8 mesh_formation_info;
- uint8 mesh_capability;
-};
-
-// Fields that are common between the MPM Open and Confirm actions
-struct MeshPeeringCommon {
- array<uint8>:6 peer_sta_address;
- uint16 protocol_id;
- uint16 local_link_id;
- vector<uint8>:32 mesh_id;
- vector<uint8> rates;
- MeshConfiguration mesh_config;
- HtCapabilities? ht_cap;
- HtOperation? ht_op;
- VhtCapabilities? vht_cap;
- VhtOperation? vht_op;
-};
-
-// IEEE Std 802.11-2016, 9.6.16.2.2
-struct MeshPeeringOpenAction {
- MeshPeeringCommon common;
-};
-
-// IEEE Std 802.11-2016, 9.6.16.3.2
-struct MeshPeeringConfirmAction {
- MeshPeeringCommon common;
- uint16 aid;
- uint16 peer_link_id;
-};
-
-// Because these methods rely on an external entity to provide a response, events are used instead
-// of return values.
-interface MLME {
- // ==== 01xxxx: scanning ====
- // We deviate from the spec here in order to support incremental scan
- // results easily. We could stay closer to 802.11ai, but the protocol
- // that is described there is more difficult to implement correctly.
-
- // Initiate a scan transaction. The caller is responsible for filling
- // the `txn_id` field in `req` with a unique number that will be used
- // to identify the transaction.
- //
- // Zero or more `OnScanResult` events with a matching `txn_id` will be sent
- // in response.
- //
- // At the end on the transaction, whether it is successful or not,
- // a `OnScanEnd` event with a matching `txn_id` is guaranteed to be sent
- // in response (unless the channel is closed first).
- //
- // After `OnScanEnd`, no further events with the same `txn_id` shall be sent.
- 010000: StartScan(ScanRequest req);
-
- // An incremental scan result containing information about a single BSS.
- // Only one event per unique BSSID per transaction will be sent.
- 010100: -> OnScanResult(ScanResult result);
-
- // An event that signals the end of a scan transaction.
- 010200: -> OnScanEnd(ScanEnd end);
-
- // ====
-
- 3: JoinReq(JoinRequest req);
- 4: -> JoinConf(JoinConfirm resp);
-
- 5: AuthenticateReq(AuthenticateRequest req);
- 6: -> AuthenticateConf(AuthenticateConfirm resp);
-
- 7: -> AuthenticateInd(AuthenticateIndication ind);
- 8: AuthenticateResp(AuthenticateResponse resp);
-
- 9: DeauthenticateReq(DeauthenticateRequest req);
- 10: -> DeauthenticateConf(DeauthenticateConfirm resp);
-
- 11: -> DeauthenticateInd(DeauthenticateIndication ind);
-
- 12: AssociateReq(AssociateRequest req);
- 13: -> AssociateConf(AssociateConfirm resp);
-
- 14: -> AssociateInd(AssociateIndication ind);
- 15: AssociateResp(AssociateResponse resp);
-
- 16: DisassociateReq(DisassociateRequest req);
- 17: -> DisassociateConf(DisassociateConfirm resp);
-
- 18: -> DisassociateInd(DisassociateIndication ind);
-
- 19: ResetReq(ResetRequest req);
-
- 20: StartReq(StartRequest req);
- 21: -> StartConf(StartConfirm resp);
-
- 22: StopReq(StopRequest req);
- 23: -> StopConf();
-
- 24: SetKeysReq(SetKeysRequest req);
-
- 25: DeleteKeysReq(DeleteKeysRequest req);
-
- 26: EapolReq(EapolRequest req);
- 27: -> EapolConf(EapolConfirm resp);
-
- // ==== 90xxxx: Mesh ===
- 900000: -> IncomingMpOpenAction(MeshPeeringOpenAction action);
- 900100: SendMpOpenAction(MeshPeeringOpenAction action);
- 900300: SendMpConfirmAction(MeshPeeringConfirmAction action);
-
- // The following are extensions to the 802.11 MLME SAP interface.
-
- 0x1001: -> SignalReport(SignalReportIndication ind);
-
- 0x1002: -> EapolInd(EapolIndication ind);
-
- 0x1003: QueryDeviceInfo() -> (DeviceInfo info);
-
- 0x1005: StatsQueryReq();
- 0x1006: -> StatsQueryResp(StatsQueryResponse resp);
-
- 0x1007: ListMinstrelPeers() -> (MinstrelListResponse resp);
- 0x1008 : GetMinstrelStats(MinstrelStatsRequest req) ->(MinstrelStatsResponse resp);
-};
diff --git a/fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl b/fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl
deleted file mode 100644
index 9dd04dc..0000000
--- a/fidl/fuchsia.wlan.mlme/wlan_mlme_ext.fidl
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.wlan.mlme;
-using fuchsia.wlan.stats;
-using fuchsia.wlan.minstrel;
-
-// Custom primitives for communicating between the wlan service and the MLME drivers.
-// The primitives defined here are not part of the official 802.11 MLME SAP interface specification,
-// but follow the same principle for the sake of consistency.
-
-
-// SIGNAL_REPORT.indication
-
-struct SignalReportIndication {
- int8 rssi_dbm;
-};
-
-// EAPOL.indication
-
-struct EapolIndication {
- array<uint8>:6 src_addr;
- array<uint8>:6 dst_addr;
- vector<uint8> data;
-};
-
-enum MacRole {
- CLIENT = 1;
- AP = 2;
- MESH = 3;
-};
-
-
-// BandInfo groups capabilities defined per band.
-// This grouping is the industry's de factor standard.
-struct BandCapabilities {
- Band band_id;
- vector<uint16> basic_rates;
- uint16 base_frequency;
- vector<uint8> channels;
-
- CapabilityInfo cap;
- HtCapabilities? ht_cap;
- VhtCapabilities? vht_cap;
-};
-
-struct DeviceInfo {
- array<uint8>:6 mac_addr;
- MacRole role;
- vector<BandCapabilities> bands;
-};
-
-// STATS_QUERY.response
-
-struct StatsQueryResponse {
- fuchsia.wlan.stats.IfaceStats stats;
-};
-
-struct MinstrelListResponse {
- fuchsia.wlan.minstrel.Peers peers;
-};
-
-struct MinstrelStatsRequest {
- array<uint8>:6 mac_addr;
-};
-
-struct MinstrelStatsResponse {
- fuchsia.wlan.minstrel.Peer? peer;
-};
-
-// Method ordinals are defined in wlan_mlme.fidl to prevent error prone overlaps with official
-// MLME primitives.
diff --git a/fidl/fuchsia.wlan.service/meta.json b/fidl/fuchsia.wlan.service/meta.json
deleted file mode 100644
index ead12c3..0000000
--- a/fidl/fuchsia.wlan.service/meta.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "deps": [
- "fuchsia.wlan.mlme",
- "fuchsia.wlan.stats"
- ],
- "files": [
- "fidl/fuchsia.wlan.service/wlan_service.fidl"
- ],
- "name": "fuchsia.wlan.service",
- "root": "fidl/fuchsia.wlan.service",
- "sources": [
- "fidl/fuchsia.wlan.service/wlan_service.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.wlan.service/wlan_service.fidl b/fidl/fuchsia.wlan.service/wlan_service.fidl
deleted file mode 100644
index ef2de3b..0000000
--- a/fidl/fuchsia.wlan.service/wlan_service.fidl
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.wlan.service;
-
-using fuchsia.wlan.mlme;
-using fuchsia.wlan.stats;
-
-enum ErrCode {
- OK = 0;
- INTERNAL = 1;
- NOT_FOUND = 2;
- NOT_SUPPORTED = 3;
- INVALID_ARGS = 4;
-};
-
-struct Error {
- ErrCode code;
- string description;
-};
-
-struct AP {
- vector<uint8> bssid;
- string ssid; // TODO(NET-698, NET-1474): Make this as vector<uint8:32>
- int8 rssi_dbm;
- bool is_secure;
- bool is_compatible; // with respect to Fuchsia
- fuchsia.wlan.mlme.WlanChan chan;
-};
-
-struct ScanRequest {
- uint8 timeout; // seconds
- // TODO: more parameters here
-};
-
-struct ScanResult {
- Error error;
- vector<AP>? aps;
-};
-
-struct ConnectConfig {
- string ssid;
- string passPhrase;
- uint8 scanInterval; // seconds
- string bssid;
-};
-
-enum State {
- UNKNOWN = 0;
- BSS = 1;
- QUERYING = 2;
- SCANNING = 3;
- JOINING = 4;
- AUTHENTICATING = 5;
- ASSOCIATING = 6;
- ASSOCIATED = 7;
-};
-
-struct WlanStatus {
- Error error;
- State state;
- AP? current_ap;
-};
-
-struct BssConfig {
- string ssid;
- int32 beaconPeriod;
- int32 dtimPeriod;
- uint8 channel;
-};
-
-struct WlanStats {
- Error error;
- fuchsia.wlan.stats.IfaceStats stats;
-};
-
-// Stub interface; eventually to be replaced by something based on the 802.11
-// SME / MSGCF.
-[Discoverable]
-interface Wlan {
- 1: Scan(ScanRequest req) -> (ScanResult result);
- 2: Connect(ConnectConfig req) -> (Error error);
- 3: Disconnect() -> (Error error);
- 4: Status() -> (WlanStatus status);
- 5: StartBss(BssConfig cfg) -> (Error error);
- 6: StopBss() -> (Error error);
- 7: Stats() -> (WlanStats stats);
-};
diff --git a/fidl/fuchsia.wlan.stats/meta.json b/fidl/fuchsia.wlan.stats/meta.json
deleted file mode 100644
index 26a02ed..0000000
--- a/fidl/fuchsia.wlan.stats/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/fuchsia.wlan.stats/wlan_stats.fidl"
- ],
- "name": "fuchsia.wlan.stats",
- "root": "fidl/fuchsia.wlan.stats",
- "sources": [
- "fidl/fuchsia.wlan.stats/wlan_stats.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/fidl/fuchsia.wlan.stats/wlan_stats.fidl b/fidl/fuchsia.wlan.stats/wlan_stats.fidl
deleted file mode 100644
index 0f35b83..0000000
--- a/fidl/fuchsia.wlan.stats/wlan_stats.fidl
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.wlan.stats;
-
-struct Counter {
- uint64 count;
- string name;
-};
-
-struct PacketCounter {
- Counter in;
- Counter out;
- Counter drop;
- Counter in_bytes;
- Counter out_bytes;
- Counter drop_bytes;
-};
-
-// LINT.IfChange
-struct DispatcherStats {
- PacketCounter any_packet;
- PacketCounter mgmt_frame;
- PacketCounter ctrl_frame;
- PacketCounter data_frame;
-};
-
-const uint8 RSSI_BINS = 129;
-
-// RssiStats count the occurrence of the RSSIs.
-// RSSI value r's occurrence is counted in the bin[-r],
-// where r is defined in [-128, 0] in dBm.
-struct RssiStats {
- // TODO(alexandrew): Change this to array.
- vector<uint64>:RSSI_BINS hist;
-};
-
-struct ClientMlmeStats {
- PacketCounter svc_msg;
- PacketCounter data_frame;
- PacketCounter mgmt_frame;
- PacketCounter tx_frame;
- PacketCounter rx_frame;
- RssiStats assoc_data_rssi;
- RssiStats beacon_rssi;
-};
-
-struct ApMlmeStats {
- PacketCounter not_used;
-};
-
-// LINT.ThenChange(//garnet/lib/wlan/common/include/wlan/common/stats.h)
-
-union MlmeStats {
- ClientMlmeStats client_mlme_stats;
- ApMlmeStats ap_mlme_stats;
-};
-
-struct IfaceStats {
- DispatcherStats dispatcher_stats;
- MlmeStats? mlme_stats;
-};
diff --git a/fidl/zircon.ethernet/ethernet.fidl b/fidl/zircon.ethernet/ethernet.fidl
deleted file mode 100644
index 79945e3..0000000
--- a/fidl/zircon.ethernet/ethernet.fidl
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library zircon.ethernet;
-
-using zx;
-
-struct MacAddress {
- array<uint8>:6 octets;
-};
-
-const uint32 DEFAULT_BUFFER_SIZE = 2048; // bytes
-/// When writing payload to a tx buffer, clients of a Device must skip this many bytes
-/// so that lower-layer drivers can fill in additional headers in that space.
-const uint32 MAC_HDR_MAX_SIZE = 64; // bytes, the closest power of 2 larger than 44, which is
- // DataFrameHeader::max_size(36) + LlcHeader::max_size(8)
-
-// Info.features bits
-const uint32 INFO_FEATURE_WLAN = 0x00000001;
-const uint32 INFO_FEATURE_SYNTH = 0x00000002;
-const uint32 INFO_FEATURE_LOOPBACK = 0x00000004;
-
-struct Info {
- uint32 features;
- uint32 mtu;
- MacAddress mac;
-};
-
-struct Fifos {
- // handles for the rx and tx fifo
- handle<fifo> rx;
- handle<fifo> tx;
-
- // maximum number of items in rx and tx fifo
- uint32 rx_depth;
- uint32 tx_depth;
-};
-
-// Signal that is asserted on the RX fifo whenever the Device has a status
-// change. This is ZX_USER_SIGNAL_0.
-// TODO(teisenbe/kulakowski): find a better way to represent this
-const uint32 SIGNAL_STATUS = 0x01000000;
-
-// device_status bits
-const uint32 DEVICE_STATUS_ONLINE = 0x00000001;
-
-// Max client name length
-const uint32 MAX_CLIENT_NAME_LEN = 15;
-
-// For compatibility with a past revision, allow one extra byte for an optional
-// null-terminator.
-const uint32 SET_CLIENT_NAME_MAX_LEN = 16;
-
-// zircon/device/ethernet.h
-[Layout = "Simple"]
-interface Device {
- // Obtain information about device
- 1: GetInfo() -> (Info info);
-
- // Obtain a pair of fifos for queueing tx and rx operations
- 2: GetFifos() -> (zx.status status, Fifos? info);
-
- // Set the IO Buffer that will provide the data buffers for tx and rx operations
- 3: SetIOBuffer(handle<vmo> h) -> (zx.status status);
-
- // Start transferring packets
- // Start will not succeed (ZX_ERR_BAD_STATE) until the fifos have been
- // obtained and an io buffer vmo has been registered.
- 4: Start() -> (zx.status status);
-
- // Stop transferring packets
- 5: Stop() -> ();
-
- // Start listening to the packets that we're transmitting
- // as well as the packets we're receiving.
- 6: ListenStart() -> (zx.status status);
-
- // Stop listening to the packets that we're transmitting.
- 7: ListenStop() -> ();
-
- 8: SetClientName(string:SET_CLIENT_NAME_MAX_LEN name) -> (zx.status status);
-
- // Obtain the device status bits
- // When these change, the signal SIGNAL_STATUS is asserted on the rx fifo.
- // When these are read, the signal is deasserted.
- 9: GetStatus() -> (uint32 device_status);
-
- 10: SetPromiscuousMode(bool enabled) -> (zx.status status);
-
- 11: ConfigMulticastAddMac(MacAddress addr) -> (zx.status status);
- 12: ConfigMulticastDeleteMac(MacAddress addr) -> (zx.status status);
- 13: ConfigMulticastSetPromiscuousMode(bool enabled) -> (zx.status status);
-
- // TODO(teisenbe): We should probably remove these? They are only used for testing.
- 14: ConfigMulticastTestFilter() -> (zx.status status);
- 15: DumpRegisters() -> (zx.status status);
-};
-
-// Operation
-//
-// Packets are transmitted by writing data into the io_vmo and writing
-// an FifoEntry referencing that data (offset + length) into the tx fifo.
-// When the driver is done accessing the data, a FifoEntry with the same
-// cookie value (opaque to the driver) will be readable from the tx fifo.
-//
-// Packets are received by writing a FifoEntry referencing an available
-// buffer (offset + length) in the io vmo. When a packet is received,
-// a FifoEntry with the same cookie value (opaque to the driver) will be
-// readable from the rx fifo. The offset field will be the same as was
-// sent. The length field will reflect the actual size of the received
-// packet. The flags field will indicate success or a specific failure
-// condition.
-//
-// IMPORTANT: The driver *will not* buffer response messages. It is the
-// client's responsibility to ensure that there is space in the reply side
-// of each fifo for each outstanding tx or rx request. The fifo sizes
-// are returned along with the fifo handles from GetFifos().
-
-// flags values for request messages
-// - none -
-
-// flags values for response messages
-const uint16 FIFO_RX_OK = 0x00000001; // packet received okay
-const uint16 FIFO_TX_OK = 0x00000001; // packet transmitted okay
-const uint16 FIFO_INVALID = 0x00000002; // offset+length not within io_vmo bounds
-const uint16 FIFO_RX_TX = 0x00000004; // received our own tx packet (when Listen enabled)
-
-struct FifoEntry {
- // offset from start of io vmo to packet data
- uint32 offset;
-
- // length of packet data to tx or rx
- uint16 length;
-
- // FIFO_* flags as above
- uint16 flags;
-
- // opaque cookie
- uint64 cookie;
-};
diff --git a/fidl/zircon.ethernet/meta.json b/fidl/zircon.ethernet/meta.json
deleted file mode 100644
index fe257e4..0000000
--- a/fidl/zircon.ethernet/meta.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "deps": [],
- "files": [
- "fidl/zircon.ethernet/ethernet.fidl"
- ],
- "name": "zircon.ethernet",
- "root": "fidl/zircon.ethernet",
- "sources": [
- "fidl/zircon.ethernet/ethernet.fidl"
- ],
- "type": "fidl_library"
-}
\ No newline at end of file
diff --git a/hash b/hash
deleted file mode 100644
index 2cc223f..0000000
--- a/hash
+++ /dev/null
@@ -1 +0,0 @@
-0e1216b2c3a4a5b141036ebb1800fc9c1202c1ab
\ No newline at end of file
diff --git a/images/fuchsia.zbi-meta.json b/images/fuchsia.zbi-meta.json
deleted file mode 100644
index 28465a1..0000000
--- a/images/fuchsia.zbi-meta.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "file": {
- "arm64": "target/arm64/fuchsia.zbi",
- "x64": "target/x64/fuchsia.zbi"
- },
- "name": "fuchsia.zbi",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/images/fvm.blk-meta.json b/images/fvm.blk-meta.json
deleted file mode 100644
index fe7dacc..0000000
--- a/images/fvm.blk-meta.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "file": {
- "arm64": "target/arm64/fvm.blk",
- "x64": "target/x64/fvm.blk"
- },
- "name": "fvm.blk",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/images/fvm.sparse.blk-meta.json b/images/fvm.sparse.blk-meta.json
deleted file mode 100644
index 077397c..0000000
--- a/images/fvm.sparse.blk-meta.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "file": {
- "arm64": "target/arm64/fvm.sparse.blk",
- "x64": "target/x64/fvm.sparse.blk"
- },
- "name": "fvm.sparse.blk",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/images/local.esp.blk-meta.json b/images/local.esp.blk-meta.json
deleted file mode 100644
index b7644c1..0000000
--- a/images/local.esp.blk-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "file": {
- "x64": "target/x64/local.esp.blk"
- },
- "name": "local.esp.blk",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/images/qemu-kernel.bin-meta.json b/images/qemu-kernel.bin-meta.json
deleted file mode 100644
index a67b5c2..0000000
--- a/images/qemu-kernel.bin-meta.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "file": {
- "arm64": "target/arm64/qemu-kernel.bin",
- "x64": "target/x64/qemu-kernel.bin"
- },
- "name": "qemu-kernel.bin",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/images/zircon.vboot-meta.json b/images/zircon.vboot-meta.json
deleted file mode 100644
index bfdf16c..0000000
--- a/images/zircon.vboot-meta.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "file": {
- "arm64": "target/arm64/zircon.vboot",
- "x64": "target/x64/zircon.vboot"
- },
- "name": "zircon.vboot",
- "root": "images",
- "type": "image"
-}
\ No newline at end of file
diff --git a/meta/manifest.json b/meta/manifest.json
index c65aeeb..c0fe5e1 100644
--- a/meta/manifest.json
+++ b/meta/manifest.json
@@ -1,92 +1,57 @@
{
"arch": {
- "host": "x86_64-linux-gnu",
+ "host": "x86_64-linux-gnu",
"target": [
- "arm64",
+ "arm64",
"x64"
]
- },
+ },
+ "id": "",
"parts": [
- "docs/low_level.json",
- "docs/metadata_schemas.json",
- "fidl/fuchsia.bluetooth.gatt/meta.json",
- "fidl/fuchsia.bluetooth.le/meta.json",
- "fidl/fuchsia.bluetooth/meta.json",
- "fidl/fuchsia.developer.tiles/meta.json",
- "fidl/fuchsia.fonts/meta.json",
- "fidl/fuchsia.images/meta.json",
- "fidl/fuchsia.io/meta.json",
- "fidl/fuchsia.ldsvc/meta.json",
- "fidl/fuchsia.logger/meta.json",
- "fidl/fuchsia.math/meta.json",
- "fidl/fuchsia.media/meta.json",
- "fidl/fuchsia.mediacodec/meta.json",
- "fidl/fuchsia.mem/meta.json",
- "fidl/fuchsia.net.http/meta.json",
- "fidl/fuchsia.net.oldhttp/meta.json",
- "fidl/fuchsia.net/meta.json",
- "fidl/fuchsia.netstack/meta.json",
- "fidl/fuchsia.process/meta.json",
- "fidl/fuchsia.simplecamera/meta.json",
- "fidl/fuchsia.sys/meta.json",
- "fidl/fuchsia.sysinfo/meta.json",
- "fidl/fuchsia.ui.app/meta.json",
- "fidl/fuchsia.ui.gfx/meta.json",
- "fidl/fuchsia.ui.input/meta.json",
- "fidl/fuchsia.ui.policy/meta.json",
- "fidl/fuchsia.ui.scenic/meta.json",
- "fidl/fuchsia.ui.vectorial/meta.json",
- "fidl/fuchsia.ui.views/meta.json",
- "fidl/fuchsia.ui.viewsv1/meta.json",
- "fidl/fuchsia.ui.viewsv1token/meta.json",
- "fidl/fuchsia.wlan.minstrel/meta.json",
- "fidl/fuchsia.wlan.mlme/meta.json",
- "fidl/fuchsia.wlan.service/meta.json",
- "fidl/fuchsia.wlan.stats/meta.json",
- "fidl/zircon.ethernet/meta.json",
- "images/fuchsia.zbi-meta.json",
- "images/fvm.blk-meta.json",
- "images/fvm.sparse.blk-meta.json",
- "images/local.esp.blk-meta.json",
- "images/qemu-kernel.bin-meta.json",
- "images/zircon.vboot-meta.json",
- "pkg/async-default/meta.json",
- "pkg/async-loop-cpp/meta.json",
- "pkg/async-loop/meta.json",
- "pkg/async/meta.json",
- "pkg/fdio/meta.json",
- "pkg/fidl-async/meta.json",
- "pkg/fidl/meta.json",
- "pkg/fidl_cpp/meta.json",
- "pkg/fidl_cpp_base/meta.json",
- "pkg/fidl_cpp_sync/meta.json",
- "pkg/fit/meta.json",
- "pkg/images_cpp/meta.json",
- "pkg/memfs/meta.json",
- "pkg/scenic_cpp/meta.json",
- "pkg/svc/meta.json",
- "pkg/sync/meta.json",
- "pkg/syslog/meta.json",
- "pkg/sysroot/meta.json",
- "pkg/trace-engine/meta.json",
- "pkg/vulkan/meta.json",
- "pkg/vulkan_layers/meta.json",
- "pkg/zx/meta.json",
- "tools/bootserver-meta.json",
- "tools/far-meta.json",
- "tools/fidl-format-meta.json",
- "tools/fidlc-meta.json",
- "tools/fidlgen-meta.json",
- "tools/fvm-meta.json",
- "tools/loglistener-meta.json",
- "tools/merkleroot-meta.json",
- "tools/minfs-meta.json",
- "tools/netaddr-meta.json",
- "tools/netcp-meta.json",
- "tools/netls-meta.json",
- "tools/netruncmd-meta.json",
- "tools/pm-meta.json",
- "tools/zbi-meta.json",
- "tools/zxdb-meta.json"
- ]
+ {
+ "meta": "docs/low_level.json",
+ "type": "documentation"
+ },
+ {
+ "meta": "docs/metadata_schemas.json",
+ "type": "documentation"
+ },
+ {
+ "meta": "docs/musl_license.json",
+ "type": "documentation"
+ },
+ {
+ "meta": "docs/open_source.json",
+ "type": "documentation"
+ },
+ {
+ "meta": "pkg/async-cpp/meta.json",
+ "type": "cc_source_library"
+ },
+ {
+ "meta": "pkg/async/meta.json",
+ "type": "cc_source_library"
+ },
+ {
+ "meta": "pkg/fdio/meta.json",
+ "type": "cc_prebuilt_library"
+ },
+ {
+ "meta": "pkg/fit/meta.json",
+ "type": "cc_source_library"
+ },
+ {
+ "meta": "pkg/sync/meta.json",
+ "type": "cc_prebuilt_library"
+ },
+ {
+ "meta": "pkg/sysroot/meta.json",
+ "type": "sysroot"
+ },
+ {
+ "meta": "pkg/zx/meta.json",
+ "type": "cc_source_library"
+ }
+ ],
+ "schema_version": "1"
}
\ No newline at end of file
diff --git a/meta/schemas/cc_prebuilt_library.json b/meta/schemas/cc_prebuilt_library.json
index 0a9c83b..9a72c8e 100644
--- a/meta/schemas/cc_prebuilt_library.json
+++ b/meta/schemas/cc_prebuilt_library.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/cc_prebuilt_library.json",
"description": "A prebuilt C/C++ library",
"type": "object",
"allOf": [
@@ -8,16 +10,25 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "cc_prebuilt_library"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "cc_prebuilt_library"
+ ]
+ }
]
},
"name": {
"description": "Name of the library",
"$ref": "common.json#/definitions/cc_library_name"
},
+ "root": {
+ "description": "The root of the element in the SDK",
+ "type": "string"
+ },
"format": {
"description": "The distribution format of the binaries",
"type": "string",
@@ -41,7 +52,7 @@
"description": "List of C/C++ libraries this library depends on",
"type": "array",
"items": {
- "$ref": "#/definitions/package_name"
+ "$ref": "common.json#/definitions/cc_library_name"
}
},
"binaries": {
@@ -67,9 +78,13 @@
"deps",
"format",
"headers",
+ "include_dir",
+ "root",
+
"name",
"type"
- ]
+ ],
+ "additionalProperties": false
}
],
"definitions": {
@@ -85,6 +100,10 @@
"description": "The version of the library to add to Fuchsia packages",
"$ref": "common.json#/definitions/file"
},
+ "dist_path": {
+ "description": "Path where the library should be installed in Fuchsia packages",
+ "$ref": "common.json#/definitions/file"
+ },
"debug": {
"description": "The unstripped version of the library",
"$ref": "common.json#/definitions/file"
diff --git a/meta/schemas/cc_source_library.json b/meta/schemas/cc_source_library.json
index 34733d3..36ceb11 100644
--- a/meta/schemas/cc_source_library.json
+++ b/meta/schemas/cc_source_library.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/cc_source_library.json",
"description": "A set of C/C++ sources",
"type": "object",
"allOf": [
@@ -8,16 +10,25 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "cc_source_library"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "cc_source_library"
+ ]
+ }
]
},
"name": {
"description": "Name of the library",
"$ref": "common.json#/definitions/cc_library_name"
},
+ "root": {
+ "description": "The root of the element in the SDK",
+ "type": "string"
+ },
"sources": {
"description": "List of library sources",
"type": "array",
@@ -28,6 +39,7 @@
"headers": {
"description": "List of public headers",
"type": "array",
+ "minItems": 1,
"items": {
"$ref": "common.json#/definitions/file"
}
@@ -40,7 +52,7 @@
"description": "List of C/C++ libraries this library depends on",
"type": "array",
"items": {
- "$ref": "#/definitions/package_name"
+ "$ref": "common.json#/definitions/cc_library_name"
}
},
"fidl_deps": {
@@ -49,17 +61,28 @@
"items": {
"$ref": "common.json#/definitions/fidl_library_name"
}
+ },
+ "banjo_deps": {
+ "description": "List of BANJO libraries this library depends on",
+ "type": "array",
+ "items": {
+ "$ref": "common.json#/definitions/banjo_library_name"
+ }
}
},
"required": [
+ "banjo_deps",
"deps",
"fidl_deps",
"headers",
"include_dir",
- "name",
+ "root",
"sources",
+
+ "name",
"type"
- ]
+ ],
+ "additionalProperties": false
}
]
}
diff --git a/meta/schemas/common.json b/meta/schemas/common.json
index a17c6a5..b02b160 100644
--- a/meta/schemas/common.json
+++ b/meta/schemas/common.json
@@ -1,36 +1,30 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/common.json",
"definitions": {
"file": {
"description": "Path to a file from the root of the SDK",
"type": "string"
},
+ "type": {
+ "description": "Represents the type of an SDK element",
+ "type": "string"
+ },
"sdk_element": {
"description": "Base type for SDK elements",
"type": "object",
"properties": {
"type": {
"description": "The type of the element",
- "type": "string"
+ "$ref": "#/definitions/type"
},
"name": {
"description": "The name of the element",
"type": "string"
- },
- "root": {
- "description": "The root of the element in the SDK",
- "type": "string"
- },
- "files": {
- "description": "The list of files pertaining to the element",
- "type": "array",
- "items": {
- "$ref": "#/definitions/file"
- }
}
},
"required": [
"name",
- "root",
"type"
]
},
diff --git a/meta/schemas/dart_library.json b/meta/schemas/dart_library.json
index 3d90f91..9a77d08 100644
--- a/meta/schemas/dart_library.json
+++ b/meta/schemas/dart_library.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/dart_library.json",
"description": "A Dart library",
"type": "object",
"allOf": [
@@ -8,19 +10,29 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "dart_library"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "dart_library"
+ ]
+ }
]
},
"name": {
"description": "Name of the library",
"$ref": "#/definitions/package_name"
},
+ "root": {
+ "description": "The root of the element in the SDK",
+ "$ref": "common.json#/definitions/file"
+ },
"sources": {
"description": "List of library sources",
"type": "array",
+ "minItems": 1,
"items": {
"$ref": "common.json#/definitions/file"
}
@@ -50,11 +62,14 @@
"required": [
"deps",
"fidl_deps",
- "name",
+ "root",
"sources",
"third_party_deps",
+
+ "name",
"type"
- ]
+ ],
+ "additionalProperties": false
}
],
"definitions": {
diff --git a/meta/schemas/data.json b/meta/schemas/data.json
new file mode 100644
index 0000000..1afbddb
--- /dev/null
+++ b/meta/schemas/data.json
@@ -0,0 +1,47 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/documentation.json",
+ "description": "A set of data files",
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/sdk_element"
+ },
+ {
+ "properties": {
+ "type": {
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "config",
+ "license"
+ ]
+ }
+ ]
+ },
+ "name": {
+ "description": "Name of the data set",
+ "type": "string"
+ },
+ "data": {
+ "description": "The list of data files pertaining to the set",
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "common.json#/definitions/file"
+ }
+ }
+ },
+ "required": [
+ "data",
+
+ "name",
+ "type"
+ ],
+ "additionalProperties": false
+ }
+ ]
+}
diff --git a/meta/schemas/device_profile.json b/meta/schemas/device_profile.json
new file mode 100644
index 0000000..48f1c41
--- /dev/null
+++ b/meta/schemas/device_profile.json
@@ -0,0 +1,52 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/device_profile.json",
+ "description": "A supported device configuration for SDK development",
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/sdk_element"
+ },
+ {
+ "properties": {
+ "type": {
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "device_profile"
+ ]
+ }
+ ]
+ },
+ "name": {
+ "description": "Name of the profile",
+ "type": "string"
+ },
+ "description": {
+ "description": "A description of the device's configuration",
+ "type": "string"
+ },
+ "images_url": {
+ "description": "GCS URL of the archive containing system images",
+ "type": "string"
+ },
+ "packages_url": {
+ "description": "GCS URL of the archive containing a package repository",
+ "type": "string"
+ }
+ },
+ "required": [
+ "description",
+ "images_url",
+ "packages_url",
+
+ "name",
+ "type"
+ ],
+ "additionalProperties": false
+ }
+ ]
+}
diff --git a/meta/schemas/documentation.json b/meta/schemas/documentation.json
index 3362acf..040ccd6 100644
--- a/meta/schemas/documentation.json
+++ b/meta/schemas/documentation.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/documentation.json",
"description": "A set of documents",
"type": "object",
"allOf": [
@@ -8,24 +10,37 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "documentation"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "documentation"
+ ]
+ }
]
},
+ "name": {
+ "description": "Name of the document set",
+ "type": "string"
+ },
"docs": {
"description": "The list of documents pertaining to the set",
"type": "array",
+ "minItems": 1,
"items": {
"$ref": "common.json#/definitions/file"
}
}
},
"required": [
- "type",
- "docs"
- ]
+ "docs",
+
+ "name",
+ "type"
+ ],
+ "additionalProperties": false
}
]
}
diff --git a/meta/schemas/fidl_library.json b/meta/schemas/fidl_library.json
index abc8291..eec1fe3 100644
--- a/meta/schemas/fidl_library.json
+++ b/meta/schemas/fidl_library.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/fidl_library.json",
"description": "A FIDL library",
"type": "object",
"allOf": [
@@ -8,29 +10,50 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "fidl_library"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "fidl_library"
+ ]
+ }
]
},
"name": {
"description": "Name of the library",
"$ref": "common.json#/definitions/fidl_library_name"
},
+ "root": {
+ "description": "The root of the element in the SDK",
+ "type": "string"
+ },
"sources": {
"description": "List of library sources",
"type": "array",
+ "minItems": 1,
"items": {
"$ref": "common.json#/definitions/file"
}
+ },
+ "deps": {
+ "description": "List of libraries this library depends on",
+ "type": "array",
+ "items": {
+ "$ref": "common.json#/definitions/fidl_library_name"
+ }
}
},
"required": [
- "name",
+ "deps",
+ "root",
"sources",
+
+ "name",
"type"
- ]
+ ],
+ "additionalProperties": false
}
]
}
diff --git a/meta/schemas/host_tool.json b/meta/schemas/host_tool.json
index a6d11fe..97c9cc3 100644
--- a/meta/schemas/host_tool.json
+++ b/meta/schemas/host_tool.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/host_tool.json",
"description": "A host tool",
"type": "object",
"allOf": [
@@ -8,24 +10,63 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "host_tool"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "host_tool"
+ ]
+ }
]
},
+ "name": {
+ "description": "Name of the tool",
+ "type": "string"
+ },
+ "root": {
+ "description": "The root of the element in the SDK",
+ "type": "string"
+ },
"files": {
"description": "The list of files pertaining to the element",
- "type": "array",
- "items": {
- "$ref": "common.json#/definitions/file"
- }
+ "$ref": "#/definitions/fileGroup"
+ },
+ "target_files": {
+ "description": "The target-specific files, per architecture",
+ "type": "object",
+ "properties": {
+ "x64": {
+ "description": "Files for the x64 architecture",
+ "$ref": "#/definitions/fileGroup"
+ },
+ "arm64": {
+ "description": "Files for the arm64 architecture",
+ "$ref": "#/definitions/fileGroup"
+ }
+ },
+ "additionalProperties": false,
+ "minProperties": 1,
+ "maxProperties": 2
}
},
"required": [
- "type",
- "files"
- ]
+ "root",
+
+ "name",
+ "type"
+ ],
+ "additionalProperties": false
}
- ]
+ ],
+ "definitions": {
+ "fileGroup": {
+ "description": "A collection of files",
+ "type": "array",
+ "items": {
+ "$ref": "common.json#/definitions/file"
+ }
+ }
+ }
}
diff --git a/meta/schemas/image.json b/meta/schemas/image.json
deleted file mode 100644
index f9fd1b0..0000000
--- a/meta/schemas/image.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "description": "A target image",
- "type": "object",
- "allOf": [
- {
- "$ref": "common.json#/definitions/sdk_element"
- },
- {
- "properties": {
- "type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "image"
- ]
- },
- "file": {
- "description": "The image, per architecture",
- "type": "object",
- "properties": {
- "x64": {
- "description": "File for the x64 architecture",
- "$ref": "common.json#/definitions/file"
- },
- "arm64": {
- "description": "File for the arm64 architecture",
- "$ref": "common.json#/definitions/file"
- }
- },
- "additionalProperties": false,
- "minProperties": 1,
- "maxProperties": 2
- }
- },
- "required": [
- "type",
- "file"
- ]
- }
- ]
-}
diff --git a/meta/schemas/loadable_module.json b/meta/schemas/loadable_module.json
index ae7361d..308b45c 100644
--- a/meta/schemas/loadable_module.json
+++ b/meta/schemas/loadable_module.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/loadable_module.json",
"description": "A collection of object files that can be loaded at runtime",
"type": "object",
"allOf": [
@@ -8,16 +10,25 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "loadable_module"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "loadable_module"
+ ]
+ }
]
},
"name": {
"description": "Name of the module",
"type": "string"
},
+ "root": {
+ "description": "The root of the element in the SDK",
+ "type": "string"
+ },
"resources": {
"description": "Resource files associated with the module",
"type": "array",
@@ -45,10 +56,12 @@
},
"required": [
"binaries",
- "name",
"resources",
+
+ "name",
"type"
- ]
+ ],
+ "additionalProperties": false
}
],
"definitions": {
diff --git a/meta/schemas/manifest.json b/meta/schemas/manifest.json
index bac0c4a..5c3be80 100644
--- a/meta/schemas/manifest.json
+++ b/meta/schemas/manifest.json
@@ -1,5 +1,7 @@
{
- "description": "A target image",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/manifest.json",
+ "description": "The manifest describing the contents of the SDK",
"type": "object",
"properties": {
"arch": {
@@ -24,17 +26,43 @@
"target"
]
},
+ "id": {
+ "description": "An opaque identifier for this SDK",
+ "type": "string"
+ },
"parts": {
- "description": "The metadata files for elements in the SDK",
+ "description": "The elements in this SDK",
"type": "array",
+ "minItems": 1,
"items": {
- "$ref": "common.json#/definitions/file"
+ "type": "object",
+ "properties": {
+ "type": {
+ "description": "The type of the element",
+ "$ref": "common.json#/definitions/type"
+ },
+ "meta": {
+ "description": "The metadata file for the element",
+ "$ref": "common.json#/definitions/file"
+ }
+ },
+ "required": [
+ "meta",
+ "type"
+ ],
+ "additionalProperties": false
}
+ },
+ "schema_version": {
+ "description": "An opaque identifier for metadata schemas in the SDK",
+ "type": "string"
}
},
- "additionalProperties": false,
"required": [
"arch",
- "parts"
- ]
+ "id",
+ "parts",
+ "schema_version"
+ ],
+ "additionalProperties": false
}
diff --git a/meta/schemas/sysroot.json b/meta/schemas/sysroot.json
index e7e2bc6..9924ce2 100644
--- a/meta/schemas/sysroot.json
+++ b/meta/schemas/sysroot.json
@@ -1,4 +1,6 @@
{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://fuchsia.com/schemas/sdk/sysroot.json",
"description": "The sysroot",
"type": "object",
"allOf": [
@@ -8,10 +10,15 @@
{
"properties": {
"type": {
- "description": "Marker for this type of element",
- "type": "string",
- "enum": [
- "sysroot"
+ "allOf": [
+ {
+ "$ref": "common.json#/definitions/type"
+ },
+ {
+ "enum": [
+ "sysroot"
+ ]
+ }
]
},
"name": {
@@ -40,10 +47,12 @@
}
},
"required": [
+ "versions",
+
"name",
- "type",
- "versions"
- ]
+ "type"
+ ],
+ "additionalProperties": false
}
],
"definitions": {
@@ -62,6 +71,10 @@
"$ref": "common.json#/definitions/file"
}
},
+ "dist_dir": {
+ "description": "Path to the base directory for prebuilt libraries",
+ "$ref": "common.json#/definitions/file"
+ },
"include_dir": {
"description": "Path to the base directory for includes",
"$ref": "common.json#/definitions/file"
@@ -94,8 +107,10 @@
"include_dir",
"link_libs",
"dist_libs",
- "debug_libs"
- ]
+ "debug_libs",
+ "dist_dir"
+ ],
+ "additionalProperties": false
}
}
}
diff --git a/pkg/async-cpp/executor.cc b/pkg/async-cpp/executor.cc
new file mode 100644
index 0000000..27b3835
--- /dev/null
+++ b/pkg/async-cpp/executor.cc
@@ -0,0 +1,228 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/executor.h>
+
+#include <zircon/assert.h>
+
+namespace async {
+
+Executor::Executor(async_dispatcher_t* dispatcher)
+ : dispatcher_(new DispatcherImpl(dispatcher, this)) {}
+
+Executor::~Executor() {
+ dispatcher_->Shutdown();
+}
+
+void Executor::schedule_task(fit::pending_task task) {
+ ZX_DEBUG_ASSERT(task);
+ dispatcher_->ScheduleTask(std::move(task));
+}
+
+Executor::DispatcherImpl::DispatcherImpl(async_dispatcher_t* dispatcher,
+ Executor* executor)
+ : async_task_t{{ASYNC_STATE_INIT}, &DispatcherImpl::Dispatch, 0},
+ dispatcher_(dispatcher), executor_(executor) {
+ ZX_DEBUG_ASSERT(dispatcher_ != nullptr);
+ ZX_DEBUG_ASSERT(executor_ != nullptr);
+}
+
+Executor::DispatcherImpl::~DispatcherImpl() {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ ZX_DEBUG_ASSERT(guarded_.was_shutdown_);
+ ZX_DEBUG_ASSERT(!guarded_.dispatch_pending_);
+ ZX_DEBUG_ASSERT(!guarded_.scheduler_.has_runnable_tasks());
+ ZX_DEBUG_ASSERT(!guarded_.scheduler_.has_suspended_tasks());
+ ZX_DEBUG_ASSERT(!guarded_.scheduler_.has_outstanding_tickets());
+ ZX_DEBUG_ASSERT(guarded_.incoming_tasks_.empty());
+ ZX_DEBUG_ASSERT(!guarded_.task_running_);
+}
+
+// Unfortunately std::unique_lock does not support thread-safety annotations
+void Executor::DispatcherImpl::Shutdown() FIT_NO_THREAD_SAFETY_ANALYSIS {
+ std::unique_lock<std::mutex> lock(guarded_.mutex_);
+ ZX_DEBUG_ASSERT(!guarded_.was_shutdown_);
+ ZX_ASSERT_MSG(!guarded_.task_running_,
+ "async::Executor must not be destroyed while tasks may "
+ "be running concurrently on the dispatcher because the "
+ "task's context holds a pointer to the executor.");
+ guarded_.was_shutdown_ = true;
+ PurgeTasksAndMaybeDeleteSelfLocked(std::move(lock));
+}
+
+void Executor::DispatcherImpl::ScheduleTask(fit::pending_task task) {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ ZX_DEBUG_ASSERT(!guarded_.was_shutdown_);
+
+ // Try to post the task first.
+ // This may fail if the loop is being shut down, in which case we
+ // will let the task be destroyed once it goes out of scope.
+ if (!guarded_.loop_failure_ && ScheduleDispatchLocked()) {
+ guarded_.incoming_tasks_.push(std::move(task));
+ } // else drop the task once the function returns
+}
+
+void Executor::DispatcherImpl::Dispatch(
+ async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status) {
+ DispatcherImpl* self = static_cast<DispatcherImpl*>(task);
+ self->Dispatch(status);
+}
+
+// Unfortunately std::unique_lock does not support thread-safety annotations
+void Executor::DispatcherImpl::Dispatch(zx_status_t status)
+ FIT_NO_THREAD_SAFETY_ANALYSIS {
+ std::unique_lock<std::mutex> lock(guarded_.mutex_);
+ ZX_DEBUG_ASSERT(guarded_.dispatch_pending_);
+ ZX_DEBUG_ASSERT(!guarded_.loop_failure_);
+ ZX_DEBUG_ASSERT(!guarded_.task_running_);
+
+ if (status == ZX_OK) {
+ // Accept incoming tasks only once before entering the loop.
+ //
+ // This ensures that each invocation of |Dispatch()| has a bounded
+ // amount of work to perform. Specifically, it will only execute
+ // incoming tasks, tasks that are already runnable, and tasks that are
+ // currently suspended but become runnable while the loop is executing.
+ // Once finished, the loop returns control back to the async dispatcher.
+ //
+ // The purpose of this deconstruction is to prevent other units of work
+ // scheduled by the async dispatcher from being starved in the event
+ // that there is a continuous stream of new tasks being scheduled on the
+ // executor. As an extreme example, we must ensure that the async
+ // dispatcher has an opportunity to process its own quit message and
+ // shut down in that scenario.
+ //
+ // An alternative way to solve this problem would be to not loop at all.
+ // Unfortunately, that would significantly increase the overhead of
+ // processing tasks resumed by other tasks.
+ AcceptIncomingTasksLocked();
+ while (!guarded_.was_shutdown_) {
+ guarded_.scheduler_.take_runnable_tasks(&runnable_tasks_);
+ if (runnable_tasks_.empty()) {
+ guarded_.dispatch_pending_ = false;
+ if (guarded_.incoming_tasks_.empty() ||
+ ScheduleDispatchLocked()) {
+ return; // all done
+ }
+ break; // a loop failure occurred, we need to clean up
+ }
+
+ // Drop lock while running tasks then reaquire it.
+ guarded_.task_running_ = true;
+ lock.unlock();
+ do {
+ RunTask(&runnable_tasks_.front());
+ runnable_tasks_.pop(); // the task may be destroyed here if it was not suspended
+ } while (!runnable_tasks_.empty());
+ lock.lock();
+ guarded_.task_running_ = false;
+ }
+ } else {
+ guarded_.loop_failure_ = true;
+ }
+ guarded_.dispatch_pending_ = false;
+ PurgeTasksAndMaybeDeleteSelfLocked(std::move(lock));
+}
+
+void Executor::DispatcherImpl::RunTask(fit::pending_task* task) {
+ ZX_DEBUG_ASSERT(current_task_ticket_ == 0);
+ const bool finished = (*task)(*this);
+ ZX_DEBUG_ASSERT(!*task == finished);
+ if (current_task_ticket_ == 0) {
+ return; // task was not suspended, no ticket was produced
+ }
+
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ guarded_.scheduler_.finalize_ticket(current_task_ticket_, task);
+ current_task_ticket_ = 0;
+}
+
+// Must only be called while |run_task()| is running a task.
+// This happens when the task's continuation calls |context::suspend_task()|
+// upon the context it received as an argument.
+fit::suspended_task Executor::DispatcherImpl::suspend_task() {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ ZX_DEBUG_ASSERT(guarded_.task_running_);
+ if (current_task_ticket_ == 0) {
+ current_task_ticket_ = guarded_.scheduler_.obtain_ticket(
+ 2 /*initial_refs*/);
+ } else {
+ guarded_.scheduler_.duplicate_ticket(current_task_ticket_);
+ }
+ return fit::suspended_task(this, current_task_ticket_);
+}
+
+fit::suspended_task::ticket Executor::DispatcherImpl::duplicate_ticket(
+ fit::suspended_task::ticket ticket) {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ guarded_.scheduler_.duplicate_ticket(ticket);
+ return ticket;
+}
+
+// Unfortunately std::unique_lock does not support thread-safety annotations
+void Executor::DispatcherImpl::resolve_ticket(
+ fit::suspended_task::ticket ticket, bool resume_task)
+ FIT_NO_THREAD_SAFETY_ANALYSIS {
+ fit::pending_task abandoned_task; // drop outside of the lock
+ {
+ std::unique_lock<std::mutex> lock(guarded_.mutex_);
+ bool did_resume = false;
+ if (resume_task) {
+ did_resume = guarded_.scheduler_.resume_task_with_ticket(ticket);
+ } else {
+ abandoned_task = guarded_.scheduler_.release_ticket(ticket);
+ }
+ if (!guarded_.was_shutdown_ && !guarded_.loop_failure_ &&
+ (!did_resume || ScheduleDispatchLocked())) {
+ return; // all done
+ }
+ PurgeTasksAndMaybeDeleteSelfLocked(std::move(lock));
+ }
+}
+
+bool Executor::DispatcherImpl::ScheduleDispatchLocked() {
+ ZX_DEBUG_ASSERT(!guarded_.was_shutdown_ && !guarded_.loop_failure_);
+ if (guarded_.dispatch_pending_) {
+ return true; // nothing to do
+ }
+ zx_status_t status = async_post_task(dispatcher_, this);
+ ZX_ASSERT_MSG(status == ZX_OK || status == ZX_ERR_BAD_STATE,
+ "status=%d", status);
+ if (status == ZX_OK) {
+ guarded_.dispatch_pending_ = true;
+ return true; // everything's ok
+ }
+ guarded_.loop_failure_ = true;
+ return false; // failed
+}
+
+void Executor::DispatcherImpl::AcceptIncomingTasksLocked() {
+ while (!guarded_.incoming_tasks_.empty()) {
+ guarded_.scheduler_.schedule_task(
+ std::move(guarded_.incoming_tasks_.front()));
+ guarded_.incoming_tasks_.pop();
+ }
+}
+
+// Unfortunately std::unique_lock does not support thread-safety annotations
+void Executor::DispatcherImpl::PurgeTasksAndMaybeDeleteSelfLocked(
+ std::unique_lock<std::mutex> lock) FIT_NO_THREAD_SAFETY_ANALYSIS {
+ ZX_DEBUG_ASSERT(lock.owns_lock());
+ ZX_DEBUG_ASSERT(guarded_.was_shutdown_ || guarded_.loop_failure_);
+
+ fit::subtle::scheduler::task_queue tasks;
+ AcceptIncomingTasksLocked();
+ guarded_.scheduler_.take_all_tasks(&tasks);
+ const bool can_delete_self = guarded_.was_shutdown_ &&
+ !guarded_.dispatch_pending_ &&
+ !guarded_.scheduler_.has_outstanding_tickets();
+
+ lock.unlock();
+
+ if (can_delete_self) {
+ delete this;
+ }
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/include/lib/async/cpp/executor.h b/pkg/async-cpp/include/lib/async/cpp/executor.h
new file mode 100644
index 0000000..00d6a10
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/executor.h
@@ -0,0 +1,174 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_EXECUTOR_H_
+#define LIB_ASYNC_CPP_EXECUTOR_H_
+
+#include <mutex>
+
+#include <lib/async/dispatcher.h>
+#include <lib/async/task.h>
+#include <lib/fit/promise.h>
+#include <lib/fit/scheduler.h>
+#include <lib/fit/thread_safety.h>
+#include <lib/zx/time.h>
+
+namespace async {
+
+// Execution context for an asynchronous task that runs within the scope
+// of an |async_dispatcher_t|'s dispatch loop, such as a |async::Promise|.
+class Context : public fit::context {
+public:
+ // Gets the executor's |async_dispatcher_t|, never null.
+ virtual async_dispatcher_t* dispatcher() const = 0;
+
+protected:
+ virtual ~Context() = default;
+};
+
+// An asynchronous task executor that wraps an |async_dispatcher_t|.
+//
+// This allows asynchronous tasks, such as promises, to be evaluated alongside
+// other asynchronous operations managed by the |async_dispatcher_t|.
+class Executor final : public fit::executor {
+public:
+ // Wraps the specified dispatcher.
+ //
+ // |dispatcher| must not be null and it must outlive the executor itself.
+ explicit Executor(async_dispatcher_t* dispatcher);
+
+ // Destroys the executor along with all of its remaining scheduled tasks
+ // that have yet to complete.
+ ~Executor() override;
+
+ // Gets the executor's |async_dispatcher_t|, never null.
+ async_dispatcher_t* dispatcher() const { return dispatcher_->dispatcher(); }
+
+ // Schedules a task for eventual execution by the executor.
+ //
+ // This method is thread-safe.
+ void schedule_task(fit::pending_task task) override;
+
+ Executor(const Executor&) = delete;
+ Executor(Executor&&) = delete;
+ Executor& operator=(const Executor&) = delete;
+ Executor& operator=(Executor&&) = delete;
+
+private:
+ // The dispatcher runs tasks, provides the suspended task resolver, and
+ // provides the task context.
+ //
+ // The lifetime of this object is somewhat complex since there are pointers
+ // to it from multiple sources which are released in different ways.
+ //
+ // - |Executor| holds a pointer in |dispatcher_| which it releases after
+ // calling |Shutdown()| to inform the dispatcher of its own demise
+ // - |suspended_task| holds a pointer to the dispatcher's resolver
+ // interface and the number of outstanding pointers corresponds to the
+ // number of outstanding suspended task tickets tracked by |scheduler_|.
+ // - |async_dispatcher_t| holds a pointer to the dispatcher's async task
+ // interface whenever dispatch is pending as indicated by |dispatch_pending_|.
+ //
+ // The dispatcher deletes itself once all pointers have been released.
+ // See also |PurgeTasksAndMaybeDeleteSelfLocked()|.
+ class DispatcherImpl final : public fit::suspended_task::resolver,
+ public async::Context,
+ public async_task_t {
+ public:
+ DispatcherImpl(async_dispatcher_t* dispatcher,
+ Executor* executor);
+
+ void Shutdown();
+ void ScheduleTask(fit::pending_task task);
+
+ // |executor()| and |dispatcher()| are presented on the |async::Context|
+ // so they are only accessible while |task_running_| is true which
+ // implies that |executor_| and |dispatcher_| have not been destroyed.
+ Executor* executor() const override { return executor_; }
+ async_dispatcher_t* dispatcher() const override { return dispatcher_; }
+
+ // Suspends the currently running task. This method is presented
+ // on the |async::Context| so it can only be called while
+ // |task_running_| is true as above.
+ fit::suspended_task suspend_task() override;
+
+ // These methods implement the suspended task token contract.
+ // They may be called on any thread at any time.
+ fit::suspended_task::ticket duplicate_ticket(
+ fit::suspended_task::ticket ticket) override;
+ void resolve_ticket(
+ fit::suspended_task::ticket ticket, bool resume_task) override;
+
+ private:
+ ~DispatcherImpl() override;
+
+ // Callback from |async_dispatcher_t*|.
+ // Invokes |Dispatch()| to run all runnable tasks.
+ static void Dispatch(async_dispatcher_t* dispatcher,
+ async_task_t* task, zx_status_t status);
+ void Dispatch(zx_status_t status);
+
+ // Runs the specified task. Called by |Dispatch()|.
+ void RunTask(fit::pending_task* task);
+
+ // Attempts to schedule a call to |Dispatch()| on the async dispatcher.
+ // Returns true if a dispatch is pending.
+ bool ScheduleDispatchLocked() FIT_REQUIRES(guarded_.mutex_);
+
+ // Moves all tasks from |incoming_tasks_| to the |scheduler_| runnable queue.
+ void AcceptIncomingTasksLocked() FIT_REQUIRES(guarded_.mutex_);
+
+ // When |was_shutdown_| or |loop_failure_| is true, purges any tasks
+ // that remain and deletes the dispatcher if all outstanding references
+ // to it have gone away. Should be called at points where one of these
+ // conditions changes. Takes ownership of the lock and drops it.
+ void PurgeTasksAndMaybeDeleteSelfLocked(
+ std::unique_lock<std::mutex> lock) FIT_REQUIRES(guarded_.mutex_);
+
+ async_dispatcher_t* const dispatcher_;
+ Executor* const executor_;
+
+ // The queue of runnable tasks.
+ // Only accessed by |RunTask()| and |suspend_task()| which happens
+ // on the dispatch thread.
+ fit::subtle::scheduler::task_queue runnable_tasks_;
+
+ // The current suspended task ticket or 0 if none.
+ // Only accessed by |RunTask()| and |suspend_task()| which happens
+ // on the dispatch thread.
+ fit::suspended_task::ticket current_task_ticket_ = 0;
+
+ // A bunch of state that is guarded by a mutex.
+ struct {
+ std::mutex mutex_;
+
+ // True if the executor is about to be destroyed.
+ bool was_shutdown_ FIT_GUARDED(mutex_) = false;
+
+ // True if the underlying async_dispatcher_t reported an error.
+ bool loop_failure_ FIT_GUARDED(mutex_) = false;
+
+ // True if a call to |Dispatch()| is pending.
+ bool dispatch_pending_ FIT_GUARDED(mutex_) = false;
+
+ // True while |RunTask| is running a task.
+ bool task_running_ FIT_GUARDED(mutex_) = false;
+
+ // Holds tasks that have been scheduled on this dispatcher.
+ fit::subtle::scheduler scheduler_ FIT_GUARDED(mutex_);
+
+ // Newly scheduled tasks which have yet to be added to the
+ // runnable queue. This allows the dispatch to distinguish between
+ // newly scheduled tasks and resumed tasks so it can manage them
+ // separately. See comments in |Dispatch()|.
+ fit::subtle::scheduler::task_queue incoming_tasks_ FIT_GUARDED(mutex_);
+ } guarded_;
+ };
+
+ DispatcherImpl* dispatcher_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_EXECUTOR_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/irq.h b/pkg/async-cpp/include/lib/async/cpp/irq.h
new file mode 100644
index 0000000..ec1e2b7
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/irq.h
@@ -0,0 +1,144 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_irq_H_
+#define LIB_ASYNC_CPP_irq_H_
+
+#include <lib/async/irq.h>
+#include <lib/fit/function.h>
+
+#include <utility>
+
+namespace async {
+
+// Holds context for an irq and its handler, with RAII semantics.
+// Automatically unbinds the irq when it goes out of scope.
+//
+// This class must only be used with single-threaded asynchronous dispatchers
+// and must only be accessed on the dispatch thread since it lacks internal
+// synchronization of its state.
+//
+// Concrete implementations: |async::Irq|, |async::IrqMethod|.
+// Please do not create subclasses of IrqBase outside of this library.
+class IrqBase {
+ protected:
+ explicit IrqBase(zx_handle_t object, zx_signals_t trigger, uint32_t options,
+ async_irq_handler_t* handler);
+ ~IrqBase();
+
+ IrqBase(const IrqBase&) = delete;
+ IrqBase(IrqBase&&) = delete;
+ IrqBase& operator=(const IrqBase&) = delete;
+ IrqBase& operator=(IrqBase&&) = delete;
+
+ public:
+ // Gets or sets the interrupt object.
+ zx_handle_t object() const { return irq_.object; }
+ void set_object(zx_handle_t object) { irq_.object = object; }
+
+ // Begins asynchronously waiting for the object to receive one or more of
+ // the trigger signals. Invokes the handler when the irq is triggered.
+ //
+ // Returns |ZX_OK| if the irq was successfully begun.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Begin(async_dispatcher_t* dispatcher);
+
+ // Cancels the irq.
+ //
+ // If successful, the irq's handler will not run.
+ //
+ // Returns |ZX_OK| if the irq was pending and it has been successfully
+ // canceled; its handler will not run again and can be released immediately.
+ // Returns |ZX_ERR_NOT_FOUND| if there was no pending irq either because it
+ // already completed, or had not been started.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Cancel();
+
+ protected:
+ template <typename T>
+ static T* Dispatch(async_irq* irq) {
+ static_assert(offsetof(IrqBase, irq_) == 0, "");
+ auto self = reinterpret_cast<IrqBase*>(irq);
+ return static_cast<T*>(self);
+ }
+
+ private:
+ async_irq_t irq_;
+ async_dispatcher_t* dispatcher_ = nullptr;
+};
+
+// An asynchronous IRQ whose handler is bound to a |async::irq::Handler| function.
+//
+// Prefer using |async::IrqMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class Irq final : public IrqBase {
+ public:
+ // Handles completion of asynchronous irq operations.
+ //
+ // The |status| is |ZX_OK| if the irq was satisfied and |signal| is non-null.
+ // The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
+ // the task's handler ran or the task was canceled.
+ using Handler = fit::function<void(async_dispatcher_t* dispatcher, async::Irq* irq,
+ zx_status_t status, const zx_packet_interrupt_t* interrupt)>;
+
+ // Creates a irq with options == 0.
+ explicit Irq(zx_handle_t object = ZX_HANDLE_INVALID, zx_signals_t trigger = ZX_SIGNAL_NONE,
+ Handler handler = nullptr)
+ : Irq(object, trigger, 0, std::move(handler)) {}
+
+ // Creates a irq with the provided |options|.
+ explicit Irq(zx_handle_t object, zx_signals_t trigger, uint32_t options,
+ Handler handler = nullptr);
+
+ ~Irq();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_irq_t* irq, zx_status_t status,
+ const zx_packet_interrupt_t* signal);
+
+ Handler handler_;
+};
+
+// An asynchronous irq whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher, async::IrqBase* irq, zx_status_t status,
+// const zx_packet_interrupt_t* interrupt) { ... }
+// async::IrqMethod<Foo, &Foo::Handle> irq_{this};
+// };
+template <class Class,
+ void (Class::*method)(async_dispatcher_t* dispatcher, async::IrqBase* irq,
+ zx_status_t status, const zx_packet_interrupt_t* interrupt)>
+class IrqMethod final : public IrqBase {
+ public:
+ // Creates a irqMethod with options == 0.
+ explicit IrqMethod(Class* instance, zx_handle_t object = ZX_HANDLE_INVALID,
+ zx_signals_t trigger = ZX_SIGNAL_NONE)
+ : IrqMethod(instance, object, trigger, 0) {}
+
+ // Creates a IrqMethod with the provided |options|.
+ explicit IrqMethod(Class* instance, zx_handle_t object, zx_signals_t trigger, uint32_t options)
+ : IrqBase(object, trigger, options, &IrqMethod::CallHandler), instance_(instance) {}
+
+ ~IrqMethod() = default;
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_irq_t* irq, zx_status_t status,
+ const zx_packet_interrupt_t* interrupt) {
+ auto self = Dispatch<IrqMethod>(irq);
+ (self->instance_->*method)(dispatcher, self, status, interrupt);
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_irq_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/paged_vmo.h b/pkg/async-cpp/include/lib/async/cpp/paged_vmo.h
new file mode 100644
index 0000000..e337ccc
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/paged_vmo.h
@@ -0,0 +1,127 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_PAGED_VMO_H_
+#define LIB_ASYNC_CPP_PAGED_VMO_H_
+
+#include <lib/async/paged_vmo.h>
+#include <lib/fit/function.h>
+#include <lib/zx/pager.h>
+#include <lib/zx/vmo.h>
+
+namespace async {
+
+// Holds content for a paged vmo packet receiver and its handler.
+//
+// After successfully binding the port, the client is responsible for
+// retaining the structure in memory (and unmodified) until all packets have
+// been received by the handler or the dispatcher shuts down.
+//
+// Concrete implementations: |async::PagedVmo|, |async::PagedVmoMethod|.
+// Please do not create subclasses of PagedVmoBase outside of this library.
+class PagedVmoBase {
+ protected:
+ explicit PagedVmoBase(async_paged_vmo_handler_t* handler);
+ ~PagedVmoBase();
+
+ PagedVmoBase(const PagedVmoBase&) = delete;
+ PagedVmoBase(PagedVmoBase&&) = delete;
+ PagedVmoBase& operator=(const PagedVmoBase&) = delete;
+ PagedVmoBase& operator=(PagedVmoBase&&) = delete;
+
+ template <typename T>
+ static T* Dispatch(async_paged_vmo_t* paged_vmo, zx_status_t status) {
+ static_assert(offsetof(PagedVmoBase, paged_vmo_) == 0, "Non-castable offset");
+ auto self = reinterpret_cast<PagedVmoBase*>(paged_vmo);
+ if (status != ZX_OK) {
+ self->dispatcher_ = nullptr;
+ }
+ return static_cast<T*>(self);
+ }
+
+ public:
+ // Return true if this object is bound to a VMO.
+ bool is_bound() const { return dispatcher_ != nullptr; }
+
+ // Creates a paged VMO registered with |pager|, which will receive notifications on the
+ // receiver provided in the constructor of |PagedVmoBase|.
+ //
+ // Returns |ZX_ERR_ALREADY_EXISTS| if this object is already associated with a VMO.
+ // May return any error from |async_create_paged_vmo()|.
+ zx_status_t CreateVmo(async_dispatcher_t* dispatcher, zx::unowned_pager pager, uint32_t options,
+ uint64_t vmo_size, zx::vmo* vmo_out);
+
+ // Detach the paged VMO from the underlying port.
+ //
+ // Returns |ZX_OK| if the VMO is successfully detached.
+ // Returns |ZX_ERR_NOT_FOUND| if this object is not bound.
+ // May return any error from |async_detach_paged_vmo()|.
+ zx_status_t Detach();
+
+ private:
+ async_paged_vmo_t paged_vmo_ = {};
+ async_dispatcher_t* dispatcher_ = nullptr;
+};
+
+// A receiver whose handler is bound to a |async::PagedVmo::Handler| function.
+//
+// Prefer using |async::PagedVmoMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class PagedVmo final : public PagedVmoBase {
+ public:
+ // Handles receipt of packets containing page requests.
+ //
+ // The |status| is |ZX_OK| if the packet was successfully delivered and |page_request|
+ // contains the information from the packet, otherwise |page_request| is null.
+ using Handler =
+ fit::function<void(async_dispatcher_t* dispatcher, async::PagedVmo* paged_vmo,
+ zx_status_t status, const zx_packet_page_request_t* page_request)>;
+
+ explicit PagedVmo(Handler handler = nullptr);
+ ~PagedVmo();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ zx_status_t status, const zx_packet_page_request_t* page_request);
+
+ Handler handler_;
+};
+
+// A receiver whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher,
+// async::PagedVmoBase* paged_vmo,
+// zx_status_t status,
+// const zx_packet_page_request_t* page_request) {
+// ...
+// }
+// async::PagedVmoMethod<Foo, &Foo::Handle> paged_vmo_{this};
+// };
+template <class Class,
+ void (Class::*method)(async_dispatcher_t* dispatcher, async::PagedVmoBase* receiver,
+ zx_status_t status, const zx_packet_page_request_t* page_request)>
+class PagedVmoMethod final : public PagedVmoBase {
+ public:
+ explicit PagedVmoMethod(Class* instance)
+ : PagedVmoBase(&PagedVmoMethod::CallHandler), instance_(instance) {}
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ zx_status_t status, const zx_packet_page_request_t* page_request) {
+ auto self = Dispatch<PagedVmoMethod>(paged_vmo, status);
+ (self->instance_->*method)(dispatcher, self, status, page_request);
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_PAGED_VMO_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/receiver.h b/pkg/async-cpp/include/lib/async/cpp/receiver.h
new file mode 100644
index 0000000..273049f
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/receiver.h
@@ -0,0 +1,115 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_RECEIVER_H_
+#define LIB_ASYNC_CPP_RECEIVER_H_
+
+#include <lib/async/receiver.h>
+#include <lib/fit/function.h>
+
+#include <utility>
+
+namespace async {
+
+// Holds content for a packet receiver and its handler.
+//
+// After successfully queuing packets to the receiver, the client is responsible
+// for retaining the structure in memory (and unmodified) until all packets have
+// been received by the handler or the dispatcher shuts down. There is no way
+// to cancel a packet which has been queued.
+//
+// Multiple packets may be delivered to the same receiver concurrently.
+//
+// Concrete implementations: |async::Receiver|, |async::ReceiverMethod|.
+// Please do not create subclasses of ReceiverBase outside of this library.
+class ReceiverBase {
+ protected:
+ explicit ReceiverBase(async_receiver_handler_t* handler);
+ ~ReceiverBase();
+
+ ReceiverBase(const ReceiverBase&) = delete;
+ ReceiverBase(ReceiverBase&&) = delete;
+ ReceiverBase& operator=(const ReceiverBase&) = delete;
+ ReceiverBase& operator=(ReceiverBase&&) = delete;
+
+ public:
+ // Enqueues a packet of data for delivery to a receiver.
+ //
+ // The |data| will be copied into the packet. May be NULL to create a
+ // zero-initialized packet payload.
+ //
+ // Returns |ZX_OK| if the packet was successfully enqueued.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t QueuePacket(async_dispatcher_t* dispatcher, const zx_packet_user_t* data = nullptr);
+
+ protected:
+ template <typename T>
+ static T* Dispatch(async_receiver_t* receiver) {
+ static_assert(offsetof(ReceiverBase, receiver_) == 0, "");
+ auto self = reinterpret_cast<ReceiverBase*>(receiver);
+ return static_cast<T*>(self);
+ }
+
+ private:
+ async_receiver_t receiver_;
+};
+
+// A receiver whose handler is bound to a |async::Task::Handler| function.
+//
+// Prefer using |async::ReceiverMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class Receiver final : public ReceiverBase {
+ public:
+ // Handles receipt of packets containing user supplied data.
+ //
+ // The |status| is |ZX_OK| if the packet was successfully delivered and |data|
+ // contains the information from the packet, otherwise |data| is null.
+ using Handler = fit::function<void(async_dispatcher_t* dispatcher, async::Receiver* receiver,
+ zx_status_t status, const zx_packet_user_t* data)>;
+
+ explicit Receiver(Handler handler = nullptr);
+ ~Receiver();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
+ zx_status_t status, const zx_packet_user_t* data);
+
+ Handler handler_;
+};
+
+// A receiver whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher, async::ReceiverBase* receiver, zx_status_t
+// status,
+// const zx_packet_user_t* data) { ... }
+// async::ReceiverMethod<Foo, &Foo::Handle> receiver_{this};
+// };
+template <class Class,
+ void (Class::*method)(async_dispatcher_t* dispatcher, async::ReceiverBase* receiver,
+ zx_status_t status, const zx_packet_user_t* data)>
+class ReceiverMethod final : public ReceiverBase {
+ public:
+ explicit ReceiverMethod(Class* instance)
+ : ReceiverBase(&ReceiverMethod::CallHandler), instance_(instance) {}
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
+ zx_status_t status, const zx_packet_user_t* data) {
+ auto self = Dispatch<ReceiverMethod>(receiver);
+ (self->instance_->*method)(dispatcher, self, status, data);
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_RECEIVER_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/task.h b/pkg/async-cpp/include/lib/async/cpp/task.h
new file mode 100644
index 0000000..0343919
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/task.h
@@ -0,0 +1,231 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_TASK_H_
+#define LIB_ASYNC_CPP_TASK_H_
+
+#include <lib/async/task.h>
+#include <lib/fit/function.h>
+#include <lib/zx/time.h>
+
+#include <utility>
+
+namespace async {
+
+// Posts a task to invoke |handler| with a deadline of now.
+//
+// The handler will not run if the dispatcher shuts down before it comes due.
+//
+// Returns |ZX_OK| if the task was successfully posted.
+// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+zx_status_t PostTask(async_dispatcher_t* dispatcher, fit::closure handler);
+
+// Posts a task to invoke |handler| with a deadline expressed as a |delay| from now.
+//
+// The handler will not run if the dispatcher shuts down before it comes due.
+//
+// Returns |ZX_OK| if the task was successfully posted.
+// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+zx_status_t PostDelayedTask(async_dispatcher_t* dispatcher, fit::closure handler,
+ zx::duration delay);
+
+// Posts a task to invoke |handler| with the specified |deadline|.
+//
+// The handler will not run if the dispatcher shuts down before it comes due.
+//
+// Returns |ZX_OK| if the task was successfully posted.
+// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+zx_status_t PostTaskForTime(async_dispatcher_t* dispatcher, fit::closure handler,
+ zx::time deadline);
+
+// Holds context for a task and its handler, with RAII semantics.
+// Automatically cancels the task when it goes out of scope.
+//
+// After successfully posting the task, the client is responsible for retaining
+// the structure in memory (and unmodified) until the task's handler runs, the task
+// is successfully canceled, or the dispatcher shuts down. Thereafter, the task
+// may be posted again or destroyed.
+//
+// This class must only be used with single-threaded asynchronous dispatchers
+// and must only be accessed on the dispatch thread since it lacks internal
+// synchronization of its state.
+//
+// Concrete implementations: |async::Task|, |async::TaskMethod|,
+// |async::TaskClosure|, |async::TaskClosureMethod|.
+// Please do not create subclasses of TaskBase outside of this library.
+class TaskBase {
+ protected:
+ explicit TaskBase(async_task_handler_t* handler);
+ ~TaskBase();
+
+ TaskBase(const TaskBase&) = delete;
+ TaskBase(TaskBase&&) = delete;
+ TaskBase& operator=(const TaskBase&) = delete;
+ TaskBase& operator=(TaskBase&&) = delete;
+
+ public:
+ // Returns true if the task has been posted and has not yet executed or been canceled.
+ bool is_pending() const { return dispatcher_ != nullptr; }
+
+ // The last deadline with which the task was posted, or |zx::time::infinite()|
+ // if it has never been posted.
+ zx::time last_deadline() const { return zx::time(task_.deadline); }
+
+ // Posts a task to invoke the handler with a deadline of now.
+ //
+ // Returns |ZX_OK| if the task was successfully posted.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_ALREADY_EXISTS| if the task is already pending.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Post(async_dispatcher_t* dispatcher);
+
+ // Posts a task to invoke the handler with a deadline expressed as a |delay| from now.
+ //
+ // Returns |ZX_OK| if the task was successfully posted.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_ALREADY_EXISTS| if the task is already pending.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t PostDelayed(async_dispatcher_t* dispatcher, zx::duration delay);
+
+ // Posts a task to invoke the handler with the specified |deadline|.
+ //
+ // The |deadline| must be expressed in the time base used by the asynchronous
+ // dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).
+ // See |async_now()| for details.
+ //
+ // Returns |ZX_OK| if the task was successfully posted.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_ALREADY_EXISTS| if the task is already pending.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t PostForTime(async_dispatcher_t* dispatcher, zx::time deadline);
+
+ // Cancels the task.
+ //
+ // If successful, the task's handler will not run.
+ //
+ // Returns |ZX_OK| if the task was pending and it has been successfully
+ // canceled; its handler will not run again and can be released immediately.
+ // Returns |ZX_ERR_NOT_FOUND| if task was not pending either because its
+ // handler already ran, or the task had not been posted.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Cancel();
+
+ protected:
+ template <typename T>
+ static T* Dispatch(async_task_t* task) {
+ static_assert(offsetof(TaskBase, task_) == 0, "");
+ auto self = reinterpret_cast<TaskBase*>(task);
+ self->dispatcher_ = nullptr;
+ return static_cast<T*>(self);
+ }
+
+ private:
+ async_task_t task_;
+ async_dispatcher_t* dispatcher_ = nullptr;
+};
+
+// A task whose handler is bound to a |async::Task::Handler| function.
+//
+// Prefer using |async::TaskMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class Task final : public TaskBase {
+ public:
+ // Handles execution of a posted task.
+ //
+ // The |status| is |ZX_OK| if the task's deadline elapsed and the task should run.
+ // The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
+ // the task's handler ran or the task was canceled.
+ using Handler =
+ fit::function<void(async_dispatcher_t* dispatcher, async::Task* task, zx_status_t status)>;
+
+ explicit Task(Handler handler = nullptr);
+ ~Task();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status);
+
+ Handler handler_;
+};
+
+// A task whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher, async::TaskBase* task, zx_status_t status) { ...
+// } async::TaskMethod<Foo, &Foo::Handle> task_{this};
+// };
+template <class Class, void (Class::*method)(async_dispatcher_t* dispatcher, async::TaskBase* task,
+ zx_status_t status)>
+class TaskMethod final : public TaskBase {
+ public:
+ explicit TaskMethod(Class* instance) : TaskBase(&TaskMethod::CallHandler), instance_(instance) {}
+ ~TaskMethod() = default;
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status) {
+ auto self = Dispatch<TaskMethod>(task);
+ (self->instance_->*method)(dispatcher, self, status);
+ }
+
+ Class* const instance_;
+};
+
+// A task whose handler is bound to a |fit::closure| function with no arguments.
+// The closure is not invoked when errors occur since it doesn't have a |zx_status_t|
+// argument.
+//
+// Prefer using |async::TaskClosureMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class TaskClosure final : public TaskBase {
+ public:
+ explicit TaskClosure(fit::closure handler = nullptr);
+ ~TaskClosure();
+
+ void set_handler(fit::closure handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status);
+
+ fit::closure handler_;
+};
+
+// A task whose handler is bound to a fixed class member function with no arguments.
+// The closure is not invoked when errors occur since it doesn't have a |zx_status_t|
+// argument.
+//
+// Usage:
+//
+// class Foo {
+// void Handle() { ... }
+// async::TaskClosureMethod<Foo, &Foo::Handle> trap_{this};
+// };
+template <class Class, void (Class::*method)()>
+class TaskClosureMethod final : public TaskBase {
+ public:
+ explicit TaskClosureMethod(Class* instance)
+ : TaskBase(&TaskClosureMethod::CallHandler), instance_(instance) {}
+ ~TaskClosureMethod() = default;
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status) {
+ auto self = Dispatch<TaskClosureMethod>(task); // must do this if status is not ok
+ if (status == ZX_OK) {
+ (self->instance_->*method)();
+ }
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_TASK_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/time.h b/pkg/async-cpp/include/lib/async/cpp/time.h
new file mode 100644
index 0000000..df7950e
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/time.h
@@ -0,0 +1,20 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_TIME_H_
+#define LIB_ASYNC_CPP_TIME_H_
+
+#include <lib/async/time.h>
+#include <lib/zx/time.h>
+
+namespace async {
+
+// Returns the current time in the dispatcher's timebase.
+// For most loops, this is generally obtained from |ZX_CLOCK_MONOTONIC|
+// but certain loops may use a different timebase, notably for testing.
+inline zx::time Now(async_dispatcher_t* dispatcher) { return zx::time(async_now(dispatcher)); }
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_TIME_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/trap.h b/pkg/async-cpp/include/lib/async/cpp/trap.h
new file mode 100644
index 0000000..35f06ec
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/trap.h
@@ -0,0 +1,123 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_TRAP_H_
+#define LIB_ASYNC_CPP_TRAP_H_
+
+#include <lib/async/trap.h>
+#include <lib/fit/function.h>
+#include <lib/zx/guest.h>
+
+#include <utility>
+
+namespace async {
+
+// Holds context for a bell trap and its handler.
+//
+// After successfully posting setting the trap, the client is responsible for retaining
+// the structure in memory (and unmodified) until the guest has been destroyed or the
+// dispatcher shuts down. There is no way to cancel a trap which has been set.
+//
+// Concrete implementations: |async::GuestBellTrap|, |async::GuestBellTrapMethod|.
+// Please do not create subclasses of GuestBellTrapBase outside of this library.
+class GuestBellTrapBase {
+ protected:
+ explicit GuestBellTrapBase(async_guest_bell_trap_handler_t* handler);
+ ~GuestBellTrapBase();
+
+ GuestBellTrapBase(const GuestBellTrapBase&) = delete;
+ GuestBellTrapBase(GuestBellTrapBase&&) = delete;
+ GuestBellTrapBase& operator=(const GuestBellTrapBase&) = delete;
+ GuestBellTrapBase& operator=(GuestBellTrapBase&&) = delete;
+
+ public:
+ // Sets a bell trap in the guest to be handled asynchronously via a handler.
+ //
+ // |guest| is the handle of the guest the trap will be set on.
+ // |addr| is the base address for the trap in the guest's physical address space.
+ // |length| is the size of the trap in the guest's physical address space.
+ //
+ // Returns |ZX_OK| if the trap was successfully set.
+ // Returns |ZX_ERR_ACCESS_DENIED| if the guest does not have |ZX_RIGHT_WRITE|.
+ // Returns |ZX_ERR_ALREADY_EXISTS| if a bell trap with the same |addr| exists.
+ // Returns |ZX_ERR_INVALID_ARGS| if |addr| or |length| are invalid.
+ // Returns |ZX_ERR_OUT_OF_RANGE| if |addr| or |length| are out of range of the
+ // address space.
+ // Returns |ZX_ERR_WRONG_TYPE| if |guest| is not a handle to a guest.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ //
+ // This operation is thread-safe.
+ zx_status_t SetTrap(async_dispatcher_t* dispatcher, const zx::guest& guest, zx_vaddr_t addr,
+ size_t length);
+
+ protected:
+ template <typename T>
+ static T* Dispatch(async_guest_bell_trap_t* trap) {
+ static_assert(offsetof(GuestBellTrapBase, trap_) == 0, "");
+ auto self = reinterpret_cast<GuestBellTrapBase*>(trap);
+ return static_cast<T*>(self);
+ }
+
+ private:
+ async_guest_bell_trap_t trap_;
+};
+
+// A bell trap whose handler is bound to a |async::Task::Handler| function.
+//
+// Prefer using |async::GuestBellTrapMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class GuestBellTrap final : public GuestBellTrapBase {
+ public:
+ // Handles an asynchronous trap access.
+ //
+ // The |status| is |ZX_OK| if the bell was received and |bell| contains the
+ // information from the packet, otherwise |bell| is null.
+ using Handler = fit::function<void(async_dispatcher_t* dispatcher, async::GuestBellTrap* trap,
+ zx_status_t status, const zx_packet_guest_bell_t* bell)>;
+
+ explicit GuestBellTrap(Handler handler = nullptr);
+ ~GuestBellTrap();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
+ zx_status_t status, const zx_packet_guest_bell_t* bell);
+
+ Handler handler_;
+};
+
+// A bell trap whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher, async::GuestBellTrapBase* trap, zx_status_t
+// status,
+// const zx_packet_guest_bell_t* bell) { ... }
+// async::GuestBellTrapMethod<Foo, &Foo::Handle> trap_{this};
+// };
+template <class Class,
+ void (Class::*method)(async_dispatcher_t* dispatcher, async::GuestBellTrapBase* trap,
+ zx_status_t status, const zx_packet_guest_bell_t* bell)>
+class GuestBellTrapMethod final : public GuestBellTrapBase {
+ public:
+ explicit GuestBellTrapMethod(Class* instance)
+ : GuestBellTrapBase(&GuestBellTrapMethod::CallHandler), instance_(instance) {}
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
+ zx_status_t status, const zx_packet_guest_bell_t* bell) {
+ auto self = Dispatch<GuestBellTrapMethod>(trap);
+ (self->instance_->*method)(dispatcher, self, status, bell);
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_TRAP_H_
diff --git a/pkg/async-cpp/include/lib/async/cpp/wait.h b/pkg/async-cpp/include/lib/async/cpp/wait.h
new file mode 100644
index 0000000..0f0d88d
--- /dev/null
+++ b/pkg/async-cpp/include/lib/async/cpp/wait.h
@@ -0,0 +1,200 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_CPP_WAIT_H_
+#define LIB_ASYNC_CPP_WAIT_H_
+
+#include <lib/async/wait.h>
+#include <lib/fit/function.h>
+
+#include <utility>
+
+namespace async {
+
+// Holds context for an asynchronous wait and its handler, with RAII semantics.
+// Automatically cancels the wait when it goes out of scope.
+//
+// After successfully beginning the wait, the client is responsible for retaining
+// the structure in memory (and unmodified) until the wait's handler runs, the wait
+// is successfully canceled, or the dispatcher shuts down. Thereafter, the wait
+// may be begun again or destroyed.
+//
+// This class must only be used with single-threaded asynchronous dispatchers
+// and must only be accessed on the dispatch thread since it lacks internal
+// synchronization of its state.
+//
+// Concrete implementations: |async::Wait|, |async::WaitMethod|.
+// Please do not create subclasses of WaitBase outside of this library.
+class WaitBase {
+ protected:
+ explicit WaitBase(zx_handle_t object, zx_signals_t trigger, uint32_t options,
+ async_wait_handler_t* handler);
+ ~WaitBase();
+
+ WaitBase(const WaitBase&) = delete;
+ WaitBase(WaitBase&&) = delete;
+ WaitBase& operator=(const WaitBase&) = delete;
+ WaitBase& operator=(WaitBase&&) = delete;
+
+ public:
+ // Gets or sets the object to wait for signals on.
+ zx_handle_t object() const { return wait_.object; }
+ void set_object(zx_handle_t object) { wait_.object = object; }
+
+ // Gets or sets the signals to wait for.
+ zx_signals_t trigger() const { return wait_.trigger; }
+ void set_trigger(zx_signals_t trigger) { wait_.trigger = trigger; }
+
+ // Gets or sets the options to wait with. See zx_object_wait_async().
+ uint32_t options() const { return wait_.options; }
+ void set_options(uint32_t options) { wait_.options = options; }
+
+ // Returns true if the wait has begun and not yet completed or been canceled.
+ bool is_pending() const { return dispatcher_ != nullptr; }
+
+ // Begins asynchronously waiting for the object to receive one or more of
+ // the trigger signals. Invokes the handler when the wait completes.
+ //
+ // The wait's handler will be invoked exactly once unless the wait is canceled.
+ // When the dispatcher is shutting down (being destroyed), the handlers of
+ // all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.
+ //
+ // Returns |ZX_OK| if the wait was successfully begun.
+ // Returns |ZX_ERR_ACCESS_DENIED| if the object does not have |ZX_RIGHT_WAIT|.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Begin(async_dispatcher_t* dispatcher);
+
+ // Cancels the wait.
+ //
+ // If successful, the wait's handler will not run.
+ //
+ // Returns |ZX_OK| if the wait was pending and it has been successfully
+ // canceled; its handler will not run again and can be released immediately.
+ // Returns |ZX_ERR_NOT_FOUND| if there was no pending wait either because it
+ // already completed, or had not been started.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Cancel();
+
+ protected:
+ template <typename T>
+ static T* Dispatch(async_wait* wait) {
+ static_assert(offsetof(WaitBase, wait_) == 0, "");
+ auto self = reinterpret_cast<WaitBase*>(wait);
+ self->dispatcher_ = nullptr;
+ return static_cast<T*>(self);
+ }
+
+ private:
+ async_wait_t wait_;
+ async_dispatcher_t* dispatcher_ = nullptr;
+};
+
+// An asynchronous wait whose handler is bound to a |async::Wait::Handler| function.
+//
+// Prefer using |async::WaitMethod| instead for binding to a fixed class member
+// function since it is more efficient to dispatch.
+class Wait final : public WaitBase {
+ public:
+ // Handles completion of asynchronous wait operations.
+ //
+ // The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.
+ // The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
+ // the task's handler ran or the task was canceled.
+ using Handler = fit::function<void(async_dispatcher_t* dispatcher, async::Wait* wait,
+ zx_status_t status, const zx_packet_signal_t* signal)>;
+
+ explicit Wait(zx_handle_t object = ZX_HANDLE_INVALID, zx_signals_t trigger = ZX_SIGNAL_NONE,
+ uint32_t options = 0, Handler handler = nullptr);
+
+ ~Wait();
+
+ void set_handler(Handler handler) { handler_ = std::move(handler); }
+ bool has_handler() const { return !!handler_; }
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait, zx_status_t status,
+ const zx_packet_signal_t* signal);
+
+ Handler handler_;
+};
+
+// An asynchronous wait whose handler is bound to a |async::WaitOnce::Handler| function, but that
+// handler can only be called once, at which point the handler is destroyed.
+//
+// This type of wait is particularly useful for handlers that will delete the wait object itself
+// since the handler will be moved to the stack prior to being called.
+class WaitOnce final : public WaitBase {
+ public:
+ // Handles completion of asynchronous wait operations.
+ //
+ // The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.
+ // The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
+ // the task's handler ran or the task was canceled.
+ using Handler = fit::function<void(async_dispatcher_t* dispatcher, async::WaitOnce* wait,
+ zx_status_t status, const zx_packet_signal_t* signal)>;
+
+ explicit WaitOnce(zx_handle_t object = ZX_HANDLE_INVALID, zx_signals_t trigger = ZX_SIGNAL_NONE,
+ uint32_t options = 0);
+
+ ~WaitOnce();
+
+ // Begins asynchronously waiting for the object to receive one or more of
+ // the trigger signals. Invokes the handler when the wait completes.
+ //
+ // The wait's handler will be invoked exactly once unless the wait is canceled.
+ // When the dispatcher is shutting down (being destroyed), the handlers of
+ // all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.
+ //
+ // As the handler is destroyed on each invocation, a new handler must be supplied at each call
+ // to Begin().
+ //
+ // Returns |ZX_OK| if the wait was successfully begun.
+ // Returns |ZX_ERR_ACCESS_DENIED| if the object does not have |ZX_RIGHT_WAIT|.
+ // Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+ // Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+ zx_status_t Begin(async_dispatcher_t* dispatcher, Handler handler);
+
+ private:
+ // Hide the base Begin() signature in favor of the one that requires a handler.
+ using WaitBase::Begin;
+
+ static void CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait, zx_status_t status,
+ const zx_packet_signal_t* signal);
+
+ Handler handler_;
+};
+
+// An asynchronous wait whose handler is bound to a fixed class member function.
+//
+// Usage:
+//
+// class Foo {
+// void Handle(async_dispatcher_t* dispatcher, async::WaitBase* wait, zx_status_t status,
+// const zx_packet_signal_t* signal) { ... }
+// async::WaitMethod<Foo, &Foo::Handle> wait_{this};
+// };
+template <class Class, void (Class::*method)(async_dispatcher_t* dispatcher, async::WaitBase* wait,
+ zx_status_t status, const zx_packet_signal_t* signal)>
+class WaitMethod final : public WaitBase {
+ public:
+ explicit WaitMethod(Class* instance, zx_handle_t object = ZX_HANDLE_INVALID,
+ zx_signals_t trigger = ZX_SIGNAL_NONE, uint32_t options = 0)
+ : WaitBase(object, trigger, options, &WaitMethod::CallHandler), instance_(instance) {}
+
+ ~WaitMethod() = default;
+
+ private:
+ static void CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait, zx_status_t status,
+ const zx_packet_signal_t* signal) {
+ auto self = Dispatch<WaitMethod>(wait);
+ (self->instance_->*method)(dispatcher, self, status, signal);
+ }
+
+ Class* const instance_;
+};
+
+} // namespace async
+
+#endif // LIB_ASYNC_CPP_WAIT_H_
diff --git a/pkg/async-cpp/irq.cc b/pkg/async-cpp/irq.cc
new file mode 100644
index 0000000..d4cc9af
--- /dev/null
+++ b/pkg/async-cpp/irq.cc
@@ -0,0 +1,64 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/irq.h>
+#include <zircon/assert.h>
+
+#include <utility>
+
+namespace async {
+
+IrqBase::IrqBase(zx_handle_t object, zx_signals_t trigger, uint32_t options,
+ async_irq_handler_t* handler)
+ : irq_{{ASYNC_STATE_INIT}, handler, object} {}
+
+IrqBase::~IrqBase() {
+ if (dispatcher_) {
+ // Failure to cancel here may result in a dangling pointer...
+ zx_status_t status = async_unbind_irq(dispatcher_, &irq_);
+ ZX_ASSERT_MSG(status == ZX_OK, "status=%d", status);
+ }
+}
+
+zx_status_t IrqBase::Begin(async_dispatcher_t* dispatcher) {
+ if (dispatcher_)
+ return ZX_ERR_ALREADY_EXISTS;
+
+ dispatcher_ = dispatcher;
+ zx_status_t status = async_bind_irq(dispatcher, &irq_);
+ if (status != ZX_OK) {
+ dispatcher_ = nullptr;
+ }
+ return status;
+}
+
+zx_status_t IrqBase::Cancel() {
+ if (!dispatcher_)
+ return ZX_ERR_NOT_FOUND;
+
+ async_dispatcher_t* dispatcher = dispatcher_;
+ dispatcher_ = nullptr;
+
+ zx_status_t status = async_unbind_irq(dispatcher, &irq_);
+ // |dispatcher| is required to be single-threaded, Cancel() is
+ // only supposed to be called on |dispatcher|'s thread, and
+ // we verified that the wait was pending before calling
+ // async_cancel_wait(). Assuming that |dispatcher| never queues
+ // a wait, |wait_| must have been pending with |dispatcher|.
+ ZX_DEBUG_ASSERT(status != ZX_ERR_NOT_FOUND);
+ return status;
+}
+
+Irq::Irq(zx_handle_t object, zx_signals_t trigger, uint32_t options, Handler handler)
+ : IrqBase(object, trigger, options, &Irq::CallHandler), handler_(std::move(handler)) {}
+
+Irq::~Irq() = default;
+
+void Irq::CallHandler(async_dispatcher_t* dispatcher, async_irq_t* irq, zx_status_t status,
+ const zx_packet_interrupt_t* signal) {
+ auto self = Dispatch<Irq>(irq);
+ self->handler_(dispatcher, self, status, signal);
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/meta.json b/pkg/async-cpp/meta.json
new file mode 100644
index 0000000..78302af
--- /dev/null
+++ b/pkg/async-cpp/meta.json
@@ -0,0 +1,32 @@
+{
+ "banjo_deps": [],
+ "deps": [
+ "async",
+ "fit",
+ "zx"
+ ],
+ "fidl_deps": [],
+ "headers": [
+ "pkg/async-cpp/include/lib/async/cpp/executor.h",
+ "pkg/async-cpp/include/lib/async/cpp/irq.h",
+ "pkg/async-cpp/include/lib/async/cpp/paged_vmo.h",
+ "pkg/async-cpp/include/lib/async/cpp/receiver.h",
+ "pkg/async-cpp/include/lib/async/cpp/task.h",
+ "pkg/async-cpp/include/lib/async/cpp/time.h",
+ "pkg/async-cpp/include/lib/async/cpp/trap.h",
+ "pkg/async-cpp/include/lib/async/cpp/wait.h"
+ ],
+ "include_dir": "pkg/async-cpp/include",
+ "name": "async-cpp",
+ "root": "pkg/async-cpp",
+ "sources": [
+ "pkg/async-cpp/executor.cc",
+ "pkg/async-cpp/irq.cc",
+ "pkg/async-cpp/paged_vmo.cc",
+ "pkg/async-cpp/receiver.cc",
+ "pkg/async-cpp/task.cc",
+ "pkg/async-cpp/trap.cc",
+ "pkg/async-cpp/wait.cc"
+ ],
+ "type": "cc_source_library"
+}
\ No newline at end of file
diff --git a/pkg/async-cpp/paged_vmo.cc b/pkg/async-cpp/paged_vmo.cc
new file mode 100644
index 0000000..6e4be85
--- /dev/null
+++ b/pkg/async-cpp/paged_vmo.cc
@@ -0,0 +1,63 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/paged_vmo.h>
+#include <zircon/assert.h>
+
+#include <utility>
+
+namespace async {
+
+PagedVmoBase::PagedVmoBase(async_paged_vmo_handler_t* handler)
+ : paged_vmo_{{ASYNC_STATE_INIT}, handler, ZX_HANDLE_INVALID, ZX_HANDLE_INVALID} {
+ ZX_DEBUG_ASSERT(handler);
+}
+
+PagedVmoBase::~PagedVmoBase() { Detach(); }
+
+zx_status_t PagedVmoBase::CreateVmo(async_dispatcher_t* dispatcher, zx::unowned_pager pager,
+ uint32_t options, uint64_t vmo_size, zx::vmo* vmo_out) {
+ if (dispatcher_) {
+ return ZX_ERR_ALREADY_EXISTS;
+ }
+
+ zx_status_t status = async_create_paged_vmo(dispatcher, &paged_vmo_, options, pager->get(),
+ vmo_size, vmo_out->reset_and_get_address());
+ if (status != ZX_OK) {
+ return status;
+ }
+ dispatcher_ = dispatcher;
+ paged_vmo_.pager = pager->get();
+ paged_vmo_.vmo = vmo_out->get();
+ return ZX_OK;
+}
+
+zx_status_t PagedVmoBase::Detach() {
+ if (!dispatcher_) {
+ return ZX_ERR_NOT_FOUND;
+ }
+
+ auto dispatcher = dispatcher_;
+ dispatcher_ = nullptr;
+
+ zx_status_t status = async_detach_paged_vmo(dispatcher, &paged_vmo_);
+ // |dispatcher| is required to be single-threaded, Detach() is only supposed to be called on
+ // |dispatcher|'s thread, and we verified that the port was bound before calling
+ // async_detach_paged_vmo().
+ ZX_DEBUG_ASSERT(status != ZX_ERR_NOT_FOUND);
+ return status;
+}
+
+PagedVmo::PagedVmo(Handler handler)
+ : PagedVmoBase(&PagedVmo::CallHandler), handler_(std::move(handler)) {}
+
+PagedVmo::~PagedVmo() = default;
+
+void PagedVmo::CallHandler(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ zx_status_t status, const zx_packet_page_request_t* request) {
+ auto self = Dispatch<PagedVmo>(paged_vmo, status);
+ self->handler_(dispatcher, self, status, request);
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/receiver.cc b/pkg/async-cpp/receiver.cc
new file mode 100644
index 0000000..f1077b9
--- /dev/null
+++ b/pkg/async-cpp/receiver.cc
@@ -0,0 +1,32 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/receiver.h>
+
+#include <utility>
+
+namespace async {
+
+ReceiverBase::ReceiverBase(async_receiver_handler_t* handler)
+ : receiver_{{ASYNC_STATE_INIT}, handler} {}
+
+ReceiverBase::~ReceiverBase() = default;
+
+zx_status_t ReceiverBase::QueuePacket(async_dispatcher_t* dispatcher,
+ const zx_packet_user_t* data) {
+ return async_queue_packet(dispatcher, &receiver_, data);
+}
+
+Receiver::Receiver(Handler handler)
+ : ReceiverBase(&Receiver::CallHandler), handler_(std::move(handler)) {}
+
+Receiver::~Receiver() = default;
+
+void Receiver::CallHandler(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
+ zx_status_t status, const zx_packet_user_t* data) {
+ auto self = Dispatch<Receiver>(receiver);
+ self->handler_(dispatcher, self, status, data);
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/task.cc b/pkg/async-cpp/task.cc
new file mode 100644
index 0000000..9f2937d
--- /dev/null
+++ b/pkg/async-cpp/task.cc
@@ -0,0 +1,123 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/task.h>
+
+#include <lib/async/cpp/time.h>
+#include <zircon/assert.h>
+
+#include <utility>
+
+namespace async {
+namespace internal {
+
+struct RetainedTask : public async_task_t {
+ RetainedTask(fit::closure handler, zx::time deadline)
+ : async_task_t{{ASYNC_STATE_INIT}, &RetainedTask::Handler, deadline.get()},
+ handler(static_cast<fit::closure&&>(handler)) {}
+
+ fit::closure handler;
+
+ static void Handler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status) {
+ auto self = static_cast<RetainedTask*>(task);
+ if (status == ZX_OK)
+ self->handler();
+ delete self;
+ }
+};
+
+} // namespace internal
+
+zx_status_t PostTask(async_dispatcher_t* dispatcher, fit::closure handler) {
+ return PostTaskForTime(dispatcher, static_cast<fit::closure&&>(handler), async::Now(dispatcher));
+}
+
+zx_status_t PostDelayedTask(async_dispatcher_t* dispatcher, fit::closure handler,
+ zx::duration delay) {
+ return PostTaskForTime(dispatcher, static_cast<fit::closure&&>(handler),
+ async::Now(dispatcher) + delay);
+}
+
+zx_status_t PostTaskForTime(async_dispatcher_t* dispatcher, fit::closure handler,
+ zx::time deadline) {
+ auto* task = new internal::RetainedTask(static_cast<fit::closure&&>(handler), deadline);
+ zx_status_t status = async_post_task(dispatcher, task);
+ if (status != ZX_OK)
+ delete task;
+ return status;
+}
+
+TaskBase::TaskBase(async_task_handler_t* handler)
+ : task_{{ASYNC_STATE_INIT}, handler, ZX_TIME_INFINITE} {}
+
+TaskBase::~TaskBase() {
+ if (dispatcher_) {
+ // Failure to cancel here may result in a dangling pointer...
+ zx_status_t status = async_cancel_task(dispatcher_, &task_);
+ ZX_ASSERT_MSG(status == ZX_OK, "status=%d", status);
+ }
+}
+
+zx_status_t TaskBase::Post(async_dispatcher_t* dispatcher) {
+ return PostForTime(dispatcher, async::Now(dispatcher));
+}
+
+zx_status_t TaskBase::PostDelayed(async_dispatcher_t* dispatcher, zx::duration delay) {
+ return PostForTime(dispatcher, async::Now(dispatcher) + delay);
+}
+
+zx_status_t TaskBase::PostForTime(async_dispatcher_t* dispatcher, zx::time deadline) {
+ if (dispatcher_)
+ return ZX_ERR_ALREADY_EXISTS;
+
+ dispatcher_ = dispatcher;
+ task_.deadline = deadline.get();
+ zx_status_t status = async_post_task(dispatcher, &task_);
+ if (status != ZX_OK) {
+ dispatcher_ = nullptr;
+ }
+ return status;
+}
+
+zx_status_t TaskBase::Cancel() {
+ if (!dispatcher_)
+ return ZX_ERR_NOT_FOUND;
+
+ async_dispatcher_t* dispatcher = dispatcher_;
+ dispatcher_ = nullptr;
+
+ zx_status_t status = async_cancel_task(dispatcher, &task_);
+ // |dispatcher| is required to be single-threaded, Cancel() is
+ // only supposed to be called on |dispatcher|'s thread, and we
+ // verified that the task was pending before calling
+ // async_cancel_task(). Assuming that |dispatcher| does not yield
+ // between removing the task and invoking the task's handler,
+ // |task_| must have been pending with |dispatcher|.
+ ZX_DEBUG_ASSERT(status != ZX_ERR_NOT_FOUND);
+ return status;
+}
+
+Task::Task(Handler handler) : TaskBase(&Task::CallHandler), handler_(std::move(handler)) {}
+
+Task::~Task() = default;
+
+void Task::CallHandler(async_dispatcher_t* dispatcher, async_task_t* task, zx_status_t status) {
+ auto self = Dispatch<Task>(task);
+ self->handler_(dispatcher, self, status);
+}
+
+TaskClosure::TaskClosure(fit::closure handler)
+ : TaskBase(&TaskClosure::CallHandler), handler_(std::move(handler)) {}
+
+TaskClosure::~TaskClosure() = default;
+
+void TaskClosure::CallHandler(async_dispatcher_t* dispatcher, async_task_t* task,
+ zx_status_t status) {
+ auto self = Dispatch<TaskClosure>(task); // must do this if status is not ok
+ if (status == ZX_OK) {
+ self->handler_();
+ }
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/trap.cc b/pkg/async-cpp/trap.cc
new file mode 100644
index 0000000..dc3781f
--- /dev/null
+++ b/pkg/async-cpp/trap.cc
@@ -0,0 +1,32 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/trap.h>
+
+#include <utility>
+
+namespace async {
+
+GuestBellTrapBase::GuestBellTrapBase(async_guest_bell_trap_handler_t* handler)
+ : trap_{{ASYNC_STATE_INIT}, handler} {}
+
+GuestBellTrapBase::~GuestBellTrapBase() = default;
+
+zx_status_t GuestBellTrapBase::SetTrap(async_dispatcher_t* dispatcher, const zx::guest& guest,
+ zx_vaddr_t addr, size_t length) {
+ return async_set_guest_bell_trap(dispatcher, &trap_, guest.get(), addr, length);
+}
+
+GuestBellTrap::GuestBellTrap(Handler handler)
+ : GuestBellTrapBase(&GuestBellTrap::CallHandler), handler_(std::move(handler)) {}
+
+GuestBellTrap::~GuestBellTrap() = default;
+
+void GuestBellTrap::CallHandler(async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
+ zx_status_t status, const zx_packet_guest_bell_t* bell) {
+ auto self = Dispatch<GuestBellTrap>(trap);
+ self->handler_(dispatcher, self, status, bell);
+}
+
+} // namespace async
diff --git a/pkg/async-cpp/wait.cc b/pkg/async-cpp/wait.cc
new file mode 100644
index 0000000..955c203
--- /dev/null
+++ b/pkg/async-cpp/wait.cc
@@ -0,0 +1,82 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/async/cpp/wait.h>
+#include <zircon/assert.h>
+
+#include <utility>
+
+namespace async {
+
+WaitBase::WaitBase(zx_handle_t object, zx_signals_t trigger, uint32_t options,
+ async_wait_handler_t* handler)
+ : wait_{{ASYNC_STATE_INIT}, handler, object, trigger, options} {}
+
+WaitBase::~WaitBase() {
+ if (dispatcher_) {
+ // Failure to cancel here may result in a dangling pointer...
+ zx_status_t status = async_cancel_wait(dispatcher_, &wait_);
+ ZX_ASSERT_MSG(status == ZX_OK, "status=%d", status);
+ }
+}
+
+zx_status_t WaitBase::Begin(async_dispatcher_t* dispatcher) {
+ if (dispatcher_)
+ return ZX_ERR_ALREADY_EXISTS;
+
+ dispatcher_ = dispatcher;
+ zx_status_t status = async_begin_wait(dispatcher, &wait_);
+ if (status != ZX_OK) {
+ dispatcher_ = nullptr;
+ }
+ return status;
+}
+
+zx_status_t WaitBase::Cancel() {
+ if (!dispatcher_)
+ return ZX_ERR_NOT_FOUND;
+
+ async_dispatcher_t* dispatcher = dispatcher_;
+ dispatcher_ = nullptr;
+
+ zx_status_t status = async_cancel_wait(dispatcher, &wait_);
+ // |dispatcher| is required to be single-threaded, Cancel() is
+ // only supposed to be called on |dispatcher|'s thread, and
+ // we verified that the wait was pending before calling
+ // async_cancel_wait(). Assuming that |dispatcher| never queues
+ // a wait, |wait_| must have been pending with |dispatcher|.
+ ZX_DEBUG_ASSERT(status != ZX_ERR_NOT_FOUND);
+ return status;
+}
+
+Wait::Wait(zx_handle_t object, zx_signals_t trigger, uint32_t options, Handler handler)
+ : WaitBase(object, trigger, options, &Wait::CallHandler), handler_(std::move(handler)) {}
+
+Wait::~Wait() = default;
+
+void Wait::CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait, zx_status_t status,
+ const zx_packet_signal_t* signal) {
+ auto self = Dispatch<Wait>(wait);
+ self->handler_(dispatcher, self, status, signal);
+}
+
+WaitOnce::WaitOnce(zx_handle_t object, zx_signals_t trigger, uint32_t options)
+ : WaitBase(object, trigger, options, &WaitOnce::CallHandler) {}
+
+WaitOnce::~WaitOnce() = default;
+
+zx_status_t WaitOnce::Begin(async_dispatcher_t* dispatcher, WaitOnce::Handler handler) {
+ handler_ = std::move(handler);
+ return WaitBase::Begin(dispatcher);
+}
+
+void WaitOnce::CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait, zx_status_t status,
+ const zx_packet_signal_t* signal) {
+ auto self = Dispatch<WaitOnce>(wait);
+ // Move the handler to the stack prior to calling.
+ auto handler = std::move(self->handler_);
+ handler(dispatcher, self, status, signal);
+}
+
+} // namespace async
diff --git a/pkg/async-default/include/lib/async/default.h b/pkg/async-default/include/lib/async/default.h
deleted file mode 100644
index b171058..0000000
--- a/pkg/async-default/include/lib/async/default.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_ASYNC_DEFAULT_H_
-#define LIB_ASYNC_DEFAULT_H_
-
-#include <lib/async/dispatcher.h>
-#include <zircon/compiler.h>
-
-__BEGIN_CDECLS
-
-// Gets the current thread's default asynchronous dispatcher interface.
-// Returns |NULL| if none.
-__EXPORT async_dispatcher_t* async_get_default_dispatcher(void);
-
-// Sets the current thread's default asynchronous dispatcher interface.
-// May be set to |NULL| if this thread doesn't have a default dispatcher.
-__EXPORT void async_set_default_dispatcher(async_dispatcher_t* dispatcher);
-
-__END_CDECLS
-
-#endif // LIB_ASYNC_DEFAULT_H_
diff --git a/pkg/async-default/meta.json b/pkg/async-default/meta.json
deleted file mode 100644
index 2394825..0000000
--- a/pkg/async-default/meta.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/48/624ebaefd10ab212943f16760a00f469ec307e.debug",
- "dist": "arch/arm64/dist/libasync-default.so",
- "link": "arch/arm64/lib/libasync-default.so"
- },
- "x64": {
- "debug": ".build-id/5e/3c55aea09e8943ae76d3603cc8c0b1ba27bfb7.debug",
- "dist": "arch/x64/dist/libasync-default.so",
- "link": "arch/x64/lib/libasync-default.so"
- }
- },
- "deps": [],
- "format": "shared",
- "headers": [
- "pkg/async-default/include/lib/async/default.h"
- ],
- "include_dir": "pkg/async-default/include",
- "name": "async-default",
- "root": "pkg/async-default",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/async-loop-cpp/include/lib/async-loop/cpp/loop.h b/pkg/async-loop-cpp/include/lib/async-loop/cpp/loop.h
deleted file mode 100644
index 6168aba..0000000
--- a/pkg/async-loop-cpp/include/lib/async-loop/cpp/loop.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <lib/async-loop/loop.h>
-#include <lib/async/default.h>
-#include <lib/zx/time.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <threads.h>
-#include <zircon/compiler.h>
-
-namespace async {
-
-// C++ wrapper for an asynchronous dispatch loop.
-//
-// This class is thread-safe.
-class Loop {
-public:
- // Creates a message loop.
- // All operations on the message loop are thread-safe (except destroy).
- //
- // Note that it's ok to run the loop on a different thread from the one
- // upon which it was created.
- //
- // |config| provides configuration for the message loop. Must not be null.
- //
- // See also |kAsyncLoopConfigAttachToThread| and |kAsyncLoopConfigNoAttachToThread|.
- explicit Loop(const async_loop_config_t* config);
-
- Loop(const Loop&) = delete;
- Loop(Loop&&) = delete;
- Loop& operator=(const Loop&) = delete;
- Loop& operator=(Loop&&) = delete;
-
- // Destroys the message loop.
- // Implicitly calls |Shutdown()|.
- ~Loop();
-
- // Gets the underlying message loop structure.
- async_loop_t* loop() const { return loop_; }
-
- // Gets the loop's asynchronous dispatch interface.
- async_dispatcher_t* dispatcher() const { return async_loop_get_dispatcher(loop_); }
-
- // Shuts down the message loop, notifies handlers which asked to handle shutdown.
- // The message loop must not currently be running on any threads other than
- // those started by |StartThread()| which this function will join.
- //
- // Does nothing if already shutting down.
- void Shutdown();
-
- // Runs the message loop on the current thread.
- // This function can be called on multiple threads to setup a multi-threaded
- // dispatcher.
- //
- // Dispatches events until the |deadline| expires or the loop is quitted.
- // Use |ZX_TIME_INFINITE| to dispatch events indefinitely.
- //
- // If |once| is true, performs a single unit of work then returns.
- //
- // Returns |ZX_OK| if the dispatcher returns after one cycle.
- // Returns |ZX_ERR_TIMED_OUT| if the deadline expired.
- // Returns |ZX_ERR_CANCELED| if the loop quitted.
- // Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |Shutdown()|.
- zx_status_t Run(zx::time deadline = zx::time::infinite(), bool once = false);
-
- // Dispatches events until there are none remaining, and then returns
- // without waiting. This is useful for unit testing, because the behavior
- // doesn't depend on time.
- //
- // Returns |ZX_OK| if the dispatcher reaches an idle state.
- // Returns |ZX_ERR_CANCELED| if the loop quitted.
- // Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |Shutdown()|.
- zx_status_t RunUntilIdle();
-
- // Quits the message loop.
- // Active invocations of |Run()| and threads started using |StartThread()|
- // will eventually terminate upon completion of their current unit of work.
- //
- // Subsequent calls to |Run()| or |StartThread()| will return immediately
- // until |ResetQuit()| is called.
- void Quit();
-
- // Resets the quit state of the message loop so that it can be restarted
- // using |Run()| or |StartThread()|.
- //
- // This function must only be called when the message loop is not running.
- // The caller must ensure all active invocations of |Run()| and threads
- // started using |StartThread()| have terminated before resetting the quit state.
- //
- // Returns |ZX_OK| if the loop's state was |ASYNC_LOOP_RUNNABLE| or |ASYNC_LOOP_QUIT|.
- // Returns |ZX_ERR_BAD_STATE| if the loop's state was |ASYNC_LOOP_SHUTDOWN| or if
- // the message loop is currently active on one or more threads.
- zx_status_t ResetQuit();
-
- // Returns the current state of the message loop.
- async_loop_state_t GetState() const;
-
- // Starts a message loop running on a new thread.
- // The thread will run until the loop quits.
- //
- // |name| is the desired name for the new thread, may be NULL.
- // If |out_thread| is not NULL, it is set to the new thread identifier.
- //
- // Returns |ZX_OK| on success.
- // Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |async_loop_shutdown()|.
- // Returns |ZX_ERR_NO_MEMORY| if allocation or thread creation failed.
- zx_status_t StartThread(const char* name = nullptr, thrd_t* out_thread = nullptr);
-
- // Blocks until all dispatch threads started with |StartThread()|
- // have terminated.
- void JoinThreads();
-
-private:
- async_loop_t* loop_;
-};
-
-} // namespace async
diff --git a/pkg/async-loop-cpp/loop_wrapper.cpp b/pkg/async-loop-cpp/loop_wrapper.cpp
deleted file mode 100644
index cc866ec..0000000
--- a/pkg/async-loop-cpp/loop_wrapper.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/async-loop/cpp/loop.h>
-
-#include <zircon/assert.h>
-
-namespace async {
-
-Loop::Loop(const async_loop_config_t* config) {
- zx_status_t status = async_loop_create(config, &loop_);
- ZX_ASSERT_MSG(status == ZX_OK, "status=%d", status);
-}
-
-Loop::~Loop() {
- async_loop_destroy(loop_);
-}
-
-void Loop::Shutdown() {
- async_loop_shutdown(loop_);
-}
-
-zx_status_t Loop::Run(zx::time deadline, bool once) {
- return async_loop_run(loop_, deadline.get(), once);
-}
-
-zx_status_t Loop::RunUntilIdle() {
- return async_loop_run_until_idle(loop_);
-}
-
-void Loop::Quit() {
- async_loop_quit(loop_);
-}
-
-zx_status_t Loop::ResetQuit() {
- return async_loop_reset_quit(loop_);
-}
-
-async_loop_state_t Loop::GetState() const {
- return async_loop_get_state(loop_);
-}
-
-zx_status_t Loop::StartThread(const char* name, thrd_t* out_thread) {
- return async_loop_start_thread(loop_, name, out_thread);
-}
-
-void Loop::JoinThreads() {
- async_loop_join_threads(loop_);
-}
-
-} // namespace async
diff --git a/pkg/async-loop-cpp/meta.json b/pkg/async-loop-cpp/meta.json
deleted file mode 100644
index 950712f..0000000
--- a/pkg/async-loop-cpp/meta.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "banjo_deps": [],
- "deps": [
- "async",
- "async-default",
- "async-loop",
- "zx"
- ],
- "fidl_deps": [],
- "files": [
- "pkg/async-loop-cpp/loop_wrapper.cpp",
- "pkg/async-loop-cpp/include/lib/async-loop/cpp/loop.h"
- ],
- "headers": [
- "pkg/async-loop-cpp/include/lib/async-loop/cpp/loop.h"
- ],
- "include_dir": "pkg/async-loop-cpp/include",
- "name": "async-loop-cpp",
- "root": "pkg/async-loop-cpp",
- "sources": [
- "pkg/async-loop-cpp/loop_wrapper.cpp"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/async-loop/include/lib/async-loop/loop.h b/pkg/async-loop/include/lib/async-loop/loop.h
deleted file mode 100644
index 1335cdb..0000000
--- a/pkg/async-loop/include/lib/async-loop/loop.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-//
-// Provides an implementation of a simple thread-safe asynchronous
-// dispatcher based on a Zircon completion port. The implementation
-// is designed to avoid most dynamic memory allocation except for that
-// which is required to create the loop in the first place or to manage
-// the list of running threads.
-//
-// See README.md for example usage.
-//
-
-#ifndef LIB_ASYNC_LOOP_LOOP_H_
-#define LIB_ASYNC_LOOP_LOOP_H_
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <threads.h>
-
-#include <zircon/compiler.h>
-
-#include <lib/async/dispatcher.h>
-
-__BEGIN_CDECLS
-
-// Pointer to a message loop created using |async_loop_create()|.
-typedef struct async_loop async_loop_t;
-
-// Message loop configuration structure.
-typedef void(async_loop_callback_t)(async_loop_t* loop, void* data);
-typedef struct async_loop_config {
- // If true, the loop will automatically register itself as the default
- // dispatcher for the thread upon which it was created and will
- // automatically unregister itself when destroyed (which must occur on
- // the same thread).
- //
- // If false, the loop will not do this. The loop's creator is then
- // resposible for retrieving the loop's dispatcher using |async_loop_get_dispatcher()|
- // and passing it around explicitly or calling |async_set_default_dispatcher()| as needed.
- //
- // Note that the loop can be used even without setting it as the current
- // thread's default.
- bool make_default_for_current_thread;
-
- // A function to call before the dispatcher invokes each handler, or NULL if none.
- async_loop_callback_t* prologue;
-
- // A function to call after the dispatcher invokes each handler, or NULL if none.
- async_loop_callback_t* epilogue;
-
- // Data to pass to the callback functions.
- void* data;
-} async_loop_config_t;
-
-// Simple config that when passed to async_loop_create will create a loop
-// that will automatically register itself as the default
-// dispatcher for the thread upon which it was created and will
-// automatically unregister itself when destroyed (which must occur on
-// the same thread).
-extern const async_loop_config_t kAsyncLoopConfigAttachToThread;
-
-// Simple config that when passed to async_loop_create will create a loop
-// that is not registered to the current thread.
-extern const async_loop_config_t kAsyncLoopConfigNoAttachToThread;
-
-// Creates a message loop and returns a pointer to it in |out_loop|.
-// All operations on the message loop are thread-safe (except destroy).
-//
-// Note that it's ok to run the loop on a different thread from the one
-// upon which it was created.
-//
-// |config| provides configuration for the message loop. Must not be null.
-//
-// Returns |ZX_OK| on success.
-// Returns |ZX_ERR_NO_MEMORY| if allocation failed.
-// May return other errors if the necessary internal handles could not be created.
-//
-// See also |kAsyncLoopConfigAttachToThread| and |kAsyncLoopConfigNoAttachToThread|.
-zx_status_t async_loop_create(const async_loop_config_t* config,
- async_loop_t** out_loop);
-
-// Gets the the message loop's asynchronous dispatch interface.
-async_dispatcher_t* async_loop_get_dispatcher(async_loop_t* loop);
-
-// Gets the message loop associated with the specified asynchronous dispatch interface
-//
-// This function assumes the dispatcher is backed by an |async_loop_t| which was created
-// using |async_loop_create()|. Its behavior is undefined if used with other dispatcher
-// implementations.
-async_loop_t* async_loop_from_dispatcher(async_dispatcher_t* dispatcher);
-
-// Shuts down the message loop, notifies handlers which asked to handle shutdown.
-// The message loop must not currently be running on any threads other than
-// those started by |async_loop_start_thread()| which this function will join.
-//
-// Does nothing if already shutting down.
-void async_loop_shutdown(async_loop_t* loop);
-
-// Destroys the message loop.
-// Implicitly calls |async_loop_shutdown()| and joins all threads started
-// using |async_loop_start_thread()| before destroying the loop itself.
-void async_loop_destroy(async_loop_t* loop);
-
-// Runs the message loop on the current thread.
-// This function can be called on multiple threads to setup a multi-threaded
-// dispatcher.
-//
-// Dispatches events until the |deadline| expires or the loop is quitted.
-// Use |ZX_TIME_INFINITE| to dispatch events indefinitely.
-//
-// If |once| is true, performs a single unit of work then returns.
-//
-// Returns |ZX_OK| if the dispatcher returns after one cycle.
-// Returns |ZX_ERR_TIMED_OUT| if the deadline expired.
-// Returns |ZX_ERR_CANCELED| if the loop quitted.
-// Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |async_loop_shutdown()|.
-zx_status_t async_loop_run(async_loop_t* loop, zx_time_t deadline, bool once);
-
-// Dispatches events until there are none remaining, and then returns without
-// waiting. This is useful for unit testing, because the behavior doesn't depend
-// on time.
-//
-// Returns |ZX_OK| if the dispatcher reaches an idle state.
-// Returns |ZX_ERR_CANCELED| if the loop quitted.
-// Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |async_loop_shutdown()|.
-zx_status_t async_loop_run_until_idle(async_loop_t* loop);
-
-// Quits the message loop.
-// Active invocations of |async_loop_run()| and threads started using
-// |async_loop_start_thread()| will eventually terminate upon completion of their
-// current unit of work.
-//
-// Subsequent calls to |async_loop_run()| or |async_loop_start_thread()|
-// will return immediately until |async_loop_reset_quit()| is called.
-void async_loop_quit(async_loop_t* loop);
-
-// Resets the quit state of the message loop so that it can be restarted
-// using |async_loop_run()| or |async_loop_start_thread()|.
-//
-// This function must only be called when the message loop is not running.
-// The caller must ensure all active invocations of |async_loop_run()| and
-// threads started using |async_loop_start_thread()| have terminated before
-// resetting the quit state.
-//
-// Returns |ZX_OK| if the loop's state was |ASYNC_LOOP_RUNNABLE| or |ASYNC_LOOP_QUIT|.
-// Returns |ZX_ERR_BAD_STATE| if the loop's state was |ASYNC_LOOP_SHUTDOWN| or if
-// the message loop is currently active on one or more threads.
-zx_status_t async_loop_reset_quit(async_loop_t* loop);
-
-// Returns the current state of the message loop.
-typedef uint32_t async_loop_state_t;
-#define ASYNC_LOOP_RUNNABLE ((async_loop_state_t) 0)
-#define ASYNC_LOOP_QUIT ((async_loop_state_t) 1)
-#define ASYNC_LOOP_SHUTDOWN ((async_loop_state_t) 2)
-async_loop_state_t async_loop_get_state(async_loop_t* loop);
-
-// Starts a message loop running on a new thread.
-// The thread will run until the loop quits.
-//
-// |name| is the desired name for the new thread, may be NULL.
-// If |out_thread| is not NULL, it is set to the new thread identifier.
-//
-// Returns |ZX_OK| on success.
-// Returns |ZX_ERR_BAD_STATE| if the loop was shut down with |async_loop_shutdown()|.
-// Returns |ZX_ERR_NO_MEMORY| if allocation or thread creation failed.
-zx_status_t async_loop_start_thread(async_loop_t* loop, const char* name,
- thrd_t* out_thread);
-
-// Blocks until all dispatch threads started with |async_loop_start_thread()|
-// have terminated.
-void async_loop_join_threads(async_loop_t* loop);
-
-__END_CDECLS
-
-#endif // LIB_ASYNC_LOOP_LOOP_H_
\ No newline at end of file
diff --git a/pkg/async-loop/loop.c b/pkg/async-loop/loop.c
deleted file mode 100644
index e70627a..0000000
--- a/pkg/async-loop/loop.c
+++ /dev/null
@@ -1,797 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef _ALL_SOURCE
-#define _ALL_SOURCE // Enables thrd_create_with_name in <threads.h>.
-#endif
-#include <lib/async-loop/loop.h>
-
-#include <assert.h>
-#include <stdatomic.h>
-#include <stdlib.h>
-
-#include <zircon/assert.h>
-#include <zircon/listnode.h>
-#include <zircon/syscalls.h>
-#include <zircon/syscalls/hypervisor.h>
-
-#include <lib/async/default.h>
-#include <lib/async/exception.h>
-#include <lib/async/receiver.h>
-#include <lib/async/task.h>
-#include <lib/async/trap.h>
-#include <lib/async/wait.h>
-
-// The port wait key associated with the dispatcher's control messages.
-#define KEY_CONTROL (0u)
-
-static zx_time_t async_loop_now(async_dispatcher_t* dispatcher);
-static zx_status_t async_loop_begin_wait(async_dispatcher_t* dispatcher, async_wait_t* wait);
-static zx_status_t async_loop_cancel_wait(async_dispatcher_t* dispatcher, async_wait_t* wait);
-static zx_status_t async_loop_post_task(async_dispatcher_t* dispatcher, async_task_t* task);
-static zx_status_t async_loop_cancel_task(async_dispatcher_t* dispatcher, async_task_t* task);
-static zx_status_t async_loop_queue_packet(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
- const zx_packet_user_t* data);
-static zx_status_t async_loop_set_guest_bell_trap(
- async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
- zx_handle_t guest, zx_vaddr_t addr, size_t length);
-static zx_status_t async_loop_bind_exception_port(async_dispatcher_t* async,
- async_exception_t* exception);
-static zx_status_t async_loop_unbind_exception_port(async_dispatcher_t* async,
- async_exception_t* exception);
-static zx_status_t async_loop_resume_from_exception(async_dispatcher_t* async,
- async_exception_t* exception,
- zx_handle_t task,
- uint32_t options);
-
-static const async_ops_t async_loop_ops = {
- .version = ASYNC_OPS_V2,
- .reserved = 0,
- .v1 = {
- .now = async_loop_now,
- .begin_wait = async_loop_begin_wait,
- .cancel_wait = async_loop_cancel_wait,
- .post_task = async_loop_post_task,
- .cancel_task = async_loop_cancel_task,
- .queue_packet = async_loop_queue_packet,
- .set_guest_bell_trap = async_loop_set_guest_bell_trap,
- },
- .v2 = {
- .bind_exception_port = async_loop_bind_exception_port,
- .unbind_exception_port = async_loop_unbind_exception_port,
- .resume_from_exception = async_loop_resume_from_exception,
- },
-};
-
-typedef struct thread_record {
- list_node_t node;
- thrd_t thread;
-} thread_record_t;
-
-const async_loop_config_t kAsyncLoopConfigAttachToThread = {
- .make_default_for_current_thread = true};
-const async_loop_config_t kAsyncLoopConfigNoAttachToThread = {
- .make_default_for_current_thread = false};
-
-typedef struct async_loop {
- async_dispatcher_t dispatcher; // must be first (the loop inherits from async_dispatcher_t)
- async_loop_config_t config; // immutable
- zx_handle_t port; // immutable
- zx_handle_t timer; // immutable
-
- _Atomic async_loop_state_t state;
- atomic_uint active_threads; // number of active dispatch threads
-
- mtx_t lock; // guards the lists and the dispatching tasks flag
- bool dispatching_tasks; // true while the loop is busy dispatching tasks
- list_node_t wait_list; // most recently added first
- list_node_t task_list; // pending tasks, earliest deadline first
- list_node_t due_list; // due tasks, earliest deadline first
- list_node_t thread_list; // earliest created thread first
- list_node_t exception_list; // most recently added first
-} async_loop_t;
-
-static zx_status_t async_loop_run_once(async_loop_t* loop, zx_time_t deadline);
-static zx_status_t async_loop_dispatch_wait(async_loop_t* loop, async_wait_t* wait,
- zx_status_t status, const zx_packet_signal_t* signal);
-static zx_status_t async_loop_dispatch_tasks(async_loop_t* loop);
-static void async_loop_dispatch_task(async_loop_t* loop, async_task_t* task,
- zx_status_t status);
-static zx_status_t async_loop_dispatch_packet(async_loop_t* loop, async_receiver_t* receiver,
- zx_status_t status, const zx_packet_user_t* data);
-static zx_status_t async_loop_dispatch_guest_bell_trap(async_loop_t* loop,
- async_guest_bell_trap_t* trap,
- zx_status_t status,
- const zx_packet_guest_bell_t* bell);
-static zx_status_t async_loop_dispatch_exception(async_loop_t* loop,
- async_exception_t* exception,
- zx_status_t status,
- const zx_port_packet_t* report);
-static void async_loop_wake_threads(async_loop_t* loop);
-static void async_loop_insert_task_locked(async_loop_t* loop, async_task_t* task);
-static void async_loop_restart_timer_locked(async_loop_t* loop);
-static void async_loop_invoke_prologue(async_loop_t* loop);
-static void async_loop_invoke_epilogue(async_loop_t* loop);
-
-static_assert(sizeof(list_node_t) <= sizeof(async_state_t),
- "async_state_t too small");
-
-#define TO_NODE(type, ptr) ((list_node_t*)&ptr->state)
-#define FROM_NODE(type, ptr) ((type*)((char*)(ptr)-offsetof(type, state)))
-
-static inline list_node_t* wait_to_node(async_wait_t* wait) {
- return TO_NODE(async_wait_t, wait);
-}
-
-static inline async_wait_t* node_to_wait(list_node_t* node) {
- return FROM_NODE(async_wait_t, node);
-}
-
-static inline list_node_t* task_to_node(async_task_t* task) {
- return TO_NODE(async_task_t, task);
-}
-
-static inline async_task_t* node_to_task(list_node_t* node) {
- return FROM_NODE(async_task_t, node);
-}
-
-static inline list_node_t* exception_to_node(async_exception_t* exception) {
- return TO_NODE(async_exception_t, exception);
-}
-
-static inline async_exception_t* node_to_exception(list_node_t* node) {
- return FROM_NODE(async_exception_t, node);
-}
-
-zx_status_t async_loop_create(const async_loop_config_t* config, async_loop_t** out_loop) {
- ZX_DEBUG_ASSERT(out_loop);
- ZX_DEBUG_ASSERT(config != NULL);
-
- async_loop_t* loop = calloc(1u, sizeof(async_loop_t));
- if (!loop)
- return ZX_ERR_NO_MEMORY;
- atomic_init(&loop->state, ASYNC_LOOP_RUNNABLE);
- atomic_init(&loop->active_threads, 0u);
-
- loop->dispatcher.ops = &async_loop_ops;
- loop->config = *config;
- mtx_init(&loop->lock, mtx_plain);
- list_initialize(&loop->wait_list);
- list_initialize(&loop->task_list);
- list_initialize(&loop->due_list);
- list_initialize(&loop->thread_list);
- list_initialize(&loop->exception_list);
-
- zx_status_t status = zx_port_create(0u, &loop->port);
- if (status == ZX_OK)
- status = zx_timer_create(0u, ZX_CLOCK_MONOTONIC, &loop->timer);
- if (status == ZX_OK) {
- status = zx_object_wait_async(loop->timer, loop->port, KEY_CONTROL,
- ZX_TIMER_SIGNALED,
- ZX_WAIT_ASYNC_REPEATING);
- }
- if (status == ZX_OK) {
- *out_loop = loop;
- if (loop->config.make_default_for_current_thread) {
- ZX_DEBUG_ASSERT(async_get_default_dispatcher() == NULL);
- async_set_default_dispatcher(&loop->dispatcher);
- }
- } else {
- loop->config.make_default_for_current_thread = false;
- async_loop_destroy(loop);
- }
- return status;
-}
-
-void async_loop_destroy(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- async_loop_shutdown(loop);
-
- zx_handle_close(loop->port);
- zx_handle_close(loop->timer);
- mtx_destroy(&loop->lock);
- free(loop);
-}
-
-void async_loop_shutdown(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- async_loop_state_t prior_state =
- atomic_exchange_explicit(&loop->state, ASYNC_LOOP_SHUTDOWN,
- memory_order_acq_rel);
- if (prior_state == ASYNC_LOOP_SHUTDOWN)
- return;
-
- async_loop_wake_threads(loop);
- async_loop_join_threads(loop);
-
- list_node_t* node;
- while ((node = list_remove_head(&loop->wait_list))) {
- async_wait_t* wait = node_to_wait(node);
- async_loop_dispatch_wait(loop, wait, ZX_ERR_CANCELED, NULL);
- }
- while ((node = list_remove_head(&loop->due_list))) {
- async_task_t* task = node_to_task(node);
- async_loop_dispatch_task(loop, task, ZX_ERR_CANCELED);
- }
- while ((node = list_remove_head(&loop->task_list))) {
- async_task_t* task = node_to_task(node);
- async_loop_dispatch_task(loop, task, ZX_ERR_CANCELED);
- }
- while ((node = list_remove_head(&loop->exception_list))) {
- async_exception_t* exception = node_to_exception(node);
- async_loop_dispatch_exception(loop, exception, ZX_ERR_CANCELED, NULL);
- }
-
- if (loop->config.make_default_for_current_thread) {
- ZX_DEBUG_ASSERT(async_get_default_dispatcher() == &loop->dispatcher);
- async_set_default_dispatcher(NULL);
- }
-}
-
-zx_status_t async_loop_run(async_loop_t* loop, zx_time_t deadline, bool once) {
- ZX_DEBUG_ASSERT(loop);
-
- zx_status_t status;
- atomic_fetch_add_explicit(&loop->active_threads, 1u, memory_order_acq_rel);
- do {
- status = async_loop_run_once(loop, deadline);
- } while (status == ZX_OK && !once);
- atomic_fetch_sub_explicit(&loop->active_threads, 1u, memory_order_acq_rel);
- return status;
-}
-
-zx_status_t async_loop_run_until_idle(async_loop_t* loop) {
- zx_status_t status = async_loop_run(loop, 0, false);
- if (status == ZX_ERR_TIMED_OUT) {
- status = ZX_OK;
- }
- return status;
-}
-
-static zx_status_t async_loop_run_once(async_loop_t* loop, zx_time_t deadline) {
- async_loop_state_t state = atomic_load_explicit(&loop->state, memory_order_acquire);
- if (state == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
- if (state != ASYNC_LOOP_RUNNABLE)
- return ZX_ERR_CANCELED;
-
- zx_port_packet_t packet;
- zx_status_t status = zx_port_wait(loop->port, deadline, &packet);
- if (status != ZX_OK)
- return status;
-
- if (packet.key == KEY_CONTROL) {
- // Handle wake-up packets.
- if (packet.type == ZX_PKT_TYPE_USER)
- return ZX_OK;
-
- // Handle task timer expirations.
- if (packet.type == ZX_PKT_TYPE_SIGNAL_REP &&
- packet.signal.observed & ZX_TIMER_SIGNALED) {
- return async_loop_dispatch_tasks(loop);
- }
- } else {
- // Handle wait completion packets.
- if (packet.type == ZX_PKT_TYPE_SIGNAL_ONE) {
- async_wait_t* wait = (void*)(uintptr_t)packet.key;
- mtx_lock(&loop->lock);
- list_delete(wait_to_node(wait));
- mtx_unlock(&loop->lock);
- return async_loop_dispatch_wait(loop, wait, packet.status, &packet.signal);
- }
-
- // Handle queued user packets.
- if (packet.type == ZX_PKT_TYPE_USER) {
- async_receiver_t* receiver = (void*)(uintptr_t)packet.key;
- return async_loop_dispatch_packet(loop, receiver, packet.status, &packet.user);
- }
-
- // Handle guest bell trap packets.
- if (packet.type == ZX_PKT_TYPE_GUEST_BELL) {
- async_guest_bell_trap_t* trap = (void*)(uintptr_t)packet.key;
- return async_loop_dispatch_guest_bell_trap(
- loop, trap, packet.status, &packet.guest_bell);
- }
-
- // Handle exception packets.
- if (ZX_PKT_IS_EXCEPTION(packet.type)) {
- async_exception_t* exception = (void*)(uintptr_t)packet.key;
- return async_loop_dispatch_exception(loop, exception, packet.status,
- &packet);
- }
- }
-
- ZX_DEBUG_ASSERT(false);
- return ZX_ERR_INTERNAL;
-}
-
-async_dispatcher_t* async_loop_get_dispatcher(async_loop_t* loop) {
- // Note: The loop's implementation inherits from async_t so we can upcast to it.
- return (async_dispatcher_t*)loop;
-}
-
-async_loop_t* async_loop_from_dispatcher(async_dispatcher_t* async) {
- return (async_loop_t*)async;
-}
-
-static zx_status_t async_loop_dispatch_guest_bell_trap(async_loop_t* loop,
- async_guest_bell_trap_t* trap,
- zx_status_t status,
- const zx_packet_guest_bell_t* bell) {
- async_loop_invoke_prologue(loop);
- trap->handler((async_dispatcher_t*)loop, trap, status, bell);
- async_loop_invoke_epilogue(loop);
- return ZX_OK;
-}
-
-static zx_status_t async_loop_dispatch_wait(async_loop_t* loop, async_wait_t* wait,
- zx_status_t status, const zx_packet_signal_t* signal) {
- async_loop_invoke_prologue(loop);
- wait->handler((async_dispatcher_t*)loop, wait, status, signal);
- async_loop_invoke_epilogue(loop);
- return ZX_OK;
-}
-
-static zx_status_t async_loop_dispatch_tasks(async_loop_t* loop) {
- // Dequeue and dispatch one task at a time in case an earlier task wants
- // to cancel a later task which has also come due. At most one thread
- // can dispatch tasks at any given moment (to preserve serial ordering).
- // Timer restarts are suppressed until we run out of tasks to dispatch.
- mtx_lock(&loop->lock);
- if (!loop->dispatching_tasks) {
- loop->dispatching_tasks = true;
-
- // Extract all of the tasks that are due into |due_list| for dispatch
- // unless we already have some waiting from a previous iteration which
- // we would like to process in order.
- list_node_t* node;
- if (list_is_empty(&loop->due_list)) {
- zx_time_t due_time = async_loop_now((async_dispatcher_t*)loop);
- list_node_t* tail = NULL;
- list_for_every(&loop->task_list, node) {
- if (node_to_task(node)->deadline > due_time)
- break;
- tail = node;
- }
- if (tail) {
- list_node_t* head = loop->task_list.next;
- loop->task_list.next = tail->next;
- tail->next->prev = &loop->task_list;
- loop->due_list.next = head;
- head->prev = &loop->due_list;
- loop->due_list.prev = tail;
- tail->next = &loop->due_list;
- }
- }
-
- // Dispatch all due tasks. Note that they might be canceled concurrently
- // so we need to grab the lock during each iteration to fetch the next
- // item from the list.
- while ((node = list_remove_head(&loop->due_list))) {
- mtx_unlock(&loop->lock);
-
- // Invoke the handler. Note that it might destroy itself.
- async_task_t* task = node_to_task(node);
- async_loop_dispatch_task(loop, task, ZX_OK);
-
- mtx_lock(&loop->lock);
- async_loop_state_t state = atomic_load_explicit(&loop->state, memory_order_acquire);
- if (state != ASYNC_LOOP_RUNNABLE)
- break;
- }
-
- loop->dispatching_tasks = false;
- async_loop_restart_timer_locked(loop);
- }
- mtx_unlock(&loop->lock);
- return ZX_OK;
-}
-
-static void async_loop_dispatch_task(async_loop_t* loop,
- async_task_t* task,
- zx_status_t status) {
- // Invoke the handler. Note that it might destroy itself.
- async_loop_invoke_prologue(loop);
- task->handler((async_dispatcher_t*)loop, task, status);
- async_loop_invoke_epilogue(loop);
-}
-
-static zx_status_t async_loop_dispatch_packet(async_loop_t* loop, async_receiver_t* receiver,
- zx_status_t status, const zx_packet_user_t* data) {
- // Invoke the handler. Note that it might destroy itself.
- async_loop_invoke_prologue(loop);
- receiver->handler((async_dispatcher_t*)loop, receiver, status, data);
- async_loop_invoke_epilogue(loop);
- return ZX_OK;
-}
-
-static zx_status_t async_loop_dispatch_exception(async_loop_t* loop,
- async_exception_t* exception,
- zx_status_t status,
- const zx_port_packet_t* report) {
- // Invoke the handler. Note that it might destroy itself.
- async_loop_invoke_prologue(loop);
- exception->handler((async_dispatcher_t*)loop, exception, status, report);
- async_loop_invoke_epilogue(loop);
- return ZX_OK;
-}
-
-void async_loop_quit(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- async_loop_state_t expected_state = ASYNC_LOOP_RUNNABLE;
- if (!atomic_compare_exchange_strong_explicit(&loop->state, &expected_state,
- ASYNC_LOOP_QUIT,
- memory_order_acq_rel, memory_order_acquire))
- return;
-
- async_loop_wake_threads(loop);
-}
-
-static void async_loop_wake_threads(async_loop_t* loop) {
- // Queue enough packets to awaken all active threads.
- // This is safe because any new threads which join the pool first increment the
- // active thread count then check the loop state, so the count we observe here
- // cannot be less than the number of threads which might be blocked in |port_wait|.
- // Issuing too many packets is also harmless.
- uint32_t n = atomic_load_explicit(&loop->active_threads, memory_order_acquire);
- for (uint32_t i = 0u; i < n; i++) {
- zx_port_packet_t packet = {
- .key = KEY_CONTROL,
- .type = ZX_PKT_TYPE_USER,
- .status = ZX_OK};
- zx_status_t status = zx_port_queue(loop->port, &packet);
- ZX_ASSERT_MSG(status == ZX_OK, "zx_port_queue: status=%d", status);
- }
-}
-
-zx_status_t async_loop_reset_quit(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- // Ensure that there are no active threads before resetting the quit state.
- // This check is inherently racy but not dangerously so. It's mainly a
- // sanity check for client code so we can make a stronger statement about
- // how |async_loop_reset_quit()| is supposed to be used.
- uint32_t n = atomic_load_explicit(&loop->active_threads, memory_order_acquire);
- if (n != 0)
- return ZX_ERR_BAD_STATE;
-
- async_loop_state_t expected_state = ASYNC_LOOP_QUIT;
- if (atomic_compare_exchange_strong_explicit(&loop->state, &expected_state,
- ASYNC_LOOP_RUNNABLE,
- memory_order_acq_rel, memory_order_acquire)) {
- return ZX_OK;
- }
-
- async_loop_state_t state = atomic_load_explicit(&loop->state, memory_order_acquire);
- if (state == ASYNC_LOOP_RUNNABLE)
- return ZX_OK;
- return ZX_ERR_BAD_STATE;
-}
-
-async_loop_state_t async_loop_get_state(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- return atomic_load_explicit(&loop->state, memory_order_acquire);
-}
-
-zx_time_t async_loop_now(async_dispatcher_t* dispatcher) {
- return zx_clock_get_monotonic();
-}
-
-static zx_status_t async_loop_begin_wait(async_dispatcher_t* async, async_wait_t* wait) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(wait);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- mtx_lock(&loop->lock);
-
- zx_status_t status = zx_object_wait_async(
- wait->object, loop->port, (uintptr_t)wait, wait->trigger, ZX_WAIT_ASYNC_ONCE);
- if (status == ZX_OK) {
- list_add_head(&loop->wait_list, wait_to_node(wait));
- } else {
- ZX_ASSERT_MSG(status == ZX_ERR_ACCESS_DENIED,
- "zx_object_wait_async: status=%d", status);
- }
-
- mtx_unlock(&loop->lock);
- return status;
-}
-
-static zx_status_t async_loop_cancel_wait(async_dispatcher_t* async, async_wait_t* wait) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(wait);
-
- // Note: We need to process cancelations even while the loop is being
- // destroyed in case the client is counting on the handler not being
- // invoked again past this point.
-
- mtx_lock(&loop->lock);
-
- // First, confirm that the wait is actually pending.
- list_node_t* node = wait_to_node(wait);
- if (!list_in_list(node)) {
- mtx_unlock(&loop->lock);
- return ZX_ERR_NOT_FOUND;
- }
-
- // Next, cancel the wait. This may be racing with another thread that
- // has read the wait's packet but not yet dispatched it. So if we fail
- // to cancel then we assume we lost the race.
- zx_status_t status = zx_port_cancel(loop->port, wait->object,
- (uintptr_t)wait);
- if (status == ZX_OK) {
- list_delete(node);
- } else {
- ZX_ASSERT_MSG(status == ZX_ERR_NOT_FOUND,
- "zx_port_cancel: status=%d", status);
- }
-
- mtx_unlock(&loop->lock);
- return status;
-}
-
-static zx_status_t async_loop_post_task(async_dispatcher_t* async, async_task_t* task) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(task);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- mtx_lock(&loop->lock);
-
- async_loop_insert_task_locked(loop, task);
- if (!loop->dispatching_tasks &&
- task_to_node(task)->prev == &loop->task_list) {
- // Task inserted at head. Earliest deadline changed.
- async_loop_restart_timer_locked(loop);
- }
-
- mtx_unlock(&loop->lock);
- return ZX_OK;
-}
-
-static zx_status_t async_loop_cancel_task(async_dispatcher_t* async, async_task_t* task) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(task);
-
- // Note: We need to process cancelations even while the loop is being
- // destroyed in case the client is counting on the handler not being
- // invoked again past this point. Also, the task we're removing here
- // might be present in the dispatcher's |due_list| if it is pending
- // dispatch instead of in the loop's |task_list| as usual. The same
- // logic works in both cases.
-
- mtx_lock(&loop->lock);
- list_node_t* node = task_to_node(task);
- if (!list_in_list(node)) {
- mtx_unlock(&loop->lock);
- return ZX_ERR_NOT_FOUND;
- }
-
- // Determine whether the head task was canceled and following task has
- // a later deadline. If so, we will bump the timer along to that deadline.
- bool must_restart = !loop->dispatching_tasks &&
- node->prev == &loop->task_list &&
- node->next != &loop->task_list &&
- node_to_task(node->next)->deadline > task->deadline;
- list_delete(node);
- if (must_restart)
- async_loop_restart_timer_locked(loop);
-
- mtx_unlock(&loop->lock);
- return ZX_OK;
-}
-
-static zx_status_t async_loop_queue_packet(async_dispatcher_t* async, async_receiver_t* receiver,
- const zx_packet_user_t* data) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(receiver);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- zx_port_packet_t packet = {
- .key = (uintptr_t)receiver,
- .type = ZX_PKT_TYPE_USER,
- .status = ZX_OK};
- if (data)
- packet.user = *data;
- return zx_port_queue(loop->port, &packet);
-}
-
-static zx_status_t async_loop_set_guest_bell_trap(
- async_dispatcher_t* async, async_guest_bell_trap_t* trap,
- zx_handle_t guest, zx_vaddr_t addr, size_t length) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(trap);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- zx_status_t status = zx_guest_set_trap(guest, ZX_GUEST_TRAP_BELL, addr,
- length, loop->port, (uintptr_t)trap);
- if (status != ZX_OK) {
- ZX_ASSERT_MSG(status == ZX_ERR_ACCESS_DENIED ||
- status == ZX_ERR_ALREADY_EXISTS ||
- status == ZX_ERR_INVALID_ARGS ||
- status == ZX_ERR_OUT_OF_RANGE ||
- status == ZX_ERR_WRONG_TYPE,
- "zx_guest_set_trap: status=%d", status);
- }
- return status;
-}
-
-static zx_status_t async_loop_bind_exception_port(async_dispatcher_t* async,
- async_exception_t* exception) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(exception);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- mtx_lock(&loop->lock);
-
- uint64_t key = (uintptr_t)(void*) exception;
- zx_status_t status = zx_task_bind_exception_port(exception->task, loop->port,
- key, exception->options);
- if (status == ZX_OK) {
- list_add_head(&loop->exception_list, exception_to_node(exception));
- }
-
- mtx_unlock(&loop->lock);
- return status;
-}
-
-static zx_status_t async_loop_unbind_exception_port(async_dispatcher_t* async,
- async_exception_t* exception) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(exception);
-
- // Note: We need to process unbindings even while the loop is being
- // destroyed in case the client is counting on the handler not being
- // invoked again past this point.
-
- mtx_lock(&loop->lock);
-
- // First, confirm that the port is actually bound.
- list_node_t* node = exception_to_node(exception);
- if (!list_in_list(node)) {
- mtx_unlock(&loop->lock);
- return ZX_ERR_NOT_FOUND;
- }
-
- uint64_t key = (uintptr_t)(void*) exception;
- zx_status_t status = zx_task_bind_exception_port(exception->task,
- ZX_HANDLE_INVALID, key, 0);
-
- if (status == ZX_OK) {
- list_delete(node);
- }
-
- mtx_unlock(&loop->lock);
- return status;
-}
-
-static zx_status_t async_loop_resume_from_exception(async_dispatcher_t* async,
- async_exception_t* exception,
- zx_handle_t task,
- uint32_t options) {
- async_loop_t* loop = (async_loop_t*)async;
- ZX_DEBUG_ASSERT(loop);
- ZX_DEBUG_ASSERT(exception);
-
- if (atomic_load_explicit(&loop->state, memory_order_acquire) == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- return zx_task_resume_from_exception(task, loop->port, options);
-}
-
-static void async_loop_insert_task_locked(async_loop_t* loop, async_task_t* task) {
- // TODO(ZX-976): We assume that tasks are inserted in quasi-monotonic order and
- // that insertion into the task queue will typically take no more than a few steps.
- // If this assumption proves false and the cost of insertion becomes a problem, we
- // should consider using a more efficient representation for maintaining order.
- list_node_t* node;
- for (node = loop->task_list.prev; node != &loop->task_list; node = node->prev) {
- if (task->deadline >= node_to_task(node)->deadline)
- break;
- }
- list_add_after(node, task_to_node(task));
-}
-
-static void async_loop_restart_timer_locked(async_loop_t* loop) {
- zx_time_t deadline;
- if (list_is_empty(&loop->due_list)) {
- list_node_t* head = list_peek_head(&loop->task_list);
- if (!head)
- return;
- async_task_t* task = node_to_task(head);
- deadline = task->deadline;
- if (deadline == ZX_TIME_INFINITE)
- return;
- } else {
- // Fire now.
- deadline = 0ULL;
- }
-
- zx_status_t status = zx_timer_set(loop->timer, deadline, 0);
- ZX_ASSERT_MSG(status == ZX_OK, "zx_timer_set: status=%d", status);
-}
-
-static void async_loop_invoke_prologue(async_loop_t* loop) {
- if (loop->config.prologue)
- loop->config.prologue(loop, loop->config.data);
-}
-
-static void async_loop_invoke_epilogue(async_loop_t* loop) {
- if (loop->config.epilogue)
- loop->config.epilogue(loop, loop->config.data);
-}
-
-static int async_loop_run_thread(void* data) {
- async_loop_t* loop = (async_loop_t*)data;
- async_set_default_dispatcher(&loop->dispatcher);
- async_loop_run(loop, ZX_TIME_INFINITE, false);
- return 0;
-}
-
-zx_status_t async_loop_start_thread(async_loop_t* loop, const char* name, thrd_t* out_thread) {
- ZX_DEBUG_ASSERT(loop);
-
- // This check is inherently racy. The client should not be racing shutdown
- // with attemps to start new threads. This is mainly a sanity check.
- async_loop_state_t state = atomic_load_explicit(&loop->state, memory_order_acquire);
- if (state == ASYNC_LOOP_SHUTDOWN)
- return ZX_ERR_BAD_STATE;
-
- thread_record_t* rec = calloc(1u, sizeof(thread_record_t));
- if (!rec)
- return ZX_ERR_NO_MEMORY;
-
- if (thrd_create_with_name(&rec->thread, async_loop_run_thread, loop, name) != thrd_success) {
- free(rec);
- return ZX_ERR_NO_MEMORY;
- }
-
- mtx_lock(&loop->lock);
- list_add_tail(&loop->thread_list, &rec->node);
- mtx_unlock(&loop->lock);
-
- if (out_thread)
- *out_thread = rec->thread;
- return ZX_OK;
-}
-
-void async_loop_join_threads(async_loop_t* loop) {
- ZX_DEBUG_ASSERT(loop);
-
- mtx_lock(&loop->lock);
- for (;;) {
- thread_record_t* rec = (thread_record_t*)list_remove_head(&loop->thread_list);
- if (!rec)
- break;
-
- mtx_unlock(&loop->lock);
- thrd_t thread = rec->thread;
- free(rec);
- int result = thrd_join(thread, NULL);
- ZX_DEBUG_ASSERT(result == thrd_success);
- mtx_lock(&loop->lock);
- }
- mtx_unlock(&loop->lock);
-}
diff --git a/pkg/async-loop/meta.json b/pkg/async-loop/meta.json
deleted file mode 100644
index 8a1eef7..0000000
--- a/pkg/async-loop/meta.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "banjo_deps": [],
- "deps": [
- "async",
- "async-default"
- ],
- "fidl_deps": [],
- "files": [
- "pkg/async-loop/loop.c",
- "pkg/async-loop/include/lib/async-loop/loop.h"
- ],
- "headers": [
- "pkg/async-loop/include/lib/async-loop/loop.h"
- ],
- "include_dir": "pkg/async-loop/include",
- "name": "async-loop",
- "root": "pkg/async-loop",
- "sources": [
- "pkg/async-loop/loop.c"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/async/include/lib/async/dispatcher.h b/pkg/async/include/lib/async/dispatcher.h
index ff9b760..8542435 100644
--- a/pkg/async/include/lib/async/dispatcher.h
+++ b/pkg/async/include/lib/async/dispatcher.h
@@ -20,7 +20,8 @@
typedef struct async_wait async_wait_t;
typedef struct async_task async_task_t;
typedef struct async_receiver async_receiver_t;
-typedef struct async_exception async_exception_t;
+typedef struct async_irq async_irq_t;
+typedef struct async_paged_vmo async_paged_vmo_t;
// Private state owned by the asynchronous dispatcher.
// This allows the dispatcher to associate a small amount of state with pending
@@ -30,11 +31,11 @@
// Clients must initialize the contents of this structure to zero using
// |ASYNC_STATE_INIT| or with calloc, memset, or a similar means.
typedef struct {
- uintptr_t reserved[2];
+ uintptr_t reserved[2];
} async_state_t;
#define ASYNC_STATE_INIT \
- { 0u, 0u }
+ { 0u, 0u }
// Asynchronous dispatcher interface.
//
@@ -50,7 +51,6 @@
// - Posting tasks: |post_task|, |cancel_task|
// - Queuing packets: |queue_packet|
// - Virtual machine operations: |set_guest_bell_trap|
-// - Exception handling: |bind_exception_port|, |unbind_exception_port|
//
// To preserve binary compatibility, each successive version of this interface
// is guaranteed to be backwards-compatible with clients of earlier versions.
@@ -70,54 +70,48 @@
// the whole interface to ensure broad compatibility.
typedef uint32_t async_ops_version_t;
-#define ASYNC_OPS_V1 ((async_ops_version_t) 1)
-#define ASYNC_OPS_V2 ((async_ops_version_t) 2)
+#define ASYNC_OPS_V1 ((async_ops_version_t)1)
+#define ASYNC_OPS_V2 ((async_ops_version_t)2)
typedef struct async_ops {
- // The interface version number, e.g. |ASYNC_OPS_V2|.
- async_ops_version_t version;
+ // The interface version number, e.g. |ASYNC_OPS_V1|.
+ async_ops_version_t version;
- // Reserved for future expansion, set to zero.
- uint32_t reserved;
+ // Reserved for future expansion, set to zero.
+ uint32_t reserved;
- // Operations supported by |ASYNC_OPS_V1|.
- struct v1 {
- // See |async_now()| for details.
- zx_time_t (*now)(async_dispatcher_t* dispatcher);
- // See |async_begin_wait()| for details.
- zx_status_t (*begin_wait)(async_dispatcher_t* dispatcher, async_wait_t* wait);
- // See |async_cancel_wait()| for details.
- zx_status_t (*cancel_wait)(async_dispatcher_t* dispatcher, async_wait_t* wait);
- // See |async_post_task()| for details.
- zx_status_t (*post_task)(async_dispatcher_t* dispatcher, async_task_t* task);
- // See |async_cancel_task()| for details.
- zx_status_t (*cancel_task)(async_dispatcher_t* dispatcher, async_task_t* task);
- // See |async_queue_packet()| for details.
- zx_status_t (*queue_packet)(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
- const zx_packet_user_t* data);
- // See |async_set_guest_bell_trap()| for details.
- zx_status_t (*set_guest_bell_trap)(async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
- zx_handle_t guest, zx_vaddr_t addr, size_t length);
- } v1;
-
- // Operations supported by |ASYNC_OPS_V2|, in addition to those in V1.
- struct v2 {
- // See |async_bind_exception_port()| for details.
- zx_status_t (*bind_exception_port)(async_dispatcher_t* dispatcher,
- async_exception_t* exception);
- // See |async_unbind_exception_port()| for details.
- zx_status_t (*unbind_exception_port)(async_dispatcher_t* dispatcher,
- async_exception_t* exception);
- // See |async_resume_from_exception()| for details.
- zx_status_t (*resume_from_exception)(async_dispatcher_t* dispatcher,
- async_exception_t* exception,
- zx_handle_t task,
- uint32_t options);
- } v2;
+ // Operations supported by |ASYNC_OPS_V1|.
+ struct v1 {
+ // See |async_now()| for details.
+ zx_time_t (*now)(async_dispatcher_t* dispatcher);
+ // See |async_begin_wait()| for details.
+ zx_status_t (*begin_wait)(async_dispatcher_t* dispatcher, async_wait_t* wait);
+ // See |async_cancel_wait()| for details.
+ zx_status_t (*cancel_wait)(async_dispatcher_t* dispatcher, async_wait_t* wait);
+ // See |async_post_task()| for details.
+ zx_status_t (*post_task)(async_dispatcher_t* dispatcher, async_task_t* task);
+ // See |async_cancel_task()| for details.
+ zx_status_t (*cancel_task)(async_dispatcher_t* dispatcher, async_task_t* task);
+ // See |async_queue_packet()| for details.
+ zx_status_t (*queue_packet)(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
+ const zx_packet_user_t* data);
+ // See |async_set_guest_bell_trap()| for details.
+ zx_status_t (*set_guest_bell_trap)(async_dispatcher_t* dispatcher,
+ async_guest_bell_trap_t* trap, zx_handle_t guest,
+ zx_vaddr_t addr, size_t length);
+ } v1;
+ struct v2 {
+ zx_status_t (*bind_irq)(async_dispatcher_t* dispatcher, async_irq_t* irq);
+ zx_status_t (*unbind_irq)(async_dispatcher_t* dispatcher, async_irq_t* irq);
+ zx_status_t (*create_paged_vmo)(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ uint32_t options, zx_handle_t pager, uint64_t vmo_size,
+ zx_handle_t* vmo_out);
+ zx_status_t (*detach_paged_vmo)(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo);
+ } v2;
} async_ops_t;
struct async_dispatcher {
- const async_ops_t* ops;
+ const async_ops_t* ops;
};
__END_CDECLS
diff --git a/pkg/async/include/lib/async/exception.h b/pkg/async/include/lib/async/exception.h
deleted file mode 100644
index 654a294..0000000
--- a/pkg/async/include/lib/async/exception.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_ASYNC_EXCEPTION_H_
-#define LIB_ASYNC_EXCEPTION_H_
-
-#include <lib/async/dispatcher.h>
-
-__BEGIN_CDECLS
-
-// Handles receipt of packets containing exception reports.
-//
-// The |status| is |ZX_OK| if the packet was successfully delivered and |data|
-// contains the information from the packet, otherwise |data| is null.
-// The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down.
-typedef void(async_exception_handler_t)(async_dispatcher_t* dispatcher,
- async_exception_t* exception,
- zx_status_t status,
- const zx_port_packet_t* report);
-
-// Holds content for an exception packet receiver and its handler.
-//
-// The client is responsible for retaining the structure in memory
-// (and unmodified) until all packets have been received by the handler or the
-// dispatcher shuts down.
-//
-// Multiple packets may be delivered to the same receiver concurrently.
-struct async_exception {
- // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
- async_state_t state;
-
- // The handler to invoke when a packet is received.
- async_exception_handler_t* handler;
-
- // The task we're watching.
- zx_handle_t task;
-
- // The options to pass to zx_task_bind_exception_port().
- uint32_t options;
-};
-
-// Bind the async port to the task's exception port.
-//
-// Returns |ZX_OK| if task's exception port was successfully bound to.
-// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
-// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
-// Other error values are possible. See the documentation for
-// |zx_task_bind_exception_port()|.
-//
-// This operation is thread-safe.
-zx_status_t async_bind_exception_port(async_dispatcher_t* dispatcher,
- async_exception_t* exception);
-
-// Unbind the async port from |task|'s exception port.
-//
-// Returns |ZX_OK| if the task's exception port was successfully unbound.
-// Returns |ZX_ERR_NOT_FOUND| if the port is not bound.
-// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
-// Other error values are possible. See the documentation for
-// |zx_task_bind_exception_port()|.
-//
-// This operation is thread-safe.
-zx_status_t async_unbind_exception_port(async_dispatcher_t* dispatcher,
- async_exception_t* exception);
-
-// Resume |task| after having processed an exception for it.
-// |options| is passed to |zx_task_resume_from_exception()|.
-//
-// Returns |ZX_OK| if the task was resumed.
-// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
-// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
-// Other error values are possible. See the documentation for
-// |zx_task_resume_from_exception()|.
-//
-// This operation is thread-safe.
-zx_status_t async_resume_from_exception(async_dispatcher_t* dispatcher,
- async_exception_t* exception,
- zx_handle_t task,
- uint32_t options);
-
-__END_CDECLS
-
-#endif // LIB_ASYNC_EXCEPTION_H_
diff --git a/pkg/async/include/lib/async/irq.h b/pkg/async/include/lib/async/irq.h
new file mode 100644
index 0000000..1ad2510
--- /dev/null
+++ b/pkg/async/include/lib/async/irq.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_IRQ_H_
+#define LIB_ASYNC_IRQ_H_
+
+#include <lib/async/dispatcher.h>
+
+__BEGIN_CDECLS
+
+// Handles interrupt.
+//
+// The |status| is |ZX_OK| if the IRQ was signalled.
+// The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
+// the task's handler ran or the task was canceled.
+typedef void(async_irq_handler_t)(async_dispatcher_t* dispatcher, async_irq_t* irq,
+ zx_status_t status, const zx_packet_interrupt_t* signal);
+
+// Similar to async_wait, but holds state for an interrupt.
+struct async_irq {
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
+
+ // The wait's handler function.
+ async_irq_handler_t* handler;
+
+ // The object to wait for signals on.
+ zx_handle_t object;
+};
+
+// Begins asynchronously waiting on an IRQ specified in |irq|.
+// Invokes the handler when the wait completes.
+// The wait's handler will be invoked exactly once unless the wait is canceled.
+// When the dispatcher is shutting down (being destroyed), the handlers of
+// all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.
+//
+// Returns |ZX_OK| if the wait was successfully begun.
+// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+//
+// This operation is thread-safe.
+zx_status_t async_bind_irq(async_dispatcher_t* dispatcher, async_irq_t* irq);
+
+// Unbinds the IRQ associated with |irq|.
+//
+// If successful, the IRQ will be unbound from the async loop.
+//
+// Returns |ZX_OK| if the IRQ has been successfully unbound.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+//
+// This operation is thread-safe.
+zx_status_t async_unbind_irq(async_dispatcher_t* dispatcher, async_irq_t* irq);
+
+__END_CDECLS
+
+#endif // LIB_ASYNC_IRQ_H_
diff --git a/pkg/async/include/lib/async/paged_vmo.h b/pkg/async/include/lib/async/paged_vmo.h
new file mode 100644
index 0000000..88b575b
--- /dev/null
+++ b/pkg/async/include/lib/async/paged_vmo.h
@@ -0,0 +1,62 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ASYNC_PAGED_VMO_H_
+#define LIB_ASYNC_PAGED_VMO_H_
+
+#include <lib/async/dispatcher.h>
+
+__BEGIN_CDECLS
+
+// Handles port packets containing page requests.
+//
+// The |status| is |ZX_OK| if the packet was successfully delivered and |request|
+// contains the information from the packet, otherwise |request| is null.
+// The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down.
+typedef void(async_paged_vmo_handler_t)(async_dispatcher_t* dispatcher,
+ async_paged_vmo_t* paged_vmo, zx_status_t status,
+ const zx_packet_page_request_t* request);
+
+// Holds content for a paged request packet receiver and its handler.
+//
+// The client is responsible for retaining the structure in memory
+// (and unmodified) until all packets have been received by the handler or the
+// dispatcher shuts down.
+struct async_paged_vmo {
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
+
+ // The handler to invoke when a packet is received.
+ async_paged_vmo_handler_t* handler;
+
+ // The associated pager when creating the VMO.
+ zx_handle_t pager;
+
+ // The VMO for this request.
+ zx_handle_t vmo;
+};
+
+// Create a pager owned VMO.
+//
+// Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+// Other error values are possible. See the documentation for
+// |zx_pager_create_vmo()|.
+zx_status_t async_create_paged_vmo(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ uint32_t options, zx_handle_t pager, uint64_t vmo_size,
+ zx_handle_t* vmo_out);
+
+// Detach ownership of VMO from pager.
+//
+// Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.
+// Returns |ZX_ERR_BAD_HANDLE| if pager or vmo is not a valid handle.
+// Returns |ZX_ERR_WRONG_TYPE| if pager is not a pager handle or vmo is not a vmo handle.
+// Returns |ZX_ERR_INVALID_ARGS| if vmo is not a vmo created from pager.
+// Other error values are possible. See the documentation for
+// |zx_detach_paged_vmo()|.
+zx_status_t async_detach_paged_vmo(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo);
+
+__END_CDECLS
+
+#endif // LIB_ASYNC_PAGED_VMO_H_
diff --git a/pkg/async/include/lib/async/receiver.h b/pkg/async/include/lib/async/receiver.h
index 453df71..ed60d7c 100644
--- a/pkg/async/include/lib/async/receiver.h
+++ b/pkg/async/include/lib/async/receiver.h
@@ -13,10 +13,8 @@
//
// The |status| is |ZX_OK| if the packet was successfully delivered and |data|
// contains the information from the packet, otherwise |data| is null.
-typedef void(async_receiver_handler_t)(async_dispatcher_t* dispatcher,
- async_receiver_t* receiver,
- zx_status_t status,
- const zx_packet_user_t* data);
+typedef void(async_receiver_handler_t)(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
+ zx_status_t status, const zx_packet_user_t* data);
// Holds content for a packet receiver and its handler.
//
@@ -27,11 +25,11 @@
//
// Multiple packets may be delivered to the same receiver concurrently.
struct async_receiver {
- // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
- async_state_t state;
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
- // The handler to invoke when a packet is received.
- async_receiver_handler_t* handler;
+ // The handler to invoke when a packet is received.
+ async_receiver_handler_t* handler;
};
// Enqueues a packet of data for delivery to a receiver.
@@ -49,4 +47,4 @@
__END_CDECLS
-#endif // LIB_ASYNC_RECEIVER_H_
\ No newline at end of file
+#endif // LIB_ASYNC_RECEIVER_H_
diff --git a/pkg/async/include/lib/async/task.h b/pkg/async/include/lib/async/task.h
index ee0b295..936270e 100644
--- a/pkg/async/include/lib/async/task.h
+++ b/pkg/async/include/lib/async/task.h
@@ -13,9 +13,8 @@
//
// The |status| is |ZX_OK| if the task's deadline elapsed and the task should run.
// The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
-// the task's handler ran or the task was canceled.
-typedef void(async_task_handler_t)(async_dispatcher_t* dispatcher,
- async_task_t* task,
+// the task's handler ran.
+typedef void(async_task_handler_t)(async_dispatcher_t* dispatcher, async_task_t* task,
zx_status_t status);
// Holds context for a task and its handler.
@@ -25,16 +24,16 @@
// is successfully canceled, or the dispatcher shuts down. Thereafter, the task
// may be posted again or destroyed.
struct async_task {
- // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
- async_state_t state;
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
- // The task's handler function.
- async_task_handler_t* handler;
+ // The task's handler function.
+ async_task_handler_t* handler;
- // The task's deadline must be expressed in the time base used by the asynchronous
- // dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).
- // See |async_now()| for details.
- zx_time_t deadline;
+ // The task's deadline must be expressed in the time base used by the asynchronous
+ // dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).
+ // See |async_now()| for details.
+ zx_time_t deadline;
};
// Posts a task to run on or after its deadline following all posted
@@ -67,4 +66,4 @@
__END_CDECLS
-#endif // LIB_ASYNC_TASK_H_
\ No newline at end of file
+#endif // LIB_ASYNC_TASK_H_
diff --git a/pkg/async/include/lib/async/time.h b/pkg/async/include/lib/async/time.h
index fe62cd5..c800099 100644
--- a/pkg/async/include/lib/async/time.h
+++ b/pkg/async/include/lib/async/time.h
@@ -16,4 +16,4 @@
__END_CDECLS
-#endif // LIB_ASYNC_TIME_H_
\ No newline at end of file
+#endif // LIB_ASYNC_TIME_H_
diff --git a/pkg/async/include/lib/async/trap.h b/pkg/async/include/lib/async/trap.h
index 814d9ef..6bd62c6 100644
--- a/pkg/async/include/lib/async/trap.h
+++ b/pkg/async/include/lib/async/trap.h
@@ -14,8 +14,7 @@
// The |status| is |ZX_OK| if the bell was received and |bell| contains the
// information from the packet, otherwise |bell| is null.
typedef void(async_guest_bell_trap_handler_t)(async_dispatcher_t* dispatcher,
- async_guest_bell_trap_t* trap,
- zx_status_t status,
+ async_guest_bell_trap_t* trap, zx_status_t status,
const zx_packet_guest_bell_t* bell);
// Holds context for a bell trap and its handler.
@@ -24,11 +23,11 @@
// the structure in memory (and unmodified) until the guest has been destroyed or the
// dispatcher shuts down. There is no way to cancel a trap which has been set.
struct async_guest_bell_trap {
- // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
- async_state_t state;
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
- // The handler to invoke to handle the trap access.
- async_guest_bell_trap_handler_t* handler;
+ // The handler to invoke to handle the trap access.
+ async_guest_bell_trap_handler_t* handler;
};
// Sets a bell trap in the guest to be handled asynchronously via a handler.
@@ -53,4 +52,4 @@
__END_CDECLS
-#endif // LIB_ASYNC_TRAP_H_
\ No newline at end of file
+#endif // LIB_ASYNC_TRAP_H_
diff --git a/pkg/async/include/lib/async/wait.h b/pkg/async/include/lib/async/wait.h
index d359979..713986f 100644
--- a/pkg/async/include/lib/async/wait.h
+++ b/pkg/async/include/lib/async/wait.h
@@ -14,10 +14,8 @@
// The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.
// The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before
// the task's handler ran or the task was canceled.
-typedef void(async_wait_handler_t)(async_dispatcher_t* dispatcher,
- async_wait_t* wait,
- zx_status_t status,
- const zx_packet_signal_t* signal);
+typedef void(async_wait_handler_t)(async_dispatcher_t* dispatcher, async_wait_t* wait,
+ zx_status_t status, const zx_packet_signal_t* signal);
// Holds context for an asynchronous wait operation and its handler.
//
@@ -26,17 +24,20 @@
// is successfully canceled, or the dispatcher shuts down. Thereafter, the wait
// may be started begun or destroyed.
struct async_wait {
- // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
- async_state_t state;
+ // Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|.
+ async_state_t state;
- // The wait's handler function.
- async_wait_handler_t* handler;
+ // The wait's handler function.
+ async_wait_handler_t* handler;
- // The object to wait for signals on.
- zx_handle_t object;
+ // The object to wait for signals on.
+ zx_handle_t object;
- // The set of signals to wait for.
- zx_signals_t trigger;
+ // The set of signals to wait for.
+ zx_signals_t trigger;
+
+ // Wait options, see zx_object_wait_async().
+ uint32_t options;
};
// Begins asynchronously waiting for an object to receive one or more signals
@@ -71,4 +72,4 @@
__END_CDECLS
-#endif // LIB_ASYNC_WAIT_H_
\ No newline at end of file
+#endif // LIB_ASYNC_WAIT_H_
diff --git a/pkg/async/meta.json b/pkg/async/meta.json
index 31913e9..94a8433 100644
--- a/pkg/async/meta.json
+++ b/pkg/async/meta.json
@@ -1,31 +1,24 @@
{
- "banjo_deps": [],
- "deps": [],
- "fidl_deps": [],
- "files": [
- "pkg/async/ops.c",
- "pkg/async/include/lib/async/dispatcher.h",
- "pkg/async/include/lib/async/exception.h",
- "pkg/async/include/lib/async/receiver.h",
- "pkg/async/include/lib/async/task.h",
- "pkg/async/include/lib/async/time.h",
- "pkg/async/include/lib/async/trap.h",
- "pkg/async/include/lib/async/wait.h"
- ],
+ "banjo_deps": [],
+ "deps": [
+ "fit"
+ ],
+ "fidl_deps": [],
"headers": [
- "pkg/async/include/lib/async/dispatcher.h",
- "pkg/async/include/lib/async/exception.h",
- "pkg/async/include/lib/async/receiver.h",
- "pkg/async/include/lib/async/task.h",
- "pkg/async/include/lib/async/time.h",
- "pkg/async/include/lib/async/trap.h",
+ "pkg/async/include/lib/async/dispatcher.h",
+ "pkg/async/include/lib/async/irq.h",
+ "pkg/async/include/lib/async/paged_vmo.h",
+ "pkg/async/include/lib/async/receiver.h",
+ "pkg/async/include/lib/async/task.h",
+ "pkg/async/include/lib/async/time.h",
+ "pkg/async/include/lib/async/trap.h",
"pkg/async/include/lib/async/wait.h"
- ],
- "include_dir": "pkg/async/include",
- "name": "async",
- "root": "pkg/async",
+ ],
+ "include_dir": "pkg/async/include",
+ "name": "async",
+ "root": "pkg/async",
"sources": [
"pkg/async/ops.c"
- ],
+ ],
"type": "cc_source_library"
}
\ No newline at end of file
diff --git a/pkg/async/ops.c b/pkg/async/ops.c
index e3b1d6d..4bea01a 100644
--- a/pkg/async/ops.c
+++ b/pkg/async/ops.c
@@ -8,55 +8,61 @@
#include <lib/async/trap.h>
#include <lib/async/wait.h>
-zx_time_t async_now(async_dispatcher_t* dispatcher) {
- return dispatcher->ops->v1.now(dispatcher);
-}
+zx_time_t async_now(async_dispatcher_t* dispatcher) { return dispatcher->ops->v1.now(dispatcher); }
zx_status_t async_begin_wait(async_dispatcher_t* dispatcher, async_wait_t* wait) {
- return dispatcher->ops->v1.begin_wait(dispatcher, wait);
+ return dispatcher->ops->v1.begin_wait(dispatcher, wait);
}
zx_status_t async_cancel_wait(async_dispatcher_t* dispatcher, async_wait_t* wait) {
- return dispatcher->ops->v1.cancel_wait(dispatcher, wait);
+ return dispatcher->ops->v1.cancel_wait(dispatcher, wait);
}
zx_status_t async_post_task(async_dispatcher_t* dispatcher, async_task_t* task) {
- return dispatcher->ops->v1.post_task(dispatcher, task);
+ return dispatcher->ops->v1.post_task(dispatcher, task);
}
zx_status_t async_cancel_task(async_dispatcher_t* dispatcher, async_task_t* task) {
- return dispatcher->ops->v1.cancel_task(dispatcher, task);
+ return dispatcher->ops->v1.cancel_task(dispatcher, task);
}
zx_status_t async_queue_packet(async_dispatcher_t* dispatcher, async_receiver_t* receiver,
const zx_packet_user_t* data) {
- return dispatcher->ops->v1.queue_packet(dispatcher, receiver, data);
+ return dispatcher->ops->v1.queue_packet(dispatcher, receiver, data);
}
zx_status_t async_set_guest_bell_trap(async_dispatcher_t* dispatcher, async_guest_bell_trap_t* trap,
zx_handle_t guest, zx_vaddr_t addr, size_t length) {
- return dispatcher->ops->v1.set_guest_bell_trap(dispatcher, trap, guest, addr, length);
+ return dispatcher->ops->v1.set_guest_bell_trap(dispatcher, trap, guest, addr, length);
}
-zx_status_t async_bind_exception_port(async_dispatcher_t* dispatcher,
- async_exception_t* exception) {
- if (dispatcher->ops->version < ASYNC_OPS_V2)
- return ZX_ERR_NOT_SUPPORTED;
- return dispatcher->ops->v2.bind_exception_port(dispatcher, exception);
+zx_status_t async_bind_irq(async_dispatcher_t* dispatcher, async_irq_t* irq) {
+ if (dispatcher->ops->version < ASYNC_OPS_V2) {
+ return ZX_ERR_NOT_SUPPORTED;
+ }
+ return dispatcher->ops->v2.bind_irq(dispatcher, irq);
}
-zx_status_t async_unbind_exception_port(async_dispatcher_t* dispatcher,
- async_exception_t* exception) {
- if (dispatcher->ops->version < ASYNC_OPS_V2)
- return ZX_ERR_NOT_SUPPORTED;
- return dispatcher->ops->v2.unbind_exception_port(dispatcher, exception);
+zx_status_t async_unbind_irq(async_dispatcher_t* dispatcher, async_irq_t* irq) {
+ if (dispatcher->ops->version < ASYNC_OPS_V2) {
+ return ZX_ERR_NOT_SUPPORTED;
+ }
+ return dispatcher->ops->v2.unbind_irq(dispatcher, irq);
}
-zx_status_t async_resume_from_exception(async_dispatcher_t* dispatcher,
- async_exception_t* exception,
- zx_handle_t task,
- uint32_t options) {
- if (dispatcher->ops->version < ASYNC_OPS_V2)
- return ZX_ERR_NOT_SUPPORTED;
- return dispatcher->ops->v2.resume_from_exception(dispatcher, exception, task, options);
+zx_status_t async_create_paged_vmo(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo,
+ uint32_t options, zx_handle_t pager, uint64_t vmo_size,
+ zx_handle_t* vmo_out) {
+ if (dispatcher->ops->version < ASYNC_OPS_V2) {
+ return ZX_ERR_NOT_SUPPORTED;
+ }
+ return dispatcher->ops->v2.create_paged_vmo(dispatcher, paged_vmo, options, pager, vmo_size,
+ vmo_out);
+}
+
+zx_status_t async_detach_paged_vmo(async_dispatcher_t* dispatcher, async_paged_vmo_t* paged_vmo) {
+ if (dispatcher->ops->version < ASYNC_OPS_V2) {
+ return ZX_ERR_NOT_SUPPORTED;
+ }
+ return dispatcher->ops->v2.detach_paged_vmo(dispatcher, paged_vmo);
}
diff --git a/pkg/fdio/include/lib/fdio/debug.h b/pkg/fdio/include/lib/fdio/debug.h
deleted file mode 100644
index 22acfb6..0000000
--- a/pkg/fdio/include/lib/fdio/debug.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <stdio.h>
-#include <zircon/compiler.h>
-
-__BEGIN_CDECLS
-
-// per-file chatty debug macro
-#define xprintf(fmt, args...) \
- do { \
- if (ZXDEBUG) { \
- printf("%s:%d: " fmt, __FILE__, __LINE__, ##args); \
- } \
- } while (0)
-
-__END_CDECLS
diff --git a/pkg/fdio/include/lib/fdio/directory.h b/pkg/fdio/include/lib/fdio/directory.h
new file mode 100644
index 0000000..e4f4d50
--- /dev/null
+++ b/pkg/fdio/include/lib/fdio/directory.h
@@ -0,0 +1,144 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_DIRECTORY_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_DIRECTORY_H_
+
+#include <lib/fdio/fd.h>
+#include <lib/fdio/fdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// Connects to a service at the given |path|.
+//
+// The |path| is looked up in the namespace for the current process. If found in
+// the namespace, the object at the path is opened, passing the |request| to
+// the remote party.
+//
+// Upon success, the |request| is handed off to the remote party. The operation
+// completes asynchronously, which means a ZX_OK result does not ensure that the
+// requested service actually exists.
+//
+// |request| must be a channel.
+//
+// Always consumes |request|.
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: |path| is invalid.
+//
+// ZX_ERR_NOT_FOUND: A prefix of |path| cannot be found in the namespace for the
+// current process.
+//
+// ZX_ERR_NOT_SUPPORTED: The requested |path| was found in the namespace for the
+// current process but the namespace entry does not support connecting to
+// services.
+//
+// ZX_ERR_ACCESS_DENIED: The namespace entry has insufficient rights to connect
+// to services.
+zx_status_t fdio_service_connect(const char* path, zx_handle_t request);
+
+// Connects to a service at the given |path| relative to the given |directory|.
+//
+// Upon success, the |request| is handed off to the remote party. The operation
+// completes asynchronously, which means a ZX_OK result does not ensure that the
+// requested service actually exists.
+//
+// |directory| must be a channel that implements the |fuchsia.io.Directory|
+// protocol.
+//
+// |request| must be a channel.
+//
+// Always consumes |request|.
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: |directory| or |path| is invalid.
+//
+// ZX_ERR_ACCESS_DENIED: |directory| has insufficient rights to connect to
+// services.
+zx_status_t fdio_service_connect_at(zx_handle_t directory, const char* path, zx_handle_t request);
+
+// Opens the remote object at the given |path| relative to the root of the namespace with the given
+// |flags| asynchronously.
+//
+// |flags| is a bit field of |fuchsia.io.OPEN_*|.
+//
+// Always consumes |request|.
+//
+// See |fdio_service_connect| for details.
+zx_status_t fdio_open(const char* path, uint32_t flags, zx_handle_t request);
+
+// Opens the remote object at the given |path| relative to the given |directory| with the given
+// |flags| asynchronously.
+//
+// |flags| is a bit field of |fuchsia.io.OPEN_*|.
+//
+// Always consumes |request|.
+//
+// See |fdio_service_connect_at| for details.
+zx_status_t fdio_open_at(zx_handle_t directory, const char* path, uint32_t flags,
+ zx_handle_t request);
+
+// Opens the remote object at the given |path| relative to the root of the namespace with the given
+// |flags| synchronously, and on success, binds that channel to a file descriptor, returned via
+// |out_fd|.
+//
+// Note that unlike fdio_open, this function is synchronous. This is because it produces a file
+// descriptor, which requires synchronously waiting for the open to complete.
+//
+// |flags| is a bit field of |fuchsia.io.OPEN_*|.
+//
+// See |fdio_service_connect| for details.
+zx_status_t fdio_open_fd(const char* path, uint32_t flags, int* out_fd);
+
+// Opens the remote object at the given |path| relative to the given |dir_fd| with the given |flags|
+// synchronously, and on success, binds that channel to a file descriptor, returned via |out_fd|.
+//
+// Note that unlike fdio_open, this function is synchronous. This is because it produces a file
+// descriptor, which requires synchronously waiting for the open to complete.
+//
+// |flags| is a bit field of |fuchsia.io.OPEN_*|.
+//
+// See |fdio_service_connect| fort details.
+zx_status_t fdio_open_fd_at(int dir_fd, const char* path, uint32_t flags, int* out_fd);
+
+// Clone the given |node| asynchronously.
+//
+// |node| must be a channel that implements the |fuchsia.io.Node| protocol.
+//
+// Upon success, returns a handle to a newly created channel whose remote
+// endpoint has been sent to |node| as a request for a clone.
+//
+// The |node| is cloned as readable and writable.
+//
+// Upon failure, returns |ZX_HANDLE_INVALID|.
+zx_handle_t fdio_service_clone(zx_handle_t node);
+
+// Requests that |request| be connected to a clone of the given |node|
+// asynchronously.
+//
+// |node| must be a channel that implements the |fuchsia.io.Node| protocol.
+//
+// |request| must be a channel.
+//
+// Upon success, |request| has been sent to |node| as a request for a clone.
+//
+// The |node| is cloned as readable and writable.
+//
+// # Errors
+//
+// |ZX_ERR_INVALID_ARGS|: |node| or |request| is invalid.
+//
+// Returns transport- and application-level errors associated with
+// |fuchsia.io.Node/Clone|.
+zx_status_t fdio_service_clone_to(zx_handle_t node, zx_handle_t request);
+
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_DIRECTORY_H_
diff --git a/pkg/fdio/include/lib/fdio/fd.h b/pkg/fdio/include/lib/fdio/fd.h
new file mode 100644
index 0000000..eb63d31
--- /dev/null
+++ b/pkg/fdio/include/lib/fdio/fd.h
@@ -0,0 +1,99 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_FD_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_FD_H_
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// Create a file descriptor from a |zx_handle_t|.
+//
+// The |handle| must be to a channel, socket, vmo, or debuglog object.
+//
+// If the |zx_handle_t| is a channel, then the channel must implement the
+// |fuchsia.io.Node| protocol.
+//
+// For more precise control over which file descriptor is allocated, consider
+// using |fdio_create| and |fdio_bind_to_fd|.
+//
+// Always consumes |handle|.
+//
+// Upon success, |fd_out| contains a file descriptor that can be used to access
+// |handle|.
+//
+// # Errors
+//
+// TODO: Catalog errors.
+zx_status_t fdio_fd_create(zx_handle_t handle, int* fd_out);
+
+// Clones the current working directory.
+//
+// Upon success, |out_handle| contains a handle that represents the current
+// working directory. This handle is suitable for tranferring to another
+// process.
+//
+// # Errors
+//
+// ZX_ERR_NOT_SUPPORTED: The cwd cannot be represented as a |zx_handle_t|.
+//
+// ZX_ERR_BAD_STATE: The cwd cannot be cloned in its current state.
+//
+// ZX_ERR_ACCESS_DENIED: The cwd has insufficient rights to clone the underlying
+// object.
+zx_status_t fdio_cwd_clone(zx_handle_t* out_handle);
+
+// Clones a file descriptor.
+//
+// Upon success, |out_handle| contains a handle that represents the given file
+// descriptor. This handle is suitable for tranferring to another process.
+//
+// |fd| is not modified by this function.
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: |fd| is not a valid file descriptor.
+//
+// ZX_ERR_NOT_SUPPORTED: |fd| cannot be represented as a |zx_handle_t|.
+//
+// ZX_ERR_BAD_STATE: |fd| cannot be cloned in its current state.
+//
+// ZX_ERR_ACCESS_DENIED: |fd| has insufficient rights to clone the underlying
+// object.
+zx_status_t fdio_fd_clone(int fd, zx_handle_t* out_handle);
+
+// Prepares a file descriptor for transfer to another process.
+//
+// Upon success, |out_handle| contains a handle that represents the given file
+// descriptor, and the given file descriptor has been removed from the file
+// descriptor table for this process.
+//
+// Upon failure, |fd| might or might not be removed from the file descriptor
+// table for this process, depending on the error condition. If this function
+// returns |ZX_ERR_INVALID_ARGS| or |ZX_ERR_UNAVAILABLE|, the file descriptor
+// is not consumed. Otherwise, the file descriptor is consumed.
+//
+// TODO(REVIEW): This function should always consume the file descriptor.
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: |fd| is not a valid file descriptor.
+//
+// ZX_ERR_UNAVAILABLE: |fd| is busy or has been dup'ed and therefore is
+// referenced by multiple entries in the file descriptor table.
+//
+// ZX_ERR_NOT_SUPPORTED: |fd| cannot be represented as a |zx_handle_t|.
+//
+// ZX_ERR_BAD_STATE: |fd| cannot be transferred to another process in its
+// current state.
+//
+// ZX_ERR_ACCESS_DENIED: |fd| has insufficient rights to clone the underlying
+// object.
+zx_status_t fdio_fd_transfer(int fd, zx_handle_t* out_handle);
+
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_FD_H_
diff --git a/pkg/fdio/include/lib/fdio/fdio.h b/pkg/fdio/include/lib/fdio/fdio.h
new file mode 100644
index 0000000..544972d
--- /dev/null
+++ b/pkg/fdio/include/lib/fdio/fdio.h
@@ -0,0 +1,124 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_FDIO_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_FDIO_H_
+
+#include <stdint.h>
+#include <unistd.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS
+
+// An opaque structure that represents the object to which a file descriptor
+// refers.
+typedef struct fdio fdio_t;
+
+// Creates an |fdio_t| from a |zx_handle_t|.
+//
+// The |handle| must be to a channel, socket, vmo, or debuglog object.
+//
+// If the |zx_handle_t| is a channel, then the channel must implement the
+// |fuchsia.io.Node| protocol.
+//
+// Always consumes |handle|.
+//
+// # Errors
+//
+// TODO: Catalog errors.
+zx_status_t fdio_create(zx_handle_t handle, fdio_t** out_io);
+
+// Creates an |fdio_t| that does nothing.
+fdio_t* fdio_null_create(void);
+
+// Access the |zxio_t| field within an |fdio_t|.
+typedef struct zxio_tag zxio_t;
+zxio_t* fdio_get_zxio(fdio_t* io);
+
+// Creates a file descriptor that does nothing.
+//
+// Returns -1 and sets errno if the function is unable to create the file
+// descriptor (e.g., if the file descriptor table is full).
+int fdio_fd_create_null(void);
+
+// Install an |fdio_t| in the file descriptor table for this process.
+//
+// If fd >= 0, request a specific fd, and starting_fd is ignored.
+//
+// If fd < 0, request the first available fd >= starting_fd.
+//
+// Upon success, returns the allocated file descriptor. Returns -1 on failure.
+//
+// Upon success, takes ownership of the given reference to the |fdio_t|. That
+// reference is owned by the file descriptor table. Upon failure, the caller
+// retains ownership of that reference. Specifically, the caller is responsible
+// for calling |fdio_unsafe_release| upon failure.
+//
+// TODO(REVIEW): This function should always take ownership of the given
+// |fdio_t| reference.
+int fdio_bind_to_fd(fdio_t* io, int fd, int starting_fd);
+
+// Removes a file descriptor from the file descriptor table for this process.
+//
+// Upon success, the |fdio_t| underlying the file descriptor is returned in
+// |io_out|, and the caller receives ownership of one reference to |fdio_t|.
+// Specifically, the caller is responsible for calling |fdio_unsafe_release|
+// upon success.
+//
+// Upon failure, the file descriptor is not removed from the file descriptor
+// table for this process.
+//
+// TODO(REVIEW): This function should always consume the file descriptor.
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: |fd| is not a valid file descriptor.
+//
+// ZX_ERR_UNAVAILABLE: |fd| is busy or has been dup'ed and therefore is
+// referenced by multiple entries in the file descriptor table.
+zx_status_t fdio_unbind_from_fd(int fd, fdio_t** io_out);
+
+// If this fd represents a "service" (an rpc channel speaking
+// an unknown fidl protocol or a fuchsia.io.* protocol),
+// this call will return ZX_OK and return the underlying handle.
+// On both success and failure, the fd is effectively closed.
+//
+// ZX_ERR_NOT_SUPPORTED is returned if this fd does not represent
+// a FIDL transport
+//
+// ZX_ERR_UNAVAILABLE is returned if this fd has been dup()'d and
+// duplicates are sharing the FIDL transport
+//
+// TODO: Can also return ZX_ERR_NOT_FOUND. Maybe should be ZX_ERR_INVALID_ARGS?
+// TODO: This function appears to work only for |fuchsia.io| protocols now.
+// Should we rename it to something like |fdio_take_remote|?
+zx_status_t fdio_get_service_handle(int fd, zx_handle_t* out);
+
+// Storage for a ZXIO object.
+//
+// See <lib/zxio/ops.h> for more information.
+typedef struct zxio_storage zxio_storage_t;
+
+// Creates an |fdio_t| that is backed by a |zxio_t|.
+//
+// The |zxio_t| is initialized with a null ops table. The |zxio_storage_t| for
+// the |zxio_t| is returned via |out_storage|. The client can re-initialize the
+// |zxio_storage_t| to customize the behavior of the |zxio_t|.
+//
+// The returned |zxio_storage_t| is valid for the lifetime of the returned
+// |fdio_t|.
+//
+// To bind the |fdio_t| to a file descriptor, use |fdio_bind_to_fd|.
+//
+// Upon success, the caller receives ownership of one reference to |fdio_t|.
+// Specifically, the caller is responsible for calling |fdio_unsafe_release|
+// upon success.
+//
+// Upon failure, returns NULL.
+fdio_t* fdio_zxio_create(zxio_storage_t** out_storage);
+
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_FDIO_H_
diff --git a/pkg/fdio/include/lib/fdio/io.h b/pkg/fdio/include/lib/fdio/io.h
index b567cf4..9195abc 100644
--- a/pkg/fdio/include/lib/fdio/io.h
+++ b/pkg/fdio/include/lib/fdio/io.h
@@ -2,22 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_IO_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_IO_H_
+#include <lib/fdio/limits.h>
#include <limits.h>
#include <poll.h>
#include <stdbool.h>
-#include <unistd.h> // for ssize_t
-
-#include <zircon/types.h>
+#include <unistd.h> // for ssize_t
#include <zircon/compiler.h>
-
-#include <lib/fdio/limits.h>
+#include <zircon/types.h>
// flag on handle args in processargs
// instructing that this fd should be dup'd to 0/1/2
// and be used for all of stdio
-#define FDIO_FLAG_USE_FOR_STDIO 0x8000
+#define FDIO_FLAG_USE_FOR_STDIO ((uint32_t)0x8000)
// events for fdio_wait_fd()
#define FDIO_EVT_READABLE POLLIN
@@ -33,16 +32,21 @@
// create a fd that works with wait APIs (epoll, select, etc.) from a handle
// and expected signals (signals_in/signals_out correspond to POLLIN/POLLOUT
-// events respectively). the handle will be closed when the fd is closed, unless
+// events respectively). The handle will be closed when the fd is closed, unless
// shared_handle is true.
-int fdio_handle_fd(zx_handle_t h, zx_signals_t signals_in, zx_signals_t signals_out, bool shared_handle);
+int fdio_handle_fd(zx_handle_t h, zx_signals_t signals_in, zx_signals_t signals_out,
+ bool shared_handle);
-// invoke a raw fdio ioctl
-ssize_t fdio_ioctl(int fd, int op, const void* in_buf, size_t in_len, void* out_buf, size_t out_len);
-
-// create a pipe, installing one half in a fd, returning the other
-// for transport to another process
-zx_status_t fdio_pipe_half(zx_handle_t* handle, uint32_t* type);
+// Creates a pipe. The first argument returns the file descriptor representing
+// the pipe, and the second argument returns the handle of the socket used to
+// communicate with the pipe.
+//
+// # Errors
+//
+// ZX_ERR_NO_MEMORY: Failed due to a lack of memory.
+//
+// ZX_ERR_NO_RESOURCES: Failed to bind to the file descriptor.
+zx_status_t fdio_pipe_half(int* out_fd, zx_handle_t* out_handle);
// Get a read-only VMO containing the whole contents of the file.
// This function creates a clone of the underlying VMO when possible, falling
@@ -59,4 +63,10 @@
// or clone data into a new VMO).
zx_status_t fdio_get_vmo_exact(int fd, zx_handle_t* out_vmo);
+// Get a read + execute VMO containing a clone of the underlying VMO.
+// This function will fail rather than copying the contents if it cannot clone.
+zx_status_t fdio_get_vmo_exec(int fd, zx_handle_t* out_vmo);
+
__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_IO_H_
diff --git a/pkg/fdio/include/lib/fdio/limits.h b/pkg/fdio/include/lib/fdio/limits.h
index d6c5b68..0a3f7d1 100644
--- a/pkg/fdio/include/lib/fdio/limits.h
+++ b/pkg/fdio/include/lib/fdio/limits.h
@@ -2,22 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_LIMITS_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_LIMITS_H_
#include <limits.h>
// Maximum number of fds per process.
-#define FDIO_MAX_FD 256
-
-// Maximum handles used in open/clone/create.
-#define FDIO_MAX_HANDLES 3
+// TODO(fxbug.dev/33737): Investigate making the array expand dynamically to avoid
+// having to increase this further.
+#define FDIO_MAX_FD 1024
// fdio_ops_t's read/write are able to do io of
// at least this size.
#define FDIO_CHUNK_SIZE 8192
-// Maximum size for an ioctl input.
-#define FDIO_IOCTL_MAX_INPUT 1024
-
// Maximum length of a filename.
#define FDIO_MAX_FILENAME NAME_MAX
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_LIMITS_H_
diff --git a/pkg/fdio/include/lib/fdio/namespace.h b/pkg/fdio/include/lib/fdio/namespace.h
index dcd7043..a9ced5a 100644
--- a/pkg/fdio/include/lib/fdio/namespace.h
+++ b/pkg/fdio/include/lib/fdio/namespace.h
@@ -2,23 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_NAMESPACE_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_NAMESPACE_H_
#include <stdint.h>
-
#include <zircon/compiler.h>
#include <zircon/types.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
typedef struct fdio_namespace fdio_ns_t;
-
// Create a new, empty namespace
zx_status_t fdio_ns_create(fdio_ns_t** out);
-// Destroy and deallocate a namespace
-// Will fail (ZX_ERR_BAD_STATE) if the namespace is in use.
+// Destroy and deallocate a namespace.
+//
+// If the namespace is in-use, it will be destroyed once it is
+// no longer referenced.
+//
+// This function always returns |ZX_OK|.
zx_status_t fdio_ns_destroy(fdio_ns_t* ns);
// Create a new directory within a namespace, bound to the
@@ -27,18 +30,24 @@
// no "." nor ".." entries. It is relative to the root of the
// namespace.
//
-// The handle is not closed on failure.
-//
-// Will fail with ZX_ERR_BAD_STATE if the namespace is in use.
+// Ownership of |h| is transferred to |ns|: it is closed on error.
zx_status_t fdio_ns_bind(fdio_ns_t* ns, const char* path, zx_handle_t h);
+// Unbinds |path| from a namespace, closing the handle within |ns| that
+// corresponds to that path when all references to the node go out of scope.
+//
+// Returns ZX_ERR_NOT_FOUND if |path| is not a remote.
+// Returns ZX_ERR_NOT_SUPPORTED if |path| is the root of the namespace.
+// Returns ZX_ERR_INVALID_ARGS if |path| is otherwise invalid.
+zx_status_t fdio_ns_unbind(fdio_ns_t* ns, const char* path);
+
// Create a new directory within a namespace, bound to the
// directory referenced by the file descriptor fd.
// The path must be an absolute path, like "/x/y/z", containing
// no "." nor ".." entries. It is relative to the root of the
// namespace.
//
-// The fd is not closed on success or failure.
+// |fd| is borrowed by this function, but is not closed on success or error.
// Closing the fd after success does not affect namespace.
//
// Failures:
@@ -53,17 +62,19 @@
// chdir to / in the provided namespace
zx_status_t fdio_ns_chdir(fdio_ns_t* ns);
-// Replace the fdio "global" namespace with the provided namespace
-zx_status_t fdio_ns_install(fdio_ns_t* ns);
-
// Retrieve the fdio "global" namespace (if any).
zx_status_t fdio_ns_get_installed(fdio_ns_t** ns);
+// flat_namespace contains parallel arrays of handles, path names, and types. The number of
+// elements of these arrays is given by |count|. For any given offset i:
+// - handle[i] is the zx_handle_t representing that element in the namespace
+// - path[i] is the user-readable name of that element (e.g., "/bin")
+// - type[i] is a handle info entry as defined in zircon/processargs.h by PA_HND.
typedef struct fdio_flat_namespace {
- size_t count;
- zx_handle_t* handle;
- uint32_t* type;
- const char* const* path;
+ size_t count;
+ zx_handle_t* handle;
+ uint32_t* type;
+ const char* const* path;
} fdio_flat_namespace_t;
// On success the caller takes ownership of a fdio_flat_namespace_t
@@ -71,8 +82,7 @@
// one provided in 'ns' or the active root namespace, respectively.)
// The handles are CLONEs of the handles in the namespace and also
// belong to the caller.
-// The whole data structure can be released with free(), keeping in
-// mind that the handles should be used or closed first.
+// The whole data structure can be released with fdio_ns_free_flat_ns().
zx_status_t fdio_ns_export(fdio_ns_t* ns, fdio_flat_namespace_t** out);
zx_status_t fdio_ns_export_root(fdio_flat_namespace_t** out);
@@ -81,15 +91,12 @@
// or passed to the remote service on success.
// The path must be an absolute path starting with / and containing
// no ".." or "." or empty segments.
-zx_status_t fdio_ns_connect(fdio_ns_t* ns, const char* path,
- uint32_t zxflags, zx_handle_t h);
+zx_status_t fdio_ns_connect(fdio_ns_t* ns, const char* path, uint32_t zxflags, zx_handle_t h);
-// Attempt a pipelined open through a namespace.
-// Success only indicates that the open was sent.
-// If the remote fails, the returned handle's peer will be closed.
-// The path must be an absolute path starting with / and containing
-// no ".." or "." or empty segments.
-zx_status_t fdio_ns_open(fdio_ns_t* ns, const char* path,
- uint32_t zxflags, zx_handle_t* out);
+// Frees a flat namespace.
+// Closes all handles contained within |ns|.
+void fdio_ns_free_flat_ns(fdio_flat_namespace_t* ns);
-__END_CDECLS;
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_NAMESPACE_H_
diff --git a/pkg/fdio/include/lib/fdio/private.h b/pkg/fdio/include/lib/fdio/private.h
index 2ceee14..6a7b1eb 100644
--- a/pkg/fdio/include/lib/fdio/private.h
+++ b/pkg/fdio/include/lib/fdio/private.h
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_PRIVATE_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_PRIVATE_H_
+#include <stdint.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
-#include <stdint.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// WARNING: These APIs are subject to change
@@ -19,4 +20,6 @@
// is set to true if the returned path must be a directory.
zx_status_t __fdio_cleanpath(const char* in, char* out, size_t* outlen, bool* is_dir);
-__END_CDECLS;
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_PRIVATE_H_
diff --git a/pkg/fdio/include/lib/fdio/spawn.h b/pkg/fdio/include/lib/fdio/spawn.h
index 94a656d..4bc19a8 100644
--- a/pkg/fdio/include/lib/fdio/spawn.h
+++ b/pkg/fdio/include/lib/fdio/spawn.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
-
-#include <zircon/compiler.h>
-#include <zircon/types.h>
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_SPAWN_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_SPAWN_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <zircon/compiler.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
@@ -29,9 +29,6 @@
//
// The shared library loader is passed as |PA_LDSVC_LOADER|.
#define FDIO_SPAWN_DEFAULT_LDSVC ((uint32_t)0x0002u)
-// FDIO_SPAWN_CLONE_LDSVC is the same as FDIO_SPAWN_DEFAULT_LDSVC.
-// TODO(ZX-3031): this name is deprecated.
-#define FDIO_SPAWN_CLONE_LDSVC ((uint32_t)0x0002u)
// Clones the filesystem namespace into the spawned process.
#define FDIO_SPAWN_CLONE_NAMESPACE ((uint32_t)0x0004u)
@@ -45,6 +42,9 @@
// Clones the environment into the spawned process.
#define FDIO_SPAWN_CLONE_ENVIRON ((uint32_t)0x0010u)
+// Clones the process-global UTC clock into the spawned process.
+#define FDIO_SPAWN_CLONE_UTC_CLOCK ((uint32_t)0x0020u)
+
// Clones all of the above into the spawned process.
#define FDIO_SPAWN_CLONE_ALL ((uint32_t)0xFFFFu)
@@ -61,10 +61,15 @@
// |zx_job_default()|. Does not take ownership of |job|.
//
// Upon success, |process_out| will be a handle to the process.
-zx_status_t fdio_spawn(zx_handle_t job,
- uint32_t flags,
- const char* path,
- const char* const* argv,
+//
+// # Errors
+//
+// ZX_ERR_NOT_FOUND: |path| cannot be opened.
+//
+// ZX_ERR_BAD_HANDLE: |path| cannot be opened as an executable VMO.
+//
+// Returns the result of |fdio_spawn_vmo| in all other cases.
+zx_status_t fdio_spawn(zx_handle_t job, uint32_t flags, const char* path, const char* const* argv,
zx_handle_t* process_out);
// The |fdio_spawn_etc| function allows the running process to control the file
@@ -92,6 +97,21 @@
// If |FDIO_SPAWN_CLONE_NAMESPACE| is specified via |flags|, the namespace entry
// is added to the cloned namespace from the calling process.
//
+// The namespace entries are added in the order they appear in the action list.
+// If |FDIO_SPAWN_CLONE_NAMESPACE| is specified via |flags|, the entries from
+// the calling process are added before any entries specified with
+// |FDIO_SPAWN_ACTION_ADD_NS_ENTRY|.
+//
+// The spawned process decides how to process and interpret the namespace
+// entries. Typically, the spawned process with disregard duplicate entries
+// (i.e., the first entry for a given name wins) and will ignore nested entries
+// (e.g., |/foo/bar| when |/foo| has already been added to the namespace).
+//
+// To override or replace an entry in the namespace of the calling process,
+// use |fdio_ns_export_root| to export the namespace table of the calling
+// process and construct the namespace for the spawned process explicitly using
+// |FDIO_SPAWN_ACTION_ADD_NS_ENTRY|.
+//
// The given handle will be closed regardless of whether the |fdio_spawn_etc|
// call succeeds.
//
@@ -113,45 +133,56 @@
// Uses the |name| entry in the |fdio_spawn_action_t| union.
#define FDIO_SPAWN_ACTION_SET_NAME ((uint32_t)0x0005u)
+// Shares the given directory by installing it into the namespace of spawned
+// process.
+//
+// Uses the |dir| entry in the |fdio_spawn_action_t| union
+#define FDIO_SPAWN_ACTION_CLONE_DIR ((uint32_t)0x0006u)
+
// Instructs |fdio_spawn_etc| which actions to take.
typedef struct fdio_spawn_action fdio_spawn_action_t;
struct fdio_spawn_action {
- // The action to take.
- //
- // See |FDIO_SPAWN_ACTION_*| above. If |action| is invalid, the action will
- // be ignored (rather than generate an error).
- uint32_t action;
- union {
- struct {
- // The file descriptor in this process to clone or transfer.
- int local_fd;
+ // The action to take.
+ //
+ // See |FDIO_SPAWN_ACTION_*| above. If |action| is invalid, the action will
+ // be ignored (rather than generate an error).
+ uint32_t action;
+ union {
+ struct {
+ // The file descriptor in this process to clone or transfer.
+ int local_fd;
- // The file descriptor in the spawned process that will receive the
- // clone or transfer.
- int target_fd;
- } fd;
- struct {
- // The prefix in which to install the given handle in the namespace
- // of the spawned process.
- const char* prefix;
+ // The file descriptor in the spawned process that will receive the
+ // clone or transfer.
+ int target_fd;
+ } fd;
+ struct {
+ // The prefix in which to install the given handle in the namespace
+ // of the spawned process.
+ const char* prefix;
- // The handle to install with the given prefix in the namespace of
- // the spawned process.
- zx_handle_t handle;
- } ns;
- struct {
- // The process argument identifier of the handle to pass to the
- // spawned process.
- uint32_t id;
+ // The handle to install with the given prefix in the namespace of
+ // the spawned process.
+ zx_handle_t handle;
+ } ns;
+ struct {
+ // The process argument identifier of the handle to pass to the
+ // spawned process.
+ uint32_t id;
- // The handle to pass to the process on startup.
- zx_handle_t handle;
- } h;
- struct {
- // The name to assign to the spawned process.
- const char* data;
- } name;
- };
+ // The handle to pass to the process on startup.
+ zx_handle_t handle;
+ } h;
+ struct {
+ // The name to assign to the spawned process.
+ const char* data;
+ } name;
+ struct {
+ // The directory to share with the spawned process. |prefix| may match zero or more
+ // entries in the callers flat namespace.
+ const char* prefix;
+ } dir;
+ };
};
// The maximum size for error messages from |fdio_spawn_etc|.
@@ -187,14 +218,17 @@
// Upon success, |process_out| will be a handle to the process. Upon failure, if
// |err_msg_out| is not null, an error message will be we written to
// |err_msg_out|, including a null terminator.
-zx_status_t fdio_spawn_etc(zx_handle_t job,
- uint32_t flags,
- const char* path,
- const char* const* argv,
- const char* const* environ,
- size_t action_count,
- const fdio_spawn_action_t* actions,
- zx_handle_t* process_out,
+//
+// # Errors
+//
+// ZX_ERR_NOT_FOUND: |path| cannot be opened.
+//
+// ZX_ERR_BAD_HANDLE: |path| cannot be opened as an executable VMO.
+//
+// Returns the result of |fdio_spawn_vmo| in all other cases.
+zx_status_t fdio_spawn_etc(zx_handle_t job, uint32_t flags, const char* path,
+ const char* const* argv, const char* const* environ, size_t action_count,
+ const fdio_spawn_action_t* actions, zx_handle_t* process_out,
char err_msg_out[FDIO_SPAWN_ERR_MSG_MAX_LENGTH]);
// Spawn a process using the given executable in the given job.
@@ -204,14 +238,29 @@
// vmo.
//
// Always consumes |executable_vmo|.
-zx_status_t fdio_spawn_vmo(zx_handle_t job,
- uint32_t flags,
- zx_handle_t executable_vmo,
- const char* const* argv,
- const char* const* environ,
- size_t action_count,
- const fdio_spawn_action_t* actions,
- zx_handle_t* process_out,
+//
+// # Errors
+//
+// ZX_ERR_INVALID_ARGS: any supplied action is invalid, or the process name is unset.
+//
+// ZX_ERR_IO_INVALID: the recursion limit is hit resolving the executable name.
+//
+// ZX_ERR_BAD_HANDLE: |executable_vmo| is not a valid handle.
+//
+// ZX_ERR_WRONG_TYPE: |executable_vmo| is not a VMO handle.
+//
+// ZX_ERR_ACCESS_DENIED: |executable_vmo| is not readable.
+//
+// ZX_ERR_OUT_OF_RANGE: |executable_vmo| is smaller than the resolver prefix.
+//
+// ZX_ERR_INTERNAL: Cannot connect to process launcher.
+//
+// May return other errors.
+zx_status_t fdio_spawn_vmo(zx_handle_t job, uint32_t flags, zx_handle_t executable_vmo,
+ const char* const* argv, const char* const* environ, size_t action_count,
+ const fdio_spawn_action_t* actions, zx_handle_t* process_out,
char err_msg_out[FDIO_SPAWN_ERR_MSG_MAX_LENGTH]);
__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_SPAWN_H_
diff --git a/pkg/fdio/include/lib/fdio/unsafe.h b/pkg/fdio/include/lib/fdio/unsafe.h
index c0f7e41..7614e13 100644
--- a/pkg/fdio/include/lib/fdio/unsafe.h
+++ b/pkg/fdio/include/lib/fdio/unsafe.h
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_UNSAFE_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_UNSAFE_H_
+#include <stdint.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
-#include <stdint.h>
-__BEGIN_CDECLS;
+__BEGIN_CDECLS
// WARNING: These interfaces exist to allow integration of fdio file
// descriptors with handle-centric message loops. If used incorrectly
@@ -51,8 +52,8 @@
// This function is only safe to call on a fdio_t you
// hold a reference to. It is not required that fdio_unsafe_wait_end() be
// called after this.
-void fdio_unsafe_wait_begin(fdio_t* io, uint32_t events,
- zx_handle_t* handle_out, zx_signals_t* signals_out);
+void fdio_unsafe_wait_begin(fdio_t* io, uint32_t events, zx_handle_t* handle_out,
+ zx_signals_t* signals_out);
// This given a set of signals observed on a handle obtained
// from fdio_unsafe_wait_begin() returns a set of posix-style events
@@ -62,4 +63,6 @@
// hold a reference to.
void fdio_unsafe_wait_end(fdio_t* io, zx_signals_t signals, uint32_t* events_out);
-__END_CDECLS;
+__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_UNSAFE_H_
diff --git a/pkg/fdio/include/lib/fdio/util.h b/pkg/fdio/include/lib/fdio/util.h
deleted file mode 100644
index fd30748..0000000
--- a/pkg/fdio/include/lib/fdio/util.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <zircon/types.h>
-#include <zircon/compiler.h>
-#include <stdint.h>
-#include <unistd.h>
-
-__BEGIN_CDECLS
-
-// These routines are "internal" to fdio but used by some companion
-// code like userboot and devmgr
-
-typedef struct fdio fdio_t;
-
-// Utilities to help assemble handles for a new process
-// may return up to FDIO_MAX_HANDLES
-zx_status_t fdio_clone_cwd(zx_handle_t* handles, uint32_t* types);
-zx_status_t fdio_clone_fd(int fd, int newfd, zx_handle_t* handles, uint32_t* types);
-zx_status_t fdio_transfer_fd(int fd, int newfd, zx_handle_t* handles, uint32_t* types);
-
-// Attempt to create an fdio fd from some handles and their associated types,
-// as returned from fdio_transfer_fd.
-//
-// Can only create fds around:
-// - Remote IO objects
-// - Pipes
-// - Connected sockets
-//
-// This function transfers ownership of handles to the fd on success, and
-// closes them on failure.
-zx_status_t fdio_create_fd(zx_handle_t* handles, uint32_t* types, size_t hcount, int* fd_out);
-
-// attempt to install a fdio in the unistd fd table
-// if fd >= 0, request a specific fd, and starting_fd is ignored
-// if fd < 0, request the first available fd >= starting_fd
-// returns fd on success
-// the fdio must have been upref'd on behalf of the fdtab first
-int fdio_bind_to_fd(fdio_t* io, int fd, int starting_fd);
-
-// attempt to detach an fdio_t from the fd table
-// returns ZX_ERR_INVALID_ARGS if fd is out of range or doesn't exist
-// returns ZX_ERR_UNAVAILABLE if the fd is busy or has been dup'd
-// returns fdio_t via io_out with refcount 1 on success
-zx_status_t fdio_unbind_from_fd(int fd, fdio_t** io_out);
-
-// If this fd represents a "service" (an rpc channel speaking
-// an unknown fidl protocol or a fuchsia.io.* protocol),
-// this call will return ZX_OK and return the underlying handle.
-// On both success and failure, the fd is effectively closed.
-//
-// ZX_ERR_NOT_SUPPORTED is returned if this fd does not represent
-// a FIDL transport
-//
-// ZX_ERR_UNAVAILABLE is returned if this fd has been dup()'d and
-// duplicates are sharing the FIDL transport
-zx_status_t fdio_get_service_handle(int fd, zx_handle_t* out);
-
-// creates a do-nothing fdio_t
-fdio_t* fdio_null_create(void);
-
-// Wraps a channel with an fdio_t using remote io.
-// Takes ownership of h and e.
-fdio_t* fdio_remote_create(zx_handle_t h, zx_handle_t event);
-
-// creates a fdio that wraps a log object
-// this will allocate a per-thread buffer (on demand) to assemble
-// entire log-lines and flush them on newline or buffer full.
-fdio_t* fdio_logger_create(zx_handle_t);
-
-typedef struct zxio_storage zxio_storage_t;
-
-// Creates an |fdio_t| that is backed by a |zxio_t|.
-//
-// The |zxio_t| is initialized with a null ops table. The |zxio_storage_t| for
-// the |zxio_t| is returned via |out_storage|. The client can re-initialize the
-// |zxio_storage_t| to customize the behavior of the |zxio_t|.
-//
-// To bind the |fdio_t| to a file descriptor, use |fdio_bind_to_fd|.
-//
-// Upon failure, returns NULL.
-fdio_t* fdio_zxio_create(zxio_storage_t** out_storage);
-
-// Attempt to connect a channel to a named service.
-// On success the channel is connected. On failure
-// an error is returned and the handle is closed.
-zx_status_t fdio_service_connect(const char* svcpath, zx_handle_t h);
-
-// Attempt to connect a channel to a named service relative to dir.
-// On success the channel is connected. On failure
-// an error is returned and the handle is closed.
-zx_status_t fdio_service_connect_at(zx_handle_t dir, const char* path, zx_handle_t h);
-
-// Same as |fdio_service_connect|, but allows the passing of flags.
-zx_status_t fdio_open(const char* path, uint32_t zxflags, zx_handle_t h);
-
-// Same as |fdio_service_connect_at, but allows the passing of flags.
-zx_status_t fdio_open_at(zx_handle_t dir, const char* path, uint32_t zxflags, zx_handle_t h);
-
-// Attempt to clone a service handle by doing a pipelined
-// CLONE operation, returning the new channel endpoint,
-// or ZX_HANDLE_INVALID.
-zx_handle_t fdio_service_clone(zx_handle_t h);
-
-// Attempt to clone a service handle by doing a pipelined
-// CLONE operation, using the provided serving channel.
-// On success srv is bound to a clone of h. On failure
-// an error is returned and srv is closed.
-// Takes ownership of srv.
-zx_status_t fdio_service_clone_to(zx_handle_t h, zx_handle_t srv);
-
-__END_CDECLS
diff --git a/pkg/fdio/include/lib/fdio/vfs.h b/pkg/fdio/include/lib/fdio/vfs.h
index f32ccb1..7fbc8d7 100644
--- a/pkg/fdio/include/lib/fdio/vfs.h
+++ b/pkg/fdio/include/lib/fdio/vfs.h
@@ -2,21 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
-
-#include <zircon/types.h>
-#include <zircon/listnode.h>
-#include <zircon/compiler.h>
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_VFS_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_VFS_H_
#include <stdio.h>
#include <unistd.h> // ssize_t
+#include <zircon/compiler.h>
+#include <zircon/listnode.h>
+#include <zircon/processargs.h>
+#include <zircon/types.h>
__BEGIN_CDECLS
// On Fuchsia, the Block Device is transmitted by file descriptor, rather than
// by path. This can prevent some racy behavior relating to FS start-up.
#ifdef __Fuchsia__
-#define FS_FD_BLOCKDEVICE 200
+#define FS_HANDLE_ROOT_ID PA_HND(PA_USER0, 0)
+#define FS_HANDLE_BLOCK_DEVICE_ID PA_HND(PA_USER0, 1)
#endif
// POSIX defines st_blocks to be the number of 512 byte blocks allocated
@@ -27,21 +29,21 @@
#define VNATTR_BLKSIZE 512
typedef struct vnattr {
- uint32_t valid; // mask of which bits to set for setattr
- uint32_t mode;
- uint64_t inode;
- uint64_t size;
- uint64_t blksize; // Block size for filesystem I/O
- uint64_t blkcount; // Number of VNATTR_BLKSIZE byte blocks allocated
- uint64_t nlink;
- uint64_t create_time; // posix time (seconds since epoch)
- uint64_t modify_time; // posix time
+ uint32_t valid; // mask of which bits to set for setattr
+ uint32_t mode;
+ uint64_t inode;
+ uint64_t size;
+ uint64_t blksize; // Block size for filesystem I/O
+ uint64_t blkcount; // Number of VNATTR_BLKSIZE byte blocks allocated
+ uint64_t nlink;
+ uint64_t create_time; // posix time (seconds since epoch)
+ uint64_t modify_time; // posix time
} vnattr_t;
// mask that identifies what fields to set in setattr
-#define ATTR_CTIME 0000001
-#define ATTR_MTIME 0000002
-#define ATTR_ATIME 0000004 // not yet implemented
+#define ATTR_CTIME 0000001
+#define ATTR_MTIME 0000002
+#define ATTR_ATIME 0000004 // not yet implemented
// bits compatible with POSIX stat
#define V_TYPE_MASK 0170000
@@ -49,7 +51,7 @@
#define V_TYPE_LINK 0120000
#define V_TYPE_FILE 0100000
#define V_TYPE_BDEV 0060000
-#define V_TYPE_DIR 0040000
+#define V_TYPE_DIR 0040000
#define V_TYPE_CDEV 0020000
#define V_TYPE_PIPE 0010000
@@ -73,10 +75,12 @@
#define DTYPE_TO_VTYPE(type) (((type)&15) << 12)
typedef struct vdirent {
- uint64_t ino;
- uint8_t size;
- uint8_t type;
- char name[0];
+ uint64_t ino;
+ uint8_t size;
+ uint8_t type;
+ char name[0];
} __PACKED vdirent_t;
__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_VFS_H_
diff --git a/pkg/fdio/include/lib/fdio/watcher.h b/pkg/fdio/include/lib/fdio/watcher.h
index 441edcf..0f0eda3 100644
--- a/pkg/fdio/include/lib/fdio/watcher.h
+++ b/pkg/fdio/include/lib/fdio/watcher.h
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#pragma once
+#ifndef LIB_FDIO_INCLUDE_LIB_FDIO_WATCHER_H_
+#define LIB_FDIO_INCLUDE_LIB_FDIO_WATCHER_H_
-#include <zircon/compiler.h>
#include <lib/fdio/io.h>
+#include <zircon/compiler.h>
__BEGIN_CDECLS
@@ -19,7 +20,7 @@
// This event occurs, once, when fdio_watch_directory() runs
// out of existing files and has to start waiting for new
// files to be added.
-#define WATCH_EVENT_IDLE 3
+#define WATCH_EVENT_WAITING 3
// Call the provided callback (cb) for each file in directory
// and each time a new file is added to the directory.
@@ -39,5 +40,6 @@
zx_status_t fdio_watch_directory(int dirfd, watchdir_func_t cb, zx_time_t deadline, void* cookie);
-
__END_CDECLS
+
+#endif // LIB_FDIO_INCLUDE_LIB_FDIO_WATCHER_H_
diff --git a/pkg/fdio/meta.json b/pkg/fdio/meta.json
index 51babcb..7874ac0 100644
--- a/pkg/fdio/meta.json
+++ b/pkg/fdio/meta.json
@@ -1,32 +1,35 @@
{
"binaries": {
"arm64": {
- "debug": ".build-id/eb/9ed8b78bc5865718b59bd2a3a47e3e28650f8f.debug",
- "dist": "arch/arm64/dist/libfdio.so",
+ "debug": ".build-id/74/2b17fa45c78956.debug",
+ "dist": "arch/arm64/dist/libfdio.so",
+ "dist_path": "lib/libfdio.so",
"link": "arch/arm64/lib/libfdio.so"
- },
+ },
"x64": {
- "debug": ".build-id/fb/6715ba574ce88bcfca5045ee90fef94163808f.debug",
- "dist": "arch/x64/dist/libfdio.so",
+ "debug": ".build-id/cf/a07b064427801f.debug",
+ "dist": "arch/x64/dist/libfdio.so",
+ "dist_path": "lib/libfdio.so",
"link": "arch/x64/lib/libfdio.so"
}
- },
- "deps": [],
- "format": "shared",
+ },
+ "deps": [],
+ "format": "shared",
"headers": [
- "pkg/fdio/include/lib/fdio/debug.h",
- "pkg/fdio/include/lib/fdio/io.h",
- "pkg/fdio/include/lib/fdio/limits.h",
- "pkg/fdio/include/lib/fdio/namespace.h",
- "pkg/fdio/include/lib/fdio/private.h",
- "pkg/fdio/include/lib/fdio/spawn.h",
- "pkg/fdio/include/lib/fdio/unsafe.h",
- "pkg/fdio/include/lib/fdio/util.h",
- "pkg/fdio/include/lib/fdio/vfs.h",
+ "pkg/fdio/include/lib/fdio/directory.h",
+ "pkg/fdio/include/lib/fdio/fd.h",
+ "pkg/fdio/include/lib/fdio/fdio.h",
+ "pkg/fdio/include/lib/fdio/io.h",
+ "pkg/fdio/include/lib/fdio/limits.h",
+ "pkg/fdio/include/lib/fdio/namespace.h",
+ "pkg/fdio/include/lib/fdio/private.h",
+ "pkg/fdio/include/lib/fdio/spawn.h",
+ "pkg/fdio/include/lib/fdio/unsafe.h",
+ "pkg/fdio/include/lib/fdio/vfs.h",
"pkg/fdio/include/lib/fdio/watcher.h"
- ],
- "include_dir": "pkg/fdio/include",
- "name": "fdio",
- "root": "pkg/fdio",
+ ],
+ "include_dir": "pkg/fdio/include",
+ "name": "fdio",
+ "root": "pkg/fdio",
"type": "cc_prebuilt_library"
}
\ No newline at end of file
diff --git a/pkg/fidl-async/bind.c b/pkg/fidl-async/bind.c
deleted file mode 100644
index fad7132..0000000
--- a/pkg/fidl-async/bind.c
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/async/wait.h>
-#include <lib/fidl-async/bind.h>
-#include <stdlib.h>
-#include <string.h>
-#include <zircon/syscalls.h>
-
-typedef struct fidl_binding {
- async_wait_t wait;
- fidl_dispatch_t* dispatch;
- async_dispatcher_t* dispatcher;
- void* ctx;
- const void* ops;
-} fidl_binding_t;
-
-typedef struct fidl_connection {
- fidl_txn_t txn;
- zx_handle_t channel;
- zx_txid_t txid;
- fidl_binding_t* binding;
-} fidl_connection_t;
-
-static zx_status_t fidl_reply(fidl_txn_t* txn, const fidl_msg_t* msg) {
- fidl_connection_t* conn = (fidl_connection_t*)txn;
- if (conn->txid == 0u)
- return ZX_ERR_BAD_STATE;
- if (msg->num_bytes < sizeof(fidl_message_header_t))
- return ZX_ERR_INVALID_ARGS;
- fidl_message_header_t* hdr = (fidl_message_header_t*)msg->bytes;
- hdr->txid = conn->txid;
- conn->txid = 0u;
- return zx_channel_write(conn->channel, 0, msg->bytes, msg->num_bytes,
- msg->handles, msg->num_handles);
-}
-
-static void fidl_binding_destroy(fidl_binding_t* binding) {
- zx_handle_close(binding->wait.object);
- free(binding);
-}
-
-static void fidl_message_handler(async_dispatcher_t* dispatcher,
- async_wait_t* wait,
- zx_status_t status,
- const zx_packet_signal_t* signal) {
- fidl_binding_t* binding = (fidl_binding_t*)wait;
- if (status != ZX_OK) {
- goto shutdown;
- }
-
- if (signal->observed & ZX_CHANNEL_READABLE) {
- char bytes[ZX_CHANNEL_MAX_MSG_BYTES];
- zx_handle_t handles[ZX_CHANNEL_MAX_MSG_HANDLES];
- for (uint64_t i = 0; i < signal->count; i++) {
- fidl_msg_t msg = {
- .bytes = bytes,
- .handles = handles,
- .num_bytes = 0u,
- .num_handles = 0u,
- };
- status = zx_channel_read(wait->object, 0, bytes, handles,
- ZX_CHANNEL_MAX_MSG_BYTES,
- ZX_CHANNEL_MAX_MSG_HANDLES,
- &msg.num_bytes, &msg.num_handles);
- if (status == ZX_ERR_SHOULD_WAIT) {
- break;
- }
- if (status != ZX_OK || msg.num_bytes < sizeof(fidl_message_header_t)) {
- goto shutdown;
- }
- fidl_message_header_t* hdr = (fidl_message_header_t*)msg.bytes;
- fidl_connection_t conn = {
- .txn.reply = fidl_reply,
- .channel = wait->object,
- .txid = hdr->txid,
- .binding = binding,
- };
- status = binding->dispatch(binding->ctx, &conn.txn, &msg, binding->ops);
- switch (status) {
- case ZX_OK:
- status = async_begin_wait(dispatcher, wait);
- if (status != ZX_OK) {
- goto shutdown;
- }
- return;
- case ZX_ERR_ASYNC:
- return;
- default:
- goto shutdown;
- }
- }
- }
-
-shutdown:
- fidl_binding_destroy(binding);
-}
-
-zx_status_t fidl_bind(async_dispatcher_t* dispatcher, zx_handle_t channel,
- fidl_dispatch_t* dispatch, void* ctx, const void* ops) {
- fidl_binding_t* binding = calloc(1, sizeof(fidl_binding_t));
- binding->wait.handler = fidl_message_handler;
- binding->wait.object = channel;
- binding->wait.trigger = ZX_CHANNEL_READABLE | ZX_CHANNEL_PEER_CLOSED;
- binding->dispatch = dispatch;
- binding->dispatcher = dispatcher;
- binding->ctx = ctx;
- binding->ops = ops;
- zx_status_t status = async_begin_wait(dispatcher, &binding->wait);
- if (status != ZX_OK) {
- fidl_binding_destroy(binding);
- }
- return status;
-}
-
-typedef struct fidl_async_txn {
- fidl_connection_t connection;
-} fidl_async_txn_t;
-
-fidl_async_txn_t* fidl_async_txn_create(fidl_txn_t* txn) {
- fidl_connection_t* connection = (fidl_connection_t*) txn;
-
- fidl_async_txn_t* async_txn = calloc(1, sizeof(fidl_async_txn_t));
- memcpy(&async_txn->connection, connection, sizeof(*connection));
-
- return async_txn;
-}
-
-fidl_txn_t* fidl_async_txn_borrow(fidl_async_txn_t* async_txn) {
- return &async_txn->connection.txn;
-}
-
-zx_status_t fidl_async_txn_complete(fidl_async_txn_t* async_txn, bool rebind) {
- zx_status_t status = ZX_OK;
- if (rebind) {
- status = async_begin_wait(async_txn->connection.binding->dispatcher,
- &async_txn->connection.binding->wait);
- if (status == ZX_OK) {
- return ZX_OK;
- }
- }
-
- fidl_binding_destroy(async_txn->connection.binding);
- free(async_txn);
- return status;
-}
diff --git a/pkg/fidl-async/include/lib/fidl-async/bind.h b/pkg/fidl-async/include/lib/fidl-async/bind.h
deleted file mode 100644
index 5fc6f8b..0000000
--- a/pkg/fidl-async/include/lib/fidl-async/bind.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_BIND_H_
-#define LIB_FIDL_BIND_H_
-
-#include <lib/async/dispatcher.h>
-#include <zircon/fidl.h>
-
-__BEGIN_CDECLS
-
-// A generic FIDL dispatch function.
-//
-// For FIDL interfaces with [Layout="Simple"], the C backend generates a
-// dispatch function that decodes the |msg| and calls through an |ops| table.
-//
-// This function signature matches the structure of these generated functions
-// but with the type of the |ops| table erased.
-//
-// Example:
-//
-// fidl_bind(dispacher, channel, (fidl_dispatch_t*)spaceship_SpaceShip_dispatch, ctx, &kOps);
-//
-typedef zx_status_t(fidl_dispatch_t)(void* ctx, fidl_txn_t* txn,
- fidl_msg_t* msg, const void* ops);
-
-// Binds a |dispatch| function to channel| using |dispatcher|.
-//
-// This function adds an |async_wait_t| to the given |dispatcher| that waits
-// asynchronously for new messages to arrive on |channel|. When a message
-// arrives, the |dispatch| function is called on one of the threads associated
-// with the |dispatcher| with the |fidl_msg_t| as well as the given |ctx| and
-// |ops|.
-//
-// Typically, the |dispatch| function is generated by the C backend for FIDL
-// interfaces with with [Layout="Simple"] (see |fidl_dispatch_t|). These
-// dispatch functions decode the |fidl_msg_t| and call through the |ops| table
-// implementations of the interface's methods, passing along the |ctx| and a
-// |fidl_txn_t| (if the method has a reply message).
-//
-// The |fidl_txn_t| passed to |dispatch| is valid only until |dispatch| returns.
-// If the method has a reply message, the |reply| function on the |fidl_txn_t|
-// object must be called synchronously within the |dispatch| call.
-//
-// If a client wishes to reply to the message asynchronously, |fidl_async_txn_create|
-// must be invoked on |fidl_txn_t|, and ZX_ERR_ASYNC must be returned.
-//
-// Returns whether |fidl_bind| was able to begin waiting on the given |channel|.
-// Upon any error, |channel| is closed and the binding is terminated. Shutting down
-// the |dispatcher| also results in |channel| being closed.
-//
-// It is safe to shutdown the dispatcher at any time.
-//
-// It is unsafe to destroy the dispatcher from within a dispatch function.
-// It is unsafe to destroy the dispatcher while any |fidl_async_txn_t| objects
-// are alive.
-zx_status_t fidl_bind(async_dispatcher_t* dispatcher, zx_handle_t channel,
- fidl_dispatch_t* dispatch, void* ctx, const void* ops);
-
-// An asynchronous FIDL txn.
-//
-// This is an opaque wrapper around |fidl_txn_t| which can extend the lifetime
-// of the object beyond the dispatched function.
-typedef struct fidl_async_txn fidl_async_txn_t;
-
-// Takes ownership of |txn| and allows usage of the txn beyond the currently
-// dispatched function.
-//
-// If this function is invoked within a dispatched function, that function
-// must return ZX_ERR_ASYNC.
-//
-// The result must be destroyed with a call to |fidl_async_txn_complete|.
-fidl_async_txn_t* fidl_async_txn_create(fidl_txn_t* txn);
-
-// Acquire a reference to the |fidl_txn_t| backing this txn object.
-//
-// It is unsafe to use this |fidl_txn_t| after |async_txn| is completed.
-fidl_txn_t* fidl_async_txn_borrow(fidl_async_txn_t* async_txn);
-
-// Destroys an asynchronous transaction created with |fidl_async_txn_create|.
-//
-// If requested, rebinds the underlying txn against the binding.
-// Returns an error if |rebind| is true and the transaction could not be
-// re-bound.
-//
-// In all cases, the |async_txn| object is consumed.
-zx_status_t fidl_async_txn_complete(fidl_async_txn_t* async_txn, bool rebind);
-
-__END_CDECLS
-
-#endif // LIB_FIDL_BIND_H_
diff --git a/pkg/fidl-async/meta.json b/pkg/fidl-async/meta.json
deleted file mode 100644
index f5dfdbb..0000000
--- a/pkg/fidl-async/meta.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "banjo_deps": [],
- "deps": [
- "async",
- "fidl"
- ],
- "fidl_deps": [],
- "files": [
- "pkg/fidl-async/bind.c",
- "pkg/fidl-async/include/lib/fidl-async/bind.h"
- ],
- "headers": [
- "pkg/fidl-async/include/lib/fidl-async/bind.h"
- ],
- "include_dir": "pkg/fidl-async/include",
- "name": "fidl-async",
- "root": "pkg/fidl-async",
- "sources": [
- "pkg/fidl-async/bind.c"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/fidl/buffer_walker.h b/pkg/fidl/buffer_walker.h
deleted file mode 100644
index 92cb2e1..0000000
--- a/pkg/fidl/buffer_walker.h
+++ /dev/null
@@ -1,809 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-namespace fidl {
-namespace internal {
-
-// Some assumptions about data type layout.
-static_assert(offsetof(fidl_string_t, size) == 0u, "");
-static_assert(offsetof(fidl_string_t, data) == 8u, "");
-
-static_assert(offsetof(fidl_vector_t, count) == 0u, "");
-static_assert(offsetof(fidl_vector_t, data) == 8u, "");
-
-static_assert(ZX_HANDLE_INVALID == FIDL_HANDLE_ABSENT, "");
-
-template <bool kConst, class U>
-struct SetPtrConst;
-
-template <class U>
-struct SetPtrConst<false, U> {
- typedef U* type;
-};
-
-template <class U>
-struct SetPtrConst<true, U> {
- typedef const U* type;
-};
-
-// Walks over a FIDL buffer and validates/encodes/decodes it per-Derived.
-//
-// kMutating controls whether this deals with mutable bytes or immutable bytes
-// (validation wants immutable, encode/decode wants mutable)
-//
-// kContinueAfterErrors controls whether parsing is continued upon failure (encode needs this to
-// see all available handles).
-//
-// Derived should offer the following methods:
-//
-// const? uint8_t* bytes() - returns the start of the buffer of bytes
-// uint32_t num_bytes() - returns the number of bytes in said buffer
-// uint32_t num_handles() - returns the number of handles that are claimable
-// bool ValidateOutOfLineStorageClaim(const void* a, const void* b)
-// - returns true if a legally points to b
-// void UnclaimedHandle(zx_handle_t*) - notes that a handle was skipped
-// void ClaimedHandle(zx_handle_t*, uint32_t idx) - notes that a handle was claimed
-// PointerState GetPointerState(const void* ptr) - returns whether a pointer is present or not
-// HandleState GetHandleState(zx_handle_t) - returns if a handle is present or not
-// void UpdatePointer(T**p, T*v) - mutates a pointer representation for a present pointer
-// void SetError(const char* error_msg) - flags that an error occurred
-template <class Derived, bool kMutating, bool kContinueAfterErrors>
-class BufferWalker {
-public:
- explicit BufferWalker(const fidl_type* type)
- : type_(type) {}
-
- void Walk() {
- // The first decode is special. It must be a struct or a table.
- // We need to know the size of the first element to compute the start of
- // the out-of-line allocations.
-
- if (type_ == nullptr) {
- SetError("Cannot decode a null fidl type");
- return;
- }
-
- if (bytes() == nullptr) {
- SetError("Cannot decode null bytes");
- return;
- }
-
- switch (type_->type_tag) {
- case fidl::kFidlTypeStruct:
- if (num_bytes() < type_->coded_struct.size) {
- SetError("Message size is smaller than expected");
- return;
- }
- out_of_line_offset_ = static_cast<uint32_t>(fidl::FidlAlign(type_->coded_struct.size));
- break;
- case fidl::kFidlTypeTable:
- if (num_bytes() < sizeof(fidl_vector_t)) {
- SetError("Message size is smaller than expected");
- return;
- }
- out_of_line_offset_ = static_cast<uint32_t>(fidl::FidlAlign(sizeof(fidl_vector_t)));
- break;
- default:
- SetError("Message must be a struct or a table");
- return;
- }
-
- Push(Frame::DoneSentinel());
- Push(Frame(type_, 0u));
-
-// Macro to insert the relevant goop required to support two control flows here:
-// one where we keep reading after error, and another where we return immediately.
-// No runtime overhead thanks to if constexpr magic.
-#define FIDL_POP_AND_CONTINUE_OR_RETURN \
- if (kContinueAfterErrors) { \
- Pop(); \
- continue; \
- } else { \
- return; \
- }
-
- for (;;) {
- Frame* frame = Peek();
-
- switch (frame->state) {
- case Frame::kStateStruct: {
- const uint32_t field_index = frame->NextStructField();
- if (field_index == frame->struct_state.field_count) {
- Pop();
- continue;
- }
- const fidl::FidlField& field = frame->struct_state.fields[field_index];
- const fidl_type_t* field_type = field.type;
- const uint32_t field_offset = frame->offset + field.offset;
- if (!Push(Frame(field_type, field_offset))) {
- SetError("recursion depth exceeded processing struct");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- continue;
- }
- case Frame::kStateStructPointer: {
- switch (GetPointerState(TypedAt<void>(frame->offset))) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- Pop();
- continue;
- default:
- SetError("Tried to decode a bad struct pointer");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- auto struct_ptr_ptr = TypedAt<void*>(frame->offset);
- if (!ClaimOutOfLineStorage(frame->struct_pointer_state.struct_type->size,
- *struct_ptr_ptr, &frame->offset)) {
- SetError("message wanted to store too large of a nullable struct");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(struct_ptr_ptr, TypedAt<void>(frame->offset));
- const fidl::FidlCodedStruct* coded_struct = frame->struct_pointer_state.struct_type;
- *frame = Frame(coded_struct, frame->offset);
- continue;
- }
- case Frame::kStateTable: {
- if (frame->field == 0u) {
- auto envelope_vector_ptr = TypedAt<fidl_vector_t>(frame->offset);
- switch (GetPointerState(&envelope_vector_ptr->data)) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- SetError("Table data cannot be absent");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- default:
- SetError("message tried to decode a non-present vector");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- uint32_t size;
- if (mul_overflow(envelope_vector_ptr->count, 2 * sizeof(uint64_t), &size)) {
- SetError("integer overflow calculating table size");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (!ClaimOutOfLineStorage(size, envelope_vector_ptr->data, &frame->offset)) {
- SetError("message wanted to store too large of a table");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(&envelope_vector_ptr->data, TypedAt<void>(frame->offset));
- frame->field = 1;
- frame->table_state.known_index = 0;
- frame->table_state.present_count = static_cast<uint32_t>(envelope_vector_ptr->count);
- frame->table_state.end_offset = out_of_line_offset_;
- frame->table_state.end_handle = handle_idx_;
- continue;
- }
- if (frame->table_state.end_offset != out_of_line_offset_) {
- SetError("Table field was mis-sized");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (frame->table_state.end_handle != handle_idx_) {
- SetError("Table handles were mis-sized");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (frame->field > frame->table_state.present_count) {
- Pop();
- continue;
- }
- const fidl::FidlTableField* known_field = nullptr;
- if (frame->table_state.known_index < frame->table_state.field_count) {
- const fidl::FidlTableField* field =
- &frame->table_state.fields[frame->table_state.known_index];
- if (field->ordinal == frame->field) {
- known_field = field;
- frame->table_state.known_index++;
- }
- }
- const uint32_t tag_offset = static_cast<uint32_t>(
- frame->offset + (frame->field - 1) * 2 * sizeof(uint64_t));
- const uint32_t data_offset = static_cast<uint32_t>(
- tag_offset + sizeof(uint64_t));
- const uint64_t packed_sizes = *TypedAt<uint64_t>(tag_offset);
- frame->field++;
- switch (GetPointerState(TypedAt<void>(data_offset))) {
- case PointerState::PRESENT:
- if (packed_sizes != 0)
- break; // expected
-
- SetError("Table envelope has present data pointer, but no data, and no handles");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- case PointerState::ABSENT:
- if (packed_sizes == 0)
- continue; // skip
-
- SetError("Table envelope has absent data pointer, yet has data and/or handles");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- default:
- SetError("Table envelope has bad data pointer");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- uint32_t offset;
- uint32_t handles;
- const uint32_t table_bytes = static_cast<uint32_t>(packed_sizes & 0xffffffffu);
- const uint32_t table_handles = static_cast<uint32_t>(packed_sizes >> 32);
- if (add_overflow(out_of_line_offset_, table_bytes, &offset) || offset > num_bytes()) {
- SetError("integer overflow decoding table field");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (add_overflow(handle_idx_, table_handles, &handles) ||
- handles > num_handles()) {
- SetError("integer overflow decoding table handles");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- frame->table_state.end_offset = offset;
- frame->table_state.end_handle = handles;
- if (known_field != nullptr) {
- const fidl_type_t* field_type = known_field->type;
- uint32_t field_offset;
- if (!ClaimOutOfLineStorage(TypeSize(field_type), TypedAt<void*>(data_offset), &field_offset)) {
- SetError("table wanted too many bytes in field");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(TypedAt<void*>(data_offset), TypedAt<void>(field_offset));
- if (!Push(Frame(field_type, field_offset))) {
- SetError("recursion depth exceeded decoding table");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- } else {
- // Table data will not be processed: discard it.
- uint32_t field_offset;
- if (!ClaimOutOfLineStorage(table_bytes, TypedAt<void*>(data_offset), &field_offset)) {
- SetError("table wanted too many bytes in field");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(TypedAt<void*>(data_offset), TypedAt<void>(field_offset));
- for (uint32_t i = 0; i < table_handles; i++) {
- if (!ClaimHandle(nullptr)) {
- SetError("expected handle not present");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- }
- }
- continue;
- }
- case Frame::kStateTablePointer: {
- switch (GetPointerState(TypedAt<void>(frame->offset))) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- Pop();
- continue;
- default:
- SetError("Tried to decode a bad table pointer");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- auto table_ptr_ptr = TypedAt<void*>(frame->offset);
- if (!ClaimOutOfLineStorage(sizeof(fidl_vector_t), *table_ptr_ptr, &frame->offset)) {
- SetError("message wanted to store too large of a nullable table");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(table_ptr_ptr, TypedAt<void>(frame->offset));
- const fidl::FidlCodedTable* coded_table = frame->table_pointer_state.table_type;
- *frame = Frame(coded_table, frame->offset);
- continue;
- }
- case Frame::kStateUnion: {
- fidl_union_tag_t union_tag = *TypedAt<fidl_union_tag_t>(frame->offset);
- if (union_tag >= frame->union_state.type_count) {
- SetError("Tried to decode a bad union discriminant");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- const fidl_type_t* member = frame->union_state.types[union_tag];
- if (!member) {
- Pop();
- continue;
- }
- frame->offset += frame->union_state.data_offset;
- *frame = Frame(member, frame->offset);
- continue;
- }
- case Frame::kStateUnionPointer: {
- auto union_ptr_ptr = TypedAt<fidl_union_tag_t*>(frame->offset);
- switch (GetPointerState(TypedAt<void>(frame->offset))) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- Pop();
- continue;
- default:
- SetError("Tried to decode a bad union pointer");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (!ClaimOutOfLineStorage(frame->union_pointer_state.union_type->size, *union_ptr_ptr,
- &frame->offset)) {
- SetError("message wanted to store too large of a nullable union");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(union_ptr_ptr, TypedAt<fidl_union_tag_t>(frame->offset));
- const fidl::FidlCodedUnion* coded_union = frame->union_pointer_state.union_type;
- *frame = Frame(coded_union, frame->offset);
- continue;
- }
- case Frame::kStateArray: {
- const uint32_t element_offset = frame->NextArrayOffset();
- if (element_offset == frame->array_state.array_size) {
- Pop();
- continue;
- }
- const fidl_type_t* element_type = frame->array_state.element;
- const uint32_t offset = frame->offset + element_offset;
- if (!Push(Frame(element_type, offset))) {
- SetError("recursion depth exceeded decoding array");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- continue;
- }
- case Frame::kStateString: {
- auto string_ptr = TypedAt<fidl_string_t>(frame->offset);
- // The string storage may be Absent for nullable strings and must
- // otherwise be Present. No other values are allowed.
- switch (GetPointerState(&string_ptr->data)) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- if (!frame->string_state.nullable) {
- SetError("message tried to decode an absent non-nullable string");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (string_ptr->size != 0u) {
- SetError("message tried to decode an absent string of non-zero length");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- Pop();
- continue;
- default:
- SetError(
- "message tried to decode a string that is neither present nor absent");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- uint64_t bound = frame->string_state.max_size;
- uint64_t size = string_ptr->size;
- if (size > bound) {
- SetError("message tried to decode too large of a bounded string");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- uint32_t string_data_offset = 0u;
- if (!ClaimOutOfLineStorage(static_cast<uint32_t>(size), string_ptr->data, &string_data_offset)) {
- SetError("decoding a string overflowed buffer");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(&string_ptr->data, TypedAt<char>(string_data_offset));
- Pop();
- continue;
- }
- case Frame::kStateHandle: {
- auto handle_ptr = TypedAt<zx_handle_t>(frame->offset);
- // The handle storage may be Absent for nullable handles and must
- // otherwise be Present. No other values are allowed.
- switch (GetHandleState(*handle_ptr)) {
- case HandleState::ABSENT:
- if (frame->handle_state.nullable) {
- Pop();
- continue;
- }
- SetError("message tried to decode a non-present handle");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- case HandleState::PRESENT:
- if (!ClaimHandle(handle_ptr)) {
- SetError("message decoded too many handles");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- Pop();
- continue;
- default:
- // The value at the handle was garbage.
- SetError("message tried to decode a garbage handle");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- }
- case Frame::kStateVector: {
- auto vector_ptr = TypedAt<fidl_vector_t>(frame->offset);
- // The vector storage may be Absent for nullable vectors and must
- // otherwise be Present. No other values are allowed.
- switch (GetPointerState(&vector_ptr->data)) {
- case PointerState::PRESENT:
- break;
- case PointerState::ABSENT:
- if (!frame->vector_state.nullable) {
- SetError("message tried to decode an absent non-nullable vector");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (vector_ptr->count != 0u) {
- SetError("message tried to decode an absent vector of non-zero elements");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- Pop();
- continue;
- default:
- SetError("message tried to decode a non-present vector");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (vector_ptr->count > frame->vector_state.max_count) {
- SetError("message tried to decode too large of a bounded vector");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- uint32_t size;
- if (mul_overflow(vector_ptr->count, frame->vector_state.element_size, &size)) {
- SetError("integer overflow calculating vector size");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- if (!ClaimOutOfLineStorage(size, vector_ptr->data, &frame->offset)) {
- SetError("message wanted to store too large of a vector");
- FIDL_POP_AND_CONTINUE_OR_RETURN;
- }
- UpdatePointer(&vector_ptr->data, TypedAt<void>(frame->offset));
- if (frame->vector_state.element) {
- // Continue by decoding the vector elements as an array.
- *frame = Frame(frame->vector_state.element, size,
- frame->vector_state.element_size, frame->offset);
- } else {
- // If there is no element type pointer, there is
- // nothing to decode in the vector secondary
- // payload. So just continue.
- Pop();
- }
- continue;
- }
- case Frame::kStateDone: {
- if (out_of_line_offset_ != num_bytes()) {
- SetError("message did not decode all provided bytes");
- }
- return;
- }
- }
- }
-
-#undef FIDL_POP_AND_CONTINUE_OR_RETURN
- }
-
-protected:
- void SetError(const char* error_msg) {
- derived()->SetError(error_msg);
- }
-
- template <typename T>
- typename SetPtrConst<!kMutating, T>::type TypedAt(uint32_t offset) const {
- return reinterpret_cast<typename SetPtrConst<!kMutating, T>::type>(bytes() + offset);
- }
-
- enum class PointerState : uintptr_t {
- PRESENT = FIDL_ALLOC_PRESENT,
- ABSENT = FIDL_ALLOC_ABSENT,
- INVALID = 1 // *OR* *ANY* non PRESENT/ABSENT value.
- };
-
- enum class HandleState : zx_handle_t {
- PRESENT = FIDL_HANDLE_PRESENT,
- ABSENT = FIDL_HANDLE_ABSENT,
- INVALID = 1 // *OR* *ANY* non PRESENT/ABSENT value.
- };
-
- uint32_t handle_idx() const { return handle_idx_; }
-
-private:
- Derived* derived() {
- return static_cast<Derived*>(this);
- }
-
- const Derived* derived() const {
- return static_cast<const Derived*>(this);
- }
-
- // Returns a pointer to the bytes in the message.
- auto bytes() const {
- return derived()->bytes();
- }
-
- // Returns the number of bytes in the message.
- auto num_bytes() const {
- return derived()->num_bytes();
- }
-
- // Returns the number of handles in the message (encoding: the max number of handles in the message).
- auto num_handles() const {
- return derived()->num_handles();
- }
-
- // Returns PRESENT/ABSENT/INVALID for a given pointer value.
- PointerState GetPointerState(const void* ptr) const {
- return derived()->GetPointerState(ptr);
- }
-
- // Returns PRESENT/ABSENT/INVALID for a given handle value.
- HandleState GetHandleState(zx_handle_t p) const {
- return derived()->GetHandleState(p);
- }
-
- // If required: mutate a pointer to the dual representation.
- template <class T2, class T1>
- void UpdatePointer(T2 p, T1 v) {
- derived()->UpdatePointer(p, v);
- }
-
- // Returns true when a handle was claimed, and false when the
- // handles are exhausted.
- template <class ZxHandleTPointer>
- bool ClaimHandle(ZxHandleTPointer out_handle) {
- if (handle_idx_ == num_handles()) {
- derived()->UnclaimedHandle(out_handle);
- return false;
- }
- derived()->ClaimedHandle(out_handle, handle_idx_);
- ++handle_idx_;
- return true;
- }
-
- // Returns true when the buffer space is claimed, and false when
- // the requested claim is too large for bytes_.
- bool ClaimOutOfLineStorage(uint32_t size, const void* storage, uint32_t* out_offset) {
- if (!derived()->ValidateOutOfLineStorageClaim(storage, &bytes()[out_of_line_offset_])) {
- return false;
- }
-
- // We have to manually maintain alignment here. For example, a pointer
- // to a struct that is 4 bytes still needs to advance the next
- // out-of-line offset by 8 to maintain the aligned-to-FIDL_ALIGNMENT
- // property.
- static constexpr uint32_t mask = FIDL_ALIGNMENT - 1;
- uint32_t offset = out_of_line_offset_;
- if (add_overflow(offset, size, &offset) ||
- add_overflow(offset, mask, &offset)) {
- return false;
- }
- offset &= ~mask;
-
- if (offset > num_bytes()) {
- return false;
- }
- *out_offset = out_of_line_offset_;
- out_of_line_offset_ = offset;
- return true;
- }
-
- uint32_t TypeSize(const fidl_type_t* type) {
- switch (type->type_tag) {
- case fidl::kFidlTypeStructPointer:
- case fidl::kFidlTypeTablePointer:
- case fidl::kFidlTypeUnionPointer:
- return sizeof(uint64_t);
- case fidl::kFidlTypeHandle:
- return sizeof(zx_handle_t);
- case fidl::kFidlTypeStruct:
- return type->coded_struct.size;
- case fidl::kFidlTypeTable:
- return sizeof(fidl_vector_t);
- case fidl::kFidlTypeUnion:
- return type->coded_union.size;
- case fidl::kFidlTypeString:
- return sizeof(fidl_string_t);
- case fidl::kFidlTypeArray:
- return type->coded_array.array_size;
- case fidl::kFidlTypeVector:
- return sizeof(fidl_vector_t);
- }
- abort();
- return 0;
- }
-
- // Functions that manipulate the decoding stack frames.
- struct Frame {
- Frame(const fidl_type_t* fidl_type, uint32_t offset)
- : offset(offset) {
- switch (fidl_type->type_tag) {
- case fidl::kFidlTypeStruct:
- state = kStateStruct;
- struct_state.fields = fidl_type->coded_struct.fields;
- struct_state.field_count = fidl_type->coded_struct.field_count;
- break;
- case fidl::kFidlTypeStructPointer:
- state = kStateStructPointer;
- struct_pointer_state.struct_type = fidl_type->coded_struct_pointer.struct_type;
- break;
- case fidl::kFidlTypeTable:
- state = kStateTable;
- table_state.fields = fidl_type->coded_table.fields;
- table_state.field_count = fidl_type->coded_table.field_count;
- table_state.present_count = 0;
- break;
- case fidl::kFidlTypeTablePointer:
- state = kStateTablePointer;
- table_pointer_state.table_type = fidl_type->coded_table_pointer.table_type;
- break;
- case fidl::kFidlTypeUnion:
- state = kStateUnion;
- union_state.types = fidl_type->coded_union.types;
- union_state.type_count = fidl_type->coded_union.type_count;
- union_state.data_offset = fidl_type->coded_union.data_offset;
- break;
- case fidl::kFidlTypeUnionPointer:
- state = kStateUnionPointer;
- union_pointer_state.union_type = fidl_type->coded_union_pointer.union_type;
- break;
- case fidl::kFidlTypeArray:
- state = kStateArray;
- array_state.element = fidl_type->coded_array.element;
- array_state.array_size = fidl_type->coded_array.array_size;
- array_state.element_size = fidl_type->coded_array.element_size;
- break;
- case fidl::kFidlTypeString:
- state = kStateString;
- string_state.max_size = fidl_type->coded_string.max_size;
- string_state.nullable = fidl_type->coded_string.nullable;
- break;
- case fidl::kFidlTypeHandle:
- state = kStateHandle;
- handle_state.nullable = fidl_type->coded_handle.nullable;
- break;
- case fidl::kFidlTypeVector:
- state = kStateVector;
- vector_state.element = fidl_type->coded_vector.element;
- vector_state.max_count = fidl_type->coded_vector.max_count;
- vector_state.element_size = fidl_type->coded_vector.element_size;
- vector_state.nullable = fidl_type->coded_vector.nullable;
- break;
- }
- }
-
- Frame(const fidl::FidlCodedStruct* coded_struct, uint32_t offset)
- : offset(offset) {
- state = kStateStruct;
- struct_state.fields = coded_struct->fields;
- struct_state.field_count = coded_struct->field_count;
- }
-
- Frame(const fidl::FidlCodedTable* coded_table, uint32_t offset)
- : offset(offset) {
- state = kStateStruct;
- table_state.fields = coded_table->fields;
- table_state.field_count = coded_table->field_count;
- }
-
- Frame(const fidl::FidlCodedUnion* coded_union, uint32_t offset)
- : offset(offset) {
- state = kStateUnion;
- union_state.types = coded_union->types;
- union_state.type_count = coded_union->type_count;
- union_state.data_offset = coded_union->data_offset;
- }
-
- Frame(const fidl_type_t* element, uint32_t array_size, uint32_t element_size,
- uint32_t offset)
- : offset(offset) {
- state = kStateArray;
- array_state.element = element;
- array_state.array_size = array_size;
- array_state.element_size = element_size;
- }
-
- // The default constructor does nothing when initializing the stack of frames.
- Frame() {}
-
- static Frame DoneSentinel() {
- Frame frame;
- frame.state = kStateDone;
- return frame;
- }
-
- uint32_t NextStructField() {
- ZX_DEBUG_ASSERT(state == kStateStruct);
-
- uint32_t current = field;
- field += 1;
- return current;
- }
-
- uint32_t NextArrayOffset() {
- ZX_DEBUG_ASSERT(state == kStateArray);
-
- uint32_t current = field;
- field += array_state.element_size;
- return current;
- }
-
- enum : int {
- kStateStruct,
- kStateStructPointer,
- kStateTable,
- kStateTablePointer,
- kStateUnion,
- kStateUnionPointer,
- kStateArray,
- kStateString,
- kStateHandle,
- kStateVector,
-
- kStateDone,
- } state;
- // A byte offset into bytes_;
- uint32_t offset;
-
- // This is a subset of the information recorded in the
- // fidl_type structures needed for decoding state. For
- // example, struct sizes do not need to be present here.
- union {
- struct {
- const fidl::FidlField* fields;
- uint32_t field_count;
- } struct_state;
- struct {
- const fidl::FidlCodedStruct* struct_type;
- } struct_pointer_state;
- struct {
- const fidl::FidlTableField* fields;
- uint32_t known_index;
- uint32_t field_count;
- uint32_t present_count;
- uint32_t end_offset;
- uint32_t end_handle;
- } table_state;
- struct {
- const fidl::FidlCodedTable* table_type;
- } table_pointer_state;
- struct {
- const fidl_type_t* const* types;
- uint32_t type_count;
- uint32_t data_offset;
- } union_state;
- struct {
- const fidl::FidlCodedUnion* union_type;
- } union_pointer_state;
- struct {
- const fidl_type_t* element;
- uint32_t array_size;
- uint32_t element_size;
- } array_state;
- struct {
- uint32_t max_size;
- bool nullable;
- } string_state;
- struct {
- bool nullable;
- } handle_state;
- struct {
- const fidl_type* element;
- uint32_t max_count;
- uint32_t element_size;
- bool nullable;
- } vector_state;
- };
-
- uint32_t field = 0u;
- };
-
- // Returns true on success and false on recursion overflow.
- bool Push(Frame frame) {
- if (depth_ == FIDL_RECURSION_DEPTH) {
- return false;
- }
- decoding_frames_[depth_] = frame;
- ++depth_;
- return true;
- }
-
- void Pop() {
- ZX_DEBUG_ASSERT(depth_ != 0u);
- --depth_;
- }
-
- Frame* Peek() {
- ZX_DEBUG_ASSERT(depth_ != 0u);
- return &decoding_frames_[depth_ - 1];
- }
-
- // Message state passed in to the constructor.
- const fidl_type_t* const type_;
-
- // Internal state.
- uint32_t handle_idx_ = 0u;
- uint32_t out_of_line_offset_ = 0u;
-
- // Decoding stack state.
- uint32_t depth_ = 0u;
- Frame decoding_frames_[FIDL_RECURSION_DEPTH];
-};
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl/builder.cpp b/pkg/fidl/builder.cpp
deleted file mode 100644
index 476b7ee..0000000
--- a/pkg/fidl/builder.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/cpp/builder.h>
-
-#include <string.h>
-
-#include <lib/fidl/internal.h>
-
-namespace fidl {
-
-Builder::Builder()
- : capacity_(0u), at_(0u), buffer_(nullptr) {}
-
-Builder::Builder(void* buffer, uint32_t capacity)
- : capacity_(capacity), at_(0u), buffer_(static_cast<uint8_t*>(buffer)) {
-}
-
-Builder::~Builder() = default;
-
-Builder::Builder(Builder&& other)
- : capacity_(other.capacity_),
- at_(other.at_),
- buffer_(other.buffer_) {
- other.Reset(nullptr, 0);
-}
-
-Builder& Builder::operator=(Builder&& other) {
- if (this != &other) {
- capacity_ = other.capacity_;
- at_ = other.at_;
- buffer_ = other.buffer_;
- other.Reset(nullptr, 0);
- }
- return *this;
-}
-
-void* Builder::Allocate(uint32_t size) {
- uint64_t limit = FidlAlign(at_ + size);
- if (limit > capacity_)
- return nullptr;
- uint8_t* result = &buffer_[at_];
- memset(buffer_ + at_, 0, limit - at_);
- at_ = static_cast<uint32_t>(limit);
- return result;
-}
-
-BytePart Builder::Finalize() {
- BytePart bytes(buffer_, capacity_, at_);
- capacity_ = 0u;
- at_ = 0u;
- return bytes;
-}
-
-void Builder::Reset(void* buffer, uint32_t capacity) {
- buffer_ = static_cast<uint8_t*>(buffer);
- capacity_ = capacity;
- at_ = 0u;
-}
-
-} // namespace fidl
diff --git a/pkg/fidl/decoding.cpp b/pkg/fidl/decoding.cpp
deleted file mode 100644
index 3066778..0000000
--- a/pkg/fidl/decoding.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/coding.h>
-
-#include <stdalign.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <lib/fidl/internal.h>
-#include <zircon/assert.h>
-#include <zircon/compiler.h>
-
-#ifdef __Fuchsia__
-#include <zircon/syscalls.h>
-#endif
-
-#include "buffer_walker.h"
-
-// TODO(kulakowski) Design zx_status_t error values.
-
-namespace {
-
-class FidlDecoder final : public fidl::internal::BufferWalker<FidlDecoder, true, false> {
- typedef fidl::internal::BufferWalker<FidlDecoder, true, false> Super;
-
-public:
- FidlDecoder(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const zx_handle_t* handles, uint32_t num_handles, const char** out_error_msg)
- : Super(type), bytes_(static_cast<uint8_t*>(bytes)), num_bytes_(num_bytes),
- handles_(handles), num_handles_(num_handles), out_error_msg_(out_error_msg) {}
-
- void Walk() {
- if (handles_ == nullptr && num_handles_ != 0u) {
- SetError("Cannot provide non-zero handle count and null handle pointer");
- return;
- }
- Super::Walk();
- if (status_ == ZX_OK && handle_idx() != num_handles()) {
- SetError("message did not contain the specified number of handles");
- }
- }
-
- uint8_t* bytes() const { return bytes_; }
- uint32_t num_bytes() const { return num_bytes_; }
- uint32_t num_handles() const { return num_handles_; }
-
- bool ValidateOutOfLineStorageClaim(const void* a, const void* b) {
- return true;
- }
-
- void UnclaimedHandle(zx_handle_t* out_handle) {}
- void ClaimedHandle(zx_handle_t* out_handle, uint32_t idx) {
- if (out_handle != nullptr) {
- *out_handle = handles_[idx];
-#ifdef __Fuchsia__
- } else {
- // Return value intentionally ignored: this is best-effort cleanup.
- zx_handle_close(handles_[idx]);
-#endif
- }
- }
-
- PointerState GetPointerState(const void* ptr) const {
- return static_cast<PointerState>(*static_cast<const uintptr_t*>(ptr));
- }
- HandleState GetHandleState(zx_handle_t p) const {
- return static_cast<HandleState>(p);
- }
-
- template <class T>
- void UpdatePointer(T* p, T v) {
- *p = v;
- }
-
- void SetError(const char* error_msg) {
- status_ = ZX_ERR_INVALID_ARGS;
- if (out_error_msg_ != nullptr) {
- *out_error_msg_ = error_msg;
- }
-#ifdef __Fuchsia__
- if (handles_) {
- // Return value intentionally ignored: this is best-effort cleanup.
- zx_handle_close_many(handles_, num_handles());
- }
-#endif
- }
-
- zx_status_t status() const { return status_; }
-
-private:
- uint8_t* const bytes_;
- const uint32_t num_bytes_;
- const zx_handle_t* const handles_;
- const uint32_t num_handles_;
- const char** const out_error_msg_;
- zx_status_t status_ = ZX_OK;
-};
-
-} // namespace
-
-zx_status_t fidl_decode(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const zx_handle_t* handles, uint32_t num_handles,
- const char** out_error_msg) {
- FidlDecoder decoder(type, bytes, num_bytes, handles, num_handles, out_error_msg);
- decoder.Walk();
- return decoder.status();
-}
-
-zx_status_t fidl_decode_msg(const fidl_type_t* type, fidl_msg_t* msg,
- const char** out_error_msg) {
- return fidl_decode(type, msg->bytes, msg->num_bytes, msg->handles,
- msg->num_handles, out_error_msg);
-}
diff --git a/pkg/fidl/encoding.cpp b/pkg/fidl/encoding.cpp
deleted file mode 100644
index f4d4f49..0000000
--- a/pkg/fidl/encoding.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/coding.h>
-
-#include <stdalign.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <lib/fidl/internal.h>
-#include <zircon/assert.h>
-#include <zircon/compiler.h>
-
-#ifdef __Fuchsia__
-#include <zircon/syscalls.h>
-#endif
-
-#include "buffer_walker.h"
-
-#include <stdio.h>
-
-// TODO(kulakowski) Design zx_status_t error values.
-
-namespace {
-
-class FidlEncoder final : public fidl::internal::BufferWalker<FidlEncoder, true, true> {
- typedef fidl::internal::BufferWalker<FidlEncoder, true, true> Super;
-
-public:
- FidlEncoder(const fidl_type_t* type, void* bytes, uint32_t num_bytes, zx_handle_t* handles,
- uint32_t num_handles, uint32_t* out_actual_handles, const char** out_error_msg)
- : Super(type), bytes_(static_cast<uint8_t*>(bytes)), num_bytes_(num_bytes),
- handles_(handles), num_handles_(num_handles), out_actual_handles_(out_actual_handles),
- out_error_msg_(out_error_msg) {}
-
- void Walk() {
- if (handles_ == nullptr && num_handles_ != 0u) {
- SetError("Cannot provide non-zero handle count and null handle pointer");
- return;
- }
- if (out_actual_handles_ == nullptr) {
- SetError("Cannot encode with null out_actual_handles");
- return;
- }
- Super::Walk();
- if (status_ == ZX_OK) {
- *out_actual_handles_ = handle_idx();
- }
- }
-
- uint8_t* bytes() const { return bytes_; }
- uint32_t num_bytes() const { return num_bytes_; }
- uint32_t num_handles() const { return num_handles_; }
-
- bool ValidateOutOfLineStorageClaim(const void* a, const void* b) {
- return a == b;
- }
-
- void UnclaimedHandle(zx_handle_t* out_handle) {
-#ifdef __Fuchsia__
- // Return value intentionally ignored: this is best-effort cleanup.
- zx_handle_close(*out_handle);
-#endif
- }
- void ClaimedHandle(zx_handle_t* out_handle, uint32_t idx) {
- assert(out_handle != nullptr);
- handles_[idx] = *out_handle;
- *out_handle = FIDL_HANDLE_PRESENT;
- }
-
- PointerState GetPointerState(const void* ptr) const {
- return *static_cast<const uintptr_t*>(ptr) == 0
- ? PointerState::ABSENT
- : PointerState::PRESENT;
- }
- HandleState GetHandleState(zx_handle_t p) const {
- return p == ZX_HANDLE_INVALID
- ? HandleState::ABSENT
- : HandleState::PRESENT;
- }
-
- template <class T>
- void UpdatePointer(T** p, T* v) {
- assert(*p == v);
- assert(v != nullptr);
- *p = reinterpret_cast<T*>(FIDL_ALLOC_PRESENT);
- }
-
- void SetError(const char* error_msg) {
- if (status_ != ZX_OK) {
- return;
- }
- status_ = ZX_ERR_INVALID_ARGS;
- if (out_error_msg_ != nullptr) {
- *out_error_msg_ = error_msg;
- }
-#ifdef __Fuchsia__
- if (handles_) {
- // Return value intentionally ignored: this is best-effort cleanup.
- zx_handle_close_many(handles_, num_handles());
- }
-#endif
- }
-
- zx_status_t status() const { return status_; }
-
-private:
- // Message state passed in to the constructor.
- uint8_t* const bytes_;
- const uint32_t num_bytes_;
- zx_handle_t* const handles_;
- const uint32_t num_handles_;
- uint32_t* const out_actual_handles_;
- const char** const out_error_msg_;
- zx_status_t status_ = ZX_OK;
-};
-
-} // namespace
-
-zx_status_t fidl_encode(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- zx_handle_t* handles, uint32_t max_handles, uint32_t* out_actual_handles,
- const char** out_error_msg) {
- FidlEncoder encoder(type, bytes, num_bytes, handles, max_handles, out_actual_handles,
- out_error_msg);
- encoder.Walk();
- return encoder.status();
-}
-
-zx_status_t fidl_encode_msg(const fidl_type_t* type, fidl_msg_t* msg,
- uint32_t* out_actual_handles, const char** out_error_msg) {
- return fidl_encode(type, msg->bytes, msg->num_bytes, msg->handles, msg->num_handles,
- out_actual_handles, out_error_msg);
-}
diff --git a/pkg/fidl/epitaph.c b/pkg/fidl/epitaph.c
deleted file mode 100644
index d1a14e1..0000000
--- a/pkg/fidl/epitaph.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifdef __Fuchsia__
-
-#include <string.h>
-
-#include <lib/fidl/epitaph.h>
-#include <zircon/fidl.h>
-#include <zircon/syscalls.h>
-
-zx_status_t fidl_epitaph_write(zx_handle_t channel, zx_status_t error) {
- fidl_epitaph_t epitaph;
- memset(&epitaph, 0, sizeof(epitaph));
- epitaph.hdr.ordinal = FIDL_EPITAPH_ORDINAL;
- epitaph.hdr.reserved0 = error;
-
- return zx_channel_write(channel, 0, &epitaph, sizeof(epitaph), NULL, 0);
-}
-
-#endif // __Fuchsia__
diff --git a/pkg/fidl/formatting.cpp b/pkg/fidl/formatting.cpp
deleted file mode 100644
index ffe6f39..0000000
--- a/pkg/fidl/formatting.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/coding.h>
-
-#include <inttypes.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include <lib/fidl/internal.h>
-#include <zircon/assert.h>
-#include <zircon/compiler.h>
-
-namespace {
-
-class StringBuilder {
-public:
- StringBuilder(char* buffer, size_t capacity)
- : buffer_(buffer), capacity_(capacity) {}
-
- size_t length() const { return length_; }
-
- void Append(const char* data, size_t length) {
- size_t remaining = capacity_ - length_;
- if (length > remaining) {
- length = remaining;
- }
- memcpy(buffer_ + length_, data, length);
- length_ += length;
- }
-
- void Append(const char* data) {
- Append(data, strlen(data));
- }
-
- void AppendPrintf(const char* format, ...) __PRINTFLIKE(2, 3) {
- va_list ap;
- va_start(ap, format);
- AppendVPrintf(format, ap);
- va_end(ap);
- }
-
- void AppendVPrintf(const char* format, va_list ap) {
- size_t remaining = capacity_ - length_;
- if (remaining == 0u) {
- return;
- }
- int count = vsnprintf(buffer_ + length_, remaining, format, ap);
- if (count <= 0) {
- return;
- }
- size_t length = static_cast<size_t>(count);
- length_ += (length >= remaining ? remaining : length);
- }
-
-private:
- char* buffer_;
- size_t capacity_;
- size_t length_ = 0u;
-};
-
-void FormatNullability(StringBuilder* str, fidl::FidlNullability nullable) {
- if (nullable == fidl::kNullable) {
- str->Append("?");
- }
-}
-
-void FormatStructName(StringBuilder* str, const fidl::FidlCodedStruct* coded_struct) {
- if (coded_struct->name) {
- str->Append(coded_struct->name);
- } else {
- str->Append("struct");
- }
-}
-
-void FormatUnionName(StringBuilder* str, const fidl::FidlCodedUnion* coded_union) {
- if (coded_union->name) {
- str->Append(coded_union->name);
- } else {
- str->Append("union");
- }
-}
-
-void FormatTypeName(StringBuilder* str, const fidl_type_t* type);
-void FormatElementName(StringBuilder* str, const fidl_type_t* type) {
- if (type) {
- FormatTypeName(str, type);
- } else {
- // TODO(jeffbrown): Print the actual primitive type name, assuming we
- // start recording that information in the tables.
- str->Append("primitive");
- }
-}
-
-void FormatTypeName(StringBuilder* str, const fidl_type_t* type) {
- switch (type->type_tag) {
- case fidl::kFidlTypeStruct:
- FormatStructName(str, &type->coded_struct);
- break;
- case fidl::kFidlTypeStructPointer:
- FormatStructName(str, type->coded_struct_pointer.struct_type);
- str->Append("?");
- break;
- case fidl::kFidlTypeUnion:
- FormatUnionName(str, &type->coded_union);
- break;
- case fidl::kFidlTypeUnionPointer:
- FormatUnionName(str, type->coded_union_pointer.union_type);
- str->Append("?");
- break;
- case fidl::kFidlTypeArray:
- str->Append("array<");
- FormatElementName(str, type->coded_array.element);
- str->Append(">");
- str->AppendPrintf(":%" PRIu32, type->coded_array.array_size /
- type->coded_array.element_size);
- break;
- case fidl::kFidlTypeString:
- str->Append("string");
- if (type->coded_string.max_size != FIDL_MAX_SIZE) {
- str->AppendPrintf(":%" PRIu32, type->coded_string.max_size);
- }
- FormatNullability(str, type->coded_string.nullable);
- break;
- case fidl::kFidlTypeHandle:
- str->Append("handle");
- if (type->coded_handle.handle_subtype) {
- str->Append("<");
- switch (type->coded_handle.handle_subtype) {
- case fidl::kFidlHandleSubtypeHandle:
- str->Append("handle");
- break;
- case fidl::kFidlHandleSubtypeProcess:
- str->Append("process");
- break;
- case fidl::kFidlHandleSubtypeThread:
- str->Append("thread");
- break;
- case fidl::kFidlHandleSubtypeVmo:
- str->Append("vmo");
- break;
- case fidl::kFidlHandleSubtypeChannel:
- str->Append("channel");
- break;
- case fidl::kFidlHandleSubtypeEvent:
- str->Append("event");
- break;
- case fidl::kFidlHandleSubtypePort:
- str->Append("port");
- break;
- case fidl::kFidlHandleSubtypeInterrupt:
- str->Append("interrupt");
- break;
- case fidl::kFidlHandleSubtypeLog:
- str->Append("log");
- break;
- case fidl::kFidlHandleSubtypeSocket:
- str->Append("socket");
- break;
- case fidl::kFidlHandleSubtypeResource:
- str->Append("resource");
- break;
- case fidl::kFidlHandleSubtypeEventpair:
- str->Append("eventpair");
- break;
- case fidl::kFidlHandleSubtypeJob:
- str->Append("job");
- break;
- case fidl::kFidlHandleSubtypeVmar:
- str->Append("vmar");
- break;
- case fidl::kFidlHandleSubtypeFifo:
- str->Append("fifo");
- break;
- case fidl::kFidlHandleSubtypeGuest:
- str->Append("guest");
- break;
- case fidl::kFidlHandleSubtypeTimer:
- str->Append("timer");
- break;
- // TODO(pascallouis): Add support for iomap, pci, and hypervisor
- // when they are supported in FIDL.
- default:
- str->AppendPrintf("%" PRIu32, type->coded_handle.handle_subtype);
- break;
- }
- str->Append(">");
- }
- FormatNullability(str, type->coded_handle.nullable);
- break;
- case fidl::kFidlTypeVector:
- str->Append("vector<");
- FormatElementName(str, type->coded_vector.element);
- str->Append(">");
- if (type->coded_vector.max_count != FIDL_MAX_SIZE) {
- str->AppendPrintf(":%" PRIu32, type->coded_vector.max_count);
- }
- FormatNullability(str, type->coded_vector.nullable);
- break;
- default:
- ZX_PANIC("unrecognized tag");
- break;
- }
-}
-
-} // namespace
-
-size_t fidl_format_type_name(const fidl_type_t* type,
- char* buffer, size_t capacity) {
- if (!type || !buffer || !capacity) {
- return 0u;
- }
-
- StringBuilder str(buffer, capacity);
- FormatTypeName(&str, type);
- return str.length();
-}
diff --git a/pkg/fidl/handle_closing.cpp b/pkg/fidl/handle_closing.cpp
deleted file mode 100644
index 5350993..0000000
--- a/pkg/fidl/handle_closing.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-
-#include <limits>
-#include <stdalign.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <lib/fidl/coding.h>
-
-#ifdef __Fuchsia__
-
-#include <lib/fidl/internal.h>
-#include <zircon/assert.h>
-#include <zircon/compiler.h>
-#include <zircon/syscalls.h>
-
-#include "buffer_walker.h"
-
-namespace {
-
-class FidlHandleCloser final : public fidl::internal::BufferWalker<FidlHandleCloser, true, true> {
- typedef fidl::internal::BufferWalker<FidlHandleCloser, true, true> Super;
-
-public:
- FidlHandleCloser(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const char** out_error_msg)
- : Super(type), bytes_(static_cast<uint8_t*>(bytes)), num_bytes_(num_bytes),
- out_error_msg_(out_error_msg) {}
-
- void Walk() {
- Super::Walk();
- }
-
- uint8_t* bytes() const { return bytes_; }
- uint32_t num_bytes() const { return num_bytes_; }
- uint32_t num_handles() const { return std::numeric_limits<uint32_t>::max(); }
-
- bool ValidateOutOfLineStorageClaim(const void* a, void* b) {
- return true;
- }
-
- void UnclaimedHandle(zx_handle_t* out_handle) {
- // This will never happen since we are returning numeric_limits::max() in num_handles.
- // We want to claim (close) all the handles.
- ZX_DEBUG_ASSERT(false);
- }
-
- void ClaimedHandle(zx_handle_t* out_handle, uint32_t idx) {
- if (*out_handle != ZX_HANDLE_INVALID) {
- zx_handle_close(*out_handle);
- }
- *out_handle = ZX_HANDLE_INVALID;
- }
-
- template <class T>
- void UpdatePointer(T* const* p, T* v) {}
-
- PointerState GetPointerState(const void* ptr) const {
- return *static_cast<const uintptr_t*>(ptr) == 0
- ? PointerState::ABSENT
- : PointerState::PRESENT;
- }
-
- HandleState GetHandleState(zx_handle_t p) const {
- // Treat all handles as present to keep the buffer walker going.
- return HandleState::PRESENT;
- }
-
- void SetError(const char* error_msg) {
- status_ = ZX_ERR_INVALID_ARGS;
- if (out_error_msg_ != nullptr) {
- *out_error_msg_ = error_msg;
- }
- }
-
- zx_status_t status() const { return status_; }
-
-private:
- // Message state passed in to the constructor.
- uint8_t* const bytes_;
- const uint32_t num_bytes_;
- const char** const out_error_msg_;
- zx_status_t status_ = ZX_OK;
-};
-
-} // namespace
-
-#endif // __Fuchsia__
-
-zx_status_t fidl_close_handles(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const char** out_error_msg) {
-#if __Fuchsia__
- FidlHandleCloser handle_closer(type, bytes, num_bytes, out_error_msg);
- handle_closer.Walk();
- return handle_closer.status();
-#else
- return ZX_OK; // there can't be any handles on the host
-#endif
-}
-
-zx_status_t fidl_close_handles_msg(const fidl_type_t* type, const fidl_msg_t* msg,
- const char** out_error_msg) {
- return fidl_close_handles(type, msg->bytes, msg->num_bytes, out_error_msg);
-}
-
diff --git a/pkg/fidl/include/lib/fidl/coding.h b/pkg/fidl/include/lib/fidl/coding.h
deleted file mode 100644
index f30fe94..0000000
--- a/pkg/fidl/include/lib/fidl/coding.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CODING_H_
-#define LIB_FIDL_CODING_H_
-
-#include <zircon/compiler.h>
-#include <zircon/fidl.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS
-
-// The maximum recursion depth the fidl encoder or decoder will
-// perform. Each nested aggregate type (structs, unions, arrays, or
-// vectors) counts as one step in the recursion depth.
-#define FIDL_RECURSION_DEPTH 32
-
-// See https://fuchsia.googlesource.com/docs/+/master/development/languages/fidl/languages/c.md#fidl_encode-fidl_encode_msg
-zx_status_t fidl_encode(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- zx_handle_t* handles, uint32_t max_handles,
- uint32_t* out_actual_handles, const char** out_error_msg);
-zx_status_t fidl_encode_msg(const fidl_type_t* type, fidl_msg_t* msg,
- uint32_t* out_actual_handles, const char** out_error_msg);
-
-// See https://fuchsia.googlesource.com/docs/+/master/development/languages/fidl/languages/c.md#fidl_decode-fidl_decode_msg
-zx_status_t fidl_decode(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const zx_handle_t* handles, uint32_t num_handles,
- const char** error_msg_out);
-zx_status_t fidl_decode_msg(const fidl_type_t* type, fidl_msg_t* msg,
- const char** out_error_msg);
-
-// Validates an encoded message against the given |type|.
-//
-// The |bytes| are not modified.
-zx_status_t fidl_validate(const fidl_type_t* type, const void* bytes, uint32_t num_bytes,
- uint32_t num_handles, const char** error_msg_out);
-zx_status_t fidl_validate_msg(const fidl_type_t* type, const fidl_msg_t* msg,
- const char** out_error_msg);
-
-// Traverses a linearized FIDL message, closing all handles within it.
-// This function is a no-op on host side.
-//
-// Handle values in |bytes| are replaced with ZX_HANDLE_INVALID.
-zx_status_t fidl_close_handles(const fidl_type_t* type, void* bytes, uint32_t num_bytes,
- const char** out_error_msg);
-zx_status_t fidl_close_handles_msg(const fidl_type_t* type, const fidl_msg_t* msg,
- const char** out_error_msg);
-
-// Stores the name of a fidl type into the provided buffer.
-// Truncates the name if it is too long to fit into the buffer.
-// Returns the number of characters written into the buffer.
-//
-// Note: This function does not write a trailing NUL.
-size_t fidl_format_type_name(const fidl_type_t* type,
- char* buffer, size_t capacity);
-
-__END_CDECLS
-
-#endif // LIB_FIDL_CODING_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/builder.h b/pkg/fidl/include/lib/fidl/cpp/builder.h
deleted file mode 100644
index bc394c5..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/builder.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_BUILDER_H_
-#define LIB_FIDL_CPP_BUILDER_H_
-
-#include <new> // For placement new.
-#include <stdalign.h>
-#include <stdint.h>
-
-#include <lib/fidl/cpp/message_part.h>
-#include <zircon/compiler.h>
-#include <zircon/fidl.h>
-#include <zircon/types.h>
-
-namespace fidl {
-
-// Builder helps FIDL clients store decoded objects in a buffer.
-//
-// Objects are allocated sequentually in the buffer with appropriate alignment
-// for in-place encoding. The client is responsible for ordering the objects in
-// the buffer appropriately.
-class Builder {
-public:
- // Creates a buffer without any storage.
- Builder();
-
- // Creates a buffer that stores objects in the given memory.
- //
- // The constructed |Builder| object does not take ownership of the given
- // storage.
- Builder(void* buffer, uint32_t capacity);
- ~Builder();
-
- Builder(const Builder& other) = delete;
- Builder& operator=(const Builder& other) = delete;
-
- Builder(Builder&& other);
- Builder& operator=(Builder&& other);
-
- // Allocates storage in the buffer of sufficient size to store an object of
- // type |T|. The object must have alignment constraints that are compatible
- // with FIDL messages.
- //
- // If there is insufficient storage in the builder's buffer, this method
- // returns nullptr.
- template <typename T>
- T* New() {
- static_assert(alignof(T) <= FIDL_ALIGNMENT, "");
- static_assert(sizeof(T) <= ZX_CHANNEL_MAX_MSG_BYTES, "");
- if (void* ptr = Allocate(sizeof(T)))
- return new (ptr) T;
- return nullptr;
- }
-
- // Allocates storage in the buffer of sufficient size to store |count|
- // objects of type |T|. The object must have alignment constraints that are
- // compatible with FIDL messages.
- //
- // If there is insufficient storage in the builder's buffer, this method
- // returns nullptr.
- template <typename T>
- T* NewArray(uint32_t count) {
- static_assert(alignof(T) <= FIDL_ALIGNMENT, "");
- static_assert(sizeof(T) <= ZX_CHANNEL_MAX_MSG_BYTES, "");
- if (sizeof(T) * static_cast<uint64_t>(count) > UINT32_MAX)
- return nullptr;
- if (void* ptr = Allocate(static_cast<uint32_t>(sizeof(T) * count)))
- return new (ptr) T[count];
- return nullptr;
- }
-
- // Completes the building and returns a |MesssagePart| containing the
- // allocated objects.
- //
- // The allocated objects are placed in the returned buffer in the order in
- // which they were allocated, with appropriate alignment for a FIDL message.
- // The returned buffer's capacity cooresponds to the capacity originally
- // provided to this builder in its constructor.
- BytePart Finalize();
-
- // Attaches the given storage to the |Builder|.
- //
- // The |Builder| object does not take ownership of the given storage. The
- // next object will be allocated at the start of the buffer.
- void Reset(void* buffer, uint32_t capacity);
-
-protected:
- uint8_t* buffer() const { return buffer_; }
- uint32_t capacity() const { return capacity_; }
-
-private:
- // Returns |size| bytes of zeroed memory aligned to at least FIDL_ALIGNMENT
- void* Allocate(uint32_t size);
-
- uint32_t capacity_;
- uint32_t at_;
- uint8_t* buffer_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_BUILDER_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/message.h b/pkg/fidl/include/lib/fidl/cpp/message.h
deleted file mode 100644
index d93e7c9..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/message.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_MESSAGE_H_
-#define LIB_FIDL_CPP_MESSAGE_H_
-
-#include <lib/fidl/coding.h>
-#include <lib/fidl/cpp/message_part.h>
-#include <zircon/fidl.h>
-
-namespace fidl {
-
-// A FIDL message.
-//
-// A FIDL message has two parts: the bytes and the handles. The bytes are
-// divided into a header (of type fidl_message_header_t) and a payload, which
-// follows the header.
-//
-// A Message object does not own the storage for the message parts.
-class Message {
-public:
- // Creates a message without any storage.
- Message();
-
- // Creates a message whose storage is backed by |bytes| and |handles|.
- //
- // The constructed |Message| object does not take ownership of the given
- // storage, although does take ownership of zircon handles contained withing
- // handles.
- Message(BytePart bytes, HandlePart handles);
-
- ~Message();
-
- Message(const Message& other) = delete;
- Message& operator=(const Message& other) = delete;
-
- Message(Message&& other);
- Message& operator=(Message&& other);
-
- // Whether the message has enough bytes to contain a fidl_message_header_t.
- bool has_header() const {
- return bytes_.actual() >= sizeof(fidl_message_header_t);
- }
-
- // The header at the start of the message.
- //
- // Valid only if has_header().
- const fidl_message_header_t& header() const {
- return *reinterpret_cast<fidl_message_header_t*>(bytes_.data());
- }
- fidl_message_header_t& header() {
- return *reinterpret_cast<fidl_message_header_t*>(bytes_.data());
- }
-
- // The transaction ID in the message header.
- //
- // Valid only if has_header().
- zx_txid_t txid() const { return header().txid; }
- void set_txid(zx_txid_t txid) { header().txid = txid; }
-
- // The flags in the message header.
- //
- // Valid only if has_header().
- uint32_t flags() const { return header().flags; }
-
- // The flags in the message header.
- //
- // Valid only if has_header().
- uint32_t ordinal() const { return header().ordinal; }
-
- // The message payload that follows the header.
- //
- // Valid only if has_header().
- BytePart payload() const {
- constexpr uint32_t n = sizeof(fidl_message_header_t);
- return BytePart(bytes_.data() + n, bytes_.capacity() - n, bytes_.actual() - n);
- }
-
- // The message bytes interpreted as the given type.
- template <typename T>
- T* GetBytesAs() const {
- return reinterpret_cast<T*>(bytes_.data());
- }
-
- // The message payload that follows the header interpreted as the given type.
- //
- // Valid only if has_header().
- template <typename T>
- T* GetPayloadAs() const {
- return reinterpret_cast<T*>(bytes_.data() + sizeof(fidl_message_header_t));
- }
-
- // The storage for the bytes of the message.
- BytePart& bytes() { return bytes_; }
- const BytePart& bytes() const { return bytes_; }
- void set_bytes(BytePart bytes) { bytes_ = static_cast<BytePart&&>(bytes); }
-
- // The storage for the handles of the message.
- //
- // When the message is encoded, the handle values are stored in this part of
- // the message. When the message is decoded, this part of the message is
- // empty and the handle values are stored in the bytes().
- HandlePart& handles() { return handles_; }
- const HandlePart& handles() const { return handles_; }
-
- // Encodes the message in-place.
- //
- // The message must previously have been in a decoded state, for example,
- // either by being built in a decoded state using a |Builder| or having been
- // decoded using the |Decode| method.
- zx_status_t Encode(const fidl_type_t* type, const char** error_msg_out);
-
- // Decodes the message in-place.
- //
- // The message must previously have been in an encoded state, for example,
- // either by being read from a zx_channel_t or having been encoded using the
- // |Encode| method.
- zx_status_t Decode(const fidl_type_t* type, const char** error_msg_out);
-
- // Validates the message in-place.
- //
- // The message must already be in an encoded state, for example, either by
- // being read from a zx_channel_t or having been created in that state.
- //
- // Does not modify the message.
- zx_status_t Validate(const fidl_type_t* type, const char** error_msg_out) const;
-
- // Read a message from the given channel.
- //
- // The bytes read from the channel are stored in bytes() and the handles
- // read from the channel are stored in handles(). Existing data in these
- // buffers is overwritten.
- zx_status_t Read(zx_handle_t channel, uint32_t flags);
-
- // Writes a message to the given channel.
- //
- // The bytes stored in bytes() are written to the channel and the handles
- // stored in handles() are written to the channel.
- //
- // If this method returns ZX_OK, handles() will be empty because they were
- // consumed by this operation.
- zx_status_t Write(zx_handle_t channel, uint32_t flags);
-
- // Issues a synchronous send and receive transaction on the given channel.
- //
- // The bytes stored in bytes() are written to the channel and the handles
- // stored in handles() are written to the channel. The bytes read from the
- // channel are stored in response->bytes() and the handles read from the
- // channel are stored in response->handles().
- //
- // If this method returns ZX_OK, handles() will be empty because they were
- // consumed by this operation.
- zx_status_t Call(zx_handle_t channel, uint32_t flags, zx_time_t deadline,
- Message* response);
-
- // Stop tracking the handles in stored in handles(), without closing them.
- //
- // Typically, these handles will be extracted during decode or the
- // message's destructor, so this function will be unnecessary. However,
- // for clients of ulib/fidl which decode message manually, this function
- // is necessary to prevent extracted handles from being closed.
- void ClearHandlesUnsafe();
-
-private:
- BytePart bytes_;
- HandlePart handles_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_MESSAGE_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/message_buffer.h b/pkg/fidl/include/lib/fidl/cpp/message_buffer.h
deleted file mode 100644
index 8e85823..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/message_buffer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_MESSAGE_BUFFER_H_
-#define LIB_FIDL_CPP_MESSAGE_BUFFER_H_
-
-#include <stdint.h>
-
-#include <lib/fidl/cpp/builder.h>
-#include <lib/fidl/cpp/message.h>
-#include <zircon/fidl.h>
-#include <zircon/types.h>
-
-namespace fidl {
-
-class MessageBuffer {
-public:
- // Creates a |MessageBuffer| that allocates buffers for message of the
- // given capacities.
- //
- // The buffers are freed when the |MessageBuffer| is destructed.
- explicit MessageBuffer(
- uint32_t bytes_capacity = ZX_CHANNEL_MAX_MSG_BYTES,
- uint32_t handles_capacity = ZX_CHANNEL_MAX_MSG_HANDLES);
-
- // The memory that backs the message is freed by this destructor.
- ~MessageBuffer();
-
- // The memory in which bytes can be stored in this buffer.
- uint8_t* bytes() const { return buffer_; }
-
- // The total number of bytes that can be stored in this buffer.
- uint32_t bytes_capacity() const { return bytes_capacity_; }
-
- // The memory in which handles can be stored in this buffer.
- zx_handle_t* handles() const;
-
- // The total number of handles that can be stored in this buffer.
- uint32_t handles_capacity() const { return handles_capacity_; }
-
- // Creates a |Message| that is backed by the memory in this buffer.
- //
- // The returned |Message| contains no bytes or handles.
- Message CreateEmptyMessage();
-
- // Creates a |Builder| that is backed by the memory in this buffer.
- Builder CreateBuilder();
-
-private:
- uint8_t* const buffer_;
- const uint32_t bytes_capacity_;
- const uint32_t handles_capacity_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_MESSAGE_BUFFER_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/message_builder.h b/pkg/fidl/include/lib/fidl/cpp/message_builder.h
deleted file mode 100644
index b571f3b..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/message_builder.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_MESSAGE_BUILDER_H_
-#define LIB_FIDL_CPP_MESSAGE_BUILDER_H_
-
-#include <stdint.h>
-
-#include <lib/fidl/cpp/builder.h>
-#include <lib/fidl/cpp/message_buffer.h>
-#include <lib/fidl/cpp/message.h>
-#include <zircon/fidl.h>
-#include <zircon/types.h>
-
-namespace fidl {
-
-// A builder for FIDL messages that owns the memory for the message.
-//
-// A |MessageBuilder| is a |Builder| that uses the heap to back the memory for
-// the message. If you wish to manage the memory yourself, you can use |Builder|
-// and |Message| directly.
-//
-// Upon creation, the |MessageBuilder| creates a FIDL message header, which you
-// can modify using |header()|.
-class MessageBuilder : public Builder {
-public:
- // Creates a |MessageBuilder| for the given |type| that allocates buffers
- // for message of the given capacities.
- //
- // The bytes buffer is initialied by adding a |fidl_message_header_t|
- // header.
- //
- // The buffers are freed when the |MessageBuilder| is destructed.
- explicit MessageBuilder(
- const fidl_type_t* type,
- uint32_t bytes_capacity = ZX_CHANNEL_MAX_MSG_BYTES,
- uint32_t handles_capacity = ZX_CHANNEL_MAX_MSG_HANDLES);
-
- // The memory that backs the message is freed by this destructor.
- ~MessageBuilder();
-
- // The type of the message payload this object is building.
- const fidl_type_t* type() const { return type_; }
-
- // The header for the message.
- //
- // The message header is allocated by the |MessageBuilder| itself.
- fidl_message_header_t* header() const {
- return reinterpret_cast<fidl_message_header_t*>(buffer());
- }
-
- // Encodes a message of the given |type|.
- //
- // The memory that backs the message returned by this function is owned by
- // the |MessageBuilder|, which means the |MessageBuilder| must remain alive
- // as long as the |Message| object is in use.
- //
- // The |message| parameter might be modified even if this method returns an
- // error.
- zx_status_t Encode(Message* message_out, const char** error_msg_out);
-
- // Resets all the data in the |MessageBuffer|.
- //
- // The underlying buffer is retained and reused. The next object will be
- // allocated at the start of the buffer.
- void Reset();
-
-private:
- const fidl_type_t* type_;
- MessageBuffer buffer_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_MESSAGE_BUILDER_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/message_part.h b/pkg/fidl/include/lib/fidl/cpp/message_part.h
deleted file mode 100644
index 1dd7f7b..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/message_part.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_MESSAGE_PART_H_
-#define LIB_FIDL_CPP_MESSAGE_PART_H_
-
-#include <stdint.h>
-#include <string.h>
-
-#include <zircon/types.h>
-
-namespace fidl {
-
-// Part of a FIDL message.
-//
-// A FIDL message has two parts: the bytes and the handles. This class is used
-// to represent both kinds of parts.
-//
-// Each part of the message has a data buffer, which contains the actual data
-// for that part of the message, a capacity for that buffer, and the actual
-// amount of data stored in the buffer, which might be less that the capacity if
-// the buffer is not completely full.
-template<typename T>
-class MessagePart {
-public:
- using value_type = T;
- using const_iterator = const T*;
-
- // A message part with no storage.
- MessagePart() : data_(nullptr), capacity_(0u), actual_(0u) {}
-
- // A message part that uses the given storage.
- //
- // The constructed |MessagePart| object does not take ownership of the given
- // storage.
- MessagePart(T* data, uint32_t capacity, uint32_t actual = 0u)
- : data_(data), capacity_(capacity), actual_(actual) {}
-
- MessagePart(const MessagePart& other) = delete;
- MessagePart& operator=(const MessagePart& other) = delete;
-
- MessagePart(MessagePart&& other)
- : data_(other.data_),
- capacity_(other.capacity_),
- actual_(other.actual_) {
- other.data_ = nullptr;
- other.capacity_ = 0u;
- other.actual_ = 0u;
- }
-
- MessagePart& operator=(MessagePart&& other) {
- if (this == &other)
- return *this;
- data_ = other.data_;
- capacity_ = other.capacity_;
- actual_ = other.actual_;
- other.data_ = nullptr;
- other.capacity_ = 0u;
- other.actual_ = 0u;
- return *this;
- }
-
- // The data stored in this part of the message.
- T* data() const { return data_; }
-
- // The total amount of storage available for this part of the message.
- //
- // This part of the message might not actually use all of this storage. To
- // determine how much storage is actually being used, see |actual()|.
- uint32_t capacity() const { return capacity_; }
-
- // The amount of storage that is actually being used for this part of the
- // message.
- //
- // There might be more storage available than is actually being used. To
- // determine how much storage is available, see |capacity()|.
- uint32_t actual() const { return actual_; }
- void set_actual(uint32_t actual) { actual_ = actual; }
-
- T* begin() { return data_; }
- const T* begin() const { return data_; }
- const T* cbegin() const { return data_; }
-
- T* end() { return data_ + actual_; }
- const T* end() const { return data_ + actual_; }
- const T* cend() const { return data_ + actual_; }
-
- size_t size() const { return actual_; }
-
-private:
- T* data_;
- uint32_t capacity_;
- uint32_t actual_;
-};
-
-using BytePart = MessagePart<uint8_t>;
-using HandlePart = MessagePart<zx_handle_t>;
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_MESSAGE_PART_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/string_view.h b/pkg/fidl/include/lib/fidl/cpp/string_view.h
deleted file mode 100644
index 88eec42..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/string_view.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_STRING_VIEW_H_
-#define LIB_FIDL_CPP_STRING_VIEW_H_
-
-#include <zircon/fidl.h>
-
-namespace fidl {
-
-class StringView : public fidl_string_t {
-public:
- StringView() : fidl_string_t{} {}
-
- uint64_t size() const { return fidl_string_t::size; }
- void set_size(uint64_t size) { fidl_string_t::size = size; }
-
- const char* data() const { return fidl_string_t::data; }
- void set_data(char* data) { fidl_string_t::data = data; }
-
- char* mutable_data() const { return fidl_string_t::data; }
-
- bool is_null() const { return fidl_string_t::data == nullptr; }
- bool empty() const { return fidl_string_t::size == 0; }
-
- const char& at(size_t offset) const { return data()[offset]; }
- char& at(size_t offset) { return mutable_data()[offset]; }
-
- const char& operator[](size_t offset) const { return at(offset); }
- char& operator[](size_t offset) { return at(offset); }
-
- char* begin() { return mutable_data(); }
- const char* begin() const { return data(); }
- const char* cbegin() const { return data(); }
-
- char* end() { return mutable_data() + size(); }
- const char* end() const { return data() + size(); }
- const char* cend() const { return data() + size(); }
-
- fidl_string_t* impl() { return this; }
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_STRING_VIEW_H_
diff --git a/pkg/fidl/include/lib/fidl/cpp/vector_view.h b/pkg/fidl/include/lib/fidl/cpp/vector_view.h
deleted file mode 100644
index df4cedf..0000000
--- a/pkg/fidl/include/lib/fidl/cpp/vector_view.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_VECTOR_VIEW_H_
-#define LIB_FIDL_CPP_VECTOR_VIEW_H_
-
-#include <zircon/fidl.h>
-
-namespace fidl {
-
-template<typename T>
-class VectorView : public fidl_vector_t {
-public:
- VectorView() : fidl_vector_t{} {}
-
- uint64_t count() const { return fidl_vector_t::count; }
- void set_count(uint64_t count) { fidl_vector_t::count = count; }
-
- const T* data() const { return static_cast<T*>(fidl_vector_t::data); }
- void set_data(T* data) { fidl_vector_t::data = data; }
-
- T* mutable_data() const { return static_cast<T*>(fidl_vector_t::data); }
-
- bool is_null() const { return fidl_vector_t::data == nullptr; }
- bool empty() const { return fidl_vector_t::count == 0; }
-
- const T& at(size_t offset) const { return data()[offset]; }
- T& at(size_t offset) { return mutable_data()[offset]; }
-
- const T& operator[](size_t offset) const { return at(offset); }
- T& operator[](size_t offset) { return at(offset); }
-
- T* begin() { return mutable_data(); }
- const T* begin() const { return data(); }
- const T* cbegin() const { return data(); }
-
- T* end() { return mutable_data() + count(); }
- const T* end() const { return data() + count(); }
- const T* cend() const { return data() + count(); }
-
- fidl_vector_t* impl() { return this; }
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_VECTOR_VIEW_H_
diff --git a/pkg/fidl/include/lib/fidl/epitaph.h b/pkg/fidl/include/lib/fidl/epitaph.h
deleted file mode 100644
index 55653a7..0000000
--- a/pkg/fidl/include/lib/fidl/epitaph.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_EPITAPH_H_
-#define LIB_FIDL_EPITAPH_H_
-
-#include <zircon/types.h>
-
-__BEGIN_CDECLS
-
-#ifdef __Fuchsia__
-
-// Sends an epitaph with the given values down the channel.
-// See https://fuchsia.googlesource.com/docs/+/master/development/languages/fidl/languages/c.md#fidl_epitaph_write
-zx_status_t fidl_epitaph_write(zx_handle_t channel, zx_status_t error);
-
-#endif // __Fuchsia__
-
-__END_CDECLS
-
-#endif // LIB_FIDL_EPITAPH_H_
diff --git a/pkg/fidl/include/lib/fidl/internal.h b/pkg/fidl/include/lib/fidl/internal.h
deleted file mode 100644
index efef16e..0000000
--- a/pkg/fidl/include/lib/fidl/internal.h
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_INTERNAL_H_
-#define LIB_FIDL_INTERNAL_H_
-
-#include <assert.h>
-#include <stdint.h>
-
-#include <lib/fidl/coding.h>
-#include <zircon/syscalls/object.h>
-#include <zircon/types.h>
-
-// All sizes here are given as uint32_t. Fidl message sizes are bounded to well below UINT32_MAX.
-// This also applies to arrays and vectors. For arrays, element_count * element_size will always fit
-// with 32 bits. For vectors, max_count * element_size will always fit within 32 bits.
-
-// Pointers to other type tables within a type are always nonnull, with the exception of vectors.
-// In that case, a null pointer indicates that the element type of the vector has no interesting
-// information to be decoded (i.e. no pointers or handles). The vector type still needs to be
-// emitted as it contains the information about the size of its secondary object. Contrast this with
-// arrays: being inline, ones with no interesting coding information can be elided, just like a
-// uint32 field in a struct is elided.
-
-namespace fidl {
-
-enum FidlNullability : uint32_t {
- kNonnullable = 0u,
- kNullable = 1u,
-};
-
-inline uint64_t FidlAlign(uint32_t offset) {
- constexpr uint64_t alignment_mask = FIDL_ALIGNMENT - 1;
- return (offset + alignment_mask) & ~alignment_mask;
-}
-
-struct FidlField {
- const fidl_type* type;
- uint32_t offset;
-
- constexpr FidlField(const fidl_type* type, uint32_t offset)
- : type(type), offset(offset) {}
-};
-
-struct FidlTableField {
- const fidl_type* type;
- uint32_t ordinal;
-
- constexpr FidlTableField(const fidl_type* type, uint32_t ordinal)
- : type(type), ordinal(ordinal) {}
-};
-
-enum FidlTypeTag : uint32_t {
- kFidlTypeStruct = 0u,
- kFidlTypeStructPointer = 1u,
- kFidlTypeTable = 8u,
- kFidlTypeTablePointer = 9u,
- kFidlTypeUnion = 2u,
- kFidlTypeUnionPointer = 3u,
- kFidlTypeArray = 4u,
- kFidlTypeString = 5u,
- kFidlTypeHandle = 6u,
- kFidlTypeVector = 7u,
-};
-
-// Though the |size| is implied by the fields, computing that information is not the purview of this
-// library. It's easier for the compiler to stash it.
-struct FidlCodedStruct {
- const FidlField* const fields;
- const uint32_t field_count;
- const uint32_t size;
- const char* name; // may be nullptr if omitted at compile time
-
- constexpr FidlCodedStruct(const FidlField* fields, uint32_t field_count, uint32_t size,
- const char* name)
- : fields(fields), field_count(field_count), size(size), name(name) {}
-};
-
-struct FidlCodedStructPointer {
- const FidlCodedStruct* const struct_type;
-
- constexpr explicit FidlCodedStructPointer(const FidlCodedStruct* struct_type)
- : struct_type(struct_type) {}
-};
-
-struct FidlCodedTable {
- const FidlTableField* const fields;
- const uint32_t field_count;
- const char* name; // may be nullptr if omitted at compile time
-
- constexpr FidlCodedTable(const FidlTableField* fields, uint32_t field_count,
- const char* name)
- : fields(fields), field_count(field_count), name(name) {}
-};
-
-struct FidlCodedTablePointer {
- const FidlCodedTable* const table_type;
-
- constexpr explicit FidlCodedTablePointer(const FidlCodedTable* table_type)
- : table_type(table_type) {}
-};
-
-// Unlike structs, union members do not have different offsets, so this points to an array of
-// |fidl_type*| rather than |FidlField|.
-//
-// On-the-wire unions begin with a tag which is an index into |types|.
-// |data_offset| is the offset of the data in the wire format (tag + padding).
-struct FidlCodedUnion {
- const fidl_type* const* types;
- const uint32_t type_count;
- const uint32_t data_offset;
- const uint32_t size;
- const char* name; // may be nullptr if omitted at compile time
-
- constexpr FidlCodedUnion(const fidl_type* const* types, uint32_t type_count,
- uint32_t data_offset, uint32_t size, const char* name)
- : types(types), type_count(type_count), data_offset(data_offset), size(size), name(name) {}
-};
-
-struct FidlCodedUnionPointer {
- const FidlCodedUnion* const union_type;
-
- constexpr explicit FidlCodedUnionPointer(const FidlCodedUnion* union_type)
- : union_type(union_type) {}
-};
-
-// An array is essentially a struct with |array_size / element_size| of the same field, named at
-// |element|.
-struct FidlCodedArray {
- const fidl_type* const element;
- const uint32_t array_size;
- const uint32_t element_size;
-
- constexpr FidlCodedArray(const fidl_type* element, uint32_t array_size, uint32_t element_size)
- : element(element), array_size(array_size), element_size(element_size) {}
-};
-
-// Note: must keep in sync with fidlc types.h HandleSubtype.
-enum FidlHandleSubtype : zx_obj_type_t {
- // special case to indicate subtype is not specified.
- kFidlHandleSubtypeHandle = ZX_OBJ_TYPE_NONE,
-
- kFidlHandleSubtypeProcess = ZX_OBJ_TYPE_PROCESS,
- kFidlHandleSubtypeThread = ZX_OBJ_TYPE_THREAD,
- kFidlHandleSubtypeVmo = ZX_OBJ_TYPE_VMO,
- kFidlHandleSubtypeChannel = ZX_OBJ_TYPE_CHANNEL,
- kFidlHandleSubtypeEvent = ZX_OBJ_TYPE_EVENT,
- kFidlHandleSubtypePort = ZX_OBJ_TYPE_PORT,
- kFidlHandleSubtypeInterrupt = ZX_OBJ_TYPE_INTERRUPT,
- kFidlHandleSubtypeLog = ZX_OBJ_TYPE_LOG,
- kFidlHandleSubtypeSocket = ZX_OBJ_TYPE_SOCKET,
- kFidlHandleSubtypeResource = ZX_OBJ_TYPE_RESOURCE,
- kFidlHandleSubtypeEventpair = ZX_OBJ_TYPE_EVENTPAIR,
- kFidlHandleSubtypeJob = ZX_OBJ_TYPE_JOB,
- kFidlHandleSubtypeVmar = ZX_OBJ_TYPE_VMAR,
- kFidlHandleSubtypeFifo = ZX_OBJ_TYPE_FIFO,
- kFidlHandleSubtypeGuest = ZX_OBJ_TYPE_GUEST,
- kFidlHandleSubtypeTimer = ZX_OBJ_TYPE_TIMER,
-};
-
-struct FidlCodedHandle {
- const zx_obj_type_t handle_subtype;
- const FidlNullability nullable;
-
- constexpr FidlCodedHandle(uint32_t handle_subtype, FidlNullability nullable)
- : handle_subtype(handle_subtype), nullable(nullable) {}
-
- static_assert(ZX_OBJ_TYPE_LAST <= UINT32_MAX, "");
-};
-
-struct FidlCodedString {
- const uint32_t max_size;
- const FidlNullability nullable;
-
- constexpr FidlCodedString(uint32_t max_size, FidlNullability nullable)
- : max_size(max_size), nullable(nullable) {}
-};
-
-// Note that |max_count * element_size| is guaranteed to fit into a uint32_t. Unlike other types,
-// the |element| pointer may be null. This occurs when the element type contains no interesting bits
-// (i.e. pointers or handles).
-struct FidlCodedVector {
- const fidl_type* const element;
- const uint32_t max_count;
- const uint32_t element_size;
- const FidlNullability nullable;
-
- constexpr FidlCodedVector(const fidl_type* element, uint32_t max_count, uint32_t element_size,
- FidlNullability nullable)
- : element(element), max_count(max_count), element_size(element_size), nullable(nullable) {}
-};
-
-} // namespace fidl
-
-struct fidl_type {
- const fidl::FidlTypeTag type_tag;
- const union {
- const fidl::FidlCodedStruct coded_struct;
- const fidl::FidlCodedStructPointer coded_struct_pointer;
- const fidl::FidlCodedTable coded_table;
- const fidl::FidlCodedTablePointer coded_table_pointer;
- const fidl::FidlCodedUnion coded_union;
- const fidl::FidlCodedUnionPointer coded_union_pointer;
- const fidl::FidlCodedHandle coded_handle;
- const fidl::FidlCodedString coded_string;
- const fidl::FidlCodedArray coded_array;
- const fidl::FidlCodedVector coded_vector;
- };
-
- constexpr fidl_type(fidl::FidlCodedStruct coded_struct)
- : type_tag(fidl::kFidlTypeStruct), coded_struct(coded_struct) {}
-
- constexpr fidl_type(fidl::FidlCodedStructPointer coded_struct_pointer)
- : type_tag(fidl::kFidlTypeStructPointer), coded_struct_pointer(coded_struct_pointer) {}
-
- constexpr fidl_type(fidl::FidlCodedTable coded_table)
- : type_tag(fidl::kFidlTypeTable), coded_table(coded_table) {}
-
- constexpr fidl_type(fidl::FidlCodedTablePointer coded_table_pointer)
- : type_tag(fidl::kFidlTypeTablePointer), coded_table_pointer(coded_table_pointer) {}
-
- constexpr fidl_type(fidl::FidlCodedUnion coded_union)
- : type_tag(fidl::kFidlTypeUnion), coded_union(coded_union) {}
-
- constexpr fidl_type(fidl::FidlCodedUnionPointer coded_union_pointer)
- : type_tag(fidl::kFidlTypeUnionPointer), coded_union_pointer(coded_union_pointer) {}
-
- constexpr fidl_type(fidl::FidlCodedHandle coded_handle)
- : type_tag(fidl::kFidlTypeHandle), coded_handle(coded_handle) {}
-
- constexpr fidl_type(fidl::FidlCodedString coded_string)
- : type_tag(fidl::kFidlTypeString), coded_string(coded_string) {}
-
- constexpr fidl_type(fidl::FidlCodedArray coded_array)
- : type_tag(fidl::kFidlTypeArray), coded_array(coded_array) {}
-
- constexpr fidl_type(fidl::FidlCodedVector coded_vector)
- : type_tag(fidl::kFidlTypeVector), coded_vector(coded_vector) {}
-};
-
-#endif // LIB_FIDL_INTERNAL_H_
diff --git a/pkg/fidl/include/lib/fidl/llcpp/decoded_message.h b/pkg/fidl/include/lib/fidl/llcpp/decoded_message.h
deleted file mode 100644
index 52d0ec5..0000000
--- a/pkg/fidl/include/lib/fidl/llcpp/decoded_message.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_LLCPP_DECODED_MESSAGE_H_
-#define LIB_FIDL_LLCPP_DECODED_MESSAGE_H_
-
-#include <lib/fidl/coding.h>
-#include <lib/fidl/llcpp/encoded_message.h>
-#include <lib/fidl/llcpp/traits.h>
-#include <type_traits>
-#include <zircon/fidl.h>
-
-namespace fidl {
-
-// `DecodedMessage` manages a linearized FIDL message in decoded form.
-// It takes care of releasing all handles which were not consumed
-// (std::moved from the decoded FIDL struct) when it goes out of scope.
-template <typename FidlType>
-class DecodedMessage final {
- static_assert(IsFidlType<FidlType>::value, "Only FIDL types allowed here");
- static_assert(FidlType::MaxSize > 0, "Positive message size");
-
-public:
- // Instantiates an empty message.
- // To populate this message, decode from an EncodedMessage object.
- DecodedMessage() = default;
-
- // Instantiates a DecodedMessage which points to a buffer region with caller-managed memory.
- // The buffer region is assumed to contain a linearized FIDL message with valid pointers.
- // This does not take ownership of that buffer region.
- // But it does take ownership of the handles within the buffer.
- DecodedMessage(BytePart bytes) :
- bytes_(std::move(bytes)) { }
-
- DecodedMessage(DecodedMessage&& other) = default;
-
- DecodedMessage& operator=(DecodedMessage&& other) = default;
-
- DecodedMessage(const DecodedMessage& other) = delete;
-
- DecodedMessage& operator=(const DecodedMessage& other) = delete;
-
- ~DecodedMessage() {
- CloseHandles();
- }
-
- // Keeps track of a new buffer region with caller-managed memory.
- // The buffer region is assumed to contain a linearized FIDL message with valid pointers.
- // This does not take ownership of that buffer region.
- // But it does take ownership of the handles within the buffer.
- void Reset(BytePart bytes) {
- CloseHandles();
- bytes_ = std::move(bytes);
- }
-
- // Consumes an encoded message object containing FIDL encoded bytes and handles.
- // The current buffer region in DecodedMessage is always released.
- // Uses the FIDL encoding tables to deserialize the message in-place.
- // If the message is invalid, discards the buffer and returns an error.
- zx_status_t DecodeFrom(EncodedMessage<FidlType>* msg, const char** out_error_msg) {
- // Clear any existing message.
- CloseHandles();
- bytes_ = BytePart();
- zx_status_t status = fidl_decode(FidlType::type,
- msg->bytes().data(), msg->bytes().actual(),
- msg->handles().data(), msg->handles().actual(),
- out_error_msg);
- // Clear out |msg| independent of success or failure
- BytePart bytes = msg->ReleaseBytesAndHandles();
- if (status == ZX_OK) {
- Reset(std::move(bytes));
- } else {
- Reset(BytePart());
- }
- return status;
- }
-
- // Serializes the content of the message in-place and stores the result
- // in |out_msg|. The message's contents are always consumed by this
- // operation, even in case of an error.
- zx_status_t EncodeTo(EncodedMessage<FidlType>* out_msg, const char** out_error_msg) {
- return out_msg->Initialize([this, &out_error_msg] (BytePart& msg_bytes,
- HandlePart& msg_handles) {
- msg_bytes = std::move(bytes_);
- uint32_t actual_handles = 0;
- zx_status_t status = fidl_encode(FidlType::type,
- msg_bytes.data(), msg_bytes.actual(),
- msg_handles.data(), msg_handles.capacity(),
- &actual_handles, out_error_msg);
- msg_handles.set_actual(actual_handles);
- return status;
- });
- }
-
- // Accesses the FIDL message by reinterpreting the buffer pointer.
- // Returns nullptr if there is no message.
- FidlType* message() const {
- return reinterpret_cast<FidlType*>(bytes_.data());
- }
-
-private:
- // Use the FIDL encoding tables for |FidlType| to walk the message and
- // destroy the handles it contains.
- void CloseHandles() {
-#ifdef __Fuchsia__
- if (bytes_.data()) {
- fidl_close_handles(FidlType::type, bytes_.data(), bytes_.actual(), nullptr);
- }
-#endif
- }
-
- // The contents of the decoded message.
- BytePart bytes_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_LLCPP_DECODED_MESSAGE_H_
diff --git a/pkg/fidl/include/lib/fidl/llcpp/encoded_message.h b/pkg/fidl/include/lib/fidl/llcpp/encoded_message.h
deleted file mode 100644
index 8fd1a06..0000000
--- a/pkg/fidl/include/lib/fidl/llcpp/encoded_message.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_LLCPP_ENCODED_MESSAGE_H_
-#define LIB_FIDL_LLCPP_ENCODED_MESSAGE_H_
-
-#include <algorithm>
-#include <cstdint>
-#include <iterator>
-#include <lib/fidl/cpp/message_part.h>
-#include <lib/fidl/llcpp/traits.h>
-#include <lib/fit/traits.h>
-#include <type_traits>
-#include <utility>
-#include <zircon/fidl.h>
-
-#ifdef __Fuchsia__
-#include <zircon/syscalls.h>
-#endif
-
-namespace fidl {
-
-// Holds an encoded FIDL message, that is, a byte array plus a handle table.
-//
-// The bytes part points to an external caller-managed buffer, while the handles part
-// is owned by this class. Any handles will be closed upon destruction.
-// This class is aware of the upper bound on the number of handles
-// in a message, such that its size can be adjusted to fit the demands
-// of a specific FIDL type.
-//
-// Because this class does not own the underlying message buffer, the caller
-// must make sure the lifetime of this class does not extend over that of the buffer.
-template <typename FidlType>
-class EncodedMessage final {
- static_assert(IsFidlType<FidlType>::value, "Only FIDL types allowed here");
- static_assert(FidlType::MaxSize > 0, "Positive message size");
-
-public:
- // Instantiates an empty buffer with no bytes or handles.
- EncodedMessage() = default;
-
- EncodedMessage(EncodedMessage&& other) noexcept {
- if (this != &other) {
- MoveImpl(std::move(other));
- }
- }
-
- EncodedMessage& operator=(EncodedMessage&& other) noexcept {
- if (this != &other) {
- MoveImpl(std::move(other));
- }
- return *this;
- }
-
- EncodedMessage(const EncodedMessage& other) = delete;
-
- EncodedMessage& operator=(const EncodedMessage& other) = delete;
-
- // Instantiates an EncodedMessage which points to a buffer region with caller-managed memory.
- // It does not take ownership of that buffer region.
- // Also initializes an empty handles part.
- EncodedMessage(BytePart bytes) :
- bytes_(std::move(bytes)) { }
-
- ~EncodedMessage() {
- CloseHandles();
- }
-
- // Takes ownership of the contents of the message.
- // The bytes and handle parts will become empty, while the existing bytes part is returned.
- // The caller is responsible for having transferred the handles elsewhere
- // before calling this method.
- BytePart ReleaseBytesAndHandles() {
- handles_.set_actual(0);
- BytePart return_bytes = std::move(bytes_);
- return return_bytes;
- }
-
- const BytePart& bytes() const { return bytes_; }
-
- const HandlePart& handles() const { return handles_; }
-
- // Clears the contents of the EncodedMessage then invokes Callback
- // to initialize the EncodedMessage in-place then returns the callback's
- // result.
- //
- // |callback| is a callable object whose arguments are (BytePart&, HandlePart&).
- template <typename Callback>
- decltype(auto) Initialize(Callback callback) {
- static_assert(
- fit::callable_traits<Callback>::args::size == 2 &&
- std::is_same<
- BytePart&,
- typename fit::template callable_traits<Callback>::args::template at<0>>::value &&
- std::is_same<
- HandlePart&,
- typename fit::template callable_traits<Callback>::args::template at<1>>::value,
- "Callback signature must be: T(BytePart&, HandlePart&).");
- bytes_ = BytePart();
- CloseHandles();
- return callback(bytes_, handles_);
- }
-
-private:
- void CloseHandles() {
- if (handles_.actual() > 0) {
-#ifdef __Fuchsia__
- zx_handle_close_many(handles_.data(), handles_.actual());
-#else
- // How did we have handles if not on Fuchsia? Something bad happened...
- assert(false);
-#endif
- handles_.set_actual(0);
- }
- }
-
- void MoveImpl(EncodedMessage&& other) noexcept {
- CloseHandles();
- bytes_ = std::move(other.bytes_);
- // copy handles from |other|
- memcpy(handle_storage_, other.handle_storage_,
- other.handles_.actual() * sizeof(zx_handle_t));
- // release handles in |other|
- handles_.set_actual(other.handles().actual());
- other.handles_.set_actual(0);
- }
-
- BytePart bytes_;
- zx_handle_t handle_storage_[FidlType::MaxNumHandles];
- HandlePart handles_{handle_storage_, FidlType::MaxNumHandles};
-};
-
-}
-
-#endif // LIB_FIDL_LLCPP_ENCODED_MESSAGE_H_
diff --git a/pkg/fidl/include/lib/fidl/llcpp/traits.h b/pkg/fidl/include/lib/fidl/llcpp/traits.h
deleted file mode 100644
index 80fadd7..0000000
--- a/pkg/fidl/include/lib/fidl/llcpp/traits.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_LLCPP_TRAITS_H_
-#define LIB_FIDL_LLCPP_TRAITS_H_
-
-#include <lib/zx/object.h>
-#include <stdint.h>
-#include <type_traits>
-#include <zircon/fidl.h>
-
-// Defines type traits used in the low-level C++ binding.
-//
-// The contracts of a FIDL type |T| are as follows:
-//
-// |IsFidlType<T>| resolves to std::true_type.
-// |IsFidlMessage<T>| resolves to std::true_type iff |T| is a transactional message.
-// |T::MaxNumHandles| is an uint32_t specifying the upper bound on the number of contained handles.
-// |T::MaxSize| is an uint32_t specifying the upper bound on the message byte size.
-// It is std::numeric_limits<uint32_t>::max() if |T| is unbounded.
-// |T::type| is a fidl_type_t* pointing to the corresponding encoding table, if any.
-//
-
-namespace fidl {
-
-// A type trait that indicates whether the given type is a request/response type
-// i.e. has a FIDL message header.
-template <typename T> struct IsFidlMessage : public std::false_type {};
-
-// Code-gen will explicitly conform the generated FIDL transactional messages to IsFidlMessage.
-
-// A type trait that indicates whether the given type is allowed to appear in
-// generated binding APIs and can be encoded/decoded.
-// As a start, all handle types are supported.
-template <typename T> struct IsFidlType :
- public std::is_base_of<zx::object_base, T> {};
-
-// clang-format off
-// Specialize for primitives
-template <> struct IsFidlType<bool> : public std::true_type {};
-template <> struct IsFidlType<uint8_t> : public std::true_type {};
-template <> struct IsFidlType<uint16_t> : public std::true_type {};
-template <> struct IsFidlType<uint32_t> : public std::true_type {};
-template <> struct IsFidlType<uint64_t> : public std::true_type {};
-template <> struct IsFidlType<int8_t> : public std::true_type {};
-template <> struct IsFidlType<int16_t> : public std::true_type {};
-template <> struct IsFidlType<int32_t> : public std::true_type {};
-template <> struct IsFidlType<int64_t> : public std::true_type {};
-template <> struct IsFidlType<float> : public std::true_type {};
-template <> struct IsFidlType<double> : public std::true_type {};
-// clang-format on
-
-// String
-class StringView;
-template <> struct IsFidlType<StringView> : public std::true_type {};
-
-// Vector (conditional on element)
-template <typename E> class VectorView;
-template <typename E>
-struct IsFidlType<VectorView<E>> : public IsFidlType<E> {};
-
-// Code-gen will explicitly conform the generated FIDL structures to IsFidlType.
-
-} // namespace fidl
-
-#endif // LIB_FIDL_LLCPP_TRAITS_H_
diff --git a/pkg/fidl/include/lib/fidl/transport.h b/pkg/fidl/include/lib/fidl/transport.h
deleted file mode 100644
index 2da0d9c..0000000
--- a/pkg/fidl/include/lib/fidl/transport.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_TRANSPORT_H_
-#define LIB_FIDL_TRANSPORT_H_
-
-#include <zircon/compiler.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS
-
-// Writes |capacity| bytes from |buffer| to the control channel of |socket|.
-//
-// Blocks until |socket| is able to accept a control plane message.
-zx_status_t fidl_socket_write_control(zx_handle_t socket, const void* buffer,
- size_t capacity);
-
-// Reads |capacity| bytes from the control channel of |socket| to |buffer|.
-//
-// Blocks until a control plane message is able to be read from |socket|.
-//
-// The actual number of bytes reads from the control plan is returned in
-// |out_actual|.
-zx_status_t fidl_socket_read_control(zx_handle_t socket, void* buffer,
- size_t capacity, size_t* out_actual);
-
-// Issues a transaction on the control channel of |socket|.
-//
-// First, writes |capacity| bytes from |buffer| to the control channel of
-// |socket|. Second, reads |out_capacity| bytes from the control channel of
-// |socket| to |out_buffer|.
-//
-// Blocks until the transaction is complete.
-//
-// |buffer| and |out_buffer| may be aliased.
-//
-// The actual number of bytes reads from the control plan is returned in
-// |out_actual|.
-zx_status_t fidl_socket_call_control(zx_handle_t socket, const void* buffer,
- size_t capacity, void* out_buffer,
- size_t out_capacity, size_t* out_actual);
-
-__END_CDECLS
-
-#endif // LIB_FIDL_TRANSPORT_H_
diff --git a/pkg/fidl/message.cpp b/pkg/fidl/message.cpp
deleted file mode 100644
index 6857459..0000000
--- a/pkg/fidl/message.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/cpp/message.h>
-
-#include <string.h>
-
-#include <lib/fidl/coding.h>
-#include <lib/fidl/cpp/builder.h>
-
-#ifdef __Fuchsia__
-#include <zircon/syscalls.h>
-#endif
-
-namespace fidl {
-
-Message::Message() = default;
-
-Message::Message(BytePart bytes, HandlePart handles)
- : bytes_(static_cast<BytePart&&>(bytes)),
- handles_(static_cast<HandlePart&&>(handles)) {}
-
-Message::~Message() {
-#ifdef __Fuchsia__
- zx_handle_close_many(handles_.data(), handles_.actual());
-#endif
- ClearHandlesUnsafe();
-}
-
-Message::Message(Message&& other)
- : bytes_(static_cast<BytePart&&>(other.bytes_)),
- handles_(static_cast<HandlePart&&>(other.handles_)) {}
-
-Message& Message::operator=(Message&& other) {
- bytes_ = static_cast<BytePart&&>(other.bytes_);
- handles_ = static_cast<HandlePart&&>(other.handles_);
- return *this;
-}
-
-zx_status_t Message::Encode(const fidl_type_t* type,
- const char** error_msg_out) {
- uint32_t actual_handles = 0u;
- zx_status_t status = fidl_encode(type, bytes_.data(), bytes_.actual(),
- handles_.data(), handles_.capacity(),
- &actual_handles, error_msg_out);
- if (status == ZX_OK)
- handles_.set_actual(actual_handles);
- return status;
-}
-
-zx_status_t Message::Decode(const fidl_type_t* type,
- const char** error_msg_out) {
- zx_status_t status = fidl_decode(type, bytes_.data(), bytes_.actual(),
- handles_.data(), handles_.actual(),
- error_msg_out);
- ClearHandlesUnsafe();
- return status;
-}
-
-zx_status_t Message::Validate(const fidl_type_t* type,
- const char** error_msg_out) const {
- return fidl_validate(type, bytes_.data(), bytes_.actual(),
- handles_.actual(), error_msg_out);
-}
-
-#ifdef __Fuchsia__
-zx_status_t Message::Read(zx_handle_t channel, uint32_t flags) {
- uint32_t actual_bytes = 0u;
- uint32_t actual_handles = 0u;
- zx_status_t status = zx_channel_read(
- channel, flags, bytes_.data(), handles_.data(), bytes_.capacity(),
- handles_.capacity(), &actual_bytes, &actual_handles);
- if (status == ZX_OK) {
- bytes_.set_actual(actual_bytes);
- handles_.set_actual(actual_handles);
- }
- return status;
-}
-
-zx_status_t Message::Write(zx_handle_t channel, uint32_t flags) {
- zx_status_t status = zx_channel_write(channel, flags, bytes_.data(),
- bytes_.actual(), handles_.data(),
- handles_.actual());
- ClearHandlesUnsafe();
- return status;
-}
-
-zx_status_t Message::Call(zx_handle_t channel, uint32_t flags,
- zx_time_t deadline, Message* response) {
- zx_channel_call_args_t args;
- args.wr_bytes = bytes_.data();
- args.wr_handles = handles_.data();
- args.rd_bytes = response->bytes_.data();
- args.rd_handles = response->handles_.data();
- args.wr_num_bytes = bytes_.actual();
- args.wr_num_handles = handles_.actual();
- args.rd_num_bytes = response->bytes_.capacity();
- args.rd_num_handles = response->handles_.capacity();
- uint32_t actual_bytes = 0u;
- uint32_t actual_handles = 0u;
- zx_status_t status = zx_channel_call(channel, flags, deadline, &args,
- &actual_bytes, &actual_handles);
- ClearHandlesUnsafe();
- if (status == ZX_OK) {
- response->bytes_.set_actual(actual_bytes);
- response->handles_.set_actual(actual_handles);
- }
- return status;
-}
-#endif
-
-void Message::ClearHandlesUnsafe() {
- handles_.set_actual(0u);
-}
-
-} // namespace fidl
diff --git a/pkg/fidl/message_buffer.cpp b/pkg/fidl/message_buffer.cpp
deleted file mode 100644
index 54e2346..0000000
--- a/pkg/fidl/message_buffer.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/cpp/message_buffer.h>
-#include <zircon/assert.h>
-
-#include <stdlib.h>
-
-namespace fidl {
-namespace {
-
-uint64_t AddPadding(uint32_t offset) {
- constexpr uint32_t kMask = alignof(zx_handle_t) - 1;
- // Cast before addition to avoid overflow.
- return static_cast<uint64_t>(offset) + static_cast<uint64_t>(offset & kMask);
-}
-
-size_t GetAllocSize(uint32_t bytes_capacity, uint32_t handles_capacity) {
- return AddPadding(bytes_capacity) + sizeof(zx_handle_t) * handles_capacity;
-}
-
-} // namespace
-
-MessageBuffer::MessageBuffer(uint32_t bytes_capacity,
- uint32_t handles_capacity)
- : buffer_(static_cast<uint8_t*>(malloc(GetAllocSize(bytes_capacity, handles_capacity)))),
- bytes_capacity_(bytes_capacity),
- handles_capacity_(handles_capacity) {
- ZX_ASSERT_MSG(buffer_, "malloc returned NULL in MessageBuffer::MessageBuffer()");
-}
-
-MessageBuffer::~MessageBuffer() {
- free(buffer_);
-}
-
-zx_handle_t* MessageBuffer::handles() const {
- return reinterpret_cast<zx_handle_t*>(buffer_ + AddPadding(bytes_capacity_));
-}
-
-Message MessageBuffer::CreateEmptyMessage() {
- return Message(BytePart(bytes(), bytes_capacity()),
- HandlePart(handles(), handles_capacity()));
-}
-
-Builder MessageBuffer::CreateBuilder() {
- return Builder(bytes(), bytes_capacity());
-}
-
-} // namespace fidl
diff --git a/pkg/fidl/message_builder.cpp b/pkg/fidl/message_builder.cpp
deleted file mode 100644
index c178690..0000000
--- a/pkg/fidl/message_builder.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/cpp/message_builder.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-
-namespace fidl {
-
-MessageBuilder::MessageBuilder(const fidl_type_t* type,
- uint32_t bytes_capacity,
- uint32_t handles_capacity)
- : type_(type),
- buffer_(bytes_capacity, handles_capacity) {
- Reset();
-}
-
-MessageBuilder::~MessageBuilder() = default;
-
-zx_status_t MessageBuilder::Encode(Message* message_out,
- const char** error_msg_out) {
- *message_out = Message(Finalize(),
- HandlePart(buffer_.handles(),
- buffer_.handles_capacity()));
- return message_out->Encode(type_, error_msg_out);
-}
-
-void MessageBuilder::Reset() {
- Builder::Reset(buffer_.bytes(), buffer_.bytes_capacity());
- New<fidl_message_header_t>();
-}
-
-} // namespace fidl
diff --git a/pkg/fidl/meta.json b/pkg/fidl/meta.json
deleted file mode 100644
index be54c7d..0000000
--- a/pkg/fidl/meta.json
+++ /dev/null
@@ -1,67 +0,0 @@
-{
- "banjo_deps": [],
- "deps": [],
- "fidl_deps": [],
- "files": [
- "pkg/fidl/buffer_walker.h",
- "pkg/fidl/builder.cpp",
- "pkg/fidl/decoding.cpp",
- "pkg/fidl/encoding.cpp",
- "pkg/fidl/epitaph.c",
- "pkg/fidl/formatting.cpp",
- "pkg/fidl/handle_closing.cpp",
- "pkg/fidl/message.cpp",
- "pkg/fidl/message_buffer.cpp",
- "pkg/fidl/message_builder.cpp",
- "pkg/fidl/transport.cpp",
- "pkg/fidl/validating.cpp",
- "pkg/fidl/include/lib/fidl/coding.h",
- "pkg/fidl/include/lib/fidl/cpp/builder.h",
- "pkg/fidl/include/lib/fidl/cpp/message.h",
- "pkg/fidl/include/lib/fidl/cpp/message_buffer.h",
- "pkg/fidl/include/lib/fidl/cpp/message_builder.h",
- "pkg/fidl/include/lib/fidl/cpp/message_part.h",
- "pkg/fidl/include/lib/fidl/cpp/string_view.h",
- "pkg/fidl/include/lib/fidl/cpp/vector_view.h",
- "pkg/fidl/include/lib/fidl/epitaph.h",
- "pkg/fidl/include/lib/fidl/internal.h",
- "pkg/fidl/include/lib/fidl/llcpp/decoded_message.h",
- "pkg/fidl/include/lib/fidl/llcpp/encoded_message.h",
- "pkg/fidl/include/lib/fidl/llcpp/traits.h",
- "pkg/fidl/include/lib/fidl/transport.h"
- ],
- "headers": [
- "pkg/fidl/include/lib/fidl/coding.h",
- "pkg/fidl/include/lib/fidl/cpp/builder.h",
- "pkg/fidl/include/lib/fidl/cpp/message.h",
- "pkg/fidl/include/lib/fidl/cpp/message_buffer.h",
- "pkg/fidl/include/lib/fidl/cpp/message_builder.h",
- "pkg/fidl/include/lib/fidl/cpp/message_part.h",
- "pkg/fidl/include/lib/fidl/cpp/string_view.h",
- "pkg/fidl/include/lib/fidl/cpp/vector_view.h",
- "pkg/fidl/include/lib/fidl/epitaph.h",
- "pkg/fidl/include/lib/fidl/internal.h",
- "pkg/fidl/include/lib/fidl/llcpp/decoded_message.h",
- "pkg/fidl/include/lib/fidl/llcpp/encoded_message.h",
- "pkg/fidl/include/lib/fidl/llcpp/traits.h",
- "pkg/fidl/include/lib/fidl/transport.h"
- ],
- "include_dir": "pkg/fidl/include",
- "name": "fidl",
- "root": "pkg/fidl",
- "sources": [
- "pkg/fidl/buffer_walker.h",
- "pkg/fidl/builder.cpp",
- "pkg/fidl/decoding.cpp",
- "pkg/fidl/encoding.cpp",
- "pkg/fidl/epitaph.c",
- "pkg/fidl/formatting.cpp",
- "pkg/fidl/handle_closing.cpp",
- "pkg/fidl/message.cpp",
- "pkg/fidl/message_buffer.cpp",
- "pkg/fidl/message_builder.cpp",
- "pkg/fidl/transport.cpp",
- "pkg/fidl/validating.cpp"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/fidl/transport.cpp b/pkg/fidl/transport.cpp
deleted file mode 100644
index 253b5ec..0000000
--- a/pkg/fidl/transport.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifdef __Fuchsia__
-
-#include <lib/fidl/transport.h>
-#include <zircon/assert.h>
-#include <zircon/syscalls.h>
-
-zx_status_t fidl_socket_write_control(zx_handle_t socket, const void* buffer,
- size_t capacity) {
- for (;;) {
- zx_status_t status = zx_socket_write(socket, ZX_SOCKET_CONTROL, buffer,
- capacity, nullptr);
- if (status != ZX_ERR_SHOULD_WAIT) {
- return status;
- }
-
- zx_signals_t observed = ZX_SIGNAL_NONE;
- status = zx_object_wait_one(socket, ZX_SOCKET_CONTROL_WRITABLE | ZX_SOCKET_PEER_CLOSED,
- ZX_TIME_INFINITE, &observed);
- if (status != ZX_OK) {
- return status;
- }
-
- if (observed & ZX_SOCKET_PEER_CLOSED) {
- return ZX_ERR_PEER_CLOSED;
- }
-
- ZX_ASSERT(observed & ZX_SOCKET_CONTROL_WRITABLE);
- }
-}
-
-zx_status_t fidl_socket_read_control(zx_handle_t socket, void* buffer,
- size_t capacity, size_t* out_actual) {
- for (;;) {
- zx_status_t status = zx_socket_read(socket, ZX_SOCKET_CONTROL, buffer,
- capacity, out_actual);
- if (status != ZX_ERR_SHOULD_WAIT) {
- return status;
- }
-
- zx_signals_t observed = ZX_SIGNAL_NONE;
- status = zx_object_wait_one(socket, ZX_SOCKET_CONTROL_READABLE | ZX_SOCKET_PEER_CLOSED,
- ZX_TIME_INFINITE, &observed);
- if (status != ZX_OK) {
- return status;
- }
-
- if (observed & ZX_SOCKET_CONTROL_READABLE) {
- continue;
- }
-
- ZX_ASSERT(observed & ZX_SOCKET_PEER_CLOSED);
- return ZX_ERR_PEER_CLOSED;
- }
-}
-
-zx_status_t fidl_socket_call_control(zx_handle_t socket, const void* buffer,
- size_t capacity, void* out_buffer,
- size_t out_capacity, size_t* out_actual) {
- zx_status_t status = fidl_socket_write_control(socket, buffer, capacity);
- if (status != ZX_OK) {
- return status;
- }
- return fidl_socket_read_control(socket, out_buffer, out_capacity, out_actual);
-}
-
-#endif
diff --git a/pkg/fidl/validating.cpp b/pkg/fidl/validating.cpp
deleted file mode 100644
index 342face..0000000
--- a/pkg/fidl/validating.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fidl/coding.h>
-
-#include <stdalign.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <lib/fidl/internal.h>
-#include <zircon/assert.h>
-#include <zircon/compiler.h>
-
-#include "buffer_walker.h"
-
-// TODO(kulakowski) Design zx_status_t error values.
-
-namespace {
-
-class FidlValidator final : public fidl::internal::BufferWalker<FidlValidator, false, false> {
- typedef fidl::internal::BufferWalker<FidlValidator, false, false> Super;
-
-public:
- FidlValidator(const fidl_type_t* type, const void* bytes, uint32_t num_bytes,
- uint32_t num_handles, const char** out_error_msg)
- : Super(type), bytes_(static_cast<const uint8_t*>(bytes)), num_bytes_(num_bytes),
- num_handles_(num_handles), out_error_msg_(out_error_msg) {}
-
- void Walk() {
- Super::Walk();
- if (status_ == ZX_OK && handle_idx() != num_handles()) {
- SetError("message did not contain the specified number of handles");
- return;
- }
- }
-
- const uint8_t* bytes() const { return bytes_; }
- uint32_t num_bytes() const { return num_bytes_; }
- uint32_t num_handles() const { return num_handles_; }
-
- bool ValidateOutOfLineStorageClaim(const void* a, const void* b) {
- return true;
- }
-
- void UnclaimedHandle(const zx_handle_t* out_handle) {}
- void ClaimedHandle(const zx_handle_t* out_handle, uint32_t idx) {}
-
- template <class T>
- void UpdatePointer(const T* const* p, const T* v) {}
-
- PointerState GetPointerState(const void* ptr) const {
- return static_cast<PointerState>(*static_cast<const uintptr_t*>(ptr));
- }
- HandleState GetHandleState(zx_handle_t p) const {
- return static_cast<HandleState>(p);
- }
-
- void SetError(const char* error_msg) {
- status_ = ZX_ERR_INVALID_ARGS;
- if (out_error_msg_ != nullptr) {
- *out_error_msg_ = error_msg;
- }
- }
-
- zx_status_t status() const { return status_; }
-
-private:
- // Message state passed in to the constructor.
- const uint8_t* const bytes_;
- const uint32_t num_bytes_;
- const uint32_t num_handles_;
- const char** const out_error_msg_;
- zx_status_t status_ = ZX_OK;
-};
-
-} // namespace
-
-zx_status_t fidl_validate(const fidl_type_t* type, const void* bytes, uint32_t num_bytes,
- uint32_t num_handles, const char** out_error_msg) {
- FidlValidator validator(type, bytes, num_bytes, num_handles, out_error_msg);
- validator.Walk();
- return validator.status();
-}
-
-zx_status_t fidl_validate_msg(const fidl_type_t* type, const fidl_msg_t* msg,
- const char** out_error_msg) {
- return fidl_validate(type, msg->bytes, msg->num_bytes, msg->num_handles,
- out_error_msg);
-}
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/binding.h b/pkg/fidl_cpp/include/lib/fidl/cpp/binding.h
deleted file mode 100644
index 05c0637..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/binding.h
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_BINDING_H_
-#define LIB_FIDL_CPP_BINDING_H_
-
-#include <lib/async/dispatcher.h>
-#include <lib/fit/function.h>
-#include <lib/zx/channel.h>
-#include <zircon/assert.h>
-
-#include <memory>
-#include <utility>
-
-#include "lib/fidl/cpp/interface_handle.h"
-#include "lib/fidl/cpp/interface_ptr.h"
-#include "lib/fidl/cpp/interface_request.h"
-#include "lib/fidl/cpp/internal/stub_controller.h"
-
-namespace fidl {
-
-// Binds the implementation of |Interface| to a channel.
-//
-// The |Binding| listens for incoming messages on the channel, decodes them, and
-// calls the appropriate method on the bound implementation. If the message
-// expects a reply, the |Binding| creates callbacks that encode and send
-// reply messages when called.
-//
-// When the |Binding| object is destroyed, the binding between the channel
-// and the interface is torn down and the channel is closed, leaving the
-// |Binding| in an unbound state.
-//
-// The implementation pointer type of the binding is also parameterized,
-// allowing the use of smart pointer types such as |std::unique_ptr| to
-// reference the implementation.
-//
-// Example:
-//
-// #include "foo.fidl.h"
-//
-// class FooImpl : public Foo {
-// public:
-// explicit FooImpl(InterfaceRequest<Foo> request)
-// : binding_(this, std::move(request)) {}
-//
-// // Foo implementation here.
-//
-// private:
-// Binding<Foo> binding_;
-// };
-//
-// After the |Binding| has been bound to an implementation, the implementation
-// will receive methods calls from the remote endpoint of the channel on the
-// async_t on which the |InterfaceRequest| was bound. By default this is the
-// thread on which the binding occurred.
-//
-// See also:
-//
-// * |InterfacePtr|, which is the client analog of a |Binding|.
-template <typename Interface, typename ImplPtr = Interface*>
-class Binding {
- public:
- // Constructs an incomplete binding that will use the implementation |impl|.
- //
- // The binding may be completed with a subsequent call to the |Bind| method.
- // Does not take ownership of |impl|, which must outlive the binding.
- explicit Binding(ImplPtr impl)
- : impl_(std::forward<ImplPtr>(impl)), stub_(&*this->impl()) {
- controller_.set_stub(&stub_);
- stub_.set_controller(&controller_);
- }
-
- // Constructs a completed binding of |channel| to implementation |impl|.
- //
- // Does not take ownership of |impl|, which must outlive the binding.
- //
- // If the |Binding| cannot be bound to the given |channel| (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|), the |Binding| will be constructed
- // in an unbound state.
- //
- // Uses the given async_dispatcher_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. If |dispatcher| is null, the current thread must
- // have a default async_dispatcher_t.
- Binding(ImplPtr impl, zx::channel channel,
- async_dispatcher_t* dispatcher = nullptr)
- : Binding(std::forward<ImplPtr>(impl)) {
- Bind(std::move(channel), dispatcher);
- }
-
- // Constructs a completed binding of |impl| to the channel in |request|.
- //
- // Does not take ownership of |impl|, which must outlive the binding.
- //
- // If the |Binding| cannot be bound to the given |channel| (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|), the |Binding| will be constructed
- // in an unbound state.
- //
- // Uses the given async_dispatcher_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. If |dispatcher| is null, the current thread must
- // have a default async_dispatcher_t.
- Binding(ImplPtr impl, InterfaceRequest<Interface> request,
- async_dispatcher_t* dispatcher = nullptr)
- : Binding(std::forward<ImplPtr>(impl)) {
- Bind(request.TakeChannel(), dispatcher);
- }
-
- Binding(const Binding&) = delete;
- Binding& operator=(const Binding&) = delete;
-
- // Completes a binding by creating a new channel, binding one endpoint to
- // the previously specified implementation and returning the other endpoint.
- //
- // If |NewBinding| fails to create the underlying channel, the returned
- // |InterfaceHandle| will return false from |is_valid()|.
- //
- // Uses the given async_dispatcher_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. If |dispatcher| is null, the current thread must
- // have a default async_dispatcher_t.
- InterfaceHandle<Interface> NewBinding(
- async_dispatcher_t* dispatcher = nullptr) {
- InterfaceHandle<Interface> client;
- Bind(client.NewRequest().TakeChannel(), dispatcher);
- return client;
- }
-
- // Binds the previously specified implementation to the given |channel|.
- //
- // If the |Binding| was prevously bound to another channel, that channel is
- // closed.
- //
- // Uses the given async_dispatcher_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. If |dispatcher| is null, the current thread must
- // have a default async_dispatcher_t.
- //
- // Returns an error if the binding was not able to be created (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|).
- zx_status_t Bind(zx::channel channel,
- async_dispatcher_t* dispatcher = nullptr) {
- return controller_.reader().Bind(std::move(channel), dispatcher);
- }
-
- // Binds the previously specified implementation to the given
- // |InterfaceRequest|.
- //
- // If the |Binding| was prevously bound to another channel, that channel is
- // closed.
- //
- // Uses the given async_dispatcher_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. If |dispatcher| is null, the current thread must
- // have a default async_dispatcher_t.
- //
- // Returns an error if the binding was not able to be created (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|).
- zx_status_t Bind(InterfaceRequest<Interface> request,
- async_dispatcher_t* dispatcher = nullptr) {
- return Bind(request.TakeChannel(), dispatcher);
- }
-
- // Unbinds the underlying channel from this binding and returns it so it can
- // be used in another context, such as on another thread or with a different
- // implementation.
- //
- // After this function returns, the |Binding| is ready to be bound to another
- // channel.
- InterfaceRequest<Interface> Unbind() {
- return InterfaceRequest<Interface>(controller_.reader().Unbind());
- }
-
- // Sends an Epitaph over the bound channel corresponding to the error passed
- // as a parameter, closes the channel, and unbinds it. An Epitaph is the last
- // message sent over a channel before a close operation; for the purposes of
- // this function, it can be thought of as a return code. See the FIDL
- // language spec for more information about Epitaphs.
- //
- // The return value can be any of the return values of zx_channel_write.
- zx_status_t Close(zx_status_t epitaph_value) {
- return controller_.reader().Close(epitaph_value);
- }
-
- // Blocks the calling thread until either a message arrives on the previously
- // bound channel or an error occurs.
- //
- // Returns an error if waiting for the message, reading the message, or
- // processing the message fails. If the error results in the channel being
- // closed, the error handler will be called synchronously before this
- // method returns.
- //
- // This method can be called only if this |Binding| is currently bound to a
- // channel.
- zx_status_t WaitForMessage() {
- return controller_.reader().WaitAndDispatchOneMessageUntil(
- zx::time::infinite());
- }
-
- // Sets an error handler that will be called if an error causes the underlying
- // channel to be closed.
- //
- // If the error is being reported because an error occurred on the local side
- // of the channel, the zx_status_t of that error will be passed as the
- // parameter to the handler.
- //
- // If an Epitaph was present on the channel, its error value will be passed as
- // the parameter. See the FIDL language specification for more detail on
- // Epitaphs.
- //
- // For example, the error handler will be called if the remote side of the
- // channel sends an invalid message. When the error handler is called, the
- // |Binding| will no longer be bound to the channel.
- void set_error_handler(fit::function<void(zx_status_t)> error_handler) {
- controller_.reader().set_error_handler(std::move(error_handler));
- }
-
- // The implementation used by this |Binding| to process incoming messages.
- const ImplPtr& impl() const { return impl_; }
-
- // The interface for sending events back to the client.
- typename Interface::EventSender_& events() { return stub_; }
-
- // Whether this |Binding| is currently listening to a channel.
- bool is_bound() const { return controller_.reader().is_bound(); }
-
- // The underlying channel.
- const zx::channel& channel() const { return controller_.reader().channel(); }
-
- private:
- const ImplPtr impl_;
- typename Interface::Stub_ stub_;
- internal::StubController controller_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_BINDING_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/binding_set.h b/pkg/fidl_cpp/include/lib/fidl/cpp/binding_set.h
deleted file mode 100644
index c505344..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/binding_set.h
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_BINDING_SET_H_
-#define LIB_FIDL_CPP_BINDING_SET_H_
-
-#include <algorithm>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include <lib/fit/function.h>
-
-#include "lib/fidl/cpp/binding.h"
-
-namespace fidl {
-
-// Manages a set of bindings to implementations owned by the bound channels.
-//
-// The implementation pointer type of the binding is also parameterized,
-// allowing the use of smart pointer types such as |std::unique_ptr<>| to
-// reference the implementation.
-//
-// See also:
-//
-// * |InterfacePtrSet|, which is the client analog of |BindingSet|.
-template <typename Interface, typename ImplPtr = Interface*>
-class BindingSet {
- public:
- using Binding = ::fidl::Binding<Interface, ImplPtr>;
- using StorageType = std::vector<std::unique_ptr<Binding>>;
-
- using iterator = typename StorageType::iterator;
-
- BindingSet() = default;
-
- BindingSet(const BindingSet&) = delete;
- BindingSet& operator=(const BindingSet&) = delete;
-
- // Adds a binding to the set.
- //
- // The given |ImplPtr| is bound to the channel underlying the
- // |InterfaceRequest|. The binding is removed (and the |~ImplPtr| called)
- // when the created binding has an error (e.g., if the remote endpoint of
- // the channel sends an invalid message).
- //
- // Whether this method takes ownership of |impl| depends on |ImplPtr|. If
- // |ImplPtr| is a raw pointer, then this method does not take ownership of
- // |impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the
- // binding generates an error will delete |impl| because |~ImplPtr| is
- // |~unique_ptr|, which deletes |impl|.
- void AddBinding(ImplPtr impl, InterfaceRequest<Interface> request,
- async_dispatcher_t* dispatcher = nullptr) {
- bindings_.push_back(std::make_unique<Binding>(
- std::forward<ImplPtr>(impl), std::move(request), dispatcher));
- auto* binding = bindings_.back().get();
- // Set the connection error handler for the newly added Binding to be a
- // function that will erase it from the vector.
- binding->set_error_handler([binding, this](zx_status_t status) {
- this->RemoveOnError(binding);
- });
- }
-
- // Adds a binding to the set for the given implementation.
- //
- // Creates a channel for the binding and returns the client endpoint of
- // the channel as an |InterfaceHandle|. If |AddBinding| fails to create the
- // underlying channel, the returned |InterfaceHandle| will return false from
- // |is_valid()|.
- //
- // The given |ImplPtr| is bound to the newly created channel. The binding is
- // removed (and the |~ImplPtr| called) when the created binding has an error
- // (e.g., if the remote endpoint of the channel sends an invalid message).
- //
- // Whether this method takes ownership of |impl| depends on |ImplPtr|. If
- // |ImplPtr| is a raw pointer, then this method does not take ownership of
- // |impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the
- // binding generates an error will delete |impl| because |~ImplPtr| is
- // |~unique_ptr|, which deletes |impl|.
- InterfaceHandle<Interface> AddBinding(
- ImplPtr impl, async_dispatcher_t* dispatcher = nullptr) {
- InterfaceHandle<Interface> handle;
- InterfaceRequest<Interface> request = handle.NewRequest();
- if (!request)
- return nullptr;
- AddBinding(std::forward<ImplPtr>(impl), std::move(request), dispatcher);
- return handle;
- }
-
- // Returns an InterfaceRequestHandler that binds the incoming
- // InterfaceRequests this object.
- InterfaceRequestHandler<Interface> GetHandler(
- ImplPtr impl, async_dispatcher_t* dispatcher = nullptr) {
- return [this, impl, dispatcher](InterfaceRequest<Interface> request) {
- AddBinding(impl, std::move(request), dispatcher);
- };
- }
-
- // Removes all the bindings from the set.
- //
- // Closes all the channels associated with this |BindingSet|.
- // Bindings are destroyed AFTER it is removed from the bindings set. An
- // example of when this is useful is if an error handler on a binding has
- // some behavior where it needs to read from the binding set; the set would
- // then properly reflect that the binding is not present in the set.
- void CloseAll() {
- auto bindings_local = std::move(bindings_);
- bindings_.clear();
- }
-
- // The number of bindings in this |BindingSet|.
- size_t size() const { return bindings_.size(); }
-
- // Called when the last binding has been removed from this |BindingSet|.
- //
- // This function is not called by |CloseAll| or by |~BindingSet|.
- void set_empty_set_handler(fit::closure empty_set_handler) {
- empty_set_handler_ = std::move(empty_set_handler);
- }
-
- // The bindings stored in this set.
- //
- // This collection of bindings can be invalidated when a |Binding| in the
- // set encounters a connection error because connection errors causes the
- // |BindingSet| to remove the |Binding| from the set.
- const StorageType& bindings() const { return bindings_; }
-
- private:
- // Called when a binding has an error to remove the binding from the set.
- void RemoveOnError(Binding* binding) {
- auto it = std::find_if(bindings_.begin(), bindings_.end(),
- [binding](const std::unique_ptr<Binding>& b) {
- return b.get() == binding;
- });
- ZX_DEBUG_ASSERT(it != bindings_.end());
-
- {
- // Move ownership of binding out of storage, such that the binding is
- // destroyed AFTER it is removed from the bindings.
- auto binding_local = std::move(*it);
- binding_local->set_error_handler(nullptr);
- bindings_.erase(it);
- }
-
- if (bindings_.empty() && empty_set_handler_)
- empty_set_handler_();
- }
-
- StorageType bindings_;
- fit::closure empty_set_handler_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_BINDING_SET_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/enum.h b/pkg/fidl_cpp/include/lib/fidl/cpp/enum.h
deleted file mode 100644
index 19ec1eb..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/enum.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_ENUM_H_
-#define LIB_FIDL_CPP_ENUM_H_
-
-#include <type_traits>
-
-namespace fidl {
-
-// Converts an enum value to its underlying type.
-template <typename TEnum>
-constexpr auto ToUnderlying(TEnum value) ->
- typename std::underlying_type<TEnum>::type {
- return static_cast<typename std::underlying_type<TEnum>::type>(value);
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_ENUM_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr.h b/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr.h
deleted file mode 100644
index e1af79a..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr.h
+++ /dev/null
@@ -1,305 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERFACE_PTR_H_
-#define LIB_FIDL_CPP_INTERFACE_PTR_H_
-
-#include <algorithm>
-#include <cstddef>
-#include <utility>
-
-#include <lib/fit/function.h>
-#include <lib/zx/channel.h>
-#include <zircon/assert.h>
-
-#include "lib/fidl/cpp/interface_handle.h"
-#include "lib/fidl/cpp/interface_request.h"
-#include "lib/fidl/cpp/internal/proxy_controller.h"
-
-namespace fidl {
-
-// A client interface to a remote implementation of |Interface|.
-//
-// An |InterfacePtr| implements |Interface| by proxying calls through a
-// |channel| to a remote implementation of |Interface|. Method calls on the
-// |Interface| proxy are encoded and sent through the bound channel to the
-// remote endpoint, which processes them. If the remote endpoint has not yet
-// been bound to an implementation, messages sent on the channel are buffered
-// by the channel, allowing for *pipelined* operation.
-//
-// The |InterfacePtr| also keeps state about the connection and about
-// outstanding request transactions that are expecting replies. When a the
-// |InterfacePtr| receives a reply to an outstanding transaction, the
-// |InterfacePtr| decodes the reply and calls the appropriate callback on the
-// thread on which the |InterfacePtr| was bound.
-//
-// You need to bind the |InterfacePtr| before calling any |Interface| methods.
-// There are a number of ways to bind the |InterfacePtr|. See |NewRequest|,
-// |Bind|, and the |Bind| method on |InterfaceHandle|.
-//
-// If the underlying channel experiences an error, the |InterfacePtr| will
-// unbind from the channel and call its error handler.
-//
-// This class is thread-hostile, as is the local proxy it manages. All calls to
-// this class or the proxy should be from the thread on which the
-// |InterfacePtr| was bound. If you need to move the proxy to a different
-// thread, extract the |InterfaceHandle| by calling |Unbind|, and pass the
-// |InterfaceHandle| to a different thread, which the |InterfaceHandle| can be
-// bound to an |InterfacePtr| again. This operation destroys the state about
-// outstanding request transactions that are expecting replies.
-//
-// See also:
-//
-// * |Binding|, which is the server analog of an |InterfacePtr|.
-// * |SynchronousInterfacePtr|, which is a synchronous client interface to a
-// remote implementation.
-template <typename Interface>
-class InterfacePtr {
- public:
- using Proxy = typename Interface::Proxy_;
-
- // Creates an unbound |InterfacePtr|.
- InterfacePtr() : impl_(new Impl) {}
- InterfacePtr(std::nullptr_t) : InterfacePtr() {}
-
- InterfacePtr(const InterfacePtr& other) = delete;
- InterfacePtr& operator=(const InterfacePtr& other) = delete;
-
- InterfacePtr(InterfacePtr&& other) : impl_(std::move(other.impl_)) {
- other.impl_.reset(new Impl);
- }
-
- InterfacePtr& operator=(InterfacePtr&& other) {
- if (this != &other) {
- impl_ = std::move(other.impl_);
- other.impl_.reset(new Impl);
- }
- return *this;
- }
-
- // Bind the |InterfacePtr| to one endpoint of a newly created channel and
- // return the other endpoint as an |InterfaceRequest|.
- //
- // Typically, the returned |InterfaceRequest| will be sent to a remote process
- // to be bound to an implementation of |Interface| using a |Binding| object.
- //
- // After calling this method, clients can start calling methods on this
- // |InterfacePtr|. The methods will write messages into the underlying
- // channel created by |NewRequest|, where they will be buffered by the
- // underlying channel until the |InterfaceRequest| is bound to an
- // implementation of |Interface|, potentially in a remote process.
- //
- // Uses the given async_t (e.g., a message loop) in order to read messages
- // from the channel and to monitor the channel for |ZX_CHANNEL_PEER_CLOSED|.
- // If |dispatcher| is null, the current thread must have a default async_t.
- //
- // # Example
- //
- // Given the following interface:
- //
- // interface Database {
- // OpenTable(request<Table> table);
- // };
- //
- // The client can use the |NewRequest| method to create the |InterfaceRequest|
- // object needed by the |OpenTable| method:
- //
- // DatabasePtr database = ...; // Connect to database.
- // TablePtr table;
- // database->OpenTable(table.NewRequest());
- //
- // The client can call methods on |table| immediately.
- InterfaceRequest<Interface> NewRequest(
- async_dispatcher_t* dispatcher = nullptr) {
- zx::channel h1;
- zx::channel h2;
- if (zx::channel::create(0, &h1, &h2) != ZX_OK ||
- Bind(std::move(h1), dispatcher) != ZX_OK)
- return nullptr;
- return InterfaceRequest<Interface>(std::move(h2));
- }
-
- // Binds the |InterfacePtr| to the given |channel|.
- //
- // The |InterfacePtr| expects the remote end of the |channel| to speak the
- // protocol defined by |Interface|. Unlike the |Bind| overload that takes a
- // |InterfaceHandle| parameter, this |Bind| overload lacks type safety.
- //
- // If the |InterfacePtr| was prevously bound to another channel, that channel
- // is closed. If the |channel| is invalid, then this method will effectively
- // unbind the |InterfacePtr|. A more direct way to have that effect is to call
- // |Unbind|.
- //
- // Uses the given async_t (e.g., a message loop) in order to read messages
- // from the channel and to monitor the channel for |ZX_CHANNEL_PEER_CLOSED|.
- // If |dispatcher| is null, the current thread must have a default async_t.
- //
- // Returns an error if the binding was not able to be created (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|).
- zx_status_t Bind(zx::channel channel,
- async_dispatcher_t* dispatcher = nullptr) {
- return impl_->controller.reader().Bind(std::move(channel), dispatcher);
- }
-
- // Binds the |InterfacePtr| to the given |InterfaceHandle|.
- //
- // The |InterfacePtr| expects the remote end of the |channel| to speak the
- // protocol defined by |Interface|. Unlike the |Bind| overload that takes a
- // |channel| parameter, this |Bind| overload provides type safety.
- //
- // If the |InterfacePtr| was prevously bound to another channel, that channel
- // is closed. If the |InterfaceHandle| is invalid, then this method will
- // effectively unbind the |InterfacePtr|. A more direct way to have that
- // effect is to call |Unbind|.
- //
- // Uses the given async_t (e.g., a message loop) in order to read messages
- // from the channel and to monitor the channel for |ZX_CHANNEL_PEER_CLOSED|.
- // If |dispatcher| is null, the current thread must have a default async_t.
- //
- // Returns an error if the binding was not able to be created (e.g., because
- // the |channel| lacks |ZX_RIGHT_WAIT|).
- zx_status_t Bind(InterfaceHandle<Interface> handle,
- async_dispatcher_t* dispatcher = nullptr) {
- return Bind(handle.TakeChannel(), dispatcher);
- }
-
- // Unbinds the underlying channel from the |InterfacePtr|.
- //
- // The underlying channel is returned as an |InterfaceHandle|, which is safe
- // to transport to another thread or process. Any callbacks waiting for
- // replies from the remote endpoint are discarded and any outstanding
- // transaction state is erased.
- //
- // After this method returns, a subsequent call to |Bind| is required before
- // calling any additional |Interface| methods.
- InterfaceHandle<Interface> Unbind() {
- return InterfaceHandle<Interface>(impl_->controller.reader().Unbind());
- }
-
- // Whether this |InterfacePtr| is currently bound to a channel.
- //
- // If the |InterfacePtr| is bound to a channel, the |InterfacePtr| has
- // affinity for the thread on which it was bound and calls to |Interface|
- // methods are proxied to the remote endpoint of the channel.
- //
- // See also:
- //
- // * |Bind|, which binds a channel to this |InterfacePtr|.
- // * |Unbind|, which unbinds a channel from this |InterfacePtr|.
- bool is_bound() const { return impl_->controller.reader().is_bound(); }
-
- // Whether this |InterfacePtr| is currently bound to a channel.
- //
- // See |is_bound| for details.
- explicit operator bool() const { return is_bound(); }
-
- // The |Interface| proxy associated with this |InterfacePtr|.
- //
- // When this |InterfacePtr| is bound, method calls on this |Interface| will
- // be proxied to the remote endpoint of the connection. Methods that expect
- // replies will retain the supplied callbacks until the |InterfacePtr| either
- // receives a reply to that transaction or the |InterfacePtr| is unbound from
- // the channel.
- //
- // When this |InterfacePtr| is not bound, it is an error to call methods on
- // the returned |Interface|.
- //
- // The returned |Interface| is thread-hostile and can be used only on the
- // thread on which the |InterfacePtr| was bound.
- Interface* get() const { return &impl_->proxy; }
- Interface* operator->() const { return get(); }
- Interface& operator*() const { return *get(); }
-
- // An object on which to register for FIDL events.
- //
- // Arriving events are dispatched to the callbacks stored on this object.
- // Events for unbound callbacks are ignored.
- Proxy& events() const { return impl_->proxy; }
-
-#ifdef FIDL_ENABLE_LEGACY_WAIT_FOR_RESPONSE
-
- // DEPRECATED: Using InterfaceSyncPtr instead. If used in a test, consider
- // spinning the async::Loop instead.
- //
- // Blocks the calling thread until either a message arrives on the previously
- // bound channel or an error occurs.
- //
- // Returns an error if waiting for the message, reading the message, or
- // processing the message fails. If the error results in the channel being
- // closed, the error handler will be called synchronously before this
- // method returns.
- //
- // This method can be called only if this |InterfacePtr| is currently bound to
- // a channel.
- zx_status_t WaitForResponse() {
- return WaitForResponseUntil(zx::time::infinite());
- }
-
- // DEPRECATED: Using InterfaceSyncPtr instead. If used in a test, consider
- // spinning the async::Loop instead.
- //
- // Blocks the calling thread until either a message arrives on the previously
- // bound channel, an error occurs, or the |deadline| is exceeded.
- //
- // Returns ZX_ERR_TIMED_OUT if the deadline is exceeded.
- //
- // Returns an error if waiting for the message, reading the message, or
- // processing the message fails. If the error results in the channel being
- // closed, the error handler will be called synchronously before this
- // method returns.
- //
- // This method can be called only if this |InterfacePtr| is currently bound to
- // a channel.
- zx_status_t WaitForResponseUntil(zx::time deadline) {
- return impl_->controller.reader().WaitAndDispatchOneMessageUntil(deadline);
- }
-#endif
-
- // Sets an error handler that will be called if an error causes the underlying
- // channel to be closed.
- //
- // If the error is being reported because an error occurred on the local side
- // of the channel, the zx_status_t of that error will be passed as the
- // parameter to the handler.
- //
- // If an Epitaph was present on the channel, its error value will be passed as
- // the parameter. See the FIDL language specification for more detail on
- // Epitaphs.
- //
- // For example, the error handler will be called if the remote side of the
- // channel sends an invalid message. When the error handler is called, the
- // |Binding| will no longer be bound to the channel.
- void set_error_handler(fit::function<void(zx_status_t)> error_handler) {
- impl_->controller.reader().set_error_handler(std::move(error_handler));
- }
-
- // The underlying channel.
- const zx::channel& channel() const {
- return impl_->controller.reader().channel();
- }
-
- // Closes the channel and sends an Epitaph with the given error. See the FIDL
- // language spec for information about Epitaphs.
- //
- // The return value can be any of the return values of zx_channel_write.
- zx_status_t Close(zx_status_t epitaph_value) {
- return impl_->controller.reader().Close(epitaph_value);
- }
-
- private:
- struct Impl;
-
- std::unique_ptr<Impl> impl_;
-};
-
-template <typename T>
-struct InterfacePtr<T>::Impl {
- Impl() : proxy(&controller) { controller.set_proxy(&proxy); }
- internal::ProxyController controller;
- mutable Proxy proxy;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERFACE_PTR_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr_set.h b/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr_set.h
deleted file mode 100644
index 8d54420..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr_set.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERFACE_PTR_SET_H_
-#define LIB_FIDL_CPP_INTERFACE_PTR_SET_H_
-
-#include <zircon/assert.h>
-#include <vector>
-
-#include "lib/fidl/cpp/interface_ptr.h"
-
-namespace fidl {
-
-// Contains a set of |InterfacePtr| objects, each with their own channels.
-//
-// An |InterfacePtr| is removed from the set and destroyed when its underlying
-// channel experiences an error. When the set is destroyed, all the underlying
-// channels are closed.
-//
-// An |InterfacePtrSet| is useful for broadcasting messages to a set of clients,
-// each with their own implementation of |Interface|.
-//
-// See also:
-//
-// * |BindingSet|, which is the server analog of an |InterfacePtrSet|.
-template <typename Interface>
-class InterfacePtrSet {
- public:
- using StorageType = std::vector<std::unique_ptr<InterfacePtr<Interface>>>;
- using Ptr = InterfacePtr<Interface>;
-
- // Creates an empty |InterfacePtrSet|.
- InterfacePtrSet() = default;
-
- InterfacePtrSet(const InterfacePtrSet& other) = delete;
- InterfacePtrSet& operator=(const InterfacePtrSet& other) = delete;
-
- // Adds the given |InterfacePtr| to the set.
- //
- // The |InterfacePtr| must already be bound to a channel. The |InterfacePtr|
- // will be removed from the set when its underlying channel experiences an
- // error.
- void AddInterfacePtr(InterfacePtr<Interface> ptr) {
- ZX_DEBUG_ASSERT(ptr.is_bound());
- // Allocated a new |InterfacePtr| so that we can have a unique value to use
- // as a key for removing the InterfacePtr. Otherwise, we'll lose track of
- // the InterfacePtr when the vector resizes.
- ptrs_.push_back(std::make_unique<Ptr>(std::move(ptr)));
- auto* pointer = ptrs_.back().get();
- pointer->set_error_handler(
- [pointer, this](zx_status_t status) { this->RemoveOnError(pointer); });
- }
-
- // The |InterfacePtr| objects stored in this set.
- //
- // This collection of bindings can be invalidated when an |InterfacePtr| in
- // the set encounters a connection error because connection errors causes the
- // |InterfacePtrSet| to remove the |InterfacePtr| from the set.
- const StorageType& ptrs() const { return ptrs_; }
-
- // Closes all channels associated with |InterfacePtr| objects in the set.
- //
- // After this method returns, the set is empty.
- void CloseAll() { ptrs_.clear(); }
-
- // The number of |InterfacePtr| objects in the set.
- //
- // This number might be smaller than the number of |InterfacePtr| objects
- // added to the set if some of the underlying channels have experienced an
- // error.
- size_t size() const { return ptrs_.size(); }
-
- private:
- // Removes the given |pointer| from the set.
- //
- // Called from the error handler callback for |pointer|.
- void RemoveOnError(Ptr* pointer) {
- auto it = std::find_if(ptrs_.begin(), ptrs_.end(),
- [pointer](const std::unique_ptr<Ptr>& p) {
- return p.get() == pointer;
- });
- ZX_DEBUG_ASSERT(it != ptrs_.end());
- ptrs_.erase(it);
- }
-
- // We use |unique_ptr| rather than just |InterfacePtr| so that we can keep
- // track of the |InterfacePtr| objects after the |vector| resizes and moves
- // its contents to its new buffer.
- StorageType ptrs_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERFACE_PTR_SET_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/header.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/header.h
deleted file mode 100644
index 60ec272..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/header.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_HEADER_H_
-#define LIB_FIDL_CPP_INTERNAL_HEADER_H_
-
-#include <functional>
-#include <ostream>
-
-#include <lib/fidl/cpp/array.h>
-#include <lib/fit/function.h>
-
-#ifdef __Fuchsia__
-#include <lib/zx/bti.h>
-#include <lib/zx/channel.h>
-#include <lib/zx/debuglog.h>
-#include <lib/zx/event.h>
-#include <lib/zx/eventpair.h>
-#include <lib/zx/fifo.h>
-#include <lib/zx/guest.h>
-#include <lib/zx/handle.h>
-#include <lib/zx/interrupt.h>
-#include <lib/zx/job.h>
-#include <lib/zx/log.h>
-#include <lib/zx/object.h>
-#include <lib/zx/pmt.h>
-#include <lib/zx/port.h>
-#include <lib/zx/process.h>
-#include <lib/zx/profile.h>
-#include <lib/zx/resource.h>
-#include <lib/zx/socket.h>
-#include <lib/zx/suspend_token.h>
-#include <lib/zx/task.h>
-#include <lib/zx/thread.h>
-#include <lib/zx/time.h>
-#include <lib/zx/timer.h>
-#include <lib/zx/vcpu.h>
-#include <lib/zx/vmar.h>
-#include <lib/zx/vmo.h>
-#endif
-
-#include "lib/fidl/cpp/coding_traits.h"
-#include "lib/fidl/cpp/enum.h"
-
-#ifdef __Fuchsia__
-#include "lib/fidl/cpp/interface_ptr.h"
-#include "lib/fidl/cpp/internal/proxy_controller.h"
-#include "lib/fidl/cpp/internal/stub_controller.h"
-#include "lib/fidl/cpp/internal/synchronous_proxy.h"
-#include "lib/fidl/cpp/synchronous_interface_ptr.h"
-#endif
-
-#include "lib/fidl/cpp/string.h"
-#include "lib/fidl/cpp/vector.h"
-
-// clone.h must be imported before any of the generated Clone methods are
-// defined, so that calls to Clone in clone.h are referencing the ADL
-// implementation and are not ambiguous.
-#include "lib/fidl/cpp/clone.h"
-
-#endif // LIB_FIDL_CPP_INTERNAL_HEADER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/implementation.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/implementation.h
deleted file mode 100644
index 37a3bec..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/implementation.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_IMPLEMENTATION_H_
-#define LIB_FIDL_CPP_INTERNAL_IMPLEMENTATION_H_
-
-#include <lib/fidl/internal.h>
-#include <stdint.h>
-#include <zircon/assert.h>
-
-#include <limits>
-#include <memory>
-
-#include "lib/fidl/cpp/clone.h"
-#include "lib/fidl/cpp/comparison.h"
-#include "lib/fidl/cpp/encoder.h"
-#include "lib/fidl/cpp/internal/logging.h"
-#include "lib/fidl/cpp/traits.h"
-
-#endif // LIB_FIDL_CPP_INTERNAL_IMPLEMENTATION_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_handler.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_handler.h
deleted file mode 100644
index 13660ad..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_handler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_MESSAGE_HANDLER_H_
-#define LIB_FIDL_CPP_INTERNAL_MESSAGE_HANDLER_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <zircon/types.h>
-
-namespace fidl {
-namespace internal {
-
-// An interface for receiving FIDL messages.
-//
-// Used by |MessageReader| to call back into its client whenever it reads a
-// message from the channel.
-class MessageHandler {
- public:
- virtual ~MessageHandler();
-
- // A new message has arrived.
- //
- // The memory backing the message will remain valid until this method returns,
- // at which point the memory might or might not be deallocated.
- virtual zx_status_t OnMessage(Message message) = 0;
-
- // The channel from which the messages were being read is gone.
- //
- // The channel's peer might have been closed or the |MessageReader| might have
- // unbound from the channel. In either case, implementations that keep
- // per-channel state should reset their state when this method is called.
- virtual void OnChannelGone();
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_MESSAGE_HANDLER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_reader.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_reader.h
deleted file mode 100644
index 5272231..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_reader.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_MESSAGE_READER_H_
-#define LIB_FIDL_CPP_INTERNAL_MESSAGE_READER_H_
-
-#include <lib/async/wait.h>
-#include <lib/fidl/cpp/message.h>
-#include <lib/fidl/cpp/message_buffer.h>
-#include <lib/fit/function.h>
-#include <lib/zx/channel.h>
-
-#include <functional>
-#include <memory>
-#include <utility>
-
-#include "lib/fidl/cpp/internal/message_handler.h"
-
-namespace fidl {
-namespace internal {
-
-class MessageReader {
- public:
- explicit MessageReader(MessageHandler* message_handler = nullptr);
- ~MessageReader();
-
- MessageReader(const MessageReader&) = delete;
- MessageReader& operator=(const MessageReader&) = delete;
-
- // Binds the given channel to this |MessageReader|.
- //
- // The |MessageReader| will wait asynchronously for messages on this channel
- // and dispatch them to the message handler using |dispatcher|. After this
- // method returns, the |MessageReader| will be waiting for incomming messages.
- //
- // If the |MessageReader| is already bound, the |MessageReader| will first
- // be unbound.
- //
- // If |dispatcher| is null, the current thread must have a default async_t.
- zx_status_t Bind(zx::channel channel,
- async_dispatcher_t* dispatcher = nullptr);
-
- // Unbinds the channel from this |MessageReader|.
- //
- // The |MessageReader| will stop waiting for the messages on this channel.
- //
- // Returns the channel to which this |MessageReader| was previously bound, if
- // any.
- zx::channel Unbind();
-
- // Unbinds the channel from this |MessageReader| and clears the error handler.
- void Reset();
-
- // Unbinds the channel from |other| and bindings it to this |MessageReader|.
- //
- // Also moves the error handler from |other| to this |MessageReader|.
- //
- // Useful for implementing move semantics for objects that have a
- // |MessageReader|.
- zx_status_t TakeChannelAndErrorHandlerFrom(MessageReader* other);
-
- // Sends an epitaph with the given value, unbinds, and then closes the channel
- // associated with this |MessageReader|.
- //
- // The |MessageReader| will send an Epitaph with the given error, unbind
- // the channel, and then close it.
- //
- // The return value can be any of the return values of zx_channel_write.
- zx_status_t Close(zx_status_t epitaph_value);
-
- // Whether the |MessageReader| is currently bound.
- //
- // See |Bind()| and |Unbind()|.
- bool is_bound() const { return channel_.is_valid(); }
-
- // The channel to which this |MessageReader| is bound, if any.
- const zx::channel& channel() const { return channel_; }
-
- // Synchronously waits on |channel()| until either a message is available or
- // the peer closes. If the channel is readable, reads a single message from
- // the channel and dispatches it to the message handler.
- //
- // Returns |ZX_ERR_BAD_STATE| if this |MessageReader| is not bound, or if it
- // receives a malformed Epitaph.
- zx_status_t WaitAndDispatchOneMessageUntil(zx::time deadline);
-
- // The given message handler is called whenever the |MessageReader| reads a
- // message from the channel.
- //
- // The |Message| given to the message handler will be valid until the message
- // handler returns.
- //
- // The handler should return ZX_OK if the message was handled and an error
- // otherwise. If the handler returns ZX_OK, the |MessageReader| will continue
- // to wait for messages.
- //
- // The handler can destroy the |MessageReader|, in which case the
- // handler MUST return |ZX_ERR_STOP|. If the handler returns
- // |ZX_ERR_SHOULD_WAIT|, the |MessageReader| will continue waiting. Other
- // errors cause the |MessageReader| to unbind from the channel and call the
- // error handler.
- void set_message_handler(MessageHandler* message_handler) {
- message_handler_ = message_handler;
- }
-
- // The given error handler is called whenever the |MessageReader| encounters
- // an error on the channel.
- //
- // If the error is being reported because an error occurred on the local side
- // of the channel, the zx_status_t of that error will be passed as the
- // parameter to the handler.
- //
- // If an Epitaph was present on the channel, its error value will be passed as
- // the parameter. See the FIDL language specification for more detail on
- // Epitaphs.
- //
- // For example, the error handler will be called if the remote side of the
- // channel sends an invalid message. When the error handler is called, the
- // |Binding| will no longer be bound to the channel.
- //
- // The handler can destroy the |MessageReader|.
- void set_error_handler(fit::function<void(zx_status_t)> error_handler) {
- error_handler_ = std::move(error_handler);
- }
-
- private:
- static void CallHandler(async_dispatcher_t* dispatcher, async_wait_t* wait,
- zx_status_t status, const zx_packet_signal_t* signal);
- void OnHandleReady(async_dispatcher_t* dispatcher, zx_status_t status,
- const zx_packet_signal_t* signal);
- zx_status_t ReadAndDispatchMessage(MessageBuffer* buffer);
- void NotifyError(zx_status_t epitaph_value);
- void Stop();
-
- async_wait_t wait_; // Must be first.
- zx::channel channel_;
- async_dispatcher_t* dispatcher_;
- bool* should_stop_; // See |Canary| in message_reader.cc.
- MessageHandler* message_handler_;
- fit::function<void(zx_status_t)> error_handler_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_MESSAGE_READER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/pending_response.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/pending_response.h
deleted file mode 100644
index 125a7d8..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/pending_response.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_PENDING_RESPONSE_H_
-#define LIB_FIDL_CPP_INTERNAL_PENDING_RESPONSE_H_
-
-#include <lib/fidl/cpp/message_builder.h>
-#include <zircon/types.h>
-
-namespace fidl {
-namespace internal {
-class WeakStubController;
-
-// A response to a FIDL message.
-//
-// When a server receives a message that expects a response, the stub receives a
-// |PendingResponse| object that the implementation can use to reply to the
-// message. A given |PendingResponse| object can be used to send a reply at
-// most once.
-//
-// If the |StubController| that processed the original message is destroyed or
-// unbound from the underlying channel (e.g., due to an error), the stub can
-// still safely call |Send|, but the response will not actually be sent to the
-// client.
-class PendingResponse {
- public:
- // Creates a |PendingResponse| that does not need a response.
- //
- // The |needs_response()| method will return false.
- PendingResponse();
-
- // Creates a |PendingResponse| for a message with the given transaction ID.
- //
- // The |PendingResponse| object will take a reference to |weak_controller|,
- // which it releases in its destructor.
- PendingResponse(zx_txid_t txid, WeakStubController* weak_controller);
-
- ~PendingResponse();
-
- // |PendingResponse| objects are copiable.
- //
- // Each copy refers to the same logical reponse, which means |Send| should be
- // called at most once among all the copies.
- //
- // The reason |PendingResponse| objects are copiable is so that they can be
- // held by an std::function, which is also copyable. Typically, a
- // |PendingResponse| object is held as a member of another object that
- // implements operator(), which can be wrapped by std::function.
- PendingResponse(const PendingResponse& other);
- PendingResponse& operator=(const PendingResponse& other);
-
- // |PendingResponse| objects are movable.
- //
- // Moving a |PendingResponse| object is more efficient that copying it because
- // moving avoid churning the reference count of the associated
- // |WeakStubController|.
- PendingResponse(PendingResponse&& other);
- PendingResponse& operator=(PendingResponse&& other);
-
- // Whether the message that caused this |PendingResponse| object to be created
- // expects a response.
- //
- // This method does not indiciate whether a response has or has not already
- // been sent. That state is difficult to track because |PendingResponse| is
- // copiable.
- bool needs_response() const { return txid_; }
-
- // Send a response.
- //
- // This function should be called at most once among all the copies of a given
- // |PendingResponse| object.
- //
- // If the associated |WeakStubController| is no longer available (e.g., if it
- // has been destroyed), this function will return |ZX_ERR_BAD_STATE|.
- zx_status_t Send(const fidl_type_t* type, Message message);
-
- private:
- // This class should be small enough to fit into the inline storage for an
- // std::function to avoid allocating additional storage when processing
- // messages. Currently, std::function has space for three pointers.
- zx_txid_t txid_;
- WeakStubController* weak_controller_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_PENDING_RESPONSE_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy.h
deleted file mode 100644
index cc72783..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_PROXY_H_
-#define LIB_FIDL_CPP_INTERNAL_PROXY_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <zircon/types.h>
-
-namespace fidl {
-namespace internal {
-
-// An interface for sending FIDL messages to a remote implementation.
-class Proxy {
- public:
- virtual ~Proxy();
-
- // A new message has arrived.
- //
- // The memory backing the message will remain valid until this method returns,
- // at which point the memory might or might not be deallocated.
- virtual zx_status_t Dispatch_(Message message) = 0;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_PROXY_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy_controller.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy_controller.h
deleted file mode 100644
index 070613f..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy_controller.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_PROXY_CONTROLLER_H_
-#define LIB_FIDL_CPP_INTERNAL_PROXY_CONTROLLER_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <lib/fidl/cpp/message_builder.h>
-
-#include <map>
-#include <memory>
-
-#include "lib/fidl/cpp/internal/message_handler.h"
-#include "lib/fidl/cpp/internal/message_reader.h"
-#include "lib/fidl/cpp/internal/proxy.h"
-
-namespace fidl {
-namespace internal {
-
-// Controls the client endpoint of a FIDL channel.
-//
-// A |ProxyController| controls the protocol-specific "proxy" object. Proxy
-// objects are used on the client endpoint of a FIDL channel to encode messages
-// into the channel and send them to the server endpoint, whose "stub" object
-// decodes them and dispatches them to an implementation of the protocol.
-class ProxyController : public MessageHandler {
- public:
- ProxyController();
- ~ProxyController();
-
- ProxyController(const ProxyController&) = delete;
- ProxyController& operator=(const ProxyController&) = delete;
-
- ProxyController(ProxyController&&);
- ProxyController& operator=(ProxyController&&);
-
- // The |MessageReader| that is listening for responses to messages sent by
- // this object.
- MessageReader& reader() { return reader_; }
- const MessageReader& reader() const { return reader_; }
-
- // The protocol-specific object that decodes messages and dispatches them to
- // an implementation of the protocol.
- //
- // The proxy must be set to a non-null value before messages are read from the
- // underlying channel. Typically, the caller will set a non-null proxy before
- // binding a channel to the |MessageReader|.
- Proxy* proxy() const { return proxy_; }
- void set_proxy(Proxy* proxy) { proxy_ = proxy; }
-
- // Send a message over the channel.
- //
- // If |response_handler| is non-null, the message will be assigned a
- // transaction identifier before being encoded and sent over the channel. The
- // |response_handler| will be retained by the |ProxyController| until the
- // |ProxyController| recieves a response to the message, at which time the
- // |ProxyController| will call the |OnMessage| method of the
- // |response_handler|.
- //
- // Returns an error if the message fails to encode properly or if the message
- // cannot be written to the channel.
- zx_status_t Send(const fidl_type_t* type, Message message,
- std::unique_ptr<MessageHandler> response_handler);
-
- // Clears all the state associated with this |ProxyController|.
- //
- // After this method returns, the |ProxyController| is in the same state it
- // would have been in if freshly constructed.
- void Reset();
-
- private:
- // Called by the |MessageReader| when a message arrives on the channel from
- // the server.
- //
- // The message might be a response to a previously sent message or an
- // unsolicited event.
- zx_status_t OnMessage(Message message) final;
-
- // Causes the |ProxyController| to |ClearPendingHandlers()|.
- void OnChannelGone() final;
-
- // Causes the |ProxyController| to destroy all pending response handlers and
- // reset its transition identifiers.
- void ClearPendingHandlers();
-
- MessageReader reader_;
- Proxy* proxy_ = nullptr;
- std::map<zx_txid_t, std::unique_ptr<MessageHandler>> handlers_;
- zx_txid_t next_txid_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_PROXY_CONTROLLER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub.h
deleted file mode 100644
index 448f995..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_STUB_H_
-#define LIB_FIDL_CPP_INTERNAL_STUB_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <zircon/types.h>
-
-#include "lib/fidl/cpp/internal/pending_response.h"
-
-namespace fidl {
-namespace internal {
-class StubController;
-
-// An interface for dispatching FIDL messages to a protocol implementation.
-//
-// Used by |StubController| to supply both a |Message| and a |PendingResponse|
-// object to protocol implementations.
-class Stub {
- public:
- virtual ~Stub();
-
- // A new message has arrived.
- //
- // If the message expects a response, the |PendingResponse| object's
- // |needs_response()| method will return true.
- //
- // The memory backing the message will remain valid until this method returns,
- // at which point the memory might or might not be deallocated.
- //
- // The |PendingResponse| object has affinity for the current thread and is not
- // safe to transport to another thread.
- virtual zx_status_t Dispatch_(Message message, PendingResponse response) = 0;
-
- // The protocol-agnostic object that listens for incoming messages.
- //
- // The controller must be set to a non-null value before sending events
- // through this stub.
- StubController* controller() const { return controller_; }
- void set_controller(StubController* controller) { controller_ = controller; }
-
- private:
- StubController* controller_ = nullptr;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_STUB_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub_controller.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub_controller.h
deleted file mode 100644
index d89729e..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub_controller.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_STUB_CONTROLLER_H_
-#define LIB_FIDL_CPP_INTERNAL_STUB_CONTROLLER_H_
-
-#include <memory>
-
-#include <lib/fidl/cpp/message.h>
-#include <lib/zx/channel.h>
-
-#include "lib/fidl/cpp/internal/message_handler.h"
-#include "lib/fidl/cpp/internal/message_reader.h"
-#include "lib/fidl/cpp/internal/stub.h"
-
-namespace fidl {
-namespace internal {
-class WeakStubController;
-
-// Controls the server endpoint of a FIDL channel.
-//
-// A |StubController| controls the protocol-specific "stub" object. Stub
-// objects are used on the server endpoint of a FIDL channel to decode messages
-// received over the channel and dispatch them to an implementation of the
-// protocol.
-class StubController : public MessageHandler {
- public:
- StubController();
- ~StubController();
-
- StubController(const StubController&) = delete;
- StubController& operator=(const StubController&) = delete;
-
- // The |MessageReader| that is listening for messages sent by the client.
- MessageReader& reader() { return reader_; }
- const MessageReader& reader() const { return reader_; }
-
- // The protocol-specific object that decodes messages and dispatches them to
- // an implementation of the protocol.
- //
- // The stub must be set to a non-null value before messages are read from the
- // underlying channel. Typically, the caller will set a non-null stub before
- // binding a channel to the |MessageReader|.
- Stub* stub() const { return stub_; }
- void set_stub(Stub* stub) { stub_ = stub; }
-
- // Send a message over the channel.
- //
- // Returns an error if the message fails to encode properly or if the message
- // cannot be written to the channel.
- zx_status_t Send(const fidl_type_t* type, Message message);
-
- private:
- // Called by the |MessageReader| when a message arrives on the channel from
- // the client.
- //
- // The message will be dispatched using the |stub()|. If the message expects a
- // response, the |stub()| will also be given a |PendingResponse| object that
- // can be used to send a reply to the message.
- zx_status_t OnMessage(Message message) final;
-
- // Causes the |StubController| to invalidate all outstanding weak pointers,
- // preventing outstanding |PendingResponse| objects from sending messages on
- // the channel that has gone away.
- void OnChannelGone() final;
-
- // Invalidate all outstanding weak pointers, preventing outstanding
- // |PendingResponse| objects from sending messages.
- void InvalidateWeakIfNeeded();
-
- WeakStubController* weak_;
- MessageReader reader_;
- Stub* stub_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_STUB_CONTROLLER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/weak_stub_controller.h b/pkg/fidl_cpp/include/lib/fidl/cpp/internal/weak_stub_controller.h
deleted file mode 100644
index cdfbb1d..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/internal/weak_stub_controller.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_WEAK_STUB_CONTROLLER_H_
-#define LIB_FIDL_CPP_INTERNAL_WEAK_STUB_CONTROLLER_H_
-
-#include <stdint.h>
-
-namespace fidl {
-namespace internal {
-class StubController;
-
-// A weak reference to a |StubController|.
-//
-// Used to link a |PendingResponse| object with a |StubController|. When the
-// |StubController| is destroyed (or unbound from the underling channel), the
-// weak reference is invalidated, preventing outstanding |PendingResponse|
-// objects from referencing the |StubController|.
-class WeakStubController {
- public:
- // Creates a weak reference to a |StubController|.
- //
- // The created |WeakStubController| has a reference count of one, which means
- // the creator is responsible for calling |Release| exactly once.
- explicit WeakStubController(StubController* controller);
-
- // Increment the refernence count for this object.
- //
- // Each call to this method imposes a requirement to eventually call |Release|
- // exactly once.
- void AddRef();
-
- // Decrements the reference count for this object.
- //
- // When the reference count reaches zero, the object is destroyed.
- void Release();
-
- // Break the connection between this object and the |StubController|.
- //
- // After calling this method, |controller()| will return nullptr.
- void Invalidate();
-
- // The |StubController| to which this weak reference refers.
- //
- // After the weak reference has been invalidated, this method returns nullptr.
- StubController* controller() const { return controller_; }
-
- private:
- ~WeakStubController();
-
- uint32_t ref_count_; // starts at one
- StubController* controller_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_WEAK_STUB_CONTROLLER_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/optional.h b/pkg/fidl_cpp/include/lib/fidl/cpp/optional.h
deleted file mode 100644
index 4dc6219..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/optional.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_OPTIONAL_H_
-#define LIB_FIDL_CPP_OPTIONAL_H_
-
-#include <memory>
-#include <utility>
-
-namespace fidl {
-
-template <typename T>
-std::unique_ptr<T> MakeOptional(T value) {
- return std::make_unique<T>(std::move(value));
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_OPTIONAL_H_
diff --git a/pkg/fidl_cpp/include/lib/fidl/cpp/thread_safe_binding_set.h b/pkg/fidl_cpp/include/lib/fidl/cpp/thread_safe_binding_set.h
deleted file mode 100644
index a3b572c..0000000
--- a/pkg/fidl_cpp/include/lib/fidl/cpp/thread_safe_binding_set.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_THREAD_SAFE_BINDING_SET_H_
-#define LIB_FIDL_CPP_THREAD_SAFE_BINDING_SET_H_
-
-#include <algorithm>
-#include <memory>
-#include <mutex>
-#include <utility>
-#include <vector>
-
-#include <lib/async/dispatcher.h>
-#include <zircon/compiler.h>
-
-#include "lib/fidl/cpp/binding.h"
-
-namespace fidl {
-
-// Manages a set of bindings to implemenations owned by the bound channels.
-//
-// The implementation pointer type of the binding is also parameterized,
-// allowing the use of smart pointer types such as |std::unique_ptr<>| to
-// reference the implementation.
-//
-// This class is thread-safe; bindings may be added or cleared from any thread.
-//
-// See also:
-//
-// * |BindingSet|, which is the thread-hostile analog that offers more
-// functionality.
-// * |InterfacePtrSet|, which is the client analog of |BindingSet|.
-template <typename Interface, typename ImplPtr = Interface*>
-class ThreadSafeBindingSet {
- public:
- using Binding = ::fidl::Binding<Interface, ImplPtr>;
- using StorageType = std::vector<std::unique_ptr<Binding>>;
-
- ThreadSafeBindingSet() = default;
-
- ThreadSafeBindingSet(const ThreadSafeBindingSet&) = delete;
- ThreadSafeBindingSet& operator=(const ThreadSafeBindingSet&) = delete;
-
- // Adds a binding to the set.
- //
- // The given |ImplPtr| is bound to the channel underlying the
- // |InterfaceRequest|. The binding is removed (and the |~ImplPtr| called)
- // when the created binding has an error (e.g., if the remote endpoint of
- // the channel sends an invalid message).
- //
- // Whether this method takes ownership of |impl| depends on |ImplPtr|. If
- // |ImplPtr| is a raw pointer, then this method does not take ownership of
- // |impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the
- // binding generates an error will delete |impl| because |~ImplPtr| is
- // |~unique_ptr|, which deletes |impl|.
- //
- // The impl will use the given async_t (e.g., a message loop) in order to read
- // messages from the channel and to monitor the channel for
- // |ZX_CHANNEL_PEER_CLOSED|. It is not necessary to use the same async_t for
- // each binding added.
- void AddBinding(ImplPtr impl, InterfaceRequest<Interface> request,
- async_dispatcher_t* dispatcher) {
- std::lock_guard<std::mutex> guard(lock_);
- bindings_.push_back(std::make_unique<Binding>(
- std::forward<ImplPtr>(impl), std::move(request), dispatcher));
- auto* binding = bindings_.back().get();
- // Set the connection error handler for the newly added Binding to be a
- // function that will erase it from the vector.
- binding->set_error_handler(
- [binding, this](zx_status_t status) { this->RemoveOnError(binding); });
- }
-
- // Adds a binding to the set for the given implementation.
- //
- // Creates a channel for the binding and returns the client endpoint of
- // the channel as an |InterfaceHandle|. If |AddBinding| fails to create the
- // underlying channel, the returned |InterfaceHandle| will return false from
- // |is_valid()|.
- //
- // The given |ImplPtr| is bound to the newly created channel. The binding is
- // removed (and the |~ImplPtr| called) when the created binding has an error
- // (e.g., if the remote endpoint of the channel sends an invalid message).
- //
- // Whether this method takes ownership of |impl| depends on |ImplPtr|. If
- // |ImplPtr| is a raw pointer, then this method does not take ownership of
- // |impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the
- // binding generates an error will delete |impl| because |~ImplPtr| is
- // |~unique_ptr|, which deletes |impl|.
- InterfaceHandle<Interface> AddBinding(ImplPtr impl,
- async_dispatcher_t* dispatcher) {
- InterfaceHandle<Interface> handle;
- InterfaceRequest<Interface> request = handle.NewRequest();
- if (!request)
- return nullptr;
- AddBinding(std::forward<ImplPtr>(impl), std::move(request), dispatcher);
- return handle;
- }
-
- // Removes all the bindings from the set.
- //
- // Closes all the channels associated with this |BindingSet|.
- void CloseAll() {
- std::lock_guard<std::mutex> guard(lock_);
- bindings_.clear();
- }
-
- private:
- // Called when a binding has an error to remove the binding from the set.
- void RemoveOnError(Binding* binding) {
- std::lock_guard<std::mutex> guard(lock_);
- auto it = std::find_if(bindings_.begin(), bindings_.end(),
- [binding](const std::unique_ptr<Binding>& b) {
- return b.get() == binding;
- });
- ZX_DEBUG_ASSERT(it != bindings_.end());
- (*it)->set_error_handler(nullptr);
- bindings_.erase(it);
- }
-
- std::mutex lock_;
- StorageType bindings_ __TA_GUARDED(lock_);
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_THREAD_SAFE_BINDING_SET_H_
diff --git a/pkg/fidl_cpp/internal/message_handler.cc b/pkg/fidl_cpp/internal/message_handler.cc
deleted file mode 100644
index fbcaa5a..0000000
--- a/pkg/fidl_cpp/internal/message_handler.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/message_handler.h"
-
-namespace fidl {
-namespace internal {
-
-MessageHandler::~MessageHandler() = default;
-
-void MessageHandler::OnChannelGone() {}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/message_reader.cc b/pkg/fidl_cpp/internal/message_reader.cc
deleted file mode 100644
index e4331f7..0000000
--- a/pkg/fidl_cpp/internal/message_reader.cc
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/message_reader.h"
-
-#include <lib/async/default.h>
-#include <lib/fidl/cpp/message_buffer.h>
-#include <lib/fidl/epitaph.h>
-#include <zircon/assert.h>
-
-namespace fidl {
-namespace internal {
-namespace {
-
-constexpr zx_signals_t kSignals = ZX_CHANNEL_READABLE | ZX_CHANNEL_PEER_CLOSED;
-
-// |Canary| is a stack-allocated object that observes when a |MessageReader| is
-// destroyed or unbound from the current channel.
-//
-// Because |WaitAndDispatchOneMessageUntil| can be called re-entrantly, we can
-// be in a state where there are N nested calls to |ReadAndDispatchMessage| on
-// the stack. While dispatching any of those messages, the client can destroy
-// the |MessageReader| or unbind it from the current channel. When that happens
-// we need to stop reading messages from the channel and unwind the stack
-// safely.
-//
-// The |Canary| works by storing a pointer to its |should_stop_| field in the
-// |MessageReader|. Upon destruction or unbinding, the |MessageReader| writes
-// |true| into |should_stop_|. When we unwind the stack, the |Canary| forwards
-// that value to the next |Canary| on the stack.
-class Canary {
- public:
- explicit Canary(bool** should_stop_slot)
- : should_stop_slot_(should_stop_slot),
- previous_should_stop_(*should_stop_slot_),
- should_stop_(false) {
- *should_stop_slot_ = &should_stop_;
- }
-
- ~Canary() {
- if (should_stop_) {
- // If we should stop, we need to propagate that information to the
- // |Canary| higher up the stack, if any. We also cannot touch
- // |*should_stop_slot_| because the |MessageReader| might have been
- // destroyed (or bound to another channel).
- if (previous_should_stop_)
- *previous_should_stop_ = should_stop_;
- } else {
- // Otherwise, the |MessageReader| was not destroyed and is still bound to
- // the same channel. We need to restore the previous |should_stop_|
- // pointer so that a |Canary| further up the stack can still be informed
- // about whether to stop.
- *should_stop_slot_ = previous_should_stop_;
- }
- }
-
- // Whether the |ReadAndDispatchMessage| that created the |Canary| should stop
- // after dispatching the current message.
- bool should_stop() const { return should_stop_; }
-
- private:
- bool** should_stop_slot_;
- bool* previous_should_stop_;
- bool should_stop_;
-};
-
-} // namespace
-
-static_assert(std::is_standard_layout<MessageReader>::value,
- "We need offsetof to work");
-
-MessageReader::MessageReader(MessageHandler* message_handler)
- : wait_{{ASYNC_STATE_INIT},
- &MessageReader::CallHandler,
- ZX_HANDLE_INVALID,
- kSignals},
- dispatcher_(nullptr),
- should_stop_(nullptr),
- message_handler_(message_handler),
- error_handler_(nullptr) {}
-
-MessageReader::~MessageReader() {
- Stop();
- if (dispatcher_)
- async_cancel_wait(dispatcher_, &wait_);
-}
-
-zx_status_t MessageReader::Bind(zx::channel channel,
- async_dispatcher_t* dispatcher) {
- if (is_bound())
- Unbind();
- if (!channel)
- return ZX_OK;
- channel_ = std::move(channel);
- if (dispatcher) {
- dispatcher_ = dispatcher;
- } else {
- dispatcher_ = async_get_default_dispatcher();
- }
- ZX_ASSERT_MSG(dispatcher_ != nullptr,
- "either |dispatcher| must be non-null, or "
- "|async_get_default_dispatcher| must "
- "be configured to return a non-null value");
- wait_.object = channel_.get();
- zx_status_t status = async_begin_wait(dispatcher_, &wait_);
- if (status != ZX_OK)
- Unbind();
- return status;
-}
-
-zx::channel MessageReader::Unbind() {
- if (!is_bound())
- return zx::channel();
- Stop();
- async_cancel_wait(dispatcher_, &wait_);
- wait_.object = ZX_HANDLE_INVALID;
- dispatcher_ = nullptr;
- zx::channel channel = std::move(channel_);
- if (message_handler_)
- message_handler_->OnChannelGone();
- return channel;
-}
-
-void MessageReader::Reset() {
- Unbind();
- error_handler_ = nullptr;
-}
-
-zx_status_t MessageReader::TakeChannelAndErrorHandlerFrom(
- MessageReader* other) {
- zx_status_t status = Bind(other->Unbind(), other->dispatcher_);
- if (status != ZX_OK)
- return status;
- error_handler_ = std::move(other->error_handler_);
- return ZX_OK;
-}
-
-zx_status_t MessageReader::WaitAndDispatchOneMessageUntil(zx::time deadline) {
- if (!is_bound())
- return ZX_ERR_BAD_STATE;
- zx_signals_t pending = ZX_SIGNAL_NONE;
- zx_status_t status = channel_.wait_one(kSignals, deadline, &pending);
- if (status == ZX_ERR_TIMED_OUT)
- return status;
- if (status != ZX_OK) {
- NotifyError(status);
- return status;
- }
-
- if (pending & ZX_CHANNEL_READABLE) {
- MessageBuffer buffer;
- return ReadAndDispatchMessage(&buffer);
- }
-
- ZX_DEBUG_ASSERT(pending & ZX_CHANNEL_PEER_CLOSED);
- NotifyError(ZX_ERR_PEER_CLOSED);
- return ZX_ERR_PEER_CLOSED;
-}
-
-void MessageReader::CallHandler(async_dispatcher_t* dispatcher,
- async_wait_t* wait, zx_status_t status,
- const zx_packet_signal_t* signal) {
- static_assert(offsetof(MessageReader, wait_) == 0,
- "The wait must be the first member for this cast to be valid.");
- reinterpret_cast<MessageReader*>(wait)->OnHandleReady(dispatcher, status,
- signal);
-}
-
-void MessageReader::OnHandleReady(async_dispatcher_t* dispatcher,
- zx_status_t status,
- const zx_packet_signal_t* signal) {
- if (status != ZX_OK) {
- NotifyError(status);
- return;
- }
-
- if (signal->observed & ZX_CHANNEL_READABLE) {
- MessageBuffer buffer;
- for (uint64_t i = 0; i < signal->count; i++) {
- status = ReadAndDispatchMessage(&buffer);
- // If ReadAndDispatchMessage returns ZX_ERR_STOP, that means the message
- // handler has destroyed this object and we need to unwind without
- // touching |this|.
- if (status == ZX_ERR_SHOULD_WAIT)
- break;
- if (status != ZX_OK)
- return;
- }
- status = async_begin_wait(dispatcher, &wait_);
- if (status != ZX_OK) {
- NotifyError(status);
- }
- return;
- }
-
- ZX_DEBUG_ASSERT(signal->observed & ZX_CHANNEL_PEER_CLOSED);
- // Notice that we don't notify an error until we've drained all the messages
- // out of the channel.
- NotifyError(ZX_ERR_PEER_CLOSED);
-}
-
-zx_status_t MessageReader::ReadAndDispatchMessage(MessageBuffer* buffer) {
- Message message = buffer->CreateEmptyMessage();
- zx_status_t status = message.Read(channel_.get(), 0);
- if (status == ZX_ERR_SHOULD_WAIT)
- return status;
- if (status != ZX_OK) {
- NotifyError(status);
- return status;
- }
-
- if (message.has_header() && message.ordinal() == FIDL_EPITAPH_ORDINAL) {
- // This indicates the message is an epitaph, and that any epitaph-friendly
- // error handlers should be invoked. Note the epitaph error is stored in
- // the header's reserved word.
-
- // TODO(FIDL-322): Use a different error code to distinguish remote encoding
- // errors from local ones.
- if (message.bytes().actual() != sizeof(fidl_epitaph_t)) {
- NotifyError(ZX_ERR_INVALID_ARGS);
- return ZX_ERR_INVALID_ARGS;
- }
- fidl_epitaph_t* epitaph = message.GetBytesAs<fidl_epitaph_t>();
- NotifyError(epitaph->hdr.reserved0);
- return ZX_ERR_PEER_CLOSED;
- }
-
- if (!message_handler_)
- return ZX_OK;
- Canary canary(&should_stop_);
- status = message_handler_->OnMessage(std::move(message));
- if (canary.should_stop())
- return ZX_ERR_STOP;
- if (status != ZX_OK)
- NotifyError(status);
- return status;
-}
-
-zx_status_t MessageReader::Close(zx_status_t epitaph_value) {
- if (!is_bound()) {
- return ZX_ERR_BAD_STATE;
- }
-
- zx_status_t status = fidl_epitaph_write(channel_.get(), epitaph_value);
- if (status != ZX_OK) {
- return status;
- }
- Unbind();
- return ZX_OK;
-}
-
-void MessageReader::NotifyError(zx_status_t epitaph_value) {
- Unbind();
- if (error_handler_) {
- error_handler_(epitaph_value);
- }
-}
-
-void MessageReader::Stop() {
- if (should_stop_) {
- *should_stop_ = true;
- should_stop_ = nullptr;
- }
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/pending_response.cc b/pkg/fidl_cpp/internal/pending_response.cc
deleted file mode 100644
index 3ac41ae..0000000
--- a/pkg/fidl_cpp/internal/pending_response.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/pending_response.h"
-
-#include "lib/fidl/cpp/internal/logging.h"
-#include "lib/fidl/cpp/internal/stub_controller.h"
-#include "lib/fidl/cpp/internal/weak_stub_controller.h"
-
-namespace fidl {
-namespace internal {
-
-PendingResponse::PendingResponse() : txid_(0), weak_controller_(nullptr) {}
-
-PendingResponse::PendingResponse(zx_txid_t txid,
- WeakStubController* weak_controller)
- : txid_(txid), weak_controller_(weak_controller) {
- if (weak_controller_)
- weak_controller_->AddRef();
-}
-
-PendingResponse::~PendingResponse() {
- if (weak_controller_)
- weak_controller_->Release();
-}
-
-PendingResponse::PendingResponse(const PendingResponse& other)
- : PendingResponse(other.txid_, other.weak_controller_) {}
-
-PendingResponse& PendingResponse::operator=(const PendingResponse& other) {
- if (this == &other)
- return *this;
- txid_ = other.txid_;
- if (weak_controller_)
- weak_controller_->Release();
- weak_controller_ = other.weak_controller_;
- if (weak_controller_)
- weak_controller_->AddRef();
- return *this;
-}
-
-PendingResponse::PendingResponse(PendingResponse&& other)
- : txid_(other.txid_), weak_controller_(other.weak_controller_) {
- other.weak_controller_ = nullptr;
-}
-
-PendingResponse& PendingResponse::operator=(PendingResponse&& other) {
- if (this == &other)
- return *this;
- txid_ = other.txid_;
- if (weak_controller_)
- weak_controller_->Release();
- weak_controller_ = other.weak_controller_;
- other.weak_controller_ = nullptr;
- return *this;
-}
-
-zx_status_t PendingResponse::Send(const fidl_type_t* type, Message message) {
- if (!weak_controller_)
- return ZX_ERR_BAD_STATE;
- StubController* controller = weak_controller_->controller();
- if (!controller)
- return ZX_ERR_BAD_STATE;
- message.set_txid(txid_);
- const char* error_msg = nullptr;
- zx_status_t status = message.Validate(type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_ENCODING_ERROR(message, type, error_msg);
- return status;
- }
- zx_handle_t channel = controller->reader().channel().get();
- return message.Write(channel, 0);
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/proxy.cc b/pkg/fidl_cpp/internal/proxy.cc
deleted file mode 100644
index 412aff7..0000000
--- a/pkg/fidl_cpp/internal/proxy.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/proxy.h"
-
-namespace fidl {
-namespace internal {
-
-Proxy::~Proxy() = default;
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/proxy_controller.cc b/pkg/fidl_cpp/internal/proxy_controller.cc
deleted file mode 100644
index bec764c..0000000
--- a/pkg/fidl_cpp/internal/proxy_controller.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/proxy_controller.h"
-
-#include <utility>
-
-#include "lib/fidl/cpp/internal/logging.h"
-
-namespace fidl {
-namespace internal {
-namespace {
-
-constexpr uint32_t kUserspaceTxidMask = 0x7FFFFFFF;
-
-} // namespace
-
-ProxyController::ProxyController() : reader_(this), next_txid_(1) {}
-
-ProxyController::~ProxyController() = default;
-
-ProxyController::ProxyController(ProxyController&& other)
- : reader_(this),
- handlers_(std::move(other.handlers_)),
- next_txid_(other.next_txid_) {
- reader_.TakeChannelAndErrorHandlerFrom(&other.reader());
- other.Reset();
-}
-
-ProxyController& ProxyController::operator=(ProxyController&& other) {
- if (this != &other) {
- reader_.TakeChannelAndErrorHandlerFrom(&other.reader());
- handlers_ = std::move(other.handlers_);
- next_txid_ = other.next_txid_;
- other.Reset();
- }
- return *this;
-}
-
-zx_status_t ProxyController::Send(
- const fidl_type_t* type, Message message,
- std::unique_ptr<MessageHandler> response_handler) {
- zx_txid_t txid = 0;
- if (response_handler) {
- txid = next_txid_++ & kUserspaceTxidMask;
- while (!txid || handlers_.find(txid) != handlers_.end())
- txid = next_txid_++ & kUserspaceTxidMask;
- message.set_txid(txid);
- }
- const char* error_msg = nullptr;
- zx_status_t status = message.Validate(type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_ENCODING_ERROR(message, type, error_msg);
- return status;
- }
- status = message.Write(reader_.channel().get(), 0);
- if (status != ZX_OK) {
- FIDL_REPORT_CHANNEL_WRITING_ERROR(message, type, status);
- return status;
- }
- if (response_handler)
- handlers_.emplace(txid, std::move(response_handler));
- return ZX_OK;
-}
-
-void ProxyController::Reset() {
- reader_.Reset();
- ClearPendingHandlers();
-}
-
-zx_status_t ProxyController::OnMessage(Message message) {
- if (!message.has_header())
- return ZX_ERR_INVALID_ARGS;
- zx_txid_t txid = message.txid();
- if (!txid) {
- if (!proxy_)
- return ZX_ERR_NOT_SUPPORTED;
- return proxy_->Dispatch_(std::move(message));
- }
- auto it = handlers_.find(txid);
- if (it == handlers_.end())
- return ZX_ERR_NOT_FOUND;
- std::unique_ptr<MessageHandler> handler = std::move(it->second);
- handlers_.erase(it);
- return handler->OnMessage(std::move(message));
-}
-
-void ProxyController::OnChannelGone() { ClearPendingHandlers(); }
-
-void ProxyController::ClearPendingHandlers() {
- handlers_.clear();
- next_txid_ = 1;
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/stub.cc b/pkg/fidl_cpp/internal/stub.cc
deleted file mode 100644
index 0ddec10..0000000
--- a/pkg/fidl_cpp/internal/stub.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/stub.h"
-
-namespace fidl {
-namespace internal {
-
-Stub::~Stub() = default;
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/stub_controller.cc b/pkg/fidl_cpp/internal/stub_controller.cc
deleted file mode 100644
index 2244229..0000000
--- a/pkg/fidl_cpp/internal/stub_controller.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/stub_controller.h"
-
-#include "lib/fidl/cpp/internal/logging.h"
-#include "lib/fidl/cpp/internal/pending_response.h"
-#include "lib/fidl/cpp/internal/weak_stub_controller.h"
-
-namespace fidl {
-namespace internal {
-
-StubController::StubController() : weak_(nullptr), reader_(this) {}
-
-StubController::~StubController() { InvalidateWeakIfNeeded(); }
-
-zx_status_t StubController::Send(const fidl_type_t* type, Message message) {
- const char* error_msg = nullptr;
- zx_status_t status = message.Validate(type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_ENCODING_ERROR(message, type, error_msg);
- return status;
- }
- return message.Write(reader_.channel().get(), 0);
-}
-
-zx_status_t StubController::OnMessage(Message message) {
- if (!message.has_header())
- return ZX_ERR_INVALID_ARGS;
- zx_txid_t txid = message.txid();
- WeakStubController* weak = nullptr;
- if (txid) {
- if (!weak_)
- weak_ = new WeakStubController(this);
- weak = weak_;
- }
- return stub_->Dispatch_(std::move(message), PendingResponse(txid, weak));
-}
-
-void StubController::OnChannelGone() { InvalidateWeakIfNeeded(); }
-
-void StubController::InvalidateWeakIfNeeded() {
- if (!weak_)
- return;
- weak_->Invalidate();
- weak_->Release();
- weak_ = nullptr;
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/internal/weak_stub_controller.cc b/pkg/fidl_cpp/internal/weak_stub_controller.cc
deleted file mode 100644
index 7693ef7..0000000
--- a/pkg/fidl_cpp/internal/weak_stub_controller.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/weak_stub_controller.h"
-
-namespace fidl {
-namespace internal {
-
-WeakStubController::WeakStubController(StubController* controller)
- : ref_count_(1u), controller_(controller) {}
-
-WeakStubController::~WeakStubController() = default;
-
-void WeakStubController::AddRef() { ++ref_count_; }
-
-void WeakStubController::Release() {
- if (--ref_count_ == 0)
- delete this;
-}
-
-void WeakStubController::Invalidate() { controller_ = nullptr; }
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp/meta.json b/pkg/fidl_cpp/meta.json
deleted file mode 100644
index 37f840f..0000000
--- a/pkg/fidl_cpp/meta.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "deps": [
- "fidl_cpp_sync",
- "async",
- "async-default",
- "fidl",
- "fidl-async",
- "fit",
- "zx"
- ],
- "fidl_deps": [],
- "headers": [
- "pkg/fidl_cpp/include/lib/fidl/cpp/binding.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/binding_set.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/enum.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/interface_ptr_set.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/header.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/implementation.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_handler.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/message_reader.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/pending_response.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/proxy_controller.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/stub_controller.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/internal/weak_stub_controller.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/optional.h",
- "pkg/fidl_cpp/include/lib/fidl/cpp/thread_safe_binding_set.h"
- ],
- "include_dir": "pkg/fidl_cpp/include",
- "name": "fidl_cpp",
- "root": "pkg/fidl_cpp",
- "sources": [
- "pkg/fidl_cpp/internal/message_handler.cc",
- "pkg/fidl_cpp/internal/message_reader.cc",
- "pkg/fidl_cpp/internal/pending_response.cc",
- "pkg/fidl_cpp/internal/proxy.cc",
- "pkg/fidl_cpp/internal/proxy_controller.cc",
- "pkg/fidl_cpp/internal/stub.cc",
- "pkg/fidl_cpp/internal/stub_controller.cc",
- "pkg/fidl_cpp/internal/weak_stub_controller.cc"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/fidl_cpp_base/clone.cc b/pkg/fidl_cpp_base/clone.cc
deleted file mode 100644
index 9b4e80a..0000000
--- a/pkg/fidl_cpp_base/clone.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/clone.h"
-
-namespace fidl {
-
-zx_status_t Clone(const StringPtr& value, StringPtr* result) {
- if (!value) {
- *result = StringPtr();
- } else {
- result->reset(*value);
- }
- return ZX_OK;
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/coding_traits.cc b/pkg/fidl_cpp_base/coding_traits.cc
deleted file mode 100644
index e66d8bd..0000000
--- a/pkg/fidl_cpp_base/coding_traits.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/coding_traits.h"
-
-namespace fidl {
-
-void EncodeNullVector(Encoder* encoder, size_t offset) {
- fidl_vector_t* vector = encoder->GetPtr<fidl_vector_t>(offset);
- vector->count = 0u;
- vector->data = reinterpret_cast<void*>(FIDL_ALLOC_ABSENT);
-}
-
-void EncodeVectorPointer(Encoder* encoder, size_t count, size_t offset) {
- fidl_vector_t* vector = encoder->GetPtr<fidl_vector_t>(offset);
- vector->count = count;
- vector->data = reinterpret_cast<void*>(FIDL_ALLOC_PRESENT);
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/decoder.cc b/pkg/fidl_cpp_base/decoder.cc
deleted file mode 100644
index bec4ee0..0000000
--- a/pkg/fidl_cpp_base/decoder.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/decoder.h"
-
-#include <utility>
-
-namespace fidl {
-
-Decoder::Decoder(Message message) : message_(std::move(message)) {}
-
-Decoder::~Decoder() = default;
-
-size_t Decoder::GetOffset(void* ptr) {
- return GetOffset(reinterpret_cast<uintptr_t>(ptr));
-}
-
-size_t Decoder::GetOffset(uintptr_t ptr) {
- // The |ptr| value comes from the message buffer, which we've already
- // validated. That means it should coorespond to a valid offset within the
- // message.
- return ptr - reinterpret_cast<uintptr_t>(message_.bytes().data());
-}
-
-#ifdef __Fuchsia__
-void Decoder::DecodeHandle(zx::object_base* value, size_t offset) {
- zx_handle_t* handle = GetPtr<zx_handle_t>(offset);
- value->reset(*handle);
- *handle = ZX_HANDLE_INVALID;
-}
-#endif
-
-uint8_t* Decoder::InternalGetPtr(size_t offset) {
- return message_.bytes().data() + offset;
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/encoder.cc b/pkg/fidl_cpp_base/encoder.cc
deleted file mode 100644
index 01ffb44..0000000
--- a/pkg/fidl_cpp_base/encoder.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/encoder.h"
-
-#include <zircon/assert.h>
-#include <zircon/fidl.h>
-
-namespace fidl {
-namespace {
-
-size_t Align(size_t size) {
- constexpr size_t alignment_mask = FIDL_ALIGNMENT - 1;
- return (size + alignment_mask) & ~alignment_mask;
-}
-
-} // namespace
-
-Encoder::Encoder(uint32_t ordinal) { EncodeMessageHeader(ordinal); }
-
-Encoder::~Encoder() = default;
-
-size_t Encoder::Alloc(size_t size) {
- size_t offset = bytes_.size();
- size_t new_size = bytes_.size() + Align(size);
- ZX_ASSERT(new_size >= offset);
- bytes_.resize(new_size);
- return offset;
-}
-
-#ifdef __Fuchsia__
-void Encoder::EncodeHandle(zx::object_base* value, size_t offset) {
- if (value->is_valid()) {
- *GetPtr<zx_handle_t>(offset) = FIDL_HANDLE_PRESENT;
- handles_.push_back(value->release());
- } else {
- *GetPtr<zx_handle_t>(offset) = FIDL_HANDLE_ABSENT;
- }
-}
-#endif
-
-Message Encoder::GetMessage() {
- return Message(BytePart(bytes_.data(), bytes_.size(), bytes_.size()),
- HandlePart(handles_.data(), handles_.size(), handles_.size()));
-}
-
-void Encoder::Reset(uint32_t ordinal) {
- bytes_.clear();
- handles_.clear();
- EncodeMessageHeader(ordinal);
-}
-
-void Encoder::EncodeMessageHeader(uint32_t ordinal) {
- size_t offset = Alloc(sizeof(fidl_message_header_t));
- fidl_message_header_t* header = GetPtr<fidl_message_header_t>(offset);
- header->ordinal = ordinal;
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/array.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/array.h
deleted file mode 100644
index aeb35e6..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/array.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_ARRAY_H_
-#define LIB_FIDL_CPP_ARRAY_H_
-
-#include <stddef.h>
-#include <string.h>
-
-#include <lib/fidl/cpp/comparison.h>
-
-namespace fidl {
-
-template <typename T, size_t N>
-class Array {
- public:
- Array() { memset(data_, 0, sizeof(data_)); }
-
- constexpr size_t size() const { return N; }
-
- // TODO(FIDL-245) Remove this overload.
- constexpr size_t count() const { return N; }
-
- const T* data() const { return data_; }
- T* data() { return data_; }
-
- // TODO(FIDL-245) Remove this overload.
- T* mutable_data() { return data_; }
-
- const T& at(size_t offset) const { return data()[offset]; }
- T& at(size_t offset) { return mutable_data()[offset]; }
-
- const T& operator[](size_t offset) const { return at(offset); }
- T& operator[](size_t offset) { return at(offset); }
-
- T* begin() { return mutable_data(); }
- const T* begin() const { return data(); }
- const T* cbegin() const { return data(); }
-
- T* end() { return mutable_data() + count(); }
- const T* end() const { return data() + count(); }
- const T* cend() const { return data() + count(); }
-
- private:
- static_assert(N > 0, "fid::Array cannot have zero elements.");
-
- T data_[N];
-};
-
-template <typename T, size_t N>
-bool operator==(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- for (size_t i = 0; i < N; ++i) {
- if (!Equals(lhs[i], rhs[i])) {
- return false;
- }
- }
- return true;
-}
-
-template <typename T, size_t N>
-bool operator!=(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- return !(lhs == rhs);
-}
-
-template <typename T, size_t N>
-bool operator<(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- for (size_t i = 0; i < N; i++) {
- if (lhs[i] != rhs[i]) {
- return lhs[i] < rhs[i];
- }
- }
- return false;
-}
-
-template <typename T, size_t N>
-bool operator>(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- for (size_t i = 0; i < N; i++) {
- if (lhs[i] != rhs[i]) {
- return lhs[i] > rhs[i];
- }
- }
- return false;
-}
-
-template <typename T, size_t N>
-bool operator<=(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- return !(lhs > rhs);
-}
-
-template <typename T, size_t N>
-bool operator>=(const Array<T, N>& lhs, const Array<T, N>& rhs) {
- return !(lhs < rhs);
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_ARRAY_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/clone.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/clone.h
deleted file mode 100644
index 8c1c108..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/clone.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_CLONE_H_
-#define LIB_FIDL_CPP_CLONE_H_
-
-#include <lib/fidl/cpp/array.h>
-#include <zircon/assert.h>
-#include <memory>
-#include "lib/fidl/cpp/string.h"
-#include "lib/fidl/cpp/traits.h"
-#include "lib/fidl/cpp/vector.h"
-
-namespace fidl {
-
-#ifdef __Fuchsia__
-namespace internal {
-
-template <typename T>
-inline typename std::enable_if<zx::object_traits<T>::supports_duplication,
- zx_status_t>::type
-CloneKernelObject(const zx::object<T>& object, zx::object<T>* result) {
- return object.duplicate(ZX_RIGHT_SAME_RIGHTS, result);
-}
-
-template <typename T>
-inline typename std::enable_if<!zx::object_traits<T>::supports_duplication,
- zx_status_t>::type
-CloneKernelObject(const zx::object<T>& object, zx::object<T>* result) {
- return ZX_ERR_ACCESS_DENIED;
-}
-
-} // namespace internal
-#endif // __Fuchsia__
-
-// Deep copies the contents of |value| into |result|.
-// This operation also attempts to duplicate any handles the value contains.
-//
-// Returns an error if the value could not be cloned, perhaps because a
-// handle was not duplicable.
-//
-// There are many overloads of this function with the following signature:
-// zx_status_t Clone(const T& value, T* result);
-template <typename T>
-inline typename std::enable_if<IsPrimitive<T>::value, zx_status_t>::type Clone(
- const T& value, T* result) {
- *result = value;
- return ZX_OK;
-}
-
-template <typename T>
-inline
-#ifdef __Fuchsia__
- typename std::enable_if<!IsPrimitive<T>::value &&
- !std::is_base_of<zx::object_base, T>::value,
- zx_status_t>::type
-#else // __Fuchsia__
- typename std::enable_if<!IsPrimitive<T>::value, zx_status_t>::type
-#endif // __Fuchsia__
- Clone(const T& value, T* result) {
- return value.Clone(result);
-}
-
-#ifdef __Fuchsia__
-template <typename T>
-zx_status_t Clone(const zx::object<T>& value, zx::object<T>* result) {
- if (!value) {
- result->reset();
- return ZX_OK;
- }
- return internal::CloneKernelObject(value, result);
-}
-#endif // __Fuchsia__
-
-template <typename T>
-inline zx_status_t Clone(const std::unique_ptr<T>& value,
- std::unique_ptr<T>* result) {
- if (!value) {
- result->reset();
- return ZX_OK;
- }
- *result = std::make_unique<T>();
- return Clone(*value, result->get());
-}
-
-template <typename T>
-inline typename std::enable_if<!IsPrimitive<T>::value, zx_status_t>::type Clone(
- const VectorPtr<T>& value, VectorPtr<T>* result) {
- if (!value) {
- *result = VectorPtr<T>();
- return ZX_OK;
- }
- result->resize(value->size());
- for (size_t i = 0; i < value->size(); ++i) {
- zx_status_t status = Clone(value->at(i), &(*result)->at(i));
- if (status != ZX_OK)
- return status;
- }
- return ZX_OK;
-}
-
-template <typename T>
-inline typename std::enable_if<IsPrimitive<T>::value, zx_status_t>::type Clone(
- const VectorPtr<T>& value, VectorPtr<T>* result) {
- if (!value) {
- *result = VectorPtr<T>();
- return ZX_OK;
- }
- result->reset(*value);
- return ZX_OK;
-}
-
-template <typename T, size_t N>
-inline zx_status_t Clone(const Array<T, N>& value, Array<T, N>* result) {
- for (size_t i = 0; i < N; ++i) {
- zx_status_t status = Clone(value[i], &result->at(i));
- if (status != ZX_OK)
- return status;
- }
- return ZX_OK;
-}
-
-zx_status_t Clone(const StringPtr& value, StringPtr* result);
-
-// Returns a deep copy of |value|.
-// This operation also attempts to duplicate any handles the value contains.
-//
-// Crashes the program if the value could not be cloned, perhaps because a
-// handle was not duplicable.
-template <typename T>
-inline T Clone(const T& value) {
- T clone;
- zx_status_t status = Clone(value, &clone);
- ZX_ASSERT(status == ZX_OK);
- return clone;
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_CODING_TRAITS_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/coding_traits.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/coding_traits.h
deleted file mode 100644
index 0a51f5a..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/coding_traits.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_CODING_TRAITS_H_
-#define LIB_FIDL_CPP_CODING_TRAITS_H_
-
-#include <lib/fidl/cpp/array.h>
-
-#include <memory>
-
-#include "lib/fidl/cpp/decoder.h"
-#include "lib/fidl/cpp/encoder.h"
-#include "lib/fidl/cpp/traits.h"
-#include "lib/fidl/cpp/vector.h"
-
-namespace fidl {
-
-template <typename T, class Enable = void>
-struct CodingTraits;
-
-template <typename T>
-struct CodingTraits<T, typename std::enable_if<IsPrimitive<T>::value>::type> {
- static constexpr size_t encoded_size = sizeof(T);
- inline static void Encode(Encoder* encoder, T* value, size_t offset) {
- *encoder->GetPtr<T>(offset) = *value;
- }
- inline static void Decode(Decoder* decoder, T* value, size_t offset) {
- *value = *decoder->GetPtr<T>(offset);
- }
-};
-
-template <>
-struct CodingTraits<bool> {
- static constexpr size_t encoded_size = sizeof(bool);
- inline static void Encode(Encoder* encoder, bool* value, size_t offset) {
- *encoder->GetPtr<bool>(offset) = *value;
- }
- inline static void Encode(Encoder* encoder, std::vector<bool>::iterator value,
- size_t offset) {
- *encoder->GetPtr<bool>(offset) = *value;
- }
- inline static void Decode(Decoder* decoder, bool* value, size_t offset) {
- *value = *decoder->GetPtr<bool>(offset);
- }
- inline static void Decode(Decoder* decoder, std::vector<bool>::iterator value,
- size_t offset) {
- *value = *decoder->GetPtr<bool>(offset);
- }
-};
-
-#ifdef __Fuchsia__
-template <typename T>
-struct CodingTraits<T, typename std::enable_if<
- std::is_base_of<zx::object_base, T>::value>::type> {
- static constexpr size_t encoded_size = sizeof(zx_handle_t);
- static void Encode(Encoder* encoder, zx::object_base* value, size_t offset) {
- encoder->EncodeHandle(value, offset);
- }
- static void Decode(Decoder* decoder, zx::object_base* value, size_t offset) {
- decoder->DecodeHandle(value, offset);
- }
-};
-#endif
-
-template <typename T>
-struct CodingTraits<std::unique_ptr<T>> {
- static constexpr size_t encoded_size = sizeof(uintptr_t);
- static void Encode(Encoder* encoder, std::unique_ptr<T>* value,
- size_t offset) {
- if (value->get()) {
- *encoder->GetPtr<uintptr_t>(offset) = FIDL_ALLOC_PRESENT;
- size_t size = CodingTraits<T>::encoded_size;
- CodingTraits<T>::Encode(encoder, value->get(), encoder->Alloc(size));
- } else {
- *encoder->GetPtr<uintptr_t>(offset) = FIDL_ALLOC_ABSENT;
- }
- }
- static void Decode(Decoder* decoder, std::unique_ptr<T>* value,
- size_t offset) {
- uintptr_t ptr = *decoder->GetPtr<uintptr_t>(offset);
- if (!ptr)
- return value->reset();
- *value = std::make_unique<T>();
- CodingTraits<T>::Decode(decoder, value->get(), decoder->GetOffset(ptr));
- }
-};
-
-void EncodeNullVector(Encoder* encoder, size_t offset);
-void EncodeVectorPointer(Encoder* encoder, size_t count, size_t offset);
-
-template <typename T>
-struct CodingTraits<VectorPtr<T>> {
- static constexpr size_t encoded_size = sizeof(fidl_vector_t);
- static void Encode(Encoder* encoder, VectorPtr<T>* value, size_t offset) {
- if (value->is_null())
- return EncodeNullVector(encoder, offset);
- size_t count = (*value)->size();
- EncodeVectorPointer(encoder, count, offset);
- size_t stride = CodingTraits<T>::encoded_size;
- size_t base = encoder->Alloc(count * stride);
- for (size_t i = 0; i < count; ++i)
- CodingTraits<T>::Encode(encoder, &(*value)->at(i), base + i * stride);
- }
- static void Decode(Decoder* decoder, VectorPtr<T>* value, size_t offset) {
- fidl_vector_t* encoded = decoder->GetPtr<fidl_vector_t>(offset);
- if (!encoded->data) {
- *value = VectorPtr<T>();
- return;
- }
- value->resize(encoded->count);
- size_t stride = CodingTraits<T>::encoded_size;
- size_t base = decoder->GetOffset(encoded->data);
- size_t count = encoded->count;
- for (size_t i = 0; i < count; ++i)
- CodingTraits<T>::Decode(decoder, &(*value)->at(i), base + i * stride);
- }
-};
-
-template <typename T, size_t N>
-struct CodingTraits<Array<T, N>> {
- static constexpr size_t encoded_size = CodingTraits<T>::encoded_size * N;
- static void Encode(Encoder* encoder, Array<T, N>* value, size_t offset) {
- size_t stride = CodingTraits<T>::encoded_size;
- for (size_t i = 0; i < N; ++i)
- CodingTraits<T>::Encode(encoder, &value->at(i), offset + i * stride);
- }
- static void Decode(Decoder* decoder, Array<T, N>* value, size_t offset) {
- size_t stride = CodingTraits<T>::encoded_size;
- for (size_t i = 0; i < N; ++i)
- CodingTraits<T>::Decode(decoder, &value->at(i), offset + i * stride);
- }
-};
-
-template <typename T, size_t EncodedSize>
-struct EncodableCodingTraits {
- static constexpr size_t encoded_size = EncodedSize;
- static void Encode(Encoder* encoder, T* value, size_t offset) {
- value->Encode(encoder, offset);
- }
- static void Decode(Decoder* decoder, T* value, size_t offset) {
- T::Decode(decoder, value, offset);
- }
-};
-
-template <typename T>
-void Encode(Encoder* encoder, T* value, size_t offset) {
- CodingTraits<T>::Encode(encoder, value, offset);
-}
-
-template <typename T>
-void Decode(Decoder* decoder, T* value, size_t offset) {
- CodingTraits<T>::Decode(decoder, value, offset);
-}
-
-template <typename T>
-T DecodeAs(Decoder* decoder, size_t offset) {
- T value;
- Decode(decoder, &value, offset);
- return value;
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_CODING_TRAITS_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/comparison.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/comparison.h
deleted file mode 100644
index f89f352..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/comparison.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GARNET_PUBLIC_LIB_FIDL_CPP_COMPARISON_H_
-#define GARNET_PUBLIC_LIB_FIDL_CPP_COMPARISON_H_
-
-#include <memory>
-
-// Comparisons that uses structure equality on on std::unique_ptr instead of
-// pointer equality.
-namespace fidl {
-
-template <class T>
-inline bool Equals(const T& lhs, const T& rhs) {
- return lhs == rhs;
-}
-
-template <class T>
-inline bool Equals(const std::unique_ptr<T>& lhs,
- const std::unique_ptr<T>& rhs) {
- if (lhs == nullptr || rhs == nullptr) {
- return rhs == lhs;
- }
- return Equals<T>(*lhs, *rhs);
-}
-
-} // namespace fidl
-
-#endif // GARNET_PUBLIC_LIB_FIDL_CPP_COMPARISON_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/decoder.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/decoder.h
deleted file mode 100644
index 119dcd0..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/decoder.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_DECODER_H_
-#define LIB_FIDL_CPP_DECODER_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <zircon/fidl.h>
-
-#ifdef __Fuchsia__
-#include <lib/zx/object.h>
-#endif
-
-namespace fidl {
-
-class Decoder {
- public:
- explicit Decoder(Message message);
- ~Decoder();
-
- template <typename T>
- T* GetPtr(size_t offset) {
- return reinterpret_cast<T*>(InternalGetPtr(offset));
- }
-
- size_t GetOffset(void* ptr);
- size_t GetOffset(uintptr_t ptr);
-
-#ifdef __Fuchsia__
- void DecodeHandle(zx::object_base* value, size_t offset);
-#endif
-
- private:
- uint8_t* InternalGetPtr(size_t offset);
-
- Message message_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_DECODER_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/encoder.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/encoder.h
deleted file mode 100644
index 00f543e..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/encoder.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_ENCODER_H_
-#define LIB_FIDL_CPP_ENCODER_H_
-
-#include <lib/fidl/cpp/message.h>
-
-#ifdef __Fuchsia__
-#include <lib/zx/object.h>
-#endif
-
-#include <zircon/fidl.h>
-
-#include <vector>
-
-namespace fidl {
-
-class Encoder {
- public:
- enum NoHeader { NO_HEADER };
-
- explicit Encoder(uint32_t ordinal);
- explicit Encoder(NoHeader) {}
- ~Encoder();
-
- size_t Alloc(size_t size);
-
- template <typename T>
- T* GetPtr(size_t offset) {
- return reinterpret_cast<T*>(bytes_.data() + offset);
- }
-
-#ifdef __Fuchsia__
- void EncodeHandle(zx::object_base* value, size_t offset);
-#endif
-
- Message GetMessage();
-
- void Reset(uint32_t ordinal);
-
- size_t CurrentLength() const { return bytes_.size(); }
-
- size_t CurrentHandleCount() const { return handles_.size(); }
-
- std::vector<uint8_t> TakeBytes() { return std::move(bytes_); }
-
- private:
- void EncodeMessageHeader(uint32_t ordinal);
-
- std::vector<uint8_t> bytes_;
- std::vector<zx_handle_t> handles_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_ENCODER_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/internal/logging.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/internal/logging.h
deleted file mode 100644
index 4ed4132..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/internal/logging.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_LOGGING_H_
-#define LIB_FIDL_CPP_INTERNAL_LOGGING_H_
-
-#include <lib/fidl/cpp/message.h>
-
-namespace fidl {
-namespace internal {
-
-void ReportEncodingError(const Message& message, const fidl_type_t* type,
- const char* error_msg, const char* file, int line);
-
-void ReportDecodingError(const Message& message, const fidl_type_t* type,
- const char* error_msg, const char* file, int line);
-
-void ReportChannelWritingError(const Message& message, const fidl_type_t* type,
- zx_status_t status, const char* file, int line);
-
-#define FIDL_REPORT_ENCODING_ERROR(message, type, error_msg) \
- ::fidl::internal::ReportEncodingError((message), (type), (error_msg), \
- __FILE__, __LINE__)
-
-#define FIDL_REPORT_DECODING_ERROR(message, type, error_msg) \
- ::fidl::internal::ReportDecodingError((message), (type), (error_msg), \
- __FILE__, __LINE__)
-
-#define FIDL_REPORT_CHANNEL_WRITING_ERROR(message, type, status) \
- ::fidl::internal::ReportChannelWritingError((message), (type), (status), \
- __FILE__, __LINE__)
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_LOGGING_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/object_coding.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/object_coding.h
deleted file mode 100644
index 202b266..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/object_coding.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "coding_traits.h"
-#include "encoder.h"
-
-namespace fidl {
-
-template <class T>
-zx_status_t EncodeObject(T* object, std::vector<uint8_t>* output,
- const char** error_msg_out) {
- Encoder encoder(Encoder::NO_HEADER);
- object->Encode(&encoder, encoder.Alloc(CodingTraits<T>::encoded_size));
- if (encoder.CurrentHandleCount() != 0) {
- if (error_msg_out != nullptr) {
- *error_msg_out = "Cannot encode handles with object encoding";
- }
- return ZX_ERR_INVALID_ARGS;
- }
- *output = encoder.TakeBytes();
- return ZX_OK;
-}
-
-template <class T>
-zx_status_t DecodeObject(uint8_t* bytes, size_t bytes_length, T* object,
- const char** error_msg_out) {
- Message msg(BytePart(bytes, bytes_length, bytes_length), HandlePart());
- zx_status_t status = msg.Decode(T::FidlType, error_msg_out);
- if (status != ZX_OK) {
- return status;
- }
- Decoder decoder(std::move(msg));
- T::Decode(&decoder, object, 0);
- return ZX_OK;
-}
-
-template <class T>
-zx_status_t ValidateObject(uint8_t* bytes, size_t bytes_length, T* object,
- const char** error_msg_out) {
- return Message(BytePart(bytes, bytes_length, bytes_length), HandlePart())
- .Validate(T::FidlType, error_msg_out);
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/string.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/string.h
deleted file mode 100644
index 3318bb7..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/string.h
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_STRING_H_
-#define LIB_FIDL_CPP_STRING_H_
-
-#include <lib/fidl/cpp/builder.h>
-#include <lib/fidl/cpp/string_view.h>
-
-#include <iosfwd>
-#include <string>
-#include <utility>
-
-#include <zircon/assert.h>
-
-#include "lib/fidl/cpp/coding_traits.h"
-#include "lib/fidl/cpp/traits.h"
-
-namespace fidl {
-
-// A representation of a FIDL string that owns the memory for the string.
-//
-// A StringPtr has three states: (1) null, (2) empty, (3) contains a string. In
-// the second state, operations that return an std::string return the empty
-// std::string. The null and empty states can be distinguished using the
-// |is_null| and |operator bool| methods.
-class StringPtr {
- public:
- StringPtr();
- StringPtr(const StringPtr& other);
- StringPtr(StringPtr&& other);
- StringPtr(std::string str);
- StringPtr(const char* str);
- StringPtr(const char* str, size_t length);
- ~StringPtr();
-
- StringPtr& operator=(const StringPtr&);
- StringPtr& operator=(StringPtr&& other);
-
- // Accesses the underlying std::string object.
- const std::string& get() const { return str_; }
-
- // Stores the given std::string in this StringPtr.
- //
- // After this method returns, the StringPtr is non-null.
- void reset(std::string str) {
- str_ = std::move(str);
- is_null_ = false;
- }
-
- // Causes this StringPtr to become null.
- void reset() {
- str_.clear();
- is_null_ = true;
- }
-
- void swap(StringPtr& other) {
- using std::swap;
- swap(str_, other.str_);
- swap(is_null_, other.is_null_);
- }
-
- // Whether this StringPtr is null.
- //
- // The null state is separate from the empty state.
- bool is_null() const { return is_null_ && str_.empty(); }
-
- // Tests as true if non-null, false if null.
- explicit operator bool() const { return !is_null_; }
-
- // Provides access to the underlying std::string.
- std::string* operator->() { return &str_; }
- const std::string* operator->() const { return &str_; }
-
- // Provides access to the underlying std::string.
- const std::string& operator*() const { return str_; }
-
- operator const std::string&() const { return str_; }
-
- void Encode(Encoder* encoder, size_t offset);
- static void Decode(Decoder* decoder, StringPtr* value, size_t offset);
-
- private:
- std::string str_;
- bool is_null_;
-};
-
-inline bool operator==(const StringPtr& a, const StringPtr& b) {
- if (a.is_null()) {
- return b.is_null();
- }
- return !b.is_null() && a.get() == b.get();
-}
-
-inline bool operator==(const char* a, const StringPtr& b) {
- if (a == nullptr) {
- return b.is_null();
- }
- return !b.is_null() && a == b.get();
-}
-
-inline bool operator==(const StringPtr& a, const char* b) {
- if (a.is_null()) {
- return b == nullptr;
- }
- return b != nullptr && a.get() == b;
-}
-
-inline bool operator!=(const StringPtr& a, const StringPtr& b) {
- return !(a == b);
-}
-
-inline bool operator!=(const char* a, const StringPtr& b) { return !(a == b); }
-
-inline bool operator!=(const StringPtr& a, const char* b) { return !(a == b); }
-
-inline bool operator<(const StringPtr& a, const StringPtr& b) {
- if (a.is_null() || b.is_null()) {
- return !b.is_null();
- }
- return *a < *b;
-}
-
-inline bool operator<(const char* a, const StringPtr& b) {
- if (a == nullptr || b.is_null()) {
- return !b.is_null();
- }
- return a < *b;
-}
-
-inline bool operator<(const StringPtr& a, const char* b) {
- if (a.is_null() || b == nullptr) {
- return b != nullptr;
- }
- return *a < b;
-}
-
-inline bool operator>(const StringPtr& a, const StringPtr& b) {
- if (a.is_null() || b.is_null()) {
- return !a.is_null();
- }
- return *a > *b;
-}
-
-inline bool operator>(const char* a, const StringPtr& b) {
- if (a == nullptr || b.is_null()) {
- return a != nullptr;
- }
- return a > *b;
-}
-
-inline bool operator>(const StringPtr& a, const char* b) {
- if (a.is_null() || b == nullptr) {
- return a != nullptr;
- }
- return *a > b;
-}
-
-inline bool operator<=(const StringPtr& a, const StringPtr& b) {
- return !(a > b);
-}
-
-inline bool operator<=(const char* a, const StringPtr& b) { return !(a > b); }
-
-inline bool operator<=(const StringPtr& a, const char* b) { return !(a > b); }
-
-inline bool operator>=(const StringPtr& a, const StringPtr& b) {
- return !(a < b);
-}
-
-inline bool operator>=(const char* a, const StringPtr& b) { return !(a < b); }
-
-inline bool operator>=(const StringPtr& a, const char* b) { return !(a < b); }
-
-inline std::ostream& operator<<(std::ostream& out, const StringPtr& str) {
- return out << str.get();
-}
-
-template <>
-struct CodingTraits<StringPtr>
- : public EncodableCodingTraits<StringPtr, sizeof(fidl_string_t)> {};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_STRING_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/traits.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/traits.h
deleted file mode 100644
index 9ce7b3a..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/traits.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_TRAITS_H_
-#define LIB_FIDL_CPP_TRAITS_H_
-
-#include <stdint.h>
-
-#include <type_traits>
-
-namespace fidl {
-
-// A type trait that indiciates whether the given type is a primitive FIDL
-// type.
-template <typename T>
-struct IsPrimitive : public std::false_type {};
-
-// clang-format off
-template <> struct IsPrimitive<bool> : public std::true_type {};
-template <> struct IsPrimitive<uint8_t> : public std::true_type {};
-template <> struct IsPrimitive<uint16_t> : public std::true_type {};
-template <> struct IsPrimitive<uint32_t> : public std::true_type {};
-template <> struct IsPrimitive<uint64_t> : public std::true_type {};
-template <> struct IsPrimitive<int8_t> : public std::true_type {};
-template <> struct IsPrimitive<int16_t> : public std::true_type {};
-template <> struct IsPrimitive<int32_t> : public std::true_type {};
-template <> struct IsPrimitive<int64_t> : public std::true_type {};
-template <> struct IsPrimitive<float> : public std::true_type {};
-template <> struct IsPrimitive<double> : public std::true_type {};
-// clang-format on
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_TRAITS_H_
diff --git a/pkg/fidl_cpp_base/include/lib/fidl/cpp/vector.h b/pkg/fidl_cpp_base/include/lib/fidl/cpp/vector.h
deleted file mode 100644
index 02d718c..0000000
--- a/pkg/fidl_cpp_base/include/lib/fidl/cpp/vector.h
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_VECTOR_H_
-#define LIB_FIDL_CPP_VECTOR_H_
-
-#include <lib/fidl/cpp/builder.h>
-#include <lib/fidl/cpp/comparison.h>
-#include <lib/fidl/cpp/vector_view.h>
-
-#include <utility>
-#include <vector>
-
-#include <zircon/assert.h>
-
-#include "lib/fidl/cpp/traits.h"
-
-namespace fidl {
-
-// A representation of a FIDL vector that owns the memory for the vector.
-//
-// A VectorPtr has three states: (1) null, (2) empty, (3) contains data. You
-// can check for the null state using the |is_null| method.
-template <typename T>
-class VectorPtr {
- public:
- VectorPtr() : is_null_if_empty_(true) {}
- ~VectorPtr() = default;
- VectorPtr(std::nullptr_t) : is_null_if_empty_(true) {}
- explicit VectorPtr(size_t size)
- : vec_(std::vector<T>(size)), is_null_if_empty_(false) {}
- explicit VectorPtr(std::vector<T> vec)
- : vec_(std::move(vec)), is_null_if_empty_(false) {}
-
- VectorPtr(const VectorPtr&) = delete;
- VectorPtr& operator=(const VectorPtr&) = delete;
-
- VectorPtr(VectorPtr&& other) = default;
- VectorPtr& operator=(VectorPtr&& other) = default;
-
- // Creates a VectorPtr of the given size.
- //
- // Equivalent to using the |VectorPtr(size_t)| constructor.
- static VectorPtr New(size_t size) { return VectorPtr(size); }
-
- // Accesses the underlying std::vector object.
- const std::vector<T>& get() const { return vec_; }
-
- // Takes the std::vector from the VectorPtr.
- //
- // After this method returns, the VectorPtr is null.
- std::vector<T> take() {
- is_null_if_empty_ = true;
- return std::move(vec_);
- }
-
- // Stores the given std::vector in this VectorPtr.
- //
- // After this method returns, the VectorPtr is non-null.
- void reset(std::vector<T> vec) {
- vec_ = std::move(vec);
- is_null_if_empty_ = false;
- }
-
- void reset() {
- vec_.clear();
- is_null_if_empty_ = true;
- }
-
- // Resizes the underlying std::vector in this VectorPtr to the given size.
- //
- // After this method returns, the VectorPtr is non-null.
- void resize(size_t size) {
- vec_.resize(size);
- is_null_if_empty_ = false;
- }
-
- // Pushes |value| onto the back of this VectorPtr.
- //
- // If this vector was null, it will become non-null with a size of 1.
- void push_back(const T& value) {
- vec_.push_back(value);
- is_null_if_empty_ = false;
- }
-
- // Pushes |value| onto the back of this VectorPtr.
- //
- // If this vector was null, it will become non-null with a size of 1.
- void push_back(T&& value) {
- vec_.push_back(std::forward<T>(value));
- is_null_if_empty_ = false;
- }
-
- void swap(VectorPtr& other) {
- using std::swap;
- swap(vec_, other.vec_);
- swap(is_null_if_empty_, other.is_null_if_empty_);
- }
-
- // Returns a copy of this VectorPtr.
- //
- // Unlike fidl::Clone, this function can never fail. However, this function
- // works only if T is copiable.
- VectorPtr Clone() const {
- if (is_null())
- return VectorPtr();
- return VectorPtr(vec_);
- }
-
- // Whether this VectorPtr is null.
- //
- // The null state is separate from the empty state.
- bool is_null() const { return is_null_if_empty_ && vec_.empty(); }
-
- // Tests as true if non-null, false if null.
- explicit operator bool() const { return !is_null(); }
-
- // Provides access to the underlying std::vector.
- std::vector<T>* operator->() { return &vec_; }
- const std::vector<T>* operator->() const { return &vec_; }
-
- // Provides access to the underlying std::vector.
- std::vector<T>& operator*() { return vec_; }
- const std::vector<T>& operator*() const { return vec_; }
-
- operator const std::vector<T>&() const { return vec_; }
-
- private:
- std::vector<T> vec_;
- bool is_null_if_empty_;
-};
-
-template <class T>
-inline bool operator==(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- if (lhs.is_null() || rhs.is_null()) {
- return lhs.is_null() == rhs.is_null();
- }
- if (lhs->size() != rhs->size()) {
- return false;
- }
- for (size_t i = 0; i < lhs->size(); ++i) {
- if (!Equals(lhs->at(i), rhs->at(i))) {
- return false;
- }
- }
- return true;
-}
-
-template <class T>
-inline bool operator!=(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- return !(lhs == rhs);
-}
-
-template <class T>
-inline bool operator<(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- if (lhs.is_null() || rhs.is_null()) {
- return !rhs.is_null();
- }
- return *lhs < *rhs;
-}
-
-template <class T>
-inline bool operator>(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- if (lhs.is_null() || rhs.is_null()) {
- return !lhs.is_null();
- }
- return *lhs > *rhs;
-}
-
-template <class T>
-inline bool operator<=(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- return !(lhs > rhs);
-}
-
-template <class T>
-inline bool operator>=(const VectorPtr<T>& lhs, const VectorPtr<T>& rhs) {
- return !(lhs < rhs);
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_VECTOR_H_
diff --git a/pkg/fidl_cpp_base/internal/logging.cc b/pkg/fidl_cpp_base/internal/logging.cc
deleted file mode 100644
index c9fd77d..0000000
--- a/pkg/fidl_cpp_base/internal/logging.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/logging.h"
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-namespace fidl {
-namespace internal {
-
-void ReportEncodingError(const Message& message, const fidl_type_t* type,
- const char* error_msg, const char* file, int line) {
- char type_name[1024];
- size_t type_name_length =
- fidl_format_type_name(type, type_name, sizeof(type_name));
- fprintf(stderr,
- "fidl encoding error at %s:%d: %s, "
- "type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
- file, line, error_msg, static_cast<int>(type_name_length), type_name,
- message.bytes().actual(), message.handles().actual());
-}
-
-void ReportDecodingError(const Message& message, const fidl_type_t* type,
- const char* error_msg, const char* file, int line) {
- char type_name[1024];
- size_t type_name_length =
- fidl_format_type_name(type, type_name, sizeof(type_name));
- fprintf(stderr,
- "fidl decoding error at %s:%d: %s, "
- "type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
- file, line, error_msg, static_cast<int>(type_name_length), type_name,
- message.bytes().actual(), message.handles().actual());
-}
-
-void ReportChannelWritingError(const Message& message, const fidl_type_t* type,
- zx_status_t status, const char* file, int line) {
- char type_name[1024];
- size_t type_name_length =
- fidl_format_type_name(type, type_name, sizeof(type_name));
- fprintf(stderr,
- "fidl channel writing error at %s:%d: zx_status_t %d, "
- "type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
- file, line, status, static_cast<int>(type_name_length), type_name,
- message.bytes().actual(), message.handles().actual());
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp_base/meta.json b/pkg/fidl_cpp_base/meta.json
deleted file mode 100644
index 29eb264..0000000
--- a/pkg/fidl_cpp_base/meta.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "deps": [
- "fit",
- "fidl",
- "fidl-async",
- "zx"
- ],
- "fidl_deps": [],
- "headers": [
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/array.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/clone.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/coding_traits.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/comparison.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/decoder.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/encoder.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/internal/logging.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/object_coding.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/string.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/traits.h",
- "pkg/fidl_cpp_base/include/lib/fidl/cpp/vector.h"
- ],
- "include_dir": "pkg/fidl_cpp_base/include",
- "name": "fidl_cpp_base",
- "root": "pkg/fidl_cpp_base",
- "sources": [
- "pkg/fidl_cpp_base/clone.cc",
- "pkg/fidl_cpp_base/coding_traits.cc",
- "pkg/fidl_cpp_base/decoder.cc",
- "pkg/fidl_cpp_base/encoder.cc",
- "pkg/fidl_cpp_base/internal/logging.cc",
- "pkg/fidl_cpp_base/string.cc"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/fidl_cpp_base/string.cc b/pkg/fidl_cpp_base/string.cc
deleted file mode 100644
index 35b8f46..0000000
--- a/pkg/fidl_cpp_base/string.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/string.h"
-
-#include <string.h>
-
-#include "lib/fidl/cpp/encoder.h"
-
-namespace fidl {
-
-StringPtr::StringPtr() : is_null_(true) {}
-
-StringPtr::StringPtr(const StringPtr& other) = default;
-
-StringPtr::StringPtr(std::string str) : str_(std::move(str)), is_null_(false) {}
-
-StringPtr::StringPtr(const char* str)
- : str_(str ? std::string(str) : std::string()), is_null_(!str) {}
-
-StringPtr::StringPtr(const char* str, size_t length)
- : str_(str ? std::string(str, length) : std::string()), is_null_(!str) {}
-
-StringPtr::~StringPtr() = default;
-
-StringPtr::StringPtr(StringPtr&& other)
- : str_(std::move(other.str_)), is_null_(other.is_null_) {}
-
-StringPtr& StringPtr::operator=(const StringPtr& other) = default;
-
-StringPtr& StringPtr::operator=(StringPtr&& other) {
- str_ = std::move(other.str_);
- is_null_ = other.is_null_;
- return *this;
-}
-
-void StringPtr::Encode(Encoder* encoder, size_t offset) {
- fidl_string_t* string = encoder->GetPtr<fidl_string_t>(offset);
- if (is_null()) {
- string->size = 0u;
- string->data = reinterpret_cast<char*>(FIDL_ALLOC_ABSENT);
- } else {
- string->size = str_.size();
- string->data = reinterpret_cast<char*>(FIDL_ALLOC_PRESENT);
- size_t base = encoder->Alloc(str_.size());
- char* payload = encoder->GetPtr<char>(base);
- memcpy(payload, str_.data(), str_.size());
- }
-}
-
-void StringPtr::Decode(Decoder* decoder, StringPtr* value, size_t offset) {
- fidl_string_t* string = decoder->GetPtr<fidl_string_t>(offset);
- if (string->data) {
- value->reset(std::string(string->data, string->size));
- } else {
- *value = StringPtr();
- }
-}
-
-} // namespace fidl
diff --git a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_handle.h b/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_handle.h
deleted file mode 100644
index 2257a00..0000000
--- a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_handle.h
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERFACE_HANDLE_H_
-#define LIB_FIDL_CPP_INTERFACE_HANDLE_H_
-
-#include <lib/zx/channel.h>
-#include <zircon/assert.h>
-
-#include <cstddef>
-#include <utility>
-
-#include "lib/fidl/cpp/clone.h"
-#include "lib/fidl/cpp/coding_traits.h"
-#include "lib/fidl/cpp/interface_request.h"
-
-namespace fidl {
-class Builder;
-template <typename Interface>
-class InterfacePtr;
-template <typename Interface>
-class SynchronousInterfacePtr;
-
-// The client endpoint of a FIDL channel.
-//
-// The remote end of the channel expects this end of the channel to speak the
-// protocol associated with |Interface|. This type is the dual of
-// |InterfaceRequest|.
-//
-// Unlike an |InterfacePtr|, an |InterfaceHandle| does not have thread affinity
-// and can therefore be transferred to another thread or another process. To
-// create an |InterfacePtr| to send messages on this channel, call the |Bind()|
-// method, either on the |InterfaceHandle| or the |InterfacePtr| object.
-//
-// See also:
-//
-// * |InterfaceRequest|, which is the server analog of an |InterfaceHandle|.
-template <typename Interface>
-class InterfaceHandle {
- public:
- // Creates an |InterfaceHandle| whose underlying channel is invalid.
- InterfaceHandle() = default;
-
- // Creates an |InterfaceHandle| that wraps the given |channel|.
- explicit InterfaceHandle(zx::channel channel)
- : channel_(std::move(channel)) {}
-
- InterfaceHandle(const InterfaceHandle& other) = delete;
- InterfaceHandle& operator=(const InterfaceHandle& other) = delete;
-
- InterfaceHandle(InterfaceHandle&& other)
- : channel_(std::move(other.channel_)) {}
-
- InterfaceHandle& operator=(InterfaceHandle&& other) {
- channel_ = std::move(other.channel_);
- return *this;
- }
-
- // Implicit conversion from nullptr to an |InterfaceHandle| without a valid
- // |channel|.
- InterfaceHandle(std::nullptr_t) {}
-
- // Implicit conversion from |InterfacePtr| unbinds the channel from the
- // |InterfacePtr|.
- //
- // Making this constructor templated ensures that it is not type-instantiated
- // unless it is used, making the InterfacePtr<->InterfaceHandle codependency
- // less fragile.
- template <typename InterfacePtr = InterfacePtr<Interface>>
- InterfaceHandle(InterfacePtr&& ptr) {
- *this = ptr.Unbind();
- }
-
- // Creates a new channel, retains one endpoint in this |InterfaceHandle| and
- // returns the other as an |InterfaceRequest|.
- //
- // Typically, the returned |InterfaceRequest| is passed to another process,
- // which will implement the server endpoint for the |Interface| protocol.
- //
- // If |NewRequest| fails to create the underlying channel, the returned
- // |InterfaceRequest| will return false from |is_valid()|.
- InterfaceRequest<Interface> NewRequest() {
- zx::channel h1, h2;
- if (zx::channel::create(0, &h1, &h2) != ZX_OK)
- return nullptr;
- channel_ = std::move(h1);
- return InterfaceRequest<Interface>(std::move(h2));
- }
-
- // Creates an |InterfacePtr| bound to the channel in this |InterfaceHandle|.
- //
- // This function transfers ownership of the underlying channel to the
- // returned |InterfacePtr|, which means the |is_valid()| method will return
- // false after this method returns.
- //
- // Requires the current thread to have a default async_t (e.g., a message
- // loop) in order to read messages from the channel and to monitor the
- // channel for |ZX_CHANNEL_PEER_CLOSED|.
- //
- // Making this method templated ensures that it is not type-instantiated
- // unless it is used, making the InterfacePtr<->InterfaceHandle codependency
- // less fragile.
- template <typename InterfacePtr = InterfacePtr<Interface>>
- inline InterfacePtr Bind() {
- InterfacePtr ptr;
- ptr.Bind(std::move(channel_));
- return ptr;
- }
-
- template <typename SyncInterfacePtr = SynchronousInterfacePtr<Interface>>
- inline SyncInterfacePtr BindSync() {
- SyncInterfacePtr ptr;
- ptr.Bind(std::move(channel_));
- return ptr;
- }
-
- // Whether the underlying channel is valid.
- bool is_valid() const { return !!channel_; }
- explicit operator bool() const { return is_valid(); }
-
- // Transfers ownership of the underlying channel to the caller.
- zx::channel TakeChannel() { return std::move(channel_); }
-
- // The underlying channel.
- const zx::channel& channel() const { return channel_; }
- void set_channel(zx::channel channel) { channel_ = std::move(channel); }
-
- void Encode(Encoder* encoder, size_t offset) {
- encoder->EncodeHandle(&channel_, offset);
- }
-
- static void Decode(Decoder* decoder, InterfaceHandle<Interface>* value,
- size_t offset) {
- decoder->DecodeHandle(&value->channel_, offset);
- }
-
- private:
- zx::channel channel_;
-};
-
-// Equality.
-template <typename T>
-bool operator==(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return lhs.channel() == rhs.channel();
-}
-template <typename T>
-bool operator!=(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return !(lhs == rhs);
-}
-
-// Comparisons.
-template <typename T>
-bool operator<(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return lhs.channel() < rhs.channel();
-}
-template <typename T>
-bool operator>(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return lhs.channel() > rhs.channel();
-}
-template <typename T>
-bool operator<=(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return !(lhs > rhs);
-}
-template <typename T>
-bool operator>=(const InterfaceHandle<T>& lhs, const InterfaceHandle<T>& rhs) {
- return !(lhs < rhs);
-}
-
-template <typename T>
-struct CodingTraits<InterfaceHandle<T>>
- : public EncodableCodingTraits<InterfaceHandle<T>, sizeof(zx_handle_t)> {};
-
-template <typename T>
-inline zx_status_t Clone(const InterfaceHandle<T>& value,
- InterfaceHandle<T>* result) {
- if (!value) {
- *result = InterfaceHandle<T>();
- return ZX_OK;
- }
- return ZX_ERR_ACCESS_DENIED;
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERFACE_HANDLE_H_
diff --git a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_request.h b/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_request.h
deleted file mode 100644
index 45af19c..0000000
--- a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_request.h
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERFACE_REQUEST_H_
-#define LIB_FIDL_CPP_INTERFACE_REQUEST_H_
-
-#include <lib/fit/function.h>
-#include <lib/zx/channel.h>
-
-#include <cstddef>
-#include <utility>
-
-#include "lib/fidl/cpp/clone.h"
-#include "lib/fidl/cpp/coding_traits.h"
-
-namespace fidl {
-class Builder;
-
-// The server endpoint of a FIDL channel.
-//
-// The remote end of the channel expects this end of the channel to speak the
-// protocol associated with |Interface|. This type is the dual of
-// |InterfaceHandle|.
-//
-// An |InterfaceRequest| does not have thread affinity and can therefore be
-// transferred to another thread or another process. To bind an implementation
-// of |Interface| to this |InterfaceRequest|, use a |Binding| object.
-//
-// Typically, |InterfaceRequest| objects are created by a prospective client of
-// |Interface|, which then sends the |InterfaceRequest| to another process to
-// request that the remote process implement the |Interface|. This pattern
-// enables *pipelined* operation, in which the client can start calling methods
-// on an associated |InterfacePtr| immediately, before the |InterfaceRequest|
-// has reached the remote process and been bound to an implementation. These
-// method calls are buffered by the underlying channel until they are read by
-// the remote process.
-//
-// Example:
-//
-// #include "foo.fidl.h"
-//
-// class FooImpl : public Foo {
-// public:
-// explicit FooImpl(InterfaceRequest<Foo> request)
-// : binding_(this, std::move(request)) {}
-//
-// // Foo implementation here.
-//
-// private:
-// Binding<Foo> binding_;
-// };
-//
-// After the |InterfaceRequest| has been bound to an implementation, the
-// implementation will receive method calls from the remote endpoint of the
-// channel on the thread on which the |InterfaceRequest| was bound.
-//
-// See also:
-//
-// * |InterfaceHandle|, which is the client analog of an |InterfaceRequest|.
-template <typename Interface>
-class InterfaceRequest {
- public:
- // Creates an |InterfaceHandle| whose underlying channel is invalid.
- //
- // Some protocols contain messages that permit such |InterfaceRequest|
- // objects, which indicate that the client is not interested in the server
- // providing an implementation of |Interface|.
- InterfaceRequest() = default;
-
- // Creates an |InterfaceHandle| that wraps the given |channel|.
- explicit InterfaceRequest(zx::channel channel)
- : channel_(std::move(channel)) {}
-
- InterfaceRequest(const InterfaceRequest& other) = delete;
- InterfaceRequest& operator=(const InterfaceRequest& other) = delete;
-
- InterfaceRequest(InterfaceRequest&& other)
- : channel_(std::move(other.channel_)) {}
-
- InterfaceRequest& operator=(InterfaceRequest&& other) {
- channel_ = std::move(other.channel_);
- return *this;
- }
-
- // Implicit conversion from nullptr to an |InterfaceRequest| without an
- // invalid |channel|.
- InterfaceRequest(std::nullptr_t) {}
-
- // Whether the underlying channel is valid.
- bool is_valid() const { return !!channel_; }
- explicit operator bool() const { return is_valid(); }
-
- // Transfers ownership of the underlying channel to the caller.
- zx::channel TakeChannel() { return std::move(channel_); }
-
- // The underlying channel.
- const zx::channel& channel() const { return channel_; }
- void set_channel(zx::channel channel) { channel_ = std::move(channel); }
-
- void Encode(Encoder* encoder, size_t offset) {
- encoder->EncodeHandle(&channel_, offset);
- }
-
- static void Decode(Decoder* decoder, InterfaceRequest<Interface>* value,
- size_t offset) {
- decoder->DecodeHandle(&value->channel_, offset);
- }
-
- private:
- zx::channel channel_;
-};
-
-// A |InterfaceRequestHandler<Interface>| is simply a function that
-// handles an interface request for |Interface|. If it determines that the
-// request should be "accepted", then it should "connect" ("take ownership
-// of") request. Otherwise, it can simply drop |request| (as implied by the
-// interface).
-template <typename Interface>
-using InterfaceRequestHandler =
- fit::function<void(fidl::InterfaceRequest<Interface> request)>;
-
-// Equality.
-template <typename T>
-bool operator==(const InterfaceRequest<T>& lhs,
- const InterfaceRequest<T>& rhs) {
- return lhs.channel() == rhs.channel();
-}
-template <typename T>
-bool operator!=(const InterfaceRequest<T>& lhs,
- const InterfaceRequest<T>& rhs) {
- return !(lhs == rhs);
-}
-
-// Comparaisons.
-template <typename T>
-bool operator<(const InterfaceRequest<T>& lhs, const InterfaceRequest<T>& rhs) {
- return lhs.channel() < rhs.channel();
-}
-template <typename T>
-bool operator>(const InterfaceRequest<T>& lhs, const InterfaceRequest<T>& rhs) {
- return lhs.channel() > rhs.channel();
-}
-template <typename T>
-bool operator<=(const InterfaceRequest<T>& lhs,
- const InterfaceRequest<T>& rhs) {
- return !(lhs > rhs);
-}
-template <typename T>
-bool operator>=(const InterfaceRequest<T>& lhs,
- const InterfaceRequest<T>& rhs) {
- return !(lhs < rhs);
-}
-
-template <typename T>
-struct CodingTraits<InterfaceRequest<T>>
- : public EncodableCodingTraits<InterfaceRequest<T>, sizeof(zx_handle_t)> {};
-
-template <typename T>
-inline zx_status_t Clone(const InterfaceRequest<T>& value,
- InterfaceRequest<T>* result) {
- if (!value) {
- *result = InterfaceRequest<T>();
- return ZX_OK;
- }
- return ZX_ERR_ACCESS_DENIED;
-}
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERFACE_REQUEST_H_
diff --git a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/internal/synchronous_proxy.h b/pkg/fidl_cpp_sync/include/lib/fidl/cpp/internal/synchronous_proxy.h
deleted file mode 100644
index ee77c99..0000000
--- a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/internal/synchronous_proxy.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_INTERNAL_SYNCHRONOUS_PROXY_H_
-#define LIB_FIDL_CPP_INTERNAL_SYNCHRONOUS_PROXY_H_
-
-#include <lib/fidl/cpp/message.h>
-#include <lib/zx/channel.h>
-#include <zircon/fidl.h>
-
-namespace fidl {
-namespace internal {
-
-// Manages the client state for a synchronous interface.
-//
-// A |SynchronousProxy| manages the client state for a sychronous interface.
-// This object validates messages before sending them to the remote endpoint,
-// and (optionally) blocks until it receives a reply.
-//
-// This object is thread-safe.
-class SynchronousProxy {
- public:
- // Creates a |SynchronousProxy| that wraps the given channel.
- explicit SynchronousProxy(zx::channel channel);
- ~SynchronousProxy();
-
- // Returns the underlying channel from this object.
- //
- // The |SynchronousProxy| does not attempt to synchronize this operation with
- // |Send| or |Call|.
- zx::channel TakeChannel();
-
- // Validates that |message| matches the given |type| and sends the message
- // through the underlying channel.
- //
- // Does not block.
- //
- // Returns an error if validation or writing fails.
- zx_status_t Send(const fidl_type_t* type, Message message);
-
- // Validate that |request| matches the given |request_type| and sends
- // |request| through the underlying channel. Blocks until it receives a
- // response, which is then decoded according to |response_type| and returned
- // in |response_type|.
- //
- // Blocks until the remote endpoint replied.
- //
- // Returns an error if validation, writing, reading, or decoding fails.
- zx_status_t Call(const fidl_type_t* request_type,
- const fidl_type_t* response_type, Message request,
- Message* response);
-
- private:
- zx::channel channel_;
-};
-
-} // namespace internal
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_INTERNAL_SYNCHRONOUS_PROXY_H_
diff --git a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/synchronous_interface_ptr.h b/pkg/fidl_cpp_sync/include/lib/fidl/cpp/synchronous_interface_ptr.h
deleted file mode 100644
index 7f9ff6c..0000000
--- a/pkg/fidl_cpp_sync/include/lib/fidl/cpp/synchronous_interface_ptr.h
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_FIDL_CPP_SYNCHRONOUS_INTERFACE_PTR_H_
-#define LIB_FIDL_CPP_SYNCHRONOUS_INTERFACE_PTR_H_
-
-#include <stddef.h>
-
-#include <memory>
-#include <utility>
-
-#include "lib/fidl/cpp/interface_handle.h"
-
-namespace fidl {
-
-// A synchronous client interface to a remote implementation of |Interface|.
-//
-// An |SynchronousInterfacePtr| implements |Interface| by proxying calls through
-// a |channel| to a remote implementation of |Interface|. Method calls on the
-// |Interface| proxy are encoded and sent through the bound channel to the
-// remote endpoint, which processes them. If the method has a reply (including
-// any empty reply), the client blocks and waits for the remote endpoint to
-// reply.
-//
-// You need to bind the |SynchronousInterfacePtr| before calling any |Interface|
-// methods. There are a number of ways to bind the |SynchronousInterfacePtr|.
-// See |NewRequest|, |Bind|, and the |BindSync| method on |InterfaceHandle|.
-//
-// This class is thread-compatible. Once bound, the |SynchronousInterfacePtr|
-// can be used from multiple threads simultaneously. However, the
-// |SynchronousInterfacePtr| does not attempt to synchronize mutating operatios,
-// such as |Bind| or |Unbind|.
-//
-// |SynchronousInterfacePtr| does not require a |async_t| implementation and
-// does not bind to the default |async_dispatcher_t*| for the current thread,
-// unlike |InterfacePtr|.
-//
-// See also:
-//
-// * |Binding|, which is the server analog of an |SynchronousInterfacePtr|.
-// * |InterfacePtr|, which is an asynchronous interface to a remote
-// implementation.
-template <typename Interface>
-class SynchronousInterfacePtr {
- public:
- using InterfaceSync = typename Interface::Sync_;
-
- // Creates an unbound |SynchronousInterfacePtr|.
- SynchronousInterfacePtr() {}
- SynchronousInterfacePtr(std::nullptr_t) {}
-
- SynchronousInterfacePtr(const SynchronousInterfacePtr& other) = delete;
- SynchronousInterfacePtr& operator=(const SynchronousInterfacePtr& other) =
- delete;
-
- SynchronousInterfacePtr(SynchronousInterfacePtr&& other) = default;
- SynchronousInterfacePtr& operator=(SynchronousInterfacePtr&& other) = default;
-
- // Bind the |SynchronousInterfacePtr| to one endpoint of a newly created
- // channel and return the other endpoint as an |InterfaceRequest|.
- //
- // Typically, the returned |InterfaceRequest| will be sent to a remote process
- // to be bound to an implementation of |Interface| using a |Binding| object.
- //
- // After calling this method, clients can start calling methods on this
- // |SynchronousInterfacePtr|. However, methods that have replies will block
- // until the remote implementation binds the |InterfaceRequest| and replies.
- //
- // # Example
- //
- // Given the following interface:
- //
- // interface Database {
- // OpenTable(request<Table> table);
- // };
- //
- // The client can use the |NewRequest| method to create the |InterfaceRequest|
- // object needed by the |OpenTable| method:
- //
- // DatabasePtr database = ...; // Connect to database.
- // TableSyncPtr table;
- // database->OpenTable(table.NewRequest());
- //
- // The client can call methods on |table| immediately. Messages that have
- // replies will block until the Database implementation binds a Table
- // implementation and replies.
- InterfaceRequest<Interface> NewRequest() {
- zx::channel h1;
- zx::channel h2;
- if (zx::channel::create(0, &h1, &h2) != ZX_OK)
- return nullptr;
- Bind(std::move(h1));
- return InterfaceRequest<Interface>(std::move(h2));
- }
-
- // Binds the |SynchronousInterfacePtr| to the given |channel|.
- //
- // The |SynchronousInterfacePtr| expects the remote end of the |channel| to
- // speak the protocol defined by |Interface|. Unlike the |Bind| overload that
- // takes a |InterfaceHandle| parameter, this |Bind| overload lacks type
- // safety.
- //
- // If the |SynchronousInterfacePtr| was prevously bound to another channel,
- // that channel is closed. If the |channel| is invalid, then this method will
- // effectively unbind the |SynchronousInterfacePtr|. A more direct way to have
- // that effect is to call |Unbind|.
- //
- // Does not require the current thread to have a default async_t.
- void Bind(zx::channel channel) {
- if (!channel) {
- proxy_.reset();
- return;
- }
- proxy_.reset(new typename InterfaceSync::Proxy_(std::move(channel)));
- }
-
- // Binds the |SynchronousInterfacePtr| to the given |InterfaceHandle|.
- //
- // The |SynchronousInterfacePtr| expects the remote end of the |channel| to
- // speak the protocol defined by |Interface|. Unlike the |Bind| overload that
- // takes a |channel| parameter, this |Bind| overload provides type safety.
- //
- // If the |SynchronousInterfacePtr| was prevously bound to another channel,
- // that channel is closed. If the |InterfaceHandle| is invalid, then this
- // method will effectively unbind the |SynchronousInterfacePtr|. A more direct
- // way to have that effect is to call |Unbind|.
- //
- // Does not require the current thread to have a default async_t.
- void Bind(InterfaceHandle<Interface> handle) {
- return Bind(handle.TakeChannel());
- }
-
- // Unbinds the underlying channel from the |SynchronousInterfacePtr|.
- //
- // The underlying channel is returned as an |InterfaceHandle|, which is safe
- // to transport to another thread or process.
- //
- // After this method returns, a subsequent call to |Bind| is required before
- // calling any additional |Interface| methods.
- InterfaceHandle<Interface> Unbind() {
- InterfaceHandle<Interface> handle(proxy_->proxy().TakeChannel());
- proxy_.reset();
- return handle;
- }
-
- // Whether this |SynchronousInterfacePtr| is currently bound to a channel.
- //
- // If the |SynchronousInterfacePtr| is bound to a channel, calls to
- // |Interface| methods are proxied to the remote endpoint of the channel.
- //
- // See also:
- //
- // * |Bind|, which binds a channel to this |SynchronousInterfacePtr|.
- // * |Unbind|, which unbinds a channel from this |SynchronousInterfacePtr|.
- bool is_bound() const { return static_cast<bool>(proxy_); }
-
- // Whether this |SynchronousInterfacePtr| is currently bound to a channel.
- //
- // See |is_bound| for details.
- explicit operator bool() const { return is_bound(); }
-
- // The |Interface| proxy associated with this |SynchronousInterfacePtr|.
- //
- // When this |SynchronousInterfacePtr| is bound, method calls on this
- // |Interface| will be proxied to the remote endpoint of the connection.
- // Methods that expect replies will block until the
- // |SynchronousInterfacePtr| either receives a reply to that transaction.
- //
- // When this |SynchronousInterfacePtr| is not bound, this method returns
- // nullptr.
- //
- // The returned |Interface| is thread-compatible and can be used from any
- // thread.
- InterfaceSync* get() const { return proxy_.get(); }
- InterfaceSync* operator->() const { return get(); }
- InterfaceSync& operator*() const { return *get(); }
-
- private:
- std::unique_ptr<typename InterfaceSync::Proxy_> proxy_;
-};
-
-} // namespace fidl
-
-#endif // LIB_FIDL_CPP_SYNCHRONOUS_INTERFACE_PTR_H_
diff --git a/pkg/fidl_cpp_sync/internal/synchronous_proxy.cc b/pkg/fidl_cpp_sync/internal/synchronous_proxy.cc
deleted file mode 100644
index 0e42e56..0000000
--- a/pkg/fidl_cpp_sync/internal/synchronous_proxy.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/fidl/cpp/internal/synchronous_proxy.h"
-
-#include <memory>
-#include <utility>
-
-#include "lib/fidl/cpp/internal/logging.h"
-
-namespace fidl {
-namespace internal {
-
-SynchronousProxy::SynchronousProxy(zx::channel channel)
- : channel_(std::move(channel)) {}
-
-SynchronousProxy::~SynchronousProxy() = default;
-
-zx::channel SynchronousProxy::TakeChannel() { return std::move(channel_); }
-
-zx_status_t SynchronousProxy::Send(const fidl_type_t* type, Message message) {
- const char* error_msg = nullptr;
- zx_status_t status = message.Validate(type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_ENCODING_ERROR(message, type, error_msg);
- return status;
- }
- return message.Write(channel_.get(), 0);
-}
-
-zx_status_t SynchronousProxy::Call(const fidl_type_t* request_type,
- const fidl_type_t* response_type,
- Message request, Message* response) {
- const char* error_msg = nullptr;
- zx_status_t status = request.Validate(request_type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_ENCODING_ERROR(request, request_type, error_msg);
- return status;
- }
- status = request.Call(channel_.get(), 0, ZX_TIME_INFINITE, response);
- if (status != ZX_OK)
- return status;
- status = response->Decode(response_type, &error_msg);
- if (status != ZX_OK) {
- FIDL_REPORT_DECODING_ERROR(*response, response_type, error_msg);
- return status;
- }
- return ZX_OK;
-}
-
-} // namespace internal
-} // namespace fidl
diff --git a/pkg/fidl_cpp_sync/meta.json b/pkg/fidl_cpp_sync/meta.json
deleted file mode 100644
index c74ae9d..0000000
--- a/pkg/fidl_cpp_sync/meta.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "deps": [
- "fidl_cpp_base",
- "fidl",
- "fidl-async",
- "fit",
- "zx"
- ],
- "fidl_deps": [],
- "headers": [
- "pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_handle.h",
- "pkg/fidl_cpp_sync/include/lib/fidl/cpp/interface_request.h",
- "pkg/fidl_cpp_sync/include/lib/fidl/cpp/internal/synchronous_proxy.h",
- "pkg/fidl_cpp_sync/include/lib/fidl/cpp/synchronous_interface_ptr.h"
- ],
- "include_dir": "pkg/fidl_cpp_sync/include",
- "name": "fidl_cpp_sync",
- "root": "pkg/fidl_cpp_sync",
- "sources": [
- "pkg/fidl_cpp_sync/internal/synchronous_proxy.cc"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/fit/barrier.cc b/pkg/fit/barrier.cc
new file mode 100644
index 0000000..76a8a71
--- /dev/null
+++ b/pkg/fit/barrier.cc
@@ -0,0 +1,26 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/fit/barrier.h>
+
+namespace fit {
+
+barrier::barrier() {
+ // Capture a new consumer and intentionally abandon its associated
+ // completer so that a promise chained onto the consumer using
+ // |promise_or()| will become immediately runnable.
+ fit::bridge<> bridge;
+ prior_ = std::move(bridge.consumer);
+}
+
+barrier::~barrier() = default;
+
+fit::consumer<> barrier::swap_prior(fit::consumer<> new_prior) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ fit::consumer<> old_prior = std::move(prior_);
+ prior_ = std::move(new_prior);
+ return old_prior;
+}
+
+} // namespace fit
diff --git a/pkg/fit/include/lib/fit/barrier.h b/pkg/fit/include/lib/fit/barrier.h
new file mode 100644
index 0000000..59c3459
--- /dev/null
+++ b/pkg/fit/include/lib/fit/barrier.h
@@ -0,0 +1,106 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_BARRIER_H_
+#define LIB_FIT_BARRIER_H_
+
+#include <assert.h>
+
+#include <atomic>
+#include <mutex>
+
+#include "bridge.h"
+#include "promise.h"
+#include "thread_safety.h"
+
+namespace fit {
+
+// A barrier is utility class for monitoring pending promises and ensuring they have completed when
+// |barrier.sync| completes. This class is used to mark promises with |barrier.wrap|, without
+// changing their order, but allowing a caller to later invoke |sync| and ensure they have
+// completed.
+//
+// EXAMPLE
+//
+// // Issue tracked work, wrapped by the barrier.
+// fit::barrier barrier;
+// auto work = fit::make_promise([] { do_work(); });
+// executor.schedule_task(work.wrap_with(barrier));
+//
+// auto more_work = fit::make_promise([] { do_work_but_more(); });
+// executor.schedule_task(more_work.wrap_with(barrier));
+//
+// // Ensure that all prior work completes, using the same barrier.
+// barrier.sync().and_then([] {
+// // |work| and |more_work| have been completed.
+// });
+//
+// See documentation of |fit::promise| for more information.
+class barrier final {
+ public:
+ barrier();
+ ~barrier();
+
+ barrier(const barrier&) = delete;
+ barrier(barrier&&) = delete;
+ barrier& operator=(const barrier&) = delete;
+ barrier& operator=(barrier&&) = delete;
+
+ // Returns a new promise which, after invoking the original |promise|, may update sync() callers
+ // if they are waiting for all prior work to complete.
+ //
+ // This method is thread-safe.
+ template <typename Promise>
+ decltype(auto) wrap(Promise promise) {
+ assert(promise);
+
+ fit::bridge<> bridge;
+ auto prior = swap_prior(std::move(bridge.consumer));
+
+ // First, execute the originally provided promise.
+ //
+ // Note that execution of this original promise is not gated behind any interactions
+ // between other calls to |sync()| or |wrap()|.
+ return promise.then([prior = std::move(prior), completer = std::move(bridge.completer)](
+ fit::context& context, typename Promise::result_type& result) mutable {
+ // Wait for all prior work to either terminate or be abandoned before terminating the
+ // completer.
+ //
+ // This means that when |sync()| invokes |swap_prior()|, that caller receives a chain
+ // of these promise-bound completer objects from all prior invocations of |wrap()|.
+ // When this chain completes, the sync promise can complete too, since it implies
+ // that all prior access to the barrier has completed.
+ context.executor()->schedule_task(prior.promise_or(fit::ok()).then(
+ [completer = std::move(completer)](const fit::result<>&) mutable { return; }));
+
+ return result;
+ });
+ }
+
+ // Returns a promise which completes after all previously wrapped work has completed.
+ //
+ // This method is thread-safe.
+ fit::promise<void, void> sync() {
+ // Swap the latest pending work with our own consumer; a subsequent request
+ // to sync should wait on this one.
+ fit::bridge<> bridge;
+ fit::consumer<> prior = swap_prior(std::move(bridge.consumer));
+ return prior.promise_or(fit::ok()).then(
+ [completer = std::move(bridge.completer)](const fit::result<>&) mutable {
+ return fit::make_ok_promise();
+ });
+ }
+
+ private:
+ fit::consumer<> swap_prior(fit::consumer<> new_prior);
+
+ std::mutex mutex_;
+
+ // Holds the consumption capability of the most recently wrapped promise.
+ fit::consumer<> prior_ FIT_GUARDED(mutex_);
+};
+
+} // namespace fit
+
+#endif // LIB_FIT_BARRIER_H_
diff --git a/pkg/fit/include/lib/fit/bridge.h b/pkg/fit/include/lib/fit/bridge.h
index 3fed908..08e0ddc 100644
--- a/pkg/fit/include/lib/fit/bridge.h
+++ b/pkg/fit/include/lib/fit/bridge.h
@@ -13,9 +13,9 @@
// by the association of two distinct participants: a completer and a consumer.
//
// - The completer is responsible for reporting completion of an asynchronous
-// task and providing its result. See |completer()| and |fit::completer|.
+// task and providing its result. See |completer| and |fit::completer|.
// - The consumer is responsible for consuming the result of the asynchronous
-// task. See |consumer()| and |fit::consumer|.
+// task. See |consumer| and |fit::consumer|.
//
// This class is often used for binding a |fit::promise| to a callback,
// facilitating interoperation of promises with functions that asynchronously
@@ -41,7 +41,7 @@
//
// The consumption capability has a single owner represented by |fit::consumer|.
// Its owner may exercise the capability to consume the task's result (as a
-/// promise), it may transfer the capability by moving it to another consumer
+// promise), it may transfer the capability by moving it to another consumer
// instance, or it may cause the asynchronous task to be "canceled" by
// discarding the capability, implying that the task's result can never be
// consumed. When this occurs, the associated completer's
@@ -50,7 +50,7 @@
//
// DECOUPLING
//
-// See |fit::schedule_for_consumer()| for a helper which uses a bridge to
+// See |fit::schedule_for_consumer| for a helper which uses a bridge to
// decouple completion and consumption of a task's result so they can be
// performed on different executors.
//
@@ -79,8 +79,8 @@
//
// fit::promise<size_t> promise_read(uint8_t* buffer, size_t num_bytes) {
// fit::bridge<size_t> bridge;
-// read_async(num_bytes, buffer, bridge.completer().bind());
-// return bridge.consumer().promise_or(::fit::error());
+// read_async(num_bytes, buffer, bridge.completer.bind());
+// return bridge.consumer.promise_or(::fit::error());
// }
//
// Finally we can chain additional asynchronous tasks to be performed upon
@@ -89,7 +89,7 @@
// uint8_t buffer[4096];
// void my_program(fit::executor* executor) {
// auto promise = promise_read(buffer, sizeof(buffer))
-// .and_then([] (size_t bytes_read) {
+// .and_then([] (const size_t& bytes_read) {
// // consume contents of buffer
// })
// .or_else() {
@@ -109,23 +109,23 @@
// fit::promise<size_t, int> promise_write(uint8_t* buffer, size_t num_bytes) {
// fit::bridge<size_t, int> bridge;
// write_async(num_bytes, buffer,
-// [completer = std::move(bridge.completer())](size_t bytes_written, int error) {
+// [completer = std::move(bridge.completer)](size_t bytes_written, int error) {
// if (bytes_written == 0) {
// completer.complete_error(error);
// return;
// }
// completer.complete_ok(bytes_written);
// });
-// return bridge.consumer().promise_or(::fit::error(ERR_ABANDONED));
+// return bridge.consumer.promise_or(::fit::error(ERR_ABANDONED));
// }
//
// uint8_t buffer[4096];
// void my_program(fit::executor* executor) {
// auto promise = promise_write(buffer, sizeof(buffer))
-// .and_then([] (size_t bytes_written) {
+// .and_then([] (const size_t& bytes_written) {
// // consume contents of buffer
// })
-// .or_else(int error) {
+// .or_else(const int& error) {
// // handle error case
// });
// executor->schedule_task(std::move(promise));
@@ -134,42 +134,31 @@
// See documentation of |fit::promise| for more information.
template <typename V, typename E>
class bridge final {
- using bridge_state = ::fit::internal::bridge_state<V, E>;
+ public:
+ using value_type = V;
+ using error_type = E;
+ using result_type = result<value_type, error_type>;
+ using completer_type = ::fit::completer<V, E>;
+ using consumer_type = ::fit::consumer<V, E>;
-public:
- using value_type = V;
- using error_type = E;
- using result_type = result<value_type, error_type>;
- using completer_type = ::fit::completer<V, E>;
- using consumer_type = ::fit::consumer<V, E>;
+ // Creates a bridge representing a new asynchronous task formed by the
+ // association of a completer and consumer.
+ bridge() {
+ ::fit::internal::bridge_state<V, E>::create(&completer.completion_ref_,
+ &consumer.consumption_ref_);
+ }
+ bridge(bridge&& other) = default;
+ bridge(const bridge& other) = delete;
+ ~bridge() = default;
- // Creates a bridge representing a new asynchronous task formed by the
- // association of a completer and consumer.
- bridge() {
- bridge_state::create(&completer_.completion_ref_,
- &consumer_.consumption_ref_);
- }
- bridge(bridge&& other) = default;
- ~bridge() = default;
+ bridge& operator=(bridge&& other) = default;
+ bridge& operator=(const bridge& other) = delete;
- bridge& operator=(bridge&& other) = default;
+ // The bridge's completer capability.
+ completer_type completer;
- // Gets a reference to the bridge's completer capability.
- // The completer can be moved out of the bridge, if desired.
- completer_type& completer() { return completer_; }
- const completer_type& completer() const { return completer_; }
-
- // Gets a reference to the bridge's consumer capability.
- // The consumer can be moved out of the bridge, if desired.
- consumer_type& consumer() { return consumer_; }
- const consumer_type& consumer() const { return consumer_; }
-
- bridge(const bridge& other) = delete;
- bridge& operator=(const bridge& other) = delete;
-
-private:
- completer_type completer_;
- consumer_type consumer_;
+ // The bridge's consumer capability.
+ consumer_type consumer;
};
// Provides a result upon completion of an asynchronous task.
@@ -194,130 +183,121 @@
// Defaults to |void|.
template <typename V, typename E>
class completer final {
- using bridge_state = ::fit::internal::bridge_state<V, E>;
- using completion_ref = typename bridge_state::completion_ref;
+ using bridge_state = ::fit::internal::bridge_state<V, E>;
+ using completion_ref = typename bridge_state::completion_ref;
-public:
- using value_type = V;
- using error_type = E;
- using result_type = ::fit::result<V, E>;
+ public:
+ using value_type = V;
+ using error_type = E;
+ using result_type = ::fit::result<V, E>;
- completer() = default;
- completer(completer&& other) = default;
- ~completer() = default;
+ completer() = default;
+ completer(completer&& other) = default;
+ ~completer() = default;
- completer& operator=(completer&& other) = default;
+ completer& operator=(completer&& other) = default;
- // Returns true if this instance currently owns the unique capability for
- // reporting completion of the task.
- explicit operator bool() const { return !!completion_ref_; }
+ // Returns true if this instance currently owns the unique capability for
+ // reporting completion of the task.
+ explicit operator bool() const { return !!completion_ref_; }
- // Returns true if the associated |consumer| has canceled the task.
- // This method returns a snapshot of the current cancelation state.
- // Note that the task may be canceled concurrently at any time.
- bool was_canceled() const {
- assert(completion_ref_);
- return completion_ref_.get()->was_canceled();
- }
+ // Returns true if the associated |consumer| has canceled the task.
+ // This method returns a snapshot of the current cancellation state.
+ // Note that the task may be canceled concurrently at any time.
+ bool was_canceled() const {
+ assert(completion_ref_);
+ return completion_ref_.get()->was_canceled();
+ }
- // Explicitly abandons the task, meaning that it will never be completed.
- // See |fit::bridge| for details about abandonment.
- void abandon() {
- assert(completion_ref_);
- completion_ref_ = completion_ref();
- }
+ // Explicitly abandons the task, meaning that it will never be completed.
+ // See |fit::bridge| for details about abandonment.
+ void abandon() {
+ assert(completion_ref_);
+ completion_ref_ = completion_ref();
+ }
- // Reports that the task has completed successfully.
- // This method takes no arguments if |value_type| is void, otherwise it
- // takes one argument which must be assignable to |value_type|.
- template <typename VV = value_type,
- typename = std::enable_if_t<std::is_void<VV>::value>>
- void complete_ok() {
- assert(completion_ref_);
- bridge_state* state = completion_ref_.get();
- state->complete_or_abandon(std::move(completion_ref_),
- ::fit::ok());
- }
- template <typename VV = value_type,
- typename = std::enable_if_t<!std::is_void<VV>::value>>
- void complete_ok(VV value) {
- assert(completion_ref_);
- bridge_state* state = completion_ref_.get();
- state->complete_or_abandon(std::move(completion_ref_),
- ::fit::ok<value_type>(std::forward<VV>(value)));
- }
+ // Reports that the task has completed successfully.
+ // This method takes no arguments if |value_type| is void, otherwise it
+ // takes one argument which must be assignable to |value_type|.
+ template <typename VV = value_type, typename = std::enable_if_t<std::is_void<VV>::value>>
+ void complete_ok() {
+ assert(completion_ref_);
+ bridge_state* state = completion_ref_.get();
+ state->complete_or_abandon(std::move(completion_ref_), ::fit::ok());
+ }
+ template <typename VV = value_type, typename = std::enable_if_t<!std::is_void<VV>::value>>
+ void complete_ok(VV value) {
+ assert(completion_ref_);
+ bridge_state* state = completion_ref_.get();
+ state->complete_or_abandon(std::move(completion_ref_),
+ ::fit::ok<value_type>(std::forward<VV>(value)));
+ }
- // Reports that the task has completed with an error.
- // This method takes no arguments if |error_type| is void, otherwise it
- // takes one argument which must be assignable to |error_type|.
- template <typename EE = error_type,
- typename = std::enable_if_t<std::is_void<EE>::value>>
- void complete_error() {
- assert(completion_ref_);
- bridge_state* state = completion_ref_.get();
- state->complete_or_abandon(std::move(completion_ref_),
- ::fit::error());
- }
- template <typename EE = error_type,
- typename = std::enable_if_t<!std::is_void<EE>::value>>
- void complete_error(EE error) {
- assert(completion_ref_);
- bridge_state* state = completion_ref_.get();
- state->complete_or_abandon(std::move(completion_ref_),
- ::fit::error<error_type>(std::forward<EE>(error)));
- }
+ // Reports that the task has completed with an error.
+ // This method takes no arguments if |error_type| is void, otherwise it
+ // takes one argument which must be assignable to |error_type|.
+ template <typename EE = error_type, typename = std::enable_if_t<std::is_void<EE>::value>>
+ void complete_error() {
+ assert(completion_ref_);
+ bridge_state* state = completion_ref_.get();
+ state->complete_or_abandon(std::move(completion_ref_), ::fit::error());
+ }
+ template <typename EE = error_type, typename = std::enable_if_t<!std::is_void<EE>::value>>
+ void complete_error(EE error) {
+ assert(completion_ref_);
+ bridge_state* state = completion_ref_.get();
+ state->complete_or_abandon(std::move(completion_ref_),
+ ::fit::error<error_type>(std::forward<EE>(error)));
+ }
- // Reports that the task has completed or been abandoned.
- // See |fit::bridge| for details about abandonment.
- //
- // The result state determines the task's final disposition.
- // - |fit::result_state::ok|: The task completed successfully.
- // - |fit::result_state::error|: The task completed with an error.
- // - |fit::result_state::pending|: The task was abandoned.
- void complete_or_abandon(result_type result) {
- assert(completion_ref_);
- bridge_state* state = completion_ref_.get();
- state->complete_or_abandon(std::move(completion_ref_),
- std::move(result));
- }
+ // Reports that the task has completed or been abandoned.
+ // See |fit::bridge| for details about abandonment.
+ //
+ // The result state determines the task's final disposition.
+ // - |fit::result_state::ok|: The task completed successfully.
+ // - |fit::result_state::error|: The task completed with an error.
+ // - |fit::result_state::pending|: The task was abandoned.
+ void complete_or_abandon(result_type result) {
+ assert(completion_ref_);
+ bridge_state* state = completion_ref_.get();
+ state->complete_or_abandon(std::move(completion_ref_), std::move(result));
+ }
- // Returns a callback that reports completion of the asynchronous task along
- // with its result when invoked. This method is typically used to bind
- // completion of a task to a callback that has zero or one argument.
- //
- // If |value_type| is void, the returned callback's signature is: void(void)
- // Otherwise, the returned callback's signature is: void(value_type).
- //
- // The returned callback is thread-safe and move-only.
- ::fit::internal::bridge_bind_callback<V, E> bind() {
- assert(completion_ref_);
- return ::fit::internal::bridge_bind_callback<V, E>(
- std::move(completion_ref_));
- }
+ // Returns a callback that reports completion of the asynchronous task along
+ // with its result when invoked. This method is typically used to bind
+ // completion of a task to a callback that has zero or one argument.
+ //
+ // If |value_type| is void, the returned callback's signature is: void(void)
+ // Otherwise, the returned callback's signature is: void(value_type).
+ //
+ // The returned callback is thread-safe and move-only.
+ ::fit::internal::bridge_bind_callback<V, E> bind() {
+ assert(completion_ref_);
+ return ::fit::internal::bridge_bind_callback<V, E>(std::move(completion_ref_));
+ }
- // A variant of |bind()| that can be used to bind a completion of a task
- // to a callback that has zero or more arguments by wrapping the callback's
- // arguments into a tuple when producing the task's result.
- //
- // The |value_type| must be a tuple type.
- // Given a |value_type| of std::tuple<Args...>, the returned callback's
- // signature is: void(Args...). Note that the tuple's fields are
- // unpacked as individual arguments of the callback.
- //
- // The returned callback is thread-safe and move-only.
- ::fit::internal::bridge_bind_tuple_callback<V, E> bind_tuple() {
- assert(completion_ref_);
- return ::fit::internal::bridge_bind_tuple_callback<V, E>(
- std::move(completion_ref_));
- }
+ // A variant of |bind()| that can be used to bind a completion of a task
+ // to a callback that has zero or more arguments by wrapping the callback's
+ // arguments into a tuple when producing the task's result.
+ //
+ // The |value_type| must be a tuple type.
+ // Given a |value_type| of std::tuple<Args...>, the returned callback's
+ // signature is: void(Args...). Note that the tuple's fields are
+ // unpacked as individual arguments of the callback.
+ //
+ // The returned callback is thread-safe and move-only.
+ ::fit::internal::bridge_bind_tuple_callback<V, E> bind_tuple() {
+ assert(completion_ref_);
+ return ::fit::internal::bridge_bind_tuple_callback<V, E>(std::move(completion_ref_));
+ }
- completer(const completer& other) = delete;
- completer& operator=(const completer& other) = delete;
+ completer(const completer& other) = delete;
+ completer& operator=(const completer& other) = delete;
-private:
- friend class bridge<V, E>;
+ private:
+ friend class bridge<V, E>;
- completion_ref completion_ref_;
+ completion_ref completion_ref_;
};
// Consumes the result of an asynchronous task.
@@ -342,81 +322,78 @@
// Defaults to |void|.
template <typename V, typename E>
class consumer final {
- using bridge_state = ::fit::internal::bridge_state<V, E>;
- using consumption_ref = typename bridge_state::consumption_ref;
+ using bridge_state = ::fit::internal::bridge_state<V, E>;
+ using consumption_ref = typename bridge_state::consumption_ref;
-public:
- using value_type = V;
- using error_type = E;
- using result_type = ::fit::result<V, E>;
+ public:
+ using value_type = V;
+ using error_type = E;
+ using result_type = ::fit::result<V, E>;
- consumer() = default;
- consumer(consumer&& other) = default;
- ~consumer() = default;
+ consumer() = default;
+ consumer(consumer&& other) = default;
+ ~consumer() = default;
- consumer& operator=(consumer&& other) = default;
+ consumer& operator=(consumer&& other) = default;
- // Returns true if this instance currently owns the unique capability for
- // consuming the result of the task upon its completion.
- explicit operator bool() const { return !!consumption_ref_; }
+ // Returns true if this instance currently owns the unique capability for
+ // consuming the result of the task upon its completion.
+ explicit operator bool() const { return !!consumption_ref_; }
- // Explicitly cancels the task, meaning that its result will never be consumed.
- // See |fit::bridge| for details about cancelation.
- void cancel() {
- assert(consumption_ref_);
- consumption_ref_ = consumption_ref();
- }
+ // Explicitly cancels the task, meaning that its result will never be consumed.
+ // See |fit::bridge| for details about cancellation.
+ void cancel() {
+ assert(consumption_ref_);
+ consumption_ref_ = consumption_ref();
+ }
- // Returns true if the associated |completer| has abandoned the task.
- // This method returns a snapshot of the current abandonment state.
- // Note that the task may be abandoned concurrently at any time.
- bool was_abandoned() const {
- assert(consumption_ref_);
- return consumption_ref_.get()->was_abandoned();
- }
+ // Returns true if the associated |completer| has abandoned the task.
+ // This method returns a snapshot of the current abandonment state.
+ // Note that the task may be abandoned concurrently at any time.
+ bool was_abandoned() const {
+ assert(consumption_ref_);
+ return consumption_ref_.get()->was_abandoned();
+ }
- // Returns an unboxed promise which resumes execution once this task has
- // completed. If the task is abandoned by its completer, the promise
- // will not produce a result, thereby causing subsequent tasks associated
- // with the promise to also be abandoned and eventually destroyed if
- // they cannot make progress without the promised result.
- promise_impl<typename bridge_state::promise_continuation>
- promise() {
- assert(consumption_ref_);
- return make_promise_with_continuation(
- typename bridge_state::promise_continuation(
- std::move(consumption_ref_)));
- }
+ // Returns an unboxed promise which resumes execution once this task has
+ // completed. If the task is abandoned by its completer, the promise
+ // will not produce a result, thereby causing subsequent tasks associated
+ // with the promise to also be abandoned and eventually destroyed if
+ // they cannot make progress without the promised result.
+ promise_impl<typename bridge_state::promise_continuation> promise() {
+ assert(consumption_ref_);
+ return make_promise_with_continuation(
+ typename bridge_state::promise_continuation(std::move(consumption_ref_)));
+ }
- // A variant of |promise()| that allows a default result to be provided when
- // the task is abandoned by its completer. Typically this is used to cause
- // the promise to return an error when the task is abandoned instead of
- // causing subsequent tasks associated with the promise to also be abandoned.
- //
- // The state of |result_if_abandoned| determines the promise's behavior
- // in case of abandonment.
- //
- // - |fit::result_state::ok|: Reports a successful result.
- // - |fit::result_state::error|: Reports a failure result.
- // - |fit::result_state::pending|: Does not report a result, thereby
- // causing subsequent tasks associated with the promise to also be
- // abandoned and eventually destroyed if they cannot make progress
- // without the promised result.
- promise_impl<typename bridge_state::promise_continuation>
- promise_or(result_type result_if_abandoned) {
- assert(consumption_ref_);
- return make_promise_with_continuation(
- typename bridge_state::promise_continuation(
- std::move(consumption_ref_), std::move(result_if_abandoned)));
- }
+ // A variant of |promise()| that allows a default result to be provided when
+ // the task is abandoned by its completer. Typically this is used to cause
+ // the promise to return an error when the task is abandoned instead of
+ // causing subsequent tasks associated with the promise to also be abandoned.
+ //
+ // The state of |result_if_abandoned| determines the promise's behavior
+ // in case of abandonment.
+ //
+ // - |fit::result_state::ok|: Reports a successful result.
+ // - |fit::result_state::error|: Reports a failure result.
+ // - |fit::result_state::pending|: Does not report a result, thereby
+ // causing subsequent tasks associated with the promise to also be
+ // abandoned and eventually destroyed if they cannot make progress
+ // without the promised result.
+ promise_impl<typename bridge_state::promise_continuation> promise_or(
+ result_type result_if_abandoned) {
+ assert(consumption_ref_);
+ return make_promise_with_continuation(typename bridge_state::promise_continuation(
+ std::move(consumption_ref_), std::move(result_if_abandoned)));
+ }
- consumer(const consumer& other) = delete;
- consumer& operator=(const consumer& other) = delete;
+ consumer(const consumer& other) = delete;
+ consumer& operator=(const consumer& other) = delete;
-private:
- friend class bridge<V, E>;
+ private:
+ friend class bridge<V, E>;
- consumption_ref consumption_ref_;
+ consumption_ref consumption_ref_;
};
// Schedules |promise| to run on |executor| and returns a |consumer| which
@@ -463,26 +440,23 @@
// executor->schedule_task(
// m->perform_calculation(16)
// .promise_or(fit::error())
-// .and_then([] (int result) { printf("done: %d\n", result); })
+// .and_then([] (const int& result) { printf("done: %d\n", result); })
// .or_else([] { puts("failed or abandoned"); }));
// }
//
template <typename Promise>
-inline consumer<typename Promise::value_type, typename Promise::error_type>
-schedule_for_consumer(fit::executor* executor, Promise promise) {
- assert(executor);
- assert(promise);
- fit::bridge<typename Promise::value_type,
- typename Promise::error_type>
- bridge;
- executor->schedule_task(
- promise.then([completer = std::move(bridge.completer())](
- typename Promise::result_type& result) mutable {
- completer.complete_or_abandon(std::move(result));
- }));
- return std::move(bridge.consumer());
+inline consumer<typename Promise::value_type, typename Promise::error_type> schedule_for_consumer(
+ fit::executor* executor, Promise promise) {
+ assert(executor);
+ assert(promise);
+ fit::bridge<typename Promise::value_type, typename Promise::error_type> bridge;
+ executor->schedule_task(promise.then(
+ [completer = std::move(bridge.completer)](typename Promise::result_type& result) mutable {
+ completer.complete_or_abandon(std::move(result));
+ }));
+ return std::move(bridge.consumer);
}
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_BRIDGE_H_
+#endif // LIB_FIT_BRIDGE_H_
diff --git a/pkg/fit/include/lib/fit/bridge_internal.h b/pkg/fit/include/lib/fit/bridge_internal.h
index 8f805ee..fe8b321 100644
--- a/pkg/fit/include/lib/fit/bridge_internal.h
+++ b/pkg/fit/include/lib/fit/bridge_internal.h
@@ -36,203 +36,184 @@
// - When both refs are dropped, the bridge state is destroyed.
template <typename V, typename E>
class bridge_state final {
-public:
- class completion_ref;
- class consumption_ref;
- class promise_continuation;
+ public:
+ class completion_ref;
+ class consumption_ref;
+ class promise_continuation;
- using result_type = result<V, E>;
+ using result_type = result<V, E>;
- ~bridge_state() = default;
+ ~bridge_state() = default;
- static void create(completion_ref* out_completion_ref,
- consumption_ref* out_consumption_ref);
+ static void create(completion_ref* out_completion_ref, consumption_ref* out_consumption_ref);
- bool was_canceled() const;
- bool was_abandoned() const;
- void complete_or_abandon(completion_ref ref, result_type result);
+ bool was_canceled() const;
+ bool was_abandoned() const;
+ void complete_or_abandon(completion_ref ref, result_type result);
- bridge_state(const bridge_state&) = delete;
- bridge_state(bridge_state&&) = delete;
- bridge_state& operator=(const bridge_state&) = delete;
- bridge_state& operator=(bridge_state&&) = delete;
+ bridge_state(const bridge_state&) = delete;
+ bridge_state(bridge_state&&) = delete;
+ bridge_state& operator=(const bridge_state&) = delete;
+ bridge_state& operator=(bridge_state&&) = delete;
-private:
- enum class disposition {
- pending,
- abandoned,
- completed,
- canceled,
- returned
- };
+ private:
+ enum class disposition { pending, abandoned, completed, canceled, returned };
- bridge_state() = default;
+ bridge_state() = default;
- void drop_completion_ref(bool was_completed);
- void drop_consumption_ref(bool was_consumed);
- void drop_ref_and_maybe_delete_self();
- void set_result_if_abandoned(result_type result_if_abandoned);
- result_type await_result(consumption_ref* ref, ::fit::context& context);
- void deliver_result() FIT_REQUIRES(mutex_);
+ void drop_completion_ref(bool was_completed);
+ void drop_consumption_ref(bool was_consumed);
+ void drop_ref_and_maybe_delete_self();
+ void set_result_if_abandoned(result_type result_if_abandoned);
+ result_type await_result(consumption_ref* ref, ::fit::context& context);
- mutable std::mutex mutex_;
+ mutable std::mutex mutex_;
- // Ref-count for completion and consumption.
- // There can only be one of each ref type so the initial count is 2.
- std::atomic<uint32_t> ref_count_{2};
+ // Ref-count for completion and consumption.
+ // There can only be one of each ref type so the initial count is 2.
+ std::atomic<uint32_t> ref_count_{2};
- // The disposition of the bridge.
- disposition disposition_ FIT_GUARDED(mutex_) = {disposition::pending};
+ // The disposition of the bridge.
+ // TODO(fxbug.dev/4139): It should be possible to implement a lock-free algorithm
+ // so as to eliminate the re-entrance hazards by introducing additional
+ // intermediate dispositions such that |task_| and |result| could be
+ // safely accessed while in those states.
+ disposition disposition_ FIT_GUARDED(mutex_) = {disposition::pending};
- // The suspended task.
- // Invariant: Only valid when disposition is |pending|.
- suspended_task task_ FIT_GUARDED(mutex_);
+ // The suspended task.
+ // Invariant: Only valid when disposition is |pending|.
+ suspended_task task_ FIT_GUARDED(mutex_);
- // The result in flight.
- // Invariant: Only valid when disposition is |pending|, |completed|,
- // or |abandoned|.
- result_type result_ FIT_GUARDED(mutex_);
+ // The result in flight.
+ // Invariant: Only valid when disposition is |pending|, |completed|,
+ // or |abandoned|.
+ result_type result_ FIT_GUARDED(mutex_);
};
// The unique capability held by a bridge's completer.
template <typename V, typename E>
class bridge_state<V, E>::completion_ref final {
-public:
- completion_ref()
- : state_(nullptr) {}
+ public:
+ completion_ref() : state_(nullptr) {}
- explicit completion_ref(bridge_state* state)
- : state_(state) {} // adopts existing reference
+ explicit completion_ref(bridge_state* state) : state_(state) {} // adopts existing reference
- completion_ref(completion_ref&& other)
- : state_(other.state_) {
- other.state_ = nullptr;
- }
+ completion_ref(completion_ref&& other) : state_(other.state_) { other.state_ = nullptr; }
- ~completion_ref() {
- if (state_)
- state_->drop_completion_ref(false /*was_completed*/);
- }
+ ~completion_ref() {
+ if (state_)
+ state_->drop_completion_ref(false /*was_completed*/);
+ }
- completion_ref& operator=(completion_ref&& other) {
- if (&other == this)
- return *this;
- if (state_)
- state_->drop_completion_ref(false /*was_completed*/);
- state_ = other.state_;
- other.state_ = nullptr;
- return *this;
- }
+ completion_ref& operator=(completion_ref&& other) {
+ if (&other == this)
+ return *this;
+ if (state_)
+ state_->drop_completion_ref(false /*was_completed*/);
+ state_ = other.state_;
+ other.state_ = nullptr;
+ return *this;
+ }
- explicit operator bool() const { return !!state_; }
+ explicit operator bool() const { return !!state_; }
- bridge_state* get() const { return state_; }
+ bridge_state* get() const { return state_; }
- void drop_after_completion() {
- state_->drop_completion_ref(true /*was_completed*/);
- state_ = nullptr;
- }
+ void drop_after_completion() {
+ state_->drop_completion_ref(true /*was_completed*/);
+ state_ = nullptr;
+ }
- completion_ref(const completion_ref& other) = delete;
- completion_ref& operator=(const completion_ref& other) = delete;
+ completion_ref(const completion_ref& other) = delete;
+ completion_ref& operator=(const completion_ref& other) = delete;
-private:
- bridge_state* state_;
+ private:
+ bridge_state* state_;
};
// The unique capability held by a bridge's consumer.
template <typename V, typename E>
class bridge_state<V, E>::consumption_ref final {
-public:
- consumption_ref()
- : state_(nullptr) {}
+ public:
+ consumption_ref() : state_(nullptr) {}
- explicit consumption_ref(bridge_state* state)
- : state_(state) {} // adopts existing reference
+ explicit consumption_ref(bridge_state* state) : state_(state) {} // adopts existing reference
- consumption_ref(consumption_ref&& other)
- : state_(other.state_) {
- other.state_ = nullptr;
- }
+ consumption_ref(consumption_ref&& other) : state_(other.state_) { other.state_ = nullptr; }
- ~consumption_ref() {
- if (state_)
- state_->drop_consumption_ref(false /*was_consumed*/);
- }
+ ~consumption_ref() {
+ if (state_)
+ state_->drop_consumption_ref(false /*was_consumed*/);
+ }
- consumption_ref& operator=(consumption_ref&& other) {
- if (&other == this)
- return *this;
- if (state_)
- state_->drop_consumption_ref(false /*was_consumed*/);
- state_ = other.state_;
- other.state_ = nullptr;
- return *this;
- }
+ consumption_ref& operator=(consumption_ref&& other) {
+ if (&other == this)
+ return *this;
+ if (state_)
+ state_->drop_consumption_ref(false /*was_consumed*/);
+ state_ = other.state_;
+ other.state_ = nullptr;
+ return *this;
+ }
- explicit operator bool() const { return !!state_; }
+ explicit operator bool() const { return !!state_; }
- bridge_state* get() const { return state_; }
+ bridge_state* get() const { return state_; }
- void drop_after_consumption() {
- state_->drop_consumption_ref(true /*was_consumed*/);
- state_ = nullptr;
- }
+ void drop_after_consumption() {
+ state_->drop_consumption_ref(true /*was_consumed*/);
+ state_ = nullptr;
+ }
- consumption_ref(const consumption_ref& other) = delete;
- consumption_ref& operator=(const consumption_ref& other) = delete;
+ consumption_ref(const consumption_ref& other) = delete;
+ consumption_ref& operator=(const consumption_ref& other) = delete;
-private:
- bridge_state* state_;
+ private:
+ bridge_state* state_;
};
// The continuation produced by |consumer::promise()| and company.
template <typename V, typename E>
class bridge_state<V, E>::promise_continuation final {
-public:
- explicit promise_continuation(consumption_ref ref)
- : ref_(std::move(ref)) {}
+ public:
+ explicit promise_continuation(consumption_ref ref) : ref_(std::move(ref)) {}
- promise_continuation(consumption_ref ref,
- result_type result_if_abandoned)
- : ref_(std::move(ref)) {
- ref_.get()->set_result_if_abandoned(std::move(result_if_abandoned));
- }
+ promise_continuation(consumption_ref ref, result_type result_if_abandoned)
+ : ref_(std::move(ref)) {
+ ref_.get()->set_result_if_abandoned(std::move(result_if_abandoned));
+ }
- result_type operator()(::fit::context& context) {
- return ref_.get()->await_result(&ref_, context);
- }
+ result_type operator()(::fit::context& context) {
+ return ref_.get()->await_result(&ref_, context);
+ }
-private:
- consumption_ref ref_;
+ private:
+ consumption_ref ref_;
};
// The callback produced by |completer::bind()|.
template <typename V, typename E>
class bridge_bind_callback final {
- using bridge_state = bridge_state<V, E>;
+ using callback_bridge_state = bridge_state<V, E>;
-public:
- explicit bridge_bind_callback(typename bridge_state::completion_ref ref)
- : ref_(std::move(ref)) {}
+ public:
+ explicit bridge_bind_callback(typename callback_bridge_state::completion_ref ref)
+ : ref_(std::move(ref)) {}
- template <typename VV = V,
- typename = std::enable_if_t<std::is_void<VV>::value>>
- void operator()() {
- bridge_state* state = ref_.get();
- state->complete_or_abandon(std::move(ref_), ::fit::ok());
- }
+ template <typename VV = V, typename = std::enable_if_t<std::is_void<VV>::value>>
+ void operator()() {
+ callback_bridge_state* state = ref_.get();
+ state->complete_or_abandon(std::move(ref_), ::fit::ok());
+ }
- template <typename VV = V,
- typename = std::enable_if_t<!std::is_void<VV>::value>>
- void operator()(VV value) {
- bridge_state* state = ref_.get();
- state->complete_or_abandon(std::move(ref_),
- ::fit::ok<V>(std::forward<VV>(value)));
- }
+ template <typename VV = V, typename = std::enable_if_t<!std::is_void<VV>::value>>
+ void operator()(VV value) {
+ callback_bridge_state* state = ref_.get();
+ state->complete_or_abandon(std::move(ref_), ::fit::ok<V>(std::forward<VV>(value)));
+ }
-private:
- typename bridge_state::completion_ref ref_;
+ private:
+ typename callback_bridge_state::completion_ref ref_;
};
// The callback produced by |completer::bind_tuple()|.
@@ -240,154 +221,169 @@
class bridge_bind_tuple_callback;
template <typename... Args, typename E>
class bridge_bind_tuple_callback<std::tuple<Args...>, E> final {
- using bridge_state = bridge_state<std::tuple<Args...>, E>;
+ using tuple_callback_bridge_state = bridge_state<std::tuple<Args...>, E>;
-public:
- explicit bridge_bind_tuple_callback(typename bridge_state::completion_ref ref)
- : ref_(std::move(ref)) {}
+ public:
+ explicit bridge_bind_tuple_callback(typename tuple_callback_bridge_state::completion_ref ref)
+ : ref_(std::move(ref)) {}
- void operator()(Args... args) {
- bridge_state* state = ref_.get();
- state->complete_or_abandon(
- std::move(ref_),
- ::fit::ok(std::make_tuple<Args...>(std::forward<Args>(args)...)));
- }
+ void operator()(Args... args) {
+ tuple_callback_bridge_state* state = ref_.get();
+ state->complete_or_abandon(std::move(ref_),
+ ::fit::ok(std::make_tuple<Args...>(std::forward<Args>(args)...)));
+ }
-private:
- typename bridge_state::completion_ref ref_;
+ private:
+ typename tuple_callback_bridge_state::completion_ref ref_;
};
template <typename V, typename E>
void bridge_state<V, E>::create(completion_ref* out_completion_ref,
consumption_ref* out_consumption_ref) {
- bridge_state* state = new bridge_state();
- *out_completion_ref = completion_ref(state);
- *out_consumption_ref = consumption_ref(state);
+ bridge_state* state = new bridge_state();
+ *out_completion_ref = completion_ref(state);
+ *out_consumption_ref = consumption_ref(state);
}
template <typename V, typename E>
bool bridge_state<V, E>::was_canceled() const {
- std::lock_guard<std::mutex> lock(mutex_);
- return disposition_ == disposition::canceled;
+ std::lock_guard<std::mutex> lock(mutex_);
+ return disposition_ == disposition::canceled;
}
template <typename V, typename E>
bool bridge_state<V, E>::was_abandoned() const {
- std::lock_guard<std::mutex> lock(mutex_);
- return disposition_ == disposition::abandoned;
+ std::lock_guard<std::mutex> lock(mutex_);
+ return disposition_ == disposition::abandoned;
}
template <typename V, typename E>
void bridge_state<V, E>::drop_completion_ref(bool was_completed) {
- if (!was_completed) {
- // The task was abandoned.
- std::lock_guard<std::mutex> lock(mutex_);
- assert(disposition_ == disposition::pending ||
- disposition_ == disposition::canceled);
- if (disposition_ == disposition::pending) {
- disposition_ = disposition::abandoned;
- deliver_result();
- }
+ suspended_task task_to_notify;
+ bool should_resume_task = false;
+ if (!was_completed) {
+ // The task was abandoned.
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(disposition_ == disposition::pending || disposition_ == disposition::canceled);
+ if (disposition_ == disposition::pending) {
+ disposition_ = disposition::abandoned;
+ task_to_notify.swap(task_);
+ should_resume_task = !result_.is_pending();
}
- drop_ref_and_maybe_delete_self();
+ }
+
+ // Drop or resume |task_to_notify| and drop the ref outside of the lock.
+ // This guards against re-entrance in case the consumption ref is
+ // dropped as a side-effect of these operations.
+ if (task_to_notify && should_resume_task) {
+ task_to_notify.resume_task();
+ }
+ drop_ref_and_maybe_delete_self();
}
template <typename V, typename E>
void bridge_state<V, E>::drop_consumption_ref(bool was_consumed) {
- if (!was_consumed) {
- // The task was canceled.
- std::lock_guard<std::mutex> lock(mutex_);
- assert(disposition_ == disposition::pending ||
- disposition_ == disposition::completed ||
- disposition_ == disposition::abandoned);
- if (disposition_ == disposition::pending) {
- disposition_ = disposition::canceled;
- result_ = ::fit::pending();
- task_.reset(); // there is no task to wake up anymore
- }
+ suspended_task task_to_drop;
+ result_type result_to_drop;
+ if (!was_consumed) {
+ // The task was canceled.
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(disposition_ == disposition::pending || disposition_ == disposition::completed ||
+ disposition_ == disposition::abandoned);
+ if (disposition_ == disposition::pending) {
+ disposition_ = disposition::canceled;
+ task_to_drop.swap(task_);
+ result_to_drop.swap(result_);
}
- drop_ref_and_maybe_delete_self();
+ }
+
+ // Drop |task_to_drop|, drop |result_to_drop|, and drop the ref
+ // outside of the lock.
+ // This guards against re-entrance in case the completion ref is
+ // dropped as a side-effect of these operations.
+ drop_ref_and_maybe_delete_self();
}
template <typename V, typename E>
void bridge_state<V, E>::drop_ref_and_maybe_delete_self() {
- uint32_t count = ref_count_.fetch_sub(1u, std::memory_order_release) - 1u;
- assert(count >= 0);
- if (count == 0) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete this;
- }
+ uint32_t count = ref_count_.fetch_sub(1u, std::memory_order_release);
+ assert(count > 0);
+ if (count == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ delete this;
+ }
}
template <typename V, typename E>
-void bridge_state<V, E>::complete_or_abandon(completion_ref ref,
- result_type result) {
- assert(ref.get() == this);
- if (result.is_pending())
- return; // let the ref go out of scope to abandon the task
+void bridge_state<V, E>::complete_or_abandon(completion_ref ref, result_type result) {
+ assert(ref.get() == this);
+ if (result.is_pending())
+ return; // let the ref go out of scope to abandon the task
- {
- std::lock_guard<std::mutex> lock(mutex_);
- assert(disposition_ == disposition::pending ||
- disposition_ == disposition::canceled);
- if (disposition_ == disposition::pending) {
- disposition_ = disposition::completed;
- result_ = std::move(result);
- deliver_result();
- }
- }
- // drop the reference ouside of the lock
- ref.drop_after_completion();
-}
-
-template <typename V, typename E>
-void bridge_state<V, E>::set_result_if_abandoned(
- result_type result_if_abandoned) {
- if (result_if_abandoned.is_pending())
- return; // nothing to do
-
+ suspended_task task_to_notify;
+ bool should_resume_task = false;
+ {
std::lock_guard<std::mutex> lock(mutex_);
- assert(disposition_ == disposition::pending ||
- disposition_ == disposition::completed ||
+ assert(disposition_ == disposition::pending || disposition_ == disposition::canceled);
+ if (disposition_ == disposition::pending) {
+ disposition_ = disposition::completed;
+ result.swap(result_);
+ task_to_notify.swap(task_);
+ should_resume_task = !result_.is_pending();
+ }
+ }
+
+ // Drop or resume |task_to_notify|, drop any prior result that
+ // was swapped into |result|, and drop the ref outside of the lock.
+ // This guards against re-entrance in case the consumption ref is
+ // dropped as a side-effect of these operations.
+ if (task_to_notify && should_resume_task) {
+ task_to_notify.resume_task();
+ }
+ ref.drop_after_completion();
+}
+
+template <typename V, typename E>
+void bridge_state<V, E>::set_result_if_abandoned(result_type result_if_abandoned) {
+ if (result_if_abandoned.is_pending())
+ return; // nothing to do
+
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(disposition_ == disposition::pending || disposition_ == disposition::completed ||
+ disposition_ == disposition::abandoned);
+ if (disposition_ == disposition::pending || disposition_ == disposition::abandoned) {
+ result_if_abandoned.swap(result_);
+ }
+
+ // Drop any prior value that was swapped into |result_if_abandoned|
+ // outside of the lock.
+}
+
+template <typename V, typename E>
+typename bridge_state<V, E>::result_type bridge_state<V, E>::await_result(consumption_ref* ref,
+ ::fit::context& context) {
+ assert(ref->get() == this);
+ suspended_task task_to_drop;
+ result_type result;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(disposition_ == disposition::pending || disposition_ == disposition::completed ||
disposition_ == disposition::abandoned);
- if (disposition_ == disposition::pending ||
- disposition_ == disposition::abandoned) {
- result_ = std::move(result_if_abandoned);
+ if (disposition_ == disposition::pending) {
+ task_to_drop.swap(task_);
+ task_ = context.suspend_task(); // assuming this isn't re-entrant
+ return ::fit::pending();
}
+ disposition_ = disposition::returned;
+ result = std::move(result_);
+ }
+
+ // Drop |task_to_drop| and the ref outside of the lock.
+ ref->drop_after_consumption();
+ return result;
}
-template <typename V, typename E>
-typename bridge_state<V, E>::result_type bridge_state<V, E>::await_result(
- consumption_ref* ref, ::fit::context& context) {
- assert(ref->get() == this);
- result_type result;
- {
- std::lock_guard<std::mutex> lock(mutex_);
- assert(disposition_ == disposition::pending ||
- disposition_ == disposition::completed ||
- disposition_ == disposition::abandoned);
- if (disposition_ == disposition::pending) {
- task_ = context.suspend_task();
- return ::fit::pending();
- }
- disposition_ = disposition::returned;
- result = std::move(result_);
- }
- // drop the reference ouside of the lock
- ref->drop_after_consumption();
- return result;
-}
-
-template <typename V, typename E>
-void bridge_state<V, E>::deliver_result() {
- if (result_.is_pending()) {
- task_.reset(); // the task has been canceled
- } else {
- task_.resume_task(); // we have a result so wake up the task
- }
-}
-
-} // namespace internal
+} // namespace internal
template <typename V = void, typename E = void>
class bridge;
@@ -396,6 +392,6 @@
template <typename V = void, typename E = void>
class consumer;
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_BRIDGE_INTERNAL_H_
+#endif // LIB_FIT_BRIDGE_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/constructors_internal.h b/pkg/fit/include/lib/fit/constructors_internal.h
new file mode 100644
index 0000000..e11fbce
--- /dev/null
+++ b/pkg/fit/include/lib/fit/constructors_internal.h
@@ -0,0 +1,101 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_CONSTRUCTORS_INTERNAL_H_
+#define LIB_FIT_CONSTRUCTORS_INTERNAL_H_
+
+#include <type_traits>
+#include <utility>
+
+#include "utility_internal.h"
+
+namespace fit {
+namespace internal {
+
+// Mixin that implicitly deletes the subclass default constructor when type T
+// is not default constructible.
+template <typename T, bool = std::is_default_constructible<T>::value>
+struct modulate_default_constructor {};
+template <typename T>
+struct modulate_default_constructor<T, false> {
+ constexpr modulate_default_constructor() = delete;
+};
+
+// Mixin that implicitly deletes the subclass copy constructor when type T is
+// not copy constructible.
+template <size_t Index, typename T, bool = std::is_copy_constructible<T>::value>
+struct modulate_copy_constructor {};
+template <size_t Index, typename T>
+struct modulate_copy_constructor<Index, T, false> {
+ constexpr modulate_copy_constructor() = default;
+ constexpr modulate_copy_constructor(const modulate_copy_constructor&) = delete;
+ constexpr modulate_copy_constructor& operator=(const modulate_copy_constructor&) = default;
+ constexpr modulate_copy_constructor(modulate_copy_constructor&&) = default;
+ constexpr modulate_copy_constructor& operator=(modulate_copy_constructor&&) = default;
+};
+
+// Mixin that implicitly deletes the subclass copy assignment operator when type
+// T is not copy assignable.
+template <size_t Index, typename T, bool = std::is_copy_assignable<T>::value>
+struct modulate_copy_assignment {};
+template <size_t Index, typename T>
+struct modulate_copy_assignment<Index, T, false> {
+ constexpr modulate_copy_assignment() = default;
+ constexpr modulate_copy_assignment(const modulate_copy_assignment&) = default;
+ constexpr modulate_copy_assignment& operator=(const modulate_copy_assignment&) = delete;
+ constexpr modulate_copy_assignment(modulate_copy_assignment&&) = default;
+ constexpr modulate_copy_assignment& operator=(modulate_copy_assignment&&) = default;
+};
+
+// Mixin that implicitly deletes the subclass move constructor when type T is
+// not move constructible.
+template <size_t Index, typename T, bool = std::is_move_constructible<T>::value>
+struct modulate_move_constructor {};
+template <size_t Index, typename T>
+struct modulate_move_constructor<Index, T, false> {
+ constexpr modulate_move_constructor() = default;
+ constexpr modulate_move_constructor(const modulate_move_constructor&) = default;
+ constexpr modulate_move_constructor& operator=(const modulate_move_constructor&) = default;
+ constexpr modulate_move_constructor(modulate_move_constructor&&) = delete;
+ constexpr modulate_move_constructor& operator=(modulate_move_constructor&&) = default;
+};
+
+// Mixin that implicitly deletes the subclass move assignment operator when type
+// T is not move assignable.
+template <size_t Index, typename T, bool = std::is_move_assignable<T>::value>
+struct modulate_move_assignment {};
+template <size_t Index, typename T>
+struct modulate_move_assignment<Index, T, false> {
+ constexpr modulate_move_assignment() = default;
+ constexpr modulate_move_assignment(const modulate_move_assignment&) = default;
+ constexpr modulate_move_assignment& operator=(const modulate_move_assignment&) = default;
+ constexpr modulate_move_assignment(modulate_move_assignment&&) = default;
+ constexpr modulate_move_assignment& operator=(modulate_move_assignment&&) = delete;
+};
+
+// Utility that takes an index sequence and an equally sized parameter pack and
+// mixes in each of the above copy/move construction/assignment modulators for
+// each type in Ts. The indices are used to avoid duplicate direct base errors
+// by ensuring that each mixin type is unique, even when there are duplicate
+// types within the parameter pack Ts.
+template <typename IndexSequence, typename... Ts>
+struct modulate_copy_and_move_index;
+
+template <size_t... Is, typename... Ts>
+struct modulate_copy_and_move_index<std::index_sequence<Is...>, Ts...>
+ : modulate_copy_constructor<Is, Ts>...,
+ modulate_copy_assignment<Is, Ts>...,
+ modulate_move_constructor<Is, Ts>...,
+ modulate_move_assignment<Is, Ts>... {};
+
+// Mixin that modulates the subclass copy/move constructors and assignment
+// operators based on the copy/move characteristics of each type in Ts.
+template <typename... Ts>
+struct modulate_copy_and_move
+ : modulate_copy_and_move_index<std::index_sequence_for<Ts...>, Ts...> {};
+
+} // namespace internal
+} // namespace fit
+
+#endif // LIB_FIT_CONSTRUCTORS_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/defer.h b/pkg/fit/include/lib/fit/defer.h
index 7d85048..850a6f6 100644
--- a/pkg/fit/include/lib/fit/defer.h
+++ b/pkg/fit/include/lib/fit/defer.h
@@ -7,6 +7,7 @@
#include <utility>
+#include "function.h"
#include "nullable.h"
namespace fit {
@@ -21,88 +22,84 @@
// See |fit::defer()| for idiomatic usage.
template <typename T>
class deferred_action final {
-public:
- // Creates a deferred action without a pending target.
- deferred_action() = default;
- explicit deferred_action(decltype(nullptr)) {}
+ public:
+ // Creates a deferred action without a pending target.
+ deferred_action() = default;
+ explicit deferred_action(decltype(nullptr)) {}
- // Creates a deferred action with a pending target.
- explicit deferred_action(T target)
- : target_(std::move(target)) {}
+ // Creates a deferred action with a pending target.
+ explicit deferred_action(T target) : target_(std::move(target)) {}
- // Creates a deferred action with a pending target moved from another
- // deferred action, leaving the other one without a pending target.
- deferred_action(deferred_action&& other) = default;
+ // Creates a deferred action with a pending target moved from another
+ // deferred action, leaving the other one without a pending target.
+ deferred_action(deferred_action&& other) : target_(std::move(other.target_)) {
+ other.target_.reset();
+ }
- // Invokes and releases the deferred action's pending target (if any).
- ~deferred_action() {
- call();
+ // Invokes and releases the deferred action's pending target (if any).
+ ~deferred_action() { call(); }
+
+ // Returns true if the deferred action has a pending target.
+ explicit operator bool() const { return !!target_; }
+
+ // Invokes and releases the deferred action's pending target (if any),
+ // then move-assigns it from another deferred action, leaving the latter
+ // one without a pending target.
+ deferred_action& operator=(deferred_action&& other) {
+ if (&other == this)
+ return *this;
+ call();
+ target_ = std::move(other.target_);
+ other.target_.reset();
+ return *this;
+ }
+
+ // Invokes and releases the deferred action's pending target (if any).
+ void call() {
+ if (target_) {
+ // Move to a local to guard against re-entrance.
+ T local_target = std::move(*target_);
+ target_.reset();
+ local_target();
}
+ }
- // Returns true if the deferred action has a pending target.
- explicit operator bool() const {
- return !!target_;
- }
+ // Releases the deferred action's pending target (if any) without
+ // invoking it.
+ void cancel() { target_.reset(); }
+ deferred_action& operator=(decltype(nullptr)) {
+ cancel();
+ return *this;
+ }
- // Invokes and releases the deferred action's pending target (if any),
- // then move-assigns it from another deferred action, leaving the latter
- // one without a pending target.
- deferred_action& operator=(deferred_action&& other) {
- if (&other == this)
- return *this;
- call();
- target_ = std::move(other.target_);
- return *this;
- }
+ // Assigns a new target to the deferred action.
+ deferred_action& operator=(T target) {
+ target_ = std::move(target);
+ return *this;
+ }
- // Invokes and releases the deferred action's pending target (if any).
- void call() {
- if (target_) {
- // Move to a local to guard against re-entrance.
- T local_target = std::move(*target_);
- target_.reset();
- local_target();
- }
- }
+ deferred_action(const deferred_action& other) = delete;
+ deferred_action& operator=(const deferred_action& other) = delete;
- // Releases the deferred action's pending target (if any) without
- // invoking it.
- void cancel() {
- target_.reset();
- }
- deferred_action& operator=(decltype(nullptr)) {
- cancel();
- return *this;
- }
-
- // Assigns a new target to the deferred action.
- deferred_action& operator=(T target) {
- target_ = std::move(target);
- return *this;
- }
-
- deferred_action(const deferred_action& other) = delete;
- deferred_action& operator=(const deferred_action& other) = delete;
-
-private:
- nullable<T> target_;
+ private:
+ nullable<T> target_;
};
template <typename T>
bool operator==(const deferred_action<T>& action, decltype(nullptr)) {
- return !action;
+ return !action;
}
template <typename T>
bool operator==(decltype(nullptr), const deferred_action<T>& action) {
- return !action;
+ return !action;
}
template <typename T>
bool operator!=(const deferred_action<T>& action, decltype(nullptr)) {
- return !!action;
+ return !!action;
}
template <typename T>
bool operator!=(decltype(nullptr), const deferred_action<T>& action) {
- return !!action;
+ return !!action;
}
// Defers execution of a function-like callable target with no arguments
@@ -130,9 +127,18 @@
// }
template <typename T>
inline deferred_action<T> defer(T target) {
- return deferred_action<T>(std::move(target));
+ return deferred_action<T>(std::move(target));
}
-} // namespace fit
+// Alias for a deferred_action using a fit::callback.
+using deferred_callback = deferred_action<fit::callback<void()>>;
-#endif // LIB_FIT_DEFER_H_
+// Defers execution of a fit::callback with no arguments. See |fit::defer| for
+// details.
+inline deferred_callback defer_callback(fit::callback<void()> target) {
+ return deferred_callback(std::move(target));
+}
+
+} // namespace fit
+
+#endif // LIB_FIT_DEFER_H_
diff --git a/pkg/fit/include/lib/fit/function.h b/pkg/fit/include/lib/fit/function.h
index 5aaecca..16febf9 100644
--- a/pkg/fit/include/lib/fit/function.h
+++ b/pkg/fit/include/lib/fit/function.h
@@ -5,18 +5,17 @@
#ifndef LIB_FIT_FUNCTION_H_
#define LIB_FIT_FUNCTION_H_
-#include <memory>
-#include <type_traits>
-
#include "function_internal.h"
-#include "nullable.h"
+#include "utility_internal.h"
namespace fit {
-template <size_t inline_target_size, bool require_inline,
- typename Result, typename... Args>
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
class function_impl;
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+class callback_impl;
+
// The default size allowance for storing a target inline within a function
// object, in bytes. This default allows for inline storage of targets
// as big as two pointers, such as an object pointer and a pointer to a member
@@ -25,9 +24,15 @@
// A |fit::function| is a move-only polymorphic function wrapper.
//
-// |fit::function<T>| behaves like |std::function<T>| except that it is move-only
-// instead of copyable so it can hold targets which cannot be copied, such as
-// mutable lambdas.
+// If you need a class with similar characteristics that also ensures
+// "run-once" semantics (such as callbacks shared with timeouts, or for
+// service requests with redundant, failover, or fallback service providers),
+// see |fit::callback|.
+//
+// |fit::function<T>| behaves like |std::function<T>| except that it is
+// move-only instead of copyable, so it can hold targets that cannot be copied,
+// such as mutable lambdas, and immutable lambdas that capture move-only
+// objects.
//
// Targets of up to |inline_target_size| bytes in size (rounded up for memory
// alignment) are stored inline within the function object without incurring
@@ -45,271 +50,444 @@
// fit within a function without requiring heap allocation.
// Defaults to |default_inline_target_size|.
//
-// Class members are documented in |fit::function_impl|.
+// Class members are documented in |fit::function_impl|, below.
//
// EXAMPLES
//
-// - https://fuchsia.googlesource.com/zircon/+/master/system/utest/fit/examples/function_example1.cpp
-// - https://fuchsia.googlesource.com/zircon/+/master/system/utest/fit/examples/function_example2.cpp
+// -
+// https://fuchsia.googlesource.com/fuchsia/+/HEAD/zircon/system/ulib/fit/test/examples/function_example1.cc
+// -
+// https://fuchsia.googlesource.com/fuchsia/+/HEAD/zircon/system/ulib/fit/test/examples/function_example2.cc
//
template <typename T, size_t inline_target_size = default_inline_target_size>
-using function = function_impl<inline_target_size, false, T>;
+using function = function_impl<inline_target_size,
+ /*require_inline=*/false, T>;
-// A move-only callable object wrapper which forces callables to be stored inline
+// A move-only callable object wrapper that forces callables to be stored inline
// and never performs heap allocation.
//
-// Behaves just like |fit::function<T, inline_target_size>| except that attempting
-// to store a target larger than |inline_target_size| will fail to compile.
+// Behaves just like |fit::function<T, inline_target_size>| except that
+// attempting to store a target larger than |inline_target_size| will fail to
+// compile.
template <typename T, size_t inline_target_size = default_inline_target_size>
-using inline_function = function_impl<inline_target_size, true, T>;
+using inline_function = function_impl<inline_target_size,
+ /*require_inline=*/true, T>;
// Synonym for a function which takes no arguments and produces no result.
using closure = function<void()>;
-// Function implementation details.
-// See |fit::function| documentation for more information.
-template <size_t inline_target_size, bool require_inline,
- typename Result, typename... Args>
-class function_impl<inline_target_size, require_inline, Result(Args...)> final {
- using ops_type = const ::fit::internal::target_ops<Result, Args...>*;
- using storage_type = typename std::aligned_storage<
- (inline_target_size >= sizeof(void*)
- ? inline_target_size
- : sizeof(void*))>::type; // avoid including <algorithm> just for max
- template <typename Callable>
- using target_type = ::fit::internal::target<
- Callable,
- (sizeof(Callable) <= sizeof(storage_type)),
- Result, Args...>;
- using null_target_type = target_type<decltype(nullptr)>;
+// A |fit::callback| is a move-only polymorphic function wrapper that also
+// ensures "run-once" semantics (such as callbacks shared with timeouts, or for
+// service requests with redundant, failover, or fallback service providers).
+// A |fit::callback| releases it's resources after the first call, and can be
+// inspected before calling, so a potential caller can know if it should call
+// the function, or skip the call because the target was already called.
+//
+// If you need a move-only function class with typical function characteristics,
+// that permits multiple invocations of the same function, see |fit::function|.
+//
+// |fit::callback<T>| behaves like |std::function<T>| except:
+//
+// 1. It is move-only instead of copyable, so it can hold targets that cannot
+// be copied, such as mutable lambdas, and immutable lambdas that capture
+// move-only objects.
+// 2. On the first call to invoke a |fit::callback|, the target function held
+// by the |fit::callback| cannot be called again.
+//
+// When a |fit::callback| is invoked for the first time, the target function is
+// released and destructed, along with any resources owned by that function
+// (typically the objects captured by a lambda).
+//
+// A |fit::callback| in the "already called" state has the same state as a
+// |fit::callback| that has been assigned to |nullptr|. It can be compared to
+// |nullptr| (via "==" or "!=", and its "operator bool()" returns false, which
+// provides a convenient way to gate whether or not the |fit::callback| should
+// be called. (Note that invoking an empty |fit::callback| or |fit::function|
+// will cause a program abort!)
+//
+// As an example, sharing |fit::callback| between both a service and a timeout
+// might look something like this:
+//
+// void service_with_timeout(fit::callback<void(bool)> cb, uint timeout_ms) {
+// service_request([cb = cb.share()]() mutable { if (cb) cb(false); });
+// timeout(timeout_ms, [cb = std::move(cb)]() mutable { if (cb) cb(true); });
+// }
+//
+// Since |fit::callback| objects are move-only, and not copyable, duplicate
+// references to the same |fit::callback| can be obtained via share(), as shown
+// in the example above. This method converts the |fit::callback| into a
+// reference-counted version of the |fit::callback| and returns a copy of the
+// reference as another |fit::callback| with the same target function.
+//
+// What is notable about |fit::callback<T>.share()| is that invoking any shared
+// copy will "nullify" all shared copies, as shown in the example.
+//
+// Note that |fit::callback| is NOT thread-safe by default. If multi-threaded
+// support is required, you would need to implement your own mutex, or similar
+// guard, before checking and calling a |fit::callback|.
+//
+// Targets of up to |inline_target_size| bytes in size (rounded up for memory
+// alignment) are stored inline within the callback object without incurring
+// any heap allocation. Larger callable objects will be moved to the heap as
+// required.
+//
+// See also |fit::inline_callback<T, size>| for more control over allocation
+// behavior.
+//
+// SYNOPSIS
+//
+// |T| is the callback's signature. e.g. void(int, std::string).
+//
+// |inline_target_size| is the minimum size of target that is guaranteed to
+// fit within a callback without requiring heap allocation.
+// Defaults to |default_inline_target_size|.
+//
+// Class members are documented in |fit::callback_impl|, below.
+//
+template <typename T, size_t inline_target_size = default_inline_target_size>
+using callback = callback_impl<inline_target_size, /*require_inline=*/false, T>;
-public:
- // The function's result type.
- using result_type = Result;
+// A move-only, run-once, callable object wrapper that forces callables to be
+// stored inline and never performs heap allocation.
+//
+// Behaves just like |fit::callback<T, inline_target_size>| except that
+// attempting to store a target larger than |inline_target_size| will fail to
+// compile.
+template <typename T, size_t inline_target_size = default_inline_target_size>
+using inline_callback = callback_impl<inline_target_size,
+ /*require_inline=*/true, T>;
- // // Creates a function with an empty target.
- function_impl() {
- initialize_null_target();
- }
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+class function_impl<inline_target_size, require_inline, Result(Args...)> final
+ : private ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)> {
+ using base = ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)>;
- // Creates a function with an empty target.
- function_impl(decltype(nullptr)) {
- initialize_null_target();
- }
+ // function_base requires private access during share()
+ friend class ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)>;
- // Creates a function bound to the specified function pointer.
- // If target == nullptr, assigns an empty target.
- function_impl(Result (*target)(Args...)) {
- initialize_target(target);
- }
+ // supports target() for shared functions
+ friend const void* ::fit::internal::get_target_type_id<>(
+ const function_impl<inline_target_size, require_inline, Result(Args...)>&);
- // Creates a function bound to the specified callable object.
- // If target == nullptr, assigns an empty target.
- //
- // For functors, we need to capture the raw type but also restrict on the existence of an
- // appropriate operator () to resolve overloads and implicit casts properly.
- template <typename Callable,
- typename = std::enable_if_t<
- std::is_convertible<
- decltype(std::declval<Callable&>()(
- std::declval<Args>()...)),
- result_type>::value>>
- function_impl(Callable target) {
- initialize_target(std::move(target));
- }
+ template <typename U>
+ using not_self_type = ::fit::internal::not_same_type<function_impl, U>;
- // Creates a function with a target moved from another function,
- // leaving the other function with an empty target.
- function_impl(function_impl&& other) {
- move_target_from(std::move(other));
- }
+ template <typename... Conditions>
+ using requires_conditions = ::fit::internal::requires_conditions<Conditions...>;
- // Destroys the function, releasing its target.
- ~function_impl() {
- destroy_target();
- }
+ template <typename... Conditions>
+ using assignment_requires_conditions =
+ ::fit::internal::assignment_requires_conditions<function_impl&, Conditions...>;
- // Returns true if the function has a non-empty target.
- explicit operator bool() const {
- return ops_ != &null_target_type::ops;
- };
+ public:
+ // The function's result type.
+ using typename base::result_type;
- // Invokes the function's target.
- // Aborts if the function's target is empty.
- Result operator()(Args... args) const {
- return ops_->invoke(&bits_, std::forward<Args>(args)...);
- }
+ // Initializes an empty (null) function. Attempting to call an empty
+ // function will abort the program.
+ function_impl() = default;
- // Assigns an empty target.
- function_impl& operator=(decltype(nullptr)) {
- destroy_target();
- initialize_null_target();
- return *this;
- }
+ // Creates a function with an empty target (same outcome as the default
+ // constructor).
+ function_impl(decltype(nullptr)) : base(nullptr) {}
- // Assigns the function's target.
- // If target == nullptr, assigns an empty target.
- template <typename Callable,
- typename = std::enable_if_t<
- std::is_convertible<
- decltype(std::declval<Callable&>()(
- std::declval<Args>()...)),
- result_type>::value>>
- function_impl& operator=(Callable target) {
- destroy_target();
- initialize_target(std::move(target));
- return *this;
- }
+ // Creates a function bound to the specified function pointer.
+ // If target == nullptr, assigns an empty target.
+ function_impl(Result (*target)(Args...)) : base(target) {}
- // Assigns the function with a target moved from another function,
- // leaving the other function with an empty target.
- function_impl& operator=(function_impl&& other) {
- if (&other == this)
- return *this;
- destroy_target();
- move_target_from(std::move(other));
- return *this;
- }
+ // Creates a function bound to the specified callable object.
+ // If target == nullptr, assigns an empty target.
+ //
+ // For functors, we need to capture the raw type but also restrict on the
+ // existence of an appropriate operator () to resolve overloads and implicit
+ // casts properly.
+ //
+ // Note that specializations of this template method that take fit::callback
+ // objects as the target Callable are deleted (see below).
+ template <typename Callable,
+ requires_conditions<
+ std::is_convertible<decltype(std::declval<Callable&>()(std::declval<Args>()...)),
+ result_type>,
+ not_self_type<Callable>> = true>
+ function_impl(Callable&& target) : base(std::forward<Callable>(target)) {}
- // Swaps the functions' targets.
- void swap(function_impl& other) {
- if (&other == this)
- return;
- ops_type temp_ops = ops_;
- storage_type temp_bits;
- ops_->move(&bits_, &temp_bits);
+ // Deletes the specializations of function_impl(Callable) that would allow
+ // a |fit::function| to be constructed from a |fit::callback|. This prevents
+ // unexpected behavior of a |fit::function| that would otherwise fail after
+ // one call. To explicitly allow this, simply wrap the |fit::callback| in a
+ // pass-through lambda before passing it to the |fit::function|.
+ template <size_t other_inline_target_size, bool other_require_inline>
+ function_impl(
+ ::fit::callback_impl<other_inline_target_size, other_require_inline, Result(Args...)>) =
+ delete;
- ops_ = other.ops_;
- other.ops_->move(&other.bits_, &bits_);
+ // Creates a function with a target moved from another function,
+ // leaving the other function with an empty target.
+ function_impl(function_impl&& other) : base(static_cast<base&&>(other)) {}
- other.ops_ = temp_ops;
- temp_ops->move(&temp_bits, &other.bits_);
- }
+ // Destroys the function, releasing its target.
+ ~function_impl() = default;
- // Returns a pointer to the function's target.
- template <typename Callable>
- Callable* target() {
- check_target_type<Callable>();
- return static_cast<Callable*>(ops_->get(&bits_));
- }
+ // Assigns the function to an empty target. Attempting to invoke the
+ // function will abort the program.
+ function_impl& operator=(decltype(nullptr)) {
+ base::assign(nullptr);
+ return *this;
+ }
- // Returns a pointer to the function's target.
- template <typename Callable>
- const Callable* target() const {
- check_target_type<Callable>();
- return static_cast<Callable*>(ops_->get(&bits_));
- }
+ // Assigns the function to the specified callable object. If target ==
+ // nullptr, assigns an empty target.
+ //
+ // For functors, we need to capture the raw type but also restrict on the
+ // existence of an appropriate operator () to resolve overloads and implicit
+ // casts properly.
+ //
+ // Note that specializations of this template method that take fit::callback
+ // objects as the target Callable are deleted (see below).
+ template <typename Callable>
+ assignment_requires_conditions<
+ std::is_convertible<decltype(std::declval<Callable&>()(std::declval<Args>()...)),
+ result_type>,
+ not_self_type<Callable>>
+ operator=(Callable&& target) {
+ base::assign(std::forward<Callable>(target));
+ return *this;
+ }
- // Returns a new function object which invokes the same target.
- // The target itself is not copied; it is moved to the heap and its
- // lifetime is extended until all references have been released.
- //
- // Note: This method is not supported on |fit::inline_function<>|
- // because it may incur a heap allocation which is contrary to
- // the stated purpose of |fit::inline_function<>|.
- function_impl share() {
- static_assert(!require_inline, "Inline functions cannot be shared.");
- // TODO(jeffbrown): Replace shared_ptr with a better ref-count mechanism.
- // TODO(jeffbrown): This definition breaks the client's ability to use
- // |target()| because the target's type has changed. We could fix this
- // by defining a new target type (and vtable) for shared targets
- // although it would be nice to avoid memory overhead and code expansion
- // when sharing is not used.
- struct ref {
- std::shared_ptr<function_impl> target;
- Result operator()(Args... args) {
- return (*target)(std::forward<Args>(args)...);
- }
- };
- if (ops_ != &target_type<ref>::ops) {
- if (ops_ == &null_target_type::ops) {
- return nullptr;
- }
- auto target = ref{std::make_shared<function_impl>(std::move(*this))};
- *this = std::move(target);
- }
- return function_impl(*static_cast<ref*>(ops_->get(&bits_)));
- }
+ // Deletes the specializations of operator=(Callable) that would allow
+ // a |fit::function| to be assigned from a |fit::callback|. This
+ // prevents unexpected behavior of a |fit::function| that would otherwise
+ // fail after one call. To explicitly allow this, simply wrap the
+ // |fit::callback| in a pass-through lambda before assigning it to the
+ // |fit::function|.
+ template <size_t other_inline_target_size, bool other_require_inline>
+ function_impl& operator=(
+ ::fit::callback_impl<other_inline_target_size, other_require_inline, Result(Args...)>) =
+ delete;
- function_impl(const function_impl& other) = delete;
- function_impl& operator=(const function_impl& other) = delete;
+ // Move assignment
+ function_impl& operator=(function_impl&& other) {
+ if (&other == this)
+ return *this;
+ base::assign(static_cast<base&&>(other));
+ return *this;
+ }
-private:
- // assumes target is uninitialized
- void initialize_null_target() {
- ops_ = &null_target_type::ops;
- }
+ // Swaps the functions' targets.
+ void swap(function_impl& other) { base::swap(other); }
- // assumes target is uninitialized
- template <typename Callable>
- void initialize_target(Callable target) {
- static_assert(!require_inline || sizeof(Callable) <= inline_target_size,
- "Callable too large to store inline as requested.");
- if (is_null(target)) {
- initialize_null_target();
- } else {
- ops_ = &target_type<Callable>::ops;
- target_type<Callable>::initialize(&bits_, std::move(target));
- }
- }
+ // Returns a pointer to the function's target.
+ using base::target;
- // leaves target uninitialized
- void destroy_target() {
- ops_->destroy(&bits_);
- }
+ // Returns true if the function has a non-empty target.
+ using base::operator bool;
- // leaves other target initialized to null
- void move_target_from(function_impl&& other) {
- ops_ = other.ops_;
- other.ops_->move(&other.bits_, &bits_);
- other.initialize_null_target();
- }
+ // Invokes the function's target.
+ // Aborts if the function's target is empty.
+ Result operator()(Args... args) const { return base::invoke(std::forward<Args>(args)...); }
- template <typename Callable>
- void check_target_type() const {
- if (ops_ != &target_type<Callable>::ops)
- abort();
- }
-
- ops_type ops_;
- mutable storage_type bits_;
-}; // namespace fit
+ // Returns a new function object that invokes the same target.
+ // The target itself is not copied; it is moved to the heap and its
+ // lifetime is extended until all references have been released.
+ //
+ // Note: This method is not supported on |fit::inline_function<>|
+ // because it may incur a heap allocation which is contrary to
+ // the stated purpose of |fit::inline_function<>|.
+ function_impl share() {
+ function_impl copy;
+ base::template share_with<function_impl>(copy);
+ return copy;
+ }
+};
template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
void swap(function_impl<inline_target_size, require_inline, Result, Args...>& a,
function_impl<inline_target_size, require_inline, Result, Args...>& b) {
- a.swap(b);
+ a.swap(b);
}
template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
bool operator==(const function_impl<inline_target_size, require_inline, Result, Args...>& f,
decltype(nullptr)) {
- return !f;
+ return !f;
}
template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
bool operator==(decltype(nullptr),
const function_impl<inline_target_size, require_inline, Result, Args...>& f) {
- return !f;
+ return !f;
}
template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
bool operator!=(const function_impl<inline_target_size, require_inline, Result, Args...>& f,
decltype(nullptr)) {
- return !!f;
+ return !!f;
}
template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
bool operator!=(decltype(nullptr),
const function_impl<inline_target_size, require_inline, Result, Args...>& f) {
- return !!f;
+ return !!f;
}
-// Returns a Callable object which invokes a member function of an object.
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+class callback_impl<inline_target_size, require_inline, Result(Args...)> final
+ : private ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)> {
+ using base = ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)>;
+
+ // function_base requires private access during share()
+ friend class ::fit::internal::function_base<inline_target_size, require_inline, Result(Args...)>;
+
+ // supports target() for shared functions
+ friend const void* ::fit::internal::get_target_type_id<>(
+ const callback_impl<inline_target_size, require_inline, Result(Args...)>&);
+
+ template <typename U>
+ using not_self_type = ::fit::internal::not_same_type<callback_impl, U>;
+
+ template <typename... Conditions>
+ using requires_conditions = ::fit::internal::requires_conditions<Conditions...>;
+
+ template <typename... Conditions>
+ using assignment_requires_conditions =
+ ::fit::internal::assignment_requires_conditions<callback_impl&, Conditions...>;
+
+ public:
+ // The callback function's result type.
+ using typename base::result_type;
+
+ // Initializes an empty (null) callback. Attempting to call an empty
+ // callback will abort the program.
+ callback_impl() = default;
+
+ // Creates a callback with an empty target (same outcome as the default
+ // constructor).
+ callback_impl(decltype(nullptr)) : base(nullptr) {}
+
+ // Creates a callback bound to the specified function pointer.
+ // If target == nullptr, assigns an empty target.
+ callback_impl(Result (*target)(Args...)) : base(target) {}
+
+ // Creates a callback bound to the specified callable object.
+ // If target == nullptr, assigns an empty target.
+ //
+ // For functors, we need to capture the raw type but also restrict on the
+ // existence of an appropriate operator () to resolve overloads and implicit
+ // casts properly.
+ template <typename Callable,
+ requires_conditions<
+ std::is_convertible<decltype(std::declval<Callable&>()(std::declval<Args>()...)),
+ result_type>,
+ not_self_type<Callable>> = true>
+ callback_impl(Callable&& target) : base(std::forward<Callable>(target)) {}
+
+ // Creates a callback with a target moved from another callback,
+ // leaving the other callback with an empty target.
+ callback_impl(callback_impl&& other) : base(static_cast<base&&>(other)) {}
+
+ // Destroys the callback, releasing its target.
+ ~callback_impl() = default;
+
+ // Assigns the callback to an empty target. Attempting to invoke the
+ // callback will abort the program.
+ callback_impl& operator=(decltype(nullptr)) {
+ base::assign(nullptr);
+ return *this;
+ }
+
+ // Assigns the callback to the specified callable object. If target ==
+ // nullptr, assigns an empty target.
+ //
+ // For functors, we need to capture the raw type but also restrict on the
+ // existence of an appropriate operator () to resolve overloads and implicit
+ // casts properly.
+ template <typename Callable>
+ assignment_requires_conditions<
+ std::is_convertible<decltype(std::declval<Callable&>()(std::declval<Args>()...)),
+ result_type>,
+ not_self_type<Callable>>
+ operator=(Callable&& target) {
+ base::assign(std::forward<Callable>(target));
+ return *this;
+ }
+
+ // Move assignment
+ callback_impl& operator=(callback_impl&& other) {
+ if (&other == this)
+ return *this;
+ base::assign(static_cast<base&&>(other));
+ return *this;
+ }
+
+ // Swaps the callbacks' targets.
+ void swap(callback_impl& other) { base::swap(other); }
+
+ // Returns a pointer to the callback's target.
+ using base::target;
+
+ // Returns true if the callback has a non-empty target.
+ using base::operator bool;
+
+ // Invokes the callback's target.
+ // Aborts if the callback's target is empty.
+ // |fit::callback| must be non-const to invoke. Before the target function
+ // is actually called, the fit::callback will be set to the default empty
+ // state (== nullptr, and operator bool() will subsequently return |false|).
+ // The target function will then be released after the function is called.
+ // If the callback was shared, any remaining copies will also be cleared.
+ Result operator()(Args... args) {
+ auto temp = std::move(*this);
+ return temp.invoke(std::forward<Args>(args)...);
+ }
+
+ // Returns a new callback object that invokes the same target.
+ // The target itself is not copied; it is moved to the heap and its
+ // lifetime is extended until all references have been released.
+ // For |fit::callback| (unlike fit::function), the first invocation of the
+ // callback will release all references to the target. All callbacks
+ // derived from the same original callback (via share()) will be cleared,
+ // as if set to |nullptr|, and "operator bool()" will return false.
+ //
+ // Note: This method is not supported on |fit::inline_function<>|
+ // because it may incur a heap allocation which is contrary to
+ // the stated purpose of |fit::inline_function<>|.
+ callback_impl share() {
+ callback_impl copy;
+ base::template share_with<callback_impl>(copy);
+ return copy;
+ }
+};
+
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+void swap(callback_impl<inline_target_size, require_inline, Result, Args...>& a,
+ callback_impl<inline_target_size, require_inline, Result, Args...>& b) {
+ a.swap(b);
+}
+
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+bool operator==(const callback_impl<inline_target_size, require_inline, Result, Args...>& f,
+ decltype(nullptr)) {
+ return !f;
+}
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+bool operator==(decltype(nullptr),
+ const callback_impl<inline_target_size, require_inline, Result, Args...>& f) {
+ return !f;
+}
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+bool operator!=(const callback_impl<inline_target_size, require_inline, Result, Args...>& f,
+ decltype(nullptr)) {
+ return !!f;
+}
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+bool operator!=(decltype(nullptr),
+ const callback_impl<inline_target_size, require_inline, Result, Args...>& f) {
+ return !!f;
+}
+
+// Returns a Callable object that invokes a member function of an object.
template <typename R, typename T, typename... Args>
auto bind_member(T* instance, R (T::*fn)(Args...)) {
- return [instance, fn](Args... args) {
- return (instance->*fn)(std::forward<Args>(args)...);
- };
+ return [instance, fn](Args... args) { return (instance->*fn)(std::forward<Args>(args)...); };
}
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_FUNCTION_H_
+#endif // LIB_FIT_FUNCTION_H_
diff --git a/pkg/fit/include/lib/fit/function_internal.h b/pkg/fit/include/lib/fit/function_internal.h
index ddcefef..6d67522 100644
--- a/pkg/fit/include/lib/fit/function_internal.h
+++ b/pkg/fit/include/lib/fit/function_internal.h
@@ -8,6 +8,10 @@
#include <stddef.h>
#include <stdlib.h>
+#include <memory>
+
+#include "nullable.h"
+
#include <new>
#include <type_traits>
#include <utility>
@@ -17,105 +21,386 @@
template <typename Result, typename... Args>
struct target_ops final {
- void* (*get)(void* bits);
- Result (*invoke)(void* bits, Args... args);
- void (*move)(void* from_bits, void* to_bits);
- void (*destroy)(void* bits);
+ const void* (*target_type_id)(void* bits, const void* impl_ops);
+ void* (*get)(void* bits);
+ Result (*invoke)(void* bits, Args... args);
+ void (*move)(void* from_bits, void* to_bits);
+ void (*destroy)(void* bits);
};
-template <typename Callable, bool is_inline, typename Result, typename... Args>
+template <typename Callable, bool is_inline, bool is_shared, typename Result, typename... Args>
struct target;
-template <typename Result, typename... Args>
-struct target<decltype(nullptr), true, Result, Args...> final {
- static Result invoke(void* bits, Args... args) {
- abort();
- }
+inline const void* unshared_target_type_id(void* bits, const void* impl_ops) { return impl_ops; }
- static const target_ops<Result, Args...> ops;
+// vtable for nullptr (empty target function)
+
+template <typename Result, typename... Args>
+struct target<decltype(nullptr),
+ /*is_inline=*/true, /*is_shared=*/false, Result, Args...>
+ final {
+ static Result invoke(void* bits, Args... args) { __builtin_abort(); }
+
+ static const target_ops<Result, Args...> ops;
};
-inline void* null_target_get(void* bits) {
- return nullptr;
-}
+inline void* null_target_get(void* bits) { return nullptr; }
inline void null_target_move(void* from_bits, void* to_bits) {}
inline void null_target_destroy(void* bits) {}
template <typename Result, typename... Args>
-constexpr target_ops<Result, Args...> target<decltype(nullptr), true, Result, Args...>::ops = {
- &null_target_get,
- &target::invoke,
- &null_target_move,
+constexpr target_ops<Result, Args...> target<decltype(nullptr),
+ /*is_inline=*/true,
+ /*is_shared=*/false, Result, Args...>::ops = {
+ &unshared_target_type_id, &null_target_get, &target::invoke, &null_target_move,
&null_target_destroy};
-template <typename Callable, typename Result, typename... Args>
-struct target<Callable, true, Result, Args...> final {
- static void initialize(void* bits, Callable&& target) {
- new (bits) Callable(std::move(target));
- }
- static Result invoke(void* bits, Args... args) {
- auto& target = *static_cast<Callable*>(bits);
- return target(std::forward<Args>(args)...);
- }
- static void move(void* from_bits, void* to_bits) {
- auto& from_target = *static_cast<Callable*>(from_bits);
- new (to_bits) Callable(std::move(from_target));
- from_target.~Callable();
- }
- static void destroy(void* bits) {
- auto& target = *static_cast<Callable*>(bits);
- target.~Callable();
- }
+// vtable for inline target function
- static const target_ops<Result, Args...> ops;
+template <typename Callable, typename Result, typename... Args>
+struct target<Callable,
+ /*is_inline=*/true, /*is_shared=*/false, Result, Args...>
+ final {
+ template <typename Callable_>
+ static void initialize(void* bits, Callable_&& target) {
+ new (bits) Callable(std::forward<Callable_>(target));
+ }
+ static Result invoke(void* bits, Args... args) {
+ auto& target = *static_cast<Callable*>(bits);
+ return target(std::forward<Args>(args)...);
+ }
+ static void move(void* from_bits, void* to_bits) {
+ auto& from_target = *static_cast<Callable*>(from_bits);
+ new (to_bits) Callable(std::move(from_target));
+ from_target.~Callable();
+ }
+ static void destroy(void* bits) {
+ auto& target = *static_cast<Callable*>(bits);
+ target.~Callable();
+ }
+
+ static const target_ops<Result, Args...> ops;
};
-inline void* inline_target_get(void* bits) {
- return bits;
-}
+inline void* inline_target_get(void* bits) { return bits; }
template <typename Callable, typename Result, typename... Args>
-constexpr target_ops<Result, Args...> target<Callable, true, Result, Args...>::ops = {
- &inline_target_get,
- &target::invoke,
- &target::move,
- &target::destroy};
+constexpr target_ops<Result, Args...> target<Callable,
+ /*is_inline=*/true,
+ /*is_shared=*/false, Result, Args...>::ops = {
+ &unshared_target_type_id, &inline_target_get, &target::invoke, &target::move, &target::destroy};
+
+// vtable for pointer to target function
template <typename Callable, typename Result, typename... Args>
-struct target<Callable, false, Result, Args...> final {
- static void initialize(void* bits, Callable&& target) {
- auto ptr = static_cast<Callable**>(bits);
- *ptr = new Callable(std::move(target));
- }
- static Result invoke(void* bits, Args... args) {
- auto& target = **static_cast<Callable**>(bits);
- return target(std::forward<Args>(args)...);
- }
- static void move(void* from_bits, void* to_bits) {
- auto from_ptr = static_cast<Callable**>(from_bits);
- auto to_ptr = static_cast<Callable**>(to_bits);
- *to_ptr = *from_ptr;
- }
- static void destroy(void* bits) {
- auto ptr = static_cast<Callable**>(bits);
- delete *ptr;
- }
+struct target<Callable,
+ /*is_inline=*/false, /*is_shared=*/false, Result, Args...>
+ final {
+ template <typename Callable_>
+ static void initialize(void* bits, Callable_&& target) {
+ auto ptr = static_cast<Callable**>(bits);
+ *ptr = new Callable(std::forward<Callable_>(target));
+ }
+ static Result invoke(void* bits, Args... args) {
+ auto& target = **static_cast<Callable**>(bits);
+ return target(std::forward<Args>(args)...);
+ }
+ static void move(void* from_bits, void* to_bits) {
+ auto from_ptr = static_cast<Callable**>(from_bits);
+ auto to_ptr = static_cast<Callable**>(to_bits);
+ *to_ptr = *from_ptr;
+ }
+ static void destroy(void* bits) {
+ auto ptr = static_cast<Callable**>(bits);
+ delete *ptr;
+ }
- static const target_ops<Result, Args...> ops;
+ static const target_ops<Result, Args...> ops;
};
-inline void* heap_target_get(void* bits) {
- return *static_cast<void**>(bits);
-}
+inline void* heap_target_get(void* bits) { return *static_cast<void**>(bits); }
template <typename Callable, typename Result, typename... Args>
-constexpr target_ops<Result, Args...> target<Callable, false, Result, Args...>::ops = {
- &heap_target_get,
- &target::invoke,
- &target::move,
- &target::destroy};
+constexpr target_ops<Result, Args...> target<Callable,
+ /*is_inline=*/false,
+ /*is_shared=*/false, Result, Args...>::ops = {
+ &unshared_target_type_id, &heap_target_get, &target::invoke, &target::move, &target::destroy};
-} // namespace internal
-} // namespace fit
+// vtable for fit::function std::shared_ptr to target function
-#endif // LIB_FIT_FUNCTION_INTERNAL_H_
+template <typename SharedFunction>
+const void* get_target_type_id(const SharedFunction& function_or_callback) {
+ return function_or_callback.target_type_id();
+}
+
+// For this vtable,
+// Callable by definition will be either a fit::function or fit::callback
+template <typename SharedFunction, typename Result, typename... Args>
+struct target<SharedFunction,
+ /*is_inline=*/false, /*is_shared=*/true, Result, Args...>
+ final {
+ static void initialize(void* bits, SharedFunction target) {
+ new (bits) std::shared_ptr<SharedFunction>(
+ std::move(std::make_shared<SharedFunction>(std::move(target))));
+ }
+ static void copy_shared_ptr(void* from_bits, void* to_bits) {
+ auto& from_shared_ptr = *static_cast<std::shared_ptr<SharedFunction>*>(from_bits);
+ new (to_bits) std::shared_ptr<SharedFunction>(from_shared_ptr);
+ }
+ static const void* target_type_id(void* bits, const void* impl_ops) {
+ auto& function_or_callback = **static_cast<std::shared_ptr<SharedFunction>*>(bits);
+ return ::fit::internal::get_target_type_id(function_or_callback);
+ }
+ static void* get(void* bits) {
+ auto& function_or_callback = **static_cast<std::shared_ptr<SharedFunction>*>(bits);
+ return function_or_callback.template target<SharedFunction>(
+ /*check=*/false); // void* will fail the check
+ }
+ static Result invoke(void* bits, Args... args) {
+ auto& function_or_callback = **static_cast<std::shared_ptr<SharedFunction>*>(bits);
+ return function_or_callback(std::forward<Args>(args)...);
+ }
+ static void move(void* from_bits, void* to_bits) {
+ auto from_shared_ptr = std::move(*static_cast<std::shared_ptr<SharedFunction>*>(from_bits));
+ new (to_bits) std::shared_ptr<SharedFunction>(std::move(from_shared_ptr));
+ }
+ static void destroy(void* bits) { static_cast<std::shared_ptr<SharedFunction>*>(bits)->reset(); }
+
+ static const target_ops<Result, Args...> ops;
+};
+
+template <typename SharedFunction, typename Result, typename... Args>
+constexpr target_ops<Result, Args...> target<SharedFunction,
+ /*is_inline=*/false,
+ /*is_shared=*/true, Result, Args...>::ops = {
+ &target::target_type_id, &target::get, &target::invoke, &target::move, &target::destroy};
+
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+class function_base;
+
+// Function implementation details.
+// See |fit::function| and |fit::callback| documentation for more information.
+template <size_t inline_target_size, bool require_inline, typename Result, typename... Args>
+class function_base<inline_target_size, require_inline, Result(Args...)> {
+ using ops_type = const target_ops<Result, Args...>*;
+ using storage_type = typename std::aligned_storage<(
+ inline_target_size >= sizeof(void*) ? inline_target_size : sizeof(void*))>::
+ type; // avoid including <algorithm> for max
+ template <typename Callable>
+ using target_type = target<Callable, (sizeof(Callable) <= sizeof(storage_type)),
+ /*is_shared=*/false, Result, Args...>;
+ template <typename SharedFunction>
+ using shared_target_type = target<SharedFunction,
+ /*is_inline=*/false,
+ /*is_shared=*/true, Result, Args...>;
+ using null_target_type = target_type<decltype(nullptr)>;
+
+ protected:
+ using result_type = Result;
+
+ function_base() { initialize_null_target(); }
+
+ function_base(decltype(nullptr)) { initialize_null_target(); }
+
+ function_base(Result (*target)(Args...)) { initialize_target(target); }
+
+ template <typename Callable,
+ typename = std::enable_if_t<std::is_convertible<
+ decltype(std::declval<Callable&>()(std::declval<Args>()...)), result_type>::value>>
+ function_base(Callable&& target) {
+ initialize_target(std::forward<Callable>(target));
+ }
+
+ function_base(function_base&& other) { move_target_from(std::move(other)); }
+
+ ~function_base() { destroy_target(); }
+
+ // Returns true if the function has a non-empty target.
+ explicit operator bool() const { return ops_->get(&bits_) != nullptr; }
+
+ // Returns a pointer to the function's target.
+ // If |check| is true (the default), the function _may_ abort if the
+ // caller tries to assign the target to a varible of the wrong type. (This
+ // check is currently skipped for share()d objects.)
+ // Note the shared pointer vtable must set |check| to false to assign the
+ // target to |void*|.
+ template <typename Callable>
+ Callable* target(bool check = true) {
+ if (check)
+ check_target_type<Callable>();
+ return static_cast<Callable*>(ops_->get(&bits_));
+ }
+
+ // Returns a pointer to the function's target (const version).
+ // If |check| is true (the default), the function _may_ abort if the
+ // caller tries to assign the target to a varible of the wrong type. (This
+ // check is currently skipped for share()d objects.)
+ // Note the shared pointer vtable must set |check| to false to assign the
+ // target to |void*|.
+ template <typename Callable>
+ const Callable* target(bool check = true) const {
+ if (check)
+ check_target_type<Callable>();
+ return static_cast<Callable*>(ops_->get(&bits_));
+ }
+
+ // Used by the derived "impl" classes to implement share().
+ //
+ // The caller creates a new object of the same type as itself, and passes in
+ // the empty object. This function first checks if |this| is already shared,
+ // and if not, creates a new version of itself containing a
+ // |std::shared_ptr| to its original self, and updates |ops_| to the vtable
+ // for the shared version.
+ //
+ // Then it copies its |shared_ptr| to the |bits_| of the given |copy|,
+ // and assigns the same shared pointer vtable to the copy's |ops_|.
+ //
+ // The target itself is not copied; it is moved to the heap and its
+ // lifetime is extended until all references have been released.
+ //
+ // Note: This method is not supported on |fit::inline_function<>|
+ // because it may incur a heap allocation which is contrary to
+ // the stated purpose of |fit::inline_function<>|.
+ template <typename SharedFunction>
+ void share_with(SharedFunction& copy) {
+ static_assert(!require_inline, "Inline functions cannot be shared.");
+ if (ops_->get(&bits_) != nullptr) {
+ if (ops_ != &shared_target_type<SharedFunction>::ops) {
+ convert_to_shared_target<SharedFunction>();
+ }
+ copy_shared_target_to(copy);
+ }
+ }
+
+ // Used by derived "impl" classes to implement operator()().
+ // Invokes the function's target.
+ // Note that fit::callback will release the target immediately after
+ // invoke() (also affecting any share()d copies).
+ // Aborts if the function's target is empty.
+ Result invoke(Args... args) const { return ops_->invoke(&bits_, std::forward<Args>(args)...); }
+
+ // Used by derived "impl" classes to implement operator=().
+ // Assigns an empty target.
+ void assign(decltype(nullptr)) {
+ destroy_target();
+ initialize_null_target();
+ }
+
+ // Used by derived "impl" classes to implement operator=().
+ // Assigns the function's target.
+ // If target == nullptr, assigns an empty target.
+ template <typename Callable,
+ typename = std::enable_if_t<std::is_convertible<
+ decltype(std::declval<Callable&>()(std::declval<Args>()...)), result_type>::value>>
+ void assign(Callable&& target) {
+ destroy_target();
+ initialize_target(std::forward<Callable>(target));
+ }
+
+ // Used by derived "impl" classes to implement operator=().
+ // Assigns the function with a target moved from another function,
+ // leaving the other function with an empty target.
+ void assign(function_base&& other) {
+ destroy_target();
+ move_target_from(std::move(other));
+ }
+
+ void swap(function_base& other) {
+ if (&other == this)
+ return;
+ ops_type temp_ops = ops_;
+ storage_type temp_bits;
+ ops_->move(&bits_, &temp_bits);
+
+ ops_ = other.ops_;
+ other.ops_->move(&other.bits_, &bits_);
+
+ other.ops_ = temp_ops;
+ temp_ops->move(&temp_bits, &other.bits_);
+ }
+
+ // returns an opaque ID unique to the |Callable| type of the target.
+ // Used by check_target_type.
+ const void* target_type_id() const { return ops_->target_type_id(&bits_, ops_); }
+
+ // Deleted copy constructor and assign. |function_base| implementations are
+ // move-only.
+ function_base(const function_base& other) = delete;
+ function_base& operator=(const function_base& other) = delete;
+
+ // Move assignment must be provided by subclasses.
+ function_base& operator=(function_base&& other) = delete;
+
+ private:
+ // Implements the move operation, used by move construction and move
+ // assignment. Leaves other target initialized to null.
+ void move_target_from(function_base&& other) {
+ ops_ = other.ops_;
+ other.ops_->move(&other.bits_, &bits_);
+ other.initialize_null_target();
+ }
+
+ // fit::function and fit::callback are not directly copyable, but share()
+ // will create shared references to the original object. This method
+ // implements the copy operation for the |std::shared_ptr| wrapper.
+ template <typename SharedFunction>
+ void copy_shared_target_to(SharedFunction& copy) {
+ copy.destroy_target();
+ assert(ops_ == &shared_target_type<SharedFunction>::ops);
+ shared_target_type<SharedFunction>::copy_shared_ptr(&bits_, ©.bits_);
+ copy.ops_ = ops_;
+ }
+
+ // assumes target is uninitialized
+ void initialize_null_target() { ops_ = &null_target_type::ops; }
+
+ // target may or may not be initialized.
+ template <typename Callable>
+ void initialize_target(Callable&& target) {
+ // Convert function or function references to function pointer.
+ using DecayedCallable = std::decay_t<Callable>;
+ static_assert(
+ std::alignment_of<DecayedCallable>::value <= std::alignment_of<storage_type>::value,
+ "Alignment of Callable must be <= alignment of max_align_t.");
+ static_assert(!require_inline || sizeof(DecayedCallable) <= inline_target_size,
+ "Callable too large to store inline as requested.");
+ if (is_null(target)) {
+ initialize_null_target();
+ } else {
+ ops_ = &target_type<DecayedCallable>::ops;
+ target_type<DecayedCallable>::initialize(&bits_, std::forward<Callable>(target));
+ }
+ }
+
+ // assumes target is uninitialized
+ template <typename SharedFunction>
+ void convert_to_shared_target() {
+ shared_target_type<SharedFunction>::initialize(&bits_,
+ std::move(*static_cast<SharedFunction*>(this)));
+ ops_ = &shared_target_type<SharedFunction>::ops;
+ }
+
+ // leaves target uninitialized
+ void destroy_target() { ops_->destroy(&bits_); }
+
+ // Called by target() if |check| is true.
+ // Checks the template parameter, usually inferred from the context of
+ // the call to target(), and aborts the program if it can determine that
+ // the Callable type is not compatible with the function's Result and Args.
+ template <typename Callable>
+ void check_target_type() const {
+ if (target_type<Callable>::ops.target_type_id(nullptr, &target_type<Callable>::ops) !=
+ target_type_id()) {
+ __builtin_abort();
+ }
+ }
+
+ ops_type ops_;
+ mutable storage_type bits_;
+};
+
+} // namespace internal
+
+} // namespace fit
+
+#endif // LIB_FIT_FUNCTION_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/function_traits.h b/pkg/fit/include/lib/fit/function_traits.h
index 3e0c2a3..6b02288 100644
--- a/pkg/fit/include/lib/fit/function_traits.h
+++ b/pkg/fit/include/lib/fit/function_traits.h
@@ -13,6 +13,6 @@
template <typename T>
using function_traits = callable_traits<T>;
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_FUNCTION_TRAITS_H_
+#endif // LIB_FIT_FUNCTION_TRAITS_H_
diff --git a/pkg/fit/include/lib/fit/in_place_internal.h b/pkg/fit/include/lib/fit/in_place_internal.h
new file mode 100644
index 0000000..dccb26a
--- /dev/null
+++ b/pkg/fit/include/lib/fit/in_place_internal.h
@@ -0,0 +1,83 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_IN_PLACE_INTERNAL_H_
+#define LIB_FIT_IN_PLACE_INTERNAL_H_
+
+#include <cstddef>
+
+namespace fit {
+
+// Tag for requesting in-place initialization.
+struct in_place_t {
+ explicit constexpr in_place_t() = default;
+};
+
+// Tag for requesting in-place initialization by type.
+template <typename T>
+struct in_place_type_t {
+ explicit constexpr in_place_type_t() = default;
+};
+
+// Tag for requesting in-place initialization by index.
+template <size_t Index>
+struct in_place_index_t final {
+ explicit constexpr in_place_index_t() = default;
+};
+
+#ifdef __cpp_inline_variables
+
+// Inline variables are only available on C++ 17 and beyond.
+
+inline constexpr in_place_t in_place{};
+
+template <typename T>
+inline constexpr in_place_type_t<T> in_place_type{};
+
+template <size_t Index>
+inline constexpr in_place_index_t<Index> in_place_index{};
+
+#else
+
+// For C++ 14 we need to provide storage for the variable so we define
+// a reference instead.
+
+template <typename Dummy = void>
+struct in_place_holder {
+ static constexpr in_place_t instance{};
+};
+
+template <typename T>
+struct in_place_type_holder {
+ static constexpr in_place_type_t<T> instance{};
+};
+
+template <size_t Index>
+struct in_place_index_holder {
+ static constexpr in_place_index_t<Index> instance{};
+};
+
+template <typename Dummy>
+constexpr in_place_t in_place_holder<Dummy>::instance;
+
+template <typename T>
+constexpr in_place_type_t<T> in_place_type_holder<T>::instance;
+
+template <size_t Index>
+constexpr in_place_index_t<Index> in_place_index_holder<Index>::instance;
+
+static constexpr const in_place_t& in_place = in_place_holder<>::instance;
+
+template <typename T>
+static constexpr const in_place_type_t<T>& in_place_type = in_place_type_holder<T>::instance;
+
+template <size_t Index>
+static constexpr const in_place_index_t<Index>& in_place_index =
+ in_place_index_holder<Index>::instance;
+
+#endif // __cpp_inline_variables
+
+} // namespace fit
+
+#endif // LIB_FIT_IN_PLACE_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/nullable.h b/pkg/fit/include/lib/fit/nullable.h
index a6050af..b693612 100644
--- a/pkg/fit/include/lib/fit/nullable.h
+++ b/pkg/fit/include/lib/fit/nullable.h
@@ -21,29 +21,28 @@
struct is_comparable_with_null<T, decltype(std::declval<const T&>() == nullptr)>
: public std::true_type {};
-// Returns true if a value equals nullptr.
-template <typename T, typename Comparable = bool>
-struct is_null_predicate {
- constexpr bool operator()(const T& value) { return false; }
-};
-template <typename T>
-struct is_null_predicate<T, decltype(std::declval<const T&>() == nullptr)> {
- constexpr bool operator()(const T& value) { return value == nullptr; }
-};
-template <typename T>
-constexpr inline bool is_null(const T& value) {
- return is_null_predicate<T>()(value);
+// Suppress the warning when the compiler can see that a nullable value is
+// never equal to nullptr.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress"
+template <typename T, std::enable_if_t<is_comparable_with_null<T>::value, bool> = true>
+constexpr inline bool is_null(T&& value) {
+ return std::forward<T>(value) == nullptr;
+}
+#pragma GCC diagnostic pop
+
+template <typename T, std::enable_if_t<!is_comparable_with_null<T>::value, bool> = false>
+constexpr inline bool is_null(T&&) {
+ return false;
}
// Determines whether a type can be initialized, assigned, and compared
// with nullptr.
template <typename T>
struct is_nullable
- : public std::integral_constant<
- bool,
- std::is_constructible<T, decltype(nullptr)>::value &&
- std::is_assignable<T&, decltype(nullptr)>::value &&
- is_comparable_with_null<T>::value> {};
+ : public std::integral_constant<bool, std::is_constructible<T, decltype(nullptr)>::value &&
+ std::is_assignable<T&, decltype(nullptr)>::value &&
+ is_comparable_with_null<T>::value> {};
template <>
struct is_nullable<void> : public std::false_type {};
@@ -58,188 +57,195 @@
// - sizeof(std::optional<void*>) == sizeof(struct { bool; void*; })
// - sizeof(fit::nullable<int>) == sizeof(struct { bool; int; })
// - sizeof(std::optional<int>) == sizeof(struct { bool; int; })
-template <typename T, bool = (is_nullable<T>::value &&
- std::is_constructible<T, T&&>::value &&
+//
+// TODO(fxbug.dev/4681): fit::nullable does not precisely mirror fit::optional now that
+// fit::optional is closer to standards compliant. This should be corrected to
+// avoid surprises when switching between the types.
+template <typename T, bool = (is_nullable<T>::value && std::is_constructible<T, T&&>::value &&
std::is_assignable<T&, T&&>::value)>
class nullable final {
-public:
- using value_type = T;
+ public:
+ using value_type = T;
- constexpr nullable() = default;
- explicit constexpr nullable(decltype(nullptr)) {}
- explicit constexpr nullable(T value)
- : opt_(std::move(value)) {}
- nullable(const nullable& other) = default;
- nullable(nullable&& other) = default;
- ~nullable() = default;
+ ~nullable() = default;
+ constexpr nullable() = default;
- constexpr T& value() & { return opt_.value(); }
- constexpr const T& value() const& { return opt_.value(); }
- constexpr T&& value() && { return std::move(opt_.value()); }
- constexpr const T&& value() const&& { return std::move(opt_.value()); }
+ explicit constexpr nullable(decltype(nullptr)) {}
+ explicit constexpr nullable(T value) : opt_(std::move(value)) {}
- template <typename U = T>
- constexpr T value_or(U&& default_value) const {
- return opt_.value_or(std::forward<U>(default_value));
- }
+ constexpr nullable(const nullable& other) = default;
+ constexpr nullable& operator=(const nullable& other) = default;
- constexpr T* operator->() { return &*opt_; }
- constexpr const T* operator->() const { return &*opt_; }
- constexpr T& operator*() { return *opt_; }
- constexpr const T& operator*() const { return *opt_; }
+ constexpr nullable(nullable&& other) = default;
+ constexpr nullable& operator=(nullable&& other) = default;
- constexpr bool has_value() const { return opt_.has_value(); }
- explicit constexpr operator bool() const { return has_value(); }
+ constexpr T& value() & { return opt_.value(); }
+ constexpr const T& value() const& { return opt_.value(); }
+ constexpr T&& value() && { return std::move(opt_.value()); }
+ constexpr const T&& value() const&& { return std::move(opt_.value()); }
- nullable& operator=(const nullable& other) = default;
- nullable& operator=(nullable&& other) = default;
+ template <typename U = T>
+ constexpr T value_or(U&& default_value) const {
+ return opt_.value_or(std::forward<U>(default_value));
+ }
- nullable& operator=(decltype(nullptr)) {
- reset();
- return *this;
- }
+ constexpr T* operator->() { return &*opt_; }
+ constexpr const T* operator->() const { return &*opt_; }
+ constexpr T& operator*() { return *opt_; }
+ constexpr const T& operator*() const { return *opt_; }
- nullable& operator=(T value) {
- opt_ = std::move(value);
- return *this;
- }
+ constexpr bool has_value() const { return opt_.has_value(); }
+ explicit constexpr operator bool() const { return has_value(); }
- void reset() { opt_.reset(); }
+ constexpr nullable& operator=(decltype(nullptr)) {
+ reset();
+ return *this;
+ }
- void swap(nullable& other) { opt_.swap(other.opt_); }
+ constexpr nullable& operator=(T value) {
+ opt_ = std::move(value);
+ return *this;
+ }
-private:
- optional<T> opt_;
+ constexpr void reset() { opt_.reset(); }
+
+ constexpr void swap(nullable& other) { opt_.swap(other.opt_); }
+
+ private:
+ optional<T> opt_;
};
template <typename T>
class nullable<T, true> final {
-public:
- using value_type = T;
+ public:
+ using value_type = T;
- constexpr nullable()
- : value_(nullptr) {}
- explicit constexpr nullable(decltype(nullptr))
- : value_(nullptr) {}
- explicit constexpr nullable(T value)
- : value_(std::move(value)) {}
- nullable(const nullable& other) = default;
- nullable(nullable&& other)
- : value_(std::move(other.value_)) {
- other.value_ = nullptr;
+ constexpr nullable() : value_(nullptr) {}
+ explicit constexpr nullable(decltype(nullptr)) : value_(nullptr) {}
+ explicit constexpr nullable(T value) : value_(std::move(value)) {}
+ constexpr nullable(const nullable& other) = default;
+ constexpr nullable(nullable&& other) : value_(std::move(other.value_)) {}
+ ~nullable() = default;
+
+ constexpr T& value() & {
+ if (has_value()) {
+ return value_;
+ } else {
+ __builtin_abort();
}
- ~nullable() = default;
-
- constexpr T& value() & {
- assert(has_value());
- return value_;
+ }
+ constexpr const T& value() const& {
+ if (has_value()) {
+ return value_;
+ } else {
+ __builtin_abort();
}
- constexpr const T& value() const& {
- assert(has_value());
- return value_;
+ }
+ constexpr T&& value() && {
+ if (has_value()) {
+ return std::move(value_);
+ } else {
+ __builtin_abort();
}
- constexpr T&& value() && {
- assert(has_value());
- return std::move(value_);
+ }
+ constexpr const T&& value() const&& {
+ if (has_value()) {
+ return std::move(value_);
+ } else {
+ __builtin_abort();
}
- constexpr const T&& value() const&& {
- assert(has_value());
- return std::move(value_);
- }
+ }
- template <typename U = T>
- constexpr T value_or(U&& default_value) const {
- return has_value() ? value_ : static_cast<T>(std::forward<U>(default_value));
- }
+ template <typename U = T>
+ constexpr T value_or(U&& default_value) const {
+ return has_value() ? value_ : static_cast<T>(std::forward<U>(default_value));
+ }
- constexpr T* operator->() { return &value_; }
- constexpr const T* operator->() const { return &value_; }
- constexpr T& operator*() { return value_; }
- constexpr const T& operator*() const { return value_; }
+ constexpr T* operator->() { return &value_; }
+ constexpr const T* operator->() const { return &value_; }
+ constexpr T& operator*() { return value_; }
+ constexpr const T& operator*() const { return value_; }
- constexpr bool has_value() const { return !(value_ == nullptr); }
- explicit constexpr operator bool() const { return has_value(); }
+ constexpr bool has_value() const { return !(value_ == nullptr); }
+ explicit constexpr operator bool() const { return has_value(); }
- nullable& operator=(const nullable& other) = default;
- nullable& operator=(nullable&& other) {
- if (&other == this)
- return *this;
- value_ = std::move(other.value_);
- other.value_ = nullptr;
- return *this;
- }
+ constexpr nullable& operator=(const nullable& other) = default;
+ constexpr nullable& operator=(nullable&& other) {
+ value_ = std::move(other.value_);
+ return *this;
+ }
- nullable& operator=(decltype(nullptr)) {
- reset();
- return *this;
- }
+ constexpr nullable& operator=(decltype(nullptr)) {
+ reset();
+ return *this;
+ }
- nullable& operator=(T value) {
- value_ = std::move(value);
- return *this;
- }
+ constexpr nullable& operator=(T value) {
+ value_ = std::move(value);
+ return *this;
+ }
- void reset() { value_ = nullptr; }
+ constexpr void reset() { value_ = nullptr; }
- void swap(nullable& other) {
- using std::swap;
- swap(value_, other.value_);
- }
+ constexpr void swap(nullable& other) {
+ using std::swap;
+ swap(value_, other.value_);
+ }
-private:
- T value_;
+ private:
+ T value_;
};
template <typename T>
void swap(nullable<T>& a, nullable<T>& b) {
- a.swap(b);
+ a.swap(b);
}
template <typename T>
constexpr bool operator==(const nullable<T>& lhs, decltype(nullptr)) {
- return !lhs.has_value();
+ return !lhs.has_value();
}
template <typename T>
constexpr bool operator!=(const nullable<T>& lhs, decltype(nullptr)) {
- return lhs.has_value();
+ return lhs.has_value();
}
template <typename T>
constexpr bool operator==(decltype(nullptr), const nullable<T>& rhs) {
- return !rhs.has_value();
+ return !rhs.has_value();
}
template <typename T>
constexpr bool operator!=(decltype(nullptr), const nullable<T>& rhs) {
- return rhs.has_value();
+ return rhs.has_value();
}
template <typename T, typename U>
constexpr bool operator==(const nullable<T>& lhs, const nullable<U>& rhs) {
- return (lhs.has_value() == rhs.has_value()) && (!lhs.has_value() || *lhs == *rhs);
+ return (lhs.has_value() == rhs.has_value()) && (!lhs.has_value() || *lhs == *rhs);
}
template <typename T, typename U>
constexpr bool operator!=(const nullable<T>& lhs, const nullable<U>& rhs) {
- return (lhs.has_value() != rhs.has_value()) || (lhs.has_value() && *lhs != *rhs);
+ return (lhs.has_value() != rhs.has_value()) || (lhs.has_value() && *lhs != *rhs);
}
template <typename T, typename U>
constexpr bool operator==(const nullable<T>& lhs, const U& rhs) {
- return (lhs.has_value() != is_null(rhs)) && (!lhs.has_value() || *lhs == rhs);
+ return (lhs.has_value() != is_null(rhs)) && (!lhs.has_value() || *lhs == rhs);
}
template <typename T, typename U>
constexpr bool operator!=(const nullable<T>& lhs, const U& rhs) {
- return (lhs.has_value() == is_null(rhs)) || (lhs.has_value() && *lhs != rhs);
+ return (lhs.has_value() == is_null(rhs)) || (lhs.has_value() && *lhs != rhs);
}
template <typename T, typename U>
constexpr bool operator==(const T& lhs, const nullable<U>& rhs) {
- return (is_null(lhs) != rhs.has_value()) && (!rhs.has_value() || lhs == *rhs);
+ return (is_null(lhs) != rhs.has_value()) && (!rhs.has_value() || lhs == *rhs);
}
template <typename T, typename U>
constexpr bool operator!=(const T& lhs, const nullable<U>& rhs) {
- return (is_null(lhs) == rhs.has_value()) || (rhs.has_value() && lhs != *rhs);
+ return (is_null(lhs) == rhs.has_value()) || (rhs.has_value() && lhs != *rhs);
}
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_NULLABLE_H_
+#endif // LIB_FIT_NULLABLE_H_
diff --git a/pkg/fit/include/lib/fit/optional.h b/pkg/fit/include/lib/fit/optional.h
index 929f05b..a29f2ea 100644
--- a/pkg/fit/include/lib/fit/optional.h
+++ b/pkg/fit/include/lib/fit/optional.h
@@ -5,294 +5,478 @@
#ifndef LIB_FIT_OPTIONAL_H_
#define LIB_FIT_OPTIONAL_H_
-#include <assert.h>
+#if defined(__cplusplus) && __cplusplus >= 201703L && !defined(FORCE_FIT_OPTIONAL)
+// In C++17 fit::optional should simply be an alias for std::optional.
+
+#include <optional>
+
+namespace fit {
+
+using std::make_optional;
+using std::nullopt;
+using std::nullopt_t;
+using std::optional;
+
+} // namespace fit
+
+#else
+
+#include <exception>
#include <new>
#include <type_traits>
#include <utility>
+#include "constructors_internal.h"
+#include "in_place_internal.h"
+#include "storage_internal.h"
+#include "traits.h"
+#include "utility_internal.h"
+
namespace fit {
-namespace internal {
-template <typename T, bool = std::is_assignable<T&, const T&>::value>
-struct copy_assign_or_reconstruct final {
- static void assign(T* dest, const T& source) {
- dest->~T();
- new (dest) T(source);
- }
-};
-
-template <typename T>
-struct copy_assign_or_reconstruct<T, true> final {
- static void assign(T* dest, const T& source) {
- *dest = source;
- }
-};
-
-template <typename T, bool = std::is_assignable<T&, T&&>::value>
-struct move_assign_or_reconstruct final {
- static void assign(T* dest, T&& source) {
- dest->~T();
- new (dest) T(std::move(source));
- }
-
- static void swap(T& a, T& b) {
- T temp(std::move(a));
- a.~T();
- new (&a) T(std::move(b));
- b.~T();
- new (&b) T(std::move(temp));
- }
-};
-
-template <typename T>
-struct move_assign_or_reconstruct<T, true> final {
- static void assign(T* dest, T&& source) {
- *dest = std::move(source);
- }
-
- static void swap(T& a, T& b) {
- using std::swap;
- swap(a, b);
- }
-};
-
-} // namespace internal
-
-// A sentinel value for |fit::optional<T>| indicating that it contains
-// no value.
+// A sentinel value for indicating that it contains no value.
struct nullopt_t {
- explicit constexpr nullopt_t(int) {}
+ explicit constexpr nullopt_t(int) {}
};
-static constexpr nullopt_t nullopt(0);
+static constexpr nullopt_t nullopt{0};
-// A minimal implementation of an |std::optional<T>| work-alike for C++ 14.
-//
-// See also |fit::nullable<T>| which may be more efficient in certain
-// circumstances if T can be initialized, assigned, and compared with
-// nullptr.
-//
-// TODO(US-90): The initial implementation only covers a minimal subset of the
-// std::optional API. Flesh this out more fully then define fit::optional
-// to be an alias for std::optional when compiling with C++ 17.
-template <typename T>
-class optional final {
-public:
- using value_type = T;
+// Exception type to report bad accesses to optional.
+class bad_optional_access : public std::exception {
+ public:
+ bad_optional_access() noexcept {}
- constexpr optional()
- : has_value_(false) {}
- constexpr optional(nullopt_t)
- : has_value_(false) {}
+ const char* what() const noexcept override { return reason_; }
- explicit constexpr optional(T value)
- : has_value_(true), value_(std::move(value)) {}
+ private:
+ template <typename T>
+ friend class optional;
- optional(const optional& other)
- : has_value_(other.has_value_) {
- if (has_value_) {
- new (&value_) T(other.value_);
- }
- }
+ bad_optional_access(const char* reason) noexcept : reason_{reason} {}
- optional(optional&& other)
- : has_value_(other.has_value_) {
- if (has_value_) {
- new (&value_) T(std::move(other.value_));
- other.value_.~T();
- other.has_value_ = false;
- }
- }
-
- // TODO(US-90): Presence of this destructor makes the type non-literal.
- // We should specialize this type to handle the case where T is literal
- // explicitly so that expressions these types can be constexpr.
- ~optional() {
- if (has_value_) {
- value_.~T();
- }
- }
-
- constexpr T& value() & {
- assert(has_value_);
- return value_;
- }
-
- constexpr const T& value() const& {
- assert(has_value_);
- return value_;
- }
-
- constexpr T&& value() && {
- assert(has_value_);
- return std::move(value_);
- }
-
- constexpr const T&& value() const&& {
- assert(has_value_);
- return std::move(value_);
- }
-
- template <typename U = T>
- constexpr T value_or(U&& default_value) const {
- return has_value_ ? value_ : static_cast<T>(std::forward<U>(default_value));
- }
-
- constexpr T* operator->() { return &value_; }
- constexpr const T* operator->() const { return &value_; }
- constexpr T& operator*() { return value_; }
- constexpr const T& operator*() const { return value_; }
-
- bool has_value() const { return has_value_; }
- explicit operator bool() const { return has_value(); }
-
- optional& operator=(const optional& other) {
- if (&other == this)
- return *this;
- if (has_value_) {
- if (other.has_value_) {
- ::fit::internal::copy_assign_or_reconstruct<T>::assign(
- &value_, other.value_);
- } else {
- reset();
- }
- } else if (other.has_value_) {
- new (&value_) T(other.value_);
- has_value_ = true;
- }
- return *this;
- }
-
- optional& operator=(optional&& other) {
- if (&other == this)
- return *this;
- if (has_value_) {
- if (other.has_value_) {
- ::fit::internal::move_assign_or_reconstruct<T>::assign(
- &value_, std::move(other.value_));
- other.value_.~T();
- other.has_value_ = false;
- } else {
- reset();
- }
- } else if (other.has_value_) {
- new (&value_) T(std::move(other.value_));
- has_value_ = true;
- other.value_.~T();
- other.has_value_ = false;
- }
- return *this;
- }
-
- optional& operator=(nullopt_t) {
- reset();
- return *this;
- }
-
- optional& operator=(T value) {
- if (has_value_) {
- ::fit::internal::move_assign_or_reconstruct<T>::assign(
- &value_, std::move(value));
- } else {
- new (&value_) T(std::move(value));
- has_value_ = true;
- }
- return *this;
- }
-
- void reset() {
- if (has_value_) {
- value_.~T();
- has_value_ = false;
- }
- }
-
- void swap(optional& other) {
- if (&other == this)
- return;
- if (has_value_) {
- if (other.has_value_) {
- ::fit::internal::move_assign_or_reconstruct<T>::swap(
- value_, other.value_);
- } else {
- new (&other.value_) T(std::move(value_));
- other.has_value_ = true;
- value_.~T();
- has_value_ = false;
- }
- } else if (other.has_value_) {
- new (&value_) T(std::move(other.value_));
- has_value_ = true;
- other.value_.~T();
- other.has_value_ = false;
- }
- }
-
- template <typename... Args>
- T& emplace(Args&&... args) {
- reset();
- new (&value_) T(std::forward<Args...>(args)...);
- has_value_ = true;
- return value_;
- }
-
-private:
- bool has_value_;
- union {
- T value_;
- };
+ // String describing the reason for the bad access. Must point to a string
+ // with static storage duration.
+ const char* reason_;
};
+// A reasonably complete implementation of std::optional compatible with C++14.
+//
+// See also fit::nullable<T>, which may be more efficient in certain
+// circumstances when T can be initialized, assigned, and compared with nullptr.
+//
template <typename T>
-void swap(optional<T>& a, optional<T>& b) {
- a.swap(b);
+class optional : private ::fit::internal::modulate_copy_and_move<T> {
+ private:
+ // Helper types and values for SFINAE and noexcept rules.
+ static constexpr bool nothrow_move_constructible = std::is_nothrow_move_constructible<T>::value;
+
+ static constexpr bool nothrow_swappable = std::is_nothrow_move_constructible<T>::value &&
+ ::fit::internal::is_nothrow_swappable<T>::value;
+
+ static constexpr auto trivial_init_v = ::fit::internal::trivial_init_v;
+ static constexpr auto maybe_init_v = ::fit::internal::maybe_init_v;
+ using type_tag = ::fit::internal::type_tag<T>;
+
+ template <typename U, typename V>
+ using converts_from_optional = disjunction<
+ std::is_constructible<U, const optional<V>&>, std::is_constructible<U, optional<V>&>,
+ std::is_constructible<U, const optional<V>&&>, std::is_constructible<U, optional<V>&&>,
+ std::is_convertible<const optional<V>&, U>, std::is_convertible<optional<V>&, U>,
+ std::is_convertible<const optional<V>&&, U>, std::is_convertible<optional<V>&&, U>>;
+
+ template <typename U, typename V>
+ using assigns_from_optional =
+ disjunction<std::is_assignable<U&, const optional<V>&>, std::is_assignable<U&, optional<V>&>,
+ std::is_assignable<U&, const optional<V>&&>,
+ std::is_assignable<U&, optional<V>&&>>;
+
+ template <typename U>
+ using not_self_type = ::fit::internal::not_same_type<optional, U>;
+
+ template <typename U>
+ using not_in_place = ::fit::internal::not_same_type<in_place_t, U>;
+
+ template <typename... Conditions>
+ using requires_conditions = ::fit::internal::requires_conditions<Conditions...>;
+
+ template <typename... Conditions>
+ using assignment_requires_conditions =
+ ::fit::internal::assignment_requires_conditions<optional&, Conditions...>;
+
+ template <typename... Args>
+ using emplace_constructible = std::enable_if_t<std::is_constructible<T, Args...>::value, T&>;
+
+ [[noreturn]] static constexpr void throw_bad_optional_access(const char* reason) {
+#if __cpp_exceptions
+ throw bad_optional_access(reason);
+#else
+ (void)reason;
+ __builtin_abort();
+#endif
+ }
+
+ public:
+ using value_type = T;
+
+ // Default constructors.
+
+ constexpr optional() = default;
+
+ constexpr optional(nullopt_t) noexcept {}
+
+ // Copy/move constructors and assignment operators.
+
+ constexpr optional(const optional&) = default;
+ constexpr optional& operator=(const optional&) = default;
+
+ constexpr optional(optional&&) = default;
+ constexpr optional& operator=(optional&&) = default;
+
+ // Converting constructors.
+
+ template <typename U = T,
+ requires_conditions<not_self_type<U>, not_in_place<U>, std::is_constructible<T, U&&>,
+ std::is_convertible<U&&, T>> = true>
+ constexpr optional(U&& value) : storage_(type_tag{}, std::forward<U>(value)) {}
+
+ template <typename U = T,
+ requires_conditions<not_self_type<U>, not_in_place<U>, std::is_constructible<T, U&&>,
+ negation<std::is_convertible<U&&, T>>> = false>
+ explicit constexpr optional(U&& value) : storage_{type_tag{}, std::forward<U>(value)} {}
+
+ template <typename U,
+ requires_conditions<negation<std::is_same<T, U>>, std::is_constructible<T, const U&>,
+ std::is_convertible<const U&, T>,
+ negation<converts_from_optional<T, U>>> = true>
+ constexpr optional(const optional<U>& other) : storage_{maybe_init_v, other.storage_} {}
+
+ template <typename U,
+ requires_conditions<negation<std::is_same<T, U>>, std::is_constructible<T, const U&>,
+ negation<std::is_convertible<const U&, T>>,
+ negation<converts_from_optional<T, U>>> = false>
+ explicit constexpr optional(const optional<U>& other) : storage_{maybe_init_v, other.storage_} {}
+
+ template <typename U,
+ requires_conditions<negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,
+ std::is_convertible<U&&, T>,
+ negation<converts_from_optional<T, U>>> = true>
+ constexpr optional(optional<U>&& other) : storage_{maybe_init_v, std::move(other.storage_)} {}
+
+ template <typename U,
+ requires_conditions<negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,
+ negation<std::is_convertible<U&&, T>>,
+ negation<converts_from_optional<T, U>>> = false>
+ explicit constexpr optional(optional<U>&& other)
+ : storage_{maybe_init_v, std::move(other.storage_)} {}
+
+ template <typename... Args, requires_conditions<std::is_constructible<T, Args&&...>> = false>
+ explicit constexpr optional(in_place_t, Args&&... args)
+ : storage_(type_tag{}, std::forward<Args>(args)...) {}
+
+ template <
+ typename U, typename... Args,
+ requires_conditions<std::is_constructible<T, std::initializer_list<U>&, Args&&...>> = false>
+ explicit constexpr optional(in_place_t, std::initializer_list<U> init_list, Args&&... args)
+ : storage_(type_tag{}, init_list, std::forward<Args>(args)...) {}
+
+ // Destructor.
+
+ ~optional() = default;
+
+ // Checked accessors.
+
+ constexpr T& value() & {
+ if (has_value()) {
+ return storage_.get(type_tag{});
+ } else {
+ throw_bad_optional_access("Accessed value of empty optional!");
+ }
+ }
+ constexpr const T& value() const& {
+ if (has_value()) {
+ return storage_.get(type_tag{});
+ } else {
+ throw_bad_optional_access("Accessed value of empty optional!");
+ }
+ }
+ constexpr T&& value() && {
+ if (has_value()) {
+ return std::move(storage_.get(type_tag{}));
+ } else {
+ throw_bad_optional_access("Accessed value of empty optional!");
+ }
+ }
+ constexpr const T&& value() const&& {
+ if (has_value()) {
+ return std::move(storage_.get(type_tag{}));
+ } else {
+ throw_bad_optional_access("Accessed value of empty optional!");
+ }
+ }
+
+ template <typename U>
+ constexpr T value_or(U&& default_value) const& {
+ static_assert(std::is_copy_constructible<T>::value,
+ "value_or() requires copy-constructible value_type!");
+ static_assert(std::is_convertible<U&&, T>::value,
+ "Default value must be convertible to value_type!");
+
+ return has_value() ? storage_.get(type_tag{}) : static_cast<T>(std::forward<U>(default_value));
+ }
+ template <typename U>
+ constexpr T value_or(U&& default_value) && {
+ static_assert(std::is_move_constructible<T>::value,
+ "value_or() requires move-constructible value_type!");
+ static_assert(std::is_convertible<U&&, T>::value,
+ "Default value must be convertible to value_type!");
+
+ return has_value() ? std::move(storage_.get(type_tag{}))
+ : static_cast<T>(std::forward<U>(default_value));
+ }
+
+ // Unchecked accessors.
+
+ constexpr T* operator->() { return std::addressof(storage_.get(type_tag{})); }
+ constexpr const T* operator->() const { return std::addressof(storage_.get(type_tag{})); }
+
+ constexpr T& operator*() { return storage_.get(type_tag{}); }
+ constexpr const T& operator*() const { return storage_.get(type_tag{}); }
+
+ // Availability accessors/operators.
+
+ constexpr bool has_value() const { return !storage_.is_empty(); }
+ constexpr explicit operator bool() const { return has_value(); }
+
+ // Assignment operators.
+
+ template <typename U>
+ constexpr assignment_requires_conditions<
+ not_self_type<U>, negation<conjunction<std::is_scalar<T>, std::is_same<T, std::decay_t<U>>>>,
+ std::is_constructible<T, U>, std::is_assignable<T&, U>>
+ operator=(U&& value) {
+ if (has_value()) {
+ storage_.get(type_tag{}) = std::forward<U>(value);
+ } else {
+ storage_.construct(type_tag{}, std::forward<U>(value));
+ }
+ return *this;
+ }
+
+ template <typename U>
+ constexpr assignment_requires_conditions<
+ negation<std::is_same<T, U>>, std::is_constructible<T, const U&>, std::is_assignable<T&, U>,
+ negation<converts_from_optional<T, U>>, negation<assigns_from_optional<T, U>>>
+ operator=(const optional<U>& other) {
+ storage_.assign(other.storage_);
+ return *this;
+ }
+
+ template <typename U>
+ constexpr assignment_requires_conditions<
+ negation<std::is_same<T, U>>, std::is_constructible<T, U>, std::is_assignable<T&, U>,
+ negation<converts_from_optional<T, U>>, negation<assigns_from_optional<T, U>>>
+ operator=(optional<U>&& other) {
+ storage_.assign(std::move(other.storage_));
+ return *this;
+ }
+
+ constexpr optional& operator=(nullopt_t) {
+ storage_.reset();
+ return *this;
+ }
+
+ // Swap.
+
+ constexpr void swap(optional& other) noexcept(nothrow_swappable) {
+ storage_.swap(other.storage_);
+ }
+
+ // Emplacement.
+
+ template <typename... Args>
+ constexpr emplace_constructible<Args&&...> emplace(Args&&... args) {
+ storage_.reset();
+ storage_.construct(type_tag{}, std::forward<Args>(args)...);
+ return storage_.get(type_tag{});
+ }
+
+ template <typename U, typename... Args>
+ constexpr emplace_constructible<std::initializer_list<U>&, Args&&...> emplace(
+ std::initializer_list<U> init_list, Args&&... args) {
+ storage_.reset();
+ storage_.construct(type_tag{}, init_list, std::forward<Args>(args)...);
+ return storage_.get(type_tag{});
+ }
+
+ // Reset.
+
+ void reset() noexcept { storage_.reset(); }
+
+ private:
+ ::fit::internal::storage_type<T> storage_;
+};
+
+// Swap.
+template <typename T>
+inline std::enable_if_t<(std::is_move_constructible<T>::value &&
+ ::fit::internal::is_swappable<T>::value)>
+swap(optional<T>& a, optional<T>& b) noexcept(noexcept(a.swap(b))) {
+ a.swap(b);
+}
+template <typename T>
+inline std::enable_if_t<(!std::is_move_constructible<T>::value &&
+ ::fit::internal::is_swappable<T>::value)>
+swap(optional<T>& a, optional<T>& b) = delete;
+
+// Make optional.
+template <typename T>
+constexpr optional<std::decay_t<T>> make_optional(T&& value) {
+ return optional<std::decay_t<T>>{std::forward<T>(value)};
+}
+template <typename T, typename... Args>
+constexpr optional<T> make_optional(Args&&... args) {
+ return optional<T>{in_place, std::forward<Args>(args)...};
+}
+template <typename T, typename U, typename... Args>
+constexpr optional<T> make_optional(std::initializer_list<U> init_list, Args&&... args) {
+ return optional<T>{in_place, init_list, std::forward<Args>(args)...};
}
+// Empty.
template <typename T>
constexpr bool operator==(const optional<T>& lhs, nullopt_t) {
- return !lhs.has_value();
+ return !lhs.has_value();
}
template <typename T>
constexpr bool operator!=(const optional<T>& lhs, nullopt_t) {
- return lhs.has_value();
+ return lhs.has_value();
}
template <typename T>
constexpr bool operator==(nullopt_t, const optional<T>& rhs) {
- return !rhs.has_value();
+ return !rhs.has_value();
}
template <typename T>
constexpr bool operator!=(nullopt_t, const optional<T>& rhs) {
- return rhs.has_value();
+ return rhs.has_value();
}
-template <typename T, typename U>
+// Equal/not equal.
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() == std::declval<U>())> = true>
constexpr bool operator==(const optional<T>& lhs, const optional<U>& rhs) {
- return (lhs.has_value() == rhs.has_value()) && (!lhs.has_value() || *lhs == *rhs);
+ return (lhs.has_value() == rhs.has_value()) && (!lhs.has_value() || *lhs == *rhs);
}
-template <typename T, typename U>
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() != std::declval<U>())> = true>
constexpr bool operator!=(const optional<T>& lhs, const optional<U>& rhs) {
- return (lhs.has_value() != rhs.has_value()) || (lhs.has_value() && *lhs != *rhs);
+ return (lhs.has_value() != rhs.has_value()) || (lhs.has_value() && *lhs != *rhs);
}
-template <typename T, typename U>
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() == std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
constexpr bool operator==(const optional<T>& lhs, const U& rhs) {
- return lhs.has_value() && *lhs == rhs;
+ return lhs.has_value() && *lhs == rhs;
}
-template <typename T, typename U>
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() != std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
constexpr bool operator!=(const optional<T>& lhs, const U& rhs) {
- return !lhs.has_value() || *lhs != rhs;
+ return !lhs.has_value() || *lhs != rhs;
}
-template <typename T, typename U>
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() == std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
constexpr bool operator==(const T& lhs, const optional<U>& rhs) {
- return rhs.has_value() && lhs == *rhs;
+ return rhs.has_value() && lhs == *rhs;
}
-template <typename T, typename U>
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() != std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
constexpr bool operator!=(const T& lhs, const optional<U>& rhs) {
- return !rhs.has_value() || lhs != *rhs;
+ return !rhs.has_value() || lhs != *rhs;
}
-} // namespace fit
+// Less than/greater than.
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() < std::declval<U>())> = true>
+constexpr bool operator<(const optional<T>& lhs, const optional<U>& rhs) {
+ return rhs.has_value() && (!lhs.has_value() || *lhs < *rhs);
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() > std::declval<U>())> = true>
+constexpr bool operator>(const optional<T>& lhs, const optional<U>& rhs) {
+ return lhs.has_value() && (!rhs.has_value() || *lhs > *rhs);
+}
-#endif // LIB_FIT_OPTIONAL_H_
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() < std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
+constexpr bool operator<(const optional<T>& lhs, const U& rhs) {
+ return !lhs.has_value() || *lhs < rhs;
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() > std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
+constexpr bool operator>(const optional<T>& lhs, const U& rhs) {
+ return lhs.has_value() && *lhs > rhs;
+}
+
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() < std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
+constexpr bool operator<(const T& lhs, const optional<U>& rhs) {
+ return rhs.has_value() && lhs < *rhs;
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() > std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
+constexpr bool operator>(const T& lhs, const optional<U>& rhs) {
+ return !rhs.has_value() || lhs > *rhs;
+}
+
+// Less than or equal/greater than or equal.
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() <= std::declval<U>())> = true>
+constexpr bool operator<=(const optional<T>& lhs, const optional<U>& rhs) {
+ return !lhs.has_value() || (rhs.has_value() && *lhs <= *rhs);
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() >= std::declval<U>())> = true>
+constexpr bool operator>=(const optional<T>& lhs, const optional<U>& rhs) {
+ return !rhs.has_value() || (lhs.has_value() && *lhs >= *rhs);
+}
+
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() <= std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
+constexpr bool operator<=(const optional<T>& lhs, const U& rhs) {
+ return !lhs.has_value() || *lhs <= rhs;
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() >= std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, U>> = true>
+constexpr bool operator>=(const optional<T>& lhs, const U& rhs) {
+ return lhs.has_value() && *lhs >= rhs;
+}
+
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() <= std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
+constexpr bool operator<=(const T& lhs, const optional<U>& rhs) {
+ return rhs.has_value() && lhs <= *rhs;
+}
+template <typename T, typename U,
+ ::fit::internal::enable_relop_t<decltype(std::declval<T>() >= std::declval<U>()),
+ ::fit::internal::not_same_type<nullopt_t, T>> = true>
+constexpr bool operator>=(const T& lhs, const optional<U>& rhs) {
+ return !rhs.has_value() || lhs >= *rhs;
+}
+
+} // namespace fit
+
+#endif
+
+#endif // LIB_FIT_OPTIONAL_H_
diff --git a/pkg/fit/include/lib/fit/promise.h b/pkg/fit/include/lib/fit/promise.h
index ece9e75..0270909 100644
--- a/pkg/fit/include/lib/fit/promise.h
+++ b/pkg/fit/include/lib/fit/promise.h
@@ -26,6 +26,9 @@
// a variety of combinators such as |then()|.
//
// Use |fit::make_promise()| to create a promise.
+// Use |fit::make_ok_promise()| to create a promise that immediately returns a value.
+// Use |fit::make_error_promise()| to create a promise that immediately returns an error.
+// Use |fit::make_result_promise()| to create a promise that immediately returns a result.
// Use |fit::future| to more conveniently hold a promise or its result.
// Use |fit::pending_task| to wrap a promise as a pending task for execution.
// Use |fit::executor| to execute a pending task.
@@ -63,8 +66,12 @@
// fit::result<> when prior promise completes
// |wrap_with()|: applies a wrapper to the promise
// |box()|: wraps the promise's continuation into a |fit::function|
-// |fit::join_promises()|: await multiple promises, once they all complete
-// return a tuple of their results
+// |fit::join_promises()|: await multiple promises in an argument list,
+// once they all complete return a tuple of
+// their results
+// |fit::join_promise_vector()|: await multiple promises in a vector,
+// once they all complete return a vector
+// of their results
//
// You can also create your own custom combinators by crafting new
// types of continuations.
@@ -146,7 +153,7 @@
// complicated continuation types that are hard to describe, often consisting of
// nested templates and lambdas. These are referred to as "unboxed"
// promises. In contrast, "boxed" promises are parameterized by a
-// a |fit::function| that hides (or "erases") the type of the continuation
+// |fit::function| that hides (or "erases") the type of the continuation
// thereby yielding type that is easier to describe.
//
// You can recognize boxed and unboxed promises by their types.
@@ -175,20 +182,20 @@
// Do this: (chaining as a single expression performs at most one heap allocation)
//
// fit::promise<> f = fit::make_promise([] { ... });
-// .then([](fit::result<> result) { ... });
+// .then([](fit::result<>& result) { ... });
// .and_then([] { ... });
//
// Or this: (still only performs at most one heap allocation)
//
// auto f = fit::make_promise([] { ... });
-// auto g = f.then([](fit::result<> result) { ... });
+// auto g = f.then([](fit::result<>& result) { ... });
// auto h = g.and_then([] { ... });
// fit::promise<> boxed_h = h;
//
// But don't do this: (incurs up to three heap allocations due to eager boxing)
//
// fit::promise<> f = fit::make_promise([] { ... });
-// fit::promise<> g = f.then([](fit::result<> result) { ... });
+// fit::promise<> g = f.then([](fit::result<>& result) { ... });
// fit::promise<> h = g.and_then([] { ... });
//
// SINGLE OWNERSHIP MODEL
@@ -275,8 +282,10 @@
//
// EXAMPLE
//
-// - https://fuchsia.googlesource.com/zircon/+/master/system/utest/fit/examples/promise_example1.cpp
-// - https://fuchsia.googlesource.com/zircon/+/master/system/utest/fit/examples/promise_example2.cpp
+// -
+// https://fuchsia.googlesource.com/fuchsia/+/HEAD/zircon/system/utest/fit/examples/promise_example1.cc
+// -
+// https://fuchsia.googlesource.com/fuchsia/+/HEAD/zircon/system/utest/fit/examples/promise_example2.cc
//
template <typename V = void, typename E = void>
using promise = promise_impl<function<result<V, E>(fit::context&)>>;
@@ -285,499 +294,477 @@
// See |fit::promise| documentation for more information.
template <typename Continuation>
class promise_impl final {
- static_assert(
- ::fit::internal::is_continuation<Continuation>::value,
- "Continuation type is invalid. A continuation is a callable object "
- "with this signature: fit::result<V, E>(fit::context&).");
+ static_assert(::fit::internal::is_continuation<Continuation>::value,
+ "Continuation type is invalid. A continuation is a callable object "
+ "with this signature: fit::result<V, E>(fit::context&).");
- using state_type = nullable<Continuation>;
+ using state_type = nullable<Continuation>;
-public:
- // The type of callable object held by the promise.
- // Its signature is: result_type(fit::context&).
- using continuation_type = Continuation;
+ public:
+ // The type of callable object held by the promise.
+ // Its signature is: result_type(fit::context&).
+ using continuation_type = Continuation;
- // The promise's result type.
- // Equivalent to fit::result<value_type, error_type>.
- using result_type = typename ::fit::internal::continuation_traits<
- Continuation>::result_type;
+ // The promise's result type.
+ // Equivalent to fit::result<value_type, error_type>.
+ using result_type = typename ::fit::internal::continuation_traits<Continuation>::result_type;
- // The type of value produced when the promise completes successfully.
- // May be void.
- using value_type = typename result_type::value_type;
+ // The type of value produced when the promise completes successfully.
+ // May be void.
+ using value_type = typename result_type::value_type;
- // The type of value produced when the promise completes with an error.
- // May be void.
- using error_type = typename result_type::error_type;
+ // The type of value produced when the promise completes with an error.
+ // May be void.
+ using error_type = typename result_type::error_type;
- // Creates an empty promise without a continuation.
- // A continuation must be assigned before the promise can be used.
- promise_impl() = default;
- explicit promise_impl(decltype(nullptr)) {}
+ // Creates an empty promise without a continuation.
+ // A continuation must be assigned before the promise can be used.
+ promise_impl() = default;
+ explicit promise_impl(decltype(nullptr)) {}
- // Creates a promise with a continuation.
- // If |continuation| equals nullptr then the promise is empty.
- explicit promise_impl(continuation_type continuation)
- : state_(std::move(continuation)) {}
+ promise_impl(const promise_impl&) = delete;
+ promise_impl& operator=(const promise_impl&) = delete;
- // Converts from a promise holding a continuation that is assignable to
- // to this promise's continuation type.
- //
- // This is typically used to create a promise with a boxed continuation
- // type (such as |fit::function|) from an unboxed promise produced by
- // |fit::make_promise| or by combinators.
- //
- // EXAMPLE
- //
- // // f is a promise_impl with a complicated unboxed type
- // auto f = fit::make_promise([] { ... });
- //
- // // g wraps f's continuation
- // fit::promise<> g = std::move(f);
- //
- template <typename OtherContinuation,
- typename = std::enable_if_t<
- std::is_constructible<continuation_type,
- OtherContinuation&&>::value>>
- promise_impl(promise_impl<OtherContinuation> other)
- : state_(other.state_.has_value()
- ? state_type(continuation_type(std::move(*other.state_)))
- : state_type()) {}
+ // Constructs the promise by taking the continuation from another promise,
+ // leaving the other promise empty.
+ promise_impl(promise_impl&& other) : state_{std::move(other.state_)} { other.state_.reset(); }
- // Creates a promise by taking the continuation from another promise,
- // leaving the other promise empty.
- promise_impl(promise_impl&& other) = default;
-
- // Destroys the promise, releasing its continuation.
- ~promise_impl() = default;
-
- // Returns true if the promise is non-empty (has a valid continuation).
- explicit operator bool() const { return state_.has_value(); }
-
- // Invokes the promise's continuation.
- //
- // This method should be called by an executor to evaluate the promise.
- // If the result's state is |result_state::pending| then the executor
- // is responsible for arranging to invoke the promise's continuation
- // again once it determines that it is possible to make progress
- // towards completion of the promise encapsulated within the promise.
- //
- // Once the continuation returns a result with status |result_state::ok|
- // or |result_state::error|, the promise is assigned an empty continuation.
- //
- // Asserts that the promise is non-empty.
- result_type operator()(context& context) {
- assert(state_.has_value());
- result_type result = (*state_)(context);
- if (!result.is_pending())
- state_.reset();
- return result;
+ // Assigns the promise by taking the continuation from another promise,
+ // leaving the other promise empty.
+ promise_impl& operator=(promise_impl&& other) {
+ if (this != &other) {
+ state_ = std::move(other.state_);
+ other.state_.reset();
}
+ return *this;
+ }
- // Takes the promise's continuation, leaving it in an empty state.
- // Asserts that the promise is non-empty.
- continuation_type take_continuation() {
- assert(state_.has_value());
- auto continuation = std::move(state_.value());
- state_.reset();
- return continuation;
- }
+ // Creates a promise with a continuation.
+ // If |continuation| equals nullptr then the promise is empty.
+ explicit promise_impl(continuation_type continuation) : state_(std::move(continuation)) {}
- // Assigns the promise by taking the continuation from another promise,
- // leaving the other promise empty.
- promise_impl& operator=(promise_impl&& other) = default;
+ // Converts from a promise holding a continuation that is assignable to
+ // to this promise's continuation type.
+ //
+ // This is typically used to create a promise with a boxed continuation
+ // type (such as |fit::function|) from an unboxed promise produced by
+ // |fit::make_promise| or by combinators.
+ //
+ // EXAMPLE
+ //
+ // // f is a promise_impl with a complicated unboxed type
+ // auto f = fit::make_promise([] { ... });
+ //
+ // // g wraps f's continuation
+ // fit::promise<> g = std::move(f);
+ //
+ template <
+ typename OtherContinuation,
+ std::enable_if_t<!std::is_same<continuation_type, OtherContinuation>::value &&
+ std::is_constructible<continuation_type, OtherContinuation&&>::value,
+ bool> = true>
+ promise_impl(promise_impl<OtherContinuation> other)
+ : state_(other.state_.has_value() ? state_type(continuation_type(std::move(*other.state_)))
+ : state_type()) {}
- // Discards the promise's continuation, leaving it empty.
- promise_impl& operator=(decltype(nullptr)) {
- state_.reset();
- return *this;
- }
+ // Destroys the promise, releasing its continuation.
+ ~promise_impl() = default;
- // Assigns the promise's continuation.
- promise_impl& operator=(continuation_type continuation) {
- state_ = std::move(continuation);
- return *this;
- }
+ // Returns true if the promise is non-empty (has a valid continuation).
+ explicit operator bool() const { return state_.has_value(); }
- // Swaps the promises' continuations.
- void swap(promise_impl& other) {
- using std::swap;
- swap(state_, other.state_);
- }
+ // Invokes the promise's continuation.
+ //
+ // This method should be called by an executor to evaluate the promise.
+ // If the result's state is |result_state::pending| then the executor
+ // is responsible for arranging to invoke the promise's continuation
+ // again once it determines that it is possible to make progress
+ // towards completion of the promise encapsulated within the promise.
+ //
+ // Once the continuation returns a result with status |result_state::ok|
+ // or |result_state::error|, the promise is assigned an empty continuation.
+ //
+ // Asserts that the promise is non-empty.
+ result_type operator()(context& context) {
+ result_type result = (state_.value())(context);
+ if (!result.is_pending())
+ state_.reset();
+ return result;
+ }
- // Returns an unboxed promise which invokes the specified handler
- // function after this promise completes (successfully or unsuccessfully),
- // passing its result.
- //
- // The received result's state is guaranteed to be either
- // |fit::result_state::ok| or |fit::result_state::error|, never
- // |fit::result_state::pending|.
- //
- // |handler| is a callable object (such as a lambda) which consumes the
- // result of this promise and returns a new result with any value type
- // and error type. Must not be null.
- //
- // The handler must return one of the following types:
- // - void
- // - fit::result<new_value_type, new_error_type>
- // - fit::ok<new_value_type>
- // - fit::error<new_error_type>
- // - fit::pending
- // - fit::promise<new_value_type, new_error_type>
- // - any callable or unboxed promise with the following signature:
- // fit::result<new_value_type, new_error_type>(fit::context&)
- //
- // The handler must accept one of the following argument lists:
- // - (result_type)
- // - (result_type&)
- // - (const result_type&)
- // - (fit::context&, result_type)
- // - (fit::context&, result_type&)
- // - (fit::context&, const result_type&)
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // auto f = fit::make_promise(...)
- // .then([] (fit::result<int, std::string> result)
- // -> fit::result<std::string, void> {
- // if (result.is_ok()) {
- // printf("received value: %d\n", result.value());
- // if (result.value() % 15 == 0)
- // return ::fit::ok("fizzbuzz");
- // if (result.value() % 3 == 0)
- // return ::fit::ok("fizz");
- // if (result.value() % 5 == 0)
- // return ::fit::ok("buzz");
- // return ::fit::ok(std::to_string(result.value()));
- // } else {
- // printf("received error: %s\n", result.error().c_str());
- // return ::fit::error();
- // }
- // })
- // .then(...);
- //
- template <typename ResultHandler>
- promise_impl<::fit::internal::then_continuation<promise_impl, ResultHandler>>
- then(ResultHandler handler) {
- static_assert(is_callable<ResultHandler>::value,
- "ResultHandler must be a callable object.");
+ // Takes the promise's continuation, leaving it in an empty state.
+ // Asserts that the promise is non-empty.
+ continuation_type take_continuation() {
+ auto continuation = std::move(state_.value());
+ state_.reset();
+ return continuation;
+ }
- assert(!is_null(handler));
- assert(state_.has_value());
- return make_promise_with_continuation(
- ::fit::internal::then_continuation<promise_impl, ResultHandler>(
- std::move(*this), std::move(handler)));
- }
+ // Discards the promise's continuation, leaving it empty.
+ promise_impl& operator=(decltype(nullptr)) {
+ state_.reset();
+ return *this;
+ }
- // Returns an unboxed promise which invokes the specified handler
- // function after this promise completes successfully, passing its
- // resulting value.
- //
- // |handler| is a callable object (such as a lambda) which consumes the
- // result of this promise and returns a new result with any value type
- // but the same error type. Must not be null.
- //
- // The handler must return one of the following types:
- // - void
- // - fit::result<new_value_type, error_type>
- // - fit::ok<new_value_type>
- // - fit::error<error_type>
- // - fit::pending
- // - fit::promise<new_value_type, error_type>
- // - any callable or unboxed promise with the following signature:
- // fit::result<new_value_type, error_type>(fit::context&)
- //
- // The handler must accept one of the following argument lists:
- // - (value_type)
- // - (value_type&)
- // - (const value_type&)
- // - (fit::context&, value_type)
- // - (fit::context&, value_type&)
- // - (fit::context&, const value_type&)
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // auto f = fit::make_promise(...)
- // .and_then([] (int value) {
- // printf("received value: %d\n", value);
- // if (value % 15 == 0)
- // return ::fit::ok("fizzbuzz");
- // if (value % 3 == 0)
- // return ::fit::ok("fizz");
- // if (value % 5 == 0)
- // return ::fit::ok("buzz");
- // return ::fit::ok(std::to_string(value));
- // })
- // .then(...);
- //
- template <typename ValueHandler>
- promise_impl<::fit::internal::and_then_continuation<promise_impl, ValueHandler>>
- and_then(ValueHandler handler) {
- static_assert(is_callable<ValueHandler>::value,
- "ValueHandler must be a callable object.");
+ // Assigns the promise's continuation.
+ promise_impl& operator=(continuation_type continuation) {
+ state_ = std::move(continuation);
+ return *this;
+ }
- assert(!is_null(handler));
- assert(state_.has_value());
- return make_promise_with_continuation(
- ::fit::internal::and_then_continuation<promise_impl, ValueHandler>(
- std::move(*this), std::move(handler)));
- }
+ // Swaps the promises' continuations.
+ void swap(promise_impl& other) {
+ using std::swap;
+ swap(state_, other.state_);
+ }
- // Returns an unboxed promise which invokes the specified handler
- // function after this promise completes with an error, passing its
- // resulting error.
- //
- // |handler| is a callable object (such as a lambda) which consumes the
- // result of this promise and returns a new result with any error type
- // but the same value type. Must not be null.
- //
- // The handler must return one of the following types:
- // - void
- // - fit::result<value_type, new_error_type>
- // - fit::ok<value_type>
- // - fit::error<new_error_type>
- // - fit::pending
- // - fit::promise<value_type, new_error_type>
- // - any callable or unboxed promise with the following signature:
- // fit::result<value_type, new_error_type>(fit::context&)
- //
- // The handler must accept one of the following argument lists:
- // - (error_type)
- // - (error_type&)
- // - (const error_type&)
- // - (fit::context&, error_type)
- // - (fit::context&, error_type&)
- // - (fit::context&, const error_type&)
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // auto f = fit::make_promise(...)
- // .or_else([] (std::string error) {
- // printf("received error: %s\n", error.c_str());
- // return ::fit::error();
- // })
- // .then(...);
- //
- template <typename ErrorHandler>
- promise_impl<::fit::internal::or_else_continuation<promise_impl, ErrorHandler>>
- or_else(ErrorHandler handler) {
- static_assert(is_callable<ErrorHandler>::value,
- "ErrorHandler must be a callable object.");
+ // Returns an unboxed promise which invokes the specified handler
+ // function after this promise completes (successfully or unsuccessfully),
+ // passing its result.
+ //
+ // The received result's state is guaranteed to be either
+ // |fit::result_state::ok| or |fit::result_state::error|, never
+ // |fit::result_state::pending|.
+ //
+ // |handler| is a callable object (such as a lambda) which consumes the
+ // result of this promise and returns a new result with any value type
+ // and error type. Must not be null.
+ //
+ // The handler must return one of the following types:
+ // - void
+ // - fit::result<new_value_type, new_error_type>
+ // - fit::ok<new_value_type>
+ // - fit::error<new_error_type>
+ // - fit::pending
+ // - fit::promise<new_value_type, new_error_type>
+ // - any callable or unboxed promise with the following signature:
+ // fit::result<new_value_type, new_error_type>(fit::context&)
+ //
+ // The handler must accept one of the following argument lists:
+ // - (result_type&)
+ // - (const result_type&)
+ // - (fit::context&, result_type&)
+ // - (fit::context&, const result_type&)
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // auto f = fit::make_promise(...)
+ // .then([] (fit::result<int, std::string>& result)
+ // -> fit::result<std::string, void> {
+ // if (result.is_ok()) {
+ // printf("received value: %d\n", result.value());
+ // if (result.value() % 15 == 0)
+ // return ::fit::ok("fizzbuzz");
+ // if (result.value() % 3 == 0)
+ // return ::fit::ok("fizz");
+ // if (result.value() % 5 == 0)
+ // return ::fit::ok("buzz");
+ // return ::fit::ok(std::to_string(result.value()));
+ // } else {
+ // printf("received error: %s\n", result.error().c_str());
+ // return ::fit::error();
+ // }
+ // })
+ // .then(...);
+ //
+ template <typename ResultHandler>
+ promise_impl<::fit::internal::then_continuation<promise_impl, ResultHandler>> then(
+ ResultHandler handler) {
+ static_assert(is_callable<ResultHandler>::value, "ResultHandler must be a callable object.");
- assert(!is_null(handler));
- assert(state_.has_value());
- return make_promise_with_continuation(
- ::fit::internal::or_else_continuation<promise_impl, ErrorHandler>(
- std::move(*this), std::move(handler)));
- }
+ assert(!is_null(handler));
+ assert(state_.has_value());
+ return make_promise_with_continuation(
+ ::fit::internal::then_continuation<promise_impl, ResultHandler>(std::move(*this),
+ std::move(handler)));
+ }
- // Returns an unboxed promise which invokes the specified handler
- // function after this promise completes (successfully or unsuccessfully),
- // passing it the promise's result then delivering the result onwards
- // to the next promise once the handler returns.
- //
- // The handler receive a copy, const reference, or non-const reference
- // depending on the signature of the handler's last argument.
- //
- // - Copies and const references are especially useful for inspecting a
- // result mid-stream without modification, such as printing it for
- // debugging.
- // - Non-const references are especially useful for synchronously
- // modifying a result mid-stream, such as clamping its bounds or
- // injecting a default value.
- //
- // |handler| is a callable object (such as a lambda) which can examine
- // or modify the incoming result. Unlike |then()|, the handler does
- // not need to propagate the result onwards. Must not be null.
- //
- // The handler must return one of the following types:
- // - void
- //
- // The handler must accept one of the following argument lists:
- // - (result_type)
- // - (result_type&)
- // - (const result_type&)
- // - (fit::context&, result_type)
- // - (fit::context&, result_type&)
- // - (fit::context&, const result_type&)
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // auto f = fit::make_promise(...)
- // .inspect([] (const fit::result<int, std::string>& result) {
- // if (result.is_ok())
- // printf("received value: %d\n", result.value());
- // else
- // printf("received error: %s\n", result.error().c_str());
- // })
- // .then(...);
- //
- template <typename InspectHandler>
- promise_impl<::fit::internal::inspect_continuation<promise_impl, InspectHandler>>
- inspect(InspectHandler handler) {
- static_assert(is_callable<InspectHandler>::value,
- "InspectHandler must be a callable object.");
- static_assert(std::is_void<typename callable_traits<
- InspectHandler>::return_type>::value,
- "InspectHandler must return void.");
+ // Returns an unboxed promise which invokes the specified handler
+ // function after this promise completes successfully, passing its
+ // resulting value.
+ //
+ // |handler| is a callable object (such as a lambda) which consumes the
+ // result of this promise and returns a new result with any value type
+ // but the same error type. Must not be null.
+ //
+ // The handler must return one of the following types:
+ // - void
+ // - fit::result<new_value_type, error_type>
+ // - fit::ok<new_value_type>
+ // - fit::error<error_type>
+ // - fit::pending
+ // - fit::promise<new_value_type, error_type>
+ // - any callable or unboxed promise with the following signature:
+ // fit::result<new_value_type, error_type>(fit::context&)
+ //
+ // The handler must accept one of the following argument lists:
+ // - (value_type&)
+ // - (const value_type&)
+ // - (fit::context&, value_type&)
+ // - (fit::context&, const value_type&)
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // auto f = fit::make_promise(...)
+ // .and_then([] (const int& value) {
+ // printf("received value: %d\n", value);
+ // if (value % 15 == 0)
+ // return ::fit::ok("fizzbuzz");
+ // if (value % 3 == 0)
+ // return ::fit::ok("fizz");
+ // if (value % 5 == 0)
+ // return ::fit::ok("buzz");
+ // return ::fit::ok(std::to_string(value));
+ // })
+ // .then(...);
+ //
+ template <typename ValueHandler>
+ promise_impl<::fit::internal::and_then_continuation<promise_impl, ValueHandler>> and_then(
+ ValueHandler handler) {
+ static_assert(is_callable<ValueHandler>::value, "ValueHandler must be a callable object.");
- assert(!is_null(handler));
- assert(state_.has_value());
- return make_promise_with_continuation(
- ::fit::internal::inspect_continuation<promise_impl, InspectHandler>(
- std::move(*this), std::move(handler)));
- }
+ assert(!is_null(handler));
+ assert(state_.has_value());
+ return make_promise_with_continuation(
+ ::fit::internal::and_then_continuation<promise_impl, ValueHandler>(std::move(*this),
+ std::move(handler)));
+ }
- // Returns an unboxed promise which discards the result of this promise
- // once it completes, thereby always producing a successful result of
- // type fit::result<void, void> regardless of whether this promise
- // succeeded or failed.
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // auto f = fit::make_promise(...)
- // .discard_result()
- // .then(...);
- //
- promise_impl<::fit::internal::discard_result_continuation<promise_impl>>
- discard_result() {
- assert(state_.has_value());
- return make_promise_with_continuation(
- ::fit::internal::discard_result_continuation<promise_impl>(
- std::move(*this)));
- }
+ // Returns an unboxed promise which invokes the specified handler
+ // function after this promise completes with an error, passing its
+ // resulting error.
+ //
+ // |handler| is a callable object (such as a lambda) which consumes the
+ // result of this promise and returns a new result with any error type
+ // but the same value type. Must not be null.
+ //
+ // The handler must return one of the following types:
+ // - void
+ // - fit::result<value_type, new_error_type>
+ // - fit::ok<value_type>
+ // - fit::error<new_error_type>
+ // - fit::pending
+ // - fit::promise<value_type, new_error_type>
+ // - any callable or unboxed promise with the following signature:
+ // fit::result<value_type, new_error_type>(fit::context&)
+ //
+ // The handler must accept one of the following argument lists:
+ // - (error_type&)
+ // - (const error_type&)
+ // - (fit::context&, error_type&)
+ // - (fit::context&, const error_type&)
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // auto f = fit::make_promise(...)
+ // .or_else([] (const std::string& error) {
+ // printf("received error: %s\n", error.c_str());
+ // return ::fit::error();
+ // })
+ // .then(...);
+ //
+ template <typename ErrorHandler>
+ promise_impl<::fit::internal::or_else_continuation<promise_impl, ErrorHandler>> or_else(
+ ErrorHandler handler) {
+ static_assert(is_callable<ErrorHandler>::value, "ErrorHandler must be a callable object.");
- // Applies a |wrapper| to the promise. Invokes the wrapper's |wrap()|
- // method, passes the promise to the wrapper by value followed by any
- // additional |args| passed to |wrap_with()|, then returns the wrapper's
- // result.
- //
- // |Wrapper| is a type that implements a method called |wrap()| which
- // accepts a promise as its argument and produces a wrapped result of
- // any type, such as another promise.
- //
- // Asserts that the promise is non-empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // In this example, |fit::sequencer| is a wrapper type that imposes
- // FIFO execution order onto a sequence of wrapped promises.
- //
- // // This wrapper type is intended to be applied to
- // // a sequence of promises so we store it in a variable.
- // fit::sequencer seq;
- //
- // // This task consists of some amount of work that must be
- // // completed sequentially followed by other work that can
- // // happen in any order. We use |wrap_with()| to wrap the
- // // sequential work with the sequencer.
- // fit::promise<> perform_complex_task() {
- // return fit::make_promise([] { /* do sequential work */ })
- // .then([] (fit::result<> result) { /* this will also be wrapped */ })
- // .wrap_with(seq)
- // .then([] (fit::result<> result) { /* do more work */ });
- // }
- //
- // This example can also be written without using |wrap_with()|.
- // The behavior is equivalent but the syntax may seem more awkward.
- //
- // fit::sequencer seq;
- //
- // promise<> perform_complex_task() {
- // return seq.wrap(
- // fit::make_promise([] { /* sequential work */ })
- // ).then([] (fit::result<> result) { /* more work */ });
- // }
- //
- template <typename Wrapper, typename... Args>
- decltype(auto) wrap_with(Wrapper& wrapper, Args... args) {
- assert(state_.has_value());
- return wrapper.wrap(std::move(*this),
- std::forward<Args>(args)...);
- }
+ assert(!is_null(handler));
+ assert(state_.has_value());
+ return make_promise_with_continuation(
+ ::fit::internal::or_else_continuation<promise_impl, ErrorHandler>(std::move(*this),
+ std::move(handler)));
+ }
- // Wraps the promise's continuation into a |fit::function|.
- //
- // A boxed promise is easier to store and pass around than the unboxed
- // promises produced by |fit::make_promise()| and combinators, though boxing
- // may incur a heap allocation.
- //
- // It is a good idea to defer boxing the promise until after all
- // desired combinators have been applied to prevent unnecessary heap
- // allocation during intermediate states of the promise's construction.
- //
- // Returns an empty promise if this promise is empty.
- // This method consumes the promise's continuation, leaving it empty.
- //
- // EXAMPLE
- //
- // // f's is a fit::promise_impl<> whose continuation contains an
- // // anonymous type (the lambda)
- // auto f = fit::make_promise([] {});
- //
- // // g's type will be fit::promise<> due to boxing
- // auto boxed_f = f.box();
- //
- // // alternately, we can get exactly the same effect by assigning
- // // the unboxed promise to a variable of a named type instead of
- // // calling box()
- // fit::promise<> boxed_f = std::move(f);
- //
- promise_impl<function<result_type(context&)>> box() {
- return std::move(*this);
- }
+ // Returns an unboxed promise which invokes the specified handler
+ // function after this promise completes (successfully or unsuccessfully),
+ // passing it the promise's result then delivering the result onwards
+ // to the next promise once the handler returns.
+ //
+ // The handler receives a const reference, or non-const reference
+ // depending on the signature of the handler's last argument.
+ //
+ // - Const references are especially useful for inspecting a
+ // result mid-stream without modification, such as printing it for
+ // debugging.
+ // - Non-const references are especially useful for synchronously
+ // modifying a result mid-stream, such as clamping its bounds or
+ // injecting a default value.
+ //
+ // |handler| is a callable object (such as a lambda) which can examine
+ // or modify the incoming result. Unlike |then()|, the handler does
+ // not need to propagate the result onwards. Must not be null.
+ //
+ // The handler must return one of the following types:
+ // - void
+ //
+ // The handler must accept one of the following argument lists:
+ // - (result_type&)
+ // - (const result_type&)
+ // - (fit::context&, result_type&)
+ // - (fit::context&, const result_type&)
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // auto f = fit::make_promise(...)
+ // .inspect([] (const fit::result<int, std::string>& result) {
+ // if (result.is_ok())
+ // printf("received value: %d\n", result.value());
+ // else
+ // printf("received error: %s\n", result.error().c_str());
+ // })
+ // .then(...);
+ //
+ template <typename InspectHandler>
+ promise_impl<::fit::internal::inspect_continuation<promise_impl, InspectHandler>> inspect(
+ InspectHandler handler) {
+ static_assert(is_callable<InspectHandler>::value, "InspectHandler must be a callable object.");
+ static_assert(std::is_void<typename callable_traits<InspectHandler>::return_type>::value,
+ "InspectHandler must return void.");
- promise_impl(const promise_impl&) = delete;
- promise_impl& operator=(const promise_impl&) = delete;
+ assert(!is_null(handler));
+ assert(state_.has_value());
+ return make_promise_with_continuation(
+ ::fit::internal::inspect_continuation<promise_impl, InspectHandler>(std::move(*this),
+ std::move(handler)));
+ }
-private:
- template <typename>
- friend class promise_impl;
+ // Returns an unboxed promise which discards the result of this promise
+ // once it completes, thereby always producing a successful result of
+ // type fit::result<void, void> regardless of whether this promise
+ // succeeded or failed.
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // auto f = fit::make_promise(...)
+ // .discard_result()
+ // .then(...);
+ //
+ promise_impl<::fit::internal::discard_result_continuation<promise_impl>> discard_result() {
+ assert(state_.has_value());
+ return make_promise_with_continuation(
+ ::fit::internal::discard_result_continuation<promise_impl>(std::move(*this)));
+ }
- state_type state_;
+ // Applies a |wrapper| to the promise. Invokes the wrapper's |wrap()|
+ // method, passes the promise to the wrapper by value followed by any
+ // additional |args| passed to |wrap_with()|, then returns the wrapper's
+ // result.
+ //
+ // |Wrapper| is a type that implements a method called |wrap()| which
+ // accepts a promise as its argument and produces a wrapped result of
+ // any type, such as another promise.
+ //
+ // Asserts that the promise is non-empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // In this example, |fit::sequencer| is a wrapper type that imposes
+ // FIFO execution order onto a sequence of wrapped promises.
+ //
+ // // This wrapper type is intended to be applied to
+ // // a sequence of promises so we store it in a variable.
+ // fit::sequencer seq;
+ //
+ // // This task consists of some amount of work that must be
+ // // completed sequentially followed by other work that can
+ // // happen in any order. We use |wrap_with()| to wrap the
+ // // sequential work with the sequencer.
+ // fit::promise<> perform_complex_task() {
+ // return fit::make_promise([] { /* do sequential work */ })
+ // .then([] (fit::result<> result) { /* this will also be wrapped */ })
+ // .wrap_with(seq)
+ // .then([] (fit::result<> result) { /* do more work */ });
+ // }
+ //
+ // This example can also be written without using |wrap_with()|.
+ // The behavior is equivalent but the syntax may seem more awkward.
+ //
+ // fit::sequencer seq;
+ //
+ // promise<> perform_complex_task() {
+ // return seq.wrap(
+ // fit::make_promise([] { /* sequential work */ })
+ // ).then([] (fit::result<> result) { /* more work */ });
+ // }
+ //
+ template <typename Wrapper, typename... Args>
+ decltype(auto) wrap_with(Wrapper& wrapper, Args... args) {
+ assert(state_.has_value());
+ return wrapper.wrap(std::move(*this), std::forward<Args>(args)...);
+ }
+
+ // Wraps the promise's continuation into a |fit::function|.
+ //
+ // A boxed promise is easier to store and pass around than the unboxed
+ // promises produced by |fit::make_promise()| and combinators, though boxing
+ // may incur a heap allocation.
+ //
+ // It is a good idea to defer boxing the promise until after all
+ // desired combinators have been applied to prevent unnecessary heap
+ // allocation during intermediate states of the promise's construction.
+ //
+ // Returns an empty promise if this promise is empty.
+ // This method consumes the promise's continuation, leaving it empty.
+ //
+ // EXAMPLE
+ //
+ // // f's is a fit::promise_impl<> whose continuation contains an
+ // // anonymous type (the lambda)
+ // auto f = fit::make_promise([] {});
+ //
+ // // g's type will be fit::promise<> due to boxing
+ // auto boxed_f = f.box();
+ //
+ // // alternately, we can get exactly the same effect by assigning
+ // // the unboxed promise to a variable of a named type instead of
+ // // calling box()
+ // fit::promise<> boxed_f = std::move(f);
+ //
+ promise_impl<function<result_type(context&)>> box() { return std::move(*this); }
+
+ private:
+ template <typename>
+ friend class promise_impl;
+
+ state_type state_;
};
template <typename Continuation>
-void swap(promise_impl<Continuation>& a,
- promise_impl<Continuation>& b) {
- a.swap(b);
+void swap(promise_impl<Continuation>& a, promise_impl<Continuation>& b) {
+ a.swap(b);
}
template <typename Continuation>
-bool operator==(const promise_impl<Continuation>& f,
- decltype(nullptr)) {
- return !f;
+bool operator==(const promise_impl<Continuation>& f, decltype(nullptr)) {
+ return !f;
}
template <typename Continuation>
-bool operator==(decltype(nullptr),
- const promise_impl<Continuation>& f) {
- return !f;
+bool operator==(decltype(nullptr), const promise_impl<Continuation>& f) {
+ return !f;
}
template <typename Continuation>
-bool operator!=(const promise_impl<Continuation>& f,
- decltype(nullptr)) {
- return !!f;
+bool operator!=(const promise_impl<Continuation>& f, decltype(nullptr)) {
+ return !!f;
}
template <typename Continuation>
-bool operator!=(decltype(nullptr),
- const promise_impl<Continuation>& f) {
- return !!f;
+bool operator!=(decltype(nullptr), const promise_impl<Continuation>& f) {
+ return !!f;
}
// Makes a promise containing the specified continuation.
@@ -790,9 +777,8 @@
// |Continuation| is a callable object with the signature
// fit::result<V, E>(fit::context&).
template <typename Continuation>
-inline promise_impl<Continuation> make_promise_with_continuation(
- Continuation continuation) {
- return promise_impl<Continuation>(std::move(continuation));
+inline promise_impl<Continuation> make_promise_with_continuation(Continuation continuation) {
+ return promise_impl<Continuation>(std::move(continuation));
}
// Returns an unboxed promise that wraps the specified handler.
@@ -831,7 +817,7 @@
// }
//
// fit::promise<weather_type, std::string> wait_for_good_weather(int max_days) {
-// return fit::make_promise([days_left = max_days] (fit::context context&) mutable
+// return fit::make_promise([days_left = max_days] (fit::context& context) mutable
// -> fit::result<int, std::string> {
// weather_type weather = look_outside();
// if (weather == weather_type::sunny || weather == weather_type::glorious)
@@ -846,19 +832,86 @@
// }
//
// auto f = wait_for_good_weather(7)
-// .and_then([] (weather_type weather) { ... })
-// .or_else([] (std::string error) { ... });
+// .and_then([] (const weather_type& weather) { ... })
+// .or_else([] (const std::string& error) { ... });
//
template <typename PromiseHandler>
-inline promise_impl<::fit::internal::context_handler_invoker<PromiseHandler>>
-make_promise(PromiseHandler handler) {
- static_assert(is_callable<PromiseHandler>::value,
- "PromiseHandler must be a callable object.");
+inline promise_impl<::fit::internal::context_handler_invoker<PromiseHandler>> make_promise(
+ PromiseHandler handler) {
+ static_assert(is_callable<PromiseHandler>::value, "PromiseHandler must be a callable object.");
- assert(!is_null(handler));
- return make_promise_with_continuation(
- ::fit::internal::promise_continuation<PromiseHandler>(
- std::move(handler)));
+ assert(!is_null(handler));
+ return make_promise_with_continuation(
+ ::fit::internal::promise_continuation<PromiseHandler>(std::move(handler)));
+}
+
+// Returns an unboxed promise that immediately returns the specified result when invoked.
+//
+// This function is especially useful for returning promises from functions
+// that have multiple branches some of which complete synchronously.
+//
+// |result| is the result for the promise to return.
+//
+// See documentation of |fit::promise| for more information.
+template <typename V = void, typename E = void>
+inline promise_impl<::fit::internal::result_continuation<V, E>> make_result_promise(
+ fit::result<V, E> result) {
+ return make_promise_with_continuation(
+ ::fit::internal::result_continuation<V, E>(std::move(result)));
+}
+template <typename V = void, typename E = void>
+inline promise_impl<::fit::internal::result_continuation<V, E>> make_result_promise(
+ fit::ok_result<V> result) {
+ return make_promise_with_continuation(
+ ::fit::internal::result_continuation<V, E>(std::move(result)));
+}
+template <typename V = void, typename E = void>
+inline promise_impl<::fit::internal::result_continuation<V, E>> make_result_promise(
+ fit::error_result<E> result) {
+ return make_promise_with_continuation(
+ ::fit::internal::result_continuation<V, E>(std::move(result)));
+}
+template <typename V = void, typename E = void>
+inline promise_impl<::fit::internal::result_continuation<V, E>> make_result_promise(
+ fit::pending_result result) {
+ return make_promise_with_continuation(
+ ::fit::internal::result_continuation<V, E>(std::move(result)));
+}
+
+// Returns an unboxed promise that immediately returns the specified value when invoked.
+//
+// This function is especially useful for returning promises from functions
+// that have multiple branches some of which complete synchronously.
+//
+// |value| is the value for the promise to return.
+//
+// See documentation of |fit::promise| for more information.
+template <typename V>
+inline promise_impl<::fit::internal::result_continuation<V, void>> make_ok_promise(V value) {
+ return make_result_promise(fit::ok(std::move(value)));
+}
+
+// Overload of |make_ok_promise()| used when the value type is void.
+inline promise_impl<::fit::internal::result_continuation<void, void>> make_ok_promise() {
+ return make_result_promise(fit::ok());
+}
+
+// Returns an unboxed promise that immediately returns the specified error when invoked.
+//
+// This function is especially useful for returning promises from functions
+// that have multiple branches some of which complete synchronously.
+//
+// |error| is the error for the promise to return.
+//
+// See documentation of |fit::promise| for more information.
+template <typename E>
+inline promise_impl<::fit::internal::result_continuation<void, E>> make_error_promise(E error) {
+ return make_result_promise(fit::error(std::move(error)));
+}
+
+// Overload of |make_error_promise()| used when the error type is void.
+inline promise_impl<::fit::internal::result_continuation<void, void>> make_error_promise() {
+ return make_result_promise(fit::error());
}
// Jointly evaluates zero or more promises.
@@ -875,31 +928,58 @@
// auto f = get_random_number();
// auto g = get_random_number();
// return fit::join_promises(std::move(f), std::move(g))
-// .and_then([] (std::tuple<fit::result<int>, fit::result<int>> results) {
+// .and_then([] (std::tuple<fit::result<int>, fit::result<int>>& results) {
// return fit::ok(results.get<0>.value() + results.get<1>.value());
// });
// }
//
template <typename... Promises>
-inline promise_impl<::fit::internal::join_continuation<Promises...>>
-join_promises(Promises... promises) {
- return make_promise_with_continuation(
- ::fit::internal::join_continuation<Promises...>(std::move(promises)...));
+inline promise_impl<::fit::internal::join_continuation<Promises...>> join_promises(
+ Promises... promises) {
+ return make_promise_with_continuation(
+ ::fit::internal::join_continuation<Promises...>(std::move(promises)...));
+}
+
+// Jointly evaluates zero or more homogenous promises (same result and error
+// type). Returns a promise that produces a std::vector<> containing the
+// result of each promise once they all complete.
+//
+// EXAMPLE
+//
+// auto get_random_number() {
+// return fit::make_promise([] { return rand() % 10 });
+// }
+//
+// auto get_random_product() {
+// std::vector<fit::promise<int>> promises;
+// promises.push_back(get_random_number());
+// promises.push_back(get_random_number());
+// return fit::join_promise_vector(std::move(promises))
+// .and_then([] (std::vector<fit::result<int>>& results) {
+// return fit::ok(results[0].value() + results[1].value());
+// });
+// }
+//
+template <typename V, typename E>
+inline promise_impl<::fit::internal::join_vector_continuation<fit::promise<V, E>>>
+join_promise_vector(std::vector<fit::promise<V, E>> promises) {
+ return make_promise_with_continuation(
+ ::fit::internal::join_vector_continuation<fit::promise<V, E>>(std::move(promises)));
}
// Describes the status of a future.
enum class future_state {
- // The future neither holds a result nor a promise that could produce a result.
- // An empty future cannot make progress until a promise or result is assigned to it.
- empty,
- // The future holds a promise that may eventually produce a result but
- // it currently doesn't have a result. The future's promise must be
- // invoked in order to make progress from this state.
- pending,
- // The future holds a successful result.
- ok,
- // The future holds an error result.
- error
+ // The future neither holds a result nor a promise that could produce a result.
+ // An empty future cannot make progress until a promise or result is assigned to it.
+ empty,
+ // The future holds a promise that may eventually produce a result but
+ // it currently doesn't have a result. The future's promise must be
+ // invoked in order to make progress from this state.
+ pending,
+ // The future holds a successful result.
+ ok,
+ // The future holds an error result.
+ error
};
// A |fit::future| holds onto a |fit::promise| until it has completed then
@@ -956,7 +1036,8 @@
//
// EXAMPLE
//
-// - https://fuchsia.googlesource.com/zircon/+/master/system/utest/fit/examples/promise_example2.cpp
+// -
+// https://fuchsia.googlesource.com/fuchsia/+/HEAD/zircon/system/utest/fit/examples/promise_example2.cc
template <typename V = void, typename E = void>
using future = future_impl<promise<V, E>>;
@@ -964,295 +1045,284 @@
// See |fit::future| documentation for more information.
template <typename Promise>
class future_impl final {
-public:
- // The type of promise held by the future.
- using promise_type = Promise;
+ public:
+ // The type of promise held by the future.
+ using promise_type = Promise;
- // The promise's result type.
- // Equivalent to fit::result<value_type, error_type>.
- using result_type = typename Promise::result_type;
+ // The promise's result type.
+ // Equivalent to fit::result<value_type, error_type>.
+ using result_type = typename Promise::result_type;
- // The type of value produced when the promise completes successfully.
- // May be void.
- using value_type = typename Promise::value_type;
+ // The type of value produced when the promise completes successfully.
+ // May be void.
+ using value_type = typename Promise::value_type;
- // The type of value produced when the promise completes with an error.
- // May be void.
- using error_type = typename Promise::error_type;
+ // The type of value produced when the promise completes with an error.
+ // May be void.
+ using error_type = typename Promise::error_type;
- // Creates a future in the empty state.
- future_impl() = default;
- future_impl(decltype(nullptr)) {}
+ // Creates a future in the empty state.
+ future_impl() = default;
+ future_impl(decltype(nullptr)) {}
- // Creates a future and assigns a promise to compute its result.
- // If the promise is empty, the future enters the empty state.
- // Otherwise the future enters the pending state.
- explicit future_impl(promise_type promise) {
- if (promise) {
- state_.template emplace<1>(std::move(promise));
- }
+ // Creates a future and assigns a promise to compute its result.
+ // If the promise is empty, the future enters the empty state.
+ // Otherwise the future enters the pending state.
+ explicit future_impl(promise_type promise) {
+ if (promise) {
+ state_.template emplace<1>(std::move(promise));
}
+ }
- // Creates a future and assigns its result.
- // If the result is pending, the future enters the empty state.
- // Otherwise the future enters the ok or error state.
- explicit future_impl(result_type result) {
- if (result) {
- state_.template emplace<2>(std::move(result));
- }
+ // Creates a future and assigns its result.
+ // If the result is pending, the future enters the empty state.
+ // Otherwise the future enters the ok or error state.
+ explicit future_impl(result_type result) {
+ if (result) {
+ state_.template emplace<2>(std::move(result));
}
+ }
- // Moves from another future, leaving the other one in an empty state.
- future_impl(future_impl&& other)
- : state_(std::move(other.state_)) {
- other.state_.template emplace<0>();
+ // Moves from another future, leaving the other one in an empty state.
+ future_impl(future_impl&& other) : state_(std::move(other.state_)) {
+ other.state_.template emplace<0>();
+ }
+
+ // Destroys the promise, releasing its promise and result (if any).
+ ~future_impl() = default;
+
+ // Returns the state of the future: empty, pending, ok, or error.
+ future_state state() const {
+ switch (state_.index()) {
+ case 0:
+ return future_state::empty;
+ case 1:
+ return future_state::pending;
+ case 2:
+ return state_.template get<2>().is_ok() ? future_state::ok : future_state::error;
}
+ __builtin_unreachable();
+ }
- // Destroys the promise, releasing its promise and result (if any).
- ~future_impl() = default;
+ // Returns true if the future's state is not |fit::future_state::empty|:
+ // it either holds a result or holds a promise that can be invoked to make
+ // progress towards obtaining a result.
+ explicit operator bool() const { return !is_empty(); }
- // Returns the state of the future: empty, pending, ok, or error.
- future_state state() const {
- switch (state_.index()) {
- case 0:
- return future_state::empty;
- case 1:
- return future_state::pending;
- case 2:
- return state_.template get<2>().is_ok()
- ? future_state::ok
- : future_state::error;
- }
- __builtin_unreachable();
+ // Returns true if the future's state is |fit::future_state::empty|:
+ // it does not hold a result or a promise so it cannot make progress.
+ bool is_empty() const { return state() == fit::future_state::empty; }
+
+ // Returns true if the future's state is |fit::future_state::pending|:
+ // it does not hold a result yet but it does hold a promise that can be invoked
+ // to make progress towards obtaining a result.
+ bool is_pending() const { return state() == fit::future_state::pending; }
+
+ // Returns true if the future's state is |fit::future_state::ok|:
+ // it holds a value that can be retrieved using |value()|, |take_value()|,
+ // |result()|, |take_result()|, or |take_ok_result()|.
+ bool is_ok() const { return state() == fit::future_state::ok; }
+
+ // Returns true if the future's state is |fit::future_state::error|:
+ // it holds an error that can be retrieved using |error()|, |take_error()|,
+ // |result()|, |take_result()|, or |take_error_result()|.
+ bool is_error() const { return state() == fit::future_state::error; }
+
+ // Returns true if the future's state is either |fit::future_state::ok| or
+ // |fit::future_state::error|.
+ bool is_ready() const { return state_.index() == 2; }
+
+ // Evaluates the future and returns true if its result is ready.
+ // Asserts that the future is not empty.
+ //
+ // If the promise completes and returns a result, the future will transition
+ // to the ok or error state according to the result. The promise itself will
+ // then be destroyed since it has fulfilled its purpose.
+ bool operator()(fit::context& context) {
+ switch (state_.index()) {
+ case 0:
+ return false;
+ case 1: {
+ result_type result = state_.template get<1>()(context);
+ if (!result)
+ return false;
+ state_.template emplace<2>(std::move(result));
+ return true;
+ }
+ case 2:
+ return true;
}
+ __builtin_unreachable();
+ }
- // Returns true if the future's state is not |fit::future_state::empty|:
- // it either holds a result or holds a promise that can be invoked to make
- // progress towards obtaining a result.
- explicit operator bool() const { return !is_empty(); }
+ // Gets a reference to the future's promise.
+ // Asserts that the future's state is |fit::future_state::pending|.
+ const promise_type& promise() const {
+ assert(is_pending());
+ return state_.template get<1>();
+ }
- // Returns true if the future's state is |fit::future_state::empty|:
- // it does not hold a result or a promise so it cannot make progress.
- bool is_empty() const { return state() == fit::future_state::empty; }
+ // Takes the future's promise, leaving it in an empty state.
+ // Asserts that the future's state is |fit::future_state::pending|.
+ promise_type take_promise() {
+ assert(is_pending());
+ auto promise = std::move(state_.template get<1>());
+ state_.template emplace<0>();
+ return promise;
+ }
- // Returns true if the future's state is |fit::future_state::pending|:
- // it does not hold a result yet but it does hold a promise that can be invoked
- // to make progress towards obtaining a result.
- bool is_pending() const { return state() == fit::future_state::pending; }
+ // Gets a reference to the future's result.
+ // Asserts that the future's state is |fit::future_state::ok| or
+ // |fit::future_state::error|.
+ result_type& result() {
+ assert(is_ready());
+ return state_.template get<2>();
+ }
+ const result_type& result() const {
+ assert(is_ready());
+ return state_.template get<2>();
+ }
- // Returns true if the future's state is |fit::future_state::ok|:
- // it holds a value that can be retrieved using |value()|, |take_value()|,
- // |result()|, |take_result()|, or |take_ok_result()|.
- bool is_ok() const { return state() == fit::future_state::ok; }
+ // Takes the future's result, leaving it in an empty state.
+ // Asserts that the future's state is |fit::future_state::ok| or
+ // |fit::future_state::error|.
+ result_type take_result() {
+ assert(is_ready());
+ auto result = std::move(state_.template get<2>());
+ state_.template emplace<0>();
+ return result;
+ }
- // Returns true if the future's state is |fit::future_state::error|:
- // it holds an error that can be retrieved using |error()|, |take_error()|,
- // |result()|, |take_result()|, or |take_error_result()|.
- bool is_error() const { return state() == fit::future_state::error; }
+ // Gets a reference to the future's value.
+ // Asserts that the future's state is |fit::future_state::ok|.
+ template <typename R = value_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R& value() {
+ assert(is_ok());
+ return state_.template get<2>().value();
+ }
+ template <typename R = value_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ const R& value() const {
+ assert(is_ok());
+ return state_.template get<2>().value();
+ }
- // Returns true if the future's state is either |fit::future_state::ok| or
- // |fit::future_state::error|.
- bool is_ready() const { return state_.index() == 2; }
+ // Takes the future's value, leaving it in an empty state.
+ // Asserts that the future's state is |fit::future_state::ok|.
+ template <typename R = value_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R take_value() {
+ assert(is_ok());
+ auto value = state_.template get<2>().take_value();
+ state_.template emplace<0>();
+ return value;
+ }
+ ok_result<value_type> take_ok_result() {
+ assert(is_ok());
+ auto result = state_.template get<2>().take_ok_result();
+ state_.template emplace<0>();
+ return result;
+ }
- // Evaluates the future and returns true if its result is ready.
- // Asserts that the future is not empty.
- //
- // If the promise completes and returns a result, the future will transition
- // to the ok or error state according to the result. The promise itself will
- // then be destroyed since it has fulfilled its purpose.
- bool operator()(fit::context& context) {
- switch (state_.index()) {
- case 0:
- return false;
- case 1: {
- result_type result = state_.template get<1>()(context);
- if (!result)
- return false;
- state_.template emplace<2>(std::move(result));
- return true;
- }
- case 2:
- return true;
- }
- __builtin_unreachable();
+ // Gets a reference to the future's error.
+ // Asserts that the future's state is |fit::future_state::error|.
+ template <typename R = error_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R& error() {
+ assert(is_error());
+ return state_.template get<2>().error();
+ }
+ template <typename R = error_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ const R& error() const {
+ assert(is_error());
+ return state_.template get<2>().error();
+ }
+
+ // Takes the future's error, leaving it in an empty state.
+ // Asserts that the future's state is |fit::future_state::error|.
+ template <typename R = error_type, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R take_error() {
+ assert(is_error());
+ auto error = state_.template get<2>().take_error();
+ state_.template emplace<0>();
+ return error;
+ }
+ error_result<error_type> take_error_result() {
+ assert(is_error());
+ auto result = state_.template get<2>().take_error_result();
+ state_.template emplace<0>();
+ return result;
+ }
+
+ // Move assigns from another future, leaving the other one in an empty state.
+ future_impl& operator=(future_impl&& other) = default;
+
+ // Discards the future's promise and result, leaving it empty.
+ future_impl& operator=(decltype(nullptr)) {
+ state_.template emplace<0>();
+ return *this;
+ }
+
+ // Assigns a promise to compute the future's result.
+ // If the promise is empty, the future enters the empty state.
+ // Otherwise the future enters the pending state.
+ future_impl& operator=(promise_type promise) {
+ if (promise) {
+ state_.template emplace<1>(std::move(promise));
+ } else {
+ state_.template emplace<0>();
}
+ return *this;
+ }
- // Gets a reference to the future's promise.
- // Asserts that the future's state is |fit::future_state::pending|.
- const promise_type& promise() const {
- assert(is_pending());
- return state_.template get<1>();
+ // Assigns the future's result.
+ // If the result is pending, the future enters the empty state.
+ // Otherwise the future enters the ok or error state.
+ future_impl& operator=(result_type result) {
+ if (result) {
+ state_.template emplace<2>(std::move(result));
+ } else {
+ state_.template emplace<0>();
}
+ return *this;
+ }
- // Takes the future's promise, leaving it in an empty state.
- // Asserts that the future's state is |fit::future_state::pending|.
- promise_type take_promise() {
- assert(is_pending());
- auto promise = std::move(state_.template get<1>());
- state_.template emplace<0>();
- return promise;
- }
+ // Swaps the futures' contents.
+ void swap(future_impl& other) {
+ using std::swap;
+ swap(state_, other.state_);
+ }
- // Gets a reference to the future's result.
- // Asserts that the future's state is |fit::future_state::ok| or
- // |fit::future_state::error|.
- result_type& result() {
- assert(is_ready());
- return state_.template get<2>();
- }
- const result_type& result() const {
- assert(is_ready());
- return state_.template get<2>();
- }
+ future_impl(const future_impl&) = delete;
+ future_impl& operator=(const future_impl&) = delete;
- // Takes the future's result, leaving it in an empty state.
- // Asserts that the future's state is |fit::future_state::ok| or
- // |fit::future_state::error|.
- result_type take_result() {
- assert(is_ready());
- auto result = std::move(state_.template get<2>());
- state_.template emplace<0>();
- return result;
- }
-
- // Gets a reference to the future's value.
- // Asserts that the future's state is |fit::future_state::ok|.
- template <typename R = value_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R& value() {
- assert(is_ok());
- return state_.template get<2>().value();
- }
- template <typename R = value_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- const R& value() const {
- assert(is_ok());
- return state_.template get<2>().value();
- }
-
- // Takes the future's value, leaving it in an empty state.
- // Asserts that the future's state is |fit::future_state::ok|.
- template <typename R = value_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R take_value() {
- assert(is_ok());
- auto value = state_.template get<2>().take_value();
- state_.template emplace<0>();
- return value;
- }
- ok_result<value_type> take_ok_result() {
- assert(is_ok());
- auto result = state_.template get<2>().take_ok_result();
- state_.template emplace<0>();
- return result;
- }
-
- // Gets a reference to the future's error.
- // Asserts that the future's state is |fit::future_state::error|.
- template <typename R = error_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R& error() {
- assert(is_error());
- return state_.template get<2>().error();
- }
- template <typename R = error_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- const R& error() const {
- assert(is_error());
- return state_.template get<2>().error();
- }
-
- // Takes the future's error, leaving it in an empty state.
- // Asserts that the future's state is |fit::future_state::error|.
- template <typename R = error_type,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R take_error() {
- assert(is_error());
- auto error = state_.template get<2>().take_error();
- state_.template emplace<0>();
- return error;
- }
- error_result<error_type> take_error_result() {
- assert(is_error());
- auto result = state_.template get<2>().take_error_result();
- state_.template emplace<0>();
- return result;
- }
-
- // Move assigns from another future, leaving the other one in an empty state.
- future_impl& operator=(future_impl&& other) = default;
-
- // Discards the future's promise and result, leaving it empty.
- future_impl& operator=(decltype(nullptr)) {
- state_.template emplace<0>();
- return *this;
- }
-
- // Assigns a promise to compute the future's result.
- // If the promise is empty, the future enters the empty state.
- // Otherwise the future enters the pending state.
- future_impl& operator=(promise_type promise) {
- if (promise) {
- state_.template emplace<1>(std::move(promise));
- } else {
- state_.template emplace<0>();
- }
- return *this;
- }
-
- // Assigns the future's result.
- // If the result is pending, the future enters the empty state.
- // Otherwise the future enters the ok or error state.
- future_impl& operator=(result_type result) {
- if (result) {
- state_.template emplace<2>(std::move(result));
- } else {
- state_.template emplace<0>();
- }
- return *this;
- }
-
- // Swaps the futures' contents.
- void swap(future_impl& other) {
- using std::swap;
- swap(state_, other.state_);
- }
-
- future_impl(const future_impl&) = delete;
- future_impl& operator=(const future_impl&) = delete;
-
-private:
- ::fit::internal::variant<::fit::internal::monostate,
- promise_type, result_type>
- state_;
+ private:
+ variant<monostate, promise_type, result_type> state_;
};
template <typename Promise>
void swap(future_impl<Promise>& a, future_impl<Promise>& b) {
- a.swap(b);
+ a.swap(b);
}
template <typename Promise>
bool operator==(const future_impl<Promise>& f, decltype(nullptr)) {
- return !f;
+ return !f;
}
template <typename Promise>
bool operator==(decltype(nullptr), const future_impl<Promise>& f) {
- return !f;
+ return !f;
}
template <typename Promise>
bool operator!=(const future_impl<Promise>& f, decltype(nullptr)) {
- return !!f;
+ return !!f;
}
template <typename Promise>
bool operator!=(decltype(nullptr), const future_impl<Promise>& f) {
- return !!f;
+ return !!f;
}
// Makes a future containing the specified promise.
template <typename Promise>
future_impl<Promise> make_future(Promise promise) {
- return future_impl<Promise>(std::move(promise));
+ return future_impl<Promise>(std::move(promise));
}
// A pending task holds a |fit::promise| that can be scheduled to run on
@@ -1266,53 +1336,48 @@
//
// See documentation of |fit::promise| for more information.
class pending_task final {
-public:
- // The type of promise held by this task.
- using promise_type = promise<void, void>;
+ public:
+ // The type of promise held by this task.
+ using promise_type = promise<void, void>;
- // Creates an empty pending task without a promise.
- pending_task() = default;
+ // Creates an empty pending task without a promise.
+ pending_task() = default;
- // Creates a pending task that wraps an already boxed promise that returns
- // |fit::result<void, void>|.
- pending_task(promise_type promise)
- : promise_(std::move(promise)) {}
+ // Creates a pending task that wraps an already boxed promise that returns
+ // |fit::result<void, void>|.
+ pending_task(promise_type promise) : promise_(std::move(promise)) {}
- // Creates a pending task that wraps any kind of promise, boxed or unboxed,
- // regardless of its result type and with any context that is assignable
- // from this task's context type.
- template <typename Continuation>
- pending_task(promise_impl<Continuation> promise)
- : promise_(promise ? promise.discard_result().box() : promise_type()) {}
+ // Creates a pending task that wraps any kind of promise, boxed or unboxed,
+ // regardless of its result type and with any context that is assignable
+ // from this task's context type.
+ template <typename Continuation>
+ pending_task(promise_impl<Continuation> promise)
+ : promise_(promise ? promise.discard_result().box() : promise_type()) {}
- pending_task(pending_task&&) = default;
- pending_task& operator=(pending_task&&) = default;
+ pending_task(pending_task&&) = default;
+ pending_task& operator=(pending_task&&) = default;
- // Destroys the pending task, releasing its promise.
- ~pending_task() = default;
+ // Destroys the pending task, releasing its promise.
+ ~pending_task() = default;
- // Returns true if the pending task is non-empty (has a valid promise).
- explicit operator bool() const { return !!promise_; }
+ // Returns true if the pending task is non-empty (has a valid promise).
+ explicit operator bool() const { return !!promise_; }
- // Evaluates the pending task.
- // If the task completes (returns a non-pending result), the task reverts
- // to an empty state (because the promise it holds has reverted to an empty
- // state) and returns true.
- // It is an error to invoke this method if the pending task is empty.
- bool operator()(fit::context& context) {
- return !promise_(context).is_pending();
- }
+ // Evaluates the pending task.
+ // If the task completes (returns a non-pending result), the task reverts
+ // to an empty state (because the promise it holds has reverted to an empty
+ // state) and returns true.
+ // It is an error to invoke this method if the pending task is empty.
+ bool operator()(fit::context& context) { return !promise_(context).is_pending(); }
- // Extracts the pending task's promise.
- promise_type take_promise() {
- return std::move(promise_);
- }
+ // Extracts the pending task's promise.
+ promise_type take_promise() { return std::move(promise_); }
- pending_task(const pending_task&) = delete;
- pending_task& operator=(const pending_task&) = delete;
+ pending_task(const pending_task&) = delete;
+ pending_task& operator=(const pending_task&) = delete;
-private:
- promise_type promise_;
+ private:
+ promise_type promise_;
};
// Execution context for an asynchronous task, such as a |fit::promise|,
@@ -1331,28 +1396,27 @@
//
// See documentation of |fit::promise| for more information.
class context {
-public:
- // Gets the executor that is running the task, never null.
- virtual class executor* executor() const = 0;
+ public:
+ // Gets the executor that is running the task, never null.
+ virtual class executor* executor() const = 0;
- // Obtains a handle that can be used to resume the task after it has been
- // suspended.
- //
- // Clients should call this method before returning |fit::pending()| from
- // the task. See documentation on |fit::executor|.
- virtual suspended_task suspend_task() = 0;
+ // Obtains a handle that can be used to resume the task after it has been
+ // suspended.
+ //
+ // Clients should call this method before returning |fit::pending()| from
+ // the task. See documentation on |fit::executor|.
+ virtual suspended_task suspend_task() = 0;
- // Converts this context to a derived context type.
- template <typename Context,
- typename = std::enable_if_t<std::is_base_of<context, Context>::value>>
- Context& as() & {
- // TODO(CP-163): We should perform a run-time type check here rather
- // than blindly casting. That's why this method exists.
- return static_cast<Context&>(*this);
- }
+ // Converts this context to a derived context type.
+ template <typename Context, typename = std::enable_if_t<std::is_base_of<context, Context>::value>>
+ Context& as() & {
+ // TODO(fxbug.dev/4060): We should perform a run-time type check here rather
+ // than blindly casting. That's why this method exists.
+ return static_cast<Context&>(*this);
+ }
-protected:
- virtual ~context() = default;
+ protected:
+ virtual ~context() = default;
};
// An abstract interface for executing asynchronous tasks, such as promises,
@@ -1399,15 +1463,15 @@
//
// See also |fit::single_threaded_executor| for a concrete implementation.
class executor {
-public:
- // Destroys the executor along with all of its remaining scheduled tasks
- // that have yet to complete.
- virtual ~executor() = default;
+ public:
+ // Destroys the executor along with all of its remaining scheduled tasks
+ // that have yet to complete.
+ virtual ~executor() = default;
- // Schedules a task for eventual execution by the executor.
- //
- // This method is thread-safe.
- virtual void schedule_task(pending_task task) = 0;
+ // Schedules a task for eventual execution by the executor.
+ //
+ // This method is thread-safe.
+ virtual void schedule_task(pending_task task) = 0;
};
// Represents a task that is awaiting resumption.
@@ -1419,102 +1483,105 @@
//
// See documentation of |fit::executor| for more information.
class suspended_task final {
-public:
- // A handle that grants the capability to resume a suspended task.
- // Each issued ticket must be individually resolved.
- using ticket = uint64_t;
+ public:
+ // A handle that grants the capability to resume a suspended task.
+ // Each issued ticket must be individually resolved.
+ using ticket = uint64_t;
- // The resolver mechanism implements a lightweight form of reference
- // counting for tasks that have been suspended.
- //
- // When a suspended task is created in a non-empty state, it receives
- // a pointer to a resolver interface and a ticket. The ticket is
- // a one-time-use handle that represents the task that was suspended
- // and provides a means to resume it. The |suspended_task| class ensures
- // that every ticket is precisely accounted for.
- //
- // When |suspended_task::resume_task()| is called on an instance with
- // a valid ticket, the resolver's |resolve_ticket()| method is invoked
- // passing the ticket's value along with *true* to resume the task. This
- // operation consumes the ticket so the |suspended_task| transitions to
- // an empty state. The ticket and resolver cannot be used again by
- // this |suspended_task| instance.
- //
- // Similarly, when |suspended_task::reset()| is called on an instance with
- // a valid ticket or when the task goes out of scope on such an instance,
- // the resolver's |resolve_ticket()| method is invoked but this time passes
- // *false* to not resume the task. As before, the ticket is consumed.
- //
- // Finally, when the |suspended_task| is copied, its ticket is duplicated
- // using |duplicate_ticket()| resulting in two tickets, both of which
- // must be individually resolved.
- //
- // Resuming a task that has already been resumed has no effect.
- // Conversely, a task is considered "abandoned" if all of its tickets
- // have been resolved without it ever being resumed. See documentation
- // of |fit::promise| for more information.
- //
- // The methods of this class are safe to call from any thread, including
- // threads that may not be managed by the task's executor.
- class resolver {
- public:
- // Duplicates the provided ticket, returning a new ticket.
- // Note: The new ticket may have the same numeric value as the
- // original ticket but should be considered a distinct instance
- // that must be separately resolved.
- virtual ticket duplicate_ticket(ticket ticket) = 0;
+ // The resolver mechanism implements a lightweight form of reference
+ // counting for tasks that have been suspended.
+ //
+ // When a suspended task is created in a non-empty state, it receives
+ // a pointer to a resolver interface and a ticket. The ticket is
+ // a one-time-use handle that represents the task that was suspended
+ // and provides a means to resume it. The |suspended_task| class ensures
+ // that every ticket is precisely accounted for.
+ //
+ // When |suspended_task::resume_task()| is called on an instance with
+ // a valid ticket, the resolver's |resolve_ticket()| method is invoked
+ // passing the ticket's value along with *true* to resume the task. This
+ // operation consumes the ticket so the |suspended_task| transitions to
+ // an empty state. The ticket and resolver cannot be used again by
+ // this |suspended_task| instance.
+ //
+ // Similarly, when |suspended_task::reset()| is called on an instance with
+ // a valid ticket or when the task goes out of scope on such an instance,
+ // the resolver's |resolve_ticket()| method is invoked but this time passes
+ // *false* to not resume the task. As before, the ticket is consumed.
+ //
+ // Finally, when the |suspended_task| is copied, its ticket is duplicated
+ // using |duplicate_ticket()| resulting in two tickets, both of which
+ // must be individually resolved.
+ //
+ // Resuming a task that has already been resumed has no effect.
+ // Conversely, a task is considered "abandoned" if all of its tickets
+ // have been resolved without it ever being resumed. See documentation
+ // of |fit::promise| for more information.
+ //
+ // The methods of this class are safe to call from any thread, including
+ // threads that may not be managed by the task's executor.
+ class resolver {
+ public:
+ // Duplicates the provided ticket, returning a new ticket.
+ // Note: The new ticket may have the same numeric value as the
+ // original ticket but should be considered a distinct instance
+ // that must be separately resolved.
+ virtual ticket duplicate_ticket(ticket ticket) = 0;
- // Consumes the provided ticket, optionally resuming its associated task.
- // The provided ticket must not be used again.
- virtual void resolve_ticket(ticket ticket, bool resume_task) = 0;
+ // Consumes the provided ticket, optionally resuming its associated task.
+ // The provided ticket must not be used again.
+ virtual void resolve_ticket(ticket ticket, bool resume_task) = 0;
- protected:
- virtual ~resolver() = default;
- };
+ protected:
+ virtual ~resolver() = default;
+ };
- suspended_task()
- : resolver_(nullptr), ticket_(0) {}
+ suspended_task() : resolver_(nullptr), ticket_(0) {}
- suspended_task(resolver* resolver, ticket ticket)
- : resolver_(resolver), ticket_(ticket) {}
+ suspended_task(resolver* resolver, ticket ticket) : resolver_(resolver), ticket_(ticket) {}
- suspended_task(const suspended_task& other);
- suspended_task(suspended_task&& other);
+ suspended_task(const suspended_task& other);
+ suspended_task(suspended_task&& other);
- // Releases the task without resumption.
- //
- // Does nothing if this object does not hold a ticket.
- ~suspended_task();
+ // Releases the task without resumption.
+ //
+ // Does nothing if this object does not hold a ticket.
+ ~suspended_task();
- // Returns true if this object holds a ticket for a suspended task.
- explicit operator bool() const { return resolver_ != nullptr; }
+ // Returns true if this object holds a ticket for a suspended task.
+ explicit operator bool() const { return resolver_ != nullptr; }
- // Asks the task's executor to resume execution of the suspended task
- // if it has not already been resumed or completed. Also releases
- // the task's ticket as a side-effect.
- //
- // Clients should call this method when it is possible for the task to
- // make progress; for example, because some event the task was
- // awaiting has occurred. See documentation on |fit::executor|.
- //
- // Does nothing if this object does not hold a ticket.
- void resume_task() { resolve(true); }
+ // Asks the task's executor to resume execution of the suspended task
+ // if it has not already been resumed or completed. Also releases
+ // the task's ticket as a side-effect.
+ //
+ // Clients should call this method when it is possible for the task to
+ // make progress; for example, because some event the task was
+ // awaiting has occurred. See documentation on |fit::executor|.
+ //
+ // Does nothing if this object does not hold a ticket.
+ void resume_task() { resolve(true); }
- // Releases the suspended task without resumption.
- //
- // Does nothing if this object does not hold a ticket.
- void reset() { resolve(false); }
+ // Releases the suspended task without resumption.
+ //
+ // Does nothing if this object does not hold a ticket.
+ void reset() { resolve(false); }
- suspended_task& operator=(const suspended_task& other);
- suspended_task& operator=(suspended_task&& other);
+ // Swaps suspended tasks.
+ void swap(suspended_task& other);
-private:
- void resolve(bool resume_task);
+ suspended_task& operator=(const suspended_task& other);
+ suspended_task& operator=(suspended_task&& other);
- resolver* resolver_;
- ticket ticket_;
+ private:
+ void resolve(bool resume_task);
+
+ resolver* resolver_;
+ ticket ticket_;
};
-} // namespace fit
+inline void swap(suspended_task& a, suspended_task& b) { a.swap(b); }
-#endif // LIB_FIT_PROMISE_H_
+} // namespace fit
+
+#endif // LIB_FIT_PROMISE_H_
diff --git a/pkg/fit/include/lib/fit/promise_internal.h b/pkg/fit/include/lib/fit/promise_internal.h
index 30e7085..01b7750 100644
--- a/pkg/fit/include/lib/fit/promise_internal.h
+++ b/pkg/fit/include/lib/fit/promise_internal.h
@@ -15,6 +15,7 @@
#include "nullable.h"
#include "result.h"
#include "traits.h"
+#include "utility_internal.h"
namespace fit {
@@ -39,511 +40,572 @@
// Deduces a continuation's result.
// Also ensures that the continuation has a compatible signature.
template <typename Continuation,
- typename = std::enable_if_t<is_result<
- decltype(std::declval<Continuation&>()(
- std::declval<::fit::context&>()))>::value>>
+ typename = std::enable_if_t<is_result<decltype(
+ std::declval<Continuation&>()(std::declval<::fit::context&>()))>::value>>
struct continuation_traits {
- using type = Continuation;
- using result_type = decltype(std::declval<Continuation&>()(std::declval<::fit::context&>()));
+ using type = Continuation;
+ using result_type = decltype(std::declval<Continuation&>()(std::declval<::fit::context&>()));
};
template <typename Continuation, typename = fit::void_t<>>
struct is_continuation : std::false_type {};
template <typename Continuation>
-struct is_continuation<
- Continuation,
- fit::void_t<typename continuation_traits<Continuation>::type>>
+struct is_continuation<Continuation, fit::void_t<typename continuation_traits<Continuation>::type>>
: std::true_type {};
+// Interposer type that provides uniform move construction/assignment for
+// callable types that may or may not be move assignable. Lambdas are not
+// typically move assignable, even though they may be move constructible.
+//
+// This type has a well-defined empty state. Instances of this type that are
+// the source of move operation are left in the empty state.
+template <typename Handler>
+class movable_handler {
+ static_assert(std::is_move_constructible<Handler>::value, "Handler must be move constructible!");
+
+ template <typename... Conditions>
+ using requires_conditions = ::fit::internal::requires_conditions<Conditions...>;
+
+ template <typename... Conditions>
+ using assignment_requires_conditions =
+ ::fit::internal::assignment_requires_conditions<movable_handler&, Conditions...>;
+
+ template <typename U>
+ using not_self_type = ::fit::internal::not_same_type<movable_handler, U>;
+
+ public:
+ constexpr movable_handler() = default;
+
+ constexpr movable_handler(const movable_handler&) = delete;
+ constexpr movable_handler& operator=(const movable_handler&) = delete;
+
+ constexpr movable_handler(movable_handler&& other) : handler_{std::move(other.handler_)} {
+ other.handler_.reset();
+ }
+
+ constexpr movable_handler& operator=(movable_handler&& other) {
+ if (this != &other) {
+ reset();
+ if (other.handler_.has_value()) {
+ handler_.emplace(std::move(other.handler_.value()));
+ other.handler_.reset();
+ }
+ }
+ return *this;
+ }
+
+ template <typename U = Handler,
+ requires_conditions<not_self_type<U>, std::is_constructible<Handler, U&&>,
+ std::is_convertible<U&&, Handler>> = true>
+ constexpr movable_handler(U&& handler) {
+ if (!is_null(handler)) {
+ handler_.emplace(std::forward<U>(handler));
+ }
+ }
+
+ ~movable_handler() = default;
+
+ template <typename U>
+ constexpr assignment_requires_conditions<not_self_type<U>, std::is_constructible<Handler, U>,
+ std::is_assignable<Handler&, U>>
+ operator=(U&& handler) {
+ handler_.reset();
+ if (!is_null(handler)) {
+ handler_.emplace(std::forward<U>(handler));
+ }
+ return *this;
+ }
+
+ template <typename... Args>
+ constexpr auto operator()(Args&&... args) {
+ // Seamlessly handle void by casting call expression to return type.
+ using Return = typename callable_traits<Handler>::return_type;
+ return static_cast<Return>((handler_.value())(std::forward<Args>(args)...));
+ }
+
+ explicit constexpr operator bool() const { return handler_.has_value(); }
+
+ constexpr void reset() { handler_.reset(); }
+
+ private:
+ optional<Handler> handler_;
+};
+
// Wraps a handler function and adapts its return type to a fit::result
// via its specializations.
template <typename Handler, typename DefaultV, typename DefaultE,
typename ReturnType = typename callable_traits<Handler>::return_type,
bool callable_result = ::fit::is_callable<ReturnType>::value>
class result_adapter final {
- // This expression always evaluates to false but depends on the template
- // type parameters so that it only gets evaluated when the template is
- // expanded. If we simply wrote "false", the compiler would raise the
- // static assertion failure as soon as it encountered the statement.
- template <typename T>
- struct check_result { static constexpr bool value = false; };
- static_assert(
- check_result<ReturnType>::value,
- "The provided handler's result type was expected to be "
- "fit::result<V, E>, fit::ok_result<V>, fit::error_result<E>, "
- "fit::pending_result, void, or a continuation with the signature "
- "fit::result<V, E>(fit::context&). "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ // This expression always evaluates to false but depends on the template
+ // type parameters so that it only gets evaluated when the template is
+ // expanded. If we simply wrote "false", the compiler would raise the
+ // static assertion failure as soon as it encountered the statement.
+ template <typename T>
+ struct check_result {
+ static constexpr bool value = false;
+ };
+ static_assert(check_result<ReturnType>::value,
+ "The provided handler's result type was expected to be "
+ "fit::result<V, E>, fit::ok_result<V>, fit::error_result<E>, "
+ "fit::pending_result, void, or a continuation with the signature "
+ "fit::result<V, E>(fit::context&). "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
};
// Supports handlers that return void.
template <typename Handler, typename DefaultV, typename DefaultE>
class result_adapter<Handler, DefaultV, DefaultE, void, false> final {
-public:
- using result_type = ::fit::result<DefaultV, DefaultE>;
+ public:
+ using result_type = ::fit::result<DefaultV, DefaultE>;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(Handler handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- handler_(std::forward<Args>(args)...);
- return ::fit::ok();
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ handler_(std::forward<Args>(args)...);
+ return ::fit::ok();
+ }
-private:
- Handler handler_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
};
// Supports handlers that return pending_result.
template <typename Handler, typename DefaultV, typename DefaultE>
class result_adapter<Handler, DefaultV, DefaultE, ::fit::pending_result, false> final {
-public:
- using result_type = ::fit::result<DefaultV, DefaultE>;
+ public:
+ using result_type = ::fit::result<DefaultV, DefaultE>;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(movable_handler<Handler> handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return handler_(std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return handler_(std::forward<Args>(args)...);
+ }
-private:
- Handler handler_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
};
// Supports handlers that return ok_result<V>.
-template <typename Handler, typename DefaultV, typename DefaultE,
- typename V>
+template <typename Handler, typename DefaultV, typename DefaultE, typename V>
class result_adapter<Handler, DefaultV, DefaultE, ::fit::ok_result<V>, false> final {
-public:
- using result_type = ::fit::result<V, DefaultE>;
+ public:
+ using result_type = ::fit::result<V, DefaultE>;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(movable_handler<Handler> handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return handler_(std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return handler_(std::forward<Args>(args)...);
+ }
-private:
- Handler handler_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
};
// Supports handlers that return error_result<E>.
-template <typename Handler, typename DefaultV, typename DefaultE,
- typename E>
+template <typename Handler, typename DefaultV, typename DefaultE, typename E>
class result_adapter<Handler, DefaultV, DefaultE, ::fit::error_result<E>, false> final {
-public:
- using result_type = ::fit::result<DefaultV, E>;
+ public:
+ using result_type = ::fit::result<DefaultV, E>;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(movable_handler<Handler> handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return handler_(std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return handler_(std::forward<Args>(args)...);
+ }
-private:
- Handler handler_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
};
// Supports handlers that return result<V, E>.
-template <typename Handler, typename DefaultV, typename DefaultE,
- typename V, typename E>
+template <typename Handler, typename DefaultV, typename DefaultE, typename V, typename E>
class result_adapter<Handler, DefaultV, DefaultE, ::fit::result<V, E>, false> final {
-public:
- using result_type = ::fit::result<V, E>;
+ public:
+ using result_type = ::fit::result<V, E>;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(movable_handler<Handler> handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return handler_(std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return handler_(std::forward<Args>(args)...);
+ }
-private:
- Handler handler_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
};
// Supports handlers that return continuations or promises.
// This works for any callable whose signature is:
// fit::result<...>(fit::context&)
-template <typename Handler, typename DefaultV, typename DefaultE,
- typename ReturnType>
+template <typename Handler, typename DefaultV, typename DefaultE, typename ReturnType>
class result_adapter<Handler, DefaultV, DefaultE, ReturnType, true> final {
- // If the handler doesn't actually return a continuation then the
- // compilation will fail here which is slightly easier to diagnose
- // than if we dropped the result_adapter specialization entirely.
- using continuation_traits = continuation_traits<ReturnType>;
- using continuation_type = typename continuation_traits::type;
+ // If the handler doesn't actually return a continuation then the
+ // compilation will fail here which is slightly easier to diagnose
+ // than if we dropped the result_adapter specialization entirely.
+ using result_continuation_traits = continuation_traits<ReturnType>;
+ using continuation_type = typename result_continuation_traits::type;
-public:
- using result_type = typename continuation_traits::result_type;
+ public:
+ using result_type = typename result_continuation_traits::result_type;
- explicit result_adapter(Handler handler)
- : handler_(std::move(handler)) {}
+ explicit result_adapter(movable_handler<Handler> handler) : handler_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- if (handler_) {
- continuation_ = (*handler_)(std::forward<Args>(args)...);
- handler_.reset();
- }
- if (!continuation_) {
- return ::fit::pending();
- }
- return (*continuation_)(context);
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ if (handler_) {
+ continuation_ = handler_(std::forward<Args>(args)...);
+ handler_.reset();
}
+ if (!continuation_) {
+ return ::fit::pending();
+ }
+ return continuation_(context);
+ }
-private:
- ::fit::nullable<Handler> handler_;
- ::fit::nullable<continuation_type> continuation_;
+ result_adapter(const result_adapter&) = delete;
+ result_adapter& operator=(const result_adapter&) = delete;
+
+ result_adapter(result_adapter&&) = default;
+ result_adapter& operator=(result_adapter&&) = default;
+
+ private:
+ movable_handler<Handler> handler_;
+ movable_handler<continuation_type> continuation_;
};
// Wraps a handler that may or may not have a fit::context& as first argument.
// This is determined by checking the argument count.
-template <typename Handler, typename DefaultV, typename DefaultE,
- size_t num_args = 0,
- int excess_args =
- (static_cast<int>(
- ::fit::callable_traits<Handler>::args::size) -
- static_cast<int>(num_args))>
+template <typename Handler, typename DefaultV, typename DefaultE, size_t num_args = 0,
+ int excess_args = (static_cast<int>(::fit::callable_traits<Handler>::args::size) -
+ static_cast<int>(num_args))>
class context_adapter final {
- static_assert(
- excess_args >= 0,
- "The provided handler has too few arguments. "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
- static_assert(
- excess_args <= 1,
- "The provided handler has too many arguments. "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ static_assert(excess_args >= 0,
+ "The provided handler has too few arguments. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
+ static_assert(excess_args <= 1,
+ "The provided handler has too many arguments. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
};
// Supports handlers without a context argument.
-template <typename Handler, typename DefaultV, typename DefaultE,
- size_t num_args>
+template <typename Handler, typename DefaultV, typename DefaultE, size_t num_args>
class context_adapter<Handler, DefaultV, DefaultE, num_args, 0> final {
- using base_type = result_adapter<Handler, DefaultV, DefaultE>;
+ using base_type = result_adapter<Handler, DefaultV, DefaultE>;
-public:
- using result_type = typename base_type::result_type;
- static constexpr size_t next_arg_index = 0;
+ public:
+ using result_type = typename base_type::result_type;
+ static constexpr size_t next_arg_index = 0;
- explicit context_adapter(Handler handler)
- : base_(std::move(handler)) {}
+ explicit context_adapter(Handler handler) : base_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return base_.template call<Args...>(context, std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return base_.template call<Args...>(context, std::forward<Args>(args)...);
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Supports handlers with a context argument.
-template <typename Handler, typename DefaultV, typename DefaultE,
- size_t num_args>
+template <typename Handler, typename DefaultV, typename DefaultE, size_t num_args>
class context_adapter<Handler, DefaultV, DefaultE, num_args, 1> final {
- using base_type = result_adapter<Handler, DefaultV, DefaultE>;
- using context_arg_type =
- typename ::fit::callable_traits<Handler>::args::template at<0>;
- static_assert(
- std::is_same<context_arg_type, ::fit::context&>::value,
- "The provided handler's first argument was expected to be of type "
- "fit::context& based on the number of arguments it has. "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ using base_type = result_adapter<Handler, DefaultV, DefaultE>;
+ using context_arg_type = typename ::fit::callable_traits<Handler>::args::template at<0>;
+ static_assert(std::is_same<context_arg_type, ::fit::context&>::value,
+ "The provided handler's first argument was expected to be of type "
+ "fit::context& based on the number of arguments it has. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
-public:
- using result_type = typename base_type::result_type;
- static constexpr size_t next_arg_index = 1;
+ public:
+ using result_type = typename base_type::result_type;
+ static constexpr size_t next_arg_index = 1;
- explicit context_adapter(Handler handler)
- : base_(std::move(handler)) {}
+ explicit context_adapter(Handler handler) : base_(std::move(handler)) {}
- template <typename... Args>
- result_type call(::fit::context& context, Args... args) {
- return base_.template call<::fit::context&, Args...>(
- context, context, std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ result_type call(::fit::context& context, Args... args) {
+ return base_.template call<::fit::context&, Args...>(context, context,
+ std::forward<Args>(args)...);
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Wraps a handler that may accept a context argument.
template <typename Handler>
class context_handler_invoker final {
- using base_type = context_adapter<Handler, void, void, 0>;
+ using base_type = context_adapter<Handler, void, void, 0>;
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit context_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit context_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context) {
- return base_.template call<>(context);
- }
+ result_type operator()(::fit::context& context) { return base_.template call<>(context); }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Wraps a handler that may accept a context and result argument.
template <typename Handler, typename PriorResult>
class result_handler_invoker final {
- using base_type = context_adapter<Handler, void, void, 1>;
- using result_arg_type =
- typename ::fit::callable_traits<Handler>::args::template at<
- base_type::next_arg_index>;
- static_assert(
- (std::is_same<result_arg_type, PriorResult>::value &&
- std::is_copy_constructible<result_arg_type>::value) ||
- std::is_same<result_arg_type, PriorResult&>::value ||
- std::is_same<result_arg_type, const PriorResult&>::value,
- "The provided handler's last argument was expected to be of type "
- "fit::result<V, E>&, const fit::result<V, E>&, or fit::result<V, E> "
- "(if the result is copy-constructible). "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ using base_type = context_adapter<Handler, void, void, 1>;
+ using result_arg_type =
+ typename ::fit::callable_traits<Handler>::args::template at<base_type::next_arg_index>;
+ static_assert(std::is_same<result_arg_type, PriorResult&>::value ||
+ std::is_same<result_arg_type, const PriorResult&>::value,
+ "The provided handler's last argument was expected to be of type "
+ "fit::result<V, E>& or const fit::result<V, E>& where V is the prior "
+ "result's value type and E is the prior result's error type. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit result_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit result_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context, PriorResult& result) {
- return base_.template call<PriorResult&>(context, result);
- }
+ result_type operator()(::fit::context& context, PriorResult& result) {
+ return base_.template call<PriorResult&>(context, result);
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Wraps a handler that may accept a context and value argument.
-template <typename Handler, typename PriorResult,
- typename V = typename PriorResult::value_type>
+template <typename Handler, typename PriorResult, typename V = typename PriorResult::value_type>
class value_handler_invoker final {
- using base_type = context_adapter<Handler,
- void, typename PriorResult::error_type, 1>;
- using value_arg_type =
- typename ::fit::callable_traits<Handler>::args::template at<
- base_type::next_arg_index>;
- static_assert(
- (std::is_same<value_arg_type, V>::value &&
- std::is_copy_constructible<value_arg_type>::value) ||
- std::is_same<value_arg_type, V&>::value ||
- std::is_same<value_arg_type, const V&>::value,
- "The provided handler's last argument was expected to be of type "
- "V&, const V&, or V (if the value is copy-constructible). "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ using base_type = context_adapter<Handler, void, typename PriorResult::error_type, 1>;
+ using value_arg_type =
+ typename ::fit::callable_traits<Handler>::args::template at<base_type::next_arg_index>;
+ static_assert(std::is_same<value_arg_type, V&>::value ||
+ std::is_same<value_arg_type, const V&>::value,
+ "The provided handler's last argument was expected to be of type "
+ "V& or const V& where V is the prior result's value type. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit value_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit value_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context, PriorResult& result) {
- return base_.template call<V&>(context, result.value());
- }
+ result_type operator()(::fit::context& context, PriorResult& result) {
+ return base_.template call<V&>(context, result.value());
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Specialization for void value.
template <typename Handler, typename PriorResult>
class value_handler_invoker<Handler, PriorResult, void> final {
- using base_type = context_adapter<Handler,
- void, typename PriorResult::error_type, 0>;
+ using base_type = context_adapter<Handler, void, typename PriorResult::error_type, 0>;
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit value_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit value_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context, PriorResult& result) {
- return base_.template call<>(context);
- }
+ result_type operator()(::fit::context& context, PriorResult& result) {
+ return base_.template call<>(context);
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Wraps a handler that may accept a context and error argument.
-template <typename Handler, typename PriorResult,
- typename E = typename PriorResult::error_type>
+template <typename Handler, typename PriorResult, typename E = typename PriorResult::error_type>
class error_handler_invoker final {
- using base_type = context_adapter<Handler,
- typename PriorResult::value_type, void, 1>;
- using error_arg_type =
- typename ::fit::callable_traits<Handler>::args::template at<
- base_type::next_arg_index>;
- static_assert(
- (std::is_same<error_arg_type, E>::value &&
- std::is_copy_constructible<error_arg_type>::value) ||
- std::is_same<error_arg_type, E&>::value ||
- std::is_same<error_arg_type, const E&>::value,
- "The provided handler's last argument was expected to be of type "
- "E&, const E&, or E (if the error is copy-constructible). "
- "Please refer to the combinator's documentation for a list of "
- "supported handler function signatures.");
+ using base_type = context_adapter<Handler, typename PriorResult::value_type, void, 1>;
+ using error_arg_type =
+ typename ::fit::callable_traits<Handler>::args::template at<base_type::next_arg_index>;
+ static_assert(std::is_same<error_arg_type, E&>::value ||
+ std::is_same<error_arg_type, const E&>::value,
+ "The provided handler's last argument was expected to be of type "
+ "E& or const E& where E is the prior result's error type. "
+ "Please refer to the combinator's documentation for a list of "
+ "supported handler function signatures.");
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit error_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit error_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context, PriorResult& result) {
- return base_.template call<E&>(context, result.error());
- }
+ result_type operator()(::fit::context& context, PriorResult& result) {
+ return base_.template call<E&>(context, result.error());
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// Specialization for void error.
template <typename Handler, typename PriorResult>
class error_handler_invoker<Handler, PriorResult, void> final {
- using base_type = context_adapter<Handler,
- typename PriorResult::value_type, void, 0>;
+ using base_type = context_adapter<Handler, typename PriorResult::value_type, void, 0>;
-public:
- using result_type = typename base_type::result_type;
+ public:
+ using result_type = typename base_type::result_type;
- explicit error_handler_invoker(Handler handler)
- : base_(std::move(handler)) {}
+ explicit error_handler_invoker(Handler handler) : base_(std::move(handler)) {}
- result_type operator()(::fit::context& context, PriorResult& result) {
- return base_.template call<>(context);
- }
+ result_type operator()(::fit::context& context, PriorResult& result) {
+ return base_.template call<>(context);
+ }
-private:
- base_type base_;
+ private:
+ base_type base_;
};
// The continuation produced by |fit::promise::then()|.
template <typename PriorPromise, typename ResultHandler>
class then_continuation final {
- using invoker_type = ::fit::internal::result_handler_invoker<
- ResultHandler, typename PriorPromise::result_type>;
+ using invoker_type =
+ ::fit::internal::result_handler_invoker<ResultHandler, typename PriorPromise::result_type>;
-public:
- then_continuation(PriorPromise prior_promise, ResultHandler handler)
- : prior_(std::move(prior_promise)),
- invoker_(std::move(handler)) {}
+ public:
+ then_continuation(PriorPromise prior_promise, ResultHandler handler)
+ : prior_(std::move(prior_promise)), invoker_(std::move(handler)) {}
- typename invoker_type::result_type operator()(::fit::context& context) {
- if (!prior_(context))
- return ::fit::pending();
- return invoker_(context, prior_.result());
- }
+ typename invoker_type::result_type operator()(::fit::context& context) {
+ if (!prior_(context))
+ return ::fit::pending();
+ return invoker_(context, prior_.result());
+ }
-private:
- future_impl<PriorPromise> prior_;
- invoker_type invoker_;
+ private:
+ future_impl<PriorPromise> prior_;
+ invoker_type invoker_;
};
// The continuation produced by |fit::promise::and_then()|.
template <typename PriorPromise, typename ValueHandler>
class and_then_continuation final {
- using invoker_type = ::fit::internal::value_handler_invoker<
- ValueHandler, typename PriorPromise::result_type>;
+ using invoker_type =
+ ::fit::internal::value_handler_invoker<ValueHandler, typename PriorPromise::result_type>;
-public:
- and_then_continuation(PriorPromise prior_promise, ValueHandler handler)
- : prior_(std::move(prior_promise)),
- invoker_(std::move(handler)) {}
+ public:
+ and_then_continuation(PriorPromise prior_promise, ValueHandler handler)
+ : prior_(std::move(prior_promise)), invoker_(std::move(handler)) {}
- typename invoker_type::result_type operator()(::fit::context& context) {
- if (!prior_(context))
- return ::fit::pending();
- if (prior_.is_error())
- return prior_.take_error_result();
- return invoker_(context, prior_.result());
- }
+ typename invoker_type::result_type operator()(::fit::context& context) {
+ if (!prior_(context))
+ return ::fit::pending();
+ if (prior_.is_error())
+ return prior_.take_error_result();
+ return invoker_(context, prior_.result());
+ }
-private:
- future_impl<PriorPromise> prior_;
- invoker_type invoker_;
+ private:
+ future_impl<PriorPromise> prior_;
+ invoker_type invoker_;
};
// The continuation produced by |fit::promise::or_else()|.
template <typename PriorPromise, typename ErrorHandler>
class or_else_continuation final {
- using invoker_type = ::fit::internal::error_handler_invoker<
- ErrorHandler, typename PriorPromise::result_type>;
+ using invoker_type =
+ ::fit::internal::error_handler_invoker<ErrorHandler, typename PriorPromise::result_type>;
-public:
- or_else_continuation(PriorPromise prior_promise, ErrorHandler handler)
- : prior_(std::move(prior_promise)),
- invoker_(std::move(handler)) {}
+ public:
+ or_else_continuation(PriorPromise prior_promise, ErrorHandler handler)
+ : prior_(std::move(prior_promise)), invoker_(std::move(handler)) {}
- typename invoker_type::result_type operator()(::fit::context& context) {
- if (!prior_(context))
- return ::fit::pending();
- if (prior_.is_ok())
- return prior_.take_ok_result();
- return invoker_(context, prior_.result());
- }
+ typename invoker_type::result_type operator()(::fit::context& context) {
+ if (!prior_(context))
+ return ::fit::pending();
+ if (prior_.is_ok())
+ return prior_.take_ok_result();
+ return invoker_(context, prior_.result());
+ }
-private:
- future_impl<PriorPromise> prior_;
- invoker_type invoker_;
+ private:
+ future_impl<PriorPromise> prior_;
+ invoker_type invoker_;
};
// The continuation produced by |fit::promise::inspect()|.
template <typename PriorPromise, typename InspectHandler>
class inspect_continuation final {
- using invoker_type = ::fit::internal::result_handler_invoker<
- InspectHandler, typename PriorPromise::result_type>;
+ using invoker_type =
+ ::fit::internal::result_handler_invoker<InspectHandler, typename PriorPromise::result_type>;
-public:
- inspect_continuation(PriorPromise prior_promise, InspectHandler handler)
- : prior_(std::move(prior_promise)),
- invoker_(std::move(handler)) {}
+ public:
+ inspect_continuation(PriorPromise prior_promise, InspectHandler handler)
+ : prior_(std::move(prior_promise)), invoker_(std::move(handler)) {}
- typename PriorPromise::result_type operator()(::fit::context& context) {
- typename PriorPromise::result_type result = prior_(context);
- if (result)
- invoker_(context, result);
- return result;
- }
+ typename PriorPromise::result_type operator()(::fit::context& context) {
+ typename PriorPromise::result_type result = prior_(context);
+ if (result)
+ invoker_(context, result);
+ return result;
+ }
-private:
- PriorPromise prior_;
- invoker_type invoker_;
+ private:
+ PriorPromise prior_;
+ invoker_type invoker_;
};
// The continuation produced by |fit::promise::discard_result()|.
template <typename PriorPromise>
class discard_result_continuation final {
-public:
- explicit discard_result_continuation(PriorPromise prior_promise)
- : prior_(std::move(prior_promise)) {}
+ public:
+ explicit discard_result_continuation(PriorPromise prior_promise)
+ : prior_(std::move(prior_promise)) {}
- fit::result<> operator()(::fit::context& context) {
- if (!prior_(context))
- return ::fit::pending();
- return ::fit::ok();
- }
+ fit::result<> operator()(::fit::context& context) {
+ if (!prior_(context))
+ return ::fit::pending();
+ return ::fit::ok();
+ }
-private:
- PriorPromise prior_;
+ private:
+ PriorPromise prior_;
};
// The continuation produced by |make_promise()|.
@@ -551,50 +613,87 @@
template <typename PromiseHandler>
using promise_continuation = context_handler_invoker<PromiseHandler>;
+// The continuation produced by |make_result_promise()|.
+template <typename V, typename E>
+class result_continuation final {
+ public:
+ explicit result_continuation(::fit::result<V, E> result) : result_(std::move(result)) {}
+
+ ::fit::result<V, E> operator()(::fit::context& context) { return std::move(result_); }
+
+ private:
+ ::fit::result<V, E> result_;
+};
+
// Returns true if all arguments are true or if there are none.
-inline bool all_true() {
- return true;
-}
+inline bool all_true() { return true; }
template <typename... Ts>
inline bool all_true(bool value, Ts... values) {
- return value & all_true(values...);
+ return value & all_true(values...);
}
// The continuation produced by |join_promises()|.
template <typename... Promises>
class join_continuation final {
-public:
- explicit join_continuation(Promises... promises)
- : promises_(std::make_tuple(std::move(promises)...)) {}
+ public:
+ explicit join_continuation(Promises... promises)
+ : promises_(std::make_tuple(std::move(promises)...)) {}
- ::fit::result<std::tuple<typename Promises::result_type...>> operator()(
- ::fit::context& context) {
- return evaluate(context, std::index_sequence_for<Promises...>{});
- }
+ ::fit::result<std::tuple<typename Promises::result_type...>> operator()(::fit::context& context) {
+ return evaluate(context, std::index_sequence_for<Promises...>{});
+ }
-private:
- template <size_t... i>
- ::fit::result<std::tuple<typename Promises::result_type...>> evaluate(
- ::fit::context& context, std::index_sequence<i...>) {
- bool done = all_true(std::get<i>(promises_)(context)...);
- if (!done)
- return ::fit::pending();
- return ::fit::ok(std::make_tuple(std::get<i>(promises_).take_result()...));
- }
+ private:
+ template <size_t... i>
+ ::fit::result<std::tuple<typename Promises::result_type...>> evaluate(::fit::context& context,
+ std::index_sequence<i...>) {
+ bool done = all_true(std::get<i>(promises_)(context)...);
+ if (!done)
+ return ::fit::pending();
+ return ::fit::ok(std::make_tuple(std::get<i>(promises_).take_result()...));
+ }
- std::tuple<future_impl<Promises>...> promises_;
+ std::tuple<future_impl<Promises>...> promises_;
};
-} // namespace internal
+// The continuation produced by |join_promise_vector()|.
+template <typename Promise>
+class join_vector_continuation final {
+ using promise_vector = std::vector<Promise>;
+ using result_vector = std::vector<typename Promise::result_type>;
+
+ public:
+ explicit join_vector_continuation(promise_vector promises)
+ : promises_(std::move(promises)), results_(promises_.size()) {}
+
+ ::fit::result<result_vector> operator()(::fit::context& context) {
+ bool all_done{true};
+ for (size_t i = 0; i < promises_.size(); ++i) {
+ if (!results_[i]) {
+ results_[i] = promises_[i](context);
+ all_done &= !results_[i].is_pending();
+ }
+ }
+ if (all_done) {
+ return fit::ok(std::move(results_));
+ }
+ return ::fit::pending();
+ }
+
+ private:
+ promise_vector promises_;
+ result_vector results_;
+};
+
+} // namespace internal
template <typename PromiseHandler>
-inline promise_impl<::fit::internal::promise_continuation<PromiseHandler>>
-make_promise(PromiseHandler handler);
+inline promise_impl<::fit::internal::promise_continuation<PromiseHandler>> make_promise(
+ PromiseHandler handler);
template <typename Continuation>
-inline promise_impl<Continuation> make_promise_with_continuation(
- Continuation continuation);
+inline promise_impl<Continuation> make_promise_with_continuation(Continuation continuation);
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_PROMISE_INTERNAL_H_
+#endif // LIB_FIT_PROMISE_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/result.h b/pkg/fit/include/lib/fit/result.h
index eb89baf..cb64ea7 100644
--- a/pkg/fit/include/lib/fit/result.h
+++ b/pkg/fit/include/lib/fit/result.h
@@ -11,6 +11,7 @@
#include <type_traits>
#include <utility>
+#include "in_place_internal.h"
#include "traits.h"
#include "variant.h"
@@ -20,66 +21,58 @@
struct pending_result final {};
// Returns an value that represents a pending result.
-constexpr inline pending_result pending() {
- return pending_result{};
-}
+constexpr inline pending_result pending() { return pending_result{}; }
// Represents the result of a successful task.
template <typename V = void>
struct ok_result final {
- using value_type = V;
+ using value_type = V;
- explicit constexpr ok_result(V value)
- : value(std::move(value)) {}
+ explicit constexpr ok_result(V value) : value(std::move(value)) {}
- V value;
+ V value;
};
template <>
struct ok_result<void> {
- using value_type = void;
+ using value_type = void;
};
// Wraps the result of a successful task as an |ok_result<T>|.
template <typename V>
constexpr inline ok_result<V> ok(V value) {
- return ok_result<V>(std::move(value));
+ return ok_result<V>(std::move(value));
}
-constexpr inline ok_result<> ok() {
- return ok_result<>{};
-}
+constexpr inline ok_result<> ok() { return ok_result<>{}; }
// Represents the result of a failed task.
template <typename E = void>
struct error_result final {
- using error_type = E;
+ using error_type = E;
- explicit constexpr error_result(E error)
- : error(std::move(error)) {}
+ explicit constexpr error_result(E error) : error(std::move(error)) {}
- E error;
+ E error;
};
template <>
struct error_result<void> {
- using error_type = void;
+ using error_type = void;
};
// Wraps the result of a failed task as an |error_result<T>|.
template <typename E>
constexpr inline error_result<E> error(E error) {
- return error_result<E>(std::move(error));
+ return error_result<E>(std::move(error));
}
-constexpr inline error_result<> error() {
- return error_result<>{};
-}
+constexpr inline error_result<> error() { return error_result<>{}; }
// Describes the status of a task's result.
enum class result_state {
- // The task is still in progress.
- pending,
- // The task completed successfully.
- ok,
- // The task failed.
- error
+ // The task is still in progress.
+ pending,
+ // The task completed successfully.
+ ok,
+ // The task failed.
+ error
};
// Represents the result of a task which may have succeeded, failed,
@@ -129,142 +122,123 @@
// }
template <typename V = void, typename E = void>
class result final {
-public:
- using value_type = V;
- using error_type = E;
+ public:
+ using value_type = V;
+ using error_type = E;
- // Creates a pending result.
- constexpr result() = default;
- constexpr result(pending_result) {}
+ // Creates a pending result.
+ constexpr result() = default;
+ constexpr result(pending_result) {}
- // Creates an ok result.
- constexpr result(ok_result<V> result)
- : state_(::fit::internal::in_place_index<1>, std::move(result)) {}
- template <typename OtherV,
- typename = std::enable_if_t<std::is_constructible<V, OtherV>::value>>
- constexpr result(ok_result<OtherV> other)
- : state_(::fit::internal::in_place_index<1>,
- fit::ok<V>(std::move(other.value))) {}
+ // Creates an ok result.
+ constexpr result(ok_result<V> result) : state_(in_place_index<1>, std::move(result)) {}
+ template <typename OtherV, typename = std::enable_if_t<std::is_constructible<V, OtherV>::value>>
+ constexpr result(ok_result<OtherV> other)
+ : state_(in_place_index<1>, fit::ok<V>(std::move(other.value))) {}
- // Creates an error result.
- constexpr result(error_result<E> result)
- : state_(::fit::internal::in_place_index<2>, std::move(result)) {}
- template <typename OtherE,
- typename = std::enable_if_t<std::is_constructible<E, OtherE>::value>>
- constexpr result(error_result<OtherE> other)
- : state_(::fit::internal::in_place_index<2>,
- fit::error<E>(std::move(other.error))) {}
+ // Creates an error result.
+ constexpr result(error_result<E> result) : state_(in_place_index<2>, std::move(result)) {}
+ template <typename OtherE, typename = std::enable_if_t<std::is_constructible<E, OtherE>::value>>
+ constexpr result(error_result<OtherE> other)
+ : state_(in_place_index<2>, fit::error<E>(std::move(other.error))) {}
- // Copies another result (if copyable).
- result(const result& other) = default;
+ // Copies another result (if copyable).
+ result(const result& other) = default;
- // Moves from another result, leaving the other one in a pending state.
- result(result&& other)
- : state_(std::move(other.state_)) {
- other.reset();
- }
+ // Moves from another result, leaving the other one in a pending state.
+ result(result&& other) noexcept : state_(std::move(other.state_)) { other.reset(); }
- ~result() = default;
+ ~result() = default;
- // Returns the state of the task's result: pending, ok, or error.
- constexpr result_state state() const {
- return static_cast<result_state>(state_.index());
- }
+ // Returns the state of the task's result: pending, ok, or error.
+ constexpr result_state state() const { return static_cast<result_state>(state_.index()); }
- // Returns true if the result is not pending.
- constexpr explicit operator bool() const {
- return !is_pending();
- }
+ // Returns true if the result is not pending.
+ constexpr explicit operator bool() const { return !is_pending(); }
- // Returns true if the task is still in progress.
- constexpr bool is_pending() const {
- return state() == result_state::pending;
- }
+ // Returns true if the task is still in progress.
+ constexpr bool is_pending() const { return state() == result_state::pending; }
- // Returns true if the task succeeded.
- constexpr bool is_ok() const {
- return state() == result_state::ok;
- }
+ // Returns true if the task succeeded.
+ constexpr bool is_ok() const { return state() == result_state::ok; }
- // Returns true if the task failed.
- constexpr bool is_error() const {
- return state() == result_state::error;
- }
+ // Returns true if the task failed.
+ constexpr bool is_error() const { return state() == result_state::error; }
- // Gets the result's value.
- // Asserts that the result's state is |fit::result_state::ok|.
- template <typename R = V,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- constexpr R& value() {
- return state_.template get<1>().value;
- }
- template <typename R = V,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- constexpr const R& value() const {
- return state_.template get<1>().value;
- }
+ // Gets the result's value.
+ // Asserts that the result's state is |fit::result_state::ok|.
+ template <typename R = V, typename = std::enable_if_t<!std::is_void<R>::value>>
+ constexpr R& value() {
+ return state_.template get<1>().value;
+ }
+ template <typename R = V, typename = std::enable_if_t<!std::is_void<R>::value>>
+ constexpr const R& value() const {
+ return state_.template get<1>().value;
+ }
- // Takes the result's value, leaving it in a pending state.
- // Asserts that the result's state is |fit::result_state::ok|.
- template <typename R = V,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R take_value() {
- auto value = std::move(state_.template get<1>().value);
- reset();
- return value;
- }
- ok_result<V> take_ok_result() {
- auto result = std::move(state_.template get<1>());
- reset();
- return result;
- }
+ // Takes the result's value, leaving it in a pending state.
+ // Asserts that the result's state is |fit::result_state::ok|.
+ template <typename R = V, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R take_value() {
+ auto value = std::move(state_.template get<1>().value);
+ reset();
+ return value;
+ }
+ ok_result<V> take_ok_result() {
+ auto result = std::move(state_.template get<1>());
+ reset();
+ return result;
+ }
- // Gets a reference to the result's error.
- // Asserts that the result's state is |fit::result_state::error|.
- template <typename R = E,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- constexpr R& error() {
- return state_.template get<2>().error;
- }
- template <typename R = E,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- constexpr const R& error() const {
- return state_.template get<2>().error;
- }
+ // Gets a reference to the result's error.
+ // Asserts that the result's state is |fit::result_state::error|.
+ template <typename R = E, typename = std::enable_if_t<!std::is_void<R>::value>>
+ constexpr R& error() {
+ return state_.template get<2>().error;
+ }
+ template <typename R = E, typename = std::enable_if_t<!std::is_void<R>::value>>
+ constexpr const R& error() const {
+ return state_.template get<2>().error;
+ }
- // Takes the result's error, leaving it in a pending state.
- // Asserts that the result's state is |fit::result_state::error|.
- template <typename R = E,
- typename = std::enable_if_t<!std::is_void<R>::value>>
- R take_error() {
- auto error = std::move(state_.template get<2>().error);
- reset();
- return error;
- }
- error_result<E> take_error_result() {
- auto result = std::move(state_.template get<2>());
- reset();
- return result;
- }
+ // Takes the result's error, leaving it in a pending state.
+ // Asserts that the result's state is |fit::result_state::error|.
+ template <typename R = E, typename = std::enable_if_t<!std::is_void<R>::value>>
+ R take_error() {
+ auto error = std::move(state_.template get<2>().error);
+ reset();
+ return error;
+ }
+ error_result<E> take_error_result() {
+ auto result = std::move(state_.template get<2>());
+ reset();
+ return result;
+ }
- // Assigns from another result (if copyable).
- result& operator=(const result& other) = default;
+ // Assigns from another result (if copyable).
+ result& operator=(const result& other) = default;
- // Moves from another result, leaving the other one in a pending state.
- result& operator=(result&& other) {
- state_ = std::move(other.state_);
- other.reset();
- return *this;
- }
+ // Moves from another result, leaving the other one in a pending state.
+ result& operator=(result&& other) {
+ state_ = std::move(other.state_);
+ other.reset();
+ return *this;
+ }
-private:
- void reset() { state_.template emplace<0>(); }
+ // Swaps results.
+ void swap(result& other) { state_.swap(other.state_); }
- ::fit::internal::variant<
- ::fit::internal::monostate, ok_result<V>, error_result<E>>
- state_;
+ private:
+ void reset() { state_.template emplace<0>(); }
+
+ variant<monostate, ok_result<V>, error_result<E>> state_;
};
-} // namespace fit
+template <typename V, typename E>
+void swap(result<V, E>& a, result<V, E>& b) {
+ a.swap(b);
+}
-#endif // LIB_FIT_RESULT_H_
+} // namespace fit
+
+#endif // LIB_FIT_RESULT_H_
diff --git a/pkg/fit/include/lib/fit/scheduler.h b/pkg/fit/include/lib/fit/scheduler.h
index d4e16ba..99283e2 100644
--- a/pkg/fit/include/lib/fit/scheduler.h
+++ b/pkg/fit/include/lib/fit/scheduler.h
@@ -21,134 +21,133 @@
// Instances of this object are not thread-safe. Its client is responsible
// for providing all necessary synchronization.
class scheduler final {
-public:
- using task_queue = std::queue<pending_task>;
- using ref_count = uint32_t;
+ public:
+ using task_queue = std::queue<pending_task>;
+ using ref_count_type = uint32_t;
- scheduler();
- ~scheduler();
+ scheduler();
+ ~scheduler();
- // Adds a task to the runnable queue.
- //
- // Preconditions:
- // - |task| must be non-empty
- void schedule_task(pending_task task);
+ // Adds a task to the runnable queue.
+ //
+ // Preconditions:
+ // - |task| must be non-empty
+ void schedule_task(pending_task task);
- // Obtains a new ticket with a ref-count of |initial_refs|.
- // The executor must eventually call |finalize_ticket()| to update the
- // state of the ticket.
- //
- // Preconditions:
- // - |initial_refs| must be at least 1
- suspended_task::ticket obtain_ticket(ref_count initial_refs = 1);
+ // Obtains a new ticket with a ref-count of |initial_refs|.
+ // The executor must eventually call |finalize_ticket()| to update the
+ // state of the ticket.
+ //
+ // Preconditions:
+ // - |initial_refs| must be at least 1
+ suspended_task::ticket obtain_ticket(ref_count_type initial_refs = 1);
- // Updates a ticket after one run of a task's continuation according
- // to the state of the task after its run. The executor must call this
- // method after calling |obtain_ticket()| to indicate the disposition of
- // the task for which the ticket was obtained.
- //
- // Passing an empty |task| indicates that the task has completed so it
- // does not need to be resumed.
- //
- // Passing a non-empty |task| indicates that the task returned a pending
- // result and may need to be suspended depending on the current state
- // of the ticket.
- // - If the ticket has already been resumed, moves |task| into the
- // runnable queue.
- // - Otherwise, if the ticket still has a non-zero ref-count, moves |task|
- // into the suspended task table.
- // - Otherwise, considers the task abandoned and the caller retains
- // ownership of |task|.
- //
- // Preconditions:
- // - |task| must be non-null (may be empty)
- // - the ticket must not have already been finalized
- void finalize_ticket(suspended_task::ticket ticket, pending_task* task);
+ // Updates a ticket after one run of a task's continuation according
+ // to the state of the task after its run. The executor must call this
+ // method after calling |obtain_ticket()| to indicate the disposition of
+ // the task for which the ticket was obtained.
+ //
+ // Passing an empty |task| indicates that the task has completed so it
+ // does not need to be resumed.
+ //
+ // Passing a non-empty |task| indicates that the task returned a pending
+ // result and may need to be suspended depending on the current state
+ // of the ticket.
+ // - If the ticket has already been resumed, moves |task| into the
+ // runnable queue.
+ // - Otherwise, if the ticket still has a non-zero ref-count, moves |task|
+ // into the suspended task table.
+ // - Otherwise, considers the task abandoned and the caller retains
+ // ownership of |task|.
+ //
+ // Preconditions:
+ // - |task| must be non-null (may be empty)
+ // - the ticket must not have already been finalized
+ void finalize_ticket(suspended_task::ticket ticket, pending_task* task);
- // Increments the ticket's ref-count.
- //
- // Preconditions:
- // - the ticket's ref-count must be non-zero (positive)
- void duplicate_ticket(suspended_task::ticket ticket);
+ // Increments the ticket's ref-count.
+ //
+ // Preconditions:
+ // - the ticket's ref-count must be non-zero (positive)
+ void duplicate_ticket(suspended_task::ticket ticket);
- // Decrements the ticket's ref-count.
- //
- // If the task's ref-count reaches 0 and has an associated task that
- // has not already been resumed, returns the associated task back
- // to the caller.
- // Otherwise, returns an empty task.
- //
- // Preconditions:
- // - the ticket's ref-count must be non-zero (positive)
- pending_task release_ticket(suspended_task::ticket ticket);
+ // Decrements the ticket's ref-count.
+ //
+ // If the task's ref-count reaches 0 and has an associated task that
+ // has not already been resumed, returns the associated task back
+ // to the caller.
+ // Otherwise, returns an empty task.
+ //
+ // Preconditions:
+ // - the ticket's ref-count must be non-zero (positive)
+ pending_task release_ticket(suspended_task::ticket ticket);
- // Resumes a task and decrements the ticket's ref-count.
- //
- // If the ticket has an associated task that has not already been resumed,
- // moves its associated task to the runnable queue and returns true.
- // Otherwise, returns false.
- //
- // Preconditions:
- // - the ticket's ref-count must be non-zero (positive)
- bool resume_task_with_ticket(suspended_task::ticket ticket);
+ // Resumes a task and decrements the ticket's ref-count.
+ //
+ // If the ticket has an associated task that has not already been resumed,
+ // moves its associated task to the runnable queue and returns true.
+ // Otherwise, returns false.
+ //
+ // Preconditions:
+ // - the ticket's ref-count must be non-zero (positive)
+ bool resume_task_with_ticket(suspended_task::ticket ticket);
- // Takes all tasks in the runnable queue.
- //
- // Preconditions:
- // - |tasks| must be non-null and empty
- void take_runnable_tasks(task_queue* tasks);
+ // Takes all tasks in the runnable queue.
+ //
+ // Preconditions:
+ // - |tasks| must be non-null and empty
+ void take_runnable_tasks(task_queue* tasks);
- // Takes all remaining tasks, regardless of whether they are runnable
- // or suspended.
- //
- // This operation is useful when shutting down an executor.
- //
- // Preconditions:
- // - |tasks| must be non-null and empty
- void take_all_tasks(task_queue* tasks);
+ // Takes all remaining tasks, regardless of whether they are runnable
+ // or suspended.
+ //
+ // This operation is useful when shutting down an executor.
+ //
+ // Preconditions:
+ // - |tasks| must be non-null and empty
+ void take_all_tasks(task_queue* tasks);
- // Returns true if there are any runnable tasks.
- bool has_runnable_tasks() const { return !runnable_tasks_.empty(); }
+ // Returns true if there are any runnable tasks.
+ bool has_runnable_tasks() const { return !runnable_tasks_.empty(); }
- // Returns true if there are any suspended tasks that have yet to
- // be resumed.
- bool has_suspended_tasks() const { return suspended_task_count_ > 0; }
+ // Returns true if there are any suspended tasks that have yet to
+ // be resumed.
+ bool has_suspended_tasks() const { return suspended_task_count_ > 0; }
- // Returns true if there are any tickets that have yet to be finalized,
- // released, or resumed.
- bool has_outstanding_tickets() const { return !tickets_.empty(); }
+ // Returns true if there are any tickets that have yet to be finalized,
+ // released, or resumed.
+ bool has_outstanding_tickets() const { return !tickets_.empty(); }
- scheduler(const scheduler&) = delete;
- scheduler(scheduler&&) = delete;
- scheduler& operator=(const scheduler&) = delete;
- scheduler& operator=(scheduler&&) = delete;
+ scheduler(const scheduler&) = delete;
+ scheduler(scheduler&&) = delete;
+ scheduler& operator=(const scheduler&) = delete;
+ scheduler& operator=(scheduler&&) = delete;
-private:
- struct ticket_record {
- ticket_record(ref_count initial_refs)
- : ref_count(initial_refs), was_resumed(false) {}
+ private:
+ struct ticket_record {
+ ticket_record(ref_count_type initial_refs) : ref_count(initial_refs), was_resumed(false) {}
- // The current reference count.
- ref_count ref_count;
+ // The current reference count.
+ ref_count_type ref_count;
- // True if the task has been resumed using |resume_task_with_ticket()|.
- bool was_resumed;
+ // True if the task has been resumed using |resume_task_with_ticket()|.
+ bool was_resumed;
- // The task is initially empty when the ticket is obtained.
- // It is later set to non-empty if the task needs to be suspended when
- // the ticket is finalized. It becomes empty again when the task
- // is moved into the runnable queue, released, or taken.
- pending_task task;
- };
- using ticket_map = std::map<suspended_task::ticket, ticket_record>;
+ // The task is initially empty when the ticket is obtained.
+ // It is later set to non-empty if the task needs to be suspended when
+ // the ticket is finalized. It becomes empty again when the task
+ // is moved into the runnable queue, released, or taken.
+ pending_task task;
+ };
+ using ticket_map = std::map<suspended_task::ticket, ticket_record>;
- task_queue runnable_tasks_;
- ticket_map tickets_;
- uint64_t suspended_task_count_ = 0;
- suspended_task::ticket next_ticket_ = 1;
+ task_queue runnable_tasks_;
+ ticket_map tickets_;
+ uint64_t suspended_task_count_ = 0;
+ suspended_task::ticket next_ticket_ = 1;
};
-} // namespace subtle
-} // namespace fit
+} // namespace subtle
+} // namespace fit
-#endif // LIB_FIT_SCHEDULER_H_
+#endif // LIB_FIT_SCHEDULER_H_
diff --git a/pkg/fit/include/lib/fit/scope.h b/pkg/fit/include/lib/fit/scope.h
new file mode 100644
index 0000000..21089b8
--- /dev/null
+++ b/pkg/fit/include/lib/fit/scope.h
@@ -0,0 +1,271 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_SCOPE_H_
+#define LIB_FIT_SCOPE_H_
+
+#include <assert.h>
+
+#include <atomic>
+#include <mutex>
+
+#include "promise.h"
+#include "thread_safety.h"
+
+namespace fit {
+
+// Provides a mechanism for binding promises to the lifetime of another object
+// such that they are destroyed before that object goes out of scope. It is
+// particularly useful for ensuring that the lifetime of a promise does not
+// exceed the lifetime of any variables that it has captured by reference.
+//
+// A scope is thread-safe but non-reentrant: it must not be destroyed while
+// any of its associated promises are running.
+//
+// EXAMPLE
+//
+// Define a |fit::scope| as a member of the object to whose lifetime the
+// promises should be bound.
+//
+// // We mark this class final because its destructor has side-effects
+// // that rely on the order of destruction. If this object were
+// // subclassed there would be a possibility for promises bound to its
+// // scope to inadvertently access the subclass's state while the object
+// // was being destroyed.
+// class accumulator final {
+// public:
+// accumulator() = default;
+// ~accumulator() = default;
+//
+// fit::promise<int> accumulate(int value);
+//
+// private:
+// int prior_total_ = 0;
+//
+// // This member is last so that the scope is exited before all
+// // other members of the object are destroyed. Alternately, we
+// // could enforce this ordering by explicitly invoking
+// // |fit::scope::exit()| where appropriate.
+// fit::scope scope_;
+// };
+//
+// Use |fit::promise::wrap_with()| to wrap up promises that capture pointers
+// to the object. In this example, the captured pointer is "this".
+//
+// fit::promise<int> accumulator::accumulate(int value) {
+// return fit::make_promise([this, value] {
+// prior_total_ += value;
+// return fit::ok(prior_total_);
+// }).wrap_with(scope_); /* binding to scope happens here */
+// }
+//
+class scope final {
+ public:
+ // Creates a new scope.
+ scope();
+
+ // Exits the scope and destroys all of its wrapped promises.
+ // Asserts that no promises are currently running.
+ ~scope();
+
+ // Returns true if the scope has been exited.
+ //
+ // This method is thread-safe.
+ bool exited() const { return state_->exited(); }
+
+ // Exits the scope and destroys all of its wrapped promises.
+ // Assets that no promises are currently running.
+ //
+ // This method is thread-safe.
+ void exit() { return state_->exit(false /*scope_was_destroyed*/); }
+
+ // Returns a promise which wraps the specified |promise| and binds the
+ // promise to this scope.
+ //
+ // The specified promise will automatically be destroyed when its wrapper
+ // is destroyed or when the scope is exited. If the scope has already
+ // exited then the wrapped promise will be immediately destroyed.
+ //
+ // When the returned promise is invoked before the scope is exited,
+ // the promise that it wraps will be invoked as usual. However, when
+ // the returned promise is invoked after the scope is exited, it
+ // immediately returns a pending result (since the promise that it
+ // previously wrapped has already been destroyed). By returning a
+ // pending result, the return promise effectively indicates to the
+ // executor that the task has been "abandoned" due to the scope being
+ // exited.
+ //
+ // This method is thread-safe.
+ template <typename Promise>
+ decltype(auto) wrap(Promise promise) {
+ assert(promise);
+ return fit::make_promise_with_continuation(scoped_continuation<Promise>(
+ state_->adopt_promise(new promise_holder<Promise>(std::move(promise)))));
+ }
+
+ scope(const scope&) = delete;
+ scope(scope&&) = delete;
+ scope& operator=(const scope&) = delete;
+ scope& operator=(scope&&) = delete;
+
+ private:
+ class state;
+ class promise_holder_base;
+
+ // Holds a reference to a promise that is owned by the state.
+ class promise_handle final {
+ public:
+ promise_handle() = default;
+
+ private:
+ // |state| and |promise_holder| belong to the state object.
+ // Invariant: If |promise_holder| is non-null then |state| is
+ // also non-null.
+ friend state;
+ promise_handle(state* state, promise_holder_base* promise_holder)
+ : state_(state), promise_holder_(promise_holder) {}
+
+ state* state_ = nullptr;
+ promise_holder_base* promise_holder_ = nullptr;
+ };
+
+ // Holds the shared state of the scope.
+ // This object is destroyed once the scope and all of its promises
+ // have been destroyed.
+ class state final {
+ public:
+ state();
+ ~state();
+
+ // The following methods are called from the |scope|.
+
+ bool exited() const;
+ void exit(bool scope_was_destroyed);
+
+ // The following methods are called from the |scoped_continuation|.
+
+ // Links a promise to the scope's lifecycle such that it will be
+ // destroyed when the scope is exited. Returns a handle that may
+ // be used to access the promise later.
+ // The state takes ownership of the promise.
+ promise_handle adopt_promise(promise_holder_base* promise_holder);
+
+ // Unlinks a promise from the scope's lifecycle given its handle
+ // and causes the underlying promise to be destroyed if it hasn't
+ // already been destroyed due to the scope exiting.
+ // Does nothing if the handle was default-initialized.
+ static void drop_promise(promise_handle promise_handle);
+
+ // Acquires a promise given its handle.
+ // Returns nullptr if the handle was default-initialized or if
+ // the scope exited, meaning that the promise was not acquired.
+ // The promise must be released before it can be acquired again.
+ static promise_holder_base* try_acquire_promise(promise_handle promise_handle);
+
+ // Releases a promise that was successfully acquired.
+ static void release_promise(promise_handle promise_handle);
+
+ state(const state&) = delete;
+ state(state&&) = delete;
+ state& operator=(const state&) = delete;
+ state& operator=(state&&) = delete;
+
+ private:
+ bool should_delete_self() const FIT_REQUIRES(mutex_) {
+ return scope_was_destroyed_ && promise_handle_count_ == 0;
+ }
+
+ static constexpr uint64_t scope_exited = static_cast<uint64_t>(1u) << 63;
+
+ // Tracks of the number of promises currently running ("acquired").
+ // The top bit is set when the scope is exited, at which point no
+ // new promises can be acquired. After exiting, the count can
+ // be incremented transiently but is immediately decremented again
+ // until all promise handles have been released. Once no promise
+ // handles remain, the count will equal |scope_exited| and will not
+ // change again.
+ std::atomic_uint64_t acquired_promise_count_{0};
+
+ mutable std::mutex mutex_;
+ bool scope_was_destroyed_ FIT_GUARDED(mutex_) = false;
+ uint64_t promise_handle_count_ FIT_GUARDED(mutex_) = 0;
+ promise_holder_base* head_promise_holder_ FIT_GUARDED(mutex_) = nullptr;
+ };
+
+ // Base type for managing the lifetime of a promise of any type.
+ // It is owned by the state and retained indirectly by the continuation
+ // using a |promise_handle|.
+ class promise_holder_base {
+ public:
+ promise_holder_base() = default;
+ virtual ~promise_holder_base() = default;
+
+ promise_holder_base(const promise_holder_base&) = delete;
+ promise_holder_base(promise_holder_base&&) = delete;
+ promise_holder_base& operator=(const promise_holder_base&) = delete;
+ promise_holder_base& operator=(promise_holder_base&&) = delete;
+
+ private:
+ // |next| and |prev| belong to the state object.
+ friend class state;
+ promise_holder_base* next = nullptr;
+ promise_holder_base* prev = nullptr;
+ };
+
+ // Holder for a promise of a particular type.
+ template <typename Promise>
+ class promise_holder final : public promise_holder_base {
+ public:
+ explicit promise_holder(Promise promise) : promise(std::move(promise)) {}
+ ~promise_holder() override = default;
+
+ Promise promise;
+ };
+
+ // Wraps a promise whose lifetime is managed by the scope.
+ template <typename Promise>
+ class scoped_continuation final {
+ public:
+ explicit scoped_continuation(promise_handle promise_handle) : promise_handle_(promise_handle) {}
+
+ scoped_continuation(scoped_continuation&& other) : promise_handle_(other.promise_handle_) {
+ other.promise_handle_ = promise_handle{};
+ }
+
+ ~scoped_continuation() { state::drop_promise(promise_handle_); }
+
+ typename Promise::result_type operator()(context& context) {
+ typename Promise::result_type result;
+ auto holder =
+ static_cast<promise_holder<Promise>*>(state::try_acquire_promise(promise_handle_));
+ if (holder) {
+ result = holder->promise(context);
+ state::release_promise(promise_handle_);
+ }
+ return result;
+ }
+
+ scoped_continuation& operator=(scoped_continuation&& other) {
+ if (this != &other) {
+ state::drop_promise(promise_handle_);
+ promise_handle_ = other.promise_handle_;
+ other.promise_handle_ = promise_handle{};
+ }
+ return *this;
+ }
+
+ scoped_continuation(const scoped_continuation&) = delete;
+ scoped_continuation& operator=(const scoped_continuation&) = delete;
+
+ private:
+ promise_handle promise_handle_;
+ };
+
+ // The scope's shared state.
+ state* const state_;
+};
+
+} // namespace fit
+
+#endif // LIB_FIT_SCOPE_H_
diff --git a/pkg/fit/include/lib/fit/sequencer.h b/pkg/fit/include/lib/fit/sequencer.h
index 509cd8e..888df7b 100644
--- a/pkg/fit/include/lib/fit/sequencer.h
+++ b/pkg/fit/include/lib/fit/sequencer.h
@@ -33,53 +33,52 @@
// // sequential work with the sequencer.
// fit::promise<> perform_complex_task() {
// return fit::make_promise([] { /* do sequential work */ })
-// .then([] (fit::result<> result) { /* this will also be wrapped */ })
+// .then([] (fit::result<>& result) { /* this will also be wrapped */ })
// .wrap_with(seq)
-// .then([] (fit::result<> result) { /* do more work */ });
+// .then([] (fit::result<>& result) { /* do more work */ });
// }
//
class sequencer final {
-public:
- sequencer();
- ~sequencer();
+ public:
+ sequencer();
+ ~sequencer();
- // Returns a new promise which will invoke |promise| after all previously
- // enqueued promises on this sequencer have completed or been abandoned.
- //
- // This method is thread-safe.
- template <typename Promise>
- decltype(auto) wrap(Promise promise) {
- assert(promise);
+ // Returns a new promise which will invoke |promise| after all previously
+ // enqueued promises on this sequencer have completed or been abandoned.
+ //
+ // This method is thread-safe.
+ template <typename Promise>
+ decltype(auto) wrap(Promise promise) {
+ assert(promise);
- fit::bridge<> bridge;
- fit::consumer<> prior = swap_prior(std::move(bridge.consumer()));
- return prior.promise_or(fit::ok())
- .then([promise = std::move(promise),
- completer = std::move(bridge.completer())](
- fit::context& context, fit::result<>) mutable {
- // This handler will run once the completer associated
- // with the |prior| promise is abandoned. Once the promise
- // has finished, both the promise and completer will be
- // destroyed thereby causing the next promise chained onto
- // the |bridge|'s associated consumer to become runnable.
- return promise(context);
- });
- }
+ fit::bridge<> bridge;
+ fit::consumer<> prior = swap_prior(std::move(bridge.consumer));
+ return prior.promise_or(fit::ok()).then(
+ [promise = std::move(promise), completer = std::move(bridge.completer)](
+ fit::context& context, const fit::result<>&) mutable {
+ // This handler will run once the completer associated
+ // with the |prior| promise is abandoned. Once the promise
+ // has finished, both the promise and completer will be
+ // destroyed thereby causing the next promise chained onto
+ // the |bridge|'s associated consumer to become runnable.
+ return promise(context);
+ });
+ }
- sequencer(const sequencer&) = delete;
- sequencer(sequencer&&) = delete;
- sequencer& operator=(const sequencer&) = delete;
- sequencer& operator=(sequencer&&) = delete;
+ sequencer(const sequencer&) = delete;
+ sequencer(sequencer&&) = delete;
+ sequencer& operator=(const sequencer&) = delete;
+ sequencer& operator=(sequencer&&) = delete;
-private:
- fit::consumer<> swap_prior(fit::consumer<> new_prior);
+ private:
+ fit::consumer<> swap_prior(fit::consumer<> new_prior);
- std::mutex mutex_;
+ std::mutex mutex_;
- // Holds the consumption capability of the most recently wrapped promise.
- fit::consumer<> prior_ FIT_GUARDED(mutex_);
+ // Holds the consumption capability of the most recently wrapped promise.
+ fit::consumer<> prior_ FIT_GUARDED(mutex_);
};
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_SEQUENCER_H_
+#endif // LIB_FIT_SEQUENCER_H_
diff --git a/pkg/fit/include/lib/fit/single_threaded_executor.h b/pkg/fit/include/lib/fit/single_threaded_executor.h
index 7ec4875..826df83 100644
--- a/pkg/fit/include/lib/fit/single_threaded_executor.h
+++ b/pkg/fit/include/lib/fit/single_threaded_executor.h
@@ -20,66 +20,65 @@
//
// See documentation of |fit::promise| for more information.
class single_threaded_executor final : public executor {
-public:
- single_threaded_executor();
+ public:
+ single_threaded_executor();
- // Destroys the executor along with all of its remaining scheduled tasks
- // that have yet to complete.
- ~single_threaded_executor() override;
+ // Destroys the executor along with all of its remaining scheduled tasks
+ // that have yet to complete.
+ ~single_threaded_executor() override;
- // Schedules a task for eventual execution by the executor.
- //
- // This method is thread-safe.
- void schedule_task(pending_task task) override;
+ // Schedules a task for eventual execution by the executor.
+ //
+ // This method is thread-safe.
+ void schedule_task(pending_task task) override;
- // Runs all scheduled tasks (including additional tasks scheduled while
- // they run) until none remain.
- //
- // This method is thread-safe but must only be called on at most one
- // thread at a time.
- void run();
+ // Runs all scheduled tasks (including additional tasks scheduled while
+ // they run) until none remain.
+ //
+ // This method is thread-safe but must only be called on at most one
+ // thread at a time.
+ void run();
- single_threaded_executor(const single_threaded_executor&) = delete;
- single_threaded_executor(single_threaded_executor&&) = delete;
- single_threaded_executor& operator=(const single_threaded_executor&) = delete;
- single_threaded_executor& operator=(single_threaded_executor&&) = delete;
+ single_threaded_executor(const single_threaded_executor&) = delete;
+ single_threaded_executor(single_threaded_executor&&) = delete;
+ single_threaded_executor& operator=(const single_threaded_executor&) = delete;
+ single_threaded_executor& operator=(single_threaded_executor&&) = delete;
-private:
- class dispatcher_impl;
+ private:
+ class dispatcher_impl;
- // The task context for tasks run by the executor.
- class context_impl final : public context {
- public:
- explicit context_impl(single_threaded_executor* executor);
- ~context_impl() override;
+ // The task context for tasks run by the executor.
+ class context_impl final : public context {
+ public:
+ explicit context_impl(single_threaded_executor* executor);
+ ~context_impl() override;
- single_threaded_executor* executor() const override;
- suspended_task suspend_task() override;
+ single_threaded_executor* executor() const override;
+ suspended_task suspend_task() override;
- private:
- single_threaded_executor* const executor_;
- };
+ private:
+ single_threaded_executor* const executor_;
+ };
- context_impl context_;
- dispatcher_impl* const dispatcher_;
+ context_impl context_;
+ dispatcher_impl* const dispatcher_;
};
// Creates a new |fit::single_threaded_executor|, schedules a promise as a task,
// runs all of the executor's scheduled tasks until none remain, then returns
// the promise's result.
template <typename Continuation>
-static typename promise_impl<Continuation>::result_type
-run_single_threaded(promise_impl<Continuation> promise) {
- using result_type = typename promise_impl<Continuation>::result_type;
- single_threaded_executor exec;
- result_type saved_result;
- exec.schedule_task(promise.then([&saved_result](result_type result) {
- saved_result = std::move(result);
- }));
- exec.run();
- return saved_result;
+static typename promise_impl<Continuation>::result_type run_single_threaded(
+ promise_impl<Continuation> promise) {
+ using result_type = typename promise_impl<Continuation>::result_type;
+ single_threaded_executor exec;
+ result_type saved_result;
+ exec.schedule_task(
+ promise.then([&saved_result](result_type& result) { saved_result = std::move(result); }));
+ exec.run();
+ return saved_result;
}
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_SINGLE_THREADED_EXECUTOR_H_
+#endif // LIB_FIT_SINGLE_THREADED_EXECUTOR_H_
diff --git a/pkg/fit/include/lib/fit/source_location.h b/pkg/fit/include/lib/fit/source_location.h
new file mode 100644
index 0000000..b723621
--- /dev/null
+++ b/pkg/fit/include/lib/fit/source_location.h
@@ -0,0 +1,102 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#ifndef LIB_FIT_SOURCE_LOCATION_H_
+#define LIB_FIT_SOURCE_LOCATION_H_
+
+#if __cplusplus > 201703L
+#include <version>
+#endif
+
+#if defined(__cpp_lib_source_location) && __cpp_lib_source_location && \
+ !defined(FORCE_FIT_SOURCE_LOCATION)
+
+// In C++20 fit::source_location should simply be an alias for std::source_location.
+
+#include <source_location>
+
+namespace fit {
+
+using std::source_location;
+
+} // namespace fit
+
+#else
+
+#include <cstdint>
+
+namespace fit {
+
+// Polyfill implementation of std::source_location.
+class source_location {
+ struct values {
+ constexpr explicit values(std::uint_least32_t line, std::uint_least32_t column,
+ const char* file_name, const char* function_name)
+ : line{line}, column{column}, file_name{file_name}, function_name{function_name} {}
+
+ std::uint_least32_t line;
+ std::uint_least32_t column;
+ const char* file_name;
+ const char* function_name;
+ };
+
+ public:
+ constexpr source_location() noexcept {} // LLVM bug 36684
+ source_location(const source_location& other) = default;
+ source_location(source_location&& other) noexcept = default;
+ ~source_location() = default;
+
+#define LIB_FIT_SOURCE_LOCATION_LINE (0)
+#define LIB_FIT_SOURCE_LOCATION_COLUMN (0)
+#define LIB_FIT_SOURCE_LOCATION_FILE ("")
+#define LIB_FIT_SOURCE_LOCATION_FUNCTION ("")
+
+#if defined(__has_builtin)
+#if __has_builtin(__builtin_LINE)
+#undef LIB_FIT_SOURCE_LOCATION_LINE
+#define LIB_FIT_SOURCE_LOCATION_LINE (__builtin_LINE())
+#endif
+#if __has_builtin(__builtin_COLUMN)
+#undef LIB_FIT_SOURCE_LOCATION_COLUMN
+#define LIB_FIT_SOURCE_LOCATION_COLUMN (__builtin_COLUMN())
+#endif
+#if __has_builtin(__builtin_FILE)
+#undef LIB_FIT_SOURCE_LOCATION_FILE
+#define LIB_FIT_SOURCE_LOCATION_FILE (__builtin_FILE())
+#endif
+#if __has_builtin(__builtin_FUNCTION)
+#undef LIB_FIT_SOURCE_LOCATION_FUNCTION
+#define LIB_FIT_SOURCE_LOCATION_FUNCTION (__builtin_FUNCTION())
+#endif
+#endif
+
+ static constexpr source_location current(
+ values value = values{LIB_FIT_SOURCE_LOCATION_LINE, LIB_FIT_SOURCE_LOCATION_COLUMN,
+ LIB_FIT_SOURCE_LOCATION_FILE, LIB_FIT_SOURCE_LOCATION_FUNCTION}) {
+ return source_location{value};
+ }
+
+#undef LIB_FIT_SOURCE_LOCATION_LINE
+#undef LIB_FIT_SOURCE_LOCATION_COLUMN
+#undef LIB_FIT_SOURCE_LOCATION_FILE
+#undef LIB_FIT_SOURCE_LOCATION_FUNCTION
+
+ constexpr std::uint_least32_t line() const noexcept { return values_.line; }
+
+ constexpr std::uint_least32_t column() const noexcept { return values_.column; }
+
+ constexpr const char* file_name() const noexcept { return values_.file_name; }
+
+ constexpr const char* function_name() const noexcept { return values_.function_name; }
+
+ private:
+ constexpr explicit source_location(values values) : values_{values} {}
+
+ values values_{0, 0, "", ""};
+};
+
+} // namespace fit
+
+#endif
+
+#endif // LIB_FIT_SOURCE_LOCATION_H_
diff --git a/pkg/fit/include/lib/fit/storage_internal.h b/pkg/fit/include/lib/fit/storage_internal.h
new file mode 100644
index 0000000..8986772
--- /dev/null
+++ b/pkg/fit/include/lib/fit/storage_internal.h
@@ -0,0 +1,846 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_STORAGE_INTERNAL_H_
+#define LIB_FIT_STORAGE_INTERNAL_H_
+
+#include <cstdint>
+#include <limits>
+#include <type_traits>
+
+#include "utility_internal.h"
+
+namespace fit {
+namespace internal {
+
+// Type tag to select overloads based on type T.
+template <typename T>
+struct type_tag {
+ using type = T;
+};
+
+// Type tag to select overloads based on index Index.
+template <size_t Index>
+struct index_tag {
+ static constexpr size_t index = Index;
+};
+
+// Type tag to select trivial initialization.
+enum trivial_init_t { trivial_init_v };
+
+// Type tag to select default initialization.
+enum default_init_t { default_init_v };
+
+// Type tag to select conditional initialization.
+enum maybe_init_t { maybe_init_v };
+
+// Represents the pair (T, Index) in the type system.
+template <typename T, size_t Index>
+struct type_index {};
+
+// Represents whether a type is trivially/non-trivially destructible.
+enum class destructor_class {
+ trivial,
+ non_trivial,
+};
+
+// Represents whether a type is trivially/non-trivially copyable.
+enum class copy_class {
+ trivial,
+ non_trivial,
+};
+
+// Represents whether a type is trivially/non-trivially movable.
+enum class move_class {
+ trivial,
+ non_trivial,
+};
+
+// Represents the full complement of move/copy/destruct classes for a type.
+template <destructor_class DestructorClass, copy_class CopyClass, move_class MoveClass>
+struct storage_class {};
+
+template <typename... Ts>
+using make_storage_class =
+ storage_class<is_trivially_destructible_v<Ts...> ? destructor_class::trivial
+ : destructor_class::non_trivial,
+ is_trivially_copyable_v<Ts...> ? copy_class::trivial : copy_class::non_trivial,
+ is_trivially_movable_v<Ts...> ? move_class::trivial : move_class::non_trivial>;
+
+// A trivial type for the empty alternative of union-based storage.
+struct empty_type {};
+
+// Index type used to track the active variant. Tracking uses zero-based
+// indices. Empty is denoted by the maximum representable value.
+using index_type = size_t;
+
+// Index denoting that no user-specified variant is active. Take care not to
+// ODR-use this value.
+constexpr index_type empty_index = std::numeric_limits<index_type>::max();
+
+#ifdef NDEBUG
+#define FIT_INTERNAL_UNREACHABLE_OR_ABORT __builtin_unreachable
+#else
+#define FIT_INTERNAL_UNREACHABLE_OR_ABORT __builtin_abort
+#endif
+
+// Base type for lazy-initialized union storage types. This type implements a
+// recursive union of the element types in Ts. Specializations handle the
+// recursive and terminal cases, and the different storage requirements for
+// trivially/non-trivially destructible types.
+template <destructor_class, typename...>
+union storage_base;
+
+// Non-trivial terminal case.
+template <>
+union storage_base<destructor_class::non_trivial, type_index<empty_type, empty_index>> {
+ storage_base() : empty{} {}
+
+ template <typename... Args>
+ storage_base(type_tag<empty_type>, Args&&...) : empty{} {}
+ template <typename... Args>
+ storage_base(index_tag<empty_index>, Args&&...) : empty{} {}
+
+ // Non-trivial destructor.
+ ~storage_base() {}
+
+ storage_base(const storage_base&) = default;
+ storage_base(storage_base&&) = default;
+ storage_base& operator=(const storage_base&) = default;
+ storage_base& operator=(storage_base&&) = default;
+
+ void construct_at(size_t index, const storage_base&) {
+ if (index == empty_index) {
+ new (&empty) empty_type{};
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+ void construct_at(size_t index, storage_base&&) {
+ if (index == empty_index) {
+ new (&empty) empty_type{};
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ void assign_at(size_t index, const storage_base& other) {
+ if (index == empty_index) {
+ empty = other.empty;
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+ void assign_at(size_t index, storage_base&& other) {
+ if (index == empty_index) {
+ empty = std::move(other.empty);
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ void swap_at(size_t index, storage_base& other) {
+ if (index == empty_index) {
+ using std::swap;
+ swap(empty, other.empty);
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ template <typename... Args>
+ size_t construct(type_tag<empty_type>, Args&&...) {
+ new (&empty) empty_type{};
+ return empty_index;
+ }
+ template <typename... Args>
+ size_t construct(index_tag<empty_index>, Args&&...) {
+ new (&empty) empty_type{};
+ return empty_index;
+ }
+
+ void reset(size_t index) {
+ if (index == empty_index) {
+ empty.empty_type::~empty_type();
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ empty_type& get(type_tag<empty_type>) { return empty; }
+ const empty_type& get(type_tag<empty_type>) const { return empty; }
+ empty_type& get(index_tag<empty_index>) { return empty; }
+ const empty_type& get(index_tag<empty_index>) const { return empty; }
+
+ size_t index(type_tag<empty_type>) const { return empty_index; }
+
+ template <typename V>
+ bool visit(size_t, V&&) {
+ return false;
+ }
+ template <typename V>
+ bool visit(size_t, V&&) const {
+ return false;
+ }
+
+ empty_type empty;
+};
+
+// Trivial terminal case.
+template <>
+union storage_base<destructor_class::trivial, type_index<empty_type, empty_index>> {
+ constexpr storage_base() : empty{} {}
+
+ template <typename... Args>
+ constexpr storage_base(type_tag<empty_type>, Args&&...) : empty{} {}
+ template <typename... Args>
+ constexpr storage_base(index_tag<empty_index>, Args&&...) : empty{} {}
+
+ // Trivial destructor.
+ ~storage_base() = default;
+
+ constexpr storage_base(const storage_base&) = default;
+ constexpr storage_base(storage_base&&) = default;
+ constexpr storage_base& operator=(const storage_base&) = default;
+ constexpr storage_base& operator=(storage_base&&) = default;
+
+ constexpr void construct_at(size_t index, const storage_base&) {
+ if (index == empty_index) {
+ new (&empty) empty_type{};
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+ constexpr void construct_at(size_t index, storage_base&&) {
+ if (index == empty_index) {
+ new (&empty) empty_type{};
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ constexpr void assign_at(size_t index, const storage_base& other) {
+ if (index == empty_index) {
+ empty = other.empty;
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+ constexpr void assign_at(size_t index, storage_base&& other) {
+ if (index == empty_index) {
+ empty = std::move(other.empty);
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ constexpr void swap_at(size_t index, storage_base& other) {
+ if (index == empty_index) {
+ using std::swap;
+ swap(empty, other.empty);
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ template <typename... Args>
+ constexpr size_t construct(type_tag<empty_type>, Args&&...) {
+ new (&empty) empty_type{};
+ return empty_index;
+ }
+ template <typename... Args>
+ constexpr size_t construct(index_tag<empty_index>, Args&&...) {
+ new (&empty) empty_type{};
+ return empty_index;
+ }
+
+ constexpr void reset(size_t index) {
+ if (index == empty_index) {
+ empty.empty_type::~empty_type();
+ } else {
+ FIT_INTERNAL_UNREACHABLE_OR_ABORT();
+ }
+ }
+
+ constexpr empty_type& get(type_tag<empty_type>) { return empty; }
+ constexpr const empty_type& get(type_tag<empty_type>) const { return empty; }
+ constexpr empty_type& get(index_tag<empty_index>) { return empty; }
+ constexpr const empty_type& get(index_tag<empty_index>) const { return empty; }
+
+ constexpr size_t index(type_tag<empty_type>) const { return empty_index; }
+
+ template <typename V>
+ constexpr bool visit(size_t, V&&) {
+ return false;
+ }
+ template <typename V>
+ constexpr bool visit(size_t, V&&) const {
+ return false;
+ }
+
+ empty_type empty;
+};
+
+template <typename T, size_t Index, typename... Ts, size_t... Is>
+union storage_base<destructor_class::non_trivial, type_index<T, Index>, type_index<Ts, Is>...> {
+ storage_base() : empty{} {}
+
+ template <typename... Args>
+ storage_base(type_tag<T>, Args&&... args) : value(std::forward<Args>(args)...) {}
+ template <typename... Args>
+ storage_base(index_tag<Index>, Args&&... args) : value(std::forward<Args>(args)...) {}
+
+ template <typename U, typename... Args>
+ storage_base(type_tag<U>, Args&&... args) : rest(type_tag<U>{}, std::forward<Args>(args)...) {}
+ template <size_t OtherIndex, typename... Args>
+ storage_base(index_tag<OtherIndex>, Args&&... args)
+ : rest(index_tag<OtherIndex>{}, std::forward<Args>(args)...) {}
+
+ // Non-trivial destructor.
+ ~storage_base() {}
+
+ // Trival copy/move construction and assignment.
+ storage_base(const storage_base&) = default;
+ storage_base(storage_base&&) = default;
+ storage_base& operator=(const storage_base&) = default;
+ storage_base& operator=(storage_base&&) = default;
+
+ void construct_at(size_t index, const storage_base& other) {
+ if (index == Index) {
+ new (&value) T{other.value};
+ } else {
+ rest.construct_at(index, other.rest);
+ }
+ }
+ void construct_at(size_t index, storage_base&& other) {
+ if (index == Index) {
+ new (&value) T{std::move(other.value)};
+ } else {
+ rest.construct_at(index, std::move(other.rest));
+ }
+ }
+
+ void assign_at(size_t index, const storage_base& other) {
+ if (index == Index) {
+ value = other.value;
+ } else {
+ rest.assign_at(index, other.rest);
+ }
+ }
+ void assign_at(size_t index, storage_base&& other) {
+ if (index == Index) {
+ value = std::move(other.value);
+ } else {
+ rest.assign_at(index, std::move(other.rest));
+ }
+ }
+
+ void swap_at(size_t index, storage_base& other) {
+ if (index == Index) {
+ using std::swap;
+ swap(value, other.value);
+ } else {
+ rest.swap_at(index, other.rest);
+ }
+ }
+
+ template <typename... Args>
+ size_t construct(type_tag<T>, Args&&... args) {
+ new (&value) T(std::forward<Args>(args)...);
+ return Index;
+ }
+ template <typename U, typename... Args>
+ size_t construct(type_tag<U>, Args&&... args) {
+ return rest.construct(type_tag<U>{}, std::forward<Args>(args)...);
+ }
+ template <typename... Args>
+ size_t construct(index_tag<Index>, Args&&... args) {
+ new (&value) T(std::forward<Args>(args)...);
+ return Index;
+ }
+ template <size_t OtherIndex, typename... Args>
+ size_t construct(index_tag<OtherIndex>, Args&&... args) {
+ return rest.construct(index_tag<OtherIndex>{}, std::forward<Args>(args)...);
+ }
+
+ void reset(size_t index) {
+ if (index == Index) {
+ value.~T();
+ } else {
+ rest.reset(index);
+ }
+ }
+
+ T& get(type_tag<T>) { return value; }
+ const T& get(type_tag<T>) const { return value; }
+ template <typename U>
+ U& get(type_tag<U>) {
+ return rest.get(type_tag<U>{});
+ }
+ template <typename U>
+ const U& get(type_tag<U>) const {
+ return rest.get(type_tag<U>{});
+ }
+ T& get(index_tag<Index>) { return value; }
+ const T& get(index_tag<Index>) const { return value; }
+ template <size_t OtherIndex>
+ auto& get(index_tag<OtherIndex>) {
+ return rest.get(index_tag<OtherIndex>{});
+ }
+ template <size_t OtherIndex>
+ const auto& get(index_tag<OtherIndex>) const {
+ return rest.get(index_tag<OtherIndex>{});
+ }
+
+ size_t index(type_tag<T>) const { return Index; }
+ template <typename U>
+ size_t index(type_tag<U>) const {
+ return rest.index(type_tag<U>{});
+ }
+
+ template <typename V>
+ bool visit(size_t index, V&& visitor) {
+ if (index == Index) {
+ std::forward<V>(visitor)(type_tag<T>{}, index_tag<Index>{}, this);
+ return true;
+ } else {
+ return rest.visit(index, std::forward<V>(visitor));
+ }
+ }
+ template <typename V>
+ bool visit(size_t index, V&& visitor) const {
+ if (index == Index) {
+ std::forward<V>(visitor)(type_tag<T>{}, index_tag<Index>{}, this);
+ return true;
+ } else {
+ return rest.visit(index, std::forward<V>(visitor));
+ }
+ }
+
+ empty_type empty;
+ T value;
+ storage_base<destructor_class::non_trivial, type_index<Ts, Is>...> rest;
+};
+
+template <typename T, size_t Index, typename... Ts, size_t... Is>
+union storage_base<destructor_class::trivial, type_index<T, Index>, type_index<Ts, Is>...> {
+ constexpr storage_base() : empty{} {}
+
+ template <typename... Args>
+ constexpr storage_base(type_tag<T>, Args&&... args) : value(std::forward<Args>(args)...) {}
+ template <typename... Args>
+ constexpr storage_base(index_tag<Index>, Args&&... args) : value(std::forward<Args>(args)...) {}
+
+ template <typename U, typename... Args>
+ constexpr storage_base(type_tag<U>, Args&&... args)
+ : rest(type_tag<U>{}, std::forward<Args>(args)...) {}
+ template <size_t OtherIndex, typename... Args>
+ constexpr storage_base(index_tag<OtherIndex>, Args&&... args)
+ : rest(index_tag<OtherIndex>{}, std::forward<Args>(args)...) {}
+
+ // Trivial destructor.
+ ~storage_base() = default;
+
+ // Trival copy/move construction and assignment.
+ constexpr storage_base(const storage_base&) = default;
+ constexpr storage_base(storage_base&&) = default;
+ constexpr storage_base& operator=(const storage_base&) = default;
+ constexpr storage_base& operator=(storage_base&&) = default;
+
+ constexpr void construct_at(size_t index, const storage_base& other) {
+ if (index == Index) {
+ new (&value) T{other.value};
+ } else {
+ rest.construct_at(index, other.rest);
+ }
+ }
+ constexpr void construct_at(size_t index, storage_base&& other) {
+ if (index == Index) {
+ new (&value) T{std::move(other.value)};
+ } else {
+ rest.construct_at(index, std::move(other.rest));
+ }
+ }
+
+ constexpr void assign_at(size_t index, const storage_base& other) {
+ if (index == Index) {
+ value = other.value;
+ } else {
+ rest.assign_at(index, other.rest);
+ }
+ }
+ constexpr void assign_at(size_t index, storage_base&& other) {
+ if (index == Index) {
+ value = std::move(other.value);
+ } else {
+ rest.assign_at(index, std::move(other.rest));
+ }
+ }
+
+ constexpr void swap_at(size_t index, storage_base& other) {
+ if (index == Index) {
+ using std::swap;
+ swap(value, other.value);
+ } else {
+ rest.swap_at(index, other.rest);
+ }
+ }
+
+ template <typename... Args>
+ constexpr size_t construct(type_tag<T>, Args&&... args) {
+ new (&value) T(std::forward<Args>(args)...);
+ return Index;
+ }
+ template <typename U, typename... Args>
+ constexpr size_t construct(type_tag<U>, Args&&... args) {
+ return rest.construct(type_tag<U>{}, std::forward<Args>(args)...);
+ }
+ template <typename... Args>
+ constexpr size_t construct(index_tag<Index>, Args&&... args) {
+ new (&value) T(std::forward<Args>(args)...);
+ return Index;
+ }
+ template <size_t OtherIndex, typename... Args>
+ constexpr size_t construct(index_tag<OtherIndex>, Args&&... args) {
+ return rest.construct(index_tag<OtherIndex>{}, std::forward<Args>(args)...);
+ }
+
+ constexpr void reset(size_t) {}
+
+ constexpr T& get(type_tag<T>) { return value; }
+ constexpr const T& get(type_tag<T>) const { return value; }
+ template <typename U>
+ constexpr U& get(type_tag<U>) {
+ return rest.get(type_tag<U>{});
+ }
+ template <typename U>
+ constexpr const U& get(type_tag<U>) const {
+ return rest.get(type_tag<U>{});
+ }
+ constexpr T& get(index_tag<Index>) { return value; }
+ constexpr const T& get(index_tag<Index>) const { return value; }
+ template <size_t OtherIndex>
+ constexpr auto& get(index_tag<OtherIndex>) {
+ return rest.get(index_tag<OtherIndex>{});
+ }
+ template <size_t OtherIndex>
+ constexpr const auto& get(index_tag<OtherIndex>) const {
+ return rest.get(index_tag<OtherIndex>{});
+ }
+
+ constexpr size_t index(type_tag<T>) const { return Index; }
+ template <typename U>
+ constexpr size_t index(type_tag<U>) const {
+ return rest.index(type_tag<U>{});
+ }
+
+ template <typename V>
+ constexpr bool visit(size_t index, V&& visitor) {
+ if (index == Index) {
+ std::forward<V>(visitor)(type_tag<T>{}, index_tag<Index>{}, this);
+ return true;
+ } else {
+ return rest.visit(index, std::forward<V>(visitor));
+ }
+ }
+ template <typename V>
+ constexpr bool visit(size_t index, V&& visitor) const {
+ if (index == Index) {
+ std::forward<V>(visitor)(type_tag<T>{}, index_tag<Index>{}, this);
+ return true;
+ } else {
+ return rest.visit(index, std::forward<V>(visitor));
+ }
+ }
+
+ empty_type empty;
+ T value;
+ storage_base<destructor_class::trivial, type_index<Ts, Is>...> rest;
+};
+
+// Lazy-initialized union storage type that tracks the index of the active
+// variant.
+template <destructor_class, typename...>
+class indexed_storage;
+
+template <destructor_class DestructorClass, typename... Ts, size_t... Is>
+class indexed_storage<DestructorClass, type_index<Ts, Is>...> {
+ private:
+ using base_type =
+ storage_base<DestructorClass, type_index<Ts, Is>..., type_index<empty_type, empty_index>>;
+
+ public:
+ static constexpr bool nothrow_default_constructible =
+ std::is_nothrow_default_constructible<first_t<Ts...>>::value;
+ static constexpr bool nothrow_move_constructible =
+ conjunction_v<std::is_nothrow_move_constructible<Ts>...>;
+ static constexpr bool nothrow_move_assignable =
+ conjunction_v<std::is_nothrow_move_assignable<Ts>...>;
+
+ constexpr indexed_storage() = default;
+
+ constexpr indexed_storage(trivial_init_t) : indexed_storage{} {}
+
+ constexpr indexed_storage(default_init_t) : index_{0}, base_{index_tag<0>{}} {}
+
+ // Only used by trivial copy/move types.
+ constexpr indexed_storage(const indexed_storage& other) = default;
+ constexpr indexed_storage& operator=(const indexed_storage& other) = default;
+ constexpr indexed_storage(indexed_storage&& other) = default;
+ constexpr indexed_storage& operator=(indexed_storage&& other) = default;
+
+ template <typename T, typename... Args>
+ constexpr indexed_storage(type_tag<T>, Args&&... args)
+ : base_(type_tag<T>{}, std::forward<Args>(args)...) {
+ index_ = base_.index(type_tag<T>{});
+ }
+ template <size_t Index, typename... Args>
+ constexpr indexed_storage(index_tag<Index>, Args&&... args)
+ : index_{Index}, base_(index_tag<Index>{}, std::forward<Args>(args)...) {}
+
+ constexpr indexed_storage(maybe_init_t, const indexed_storage& other)
+ : index_{other.index()}, base_{} {
+ base_.construct_at(other.index(), other.base_);
+ }
+ constexpr indexed_storage(maybe_init_t, indexed_storage&& other)
+ : index_{other.index()}, base_{} {
+ base_.construct_at(other.index(), std::move(other.base_));
+ }
+
+ ~indexed_storage() = default;
+
+ constexpr index_type index() const { return index_; }
+ constexpr bool is_empty() const { return index() == empty_index; }
+ template <typename T>
+ constexpr bool has_value(type_tag<T>) const {
+ return index() == base_.index(type_tag<T>{});
+ }
+ template <size_t Index>
+ constexpr bool has_value(index_tag<Index>) const {
+ return index() == Index;
+ }
+
+ template <typename T>
+ constexpr auto& get(type_tag<T>) {
+ return base_.get(type_tag<T>{});
+ }
+ template <typename T>
+ constexpr const auto& get(type_tag<T>) const {
+ return base_.get(type_tag<T>{});
+ }
+ template <size_t Index>
+ constexpr auto& get(index_tag<Index>) {
+ return base_.get(index_tag<Index>{});
+ }
+ template <size_t Index>
+ constexpr const auto& get(index_tag<Index>) const {
+ return base_.get(index_tag<Index>{});
+ }
+
+ template <typename T, typename... Args>
+ constexpr void construct(type_tag<T>, Args&&... args) {
+ index_ = base_.construct(type_tag<T>{}, std::forward<Args>(args)...);
+ }
+ template <size_t Index, typename... Args>
+ constexpr void construct(index_tag<Index>, Args&&... args) {
+ index_ = base_.construct(index_tag<Index>{}, std::forward<Args>(args)...);
+ }
+
+ constexpr void assign(const indexed_storage& other) {
+ if (index() == other.index()) {
+ base_.assign_at(index_, other.base_);
+ } else {
+ reset();
+ base_.construct_at(other.index_, other.base_);
+ index_ = other.index_;
+ }
+ }
+ constexpr void assign(indexed_storage&& other) {
+ if (index() == other.index()) {
+ base_.assign_at(index_, std::move(other.base_));
+ } else {
+ reset();
+ base_.construct_at(other.index_, std::move(other.base_));
+ index_ = other.index_;
+ }
+ }
+
+ template <typename V>
+ constexpr bool visit(V&& visitor) {
+ return base_.visit(index_, std::forward<V>(visitor));
+ }
+ template <typename V>
+ constexpr bool visit(V&& visitor) const {
+ return base_.visit(index_, std::forward<V>(visitor));
+ }
+
+ constexpr void swap(indexed_storage& other) {
+ if (index() == other.index()) {
+ // Swap directly when the variants are the same, including empty.
+ base_.swap_at(index_, other.base_);
+ } else {
+ // Swap when the variants are different, including one being empty.
+ // This approach avoids GCC -Wmaybe-uninitialized warnings by
+ // initializing and accessing |temp| unconditionally within a
+ // conditional scope. The alternative, using the maybe_init_t
+ // constructor confuses GCC because it doesn't understand that the
+ // index checks prevent uninitialized access.
+ auto do_swap = [](indexed_storage& a, indexed_storage& b) {
+ return a.base_.visit(a.index_, [&a, &b](auto type_tag_v, auto index_tag_v, auto* element) {
+ indexed_storage temp{index_tag_v, std::move(element->value)};
+ a.reset();
+
+ a.base_.construct_at(b.index_, std::move(b.base_));
+ a.index_ = b.index_;
+ b.reset();
+
+ b.base_.construct_at(temp.index_, std::move(temp.base_));
+ b.index_ = temp.index_;
+ temp.reset();
+ });
+ };
+
+ // The visitor above returns false when the first argument is empty
+ // and no action is taken. In that case, the other order is tried to
+ // complete the half-empty swap.
+ do_swap(*this, other) || do_swap(other, *this);
+ }
+ }
+
+ // Destroys the active variant. Does nothing when already empty.
+ constexpr void reset() {
+ base_.reset(index_);
+ index_ = empty_index;
+ }
+
+ private:
+ index_type index_{empty_index};
+ base_type base_;
+};
+
+// Internal variant storage type used by fit::optional and fit::variant.
+// Specializations of this type select trivial vs. non-trivial copy/move
+// construction, assignment operators, and destructor based on the storage class
+// of the types in Ts.
+template <typename StorageClass, typename... Ts>
+struct storage;
+
+template <typename... Ts, size_t... Is>
+struct storage<storage_class<destructor_class::trivial, copy_class::trivial, move_class::trivial>,
+ type_index<Ts, Is>...>
+ : indexed_storage<destructor_class::trivial, type_index<Ts, Is>...> {
+ using base_type = indexed_storage<destructor_class::trivial, type_index<Ts, Is>...>;
+ using base_type::base_type;
+ constexpr storage() = default;
+};
+
+template <typename... Ts, size_t... Is>
+struct storage<
+ storage_class<destructor_class::trivial, copy_class::non_trivial, move_class::trivial>,
+ type_index<Ts, Is>...> : indexed_storage<destructor_class::trivial, type_index<Ts, Is>...> {
+ using base_type = indexed_storage<destructor_class::trivial, type_index<Ts, Is>...>;
+ using base_type::base_type;
+
+ ~storage() = default;
+ constexpr storage() = default;
+
+ constexpr storage(const storage& other) : base_type{maybe_init_v, other} {}
+
+ constexpr storage& operator=(const storage& other) {
+ this->assign(other);
+ return *this;
+ }
+
+ constexpr storage(storage&&) = default;
+ constexpr storage& operator=(storage&&) = default;
+};
+
+template <typename... Ts, size_t... Is>
+struct storage<
+ storage_class<destructor_class::trivial, copy_class::trivial, move_class::non_trivial>,
+ type_index<Ts, Is>...> : indexed_storage<destructor_class::trivial, type_index<Ts, Is>...> {
+ using base_type = indexed_storage<destructor_class::trivial, type_index<Ts, Is>...>;
+ using base_type::base_type;
+
+ ~storage() = default;
+ constexpr storage() = default;
+ constexpr storage(const storage&) = default;
+ constexpr storage& operator=(const storage&) = default;
+
+ constexpr storage(storage&& other) noexcept(base_type::nothrow_move_constructible)
+ : base_type{maybe_init_v, std::move(other)} {}
+
+ constexpr storage& operator=(storage&& other) noexcept(base_type::nothrow_move_assignable) {
+ this->assign(std::move(other));
+ return *this;
+ }
+};
+
+template <typename... Ts, size_t... Is>
+struct storage<
+ storage_class<destructor_class::trivial, copy_class::non_trivial, move_class::non_trivial>,
+ type_index<Ts, Is>...> : indexed_storage<destructor_class::trivial, type_index<Ts, Is>...> {
+ using base_type = indexed_storage<destructor_class::trivial, type_index<Ts, Is>...>;
+ using base_type::base_type;
+
+ ~storage() = default;
+ constexpr storage() = default;
+
+ constexpr storage(const storage& other) : base_type{maybe_init_v, other} {}
+
+ constexpr storage& operator=(const storage& other) {
+ this->assign(other);
+ return *this;
+ }
+
+ constexpr storage(storage&& other) noexcept(base_type::nothrow_move_constructible)
+ : base_type{maybe_init_v, std::move(other)} {}
+
+ constexpr storage& operator=(storage&& other) noexcept(base_type::nothrow_move_assignable) {
+ this->assign(std::move(other));
+ return *this;
+ }
+};
+
+// Specialization for non-trivially movable/copyable types. Types with a non-
+// trivial destructor are always non-trivially movable/copyable.
+template <copy_class CopyClass, move_class MoveClass, typename... Ts, size_t... Is>
+struct storage<storage_class<destructor_class::non_trivial, CopyClass, MoveClass>,
+ type_index<Ts, Is>...>
+ : indexed_storage<destructor_class::non_trivial, type_index<Ts, Is>...> {
+ using base_type = indexed_storage<destructor_class::non_trivial, type_index<Ts, Is>...>;
+ using base_type::base_type;
+
+ ~storage() { this->reset(); }
+
+ constexpr storage() = default;
+
+ constexpr storage(const storage& other) : base_type{maybe_init_v, other} {}
+
+ constexpr storage& operator=(const storage& other) {
+ this->assign(other);
+ return *this;
+ }
+
+ constexpr storage(storage&& other) noexcept(base_type::nothrow_move_constructible)
+ : base_type{maybe_init_v, std::move(other)} {}
+
+ constexpr storage& operator=(storage&& other) noexcept(base_type::nothrow_move_assignable) {
+ this->assign(std::move(other));
+ return *this;
+ }
+};
+
+template <typename... Ts, size_t... Is>
+constexpr auto make_storage(std::index_sequence<Is...>) {
+ return storage<make_storage_class<Ts...>, type_index<Ts, Is>...>{};
+}
+
+template <typename... Ts>
+using storage_type = decltype(make_storage<Ts...>(std::index_sequence_for<Ts...>{}));
+
+} // namespace internal
+} // namespace fit
+
+#endif // LIB_FIT_STORAGE_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/string_view.h b/pkg/fit/include/lib/fit/string_view.h
new file mode 100644
index 0000000..54fff50
--- /dev/null
+++ b/pkg/fit/include/lib/fit/string_view.h
@@ -0,0 +1,557 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_STRING_VIEW_H_
+#define LIB_FIT_STRING_VIEW_H_
+
+#include <cassert>
+#include <cstdlib>
+#include <ios>
+#include <iterator>
+#include <memory>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+namespace fit {
+
+namespace internal {
+
+// Constexpr filler for std::swap. No specialization for arrays.
+template <typename T>
+constexpr void constexpr_swap(T& a, T& b) noexcept {
+ T tmp = std::move(a);
+ a = std::move(b);
+ b = std::move(tmp);
+}
+
+// Constexpr filler for C++17 std::addressof.
+template <typename T>
+constexpr T* addressof(T& arg) {
+ return reinterpret_cast<T*>(&const_cast<char&>(reinterpret_cast<const volatile char&>(arg)));
+}
+
+// Filler for char_traits<CharT>::compare
+template <typename CharT>
+constexpr int compare(const CharT* s1, const CharT* s2, std::size_t count) {
+ for (std::size_t curr = 0; curr < count; ++curr) {
+ // Exit as soon as we find a different character.
+ if (std::char_traits<CharT>::lt(s1[curr], s2[curr])) {
+ return -1;
+ } else if (!std::char_traits<CharT>::eq(s1[curr], s2[curr])) {
+ return 1;
+ }
+ }
+ // If all characters within [s1, s1+count) and [s2, s2+count) are equal
+ // return 0.
+ return 0;
+}
+
+// Returns the distance from |begin| to first character in [|it|, |end|) that is equal to
+// |needle.front()|.
+// Returns |StringViewType::npos| if no such character is found.
+//
+// Complexity: O(|std::distance(it, end)|).
+template <typename StringViewType, typename Iterator>
+typename StringViewType::size_type find_char(Iterator it, Iterator begin, Iterator end,
+ StringViewType needle) {
+ // Look starting point.
+ while (it != end && !StringViewType::traits_type::eq(*it, needle.front())) {
+ ++it;
+ }
+
+ if (it == end) {
+ return StringViewType::npos;
+ }
+ return static_cast<typename StringViewType::size_type>(std::distance(begin, it));
+}
+
+// Returns the distance from the first character starting from |begin| that matches
+// any characters in |matchers|.
+// Returns |StringViewType::npos| if no characters are within |matchers|.
+//
+// Complexity: O(|std::distance(begin, end)|*|matchers.length()|).
+template <typename StringViewType, typename Iterator>
+constexpr typename StringViewType::size_type find_first_of(Iterator begin, Iterator end,
+ StringViewType matchers) {
+ typename StringViewType::size_type curr = 0;
+ for (Iterator it = begin; it < end; ++it) {
+ for (const auto& matcher : matchers) {
+ if (StringViewType::traits_type::eq(*it, matcher)) {
+ return curr;
+ }
+ }
+ ++curr;
+ }
+
+ return StringViewType::npos;
+}
+
+// Returns the distance from the first character starting from |begin| that does not match
+// any characters in |matchers|.
+// Returns |StringViewType::npos| if all characters are within |matchers|.
+//
+// Complexity: O(|std::distance(begin, end)|*|matchers.length()|).
+template <typename StringViewType, typename Iterator>
+constexpr typename StringViewType::size_type find_first_not_of(Iterator begin, Iterator end,
+ StringViewType matchers) {
+ typename StringViewType::size_type curr = 0;
+
+ for (Iterator it = begin; it < end; ++it) {
+ bool matched = false;
+ for (const auto& matcher : matchers) {
+ if (StringViewType::traits_type::eq(*it, matcher)) {
+ matched = true;
+ break;
+ }
+ }
+
+ if (!matched) {
+ return curr;
+ }
+ ++curr;
+ }
+
+ return StringViewType::npos;
+}
+
+// Returns the starting point of |needle| within |haystack|.
+// If no match is found, return |StringViewType::npos|.
+//
+// Complexity: O(|std::distance(begin, end)| * |needle.length()|)
+template <typename StringViewType, typename Iterator>
+constexpr typename StringViewType::size_type find(Iterator begin, Iterator end,
+ const StringViewType needle) {
+ // If the needle does not fit in the haystack, there is no possible match.
+ if (static_cast<typename StringViewType::size_type>(std::distance(begin, end)) <
+ needle.length()) {
+ return StringViewType::npos;
+ }
+
+ if (needle.empty()) {
+ return 0;
+ }
+
+ Iterator it = begin;
+
+ while (it < end) {
+ typename StringViewType::size_type offset = find_char(it, begin, end, needle);
+ // If no match discard.
+ if (offset == StringViewType::npos) {
+ return StringViewType::npos;
+ }
+ it = begin + offset;
+
+ if (internal::compare<typename StringViewType::value_type>(&(*it), needle.data(),
+ needle.size()) == 0) {
+ return std::distance(begin, it);
+ }
+ ++it;
+ }
+
+ // We did not find the substring in the haystack.
+ return StringViewType::npos;
+}
+
+} // namespace internal
+
+// Provides a view to a sequence of characters.
+template <class CharT, class Traits = std::char_traits<CharT>>
+class basic_string_view {
+ public:
+ using traits_type = Traits;
+ using value_type = CharT;
+ using pointer = CharT*;
+ using const_pointer = const CharT*;
+ using reference = CharT&;
+ using const_reference = const CharT&;
+ using iterator = const_pointer;
+ using const_iterator = iterator;
+ using reverse_iterator = std::reverse_iterator<const_iterator>;
+ using const_reverse_iterator = reverse_iterator;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
+
+ static constexpr size_type npos = static_cast<size_type>(-1);
+
+ constexpr basic_string_view() noexcept : data_(nullptr), length_(0) {}
+ constexpr basic_string_view(const CharT* s, size_type count) noexcept
+ : data_(s), length_(count) {}
+ constexpr basic_string_view(const CharT* s) noexcept : data_(s), length_(Traits::length(s)) {}
+ template <typename Allocator>
+ basic_string_view(const std::basic_string<CharT, Traits, Allocator>& s) noexcept
+ : data_(s.data()), length_(s.length()) {}
+ constexpr basic_string_view(const basic_string_view& other) noexcept = default;
+ basic_string_view(basic_string_view&&) noexcept = default;
+ constexpr basic_string_view& operator=(const basic_string_view& view) noexcept = default;
+ constexpr basic_string_view& operator=(basic_string_view&&) noexcept = default;
+ ~basic_string_view() = default;
+
+ constexpr iterator begin() const { return data_; }
+ constexpr iterator end() const { return begin() + length_; }
+ constexpr const_iterator cbegin() const { return data_; }
+ constexpr const_iterator cend() const { return begin() + length_; }
+
+ constexpr reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+ constexpr reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+ constexpr const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
+ constexpr const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
+
+ constexpr const_pointer data() const { return data_; }
+ constexpr size_type size() const { return length_; }
+ constexpr size_type length() const { return length_; }
+ constexpr size_type max_size() const { return std::numeric_limits<size_type>::max(); }
+
+ constexpr const_reference front() const { return this->operator[](0); }
+ constexpr const_reference back() const { return this->operator[](size() - 1); }
+ constexpr bool empty() const { return size() == 0; }
+
+ constexpr const_reference operator[](size_type pos) const { return *(data() + pos); }
+ constexpr const_reference at(size_type pos) const {
+ assert(pos < size());
+ return this->operator[](pos);
+ }
+
+ constexpr void remove_prefix(size_type n) {
+ data_ += n;
+ length_ -= n;
+ }
+ constexpr void remove_suffix(size_type n) { length_ -= n; }
+
+ constexpr void swap(basic_string_view& other) noexcept {
+ internal::constexpr_swap(data_, other.data_);
+ internal::constexpr_swap(length_, other.length_);
+ }
+
+ size_type copy(CharT* dest, size_type count, size_type pos = 0) const {
+ assert(pos < size());
+ Traits::copy(dest, data() + pos, calculate_length(pos, count));
+ return count;
+ }
+
+ constexpr basic_string_view substr(size_type pos = 0, size_type count = npos) const {
+ return basic_string_view(data() + pos, calculate_length(pos, count));
+ }
+
+ constexpr int compare(basic_string_view v) const {
+ const int result = internal::compare(data(), v.data(), std::min(size(), v.size()));
+ if (result == 0) {
+ return static_cast<int>(size() - v.size());
+ }
+ return result;
+ }
+
+ constexpr int compare(size_type pos1, size_type count1, basic_string_view v) const {
+ return substr(pos1, count1).compare(v);
+ }
+
+ constexpr int compare(size_type pos1, size_type count1, basic_string_view v, size_type pos2,
+ size_type count2) const {
+ return substr(pos1, count1).compare(v.substr(pos2, count2));
+ }
+
+ constexpr int compare(const CharT* s) const { return compare(basic_string_view(s)); }
+
+ constexpr int compare(size_type pos1, size_type count1, const CharT* s) const {
+ return substr(pos1, count1).compare(basic_string_view(s));
+ }
+
+ constexpr int compare(size_type pos1, size_type count1, const CharT* s, size_type count2) const {
+ return substr(pos1, count1).compare(basic_string_view(s, count2));
+ }
+
+ constexpr size_type find(basic_string_view v, size_type pos = 0) const noexcept {
+ auto tmp = internal::find(substr(pos).begin(), substr(pos).end(), v);
+ return (tmp == npos) ? npos : pos + tmp;
+ }
+
+ constexpr size_type find(CharT ch, size_type pos = 0) const {
+ return find(basic_string_view(internal::addressof(ch), 1), pos);
+ }
+
+ constexpr size_type find(const CharT* s, size_type pos, size_type count) const {
+ return find(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type find(const CharT* s, size_type pos) const {
+ return find(basic_string_view(s), pos);
+ }
+
+ constexpr size_type rfind(basic_string_view v, size_type pos = 0) const noexcept {
+ auto tmp = internal::find(substr(pos).rbegin(), substr(pos).rend(), v);
+ return (tmp == npos) ? npos : length() - 1 - tmp;
+ }
+
+ constexpr size_type rfind(CharT ch, size_type pos = 0) const {
+ return rfind(basic_string_view(internal::addressof(ch), 1), pos);
+ }
+
+ constexpr size_type rfind(const CharT* s, size_type pos, size_type count) const {
+ return rfind(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type rfind(const CharT* s, size_type pos) const {
+ return rfind(basic_string_view(s), pos);
+ }
+
+ constexpr size_type find_first_of(basic_string_view v, size_type pos = 0) const noexcept {
+ auto tmp = internal::find_first_of(substr(pos).begin(), substr(pos).end(), v);
+ return tmp == npos ? npos : pos + tmp;
+ }
+
+ constexpr size_type find_first_of(CharT c, size_type pos = 0) const noexcept {
+ return find_first_of(basic_string_view(internal::addressof(c), 1), pos);
+ }
+
+ constexpr size_type find_first_of(const CharT* s, size_type pos, size_type count) const {
+ return find_first_of(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type find_first_of(const CharT* s, size_type pos = 0) const {
+ return find_first_of(basic_string_view(s), pos);
+ }
+
+ constexpr size_type find_last_of(basic_string_view v,
+ size_type pos = basic_string_view::npos) const noexcept {
+ const size_type fixed_length = (pos == npos) ? size() : pos + 1;
+ const size_type tmp = internal::find_first_of(substr(0, fixed_length).rbegin(),
+ substr(0, fixed_length).rend(), v);
+ return tmp == npos ? npos : fixed_length - 1 - tmp;
+ }
+
+ constexpr size_type find_last_of(CharT c, size_type pos = basic_string_view::npos) const
+ noexcept {
+ return find_last_of(basic_string_view(internal::addressof(c), 1), pos);
+ }
+
+ constexpr size_type find_last_of(const CharT* s, size_type pos, size_type count) const {
+ return find_last_of(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type find_last_of(const CharT* s, size_type pos = basic_string_view::npos) const {
+ return find_last_of(basic_string_view(s), pos);
+ }
+
+ constexpr size_type find_first_not_of(basic_string_view v, size_type pos = 0) const noexcept {
+ const auto tmp = internal::find_first_not_of(substr(pos).begin(), substr(pos).end(), v);
+ return tmp == npos ? npos : pos + tmp;
+ }
+
+ constexpr size_type find_first_not_of(CharT c, size_type pos = 0) const noexcept {
+ return find_first_not_of(basic_string_view(internal::addressof(c), 1), pos);
+ }
+
+ constexpr size_type find_first_not_of(const CharT* s, size_type pos, size_type count) const {
+ return find_first_not_of(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type find_first_not_of(const CharT* s, size_type pos = 0) const {
+ return find_first_not_of(basic_string_view(s), pos);
+ }
+
+ constexpr size_type find_last_not_of(basic_string_view v,
+ size_type pos = basic_string_view::npos) const noexcept {
+ const size_type fixed_length = (pos == npos) ? size() : pos + 1;
+ auto tmp = internal::find_first_not_of(substr(0, fixed_length).rbegin(),
+ substr(0, fixed_length).rend(), v);
+ return tmp == npos ? npos : fixed_length - 1 - tmp;
+ }
+
+ constexpr size_type find_last_not_of(CharT c, size_type pos = basic_string_view::npos) const
+ noexcept {
+ return find_last_not_of(basic_string_view(internal::addressof(c), 1), pos);
+ }
+
+ constexpr size_type find_last_not_of(const CharT* s, size_type pos, size_type count) const {
+ return find_last_not_of(basic_string_view(s, count), pos);
+ }
+
+ constexpr size_type find_last_not_of(const CharT* s,
+ size_type pos = basic_string_view::npos) const {
+ return find_last_not_of(basic_string_view(s), pos);
+ }
+
+ private:
+ constexpr size_type calculate_length(size_type pos, size_type count) const {
+ if (count == npos) {
+ count = size();
+ }
+ return std::min(count, size() - pos);
+ }
+
+ const_pointer data_;
+ size_type length_;
+};
+
+// Operators and overloads to satisfy all conversions.
+//
+// Defined overloads are of the form:
+// <basic_string_view, basic_string_view>
+// <RawType, basic_string_view>
+// <basic_string_view, RawType>
+//
+// When |RawType| is lhs: std::is_constructible<basic_string_view, RawType>::value must be true.
+// When |RawType| is rhs: There must be an overload of basic_string_view::compare for |RawType|.
+template <class CharT, class Traits>
+constexpr bool operator==(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) == 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator==(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) == 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator==(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) == 0;
+}
+
+template <class CharT, class Traits>
+constexpr bool operator!=(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) != 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator!=(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) != 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator!=(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) != 0;
+}
+
+template <class CharT, class Traits>
+constexpr bool operator<(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) < 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator<(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) < 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator<(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) < 0;
+}
+
+template <class CharT, class Traits>
+constexpr bool operator>(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) > 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator>(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) > 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator>(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) > 0;
+}
+
+template <class CharT, class Traits>
+constexpr bool operator<=(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) <= 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator<=(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) <= 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator<=(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) <= 0;
+}
+
+template <class CharT, class Traits>
+constexpr bool operator>=(fit::basic_string_view<CharT, Traits> lhs,
+ fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return lhs.compare(rhs) >= 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator>=(RawType lhs, fit::basic_string_view<CharT, Traits> rhs) noexcept {
+ return fit::basic_string_view<CharT, Traits>(lhs).compare(rhs) >= 0;
+}
+
+template <class CharT, class Traits, class RawType>
+constexpr bool operator>=(fit::basic_string_view<CharT, Traits> lhs, RawType rhs) noexcept {
+ return lhs.compare(rhs) >= 0;
+}
+
+// Specializations.
+using string_view = fit::basic_string_view<char>;
+
+// Constructs a string_view from ""_sv literal.
+// Literals with no leading underscore are reserved for the standard library.
+// https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv
+inline namespace literals {
+inline namespace string_view_literals {
+
+constexpr fit::string_view operator"" _sv(typename fit::string_view::const_pointer str,
+ typename fit::string_view::size_type len) noexcept {
+ return fit::string_view(str, len);
+}
+} // namespace string_view_literals
+} // namespace literals
+
+} // namespace fit
+
+namespace std {
+// Hash needs to match basic_string view hash of the same string, so we need to rely on compiler
+// implementation.
+// https://en.cppreference.com/w/cpp/string/basic_string_view/hash
+template <class CharT>
+struct hash<fit::basic_string_view<CharT, std::char_traits<CharT>>> {
+ std::size_t operator()(const fit::basic_string_view<CharT, std::char_traits<CharT>> val) const {
+ return __do_string_hash(val.data(), val.data() + val.length());
+ }
+};
+
+// Output stream specialization for fit::string_view.
+//
+// https://en.cppreference.com/w/cpp/string/basic_string_view/operator_ltlt
+template <class CharT, class Traits>
+std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
+ fit::basic_string_view<CharT, Traits> v) {
+ using size_type = typename fit::basic_string_view<CharT, Traits>::size_type;
+ const size_type fixed_length = std::min(static_cast<size_type>(os.width()), v.length());
+ const size_type fill_length =
+ (static_cast<size_type>(os.width()) > v.length()) ? os.width() - v.length() : 0;
+
+ auto fill_space = [](std::basic_ostream<CharT, Traits>& os, size_type fill_length) {
+ for (std::size_t i = 0; i < fill_length; ++i) {
+ os.put(os.fill());
+ }
+ };
+
+ bool fill_left = (os.flags() & std::ios_base::adjustfield) == std::ios_base::left;
+
+ if (!fill_left) {
+ fill_space(os, fill_length);
+ }
+
+ os.write(v.data(), fixed_length);
+
+ if (fill_left) {
+ fill_space(os, fill_length);
+ }
+
+ os.width(0);
+
+ return os;
+}
+
+} // namespace std
+
+#endif
diff --git a/pkg/fit/include/lib/fit/thread_safety.h b/pkg/fit/include/lib/fit/thread_safety.h
index 8ffc5ad..9545def 100644
--- a/pkg/fit/include/lib/fit/thread_safety.h
+++ b/pkg/fit/include/lib/fit/thread_safety.h
@@ -7,8 +7,7 @@
// Thread-safety annotations.
// Currently these are only supported on Clang.
-#if defined(__clang__) && \
- defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && \
+#if defined(__clang__) && defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && \
__has_attribute(acquire_capability)
#define FIT_THREAD_ANNOTATION(x) __attribute__((x))
#else
@@ -27,4 +26,4 @@
#define FIT_SCOPED_CAPABILITY FIT_THREAD_ANNOTATION(__scoped_lockable__)
#define FIT_NO_THREAD_SAFETY_ANALYSIS FIT_THREAD_ANNOTATION(__no_thread_safety_analysis__)
-#endif // LIB_FIT_THREAD_SAFETY_H_
+#endif // LIB_FIT_THREAD_SAFETY_H_
diff --git a/pkg/fit/include/lib/fit/traits.h b/pkg/fit/include/lib/fit/traits.h
index 933005e..ff43b92 100644
--- a/pkg/fit/include/lib/fit/traits.h
+++ b/pkg/fit/include/lib/fit/traits.h
@@ -10,15 +10,65 @@
namespace fit {
-// C++ 14 compatible implementation of std::void_t.
+// C++14 compatible polyfill for C++17 traits.
#if defined(__cplusplus) && __cplusplus >= 201703L
+
template <typename... T>
using void_t = std::void_t<T...>;
+
+template <typename... Ts>
+using conjunction = std::conjunction<Ts...>;
+template <typename... Ts>
+inline constexpr bool conjunction_v = std::conjunction_v<Ts...>;
+
+template <typename... Ts>
+using disjunction = std::disjunction<Ts...>;
+template <typename... Ts>
+inline constexpr bool disjunction_v = std::disjunction_v<Ts...>;
+
+template <typename... Ts>
+using negation = std::negation<Ts...>;
+template <typename... Ts>
+inline constexpr bool negation_v = std::negation_v<Ts...>;
+
#else
+
template <typename... T>
-struct make_void { typedef void type; };
+struct make_void {
+ typedef void type;
+};
template <typename... T>
using void_t = typename make_void<T...>::type;
+
+template <typename... Ts>
+struct conjunction : std::true_type {};
+template <typename T>
+struct conjunction<T> : T {};
+template <typename First, typename... Rest>
+struct conjunction<First, Rest...>
+ : std::conditional_t<bool(First::value), conjunction<Rest...>, First> {};
+
+template <typename... Ts>
+constexpr bool conjunction_v = conjunction<Ts...>::value;
+
+template <typename... Ts>
+struct disjunction : std::false_type {};
+template <typename T>
+struct disjunction<T> : T {};
+template <typename First, typename... Rest>
+struct disjunction<First, Rest...>
+ : std::conditional_t<bool(First::value), First, disjunction<Rest...>> {};
+
+template <typename... Ts>
+constexpr bool disjunction_v = disjunction<Ts...>::value;
+
+// Utility type that negates its truth-like parameter type.
+template <typename T>
+struct negation : std::integral_constant<bool, !bool(T::value)> {};
+
+template <typename T>
+constexpr bool negation_v = negation<T>::value;
+
#endif
// Encapsulates capture of a parameter pack. Typical use is to use instances of this empty struct
@@ -36,10 +86,10 @@
// }
template <typename... T>
struct parameter_pack {
- static constexpr size_t size = sizeof...(T);
+ static constexpr size_t size = sizeof...(T);
- template <size_t i>
- using at = typename std::tuple_element_t<i, std::tuple<T...>>;
+ template <size_t i>
+ using at = typename std::tuple_element_t<i, std::tuple<T...>>;
};
// |callable_traits| captures elements of interest from function-like types (functions, function
@@ -70,41 +120,36 @@
template <typename FunctorType, typename ReturnType, typename... ArgTypes>
struct callable_traits<ReturnType (FunctorType::*)(ArgTypes...) const>
: public callable_traits<ReturnType (*)(ArgTypes...)> {
-
- using type = FunctorType;
+ using type = FunctorType;
};
// Function pointer specialization.
template <typename ReturnType, typename... ArgTypes>
struct callable_traits<ReturnType (*)(ArgTypes...)>
: public callable_traits<ReturnType(ArgTypes...)> {
-
- using type = ReturnType (*)(ArgTypes...);
+ using type = ReturnType (*)(ArgTypes...);
};
// Base specialization.
template <typename ReturnType, typename... ArgTypes>
struct callable_traits<ReturnType(ArgTypes...)> {
- using signature = ReturnType(ArgTypes...);
- using return_type = ReturnType;
- using args = parameter_pack<ArgTypes...>;
+ using signature = ReturnType(ArgTypes...);
+ using return_type = ReturnType;
+ using args = parameter_pack<ArgTypes...>;
- callable_traits() = delete;
+ callable_traits() = delete;
};
// Determines whether a type has an operator() that can be invoked.
template <typename T, typename = void_t<>>
struct is_callable : public std::false_type {};
template <typename ReturnType, typename... ArgTypes>
-struct is_callable<ReturnType (*)(ArgTypes...)>
- : public std::true_type {};
+struct is_callable<ReturnType (*)(ArgTypes...)> : public std::true_type {};
template <typename FunctorType, typename ReturnType, typename... ArgTypes>
-struct is_callable<ReturnType (FunctorType::*)(ArgTypes...)>
- : public std::true_type {};
+struct is_callable<ReturnType (FunctorType::*)(ArgTypes...)> : public std::true_type {};
template <typename T>
-struct is_callable<T, void_t<decltype(&T::operator())>>
- : public std::true_type {};
+struct is_callable<T, void_t<decltype(&T::operator())>> : public std::true_type {};
-} // namespace fit
+} // namespace fit
-#endif // LIB_FIT_TRAITS_H_
+#endif // LIB_FIT_TRAITS_H_
diff --git a/pkg/fit/include/lib/fit/utility_internal.h b/pkg/fit/include/lib/fit/utility_internal.h
new file mode 100644
index 0000000..2351831
--- /dev/null
+++ b/pkg/fit/include/lib/fit/utility_internal.h
@@ -0,0 +1,134 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_FIT_UTILITY_INTERNAL_H_
+#define LIB_FIT_UTILITY_INTERNAL_H_
+
+#include <type_traits>
+#include <utility>
+
+#include "traits.h"
+
+namespace fit {
+namespace internal {
+
+// Utility to return the first type in a parameter pack.
+template <typename... Ts>
+struct first;
+template <typename First, typename... Rest>
+struct first<First, Rest...> {
+ using type = First;
+};
+
+template <typename... Ts>
+using first_t = typename first<Ts...>::type;
+
+// Utility to count the occurences of type T in the parameter pack Ts.
+template <typename T, typename... Ts>
+struct occurences_of : std::integral_constant<size_t, 0> {};
+template <typename T, typename U>
+struct occurences_of<T, U> : std::integral_constant<size_t, std::is_same<T, U>::value> {};
+template <typename T, typename First, typename... Rest>
+struct occurences_of<T, First, Rest...>
+ : std::integral_constant<size_t,
+ occurences_of<T, First>::value + occurences_of<T, Rest...>::value> {};
+
+template <typename T, typename... Ts>
+constexpr size_t occurences_of_v = occurences_of<T, Ts...>::value;
+
+// Utility to remove const, volatile, and reference qualifiers.
+template <typename T>
+using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
+
+// Evaluates to truth-like when type T matches type U with cv-reference removed.
+template <typename T, typename U>
+using not_same_type = negation<std::is_same<T, remove_cvref_t<U>>>;
+
+// Concept helper for constructors.
+template <typename... Conditions>
+using requires_conditions = std::enable_if_t<conjunction_v<Conditions...>, bool>;
+
+// Concept helper for assignment operators.
+template <typename Return, typename... Conditions>
+using assignment_requires_conditions =
+ std::enable_if_t<conjunction_v<Conditions...>, std::add_lvalue_reference_t<Return>>;
+
+// Evaluates to true when every element type of Ts is trivially destructible.
+template <typename... Ts>
+constexpr bool is_trivially_destructible_v = conjunction_v<std::is_trivially_destructible<Ts>...>;
+
+// Evaluates to true when every element type of Ts is trivially copyable.
+template <typename... Ts>
+constexpr bool is_trivially_copyable_v =
+ (conjunction_v<std::is_trivially_copy_assignable<Ts>...> &&
+ conjunction_v<std::is_trivially_copy_constructible<Ts>...>);
+
+// Evaluates to true when every element type of Ts is trivially movable.
+template <typename... Ts>
+constexpr bool is_trivially_movable_v =
+ (conjunction_v<std::is_trivially_move_assignable<Ts>...> &&
+ conjunction_v<std::is_trivially_move_constructible<Ts>...>);
+
+// Enable if relational operator is convertible to bool and the optional
+// conditions are true.
+template <typename Op, typename... Conditions>
+using enable_relop_t =
+ std::enable_if_t<(std::is_convertible<Op, bool>::value && conjunction_v<Conditions...>), bool>;
+
+template <typename T>
+struct identity {
+ using type = T;
+};
+
+// Evaluates to true when T is an unbounded array.
+template <typename T>
+struct is_unbounded_array : conjunction<std::is_array<T>, negation<std::extent<T>>> {};
+
+// Returns true when T is a complete type or an unbounded array.
+template <typename T, size_t = sizeof(T)>
+constexpr bool is_complete_or_unbounded_array(identity<T>) {
+ return true;
+}
+template <typename Identity, typename T = typename Identity::type>
+constexpr bool is_complete_or_unbounded_array(Identity) {
+ return disjunction<std::is_reference<T>, std::is_function<T>, std::is_void<T>,
+ is_unbounded_array<T>>::value;
+}
+
+// Using swap for ADL. This directive is contained within the fit::internal
+// namespace, which prevents leaking std::swap into user namespaces. Doing this
+// at namespace scope is necessary to lookup swap via ADL while preserving the
+// noexcept() specification of the resulting lookup.
+using std::swap;
+
+// Evaluates to true when T is swappable.
+template <typename T, typename = void>
+struct is_swappable : std::false_type {
+ static_assert(is_complete_or_unbounded_array(identity<T>{}),
+ "T must be a complete type or an unbounded array!");
+};
+template <typename T>
+struct is_swappable<T, void_t<decltype(swap(std::declval<T&>(), std::declval<T&>()))>>
+ : std::true_type {
+ static_assert(is_complete_or_unbounded_array(identity<T>{}),
+ "T must be a complete type or an unbounded array!");
+};
+
+// Evaluates to true when T is nothrow swappable.
+template <typename T, typename = void>
+struct is_nothrow_swappable : std::false_type {
+ static_assert(is_complete_or_unbounded_array(identity<T>{}),
+ "T must be a complete type or an unbounded array!");
+};
+template <typename T>
+struct is_nothrow_swappable<T, void_t<decltype(swap(std::declval<T&>(), std::declval<T&>()))>>
+ : std::integral_constant<bool, noexcept(swap(std::declval<T&>(), std::declval<T&>()))> {
+ static_assert(is_complete_or_unbounded_array(identity<T>{}),
+ "T must be a complete type or an unbounded array!");
+};
+
+} // namespace internal
+} // namespace fit
+
+#endif // LIB_FIT_UTILITY_INTERNAL_H_
diff --git a/pkg/fit/include/lib/fit/variant.h b/pkg/fit/include/lib/fit/variant.h
index f91a4a2..a5fd943 100644
--- a/pkg/fit/include/lib/fit/variant.h
+++ b/pkg/fit/include/lib/fit/variant.h
@@ -5,400 +5,629 @@
#ifndef LIB_FIT_VARIANT_H_
#define LIB_FIT_VARIANT_H_
-#include <assert.h>
-
+#include <exception>
#include <new>
#include <type_traits>
#include <utility>
+#include "constructors_internal.h"
+#include "in_place_internal.h"
+#include "storage_internal.h"
+#include "traits.h"
+#include "utility_internal.h"
+
namespace fit {
-namespace internal {
-// This is a very basic partial implementation of |std::variant| which
-// is compatible with C++ 14. In its current state, it only implements
-// enough of the API for internal usage. Transforming this into a more
-// complete and precise implementation of |std::variant| is left as an
-// exercise for the reader. ;)
-//
-// Some key differences:
-// - always requires first type to be monostate
-// - always default constructible
-// - no relational operators
-// - no visitors
-// - no find by type, only find by index
-// - no exception support
-// - simplified get/set methods
-
-// Unit type.
+// A default-constructible type that may be used as the first variant type to
+// make fit::variant default-constructible when other variants are not. This
+// type may also be used as an alternative representing an empty value.
struct monostate final {
- constexpr bool operator==(const monostate& other) const { return true; }
- constexpr bool operator!=(const monostate& other) const { return false; }
+ constexpr bool operator==(const monostate& other) const { return true; }
+ constexpr bool operator!=(const monostate& other) const { return false; }
+ constexpr bool operator<(const monostate& other) const { return false; }
+ constexpr bool operator>(const monostate& other) const { return false; }
+ constexpr bool operator<=(const monostate& other) const { return true; }
+ constexpr bool operator>=(const monostate& other) const { return true; }
};
-// Tag for requesting in-place initialization of a variant alternative by index.
-template <size_t index>
-struct in_place_index_t final {};
+namespace internal {
+
+// Helper type to avoid recursive instantiations of the full variant type.
+template <typename...>
+struct variant_list {};
+
+// Gets the number of alternatives in a variant_list as a compile-time constant.
+template <typename T>
+struct variant_list_size;
+
+template <typename... Ts>
+struct variant_list_size<variant_list<Ts...>> : std::integral_constant<size_t, sizeof...(Ts)> {};
+
+// Helper to get the type of a variant_list alternative with the given index.
+template <size_t Index, typename VariantList>
+struct variant_alternative;
+
+template <size_t Index, typename T0, typename... Ts>
+struct variant_alternative<Index, variant_list<T0, Ts...>>
+ : variant_alternative<Index - 1, variant_list<Ts...>> {};
+
+template <typename T0, typename... Ts>
+struct variant_alternative<0, variant_list<T0, Ts...>> {
+ using type = T0;
+};
+
+} // namespace internal
+
+// Forward declaration.
+template <typename... Ts>
+class variant;
+
+// Gets the type of a variant alternative with the given index.
+template <size_t Index, typename Variant>
+struct variant_alternative;
+
+template <size_t Index, typename... Ts>
+struct variant_alternative<Index, variant<Ts...>>
+ : ::fit::internal::variant_alternative<Index, ::fit::internal::variant_list<Ts...>> {};
+
+template <size_t index, typename Variant>
+using variant_alternative_t = typename variant_alternative<index, Variant>::type;
+
+// Gets the number of alternatives in a variant as a compile-time constant
+// expression.
+template <typename T>
+struct variant_size;
+
+template <typename... Ts>
+struct variant_size<variant<Ts...>> : std::integral_constant<size_t, sizeof...(Ts)> {};
+
+template <typename T>
+struct variant_size<const T> : variant_size<T> {};
+template <typename T>
+struct variant_size<volatile T> : variant_size<T> {};
+template <typename T>
+struct variant_size<const volatile T> : variant_size<T> {};
#ifdef __cpp_inline_variables
-// Inline variables are only available on C++ 17 and beyond.
-template <size_t index>
-inline constexpr in_place_index_t<index> in_place_index{};
+template <typename T>
+inline constexpr size_t variant_size_v = variant_size<T>::value;
#else
-// On C++ 14 we need to provide storage for the variable so we define
-// |in_place_index| as a reference instead.
-template <size_t index>
-struct in_place_index_holder {
- static constexpr in_place_index_t<index> instance{};
+template <typename T>
+struct variant_size_holder {
+ static constexpr size_t value{variant_size<T>::value};
};
-template <size_t index>
-constexpr in_place_index_t<index> in_place_index_holder<index>::instance;
+template <typename T>
+constexpr size_t variant_size_holder<T>::value;
-template <size_t index>
-static constexpr const in_place_index_t<index>& in_place_index =
- in_place_index_holder<index>::instance;
+template <typename T>
+static constexpr const size_t& variant_size_v = variant_size_holder<T>::value;
-#endif // __cpp_inline_variables
+#endif
-// Stores the contents of the variant as a recursively nested union
-// of alternatives. Conceptually it might be simpler to use
-// std::in_place_storage<> but we would lose the ability to treat the
-// storage as a literal type.
-template <typename... Ts>
-union variant_storage final {
- static constexpr bool copy_construct_supported = true;
- static constexpr bool move_construct_supported = true;
+// Exception type to report bad accesses to variant.
+class bad_variant_access : public std::exception {
+ public:
+ bad_variant_access() noexcept {}
- void copy_construct_from(size_t index, const variant_storage& other) {}
- void move_construct_from(size_t index, variant_storage&& other) {}
- void destroy(size_t index) {}
- void swap(size_t index, variant_storage& other) {}
+ const char* what() const noexcept override { return reason_; }
+
+ private:
+ template <typename... Ts>
+ friend class variant;
+
+ bad_variant_access(const char* reason) noexcept : reason_{reason} {}
+
+ // String describing the reason for the bad access. Must point to a string
+ // with static storage duration.
+ const char* reason_;
};
-template <typename T0, typename... Ts>
-union variant_storage<T0, Ts...> final {
- static constexpr bool copy_construct_supported =
- std::is_copy_constructible<T0>::value &&
- variant_storage<Ts...>::copy_construct_supported;
- static constexpr bool move_construct_supported =
- std::is_move_constructible<T0>::value &&
- variant_storage<Ts...>::move_construct_supported;
+namespace internal {
- constexpr variant_storage() = default;
-
- template <typename... Args>
- explicit constexpr variant_storage(in_place_index_t<0>, Args&&... args)
- : alt(std::forward<Args>(args)...) {}
-
- template <size_t index, typename... Args>
- explicit constexpr variant_storage(in_place_index_t<index>, Args&&... args)
- : rest(in_place_index<index - 1>, std::forward<Args>(args)...) {}
-
- constexpr T0& get(in_place_index_t<0>) { return alt; }
-
- constexpr const T0& get(in_place_index_t<0>) const { return alt; }
-
- template <size_t index>
- constexpr auto& get(in_place_index_t<index>) {
- return rest.get(in_place_index<index - 1>);
- }
-
- template <size_t index>
- constexpr const auto& get(in_place_index_t<index>) const {
- return rest.get(in_place_index<index - 1>);
- }
-
- template <typename... Args>
- auto& emplace(in_place_index_t<0>, Args&&... args) {
- new (&alt) T0(std::forward<Args>(args)...);
- return alt;
- }
-
- template <size_t index, typename... Args>
- auto& emplace(in_place_index_t<index>, Args&&... args) {
- return rest.emplace(in_place_index<index - 1>,
- std::forward<Args>(args)...);
- }
-
- void copy_construct_from(size_t index, const variant_storage& other) {
- if (index == 0) {
- new (&alt) T0(other.alt);
- } else {
- rest.copy_construct_from(index - 1, other.rest);
- }
- }
-
- void move_construct_from(size_t index, variant_storage&& other) {
- if (index == 0) {
- new (&alt) T0(std::move(other.alt));
- } else {
- rest.move_construct_from(index - 1, std::move(other.rest));
- }
- }
-
- void destroy(size_t index) {
- if (index == 0) {
- alt.~T0();
- } else {
- rest.destroy(index - 1);
- }
- }
-
- void swap(size_t index, variant_storage& other) {
- using std::swap;
- if (index == 0) {
- swap(alt, other.alt);
- } else {
- rest.swap(index - 1, other.rest);
- }
- }
-
- T0 alt;
- variant_storage<Ts...> rest;
+// Helper type to check that conversions do not narrow.
+template <typename T>
+struct check_narrow {
+ T x[1];
};
-// Holds the index and storage for a variant with a trivial destructor.
-template <typename... Ts>
-class variant_base_impl_trivial;
-template <typename... Ts>
-class variant_base_impl_trivial<monostate, Ts...> {
-public:
- constexpr variant_base_impl_trivial()
- : index_(0),
- storage_(in_place_index<0>, monostate{}) {}
-
- template <size_t index, typename... Args>
- explicit constexpr variant_base_impl_trivial(
- in_place_index_t<index>, Args&&... args)
- : index_(index),
- storage_(in_place_index<index>, std::forward<Args>(args)...) {}
-
- // Used by emplace.
- void destroy() {}
-
-protected:
- size_t index_;
- variant_storage<monostate, Ts...> storage_;
+// Builds a check(Ti) function for each alternative Ti. This trait is evaluated
+// for each element of fit::variant<Ts...>. Essentially: for (Index, Ti) in Ts.
+//
+// Index is the zero-based index of the corresponding element Ti in the pack Ts.
+// T is the type deduced from the converting constructor or assignment operator
+// of fit::variant for which we want to find an appropriately convertible
+// element.
+//
+// The specializations below match the element Ti that passes the conversion
+// checks.
+template <size_t Index, typename T, typename Ti,
+ bool IsBool = std::is_same<bool, std::remove_cv_t<Ti>>::value, typename = void>
+struct check_valid_option {
+ // Non-static so that check_valid_option<...>::check is always a valid
+ // name, but doesn't participate in the overload resolution in the
+ // valid_option_index selection trait.
+ void check();
};
-// Holds the index and storage for a variant with a non-trivial destructor.
-template <typename... Ts>
-class variant_base_impl_non_trivial;
-template <typename... Ts>
-class variant_base_impl_non_trivial<monostate, Ts...> {
-public:
- constexpr variant_base_impl_non_trivial()
- : index_(0),
- storage_(in_place_index<0>, monostate{}) {}
-
- template <size_t index, typename... Args>
- explicit constexpr variant_base_impl_non_trivial(
- in_place_index_t<index>, Args&&... args)
- : index_(index),
- storage_(in_place_index<index>, std::forward<Args>(args)...) {}
-
- ~variant_base_impl_non_trivial() {
- destroy();
- }
-
- // Used by emplace and by the destructor.
- void destroy() {
- storage_.destroy(index_);
- }
-
-protected:
- size_t index_;
- union {
- variant_storage<monostate, Ts...> storage_;
- };
+// Checks that Ti x[] = {std::forward<T>()} is well formed.
+template <size_t Index, typename T, typename Ti>
+struct check_valid_option<Index, T, Ti, false,
+ void_t<decltype(check_narrow<Ti>{{std::declval<T>()}})>> {
+ static std::integral_constant<size_t, Index> check(Ti);
};
-// Selects an appropriate variant base class depending on whether
-// its destructor is trivial or non-trivial.
-template <typename... Ts>
-using variant_base_impl =
- std::conditional_t<
- std::is_destructible<
- variant_base_impl_trivial<Ts...>>::value,
- variant_base_impl_trivial<Ts...>,
- variant_base_impl_non_trivial<Ts...>>;
-
-// Implements non-trivial move-construction and move-assignment.
-template <typename... Ts>
-class variant_move_impl_non_trivial : protected variant_base_impl<Ts...> {
- using base = variant_base_impl<Ts...>;
-
-public:
- using base::base;
-
- variant_move_impl_non_trivial(
- const variant_move_impl_non_trivial& other) = default;
-
- variant_move_impl_non_trivial(
- variant_move_impl_non_trivial&& other) {
- index_ = other.index_;
- storage_.move_construct_from(index_, std::move(other.storage_));
- }
-
- variant_move_impl_non_trivial& operator=(
- const variant_move_impl_non_trivial& other) = default;
-
- variant_move_impl_non_trivial& operator=(
- variant_move_impl_non_trivial&& other) {
- if (&other == this)
- return *this;
- storage_.destroy(index_);
- index_ = other.index_;
- storage_.move_construct_from(index_, std::move(other.storage_));
- return *this;
- }
-
-protected:
- using base::index_;
- using base::storage_;
+// Checks that remove_cvref_t<T> is bool when Ti is cv bool.
+template <size_t Index, typename T, typename Ti>
+struct check_valid_option<Index, T, Ti, true,
+ std::enable_if_t<std::is_same<bool, remove_cvref_t<T>>::value>> {
+ static std::integral_constant<size_t, Index> check(Ti);
};
-// Selects an appropriate variant base class for moving.
-template <typename... Ts>
-using variant_move_impl =
- std::conditional_t<
- (std::is_move_constructible<variant_base_impl<Ts...>>::value &&
- std::is_move_assignable<variant_base_impl<Ts...>>::value) ||
- !variant_storage<Ts...>::move_construct_supported,
- variant_base_impl<Ts...>,
- variant_move_impl_non_trivial<Ts...>>;
-
-// Implements non-trivial copy-construction and copy-assignment.
-template <typename... Ts>
-class variant_copy_impl_non_trivial : protected variant_move_impl<Ts...> {
- using base = variant_move_impl<Ts...>;
-
-public:
- using base::base;
-
- variant_copy_impl_non_trivial(
- const variant_copy_impl_non_trivial& other) {
- index_ = other.index_;
- storage_.copy_construct_from(index_, other.storage_);
- }
-
- variant_copy_impl_non_trivial(
- variant_copy_impl_non_trivial&&) = default;
-
- variant_copy_impl_non_trivial& operator=(
- const variant_copy_impl_non_trivial& other) {
- if (&other == this)
- return *this;
- storage_.destroy(index_);
- index_ = other.index_;
- storage_.copy_construct_from(index_, other.storage_);
- return *this;
- }
-
- variant_copy_impl_non_trivial& operator=(
- variant_copy_impl_non_trivial&&) = default;
-
-protected:
- using base::index_;
- using base::storage_;
+// Mixes in instantiations of check_valid_option for each element in
+// fit::variant<Ts...>, creating a set of check(Ti) functions that might match
+// T following the conversion rules.
+template <typename T, typename VariantList,
+ typename = std::make_index_sequence<variant_list_size<VariantList>::value>>
+struct find_valid_option {
+ // Non-static so that find_valid_option<...>::check is always a valid name
+ // in the using clause of the recursive case, but doesn't participate in the
+ // overload resolution in the valid_option_index trait.
+ void check();
};
-// Selects an appropriate variant base class for copying.
-// Use the base impl if the type is trivially
+// Recursive case. This would be simpler with C++17 pack expansion in using
+// directives, but this must function in C++14.
+template <typename T, typename Ti, size_t Index, typename... Ts, size_t... Is>
+struct find_valid_option<T, variant_list<Ti, Ts...>, std::index_sequence<Index, Is...>>
+ : check_valid_option<Index, T, Ti>,
+ find_valid_option<T, variant_list<Ts...>, std::index_sequence<Is...>> {
+ // Introduce the base class definitions of check() into this scope. The
+ // static check(Ti) methods participate in overload resolution in the
+ // valid_option_index trait, while the non-static check() methods are
+ // ignored.
+ using check_valid_option<Index, T, Ti>::check;
+ using find_valid_option<T, variant_list<Ts...>, std::index_sequence<Is...>>::check;
+};
+
+// Evaluates to the index of the valid target type Ti selected from
+// fit::variant<Ts...>. The type expression is well formed IFF a single valid
+// target type is available that converts from T.
+template <typename T, typename VariantList>
+using valid_option_index = decltype(find_valid_option<T, VariantList>::check(std::declval<T>()));
+
+// Evaluates to the index of the valid target Ti that converts from T or the
+// reserved empty index when no uniquely suitable option is available.
+template <typename T, typename Variant, typename = void>
+struct selected_index : std::integral_constant<size_t, ::fit::internal::empty_index> {};
+
+template <typename T, typename... Ts>
+struct selected_index<T, variant<Ts...>, void_t<valid_option_index<T, variant_list<Ts...>>>>
+ : valid_option_index<T, variant_list<Ts...>> {};
+
+} // namespace internal
+
+// A resonably complete implementation of std::variant compatible with C++14.
template <typename... Ts>
-using variant_copy_impl =
- std::conditional_t<
- (std::is_copy_constructible<variant_move_impl<Ts...>>::value &&
- std::is_copy_assignable<variant_move_impl<Ts...>>::value) ||
- !variant_storage<Ts...>::copy_construct_supported,
- variant_move_impl<Ts...>,
- variant_copy_impl_non_trivial<Ts...>>;
+class variant
+ : private ::fit::internal::modulate_default_constructor<::fit::internal::first_t<Ts...>>,
+ private ::fit::internal::modulate_copy_and_move<Ts...> {
+ private:
+ static_assert(sizeof...(Ts) > 0, "Variant must have at least one type!");
-// Actual variant type.
-template <typename... Ts>
-class variant : private variant_copy_impl<Ts...> {
- using base = variant_copy_impl<Ts...>;
+ static constexpr bool nothrow_default_constructible =
+ std::is_nothrow_default_constructible<::fit::internal::first_t<Ts...>>::value;
-public:
- constexpr variant() = default;
+ static constexpr bool nothrow_move_constructible =
+ conjunction_v<std::is_nothrow_move_constructible<Ts>...>;
- template <size_t index, typename... Args>
- explicit constexpr variant(in_place_index_t<index> i, Args&&... args)
- : base(i, std::forward<Args>(args)...) {}
+ static constexpr auto default_init_v = ::fit::internal::default_init_v;
+ static constexpr auto trivial_init_v = ::fit::internal::trivial_init_v;
- variant(const variant&) = default;
- variant(variant&&) = default;
- ~variant() = default;
+ template <typename T>
+ using type_tag = ::fit::internal::type_tag<T>;
+ template <size_t Index>
+ using index_tag = ::fit::internal::index_tag<Index>;
- variant& operator=(const variant&) = default;
- variant& operator=(variant&&) = default;
+ template <typename T>
+ using not_self_type = ::fit::internal::not_same_type<variant, T>;
- constexpr size_t index() const { return index_; }
+ template <typename T>
+ using not_in_place = ::fit::internal::not_same_type<in_place_t, T>;
- template <size_t index>
- constexpr auto& get() {
- assert(index_ == index);
- return storage_.get(in_place_index<index>);
+ template <typename T>
+ struct occurs_once
+ : std::integral_constant<bool, ::fit::internal::occurences_of_v<T, Ts...> == 1> {};
+
+ template <typename... Conditions>
+ using requires_conditions = ::fit::internal::requires_conditions<Conditions...>;
+
+ template <typename... Conditions>
+ using assignment_requires_conditions =
+ ::fit::internal::assignment_requires_conditions<variant&, Conditions...>;
+
+ template <typename T, typename... Args>
+ using emplace_constructible_by_type =
+ std::enable_if_t<(::fit::internal::occurences_of_v<T, Ts...> == 1 &&
+ std::is_constructible<T, Args...>::value),
+ std::add_lvalue_reference_t<T>>;
+
+ template <size_t Index, typename = std::enable_if_t<(Index < sizeof...(Ts))>>
+ using alternative_t = variant_alternative_t<Index, variant>;
+
+ template <size_t Index, typename... Args>
+ using emplace_constructible_by_index =
+ std::enable_if_t<std::is_constructible<alternative_t<Index>, Args...>::value,
+ std::add_lvalue_reference_t<alternative_t<Index>>>;
+
+ template <typename T>
+ static constexpr size_t selected_index = ::fit::internal::selected_index<T, variant>::value;
+
+ template <typename T, typename = std::enable_if<not_self_type<T>::value>>
+ using selected_t = alternative_t<selected_index<T>>;
+
+ [[noreturn]] static constexpr void throw_bad_variant_access(const char* reason) {
+#if __cpp_exceptions
+ throw bad_variant_access(reason);
+#else
+ (void)reason;
+ __builtin_abort();
+#endif
+ }
+
+ public:
+ // Default constructors.
+
+ constexpr variant() noexcept(nothrow_default_constructible) : storage_{default_init_v} {}
+
+ // Copy/move constructors and assignment operators.
+
+ constexpr variant(const variant&) = default;
+ constexpr variant& operator=(const variant&) = default;
+
+ constexpr variant(variant&&) noexcept(nothrow_move_constructible) = default;
+ constexpr variant& operator=(variant&&) = default;
+
+ // Converting constructors.
+
+ template <typename T,
+ requires_conditions<std::integral_constant<bool, (sizeof...(Ts) > 0)>,
+ not_in_place<T>> = true,
+ typename Ti = selected_t<T&&>,
+ requires_conditions<occurs_once<Ti>, std::is_constructible<Ti, T>> = true>
+ constexpr variant(T&& value) noexcept(std::is_nothrow_constructible<Ti, T>::value)
+ : storage_(type_tag<Ti>{}, std::forward<T>(value)) {}
+
+ template <typename T, typename... Args,
+ requires_conditions<occurs_once<T>, std::is_constructible<T, Args...>> = true>
+ explicit constexpr variant(in_place_type_t<T>, Args&&... args)
+ : storage_(type_tag<T>{}, std::forward<Args>(args)...) {}
+
+ template <typename T, typename U, typename... Args,
+ requires_conditions<occurs_once<T>, std::is_constructible<T, std::initializer_list<T>&,
+ Args...>> = true>
+ explicit constexpr variant(in_place_type_t<T>, std::initializer_list<U> init_list, Args&&... args)
+ : storage_(type_tag<T>{}, init_list, std::forward<Args>(args)...) {}
+
+ template <size_t Index, typename... Args,
+ requires_conditions<std::is_constructible<alternative_t<Index>, Args...>> = true>
+ explicit constexpr variant(in_place_index_t<Index>, Args&&... args)
+ : storage_(index_tag<Index>{}, std::forward<Args>(args)...) {}
+
+ template <size_t Index, typename U, typename... Args,
+ requires_conditions<std::is_constructible<alternative_t<Index>,
+ std::initializer_list<U>&, Args...>> = true>
+ explicit constexpr variant(in_place_index_t<Index>, std::initializer_list<U> init_list,
+ Args&&... args)
+ : storage_(index_tag<Index>{}, init_list, std::forward<Args>(args)...) {}
+
+ ~variant() = default;
+
+ // Converting assignment.
+
+ template <typename T>
+ constexpr assignment_requires_conditions<
+ occurs_once<selected_t<T>>, std::is_constructible<selected_t<T&&>, T>,
+ std::is_assignable<selected_t<T&&>&, T>,
+ disjunction<std::is_nothrow_constructible<selected_t<T&&>, T>,
+ negation<std::is_nothrow_move_constructible<selected_t<T&&>>>>>
+ operator=(T&& value) noexcept(std::is_nothrow_assignable<selected_t<T&&>&, T>::value&&
+ std::is_nothrow_constructible<selected_t<T&&>, T>::value) {
+ constexpr auto index = selected_index<T>;
+ if (storage_.index() == index) {
+ storage_.get(index_tag<index>{}) = std::forward<T>(value);
+ } else {
+ this->emplace<index>(std::forward<T>(value));
}
+ return *this;
+ }
- template <size_t index>
- constexpr const auto& get() const {
- assert(index_ == index);
- return storage_.get(in_place_index<index>);
+ template <typename T>
+ constexpr assignment_requires_conditions<
+ occurs_once<selected_t<T>>, std::is_constructible<selected_t<T&&>, T>,
+ std::is_assignable<selected_t<T&&>&, T>,
+ conjunction<negation<std::is_nothrow_constructible<selected_t<T&&>, T>>,
+ std::is_nothrow_move_constructible<selected_t<T&&>>>>
+ operator=(T&& value) noexcept(std::is_nothrow_assignable<selected_t<T&&>&, T>::value&&
+ std::is_nothrow_constructible<selected_t<T&&>, T>::value) {
+ constexpr auto index = selected_index<T>;
+ if (storage_.index() == index) {
+ storage_.get(index_tag<index>{}) = std::forward<T>(value);
+ } else {
+ this->operator=(variant(std::forward<T>(value)));
}
+ return *this;
+ }
- template <size_t index, typename... Args>
- auto& emplace(Args&&... args) {
- this->destroy();
- index_ = index;
- return storage_.emplace(in_place_index<index>,
- std::forward<Args>(args)...);
+ constexpr size_t index() const noexcept { return storage_.index(); }
+
+ // TODO(eieio): Remove uses of these in favor of non-member get.
+ template <size_t Index>
+ constexpr auto& get() & {
+ if (storage_.has_value(index_tag<Index>{})) {
+ return storage_.get(index_tag<Index>{});
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
}
-
- void swap(variant& other) {
- using std::swap;
- if (&other == this)
- return;
- if (index_ == other.index_) {
- storage_.swap(index_, other.storage_);
- } else {
- variant temp(std::move(*this));
- *this = std::move(other);
- other = std::move(temp);
- }
+ }
+ template <size_t Index>
+ constexpr const auto& get() const& {
+ if (storage_.has_value(index_tag<Index>{})) {
+ return storage_.get(index_tag<Index>{});
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
}
+ }
+ template <size_t Index>
+ constexpr auto&& get() && {
+ if (storage_.has_value(index_tag<Index>{})) {
+ return std::move(storage_.get(index_tag<Index>{}));
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
+ template <size_t Index>
+ constexpr const auto&& get() const&& {
+ if (storage_.has_value(index_tag<Index>{})) {
+ return std::move(storage_.get(index_tag<Index>{}));
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
-private:
- using base::index_;
- using base::storage_;
+ template <typename T>
+ constexpr auto& get() & {
+ if (storage_.has_value(type_tag<T>{})) {
+ return storage_.get(type_tag<T>{});
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
+ template <typename T>
+ constexpr const auto& get() const& {
+ if (storage_.has_value(type_tag<T>{})) {
+ return storage_.get(type_tag<T>{});
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
+ template <typename T>
+ constexpr auto&& get() && {
+ if (storage_.has_value(type_tag<T>{})) {
+ return std::move(storage_.get(type_tag<T>{}));
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
+ template <typename T>
+ constexpr const auto&& get() const&& {
+ if (storage_.has_value(type_tag<T>{})) {
+ return std::move(storage_.get(type_tag<T>{}));
+ } else {
+ throw_bad_variant_access("Bad get<>() from variant!");
+ }
+ }
+
+ // Emplacement.
+
+ template <typename T, typename... Args>
+ constexpr emplace_constructible_by_type<T, Args&&...> emplace(Args&&... args) {
+ storage_.reset();
+ storage_.construct(type_tag<T>{}, std::forward<Args>(args)...);
+ return storage_.get(type_tag<T>{});
+ }
+
+ template <typename T, typename U, typename... Args>
+ constexpr emplace_constructible_by_type<T, std::initializer_list<U>&, Args&&...> emplace(
+ std::initializer_list<U> init_list, Args&&... args) {
+ storage_.reset();
+ storage_.construct(type_tag<T>{}, init_list, std::forward<Args>(args)...);
+ return storage_.get(type_tag<T>{});
+ }
+
+ template <size_t Index, typename... Args>
+ constexpr emplace_constructible_by_index<Index, Args&&...> emplace(Args&&... args) {
+ storage_.reset();
+ storage_.construct(index_tag<Index>{}, std::forward<Args>(args)...);
+ return storage_.get(index_tag<Index>{});
+ }
+
+ template <size_t Index, typename U, typename... Args>
+ constexpr emplace_constructible_by_index<Index, std::initializer_list<U>&, Args&&...> emplace(
+ std::initializer_list<U> init_list, Args&&... args) {
+ storage_.reset();
+ storage_.construct(index_tag<Index>{}, init_list, std::forward<Args>(args)...);
+ return storage_.get(index_tag<Index>{});
+ }
+
+ // Swap.
+
+ void swap(variant& other) { storage_.swap(other.storage_); }
+
+ // Comparison.
+
+ friend constexpr bool operator==(const variant& lhs, const variant& rhs) {
+ bool result = false;
+ const bool has_value =
+ lhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (lhs.index() != rhs.index()) {
+ result = false;
+ } else {
+ result = lhs.storage_.get(active_index_tag) == rhs.storage_.get(active_index_tag);
+ }
+ });
+ return !has_value || result;
+ }
+ friend constexpr bool operator!=(const variant& lhs, const variant& rhs) {
+ bool result = true;
+ const bool has_value =
+ lhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (lhs.index() != rhs.index()) {
+ result = true;
+ } else {
+ result = lhs.storage_.get(active_index_tag) != rhs.storage_.get(active_index_tag);
+ }
+ });
+ return has_value && result;
+ }
+ friend constexpr bool operator<(const variant& lhs, const variant& rhs) {
+ bool result = true;
+ const bool has_value =
+ rhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (lhs.storage_.is_empty()) {
+ result = true;
+ } else if (lhs.index() < rhs.index()) {
+ result = true;
+ } else if (lhs.index() > rhs.index()) {
+ result = false;
+ } else {
+ result = lhs.storage_.get(active_index_tag) < rhs.storage_.get(active_index_tag);
+ }
+ });
+ return has_value && result;
+ }
+ friend constexpr bool operator>(const variant& lhs, const variant& rhs) {
+ bool result = true;
+ const bool has_value =
+ lhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (rhs.storage_.is_empty()) {
+ result = true;
+ } else if (lhs.index() > rhs.index()) {
+ result = true;
+ } else if (lhs.index() < rhs.index()) {
+ result = false;
+ } else {
+ result = lhs.storage_.get(active_index_tag) > rhs.storage_.get(active_index_tag);
+ }
+ });
+ return has_value && result;
+ }
+ friend constexpr bool operator<=(const variant& lhs, const variant& rhs) {
+ bool result = false;
+ const bool has_value =
+ lhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (rhs.storage_.is_empty()) {
+ result = false;
+ } else if (lhs.index() < rhs.index()) {
+ result = true;
+ } else if (lhs.index() > rhs.index()) {
+ result = false;
+ } else {
+ result = lhs.storage_.get(active_index_tag) <= rhs.storage_.get(active_index_tag);
+ }
+ });
+ return !has_value || result;
+ }
+ friend constexpr bool operator>=(const variant& lhs, const variant& rhs) {
+ bool result = false;
+ const bool has_value =
+ rhs.storage_.visit([&result, &lhs, &rhs](auto, auto active_index_tag, const auto*) {
+ if (lhs.storage_.is_empty()) {
+ result = false;
+ } else if (lhs.index() > rhs.index()) {
+ result = true;
+ } else if (lhs.index() < rhs.index()) {
+ result = false;
+ } else {
+ result = lhs.storage_.get(active_index_tag) >= rhs.storage_.get(active_index_tag);
+ }
+ });
+ return !has_value || result;
+ }
+
+ private:
+ ::fit::internal::storage_type<Ts...> storage_;
};
// Swaps variants.
template <typename... Ts>
void swap(variant<Ts...>& a, variant<Ts...>& b) {
- a.swap(b);
+ a.swap(b);
}
-// Gets the type of a variant alternative with the given index.
-template <size_t index, typename Variant>
-struct variant_alternative;
+// Accesses the variant by zero-based index.
+//
+// Accesses should use ADL, similar to the pattern for std::swap:
+//
+// using std::get;
+// get<some_index>(some_fit_variant);
+//
+// This makes code adaptable to substituting std::variant for fit::variant on
+// newer compilers.
+template <size_t Index, typename... Ts>
+constexpr auto& get(variant<Ts...>& value) {
+ return value.template get<Index>();
+}
+template <size_t Index, typename... Ts>
+constexpr auto&& get(variant<Ts...>&& value) {
+ return std::move(value).template get<Index>();
+}
+template <size_t Index, typename... Ts>
+constexpr const auto& get(const variant<Ts...>& value) {
+ return value.template get<Index>();
+}
+template <size_t Index, typename... Ts>
+constexpr const auto&& get(const variant<Ts...>&& value) {
+ return std::move(value).template get<Index>();
+}
-template <size_t index, typename T0, typename... Ts>
-struct variant_alternative<index, variant<T0, Ts...>>
- : variant_alternative<index - 1, variant<Ts...>> {};
+// Accesses the variant by unique type. See note above about ADL.
+template <typename T, typename... Ts>
+constexpr auto& get(variant<Ts...>& value) {
+ return value.template get<T>();
+}
+template <typename T, typename... Ts>
+constexpr auto&& get(variant<Ts...>&& value) {
+ return std::move(value).template get<T>();
+}
+template <typename T, typename... Ts>
+constexpr const auto& get(const variant<Ts...>& value) {
+ return value.template get<T>();
+}
+template <typename T, typename... Ts>
+constexpr const auto&& get(const variant<Ts...>&& value) {
+ return std::move(value).template get<T>();
+}
-template <typename T0, typename... Ts>
-struct variant_alternative<0, variant<T0, Ts...>> {
- using type = T0;
-};
+// Checks if the variant holds type T. See note above about ADL.
+template <typename T, typename... Ts>
+constexpr bool holds_alternative(const variant<Ts...>& value) {
+ constexpr auto index = ::fit::internal::selected_index<T, variant<Ts...>>::value;
+ return value.index() == index;
+}
-template <size_t index, typename Variant>
-using variant_alternative_t = typename variant_alternative<index, Variant>::type;
+// TODO(eieio): Remove once the old ::fit::internal spellings of these types is
+// removed from FIDL.
+namespace internal {
-} // namespace internal
-} // namespace fit
+using ::fit::monostate;
+using ::fit::variant;
-#endif // LIB_FIT_VARIANT_H_
+} // namespace internal
+
+} // namespace fit
+
+#endif // LIB_FIT_VARIANT_H_
diff --git a/pkg/fit/meta.json b/pkg/fit/meta.json
index db86eb9..1cfa090 100644
--- a/pkg/fit/meta.json
+++ b/pkg/fit/meta.json
@@ -1,57 +1,44 @@
{
- "banjo_deps": [],
- "deps": [],
- "fidl_deps": [],
- "files": [
- "pkg/fit/promise.cpp",
- "pkg/fit/scheduler.cpp",
- "pkg/fit/sequencer.cpp",
- "pkg/fit/single_threaded_executor.cpp",
- "pkg/fit/include/lib/fit/bridge.h",
- "pkg/fit/include/lib/fit/bridge_internal.h",
- "pkg/fit/include/lib/fit/defer.h",
- "pkg/fit/include/lib/fit/function.h",
- "pkg/fit/include/lib/fit/function_internal.h",
- "pkg/fit/include/lib/fit/function_traits.h",
- "pkg/fit/include/lib/fit/nullable.h",
- "pkg/fit/include/lib/fit/optional.h",
- "pkg/fit/include/lib/fit/promise.h",
- "pkg/fit/include/lib/fit/promise_internal.h",
- "pkg/fit/include/lib/fit/result.h",
- "pkg/fit/include/lib/fit/scheduler.h",
- "pkg/fit/include/lib/fit/sequencer.h",
- "pkg/fit/include/lib/fit/single_threaded_executor.h",
- "pkg/fit/include/lib/fit/thread_safety.h",
- "pkg/fit/include/lib/fit/traits.h",
- "pkg/fit/include/lib/fit/variant.h"
- ],
+ "banjo_deps": [],
+ "deps": [],
+ "fidl_deps": [],
"headers": [
- "pkg/fit/include/lib/fit/bridge.h",
- "pkg/fit/include/lib/fit/bridge_internal.h",
- "pkg/fit/include/lib/fit/defer.h",
- "pkg/fit/include/lib/fit/function.h",
- "pkg/fit/include/lib/fit/function_internal.h",
- "pkg/fit/include/lib/fit/function_traits.h",
- "pkg/fit/include/lib/fit/nullable.h",
- "pkg/fit/include/lib/fit/optional.h",
- "pkg/fit/include/lib/fit/promise.h",
- "pkg/fit/include/lib/fit/promise_internal.h",
- "pkg/fit/include/lib/fit/result.h",
- "pkg/fit/include/lib/fit/scheduler.h",
- "pkg/fit/include/lib/fit/sequencer.h",
- "pkg/fit/include/lib/fit/single_threaded_executor.h",
- "pkg/fit/include/lib/fit/thread_safety.h",
- "pkg/fit/include/lib/fit/traits.h",
+ "pkg/fit/include/lib/fit/barrier.h",
+ "pkg/fit/include/lib/fit/bridge.h",
+ "pkg/fit/include/lib/fit/bridge_internal.h",
+ "pkg/fit/include/lib/fit/constructors_internal.h",
+ "pkg/fit/include/lib/fit/defer.h",
+ "pkg/fit/include/lib/fit/function.h",
+ "pkg/fit/include/lib/fit/function_internal.h",
+ "pkg/fit/include/lib/fit/function_traits.h",
+ "pkg/fit/include/lib/fit/in_place_internal.h",
+ "pkg/fit/include/lib/fit/nullable.h",
+ "pkg/fit/include/lib/fit/optional.h",
+ "pkg/fit/include/lib/fit/promise.h",
+ "pkg/fit/include/lib/fit/promise_internal.h",
+ "pkg/fit/include/lib/fit/result.h",
+ "pkg/fit/include/lib/fit/scheduler.h",
+ "pkg/fit/include/lib/fit/scope.h",
+ "pkg/fit/include/lib/fit/sequencer.h",
+ "pkg/fit/include/lib/fit/single_threaded_executor.h",
+ "pkg/fit/include/lib/fit/storage_internal.h",
+ "pkg/fit/include/lib/fit/source_location.h",
+ "pkg/fit/include/lib/fit/string_view.h",
+ "pkg/fit/include/lib/fit/thread_safety.h",
+ "pkg/fit/include/lib/fit/traits.h",
+ "pkg/fit/include/lib/fit/utility_internal.h",
"pkg/fit/include/lib/fit/variant.h"
- ],
- "include_dir": "pkg/fit/include",
- "name": "fit",
- "root": "pkg/fit",
+ ],
+ "include_dir": "pkg/fit/include",
+ "name": "fit",
+ "root": "pkg/fit",
"sources": [
- "pkg/fit/promise.cpp",
- "pkg/fit/scheduler.cpp",
- "pkg/fit/sequencer.cpp",
- "pkg/fit/single_threaded_executor.cpp"
- ],
+ "pkg/fit/barrier.cc",
+ "pkg/fit/promise.cc",
+ "pkg/fit/scheduler.cc",
+ "pkg/fit/scope.cc",
+ "pkg/fit/sequencer.cc",
+ "pkg/fit/single_threaded_executor.cc"
+ ],
"type": "cc_source_library"
}
\ No newline at end of file
diff --git a/pkg/fit/promise.cc b/pkg/fit/promise.cc
new file mode 100644
index 0000000..f25e8ab
--- /dev/null
+++ b/pkg/fit/promise.cc
@@ -0,0 +1,58 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/fit/promise.h>
+
+namespace fit {
+
+suspended_task::suspended_task(const suspended_task& other)
+ : resolver_(other.resolver_),
+ ticket_(resolver_ ? resolver_->duplicate_ticket(other.ticket_) : 0) {}
+
+suspended_task::suspended_task(suspended_task&& other)
+ : resolver_(other.resolver_), ticket_(other.ticket_) {
+ other.resolver_ = nullptr;
+}
+
+suspended_task::~suspended_task() { reset(); }
+
+void suspended_task::resolve(bool resume_task) {
+ if (resolver_) {
+ // Move the ticket to the stack to guard against possible re-entrance
+ // occurring as a side-effect of the task's own destructor running.
+ resolver* cached_resolver = resolver_;
+ ticket cached_ticket = ticket_;
+ resolver_ = nullptr;
+ cached_resolver->resolve_ticket(cached_ticket, resume_task);
+ }
+}
+
+suspended_task& suspended_task::operator=(const suspended_task& other) {
+ if (this != &other) {
+ reset();
+ resolver_ = other.resolver_;
+ ticket_ = resolver_ ? resolver_->duplicate_ticket(other.ticket_) : 0;
+ }
+ return *this;
+}
+
+suspended_task& suspended_task::operator=(suspended_task&& other) {
+ if (this != &other) {
+ reset();
+ resolver_ = other.resolver_;
+ ticket_ = other.ticket_;
+ other.resolver_ = nullptr;
+ }
+ return *this;
+}
+
+void suspended_task::swap(suspended_task& other) {
+ if (this != &other) {
+ using std::swap;
+ swap(resolver_, other.resolver_);
+ swap(ticket_, other.ticket_);
+ }
+}
+
+} // namespace fit
diff --git a/pkg/fit/promise.cpp b/pkg/fit/promise.cpp
deleted file mode 100644
index 8309f00..0000000
--- a/pkg/fit/promise.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Can't compile this for Zircon userspace yet since libstdc++ isn't available.
-#ifndef FIT_NO_STD_FOR_ZIRCON_USERSPACE
-
-#include <lib/fit/promise.h>
-
-namespace fit {
-
-suspended_task::suspended_task(const suspended_task& other)
- : resolver_(other.resolver_),
- ticket_(resolver_ ? resolver_->duplicate_ticket(other.ticket_) : 0) {}
-
-suspended_task::suspended_task(suspended_task&& other)
- : resolver_(other.resolver_), ticket_(other.ticket_) {
- other.resolver_ = nullptr;
-}
-
-suspended_task::~suspended_task() {
- reset();
-}
-
-void suspended_task::resolve(bool resume_task) {
- if (resolver_) {
- // Move the ticket to the stack to guard against possible re-entrance
- // occurring as a side-effect of the task's own destructor running.
- resolver* cached_resolver = resolver_;
- ticket cached_ticket = ticket_;
- resolver_ = nullptr;
- cached_resolver->resolve_ticket(cached_ticket, resume_task);
- }
-}
-
-suspended_task& suspended_task::operator=(const suspended_task& other) {
- if (this != &other) {
- reset();
- resolver_ = other.resolver_;
- ticket_ = resolver_ ? resolver_->duplicate_ticket(other.ticket_) : 0;
- }
- return *this;
-}
-
-suspended_task& suspended_task::operator=(suspended_task&& other) {
- if (this != &other) {
- reset();
- resolver_ = other.resolver_;
- ticket_ = other.ticket_;
- other.resolver_ = nullptr;
- }
- return *this;
-}
-
-} // namespace fit
-
-#endif // FIT_NO_STD_FOR_ZIRCON_USERSPACE
diff --git a/pkg/fit/scheduler.cc b/pkg/fit/scheduler.cc
new file mode 100644
index 0000000..144cc76
--- /dev/null
+++ b/pkg/fit/scheduler.cc
@@ -0,0 +1,122 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/fit/scheduler.h>
+
+#include <map>
+#include <queue>
+#include <utility>
+
+namespace fit {
+namespace subtle {
+
+scheduler::scheduler() = default;
+
+scheduler::~scheduler() = default;
+
+void scheduler::schedule_task(pending_task task) {
+ assert(task);
+ runnable_tasks_.push(std::move(task));
+}
+
+suspended_task::ticket scheduler::obtain_ticket(uint32_t initial_refs) {
+ suspended_task::ticket ticket = next_ticket_++;
+ tickets_.emplace(ticket, ticket_record(initial_refs));
+ return ticket;
+}
+
+void scheduler::finalize_ticket(suspended_task::ticket ticket, pending_task* task) {
+ auto it = tickets_.find(ticket);
+ assert(it != tickets_.end());
+ assert(!it->second.task);
+ assert(it->second.ref_count > 0);
+ assert(task);
+
+ it->second.ref_count--;
+ if (!*task) {
+ // task already finished
+ } else if (it->second.was_resumed) {
+ // task immediately became runnable
+ runnable_tasks_.push(std::move(*task));
+ } else if (it->second.ref_count > 0) {
+ // task remains suspended
+ it->second.task = std::move(*task);
+ suspended_task_count_++;
+ } // else, task was abandoned and caller retains ownership of it
+ if (it->second.ref_count == 0) {
+ tickets_.erase(it);
+ }
+}
+
+void scheduler::duplicate_ticket(suspended_task::ticket ticket) {
+ auto it = tickets_.find(ticket);
+ assert(it != tickets_.end());
+ assert(it->second.ref_count > 0);
+
+ it->second.ref_count++;
+ assert(it->second.ref_count != 0); // did we really make 4 billion refs?!
+}
+
+pending_task scheduler::release_ticket(suspended_task::ticket ticket) {
+ auto it = tickets_.find(ticket);
+ assert(it != tickets_.end());
+ assert(it->second.ref_count > 0);
+
+ it->second.ref_count--;
+ if (it->second.ref_count == 0) {
+ pending_task task = std::move(it->second.task);
+ if (task) {
+ assert(suspended_task_count_ > 0);
+ suspended_task_count_--;
+ }
+ tickets_.erase(it);
+ return task;
+ }
+ return pending_task();
+}
+
+bool scheduler::resume_task_with_ticket(suspended_task::ticket ticket) {
+ auto it = tickets_.find(ticket);
+ assert(it != tickets_.end());
+ assert(it->second.ref_count > 0);
+
+ bool did_resume = false;
+ it->second.ref_count--;
+ if (!it->second.was_resumed) {
+ it->second.was_resumed = true;
+ if (it->second.task) {
+ did_resume = true;
+ assert(suspended_task_count_ > 0);
+ suspended_task_count_--;
+ runnable_tasks_.push(std::move(it->second.task));
+ }
+ }
+ if (it->second.ref_count == 0) {
+ tickets_.erase(it);
+ }
+ return did_resume;
+}
+
+void scheduler::take_runnable_tasks(task_queue* tasks) {
+ assert(tasks && tasks->empty());
+ runnable_tasks_.swap(*tasks);
+}
+
+void scheduler::take_all_tasks(task_queue* tasks) {
+ assert(tasks && tasks->empty());
+
+ runnable_tasks_.swap(*tasks);
+ if (suspended_task_count_ > 0) {
+ for (auto& item : tickets_) {
+ if (item.second.task) {
+ assert(suspended_task_count_ > 0);
+ suspended_task_count_--;
+ tasks->push(std::move(item.second.task));
+ }
+ }
+ }
+}
+
+} // namespace subtle
+} // namespace fit
diff --git a/pkg/fit/scheduler.cpp b/pkg/fit/scheduler.cpp
deleted file mode 100644
index 69acc03..0000000
--- a/pkg/fit/scheduler.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Can't compile this for Zircon userspace yet since libstdc++ isn't available.
-#ifndef FIT_NO_STD_FOR_ZIRCON_USERSPACE
-
-#include <lib/fit/scheduler.h>
-
-#include <map>
-#include <queue>
-#include <utility>
-
-namespace fit {
-namespace subtle {
-
-scheduler::scheduler() = default;
-
-scheduler::~scheduler() = default;
-
-void scheduler::schedule_task(pending_task task) {
- assert(task);
- runnable_tasks_.push(std::move(task));
-}
-
-suspended_task::ticket scheduler::obtain_ticket(uint32_t initial_refs) {
- suspended_task::ticket ticket = next_ticket_++;
- tickets_.emplace(ticket, ticket_record(initial_refs));
- return ticket;
-}
-
-void scheduler::finalize_ticket(suspended_task::ticket ticket,
- pending_task* task) {
- auto it = tickets_.find(ticket);
- assert(it != tickets_.end());
- assert(!it->second.task);
- assert(it->second.ref_count > 0);
- assert(task);
-
- it->second.ref_count--;
- if (!*task) {
- // task already finished
- } else if (it->second.was_resumed) {
- // task immediately became runnable
- runnable_tasks_.push(std::move(*task));
- } else if (it->second.ref_count > 0) {
- // task remains suspended
- it->second.task = std::move(*task);
- suspended_task_count_++;
- } // else, task was abandoned and caller retains ownership of it
- if (it->second.ref_count == 0) {
- tickets_.erase(it);
- }
-}
-
-void scheduler::duplicate_ticket(suspended_task::ticket ticket) {
- auto it = tickets_.find(ticket);
- assert(it != tickets_.end());
- assert(it->second.ref_count > 0);
-
- it->second.ref_count++;
- assert(it->second.ref_count != 0); // did we really make 4 billion refs?!
-}
-
-pending_task scheduler::release_ticket(suspended_task::ticket ticket) {
- auto it = tickets_.find(ticket);
- assert(it != tickets_.end());
- assert(it->second.ref_count > 0);
-
- it->second.ref_count--;
- if (it->second.ref_count == 0) {
- pending_task task = std::move(it->second.task);
- if (task) {
- assert(suspended_task_count_ > 0);
- suspended_task_count_--;
- }
- tickets_.erase(it);
- return task;
- }
- return pending_task();
-}
-
-bool scheduler::resume_task_with_ticket(suspended_task::ticket ticket) {
- auto it = tickets_.find(ticket);
- assert(it != tickets_.end());
- assert(it->second.ref_count > 0);
-
- bool did_resume = false;
- it->second.ref_count--;
- if (!it->second.was_resumed) {
- it->second.was_resumed = true;
- if (it->second.task) {
- did_resume = true;
- assert(suspended_task_count_ > 0);
- suspended_task_count_--;
- runnable_tasks_.push(std::move(it->second.task));
- }
- }
- if (it->second.ref_count == 0) {
- tickets_.erase(it);
- }
- return did_resume;
-}
-
-void scheduler::take_runnable_tasks(task_queue* tasks) {
- assert(tasks && tasks->empty());
- runnable_tasks_.swap(*tasks);
-}
-
-void scheduler::take_all_tasks(task_queue* tasks) {
- assert(tasks && tasks->empty());
-
- runnable_tasks_.swap(*tasks);
- if (suspended_task_count_ > 0) {
- for (auto& item : tickets_) {
- if (item.second.task) {
- assert(suspended_task_count_ > 0);
- suspended_task_count_--;
- tasks->push(std::move(item.second.task));
- }
- }
- }
-}
-
-} // namespace subtle
-} // namespace fit
-
-#endif // FIT_NO_STD_FOR_ZIRCON_USERSPACE
diff --git a/pkg/fit/scope.cc b/pkg/fit/scope.cc
new file mode 100644
index 0000000..8777f4a
--- /dev/null
+++ b/pkg/fit/scope.cc
@@ -0,0 +1,143 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/fit/scope.h>
+
+namespace fit {
+
+scope::scope() : state_(new state()) {}
+
+scope::~scope() { state_->exit(true /*scope_was_destroyed*/); }
+
+scope::state::state() = default;
+
+scope::state::~state() {
+ assert(acquired_promise_count_.load(std::memory_order_relaxed) == scope_exited);
+ assert(scope_was_destroyed_);
+ assert(promise_handle_count_ == 0);
+ assert(head_promise_holder_ == nullptr);
+}
+
+bool scope::state::exited() const {
+ return acquired_promise_count_.load(std::memory_order_relaxed) & scope_exited;
+}
+
+void scope::state::exit(bool scope_was_destroyed) {
+ promise_holder_base* release_head = nullptr;
+ bool delete_self = false;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(!scope_was_destroyed_);
+ scope_was_destroyed_ = scope_was_destroyed;
+
+ // Atomically exit the scope. We cannot do this safely if there are
+ // any running promises since they might still be accessing state which
+ // is guarded by the scope. Worse, if a promise re-entrantly destroys
+ // the scope during its execution then as a side-effect the promise
+ // itself will be destroyed. So assert!
+ uint64_t prior_count =
+ acquired_promise_count_.exchange(scope_exited, std::memory_order_relaxed);
+ if (!(prior_count & scope_exited)) {
+ // Cannot exit fit::scope while any of its promises are running!
+ assert(prior_count == 0);
+
+ // Take the promises so they can be deleted outside of the lock.
+ release_head = head_promise_holder_;
+ head_promise_holder_ = nullptr;
+ }
+
+ // If there are no more handles then we can delete the state now.
+ delete_self = should_delete_self();
+ }
+
+ // Delete aborted promises and self outside of the lock.
+ while (release_head) {
+ promise_holder_base* release_next = release_head->next;
+ delete release_head;
+ release_head = release_next;
+ }
+ if (delete_self) {
+ delete this;
+ }
+}
+
+scope::promise_handle scope::state::adopt_promise(promise_holder_base* promise_holder) {
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ assert(!scope_was_destroyed_); // otherwise how did we get here?
+
+ // If the scope hasn't been exited yet, link the promise and mint
+ // a new handle. Otherwise we will abort the promise.
+ if (!exited()) {
+ if (head_promise_holder_) {
+ head_promise_holder_->prev = promise_holder;
+ promise_holder->next = head_promise_holder_;
+ }
+ head_promise_holder_ = promise_holder;
+ promise_handle_count_++;
+ return promise_handle(this, promise_holder);
+ }
+ }
+
+ // Delete aborted promise outside of the lock.
+ delete promise_holder;
+ return promise_handle{};
+}
+
+void scope::state::drop_promise(promise_handle promise_handle) {
+ if (!promise_handle.promise_holder_) {
+ return; // invalid handle, nothing to do
+ }
+
+ {
+ std::lock_guard<std::mutex> lock(promise_handle.state_->mutex_);
+
+ // If the scope hasn't been exited yet, unlink the promise and
+ // prepare to destroy it. Otherwise, it's already been unlinked
+ // and destroyed so release the handle but don't touch the pointer!
+ assert(promise_handle.state_->promise_handle_count_ > 0);
+ promise_handle.state_->promise_handle_count_--;
+ if (!promise_handle.state_->exited()) {
+ if (promise_handle.promise_holder_->next) {
+ promise_handle.promise_holder_->next->prev = promise_handle.promise_holder_->prev;
+ }
+ if (promise_handle.promise_holder_->prev) {
+ promise_handle.promise_holder_->prev->next = promise_handle.promise_holder_->next;
+ } else {
+ promise_handle.state_->head_promise_holder_ = promise_handle.promise_holder_->next;
+ }
+ // Fallthrough to delete the promise.
+ } else if (!promise_handle.state_->should_delete_self()) {
+ return;
+ } else {
+ // Fallthrough to delete self.
+ promise_handle.promise_holder_ = nullptr;
+ }
+ }
+
+ // Delete the promise or scope outside of the lock.
+ if (promise_handle.promise_holder_) {
+ delete promise_handle.promise_holder_;
+ } else {
+ delete promise_handle.state_;
+ }
+}
+
+scope::promise_holder_base* scope::state::try_acquire_promise(promise_handle promise_handle) {
+ if (promise_handle.promise_holder_) {
+ uint64_t prior_count =
+ promise_handle.state_->acquired_promise_count_.fetch_add(1u, std::memory_order_relaxed);
+ if (!(prior_count & scope_exited)) {
+ return promise_handle.promise_holder_;
+ }
+ promise_handle.state_->acquired_promise_count_.fetch_sub(1u, std::memory_order_relaxed);
+ }
+ return nullptr;
+}
+
+void scope::state::release_promise(promise_handle promise_handle) {
+ promise_handle.state_->acquired_promise_count_.fetch_sub(1u, std::memory_order_relaxed);
+}
+
+} // namespace fit
diff --git a/pkg/fit/sequencer.cc b/pkg/fit/sequencer.cc
new file mode 100644
index 0000000..69d4da0
--- /dev/null
+++ b/pkg/fit/sequencer.cc
@@ -0,0 +1,26 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/fit/sequencer.h>
+
+namespace fit {
+
+sequencer::sequencer() {
+ // Capture a new consumer and intentionally abandon its associated
+ // completer so that a promise chained onto the consumer using
+ // |promise_or()| will become immediately runnable.
+ fit::bridge<> bridge;
+ prior_ = std::move(bridge.consumer);
+}
+
+sequencer::~sequencer() = default;
+
+fit::consumer<> sequencer::swap_prior(fit::consumer<> new_prior) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ fit::consumer<> old_prior = std::move(prior_);
+ prior_ = std::move(new_prior);
+ return old_prior;
+}
+
+} // namespace fit
diff --git a/pkg/fit/sequencer.cpp b/pkg/fit/sequencer.cpp
deleted file mode 100644
index 687db67..0000000
--- a/pkg/fit/sequencer.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Can't compile this for Zircon userspace yet since libstdc++ isn't available.
-#ifndef FIT_NO_STD_FOR_ZIRCON_USERSPACE
-
-#include <lib/fit/sequencer.h>
-
-namespace fit {
-
-sequencer::sequencer() {
- // Capture a new consumer and intentionally abandon its associated
- // completer so that a promise chained onto the consumer using
- // |promise_or()| will become immediately runnable.
- fit::bridge<> bridge;
- prior_ = std::move(bridge.consumer());
-}
-
-sequencer::~sequencer() = default;
-
-fit::consumer<> sequencer::swap_prior(fit::consumer<> new_prior) {
- std::lock_guard<std::mutex> lock(mutex_);
- fit::consumer<> old_prior = std::move(prior_);
- prior_ = std::move(new_prior);
- return old_prior;
-}
-
-} // namespace fit
-
-#endif // FIT_NO_STD_FOR_ZIRCON_USERSPACE
diff --git a/pkg/fit/single_threaded_executor.cc b/pkg/fit/single_threaded_executor.cc
new file mode 100644
index 0000000..9b3909f
--- /dev/null
+++ b/pkg/fit/single_threaded_executor.cc
@@ -0,0 +1,224 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <condition_variable>
+#include <mutex>
+
+#include <lib/fit/single_threaded_executor.h>
+#include <lib/fit/thread_safety.h>
+
+namespace fit {
+
+// The dispatcher runs tasks and provides the suspended task resolver.
+//
+// The lifetime of this object is somewhat complex since there are pointers
+// to it from multiple sources which are released in different ways.
+//
+// - |single_threaded_executor| holds a pointer in |dispatcher_| which it releases
+// after calling |shutdown()| to inform the dispatcher of its own demise
+// - |suspended_task| holds a pointer to the dispatcher's resolver
+// interface and the number of outstanding pointers corresponds to the
+// number of outstanding suspended task tickets tracked by |scheduler_|.
+//
+// The dispatcher deletes itself once all pointers have been released.
+class single_threaded_executor::dispatcher_impl final : public suspended_task::resolver {
+ public:
+ dispatcher_impl();
+
+ void shutdown();
+ void schedule_task(pending_task task);
+ void run(context_impl& context);
+ suspended_task suspend_current_task();
+
+ suspended_task::ticket duplicate_ticket(suspended_task::ticket ticket) override;
+ void resolve_ticket(suspended_task::ticket ticket, bool resume_task) override;
+
+ private:
+ ~dispatcher_impl() override;
+
+ void wait_for_runnable_tasks(fit::subtle::scheduler::task_queue* out_tasks);
+ void run_task(pending_task* task, context& context);
+
+ suspended_task::ticket current_task_ticket_ = 0;
+ std::condition_variable wake_;
+
+ // A bunch of state that is guarded by a mutex.
+ struct {
+ std::mutex mutex_;
+ bool was_shutdown_ FIT_GUARDED(mutex_) = false;
+ bool need_wake_ FIT_GUARDED(mutex_) = false;
+ fit::subtle::scheduler scheduler_ FIT_GUARDED(mutex_);
+ } guarded_;
+};
+
+single_threaded_executor::single_threaded_executor()
+ : context_(this), dispatcher_(new dispatcher_impl()) {}
+
+single_threaded_executor::~single_threaded_executor() { dispatcher_->shutdown(); }
+
+void single_threaded_executor::schedule_task(pending_task task) {
+ assert(task);
+ dispatcher_->schedule_task(std::move(task));
+}
+
+void single_threaded_executor::run() { dispatcher_->run(context_); }
+
+single_threaded_executor::context_impl::context_impl(single_threaded_executor* executor)
+ : executor_(executor) {}
+
+single_threaded_executor::context_impl::~context_impl() = default;
+
+single_threaded_executor* single_threaded_executor::context_impl::executor() const {
+ return executor_;
+}
+
+suspended_task single_threaded_executor::context_impl::suspend_task() {
+ return executor_->dispatcher_->suspend_current_task();
+}
+
+single_threaded_executor::dispatcher_impl::dispatcher_impl() = default;
+
+single_threaded_executor::dispatcher_impl::~dispatcher_impl() {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ assert(guarded_.was_shutdown_);
+ assert(!guarded_.scheduler_.has_runnable_tasks());
+ assert(!guarded_.scheduler_.has_suspended_tasks());
+ assert(!guarded_.scheduler_.has_outstanding_tickets());
+}
+
+void single_threaded_executor::dispatcher_impl::shutdown() {
+ fit::subtle::scheduler::task_queue tasks; // drop outside of the lock
+ {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ assert(!guarded_.was_shutdown_);
+ guarded_.was_shutdown_ = true;
+ guarded_.scheduler_.take_all_tasks(&tasks);
+ if (guarded_.scheduler_.has_outstanding_tickets()) {
+ return; // can't delete self yet
+ }
+ }
+
+ // Must destroy self outside of the lock.
+ delete this;
+}
+
+void single_threaded_executor::dispatcher_impl::schedule_task(pending_task task) {
+ {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ assert(!guarded_.was_shutdown_);
+ guarded_.scheduler_.schedule_task(std::move(task));
+ if (!guarded_.need_wake_) {
+ return; // don't need to wake
+ }
+ guarded_.need_wake_ = false;
+ }
+
+ // It is more efficient to notify outside the lock.
+ wake_.notify_one();
+}
+
+void single_threaded_executor::dispatcher_impl::run(context_impl& context) {
+ fit::subtle::scheduler::task_queue tasks;
+ for (;;) {
+ wait_for_runnable_tasks(&tasks);
+ if (tasks.empty()) {
+ return; // all done!
+ }
+
+ do {
+ run_task(&tasks.front(), context);
+ tasks.pop(); // the task may be destroyed here if it was not suspended
+ } while (!tasks.empty());
+ }
+}
+
+// Must only be called while |run_task()| is running a task.
+// This happens when the task's continuation calls |context::suspend_task()|
+// upon the context it received as an argument.
+suspended_task single_threaded_executor::dispatcher_impl::suspend_current_task() {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ assert(!guarded_.was_shutdown_);
+ if (current_task_ticket_ == 0) {
+ current_task_ticket_ = guarded_.scheduler_.obtain_ticket(2 /*initial_refs*/);
+ } else {
+ guarded_.scheduler_.duplicate_ticket(current_task_ticket_);
+ }
+ return suspended_task(this, current_task_ticket_);
+}
+
+// Unfortunately std::unique_lock does not support thread-safety annotations
+void single_threaded_executor::dispatcher_impl::wait_for_runnable_tasks(
+ fit::subtle::scheduler::task_queue* out_tasks) FIT_NO_THREAD_SAFETY_ANALYSIS {
+ std::unique_lock<std::mutex> lock(guarded_.mutex_);
+ for (;;) {
+ assert(!guarded_.was_shutdown_);
+ guarded_.scheduler_.take_runnable_tasks(out_tasks);
+ if (!out_tasks->empty()) {
+ return; // got some tasks
+ }
+ if (!guarded_.scheduler_.has_suspended_tasks()) {
+ return; // all done!
+ }
+ guarded_.need_wake_ = true;
+ wake_.wait(lock);
+ guarded_.need_wake_ = false;
+ }
+}
+
+void single_threaded_executor::dispatcher_impl::run_task(pending_task* task, context& context) {
+ assert(current_task_ticket_ == 0);
+ const bool finished = (*task)(context);
+ assert(!*task == finished);
+ (void)finished;
+ if (current_task_ticket_ == 0) {
+ return; // task was not suspended, no ticket was produced
+ }
+
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ assert(!guarded_.was_shutdown_);
+ guarded_.scheduler_.finalize_ticket(current_task_ticket_, task);
+ current_task_ticket_ = 0;
+}
+
+suspended_task::ticket single_threaded_executor::dispatcher_impl::duplicate_ticket(
+ suspended_task::ticket ticket) {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ guarded_.scheduler_.duplicate_ticket(ticket);
+ return ticket;
+}
+
+void single_threaded_executor::dispatcher_impl::resolve_ticket(suspended_task::ticket ticket,
+ bool resume_task) {
+ pending_task abandoned_task; // drop outside of the lock
+ bool do_wake = false;
+ {
+ std::lock_guard<std::mutex> lock(guarded_.mutex_);
+ if (resume_task) {
+ guarded_.scheduler_.resume_task_with_ticket(ticket);
+ } else {
+ abandoned_task = guarded_.scheduler_.release_ticket(ticket);
+ }
+ if (guarded_.was_shutdown_) {
+ assert(!guarded_.need_wake_);
+ if (guarded_.scheduler_.has_outstanding_tickets()) {
+ return; // can't shutdown yet
+ }
+ } else if (guarded_.need_wake_ && (guarded_.scheduler_.has_runnable_tasks() ||
+ !guarded_.scheduler_.has_suspended_tasks())) {
+ guarded_.need_wake_ = false;
+ do_wake = true;
+ } else {
+ return; // nothing else to do
+ }
+ }
+
+ // Must do this outside of the lock.
+ if (do_wake) {
+ wake_.notify_one();
+ } else {
+ delete this;
+ }
+}
+
+} // namespace fit
diff --git a/pkg/fit/single_threaded_executor.cpp b/pkg/fit/single_threaded_executor.cpp
deleted file mode 100644
index ba738d0..0000000
--- a/pkg/fit/single_threaded_executor.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Can't compile this for Zircon userspace yet since libstdc++ isn't available.
-#ifndef FIT_NO_STD_FOR_ZIRCON_USERSPACE
-
-#include <condition_variable>
-#include <mutex>
-
-#include <lib/fit/single_threaded_executor.h>
-#include <lib/fit/thread_safety.h>
-
-namespace fit {
-
-// The dispatcher runs tasks and provides the suspended task resolver.
-//
-// The lifetime of this object is somewhat complex since there are pointers
-// to it from multiple sources which are released in different ways.
-//
-// - |single_threaded_executor| holds a pointer in |dispatcher_| which it releases
-// after calling |shutdown()| to inform the dispatcher of its own demise
-// - |suspended_task| holds a pointer to the dispatcher's resolver
-// interface and the number of outstanding pointers corresponds to the
-// number of outstanding suspended task tickets tracked by |scheduler_|.
-//
-// The dispatcher deletes itself once all pointers have been released.
-class single_threaded_executor::dispatcher_impl final
- : public suspended_task::resolver {
-public:
- dispatcher_impl();
-
- void shutdown();
- void schedule_task(pending_task task);
- void run(context_impl& context);
- suspended_task suspend_current_task();
-
- suspended_task::ticket duplicate_ticket(
- suspended_task::ticket ticket) override;
- void resolve_ticket(
- suspended_task::ticket ticket, bool resume_task) override;
-
-private:
- ~dispatcher_impl() override;
-
- void wait_for_runnable_tasks(
- fit::subtle::scheduler::task_queue* out_tasks);
- void run_task(pending_task* task, context& context);
-
- suspended_task::ticket current_task_ticket_ = 0;
- std::condition_variable wake_;
-
- // A bunch of state that is guarded by a mutex.
- struct {
- std::mutex mutex_;
- bool was_shutdown_ FIT_GUARDED(mutex_) = false;
- bool need_wake_ FIT_GUARDED(mutex_) = false;
- fit::subtle::scheduler scheduler_ FIT_GUARDED(mutex_);
- } guarded_;
-};
-
-single_threaded_executor::single_threaded_executor()
- : context_(this), dispatcher_(new dispatcher_impl()) {}
-
-single_threaded_executor::~single_threaded_executor() {
- dispatcher_->shutdown();
-}
-
-void single_threaded_executor::schedule_task(pending_task task) {
- assert(task);
- dispatcher_->schedule_task(std::move(task));
-}
-
-void single_threaded_executor::run() {
- dispatcher_->run(context_);
-}
-
-single_threaded_executor::context_impl::context_impl(single_threaded_executor* executor)
- : executor_(executor) {}
-
-single_threaded_executor::context_impl::~context_impl() = default;
-
-single_threaded_executor* single_threaded_executor::context_impl::executor() const {
- return executor_;
-}
-
-suspended_task single_threaded_executor::context_impl::suspend_task() {
- return executor_->dispatcher_->suspend_current_task();
-}
-
-single_threaded_executor::dispatcher_impl::dispatcher_impl() = default;
-
-single_threaded_executor::dispatcher_impl::~dispatcher_impl() {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- assert(guarded_.was_shutdown_);
- assert(!guarded_.scheduler_.has_runnable_tasks());
- assert(!guarded_.scheduler_.has_suspended_tasks());
- assert(!guarded_.scheduler_.has_outstanding_tickets());
-}
-
-void single_threaded_executor::dispatcher_impl::shutdown() {
- fit::subtle::scheduler::task_queue tasks; // drop outside of the lock
- {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- assert(!guarded_.was_shutdown_);
- guarded_.was_shutdown_ = true;
- guarded_.scheduler_.take_all_tasks(&tasks);
- if (guarded_.scheduler_.has_outstanding_tickets()) {
- return; // can't delete self yet
- }
- }
-
- // Must destroy self outside of the lock.
- delete this;
-}
-
-void single_threaded_executor::dispatcher_impl::schedule_task(pending_task task) {
- {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- assert(!guarded_.was_shutdown_);
- guarded_.scheduler_.schedule_task(std::move(task));
- if (!guarded_.need_wake_) {
- return; // don't need to wake
- }
- guarded_.need_wake_ = false;
- }
-
- // It is more efficient to notify outside the lock.
- wake_.notify_one();
-}
-
-void single_threaded_executor::dispatcher_impl::run(context_impl& context) {
- fit::subtle::scheduler::task_queue tasks;
- for (;;) {
- wait_for_runnable_tasks(&tasks);
- if (tasks.empty()) {
- return; // all done!
- }
-
- do {
- run_task(&tasks.front(), context);
- tasks.pop(); // the task may be destroyed here if it was not suspended
- } while (!tasks.empty());
- }
-}
-
-// Must only be called while |run_task()| is running a task.
-// This happens when the task's continuation calls |context::suspend_task()|
-// upon the context it received as an argument.
-suspended_task single_threaded_executor::dispatcher_impl::suspend_current_task() {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- assert(!guarded_.was_shutdown_);
- if (current_task_ticket_ == 0) {
- current_task_ticket_ = guarded_.scheduler_.obtain_ticket(
- 2 /*initial_refs*/);
- } else {
- guarded_.scheduler_.duplicate_ticket(current_task_ticket_);
- }
- return suspended_task(this, current_task_ticket_);
-}
-
-// Unfortunately std::unique_lock does not support thread-safety annotations
-void single_threaded_executor::dispatcher_impl::wait_for_runnable_tasks(
- fit::subtle::scheduler::task_queue* out_tasks) FIT_NO_THREAD_SAFETY_ANALYSIS {
- std::unique_lock<std::mutex> lock(guarded_.mutex_);
- for (;;) {
- assert(!guarded_.was_shutdown_);
- guarded_.scheduler_.take_runnable_tasks(out_tasks);
- if (!out_tasks->empty()) {
- return; // got some tasks
- }
- if (!guarded_.scheduler_.has_suspended_tasks()) {
- return; // all done!
- }
- guarded_.need_wake_ = true;
- wake_.wait(lock);
- guarded_.need_wake_ = false;
- }
-}
-
-void single_threaded_executor::dispatcher_impl::run_task(pending_task* task,
- context& context) {
- assert(current_task_ticket_ == 0);
- const bool finished = (*task)(context);
- assert(!*task == finished);
- (void)finished;
- if (current_task_ticket_ == 0) {
- return; // task was not suspended, no ticket was produced
- }
-
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- assert(!guarded_.was_shutdown_);
- guarded_.scheduler_.finalize_ticket(current_task_ticket_, task);
- current_task_ticket_ = 0;
-}
-
-suspended_task::ticket single_threaded_executor::dispatcher_impl::duplicate_ticket(
- suspended_task::ticket ticket) {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- guarded_.scheduler_.duplicate_ticket(ticket);
- return ticket;
-}
-
-void single_threaded_executor::dispatcher_impl::resolve_ticket(
- suspended_task::ticket ticket, bool resume_task) {
- pending_task abandoned_task; // drop outside of the lock
- bool do_wake = false;
- {
- std::lock_guard<std::mutex> lock(guarded_.mutex_);
- if (resume_task) {
- guarded_.scheduler_.resume_task_with_ticket(ticket);
- } else {
- abandoned_task = guarded_.scheduler_.release_ticket(ticket);
- }
- if (guarded_.was_shutdown_) {
- assert(!guarded_.need_wake_);
- if (guarded_.scheduler_.has_outstanding_tickets()) {
- return; // can't shutdown yet
- }
- } else if (guarded_.need_wake_ &&
- (guarded_.scheduler_.has_runnable_tasks() ||
- !guarded_.scheduler_.has_suspended_tasks())) {
- guarded_.need_wake_ = false;
- do_wake = true;
- } else {
- return; // nothing else to do
- }
- }
-
- // Must do this outside of the lock.
- if (do_wake) {
- wake_.notify_one();
- } else {
- delete this;
- }
-}
-
-} // namespace fit
-
-#endif // FIT_NO_STD_FOR_ZIRCON_USERSPACE
diff --git a/pkg/images_cpp/images.cc b/pkg/images_cpp/images.cc
deleted file mode 100644
index 17803c6..0000000
--- a/pkg/images_cpp/images.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/images/cpp/images.h"
-
-#include <zircon/assert.h>
-
-namespace images {
-
-// Overall bits per pixel, across all pixel data in the whole image.
-size_t BitsPerPixel(const fuchsia::images::PixelFormat& pixel_format) {
- switch (pixel_format) {
- case fuchsia::images::PixelFormat::BGRA_8:
- return 4u * 8u;
- case fuchsia::images::PixelFormat::YUY2:
- return 2u * 8u;
- case fuchsia::images::PixelFormat::NV12:
- return 12;
- case fuchsia::images::PixelFormat::YV12:
- return 12;
- }
- ZX_PANIC("Unknown Pixel Format: %d", static_cast<int>(pixel_format));
- return 0;
-}
-
-size_t StrideBytesPerWidthPixel(
- const fuchsia::images::PixelFormat& pixel_format) {
- switch (pixel_format) {
- case fuchsia::images::PixelFormat::BGRA_8:
- return 4u;
- case fuchsia::images::PixelFormat::YUY2:
- return 2u;
- case fuchsia::images::PixelFormat::NV12:
- return 1u;
- case fuchsia::images::PixelFormat::YV12:
- return 1u;
- }
- ZX_PANIC("Unknown Pixel Format: %d", static_cast<int>(pixel_format));
- return 0;
-}
-
-size_t MaxSampleAlignment(const fuchsia::images::PixelFormat& pixel_format) {
- switch (pixel_format) {
- case fuchsia::images::PixelFormat::BGRA_8:
- return 4u;
- case fuchsia::images::PixelFormat::YUY2:
- return 2u;
- case fuchsia::images::PixelFormat::NV12:
- // In the sense that line stride "must preserve pixel alignment", which is
- // what MaxSampleAlignment() is used for, NV12 ~~has (very roughly
- // speaking) a pixel alignment of 2, ~~because the width of the Y plane in
- // this implementation must be even, and ~because the interleaved UV data
- // after the planar Y data is 2 bytes per sample, so we may as well
- // require UV samples to remain aligned UV line to UV line.
- return 2u;
- case fuchsia::images::PixelFormat::YV12:
- // In the sense that line stride "must preserve pixel alignment", which is
- // what MaxSampleAlignment() is used for, YV12 ~~has (very roughly
- // speaking) a pixel alignment of 2, ~~because the width of the Y plane in
- // this implementation must be even.
- return 2u;
- }
- ZX_PANIC("Unknown Pixel Format: %d", static_cast<int>(pixel_format));
- return 0;
-}
-
-size_t ImageSize(const fuchsia::images::ImageInfo& image_info) {
- ZX_DEBUG_ASSERT(image_info.tiling == fuchsia::images::Tiling::LINEAR);
- switch (image_info.pixel_format) {
- case fuchsia::images::PixelFormat::BGRA_8:
- case fuchsia::images::PixelFormat::YUY2:
- return image_info.height * image_info.stride;
- case fuchsia::images::PixelFormat::NV12:
- return image_info.height * image_info.stride * 3 / 2;
- case fuchsia::images::PixelFormat::YV12:
- return image_info.height * image_info.stride * 3 / 2;
- }
- ZX_PANIC("Unknown Pixel Format: %d",
- static_cast<int>(image_info.pixel_format));
- return 0;
-}
-
-} // namespace images
diff --git a/pkg/images_cpp/include/lib/images/cpp/images.h b/pkg/images_cpp/include/lib/images/cpp/images.h
deleted file mode 100644
index 48d75e6..0000000
--- a/pkg/images_cpp/include/lib/images/cpp/images.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_IMAGES_CPP_IMAGES_H_
-#define LIB_IMAGES_CPP_IMAGES_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-
-#include <stdint.h>
-
-namespace images {
-
-// Returns the number of bits per pixel for the given format. This is the bits
-// per pixel in the overall image across all bytes that contain pixel data. For
-// example, NV12 is 12 bits per pixel.
-size_t BitsPerPixel(const fuchsia::images::PixelFormat& pixel_format);
-
-// This is the number of stride bytes per pixel of width. For formats such as
-// NV12 that separate Y and UV data, this is the number of stride bytes of the Y
-// plane. NV12 has the same stride for the UV data. formats with a different
-// stride for UV data vs Y data are not handled yet.
-size_t StrideBytesPerWidthPixel(
- const fuchsia::images::PixelFormat& pixel_format);
-
-// Returns the pixel alignment for the given format.
-//
-// This is technically something closer to "max sample alignment" for the given
-// format. For example, NV12 returns 2 here because its UV interleaved data has
-// 2 bytes per sample, despite its Y plane having 1 byte per sample.
-//
-// The stride is required to be divisible by this alignment.
-size_t MaxSampleAlignment(const fuchsia::images::PixelFormat& pixel_format);
-
-// This would be height * stride, if it weren't for formats like NV12, where it
-// isn't. The output is bytes.
-size_t ImageSize(const fuchsia::images::ImageInfo& image_info);
-
-} // namespace images
-
-#endif // LIB_IMAGES_CPP_IMAGES_H_
diff --git a/pkg/images_cpp/meta.json b/pkg/images_cpp/meta.json
deleted file mode 100644
index 61fdef4..0000000
--- a/pkg/images_cpp/meta.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "deps": [],
- "fidl_deps": [
- "fuchsia.images"
- ],
- "headers": [
- "pkg/images_cpp/include/lib/images/cpp/images.h"
- ],
- "include_dir": "pkg/images_cpp/include",
- "name": "images_cpp",
- "root": "pkg/images_cpp",
- "sources": [
- "pkg/images_cpp/images.cc"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/memfs/include/lib/memfs/memfs.h b/pkg/memfs/include/lib/memfs/memfs.h
deleted file mode 100644
index 7f49a96..0000000
--- a/pkg/memfs/include/lib/memfs/memfs.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_MEMFS_INCLUDE_LIB_MEMFS_MEMFS_H_
-#define LIB_MEMFS_INCLUDE_LIB_MEMFS_MEMFS_H_
-
-#include <lib/async/dispatcher.h>
-#include <lib/sync/completion.h>
-#include <zircon/compiler.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS
-
-typedef struct memfs_filesystem memfs_filesystem_t;
-
-// Given an async dispatcher, create an in-memory filesystem.
-//
-// Returns the MemFS filesystem object in |out_fs|. This object
-// must be freed by memfs_free_filesystem.
-//
-// Returns a handle to the root directory in |out_root|.
-__EXPORT zx_status_t memfs_create_filesystem(async_dispatcher_t* dispatcher,
- memfs_filesystem_t** out_fs,
- zx_handle_t* out_root);
-
-// Same as memfs_create_filesystem, but with an extra |max_num_pages| option.
-//
-// Specify the maximum number of pages available to the fs via |max_num_pages|.
-// This puts a bound on memory consumption.
-__EXPORT zx_status_t memfs_create_filesystem_with_page_limit(async_dispatcher_t* dispatcher,
- size_t max_num_pages,
- memfs_filesystem_t** out_fs,
- zx_handle_t* out_root);
-
-// Frees a MemFS filesystem, unmounting any sub-filesystems that
-// may exist.
-//
-// Requires that the async handler dispatcher provided to
-// |memfs_create_filesystem| still be running.
-//
-// Signals the optional argument |unmounted| when memfs has torn down.
-__EXPORT void memfs_free_filesystem(memfs_filesystem_t* fs, sync_completion_t* unmounted);
-
-// Creates an in-memory filesystem and installs it into the local namespace at
-// the given path.
-//
-// Operations on the filesystem are serviced by the given async dispatcher.
-//
-// Returns |ZX_ERR_ALREADY_EXISTS| if |path| already exists in the namespace for
-// this process.
-__EXPORT zx_status_t memfs_install_at(async_dispatcher_t* dispatcher, const char* path);
-
-// Same as memfs_install_at, but with an extra |max_num_pages| option.
-//
-// Specify the maximum number of pages available to the fs via |max_num_pages|.
-// This puts a bound on memory consumption.
-__EXPORT zx_status_t memfs_install_at_with_page_limit(async_dispatcher_t* dispatcher,
- size_t max_num_pages,
- const char* path);
-
-__END_CDECLS
-
-#endif // LIB_MEMFS_INCLUDE_LIB_MEMFS_MEMFS_H_
diff --git a/pkg/memfs/meta.json b/pkg/memfs/meta.json
deleted file mode 100644
index 1492c3e..0000000
--- a/pkg/memfs/meta.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/bf/c0f8386f84cd2c91ccae603bc6910bdbaf7f29.debug",
- "dist": "arch/arm64/dist/libmemfs.so",
- "link": "arch/arm64/lib/libmemfs.so"
- },
- "x64": {
- "debug": ".build-id/7b/1c4f16beffe8102284ef4860a2a92696ed5045.debug",
- "dist": "arch/x64/dist/libmemfs.so",
- "link": "arch/x64/lib/libmemfs.so"
- }
- },
- "deps": [
- "fdio",
- "trace-engine"
- ],
- "format": "shared",
- "headers": [
- "pkg/memfs/include/lib/memfs/memfs.h"
- ],
- "include_dir": "pkg/memfs/include",
- "name": "memfs",
- "root": "pkg/memfs",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/scenic_cpp/commands.cc b/pkg/scenic_cpp/commands.cc
deleted file mode 100644
index 4991905..0000000
--- a/pkg/scenic_cpp/commands.cc
+++ /dev/null
@@ -1,1300 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/ui/scenic/cpp/commands.h"
-
-#include <array>
-
-#include <zircon/assert.h>
-
-namespace scenic {
-
-fuchsia::ui::scenic::Command NewCommand(fuchsia::ui::gfx::Command command) {
- fuchsia::ui::scenic::Command scenic_command;
- scenic_command.set_gfx(std::move(command));
- return scenic_command;
-}
-
-fuchsia::ui::scenic::Command NewCommand(fuchsia::ui::input::Command command) {
- fuchsia::ui::scenic::Command scenic_command;
- scenic_command.set_input(std::move(command));
- return scenic_command;
-}
-
-// Helper function for all resource creation functions.
-fuchsia::ui::gfx::Command NewCreateResourceCmd(
- uint32_t id, fuchsia::ui::gfx::ResourceArgs resource) {
- fuchsia::ui::gfx::CreateResourceCmd create_resource;
- create_resource.id = id;
- create_resource.resource = std::move(resource);
-
- fuchsia::ui::gfx::Command command;
- command.set_create_resource(std::move(create_resource));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewCreateMemoryCmd(
- uint32_t id, zx::vmo vmo, uint64_t allocation_size,
- fuchsia::images::MemoryType memory_type) {
- fuchsia::ui::gfx::MemoryArgs memory;
- memory.vmo = std::move(vmo);
- memory.allocation_size = allocation_size;
- memory.memory_type = memory_type;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_memory(std::move(memory));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateImageCmd(uint32_t id, uint32_t memory_id,
- uint32_t memory_offset,
- fuchsia::images::ImageInfo info) {
- fuchsia::ui::gfx::ImageArgs image;
- image.memory_id = memory_id;
- image.memory_offset = memory_offset;
- image.info = std::move(info);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_image(std::move(image));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateImagePipeCmd(
- uint32_t id, ::fidl::InterfaceRequest<fuchsia::images::ImagePipe> request) {
- fuchsia::ui::gfx::ImagePipeArgs image_pipe;
- image_pipe.image_pipe_request = std::move(request);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_image_pipe(std::move(image_pipe));
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateImageCmd(
- uint32_t id, uint32_t memory_id, uint32_t memory_offset,
- fuchsia::images::PixelFormat format,
- fuchsia::images::ColorSpace color_space, fuchsia::images::Tiling tiling,
- uint32_t width, uint32_t height, uint32_t stride) {
- fuchsia::images::ImageInfo info;
- info.pixel_format = format;
- info.color_space = color_space;
- info.tiling = tiling;
- info.width = width;
- info.height = height;
- info.stride = stride;
- return NewCreateImageCmd(id, memory_id, memory_offset, std::move(info));
-}
-
-fuchsia::ui::gfx::Command NewCreateBufferCmd(uint32_t id, uint32_t memory_id,
- uint32_t memory_offset,
- uint32_t num_bytes) {
- fuchsia::ui::gfx::BufferArgs buffer;
- buffer.memory_id = memory_id;
- buffer.memory_offset = memory_offset;
- buffer.num_bytes = num_bytes;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_buffer(std::move(buffer));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateCompositorCmd(uint32_t id) {
- fuchsia::ui::gfx::CompositorArgs compositor;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_compositor(std::move(compositor));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateDisplayCompositorCmd(uint32_t id) {
- fuchsia::ui::gfx::DisplayCompositorArgs display_compositor;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_display_compositor(std::move(display_compositor));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateLayerStackCmd(uint32_t id) {
- fuchsia::ui::gfx::LayerStackArgs layer_stack;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_layer_stack(std::move(layer_stack));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateLayerCmd(uint32_t id) {
- fuchsia::ui::gfx::LayerArgs layer;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_layer(std::move(layer));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateSceneCmd(uint32_t id) {
- fuchsia::ui::gfx::SceneArgs scene;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_scene(std::move(scene));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateCameraCmd(uint32_t id, uint32_t scene_id) {
- fuchsia::ui::gfx::CameraArgs camera;
- camera.scene_id = scene_id;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_camera(std::move(camera));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateStereoCameraCmd(uint32_t id,
- uint32_t scene_id) {
- fuchsia::ui::gfx::StereoCameraArgs stereo_camera;
- stereo_camera.scene_id = scene_id;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_stereo_camera(std::move(stereo_camera));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateRendererCmd(uint32_t id) {
- fuchsia::ui::gfx::RendererArgs renderer;
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_renderer(std::move(renderer));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateAmbientLightCmd(uint32_t id) {
- fuchsia::ui::gfx::AmbientLightArgs ambient_light;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_ambient_light(std::move(ambient_light));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateDirectionalLightCmd(uint32_t id) {
- fuchsia::ui::gfx::DirectionalLightArgs directional_light;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_directional_light(std::move(directional_light));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateCircleCmd(uint32_t id, float radius) {
- fuchsia::ui::gfx::Value radius_value;
- radius_value.set_vector1(radius);
-
- fuchsia::ui::gfx::CircleArgs circle;
- circle.radius = std::move(radius_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_circle(std::move(circle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateRectangleCmd(uint32_t id, float width,
- float height) {
- fuchsia::ui::gfx::Value width_value;
- width_value.set_vector1(width);
-
- fuchsia::ui::gfx::Value height_value;
- height_value.set_vector1(height);
-
- fuchsia::ui::gfx::RectangleArgs rectangle;
- rectangle.width = std::move(width_value);
- rectangle.height = std::move(height_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_rectangle(std::move(rectangle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateRoundedRectangleCmd(
- uint32_t id, float width, float height, float top_left_radius,
- float top_right_radius, float bottom_right_radius,
- float bottom_left_radius) {
- fuchsia::ui::gfx::Value width_value;
- width_value.set_vector1(width);
-
- fuchsia::ui::gfx::Value height_value;
- height_value.set_vector1(height);
-
- fuchsia::ui::gfx::Value top_left_radius_value;
- top_left_radius_value.set_vector1(top_left_radius);
-
- fuchsia::ui::gfx::Value top_right_radius_value;
- top_right_radius_value.set_vector1(top_right_radius);
-
- fuchsia::ui::gfx::Value bottom_right_radius_value;
- bottom_right_radius_value.set_vector1(bottom_right_radius);
-
- fuchsia::ui::gfx::Value bottom_left_radius_value;
- bottom_left_radius_value.set_vector1(bottom_left_radius);
-
- fuchsia::ui::gfx::RoundedRectangleArgs rectangle;
- rectangle.width = std::move(width_value);
- rectangle.height = std::move(height_value);
- rectangle.top_left_radius = std::move(top_left_radius_value);
- rectangle.top_right_radius = std::move(top_right_radius_value);
- rectangle.bottom_right_radius = std::move(bottom_right_radius_value);
- rectangle.bottom_left_radius = std::move(bottom_left_radius_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_rounded_rectangle(std::move(rectangle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateVarCircleCmd(uint32_t id,
- uint32_t radius_var_id,
- uint32_t height_var_id) {
- fuchsia::ui::gfx::Value radius_value;
- radius_value.set_variable_id(radius_var_id);
-
- fuchsia::ui::gfx::CircleArgs circle;
- circle.radius = std::move(radius_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_circle(std::move(circle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateVarRectangleCmd(uint32_t id,
- uint32_t width_var_id,
- uint32_t height_var_id) {
- fuchsia::ui::gfx::Value width_value;
- width_value.set_variable_id(width_var_id);
-
- fuchsia::ui::gfx::Value height_value;
- height_value.set_variable_id(height_var_id);
-
- fuchsia::ui::gfx::RectangleArgs rectangle;
- rectangle.width = std::move(width_value);
- rectangle.height = std::move(height_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_rectangle(std::move(rectangle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateVarRoundedRectangleCmd(
- uint32_t id, uint32_t width_var_id, uint32_t height_var_id,
- uint32_t top_left_radius_var_id, uint32_t top_right_radius_var_id,
- uint32_t bottom_left_radius_var_id, uint32_t bottom_right_radius_var_id) {
- fuchsia::ui::gfx::Value width_value;
- width_value.set_variable_id(width_var_id);
-
- fuchsia::ui::gfx::Value height_value;
- height_value.set_variable_id(height_var_id);
-
- fuchsia::ui::gfx::Value top_left_radius_value;
- top_left_radius_value.set_variable_id(top_left_radius_var_id);
-
- fuchsia::ui::gfx::Value top_right_radius_value;
- top_right_radius_value.set_variable_id(top_right_radius_var_id);
-
- fuchsia::ui::gfx::Value bottom_left_radius_value;
- bottom_left_radius_value.set_variable_id(bottom_left_radius_var_id);
-
- fuchsia::ui::gfx::Value bottom_right_radius_value;
- bottom_right_radius_value.set_variable_id(bottom_right_radius_var_id);
-
- fuchsia::ui::gfx::RoundedRectangleArgs rectangle;
- rectangle.width = std::move(width_value);
- rectangle.height = std::move(height_value);
- rectangle.top_left_radius = std::move(top_left_radius_value);
- rectangle.top_right_radius = std::move(top_right_radius_value);
- rectangle.bottom_left_radius = std::move(bottom_left_radius_value);
- rectangle.bottom_right_radius = std::move(bottom_right_radius_value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_rounded_rectangle(std::move(rectangle));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateMeshCmd(uint32_t id) {
- fuchsia::ui::gfx::MeshArgs mesh;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_mesh(std::move(mesh));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateMaterialCmd(uint32_t id) {
- fuchsia::ui::gfx::MaterialArgs material;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_material(std::move(material));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateClipNodeCmd(uint32_t id) {
- fuchsia::ui::gfx::ClipNodeArgs node;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_clip_node(std::move(node));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateEntityNodeCmd(uint32_t id) {
- fuchsia::ui::gfx::EntityNodeArgs node;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_entity_node(std::move(node));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateOpacityNodeCmd(uint32_t id) {
- fuchsia::ui::gfx::OpacityNodeArgs node;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_opacity_node(std::move(node));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateShapeNodeCmd(uint32_t id) {
- fuchsia::ui::gfx::ShapeNodeArgs node;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_shape_node(std::move(node));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateViewCmd(uint32_t id, zx::eventpair token,
- const std::string& debug_name) {
- ZX_DEBUG_ASSERT(token);
- fuchsia::ui::gfx::ViewArgs view;
- view.token = std::move(token);
- view.debug_name = debug_name;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_view(std::move(view));
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateViewHolderCmd(
- uint32_t id, zx::eventpair token, const std::string& debug_name) {
- ZX_DEBUG_ASSERT(token);
- fuchsia::ui::gfx::ViewHolderArgs view_holder;
- view_holder.token = std::move(token);
- view_holder.debug_name = debug_name;
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_view_holder(std::move(view_holder));
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewCreateVariableCmd(uint32_t id,
- fuchsia::ui::gfx::Value value) {
- fuchsia::ui::gfx::VariableArgs variable;
- switch (value.Which()) {
- case ::fuchsia::ui::gfx::Value::Tag::kVector1:
- variable.type = fuchsia::ui::gfx::ValueType::kVector1;
- break;
- case ::fuchsia::ui::gfx::Value::Tag::kVector2:
- variable.type = fuchsia::ui::gfx::ValueType::kVector2;
- break;
- case ::fuchsia::ui::gfx::Value::Tag::kVector3:
- variable.type = fuchsia::ui::gfx::ValueType::kVector3;
- break;
- case ::fuchsia::ui::gfx::Value::Tag::kVector4:
- variable.type = fuchsia::ui::gfx::ValueType::kVector4;
- break;
- case fuchsia::ui::gfx::Value::Tag::kMatrix4x4:
- variable.type = fuchsia::ui::gfx::ValueType::kMatrix4;
- break;
- case fuchsia::ui::gfx::Value::Tag::kColorRgba:
- variable.type = fuchsia::ui::gfx::ValueType::kColorRgba;
- break;
- case fuchsia::ui::gfx::Value::Tag::kColorRgb:
- variable.type = fuchsia::ui::gfx::ValueType::kColorRgb;
- break;
- case fuchsia::ui::gfx::Value::Tag::kDegrees:
- variable.type = fuchsia::ui::gfx::ValueType::kVector1;
- break;
- case fuchsia::ui::gfx::Value::Tag::kTransform:
- variable.type = fuchsia::ui::gfx::ValueType::kFactoredTransform;
- break;
- case fuchsia::ui::gfx::Value::Tag::kQuaternion:
- variable.type = fuchsia::ui::gfx::ValueType::kQuaternion;
- break;
- case fuchsia::ui::gfx::Value::Tag::kVariableId:
- // A variable's initial value cannot be another variable.
- return fuchsia::ui::gfx::Command();
- case fuchsia::ui::gfx::Value::Tag::Invalid:
- return fuchsia::ui::gfx::Command();
- }
- variable.initial_value = std::move(value);
-
- fuchsia::ui::gfx::ResourceArgs resource;
- resource.set_variable(std::move(variable));
-
- return NewCreateResourceCmd(id, std::move(resource));
-}
-
-fuchsia::ui::gfx::Command NewReleaseResourceCmd(uint32_t id) {
- fuchsia::ui::gfx::ReleaseResourceCmd release_resource;
- release_resource.id = id;
-
- fuchsia::ui::gfx::Command command;
- command.set_release_resource(std::move(release_resource));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewExportResourceCmd(uint32_t resource_id,
- zx::eventpair export_token) {
- ZX_DEBUG_ASSERT(export_token);
-
- fuchsia::ui::gfx::ExportResourceCmd export_resource;
- export_resource.id = resource_id;
- export_resource.token = std::move(export_token);
-
- fuchsia::ui::gfx::Command command;
- command.set_export_resource(std::move(export_resource));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewImportResourceCmd(
- uint32_t resource_id, fuchsia::ui::gfx::ImportSpec spec,
- zx::eventpair import_token) {
- ZX_DEBUG_ASSERT(import_token);
-
- fuchsia::ui::gfx::ImportResourceCmd import_resource;
- import_resource.id = resource_id;
- import_resource.token = std::move(import_token);
- import_resource.spec = spec;
-
- fuchsia::ui::gfx::Command command;
- command.set_import_resource(std::move(import_resource));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewExportResourceCmdAsRequest(
- uint32_t resource_id, zx::eventpair* out_import_token) {
- ZX_DEBUG_ASSERT(out_import_token);
- ZX_DEBUG_ASSERT(!*out_import_token);
-
- zx::eventpair export_token;
- zx_status_t status =
- zx::eventpair::create(0u, &export_token, out_import_token);
- ZX_DEBUG_ASSERT_MSG(status == ZX_OK, "event pair create failed: status=%d",
- status);
- return NewExportResourceCmd(resource_id, std::move(export_token));
-}
-
-fuchsia::ui::gfx::Command NewImportResourceCmdAsRequest(
- uint32_t resource_id, fuchsia::ui::gfx::ImportSpec import_spec,
- zx::eventpair* out_export_token) {
- ZX_DEBUG_ASSERT(out_export_token);
- ZX_DEBUG_ASSERT(!*out_export_token);
-
- zx::eventpair import_token;
- zx_status_t status =
- zx::eventpair::create(0u, &import_token, out_export_token);
- ZX_DEBUG_ASSERT_MSG(status == ZX_OK, "event pair create failed: status=%d",
- status);
- return NewImportResourceCmd(resource_id, import_spec,
- std::move(import_token));
-}
-
-fuchsia::ui::gfx::Command NewSetViewPropertiesCmd(
- uint32_t view_holder_id, const float bounding_box_min[3],
- const float bounding_box_max[3], const float inset_from_min[3],
- const float inset_from_max[3]) {
- fuchsia::ui::gfx::SetViewPropertiesCmd set_view_properties;
- set_view_properties.view_holder_id = view_holder_id;
- auto& props = set_view_properties.properties;
- props.bounding_box.min = NewVector3(bounding_box_min);
- props.bounding_box.max = NewVector3(bounding_box_max);
- props.inset_from_min = NewVector3(inset_from_min);
- props.inset_from_max = NewVector3(inset_from_max);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_view_properties(std::move(set_view_properties));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetViewPropertiesCmd(
- uint32_t view_holder_id, const fuchsia::ui::gfx::ViewProperties& props) {
- fuchsia::ui::gfx::SetViewPropertiesCmd set_view_properties;
- set_view_properties.view_holder_id = view_holder_id;
- set_view_properties.properties = props;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_view_properties(std::move(set_view_properties));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewAddChildCmd(uint32_t node_id, uint32_t child_id) {
- fuchsia::ui::gfx::AddChildCmd add_child;
- add_child.node_id = node_id;
- add_child.child_id = child_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_add_child(std::move(add_child));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewAddPartCmd(uint32_t node_id, uint32_t part_id) {
- fuchsia::ui::gfx::AddPartCmd add_part;
- add_part.node_id = node_id;
- add_part.part_id = part_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_add_part(std::move(add_part));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewDetachCmd(uint32_t id) {
- fuchsia::ui::gfx::DetachCmd detach;
- detach.id = id;
-
- fuchsia::ui::gfx::Command command;
- command.set_detach(std::move(detach));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewDetachChildrenCmd(uint32_t node_id) {
- fuchsia::ui::gfx::DetachChildrenCmd detach_children;
- detach_children.node_id = node_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_detach_children(std::move(detach_children));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetTranslationCmd(uint32_t node_id,
- const float translation[3]) {
- fuchsia::ui::gfx::SetTranslationCmd set_translation;
- set_translation.id = node_id;
- set_translation.value = NewVector3Value(translation);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_translation(std::move(set_translation));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetTranslationCmd(uint32_t node_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetTranslationCmd set_translation;
- set_translation.id = node_id;
- set_translation.value = NewVector3Value(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_translation(std::move(set_translation));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetScaleCmd(uint32_t node_id,
- const float scale[3]) {
- fuchsia::ui::gfx::SetScaleCmd set_scale;
- set_scale.id = node_id;
- set_scale.value = NewVector3Value(scale);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_scale(std::move(set_scale));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetScaleCmd(uint32_t node_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetScaleCmd set_scale;
- set_scale.id = node_id;
- set_scale.value = NewVector3Value(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_scale(std::move(set_scale));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetRotationCmd(uint32_t node_id,
- const float quaternion[4]) {
- fuchsia::ui::gfx::SetRotationCmd set_rotation;
- set_rotation.id = node_id;
- set_rotation.value = NewQuaternionValue(quaternion);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_rotation(std::move(set_rotation));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetRotationCmd(uint32_t node_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetRotationCmd set_rotation;
- set_rotation.id = node_id;
- set_rotation.value = NewQuaternionValue(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_rotation(std::move(set_rotation));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetAnchorCmd(uint32_t node_id,
- const float anchor[3]) {
- fuchsia::ui::gfx::SetAnchorCmd set_anchor;
- set_anchor.id = node_id;
- set_anchor.value = NewVector3Value(anchor);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_anchor(std::move(set_anchor));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetAnchorCmd(uint32_t node_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetAnchorCmd set_anchor;
- set_anchor.id = node_id;
- set_anchor.value = NewVector3Value(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_anchor(std::move(set_anchor));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetOpacityCmd(uint32_t node_id, float opacity) {
- fuchsia::ui::gfx::SetOpacityCmd set_opacity;
- set_opacity.node_id = node_id;
- set_opacity.opacity = opacity;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_opacity(std::move(set_opacity));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSendSizeChangeHintCmdHACK(
- uint32_t node_id, float width_change_factor, float height_change_factor) {
- fuchsia::ui::gfx::SendSizeChangeHintCmdHACK send_size_change_hint;
- send_size_change_hint.node_id = node_id;
- send_size_change_hint.width_change_factor = width_change_factor;
- send_size_change_hint.height_change_factor = height_change_factor;
-
- fuchsia::ui::gfx::Command command;
- command.set_send_size_change_hint_hack(std::move(send_size_change_hint));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetShapeCmd(uint32_t node_id, uint32_t shape_id) {
- fuchsia::ui::gfx::SetShapeCmd set_shape;
- set_shape.node_id = node_id;
- set_shape.shape_id = shape_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_shape(std::move(set_shape));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetMaterialCmd(uint32_t node_id,
- uint32_t material_id) {
- fuchsia::ui::gfx::SetMaterialCmd set_material;
- set_material.node_id = node_id;
- set_material.material_id = material_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_material(std::move(set_material));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetClipCmd(uint32_t node_id, uint32_t clip_id,
- bool clip_to_self) {
- fuchsia::ui::gfx::SetClipCmd set_clip;
- set_clip.node_id = node_id;
- set_clip.clip_id = clip_id;
- set_clip.clip_to_self = clip_to_self;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_clip(std::move(set_clip));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetTagCmd(uint32_t node_id, uint32_t tag_value) {
- fuchsia::ui::gfx::SetTagCmd set_tag;
- set_tag.node_id = node_id;
- set_tag.tag_value = tag_value;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_tag(std::move(set_tag));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewTakeSnapshotCmdHACK(
- uint32_t node_id, fuchsia::ui::gfx::SnapshotCallbackHACKPtr callback) {
- fuchsia::ui::gfx::TakeSnapshotCmdHACK snapshot_cmd;
- snapshot_cmd.node_id = node_id;
- snapshot_cmd.callback = std::move(callback);
-
- fuchsia::ui::gfx::Command command;
- command.set_take_snapshot_cmd(std::move(snapshot_cmd));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetHitTestBehaviorCmd(
- uint32_t node_id, fuchsia::ui::gfx::HitTestBehavior hit_test_behavior) {
- fuchsia::ui::gfx::SetHitTestBehaviorCmd set_hit_test_behavior;
- set_hit_test_behavior.node_id = node_id;
- set_hit_test_behavior.hit_test_behavior = hit_test_behavior;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_hit_test_behavior(std::move(set_hit_test_behavior));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetCameraCmd(uint32_t renderer_id,
- uint32_t camera_id) {
- fuchsia::ui::gfx::SetCameraCmd set_camera;
- set_camera.renderer_id = renderer_id;
- set_camera.camera_id = camera_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_camera(std::move(set_camera));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetTextureCmd(uint32_t material_id,
- uint32_t texture_id) {
- fuchsia::ui::gfx::SetTextureCmd set_texture;
- set_texture.material_id = material_id;
- set_texture.texture_id = texture_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_texture(std::move(set_texture));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetColorCmd(uint32_t material_id, uint8_t red,
- uint8_t green, uint8_t blue,
- uint8_t alpha) {
- fuchsia::ui::gfx::ColorRgbaValue color;
- color.value.red = red;
- color.value.green = green;
- color.value.blue = blue;
- color.value.alpha = alpha;
- color.variable_id = 0;
- fuchsia::ui::gfx::SetColorCmd set_color;
- set_color.material_id = material_id;
- set_color.color = std::move(color);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_color(std::move(set_color));
-
- return command;
-}
-
-fuchsia::ui::gfx::MeshVertexFormat NewMeshVertexFormat(
- fuchsia::ui::gfx::ValueType position_type,
- fuchsia::ui::gfx::ValueType normal_type,
- fuchsia::ui::gfx::ValueType tex_coord_type) {
- fuchsia::ui::gfx::MeshVertexFormat vertex_format;
- vertex_format.position_type = position_type;
- vertex_format.normal_type = normal_type;
- vertex_format.tex_coord_type = tex_coord_type;
- return vertex_format;
-}
-
-fuchsia::ui::gfx::Command NewBindMeshBuffersCmd(
- uint32_t mesh_id, uint32_t index_buffer_id,
- fuchsia::ui::gfx::MeshIndexFormat index_format, uint64_t index_offset,
- uint32_t index_count, uint32_t vertex_buffer_id,
- fuchsia::ui::gfx::MeshVertexFormat vertex_format, uint64_t vertex_offset,
- uint32_t vertex_count, const float bounding_box_min[3],
- const float bounding_box_max[3]) {
- fuchsia::ui::gfx::BindMeshBuffersCmd bind_mesh_buffers;
- bind_mesh_buffers.mesh_id = mesh_id;
- bind_mesh_buffers.index_buffer_id = index_buffer_id;
- bind_mesh_buffers.index_format = index_format;
- bind_mesh_buffers.index_offset = index_offset;
- bind_mesh_buffers.index_count = index_count;
- bind_mesh_buffers.vertex_buffer_id = vertex_buffer_id;
- bind_mesh_buffers.vertex_format = std::move(vertex_format);
- bind_mesh_buffers.vertex_offset = vertex_offset;
- bind_mesh_buffers.vertex_count = vertex_count;
- auto& bbox = bind_mesh_buffers.bounding_box;
- bbox.min.x = bounding_box_min[0];
- bbox.min.y = bounding_box_min[1];
- bbox.min.z = bounding_box_min[2];
- bbox.max.x = bounding_box_max[0];
- bbox.max.y = bounding_box_max[1];
- bbox.max.z = bounding_box_max[2];
-
- fuchsia::ui::gfx::Command command;
- command.set_bind_mesh_buffers(std::move(bind_mesh_buffers));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewAddLayerCmd(uint32_t layer_stack_id,
- uint32_t layer_id) {
- fuchsia::ui::gfx::AddLayerCmd add_layer;
- add_layer.layer_stack_id = layer_stack_id;
- add_layer.layer_id = layer_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_add_layer(std::move(add_layer));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewRemoveLayerCmd(uint32_t layer_stack_id,
- uint32_t layer_id) {
- fuchsia::ui::gfx::RemoveLayerCmd remove_layer;
- remove_layer.layer_stack_id = layer_stack_id;
- remove_layer.layer_id = layer_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_remove_layer(std::move(remove_layer));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewRemoveAllLayersCmd(uint32_t layer_stack_id) {
- fuchsia::ui::gfx::RemoveAllLayersCmd remove_all_layers;
- remove_all_layers.layer_stack_id = layer_stack_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_remove_all_layers(std::move(remove_all_layers));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLayerStackCmd(uint32_t compositor_id,
- uint32_t layer_stack_id) {
- fuchsia::ui::gfx::SetLayerStackCmd set_layer_stack;
- set_layer_stack.compositor_id = compositor_id;
- set_layer_stack.layer_stack_id = layer_stack_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_layer_stack(std::move(set_layer_stack));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetRendererCmd(uint32_t layer_id,
- uint32_t renderer_id) {
- fuchsia::ui::gfx::SetRendererCmd set_renderer;
- set_renderer.layer_id = layer_id;
- set_renderer.renderer_id = renderer_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_renderer(std::move(set_renderer));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetRendererParamCmd(
- uint32_t renderer_id, fuchsia::ui::gfx::RendererParam param) {
- fuchsia::ui::gfx::SetRendererParamCmd param_command;
- param_command.renderer_id = renderer_id;
- param_command.param = std::move(param);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_renderer_param(std::move(param_command));
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetSizeCmd(uint32_t node_id, const float size[2]) {
- fuchsia::ui::gfx::SetSizeCmd set_size;
- set_size.id = node_id;
- auto& value = set_size.value.value;
- value.x = size[0];
- value.y = size[1];
- set_size.value.variable_id = 0;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_size(std::move(set_size));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetCameraTransformCmd(uint32_t camera_id,
- const float eye_position[3],
- const float eye_look_at[3],
- const float eye_up[3]) {
- fuchsia::ui::gfx::SetCameraTransformCmd set_command;
- set_command.camera_id = camera_id;
- set_command.eye_position = NewVector3Value(eye_position);
- set_command.eye_look_at = NewVector3Value(eye_look_at);
- set_command.eye_up = NewVector3Value(eye_up);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_camera_transform(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetCameraProjectionCmd(uint32_t camera_id,
- const float fovy) {
- fuchsia::ui::gfx::SetCameraProjectionCmd set_command;
- set_command.camera_id = camera_id;
- set_command.fovy = NewFloatValue(fovy);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_camera_projection(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetStereoCameraProjectionCmd(
- uint32_t camera_id, const float left_projection[16],
- const float right_projection[16]) {
- fuchsia::ui::gfx::SetStereoCameraProjectionCmd set_command;
- set_command.camera_id = camera_id;
- set_command.left_projection = NewMatrix4Value(left_projection);
- set_command.right_projection = NewMatrix4Value(right_projection);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_stereo_camera_projection(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetCameraPoseBufferCmd(uint32_t camera_id,
- uint32_t buffer_id,
- uint32_t num_entries,
- int64_t base_time,
- uint64_t time_interval) {
- fuchsia::ui::gfx::SetCameraPoseBufferCmd set_command;
- set_command.camera_id = camera_id;
- set_command.buffer_id = buffer_id;
- set_command.num_entries = num_entries;
- set_command.base_time = base_time;
- set_command.time_interval = time_interval;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_camera_pose_buffer(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLightColorCmd(uint32_t light_id,
- const float rgb[3]) {
- fuchsia::ui::gfx::SetLightColorCmd set_command;
- set_command.light_id = light_id;
- set_command.color = NewColorRgbValue(rgb[0], rgb[1], rgb[2]);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_light_color(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLightColorCmd(uint32_t light_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetLightColorCmd set_command;
- set_command.light_id = light_id;
- set_command.color = NewColorRgbValue(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_light_color(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLightDirectionCmd(uint32_t light_id,
- const float dir[3]) {
- fuchsia::ui::gfx::SetLightDirectionCmd set_command;
- set_command.light_id = light_id;
- set_command.direction = NewVector3Value(dir);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_light_direction(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLightDirectionCmd(uint32_t light_id,
- uint32_t variable_id) {
- fuchsia::ui::gfx::SetLightDirectionCmd set_command;
- set_command.light_id = light_id;
- set_command.direction = NewVector3Value(variable_id);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_light_direction(std::move(set_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewAddLightCmd(uint32_t scene_id, uint32_t light_id) {
- fuchsia::ui::gfx::AddLightCmd add_light_command;
- add_light_command.scene_id = scene_id;
- add_light_command.light_id = light_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_add_light(std::move(add_light_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewDetachLightCmd(uint32_t light_id) {
- fuchsia::ui::gfx::DetachLightCmd detach_light_command;
- detach_light_command.light_id = light_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_detach_light(std::move(detach_light_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewDetachLightsCmd(uint32_t scene_id) {
- fuchsia::ui::gfx::DetachLightsCmd detach_lights_command;
- detach_lights_command.scene_id = scene_id;
-
- fuchsia::ui::gfx::Command command;
- command.set_detach_lights(std::move(detach_lights_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetEventMaskCmd(uint32_t resource_id,
- uint32_t event_mask) {
- fuchsia::ui::gfx::SetEventMaskCmd set_event_mask_command;
- set_event_mask_command.id = resource_id;
- set_event_mask_command.event_mask = event_mask;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_event_mask(std::move(set_event_mask_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetLabelCmd(uint32_t resource_id,
- const std::string& label) {
- fuchsia::ui::gfx::SetLabelCmd set_label_command;
- set_label_command.id = resource_id;
- set_label_command.label = label.substr(0, fuchsia::ui::gfx::kLabelMaxLength);
-
- fuchsia::ui::gfx::Command command;
- command.set_set_label(std::move(set_label_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::Command NewSetDisableClippingCmd(uint32_t renderer_id,
- bool disable_clipping) {
- fuchsia::ui::gfx::SetDisableClippingCmd set_disable_clipping_command;
- set_disable_clipping_command.renderer_id = renderer_id;
- set_disable_clipping_command.disable_clipping = disable_clipping;
-
- fuchsia::ui::gfx::Command command;
- command.set_set_disable_clipping(std::move(set_disable_clipping_command));
-
- return command;
-}
-
-fuchsia::ui::gfx::FloatValue NewFloatValue(float value) {
- fuchsia::ui::gfx::FloatValue val;
- val.variable_id = 0;
- val.value = value;
- return val;
-}
-
-fuchsia::ui::gfx::vec2 NewVector2(const float value[2]) {
- fuchsia::ui::gfx::vec2 val;
- val.x = value[0];
- val.y = value[1];
- return val;
-}
-
-fuchsia::ui::gfx::Vector2Value NewVector2Value(const float value[2]) {
- fuchsia::ui::gfx::Vector2Value val;
- val.variable_id = 0;
- val.value = NewVector2(value);
- return val;
-}
-
-fuchsia::ui::gfx::Vector2Value NewVector2Value(uint32_t variable_id) {
- fuchsia::ui::gfx::Vector2Value val;
- val.variable_id = variable_id;
- return val;
-}
-
-fuchsia::ui::gfx::vec3 NewVector3(const float value[3]) {
- fuchsia::ui::gfx::vec3 val;
- val.x = value[0];
- val.y = value[1];
- val.z = value[2];
- return val;
-}
-
-fuchsia::ui::gfx::Vector3Value NewVector3Value(const float value[3]) {
- fuchsia::ui::gfx::Vector3Value val;
- val.variable_id = 0;
- val.value = NewVector3(value);
- return val;
-}
-
-fuchsia::ui::gfx::Vector3Value NewVector3Value(uint32_t variable_id) {
- fuchsia::ui::gfx::Vector3Value val;
- val.variable_id = variable_id;
- return val;
-}
-
-fuchsia::ui::gfx::vec4 NewVector4(const float value[4]) {
- fuchsia::ui::gfx::vec4 val;
- val.x = value[0];
- val.y = value[1];
- val.z = value[2];
- val.w = value[3];
- return val;
-}
-
-fuchsia::ui::gfx::Vector4Value NewVector4Value(const float value[4]) {
- fuchsia::ui::gfx::Vector4Value val;
- val.variable_id = 0;
- val.value = NewVector4(value);
- return val;
-}
-
-fuchsia::ui::gfx::Vector4Value NewVector4Value(uint32_t variable_id) {
- fuchsia::ui::gfx::Vector4Value val;
- val.variable_id = variable_id;
- return val;
-}
-
-fuchsia::ui::gfx::Quaternion NewQuaternion(const float value[4]) {
- fuchsia::ui::gfx::Quaternion val;
- val.x = value[0];
- val.y = value[1];
- val.z = value[2];
- val.w = value[3];
- return val;
-}
-
-fuchsia::ui::gfx::QuaternionValue NewQuaternionValue(const float value[4]) {
- fuchsia::ui::gfx::QuaternionValue val;
- val.variable_id = 0;
- val.value = NewQuaternion(value);
- return val;
-}
-
-fuchsia::ui::gfx::QuaternionValue NewQuaternionValue(uint32_t variable_id) {
- fuchsia::ui::gfx::QuaternionValue val;
- val.variable_id = variable_id;
- return val;
-}
-
-fuchsia::ui::gfx::mat4 NewMatrix4(const float matrix[16]) {
- fuchsia::ui::gfx::mat4 val;
- val.matrix[0] = matrix[0];
- val.matrix[1] = matrix[1];
- val.matrix[2] = matrix[2];
- val.matrix[3] = matrix[3];
- val.matrix[4] = matrix[4];
- val.matrix[5] = matrix[5];
- val.matrix[6] = matrix[6];
- val.matrix[7] = matrix[7];
- val.matrix[8] = matrix[8];
- val.matrix[9] = matrix[9];
- val.matrix[10] = matrix[10];
- val.matrix[11] = matrix[11];
- val.matrix[12] = matrix[12];
- val.matrix[13] = matrix[13];
- val.matrix[14] = matrix[14];
- val.matrix[15] = matrix[15];
- return val;
-}
-
-fuchsia::ui::gfx::Matrix4Value NewMatrix4Value(const float matrix[16]) {
- fuchsia::ui::gfx::Matrix4Value val;
- val.variable_id = 0;
- val.value = NewMatrix4(matrix);
- return val;
-}
-
-fuchsia::ui::gfx::Matrix4Value NewMatrix4Value(uint32_t variable_id) {
- fuchsia::ui::gfx::Matrix4Value val;
- val.variable_id = variable_id;
- return val;
-}
-
-fuchsia::ui::gfx::ColorRgbValue NewColorRgbValue(float red, float green,
- float blue) {
- fuchsia::ui::gfx::ColorRgbValue val;
- val.variable_id = 0;
- auto& color = val.value;
- color.red = red;
- color.green = green;
- color.blue = blue;
-
- return val;
-}
-
-fuchsia::ui::gfx::ColorRgbValue NewColorRgbValue(uint32_t variable_id) {
- fuchsia::ui::gfx::ColorRgbValue val;
- val.variable_id = variable_id;
-
- return val;
-}
-
-fuchsia::ui::gfx::ColorRgbaValue NewColorRgbaValue(const uint8_t value[4]) {
- fuchsia::ui::gfx::ColorRgbaValue val;
- val.variable_id = 0;
- auto& color = val.value;
- color.red = value[0];
- color.green = value[1];
- color.blue = value[2];
- color.alpha = value[3];
-
- return val;
-}
-
-fuchsia::ui::gfx::ColorRgbaValue NewColorRgbaValue(uint32_t variable_id) {
- fuchsia::ui::gfx::ColorRgbaValue val;
- val.variable_id = variable_id;
-
- return val;
-}
-
-// TODO(mikejurka): this should be in an images util file
-bool ImageInfoEquals(const fuchsia::images::ImageInfo& a,
- const fuchsia::images::ImageInfo& b) {
- return a.transform == b.transform && a.width == b.width &&
- a.height == b.height && a.stride == b.stride &&
- a.pixel_format == b.pixel_format && a.color_space == b.color_space &&
- a.tiling == b.tiling && a.alpha_format == b.alpha_format;
-}
-
-} // namespace scenic
diff --git a/pkg/scenic_cpp/host_image_cycler.cc b/pkg/scenic_cpp/host_image_cycler.cc
deleted file mode 100644
index 70b45d6..0000000
--- a/pkg/scenic_cpp/host_image_cycler.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/ui/scenic/cpp/host_image_cycler.h"
-
-#include <zircon/assert.h>
-
-namespace scenic {
-
-HostImageCycler::HostImageCycler(Session* session)
- : EntityNode(session),
- content_node_(session),
- content_material_(session),
- image_pool_(session, kNumBuffers) {
- content_node_.SetMaterial(content_material_);
- AddChild(content_node_);
-}
-
-HostImageCycler::~HostImageCycler() = default;
-
-const HostImage* HostImageCycler::AcquireImage(
- uint32_t width, uint32_t height, uint32_t stride,
- fuchsia::images::PixelFormat pixel_format,
- fuchsia::images::ColorSpace color_space) {
- ZX_DEBUG_ASSERT(!acquired_image_);
-
- // Update the image pool and content shape.
- fuchsia::images::ImageInfo image_info;
- image_info.width = width;
- image_info.height = height;
- image_info.stride = stride;
- image_info.pixel_format = pixel_format;
- image_info.color_space = color_space;
- image_info.tiling = fuchsia::images::Tiling::LINEAR;
- reconfigured_ = image_pool_.Configure(&image_info);
-
- const HostImage* image = image_pool_.GetImage(image_index_);
- ZX_DEBUG_ASSERT(image);
- acquired_image_ = true;
- return image;
-}
-
-void HostImageCycler::ReleaseAndSwapImage() {
- ZX_DEBUG_ASSERT(acquired_image_);
- acquired_image_ = false;
-
- const HostImage* image = image_pool_.GetImage(image_index_);
- ZX_DEBUG_ASSERT(image);
- content_material_.SetTexture(*image);
-
- if (reconfigured_) {
- Rectangle content_rect(content_node_.session(),
- image_pool_.image_info()->width,
- image_pool_.image_info()->height);
- content_node_.SetShape(content_rect);
- reconfigured_ = false;
- }
-
- // TODO(MZ-145): Define an |InvalidateCmd| on |Image| instead.
- image_pool_.DiscardImage(image_index_);
- image_index_ = (image_index_ + 1) % kNumBuffers;
-}
-
-} // namespace scenic
diff --git a/pkg/scenic_cpp/host_memory.cc b/pkg/scenic_cpp/host_memory.cc
deleted file mode 100644
index d01e665..0000000
--- a/pkg/scenic_cpp/host_memory.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/ui/scenic/cpp/host_memory.h"
-
-#include <lib/zx/vmar.h>
-#include <lib/zx/vmo.h>
-#include <zircon/assert.h>
-#include <memory>
-
-#include "lib/ui/scenic/cpp/commands.h"
-
-namespace scenic {
-namespace {
-
-// Returns true if a memory object is of an appropriate size to recycle.
-bool CanReuseMemory(const HostMemory& memory, size_t desired_size) {
- return memory.data_size() >= desired_size &&
- memory.data_size() <= desired_size * 2;
-}
-
-std::pair<zx::vmo, std::shared_ptr<HostData>> AllocateMemory(size_t size) {
- // Create the vmo and map it into this process.
- zx::vmo local_vmo;
- zx_status_t status = zx::vmo::create(size, 0u, &local_vmo);
- ZX_ASSERT_MSG(status == ZX_OK, "vmo create failed: status=%d", status);
- auto data = std::make_shared<HostData>(local_vmo, 0u, size);
-
- // Drop rights before we transfer the VMO to the session manager.
- // TODO(MA-492): Now that host-local memory may be concurrently used as
- // device-local memory on UMA platforms, we need to keep all permissions on
- // the duplicated vmo handle, until Vulkan can import read-only memory.
- zx::vmo remote_vmo;
- status = local_vmo.replace(ZX_RIGHT_SAME_RIGHTS, &remote_vmo);
- ZX_ASSERT_MSG(status == ZX_OK, "replace rights failed: status=%d", status);
- return std::make_pair(std::move(remote_vmo), std::move(data));
-}
-
-} // namespace
-
-HostData::HostData(const zx::vmo& vmo, off_t offset, size_t size)
- : size_(size) {
- static const uint32_t flags =
- ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE | ZX_VM_FLAG_MAP_RANGE;
- uintptr_t ptr;
- zx_status_t status =
- zx::vmar::root_self()->map(0, vmo, offset, size, flags, &ptr);
- ZX_ASSERT_MSG(status == ZX_OK, "map failed: status=%d", status);
- ptr_ = reinterpret_cast<void*>(ptr);
-}
-
-HostData::~HostData() {
- zx_status_t status =
- zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(ptr_), size_);
- ZX_ASSERT_MSG(status == ZX_OK, "unmap failed: status=%d", status);
-}
-
-HostMemory::HostMemory(Session* session, size_t size)
- : HostMemory(session, AllocateMemory(size)) {}
-
-HostMemory::HostMemory(Session* session,
- std::pair<zx::vmo, std::shared_ptr<HostData>> init)
- : Memory(session, std::move(init.first), init.second->size(),
- fuchsia::images::MemoryType::HOST_MEMORY),
- data_(std::move(init.second)) {}
-
-HostMemory::HostMemory(HostMemory&& moved)
- : Memory(std::move(moved)), data_(std::move(moved.data_)) {}
-
-HostMemory::~HostMemory() = default;
-
-HostImage::HostImage(const HostMemory& memory, off_t memory_offset,
- fuchsia::images::ImageInfo info)
- : HostImage(memory.session(), memory.id(), memory_offset, memory.data(),
- std::move(info)) {}
-
-HostImage::HostImage(Session* session, uint32_t memory_id, off_t memory_offset,
- std::shared_ptr<HostData> data,
- fuchsia::images::ImageInfo info)
- : Image(session, memory_id, memory_offset, std::move(info)),
- data_(std::move(data)) {}
-
-HostImage::HostImage(HostImage&& moved)
- : Image(std::move(moved)), data_(std::move(moved.data_)) {}
-
-HostImage::~HostImage() = default;
-
-HostImagePool::HostImagePool(Session* session, uint32_t num_images)
- : session_(session), image_ptrs_(num_images), memory_ptrs_(num_images) {}
-
-HostImagePool::~HostImagePool() = default;
-
-// TODO(mikejurka): Double-check these changes
-bool HostImagePool::Configure(const fuchsia::images::ImageInfo* image_info) {
- if (image_info) {
- if (configured_ && ImageInfoEquals(*image_info, image_info_)) {
- return false; // no change
- }
- configured_ = true;
- image_info_ = *image_info;
- } else {
- if (!configured_) {
- return false; // no change
- }
- configured_ = false;
- }
-
- for (uint32_t i = 0; i < num_images(); i++)
- image_ptrs_[i].reset();
-
- if (configured_) {
- ZX_DEBUG_ASSERT(image_info_.width > 0);
- ZX_DEBUG_ASSERT(image_info_.height > 0);
- ZX_DEBUG_ASSERT(image_info_.stride > 0);
-
- size_t desired_size = Image::ComputeSize(image_info_);
- for (uint32_t i = 0; i < num_images(); i++) {
- if (memory_ptrs_[i] && !CanReuseMemory(*memory_ptrs_[i], desired_size))
- memory_ptrs_[i].reset();
- }
- }
- return true;
-}
-
-const HostImage* HostImagePool::GetImage(uint32_t index) {
- ZX_DEBUG_ASSERT(index < num_images());
-
- if (image_ptrs_[index])
- return image_ptrs_[index].get();
-
- if (!configured_)
- return nullptr;
-
- if (!memory_ptrs_[index]) {
- memory_ptrs_[index] =
- std::make_unique<HostMemory>(session_, Image::ComputeSize(image_info_));
- }
-
- image_ptrs_[index] =
- std::make_unique<HostImage>(*memory_ptrs_[index], 0u, image_info_);
- return image_ptrs_[index].get();
-}
-
-void HostImagePool::DiscardImage(uint32_t index) {
- ZX_DEBUG_ASSERT(index < num_images());
-
- image_ptrs_[index].reset();
-}
-
-} // namespace scenic
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/commands.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/commands.h
deleted file mode 100644
index 2c44a2f..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/commands.h
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_COMMANDS_H_
-#define LIB_UI_SCENIC_CPP_COMMANDS_H_
-
-#include <string>
-
-#include <fuchsia/images/cpp/fidl.h>
-#include <fuchsia/ui/gfx/cpp/fidl.h>
-#include <fuchsia/ui/scenic/cpp/fidl.h>
-
-namespace scenic {
-
-constexpr float kZeroesFloat3[3] = {0.f, 0.f, 0.f};
-constexpr float kOnesFloat3[3] = {1.f, 1.f, 1.f};
-// A quaterion that has no rotation.
-constexpr float kQuaternionDefault[4] = {0.f, 0.f, 0.f, 1.f};
-
-// Helper function for wrapping a GFX command as a Scenic command.
-fuchsia::ui::scenic::Command NewCommand(fuchsia::ui::gfx::Command command);
-
-// Helper function for wrapping an input command as a Scenic command.
-fuchsia::ui::scenic::Command NewCommand(fuchsia::ui::input::Command command);
-
-// Resource creation.
-fuchsia::ui::gfx::Command NewCreateMemoryCmd(
- uint32_t id, zx::vmo vmo, uint64_t allocation_size,
- fuchsia::images::MemoryType memory_type);
-fuchsia::ui::gfx::Command NewCreateImageCmd(uint32_t id, uint32_t memory_id,
- uint32_t memory_offset,
- fuchsia::images::ImageInfo info);
-fuchsia::ui::gfx::Command NewCreateImageCmd(
- uint32_t id, uint32_t memory_id, uint32_t memory_offset,
- fuchsia::images::PixelFormat format,
- fuchsia::images::ColorSpace color_space, fuchsia::images::Tiling tiling,
- uint32_t width, uint32_t height, uint32_t stride);
-fuchsia::ui::gfx::Command NewCreateImagePipeCmd(
- uint32_t id, ::fidl::InterfaceRequest<fuchsia::images::ImagePipe> request);
-fuchsia::ui::gfx::Command NewCreateBufferCmd(uint32_t id, uint32_t memory_id,
- uint32_t memory_offset,
- uint32_t num_bytes);
-
-fuchsia::ui::gfx::Command NewCreateCompositorCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateDisplayCompositorCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateLayerStackCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateLayerCmd(uint32_t id);
-
-fuchsia::ui::gfx::Command NewCreateSceneCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateCameraCmd(uint32_t id, uint32_t scene_id);
-fuchsia::ui::gfx::Command NewCreateStereoCameraCmd(uint32_t id,
- uint32_t scene_id);
-fuchsia::ui::gfx::Command NewCreateRendererCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateAmbientLightCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateDirectionalLightCmd(uint32_t id);
-
-fuchsia::ui::gfx::Command NewCreateCircleCmd(uint32_t id, float radius);
-fuchsia::ui::gfx::Command NewCreateRectangleCmd(uint32_t id, float width,
- float height);
-fuchsia::ui::gfx::Command NewCreateRoundedRectangleCmd(
- uint32_t id, float width, float height, float top_left_radius,
- float top_right_radius, float bottom_right_radius,
- float bottom_left_radius);
-
-// Variant of NewCreateCircleCmd that uses a variable radius instead of a
-// constant one set at construction time.
-fuchsia::ui::gfx::Command NewCreateVarCircleCmd(uint32_t id,
- uint32_t radius_var_id);
-// Variant of NewCreateRectangleCmd that uses a variable width/height
-// instead of constant ones set at construction time.
-fuchsia::ui::gfx::Command NewCreateVarRectangleCmd(uint32_t id,
- uint32_t width_var_id,
- uint32_t height_var_id);
-// Variant of NewCreateRoundedRectangleCmd that uses a variable
-// width/height/etc. instead of constant ones set at construction time.
-fuchsia::ui::gfx::Command NewCreateVarRoundedRectangleCmd(
- uint32_t id, uint32_t width_var_id, uint32_t height_var_id,
- uint32_t top_left_radius_var_id, uint32_t top_right_radius_var_id,
- uint32_t bottom_left_radius_var_id, uint32_t bottom_right_radius_var_id);
-
-fuchsia::ui::gfx::Command NewCreateMeshCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateMaterialCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateClipNodeCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateEntityNodeCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateOpacityNodeCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateShapeNodeCmd(uint32_t id);
-fuchsia::ui::gfx::Command NewCreateViewCmd(uint32_t id, zx::eventpair token,
- const std::string& debug_name);
-fuchsia::ui::gfx::Command NewCreateViewHolderCmd(uint32_t id,
- zx::eventpair token,
- const std::string& debug_name);
-fuchsia::ui::gfx::Command NewCreateVariableCmd(uint32_t id,
- fuchsia::ui::gfx::Value value);
-
-fuchsia::ui::gfx::Command NewReleaseResourceCmd(uint32_t id);
-
-// Export & Import operations.
-fuchsia::ui::gfx::Command NewExportResourceCmd(uint32_t resource_id,
- zx::eventpair export_token);
-fuchsia::ui::gfx::Command NewImportResourceCmd(
- uint32_t resource_id, fuchsia::ui::gfx::ImportSpec spec,
- zx::eventpair import_token);
-
-// Exports the resource and returns an import token in |out_import_token|
-// which allows it to be imported into other sessions.
-fuchsia::ui::gfx::Command NewExportResourceCmdAsRequest(
- uint32_t resource_id, zx::eventpair* out_import_token);
-
-// Imports the resource and returns an export token in |out_export_token|
-// by which another session can export a resource to associate with this import.
-fuchsia::ui::gfx::Command NewImportResourceCmdAsRequest(
- uint32_t resource_id, fuchsia::ui::gfx::ImportSpec import_spec,
- zx::eventpair* out_export_token);
-
-// View/ViewHolder commands.
-fuchsia::ui::gfx::Command NewSetViewPropertiesCmd(
- uint32_t view_holder_id, const float bounding_box_min[3],
- const float bounding_box_max[3], const float inset_from_min[3],
- const float inset_from_max[3]);
-fuchsia::ui::gfx::Command NewSetViewPropertiesCmd(
- uint32_t view_holder_id, const fuchsia::ui::gfx::ViewProperties& props);
-
-// Node operations.
-fuchsia::ui::gfx::Command NewAddChildCmd(uint32_t node_id, uint32_t child_id);
-fuchsia::ui::gfx::Command NewAddPartCmd(uint32_t node_id, uint32_t part_id);
-fuchsia::ui::gfx::Command NewDetachCmd(uint32_t node_id);
-fuchsia::ui::gfx::Command NewDetachChildrenCmd(uint32_t node_id);
-fuchsia::ui::gfx::Command NewSetTranslationCmd(uint32_t node_id,
- const float translation[3]);
-fuchsia::ui::gfx::Command NewSetTranslationCmd(uint32_t node_id,
- uint32_t variable_id);
-fuchsia::ui::gfx::Command NewSetScaleCmd(uint32_t node_id,
- const float scale[3]);
-fuchsia::ui::gfx::Command NewSetScaleCmd(uint32_t node_id,
- uint32_t variable_id);
-fuchsia::ui::gfx::Command NewSetRotationCmd(uint32_t node_id,
- const float quaternion[4]);
-fuchsia::ui::gfx::Command NewSetRotationCmd(uint32_t node_id,
- uint32_t variable_id);
-fuchsia::ui::gfx::Command NewSetAnchorCmd(uint32_t node_id,
- const float anchor[3]);
-fuchsia::ui::gfx::Command NewSetAnchorCmd(uint32_t node_id,
- uint32_t variable_id);
-
-fuchsia::ui::gfx::Command NewSetOpacityCmd(uint32_t node_id, float opacity);
-fuchsia::ui::gfx::Command NewSendSizeChangeHintCmdHACK(
- uint32_t node_id, float width_change_factor, float height_change_factor);
-fuchsia::ui::gfx::Command NewSetShapeCmd(uint32_t node_id, uint32_t shape_id);
-fuchsia::ui::gfx::Command NewSetMaterialCmd(uint32_t node_id,
- uint32_t material_id);
-fuchsia::ui::gfx::Command NewSetClipCmd(uint32_t node_id, uint32_t clip_id,
- bool clip_to_self);
-fuchsia::ui::gfx::Command NewSetTagCmd(uint32_t node_id, uint32_t tag_value);
-fuchsia::ui::gfx::Command NewSetHitTestBehaviorCmd(
- uint32_t node_id, fuchsia::ui::gfx::HitTestBehavior hit_test_behavior);
-fuchsia::ui::gfx::Command NewTakeSnapshotCmdHACK(
- uint32_t id, fuchsia::ui::gfx::SnapshotCallbackHACKPtr callback);
-
-// Camera and lighting operations.
-
-fuchsia::ui::gfx::Command NewSetCameraCmd(uint32_t renderer_id,
- uint32_t camera_id);
-fuchsia::ui::gfx::Command NewSetCameraTransformCmd(uint32_t camera_id,
- const float eye_position[3],
- const float eye_look_at[3],
- const float eye_up[3]);
-fuchsia::ui::gfx::Command NewSetCameraProjectionCmd(uint32_t camera_id,
- const float fovy);
-
-fuchsia::ui::gfx::Command NewSetCameraPoseBufferCmd(uint32_t camera_id,
- uint32_t buffer_id,
- uint32_t num_entries,
- int64_t base_time,
- uint64_t time_interval);
-
-fuchsia::ui::gfx::Command NewSetStereoCameraProjectionCmd(
- uint32_t camera_id, const float left_projection[16],
- const float right_projection[16]);
-
-fuchsia::ui::gfx::Command NewSetLightColorCmd(uint32_t light_id,
- const float rgb[3]);
-fuchsia::ui::gfx::Command NewSetLightColorCmd(uint32_t light_id,
- uint32_t variable_id);
-fuchsia::ui::gfx::Command NewSetLightDirectionCmd(uint32_t light_id,
- const float direction[3]);
-fuchsia::ui::gfx::Command NewSetLightDirectionCmd(uint32_t light_id,
- uint32_t variable_id);
-fuchsia::ui::gfx::Command NewAddLightCmd(uint32_t scene_id, uint32_t light_id);
-fuchsia::ui::gfx::Command NewDetachLightCmd(uint32_t light_id);
-fuchsia::ui::gfx::Command NewDetachLightsCmd(uint32_t scene_id);
-
-// Material operations.
-fuchsia::ui::gfx::Command NewSetTextureCmd(uint32_t node_id, uint32_t image_id);
-fuchsia::ui::gfx::Command NewSetColorCmd(uint32_t node_id, uint8_t red,
- uint8_t green, uint8_t blue,
- uint8_t alpha);
-
-// Mesh operations.
-fuchsia::ui::gfx::MeshVertexFormat NewMeshVertexFormat(
- fuchsia::ui::gfx::ValueType position_type,
- fuchsia::ui::gfx::ValueType normal_type,
- fuchsia::ui::gfx::ValueType tex_coord_type);
-// These arguments are documented in commands.fidl; see BindMeshBuffersCmd.
-fuchsia::ui::gfx::Command NewBindMeshBuffersCmd(
- uint32_t mesh_id, uint32_t index_buffer_id,
- fuchsia::ui::gfx::MeshIndexFormat index_format, uint64_t index_offset,
- uint32_t index_count, uint32_t vertex_buffer_id,
- fuchsia::ui::gfx::MeshVertexFormat vertex_format, uint64_t vertex_offset,
- uint32_t vertex_count, const float bounding_box_min[3],
- const float bounding_box_max[3]);
-
-// Layer / LayerStack / Compositor operations.
-fuchsia::ui::gfx::Command NewAddLayerCmd(uint32_t layer_stack_id,
- uint32_t layer_id);
-fuchsia::ui::gfx::Command NewRemoveLayerCmd(uint32_t layer_stack_id,
- uint32_t layer_id);
-fuchsia::ui::gfx::Command NewRemoveAllLayersCmd(uint32_t layer_stack_id);
-fuchsia::ui::gfx::Command NewSetLayerStackCmd(uint32_t compositor_id,
- uint32_t layer_stack_id);
-fuchsia::ui::gfx::Command NewSetRendererCmd(uint32_t layer_id,
- uint32_t renderer_id);
-fuchsia::ui::gfx::Command NewSetRendererParamCmd(
- uint32_t renderer_id, fuchsia::ui::gfx::RendererParam param);
-fuchsia::ui::gfx::Command NewSetSizeCmd(uint32_t node_id, const float size[2]);
-
-// Event operations.
-fuchsia::ui::gfx::Command NewSetEventMaskCmd(uint32_t resource_id,
- uint32_t event_mask);
-
-// Diagnostic operations.
-fuchsia::ui::gfx::Command NewSetLabelCmd(uint32_t resource_id,
- const std::string& label);
-
-// Debugging operations.
-fuchsia::ui::gfx::Command NewSetDisableClippingCmd(uint32_t resource_id,
- bool disable_clipping);
-
-// Basic types.
-fuchsia::ui::gfx::FloatValue NewFloatValue(float value);
-fuchsia::ui::gfx::Vector2Value NewVector2Value(const float value[2]);
-fuchsia::ui::gfx::Vector2Value NewVector2Value(uint32_t variable_id);
-fuchsia::ui::gfx::Vector3Value NewVector3Value(const float value[3]);
-fuchsia::ui::gfx::Vector3Value NewVector3Value(uint32_t variable_id);
-fuchsia::ui::gfx::Vector4Value NewVector4Value(const float value[4]);
-fuchsia::ui::gfx::Vector4Value NewVector4Value(uint32_t variable_id);
-fuchsia::ui::gfx::QuaternionValue NewQuaternionValue(const float value[4]);
-fuchsia::ui::gfx::QuaternionValue NewQuaternionValue(uint32_t variable_id);
-fuchsia::ui::gfx::Matrix4Value NewMatrix4Value(const float value[16]);
-fuchsia::ui::gfx::Matrix4Value NewMatrix4Value(uint32_t variable_id);
-fuchsia::ui::gfx::ColorRgbValue NewColorRgbValue(float red, float green,
- float blue);
-fuchsia::ui::gfx::ColorRgbValue NewColorRgbValue(uint32_t variable_id);
-fuchsia::ui::gfx::ColorRgbaValue NewColorRgbaValue(const uint8_t value[4]);
-fuchsia::ui::gfx::ColorRgbaValue NewColorRgbaValue(uint32_t variable_id);
-fuchsia::ui::gfx::QuaternionValue NewQuaternionValue(const float value[4]);
-fuchsia::ui::gfx::vec2 NewVector2(const float value[2]);
-fuchsia::ui::gfx::vec3 NewVector3(const float value[3]);
-fuchsia::ui::gfx::vec4 NewVector4(const float value[4]);
-
-// Utilities.
-
-bool ImageInfoEquals(const fuchsia::images::ImageInfo& a,
- const fuchsia::images::ImageInfo& b);
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_COMMANDS_H_
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_image_cycler.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_image_cycler.h
deleted file mode 100644
index 0e89ce4..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_image_cycler.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_HOST_IMAGE_CYCLER_H_
-#define LIB_UI_SCENIC_CPP_HOST_IMAGE_CYCLER_H_
-
-#include "lib/ui/scenic/cpp/host_memory.h"
-
-namespace scenic {
-
-// Creates a node which presents double-buffered content drawn to an image
-// in host memory.
-class HostImageCycler : public scenic::EntityNode {
- public:
- explicit HostImageCycler(scenic::Session* session);
- ~HostImageCycler();
-
- HostImageCycler(const HostImageCycler&) = delete;
- HostImageCycler& operator=(const HostImageCycler&) = delete;
-
- // Acquires an image for rendering.
- // At most one image can be acquired at a time.
- // The client is responsible for clearing the image.
- const HostImage* AcquireImage(uint32_t width, uint32_t height,
- uint32_t stride,
- fuchsia::images::PixelFormat pixel_format =
- fuchsia::images::PixelFormat::BGRA_8,
- fuchsia::images::ColorSpace color_space =
- fuchsia::images::ColorSpace::SRGB);
-
- // Releases the image most recently acquired using |AcquireImage()|.
- // Sets the content node's texture to be backed by the image.
- void ReleaseAndSwapImage();
-
- private:
- static constexpr uint32_t kNumBuffers = 2u;
-
- scenic::ShapeNode content_node_;
- scenic::Material content_material_;
- scenic::HostImagePool image_pool_;
-
- bool acquired_image_ = false;
- bool reconfigured_ = false;
- uint32_t image_index_ = 0u;
-};
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_HOST_IMAGE_CYCLER_H_
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_memory.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_memory.h
deleted file mode 100644
index 6209422..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_memory.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_HOST_MEMORY_H_
-#define LIB_UI_SCENIC_CPP_HOST_MEMORY_H_
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include <lib/zx/vmo.h>
-
-#include "lib/ui/scenic/cpp/resources.h"
-
-namespace scenic {
-
-// Provides access to data stored in a host-accessible shared memory region.
-// The memory is unmapped once all references to this object have been released.
-class HostData : public std::enable_shared_from_this<HostData> {
- public:
- // Maps a range of an existing VMO into memory.
- HostData(const zx::vmo& vmo, off_t offset, size_t size);
- ~HostData();
-
- HostData(const HostData&) = delete;
- HostData& operator=(const HostData&) = delete;
-
- // Gets the size of the data in bytes.
- size_t size() const { return size_; }
-
- // Gets a pointer to the data.
- void* ptr() const { return ptr_; }
-
- private:
- size_t const size_;
- void* ptr_;
-};
-
-// Represents a host-accessible shared memory backed memory resource in a
-// session. The memory is mapped read/write into this process and transferred
-// read-only to the scene manager. The shared memory region is retained until
-// this object is destroyed.
-// TODO(MZ-268): Don't inherit from Memory, so that Memory can have a public
-// move constructor.
-// TODO(MA-492): The memory is currently not transferred read-only, as we may
-// choose to map it as device-local memory on UMA platforms, and Vulkan requires
-// a read/write vmo in order to successfully import the memory.
-class HostMemory final : public Memory {
- public:
- HostMemory(Session* session, size_t size);
- HostMemory(HostMemory&& moved);
- ~HostMemory();
-
- HostMemory(const HostMemory&) = delete;
- HostMemory& operator=(const HostMemory&) = delete;
-
- // Gets a reference to the underlying shared memory region.
- const std::shared_ptr<HostData>& data() const { return data_; }
-
- // Gets the size of the data in bytes.
- size_t data_size() const { return data_->size(); }
-
- // Gets a pointer to the data.
- void* data_ptr() const { return data_->ptr(); }
-
- private:
- explicit HostMemory(Session* session,
- std::pair<zx::vmo, std::shared_ptr<HostData>> init);
-
- std::shared_ptr<HostData> data_;
-};
-
-// Represents an image resource backed by host-accessible shared memory bound to
-// a session. The shared memory region is retained until this object is
-// destroyed.
-// TODO(MZ-268): Don't inherit from Image, so that Image can have a public move
-// constructor.
-class HostImage final : public Image {
- public:
- HostImage(const HostMemory& memory, off_t memory_offset,
- fuchsia::images::ImageInfo info);
- HostImage(Session* session, uint32_t memory_id, off_t memory_offset,
- std::shared_ptr<HostData> data, fuchsia::images::ImageInfo info);
- HostImage(HostImage&& moved);
- ~HostImage();
-
- HostImage(const HostImage&) = delete;
- HostImage& operator=(const HostImage&) = delete;
-
- // Gets a reference to the underlying shared memory region.
- const std::shared_ptr<HostData>& data() const { return data_; }
-
- // Gets a pointer to the image data.
- void* image_ptr() const {
- return static_cast<uint8_t*>(data_->ptr()) + memory_offset();
- }
-
- private:
- std::shared_ptr<HostData> data_;
-};
-
-// Represents a pool of image resources backed by host-accessible shared memory
-// bound to a session. All images in the pool must have the same layout.
-class HostImagePool {
- public:
- // Creates a pool which can supply up to |num_images| images on demand.
- explicit HostImagePool(Session* session, uint32_t num_images);
- ~HostImagePool();
-
- HostImagePool(const HostImagePool&) = delete;
- HostImagePool& operator=(const HostImagePool&) = delete;
-
- // The number of images which this pool can manage.
- uint32_t num_images() const { return image_ptrs_.size(); }
-
- // Gets information about the images in the pool, or nullptr if the
- // pool is not configured.
- const fuchsia::images::ImageInfo* image_info() const { return &image_info_; }
-
- // Sets the image information for images in the pool.
- // Previously created images are released but their memory may be reused.
- // If |image_info| is nullptr, the pool reverts to an non-configured state;
- // all images are released but the memory is retained for recycling.
- // Returns true if the configuration changed.
- bool Configure(const fuchsia::images::ImageInfo* image_info);
-
- // Gets the image with the specified index.
- // The |index| must be between 0 and |num_images() - 1|.
- // The returned pointer is valid until the image is discarded or the
- // pool is reconfigured. Returns nullptr if the pool is not configured.
- const HostImage* GetImage(uint32_t index);
-
- // Discards the image with the specified index but recycles its memory.
- // The |index| must be between 0 and |num_images() - 1|.
- void DiscardImage(uint32_t index);
-
- private:
- Session* const session_;
-
- bool configured_ = false;
- fuchsia::images::ImageInfo image_info_;
- std::vector<std::unique_ptr<HostImage>> image_ptrs_;
- std::vector<std::unique_ptr<HostMemory>> memory_ptrs_;
-};
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_HOST_MEMORY_H_
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/id.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/id.h
deleted file mode 100644
index a500046..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/id.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_ID_H_
-#define LIB_UI_SCENIC_CPP_ID_H_
-
-#include <cstdint>
-
-namespace scenic {
-
-using SessionId = uint64_t;
-using ResourceId = uint32_t;
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_ID_H_
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h
deleted file mode 100644
index 40d6b0c..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h
+++ /dev/null
@@ -1,593 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_RESOURCES_H_
-#define LIB_UI_SCENIC_CPP_RESOURCES_H_
-
-#include "lib/ui/scenic/cpp/session.h"
-
-#include <zircon/assert.h>
-
-namespace scenic {
-
-// Represents a resource in a session with a dynamically allocated id.
-// The resource is released from the session when this object is destroyed
-// but it may still be in use within the session if other resources reference
-// it.
-// This type cannot be instantiated, please see subclasses.
-class Resource {
- public:
- // Gets the session which owns this resource.
- Session* session() const {
- ZX_DEBUG_ASSERT(session_);
- return session_;
- }
-
- // Gets the resource's id.
- uint32_t id() const { return id_; }
-
- // Exports the resource and associates it with |export_token|.
- void Export(zx::eventpair export_token);
-
- // Exports the resource and returns an import token in |out_import_token|
- // which allows it to be imported into other sessions.
- void ExportAsRequest(zx::eventpair* out_import_token);
-
- // Sets which events a resource should deliver to the session listener.
- void SetEventMask(uint32_t event_mask);
-
- // Sets a label to help developers identify the purpose of the resource
- // when using diagnostic tools.
- void SetLabel(const std::string& label);
-
- protected:
- explicit Resource(Session* session);
- Resource(Resource&& moved);
-
- Resource(const Resource&) = delete;
- Resource& operator=(const Resource&) = delete;
-
- virtual ~Resource();
-
- private:
- Session* const session_;
- uint32_t const id_;
-};
-
-// Represents a memory resource in a session.
-// TODO(MZ-268): Make this class final, and add public move constructor.
-class Memory : public Resource {
- public:
- Memory(Session* session, zx::vmo vmo, uint64_t allocation_size,
- fuchsia::images::MemoryType memory_type);
- ~Memory();
-
- // Gets the underlying VMO's memory type, indicating whether it represents
- // host or GPU memory.
- fuchsia::images::MemoryType memory_type() const { return memory_type_; }
-
- protected:
- Memory(Memory&& moved);
-
- private:
- fuchsia::images::MemoryType const memory_type_;
-};
-
-// Represents an abstract shape resource in a session.
-// This type cannot be instantiated, please see subclasses.
-class Shape : public Resource {
- protected:
- explicit Shape(Session* session);
- Shape(Shape&& moved);
- ~Shape();
-};
-
-// Represents a circle shape resource in a session.
-class Circle final : public Shape {
- public:
- Circle(Session* session, float radius);
- Circle(Circle&& moved);
- ~Circle();
-};
-
-// Represents a rectangle shape resource in a session.
-class Rectangle final : public Shape {
- public:
- Rectangle(Session* session, float width, float height);
- Rectangle(Rectangle&& moved);
- ~Rectangle();
-};
-
-// Represents a rounded rectangle shape resource in a session.
-class RoundedRectangle final : public Shape {
- public:
- RoundedRectangle(Session* session, float width, float height,
- float top_left_radius, float top_right_radius,
- float bottom_right_radius, float bottom_left_radius);
- RoundedRectangle(RoundedRectangle&& moved);
- ~RoundedRectangle();
-};
-
-// Represents an image resource in a session.
-// TODO(MZ-268): Make this class final, and add public move constructor.
-class Image : public Resource {
- public:
- // Creates an image resource bound to a session.
- Image(const Memory& memory, off_t memory_offset,
- fuchsia::images::ImageInfo info);
- Image(Session* session, uint32_t memory_id, off_t memory_offset,
- fuchsia::images::ImageInfo info);
- ~Image();
-
- // Returns the number of bytes needed to represent an image.
- static size_t ComputeSize(const fuchsia::images::ImageInfo& image_info);
-
- // Gets the byte offset of the image within its memory resource.
- off_t memory_offset() const { return memory_offset_; }
-
- // Gets information about the image's layout.
- const fuchsia::images::ImageInfo& info() const { return info_; }
-
- protected:
- Image(Image&& moved);
-
- private:
- off_t const memory_offset_;
- fuchsia::images::ImageInfo const info_;
-};
-
-// Represents a buffer that is immutably bound to a range of a memory resource.
-class Buffer final : public Resource {
- public:
- Buffer(const Memory& memory, off_t memory_offset, size_t buffer_size);
- Buffer(Session* session, uint32_t memory_id, off_t memory_offset,
- size_t buffer_size);
- Buffer(Buffer&& moved);
- ~Buffer();
-};
-
-// Represents a mesh resource in a session. Before it can be rendered, it
-// must be bound to index and vertex arrays by calling the BindBuffers() method.
-class Mesh final : public Shape {
- public:
- Mesh(Session* session);
- Mesh(Mesh&& moved);
- ~Mesh();
-
- // These arguments are documented in commands.fidl; see
- // BindMeshBuffersCmd.
- void BindBuffers(const Buffer& index_buffer,
- fuchsia::ui::gfx::MeshIndexFormat index_format,
- uint64_t index_offset, uint32_t index_count,
- const Buffer& vertex_buffer,
- fuchsia::ui::gfx::MeshVertexFormat vertex_format,
- uint64_t vertex_offset, uint32_t vertex_count,
- const float bounding_box_min[3],
- const float bounding_box_max[3]);
-};
-
-// Represents a material resource in a session.
-class Material final : public Resource {
- public:
- explicit Material(Session* session);
- Material(Material&& moved);
- ~Material();
-
- // Sets the material's texture.
- void SetTexture(const Image& image) {
- ZX_DEBUG_ASSERT(session() == image.session());
- SetTexture(image.id());
- }
- void SetTexture(uint32_t image_id);
-
- // Sets the material's color.
- void SetColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
-};
-
-// Represents an abstract node resource in a session.
-// This type cannot be instantiated, please see subclasses.
-class Node : public Resource {
- public:
- // Sets the node's transform properties.
- void SetTranslation(float tx, float ty, float tz) {
- SetTranslation((float[3]){tx, ty, tz});
- }
- void SetTranslation(const float translation[3]);
- void SetTranslation(uint32_t variable_id);
- void SetScale(float sx, float sy, float sz) {
- SetScale((float[3]){sx, sy, sz});
- }
- void SetScale(const float scale[3]);
- void SetScale(uint32_t variable_id);
- void SetRotation(float qi, float qj, float qk, float qw) {
- SetRotation((float[4]){qi, qj, qk, qw});
- }
- void SetRotation(const float quaternion[4]);
- void SetRotation(uint32_t variable_id);
- void SetAnchor(float ax, float ay, float az) {
- SetAnchor((float[3]){ax, ay, az});
- }
- void SetAnchor(const float anchor[3]);
- void SetAnchor(uint32_t variable_id);
-
- void SendSizeChangeHint(float width_change_factor,
- float height_change_factor);
-
- // Sets the node's tag value.
- void SetTag(uint32_t tag_value);
-
- // Sets the node's hit test behavior.
- void SetHitTestBehavior(fuchsia::ui::gfx::HitTestBehavior hit_test_behavior);
-
- // Detaches the node from its parent.
- void Detach();
-
- protected:
- explicit Node(Session* session);
- Node(Node&& moved);
- ~Node();
-};
-
-// Represents an shape node resource in a session.
-class ShapeNode final : public Node {
- public:
- explicit ShapeNode(Session* session);
- ShapeNode(ShapeNode&& moved);
- ~ShapeNode();
-
- // Sets the shape that the shape node should draw.
- void SetShape(const Shape& shape) {
- ZX_DEBUG_ASSERT(session() == shape.session());
- SetShape(shape.id());
- }
- void SetShape(uint32_t shape_id);
-
- // Sets the material with which to draw the shape.
- void SetMaterial(const Material& material) {
- ZX_DEBUG_ASSERT(session() == material.session());
- SetMaterial(material.id());
- }
- void SetMaterial(uint32_t material_id);
-};
-
-// Abstract base class for nodes which can have child nodes.
-// This type cannot be instantiated, please see subclasses.
-class ContainerNode : public Node {
- public:
- // Adds a child to the node.
- void AddChild(const Node& child) {
- ZX_DEBUG_ASSERT(session() == child.session());
- AddChild(child.id());
- }
- void AddChild(uint32_t child_node_id);
-
- void AddPart(const Node& part) {
- ZX_DEBUG_ASSERT(session() == part.session());
- AddPart(part.id());
- }
- void AddPart(uint32_t part_node_id);
-
- // Detaches all children from the node.
- void DetachChildren();
-
- protected:
- explicit ContainerNode(Session* session);
- ContainerNode(ContainerNode&& moved);
- ~ContainerNode();
-};
-
-// Required by EntityNode::Attach().
-class ViewHolder;
-
-// Represents an entity node resource in a session.
-// TODO(MZ-268): Make this class final, and add public move constructor.
-class EntityNode : public ContainerNode {
- public:
- explicit EntityNode(Session* session);
- ~EntityNode();
-
- void SetClip(uint32_t clip_id, bool clip_to_self);
-
- void Attach(const ViewHolder& view_holder);
-
- void Snapshot(fuchsia::ui::gfx::SnapshotCallbackHACKPtr callback);
-};
-
-// Represents an imported node resource in a session.
-// The imported node is initially created in an unbound state and must
-// be bound immediately after creation, prior to use.
-class ImportNode final : public ContainerNode {
- public:
- explicit ImportNode(Session* session);
- ImportNode(ImportNode&& moved);
- ~ImportNode();
-
- // Imports the node associated with |import_token|.
- void Bind(zx::eventpair import_token);
-
- // Imports the node and returns an export token in |out_export_token|
- // by which another session can export a node to associate with this import.
- void BindAsRequest(zx::eventpair* out_export_token);
-
- // Returns true if the import has been bound.
- bool is_bound() const { return is_bound_; }
-
- private:
- bool is_bound_ = false;
-};
-
-// Represents a proxy for a View which can be added to a scene graph in order
-// to embed the View within it.
-//
-// Each ViewHolder is linked to a paired View via a shared token.
-//
-// Usually the ViewHolder and its associated View exist in separate processes,
-// allowing a distributed scene graph to be constructed.
-class ViewHolder final : public Resource {
- public:
- ViewHolder(Session* session, zx::eventpair token,
- const std::string& debug_name);
- ~ViewHolder();
-
- // Set properties of the attached view.
-
- void SetViewProperties(float min_x, float min_y, float min_z, float max_x,
- float max_y, float max_z, float in_min_x,
- float in_min_y, float in_min_z, float in_max_x,
- float in_max_y, float in_max_z) {
- SetViewProperties((float[3]){min_x, min_y, min_z},
- (float[3]){max_x, max_y, max_z},
- (float[3]){in_min_x, in_min_y, in_min_z},
- (float[3]){in_max_x, in_max_y, in_max_z});
- }
- void SetViewProperties(const float bounding_box_min[3],
- const float bounding_box_max[3],
- const float inset_from_min[3],
- const float inset_from_max[3]);
- void SetViewProperties(const fuchsia::ui::gfx::ViewProperties& props);
-};
-
-// Represents a transform space which serves as a container for Nodes. The
-// Nodes will have the Views' coordinate transform applied to their own, in
-// addition to being clipped to the Views' bounding box.
-class View final : public Resource {
- public:
- View(Session* session, zx::eventpair token, const std::string& debug_name);
- ~View();
-
- void AddChild(const Node& child) const;
- void DetachChild(const Node& child) const;
-};
-
-// Creates a node that clips the contents of its hierarchy to the specified clip
-// shape.
-class ClipNode final : public ContainerNode {
- public:
- explicit ClipNode(Session* session);
- ClipNode(ClipNode&& moved);
- ~ClipNode();
-};
-
-// Creates a node that renders its hierarchy with the specified opacity.
-class OpacityNode final : public ContainerNode {
- public:
- explicit OpacityNode(Session* session);
- OpacityNode(OpacityNode&& moved);
- ~OpacityNode();
-
- // The opacity with which to render the contents of the hierarchy rooted at
- // this node. The opacity values are clamped 0.0 to 1.0.
- void SetOpacity(float opacity);
-};
-
-// A value that can be used in place of a constant value.
-class Variable final : public Resource {
- public:
- explicit Variable(Session* session, fuchsia::ui::gfx::Value initial_value);
- Variable(Variable&& moved);
- ~Variable();
-};
-
-// Represents an abstract light resource in a session.
-// This type cannot be instantiated, please see subclasses.
-class Light : public Resource {
- public:
- // Sets the light's color.
- void SetColor(float red, float green, float blue) {
- SetColor((float[3]){red, green, blue});
- }
- void SetColor(const float rgb[3]);
- void SetColor(uint32_t variable_id);
-
- // Detach light from the scene it is attached to, if any.
- void Detach();
-
- protected:
- explicit Light(Session* session);
- Light(Light&& moved);
- ~Light();
-};
-
-// Represents a directional light resource in a session.
-class AmbientLight final : public Light {
- public:
- explicit AmbientLight(Session* session);
- AmbientLight(AmbientLight&& moved);
- ~AmbientLight();
-};
-
-// Represents a directional light resource in a session.
-class DirectionalLight final : public Light {
- public:
- explicit DirectionalLight(Session* session);
- DirectionalLight(DirectionalLight&& moved);
- ~DirectionalLight();
-
- // Sets the light's direction.
- void SetDirection(float dx, float dy, float dz) {
- SetDirection((float[3]){dx, dy, dz});
- }
- void SetDirection(const float direction[3]);
- void SetDirection(uint32_t variable_id);
-};
-
-// Represents a scene resource in a session.
-class Scene final : public ContainerNode {
- public:
- explicit Scene(Session* session);
- Scene(Scene&& moved);
- ~Scene();
-
- void AddLight(const Light& light) {
- ZX_DEBUG_ASSERT(session() == light.session());
- AddLight(light.id());
- }
- void AddLight(uint32_t light_id);
- void DetachLights();
-
- private:
- void Detach() = delete;
-};
-
-class CameraBase : public Resource {
- public:
- CameraBase(Session* session) : Resource(session) {}
- CameraBase(CameraBase&& moved) : Resource(std::move(moved)) {}
- ~CameraBase() {}
- // Sets the camera's view parameters.
- void SetTransform(const float eye_position[3], const float eye_look_at[3],
- const float eye_up[3]);
- // Sets the camera pose buffer
- void SetPoseBuffer(const Buffer& buffer, uint32_t num_entries,
- int64_t base_time, uint64_t time_interval);
-};
-
-// Represents a camera resource in a session.
-class Camera : public CameraBase {
- public:
- explicit Camera(const Scene& scene);
- Camera(Session* session, uint32_t scene_id);
- Camera(Camera&& moved);
- ~Camera();
-
- // Sets the camera's projection parameters.
- void SetProjection(const float fovy);
-};
-
-// Represents a StereoCamera resource in a session.
-class StereoCamera final : public CameraBase {
- public:
- explicit StereoCamera(const Scene& scene);
- StereoCamera(Session* session, uint32_t scene_id);
- StereoCamera(StereoCamera&& moved);
- ~StereoCamera();
-
- // Sets the camera's projection parameters.
- void SetStereoProjection(const float left_projection[16],
- const float right_projection[16]);
-};
-
-// Represents a renderer resource in a session.
-class Renderer final : public Resource {
- public:
- explicit Renderer(Session* session);
- Renderer(Renderer&& moved);
- ~Renderer();
-
- // Sets the camera whose view will be rendered.
- void SetCamera(const Camera& camera) {
- ZX_DEBUG_ASSERT(session() == camera.session());
- SetCamera(camera.id());
- }
- void SetCamera(uint32_t camera_id);
-
- void SetParam(fuchsia::ui::gfx::RendererParam param);
-
- // Convenient wrapper for SetParam().
- void SetShadowTechnique(fuchsia::ui::gfx::ShadowTechnique technique);
-
- // Set whether clipping is disabled for this renderer.
- // NOTE: disabling clipping only has a visual effect; hit-testing is not
- // affected.
- void SetDisableClipping(bool disable_clipping);
-};
-
-// Represents a layer resource in a session.
-class Layer final : public Resource {
- public:
- explicit Layer(Session* session);
- Layer(Layer&& moved);
- ~Layer();
-
- // Sets the layer's XY translation and Z-order.
- void SetTranslation(float tx, float ty, float tz) {
- SetTranslation((float[3]){tx, ty, tz});
- }
- void SetTranslation(const float translation[3]);
-
- void SetSize(float width, float height) {
- SetSize((float[2]){width, height});
- }
- void SetSize(const float size[2]);
-
- void SetRenderer(const Renderer& renderer) {
- ZX_DEBUG_ASSERT(session() == renderer.session());
- SetRenderer(renderer.id());
- }
- void SetRenderer(uint32_t renderer_id);
-};
-
-// Represents a layer-stack resource in a session.
-class LayerStack final : public Resource {
- public:
- explicit LayerStack(Session* session);
- LayerStack(LayerStack&& moved);
- ~LayerStack();
-
- void AddLayer(const Layer& layer) {
- ZX_DEBUG_ASSERT(session() == layer.session());
- AddLayer(layer.id());
- }
- void AddLayer(uint32_t layer_id);
- void RemoveLayer(const Layer& layer) {
- ZX_DEBUG_ASSERT(session() == layer.session());
- RemoveLayer(layer.id());
- }
- void RemoveLayer(uint32_t layer_id);
- void RemoveAllLayers();
-};
-
-// Represents a display-compositor resource in a session.
-class DisplayCompositor final : public Resource {
- public:
- explicit DisplayCompositor(Session* session);
- DisplayCompositor(DisplayCompositor&& moved);
- ~DisplayCompositor();
-
- // Sets the layer-stack that is to be composited.
- void SetLayerStack(const LayerStack& layer_stack) {
- ZX_DEBUG_ASSERT(session() == layer_stack.session());
- SetLayerStack(layer_stack.id());
- }
- void SetLayerStack(uint32_t layer_stack_id);
-};
-
-// Represents a display-less compositor resource in a session.
-class Compositor final : public Resource {
- public:
- explicit Compositor(Session* session);
- Compositor(Compositor&& moved);
- ~Compositor();
-
- // Sets the layer-stack that is to be composited.
- void SetLayerStack(const LayerStack& layer_stack) {
- ZX_DEBUG_ASSERT(session() == layer_stack.session());
- SetLayerStack(layer_stack.id());
- }
- void SetLayerStack(uint32_t layer_stack_id);
-};
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_RESOURCES_H_
diff --git a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h b/pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h
deleted file mode 100644
index 3455d15..0000000
--- a/pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_CPP_SESSION_H_
-#define LIB_UI_SCENIC_CPP_SESSION_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-#include <fuchsia/ui/gfx/cpp/fidl.h>
-#include <fuchsia/ui/input/cpp/fidl.h>
-#include <fuchsia/ui/scenic/cpp/fidl.h>
-#include <lib/fit/function.h>
-#include <lib/zx/event.h>
-
-#include <utility>
-
-#include "lib/fidl/cpp/binding.h"
-
-namespace scenic {
-
-// Connect to Scenic and establish a new Session, as well as an InterfaceRequest
-// for a SessionListener that can be hooked up as desired.
-using SessionPtrAndListenerRequest =
- std::pair<fuchsia::ui::scenic::SessionPtr,
- fidl::InterfaceRequest<fuchsia::ui::scenic::SessionListener>>;
-SessionPtrAndListenerRequest CreateScenicSessionPtrAndListenerRequest(
- fuchsia::ui::scenic::Scenic* scenic);
-
-// Wraps a Scenic session.
-// Maintains a queue of pending operations and assists with allocation of
-// resource ids.
-class Session : private fuchsia::ui::scenic::SessionListener {
- public:
- // Provides timing information about a presentation request which has
- // been applied by the scene manager.
- using PresentCallback =
- fit::function<void(fuchsia::images::PresentationInfo info)>;
-
- // Provide information about hits.
- using HitTestCallback =
- fit::function<void(fidl::VectorPtr<fuchsia::ui::gfx::Hit> hits)>;
-
- // Called when session events are received.
- using EventHandler =
- fit::function<void(fidl::VectorPtr<fuchsia::ui::scenic::Event>)>;
-
- // Wraps the provided session and session listener.
- // The listener is optional.
- explicit Session(fuchsia::ui::scenic::SessionPtr session,
- fidl::InterfaceRequest<fuchsia::ui::scenic::SessionListener>
- session_listener = nullptr);
-
- // Creates a new session using the provided Scenic and binds the listener to
- // this object. The Scenic itself is not retained after construction.
- explicit Session(fuchsia::ui::scenic::Scenic* scenic);
-
- explicit Session(SessionPtrAndListenerRequest session_and_listener);
-
- Session(const Session&) = delete;
- Session& operator=(const Session&) = delete;
-
- // Destroys the session.
- // All resources must be released prior to destruction.
- ~Session();
-
- void set_error_handler(fit::function<void(zx_status_t)> closure) {
- session_.set_error_handler(std::move(closure));
- }
-
- // Sets a callback which is invoked when events are received.
- void set_event_handler(EventHandler event_handler) {
- event_handler_ = std::move(event_handler);
- }
-
- // Gets a pointer to the underlying session interface.
- fuchsia::ui::scenic::Session* session() { return session_.get(); }
-
- // Allocates a new unique resource id.
- uint32_t AllocResourceId();
-
- // Enqueues an operation to release a resource.
- void ReleaseResource(uint32_t resource_id);
-
- // Enqueues an operation.
- // The session will queue operations locally to batch submission of operations
- // until |Flush()| or |Present()| is called.
- void Enqueue(fuchsia::ui::scenic::Command command);
- void Enqueue(fuchsia::ui::gfx::Command command);
- void Enqueue(fuchsia::ui::input::Command command);
-
- // Registers an acquire fence to be submitted during the subsequent call to
- // |Present()|.
- void EnqueueAcquireFence(zx::event fence);
-
- // Registers a release fence to be submitted during the subsequent call to
- // |Present()|.
- void EnqueueReleaseFence(zx::event fence);
-
- // Flushes queued operations to the session.
- void Flush();
-
- // Presents all previously enqueued operations.
- // Implicitly flushes all queued operations to the session.
- // Invokes the callback when the scene manager applies the presentation.
- void Present(uint64_t presentation_time, PresentCallback callback);
-
- // Performs a hit test along the specified ray.
- void HitTest(uint32_t node_id, const float ray_origin[3],
- const float ray_direction[3], HitTestCallback callback);
-
- // Performs a hit test along the specified ray into the engine's first
- // compositor.
- void HitTestDeviceRay(
- const float ray_origin[3], const float ray_direction[3],
- fuchsia::ui::scenic::Session::HitTestDeviceRayCallback callback);
-
- // Unbinds the internal SessionPtr; this allows moving this across threads.
- void Unbind();
-
- // Rebinds the Session interface internally; this must be called after a call
- // to Unbind().
- void Rebind();
-
- void SetDebugName(const std::string& debug_name);
-
- private:
- // |fuchsia::ui::scenic::SessionListener|
- void OnScenicError(fidl::StringPtr error) override;
- void OnScenicEvent(
- fidl::VectorPtr<fuchsia::ui::scenic::Event> events) override;
-
- fuchsia::ui::scenic::SessionPtr session_;
- // |session_handle_| is stored only when |session_| is unbound/invalid.
- fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session_handle_;
- uint32_t next_resource_id_ = 1u;
- uint32_t resource_count_ = 0u;
-
- fidl::VectorPtr<fuchsia::ui::scenic::Command> commands_;
- fidl::VectorPtr<zx::event> acquire_fences_;
- fidl::VectorPtr<zx::event> release_fences_;
-
- EventHandler event_handler_;
- fidl::Binding<fuchsia::ui::scenic::SessionListener> session_listener_binding_;
-};
-
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_CPP_SESSION_H_
diff --git a/pkg/scenic_cpp/meta.json b/pkg/scenic_cpp/meta.json
deleted file mode 100644
index 3c966c8..0000000
--- a/pkg/scenic_cpp/meta.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "deps": [
- "fidl_cpp",
- "images_cpp",
- "fit",
- "zx"
- ],
- "fidl_deps": [
- "fuchsia.ui.gfx",
- "fuchsia.ui.scenic"
- ],
- "headers": [
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/commands.h",
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_image_cycler.h",
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_memory.h",
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/id.h",
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h",
- "pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h"
- ],
- "include_dir": "pkg/scenic_cpp/include",
- "name": "scenic_cpp",
- "root": "pkg/scenic_cpp",
- "sources": [
- "pkg/scenic_cpp/commands.cc",
- "pkg/scenic_cpp/host_image_cycler.cc",
- "pkg/scenic_cpp/host_memory.cc",
- "pkg/scenic_cpp/resources.cc",
- "pkg/scenic_cpp/session.cc"
- ],
- "type": "cc_source_library"
-}
\ No newline at end of file
diff --git a/pkg/scenic_cpp/resources.cc b/pkg/scenic_cpp/resources.cc
deleted file mode 100644
index 58ab0d5..0000000
--- a/pkg/scenic_cpp/resources.cc
+++ /dev/null
@@ -1,570 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/ui/scenic/cpp/resources.h"
-
-#include <algorithm>
-
-#include "lib/images/cpp/images.h"
-#include "lib/ui/scenic/cpp/commands.h"
-
-namespace scenic {
-namespace {
-
-template <class T>
-constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
- return (v < lo) ? lo : (hi < v) ? hi : v;
-}
-
-} // namespace
-
-Resource::Resource(Session* session)
- : session_(session), id_(session->AllocResourceId()) {}
-
-Resource::Resource(Resource&& moved)
- : session_(moved.session_), id_(moved.id_) {
- auto& moved_session = *const_cast<Session**>(&moved.session_);
- auto& moved_id = *const_cast<uint32_t*>(&moved.id_);
- moved_session = nullptr;
- moved_id = 0;
-}
-
-Resource::~Resource() {
- // If this resource was moved, it is not responsible for releasing the ID.
- if (session_)
- session_->ReleaseResource(id_);
-}
-
-void Resource::Export(zx::eventpair export_token) {
- session_->Enqueue(NewExportResourceCmd(id(), std::move(export_token)));
-}
-
-void Resource::ExportAsRequest(zx::eventpair* out_import_token) {
- session_->Enqueue(NewExportResourceCmdAsRequest(id(), out_import_token));
-}
-
-void Resource::SetEventMask(uint32_t event_mask) {
- session_->Enqueue(NewSetEventMaskCmd(id(), event_mask));
-}
-
-void Resource::SetLabel(const std::string& label) {
- session_->Enqueue(NewSetLabelCmd(id(), label));
-}
-
-Shape::Shape(Session* session) : Resource(session) {}
-
-Shape::Shape(Shape&& moved) : Resource(std::move(moved)) {}
-
-Shape::~Shape() = default;
-
-Circle::Circle(Session* session, float radius) : Shape(session) {
- session->Enqueue(NewCreateCircleCmd(id(), radius));
-}
-
-Circle::Circle(Circle&& moved) : Shape(std::move(moved)) {}
-
-Circle::~Circle() = default;
-
-Rectangle::Rectangle(Session* session, float width, float height)
- : Shape(session) {
- session->Enqueue(NewCreateRectangleCmd(id(), width, height));
-}
-
-Rectangle::Rectangle(Rectangle&& moved) : Shape(std::move(moved)) {}
-
-Rectangle::~Rectangle() = default;
-
-RoundedRectangle::RoundedRectangle(Session* session, float width, float height,
- float top_left_radius,
- float top_right_radius,
- float bottom_right_radius,
- float bottom_left_radius)
- : Shape(session) {
- session->Enqueue(NewCreateRoundedRectangleCmd(
- id(), width, height, top_left_radius, top_right_radius,
- bottom_right_radius, bottom_left_radius));
-}
-
-RoundedRectangle::RoundedRectangle(RoundedRectangle&& moved)
- : Shape(std::move(moved)) {}
-
-RoundedRectangle::~RoundedRectangle() = default;
-
-Image::Image(const Memory& memory, off_t memory_offset,
- fuchsia::images::ImageInfo info)
- : Image(memory.session(), memory.id(), memory_offset, std::move(info)) {}
-
-Image::Image(Session* session, uint32_t memory_id, off_t memory_offset,
- fuchsia::images::ImageInfo info)
- : Resource(session), memory_offset_(memory_offset), info_(info) {
- session->Enqueue(
- NewCreateImageCmd(id(), memory_id, memory_offset_, std::move(info)));
-}
-
-Image::Image(Image&& moved)
- : Resource(std::move(moved)),
- memory_offset_(moved.memory_offset_),
- info_(moved.info_) {}
-
-Image::~Image() = default;
-
-size_t Image::ComputeSize(const fuchsia::images::ImageInfo& image_info) {
- return images::ImageSize(image_info);
-}
-
-Buffer::Buffer(const Memory& memory, off_t memory_offset, size_t num_bytes)
- : Buffer(memory.session(), memory.id(), memory_offset, num_bytes) {}
-
-Buffer::Buffer(Session* session, uint32_t memory_id, off_t memory_offset,
- size_t num_bytes)
- : Resource(session) {
- session->Enqueue(
- NewCreateBufferCmd(id(), memory_id, memory_offset, num_bytes));
-}
-
-Buffer::Buffer(Buffer&& moved) : Resource(std::move(moved)) {}
-
-Buffer::~Buffer() = default;
-
-Memory::Memory(Session* session, zx::vmo vmo, uint64_t allocation_size,
- fuchsia::images::MemoryType memory_type)
- : Resource(session), memory_type_(memory_type) {
- session->Enqueue(
- NewCreateMemoryCmd(id(), std::move(vmo), allocation_size, memory_type));
-}
-
-Memory::Memory(Memory&& moved)
- : Resource(std::move(moved)), memory_type_(moved.memory_type_) {}
-
-Memory::~Memory() = default;
-
-Mesh::Mesh(Session* session) : Shape(session) {
- session->Enqueue(NewCreateMeshCmd(id()));
-}
-
-Mesh::Mesh(Mesh&& moved) : Shape(std::move(moved)) {}
-
-Mesh::~Mesh() = default;
-
-void Mesh::BindBuffers(const Buffer& index_buffer,
- fuchsia::ui::gfx::MeshIndexFormat index_format,
- uint64_t index_offset, uint32_t index_count,
- const Buffer& vertex_buffer,
- fuchsia::ui::gfx::MeshVertexFormat vertex_format,
- uint64_t vertex_offset, uint32_t vertex_count,
- const float bounding_box_min[3],
- const float bounding_box_max[3]) {
- ZX_DEBUG_ASSERT(session() == index_buffer.session() &&
- session() == vertex_buffer.session());
- session()->Enqueue(NewBindMeshBuffersCmd(
- id(), index_buffer.id(), index_format, index_offset, index_count,
- vertex_buffer.id(), std::move(vertex_format), vertex_offset, vertex_count,
- bounding_box_min, bounding_box_max));
-}
-
-Material::Material(Session* session) : Resource(session) {
- session->Enqueue(NewCreateMaterialCmd(id()));
-}
-
-Material::Material(Material&& moved) : Resource(std::move(moved)) {}
-
-Material::~Material() = default;
-
-void Material::SetTexture(uint32_t image_id) {
- session()->Enqueue(NewSetTextureCmd(id(), image_id));
-}
-
-void Material::SetColor(uint8_t red, uint8_t green, uint8_t blue,
- uint8_t alpha) {
- session()->Enqueue(NewSetColorCmd(id(), red, green, blue, alpha));
-}
-
-Node::Node(Session* session) : Resource(session) {}
-
-Node::Node(Node&& moved) : Resource(std::move(moved)) {}
-
-Node::~Node() = default;
-
-void Node::SetTranslation(const float translation[3]) {
- session()->Enqueue(NewSetTranslationCmd(id(), translation));
-}
-
-void Node::SetTranslation(uint32_t variable_id) {
- session()->Enqueue(NewSetTranslationCmd(id(), variable_id));
-}
-
-void Node::SetScale(const float scale[3]) {
- session()->Enqueue(NewSetScaleCmd(id(), scale));
-}
-
-void Node::SetScale(uint32_t variable_id) {
- session()->Enqueue(NewSetScaleCmd(id(), variable_id));
-}
-
-void Node::SetRotation(const float quaternion[4]) {
- session()->Enqueue(NewSetRotationCmd(id(), quaternion));
-}
-
-void Node::SetRotation(uint32_t variable_id) {
- session()->Enqueue(NewSetRotationCmd(id(), variable_id));
-}
-
-void Node::SetAnchor(const float anchor[3]) {
- session()->Enqueue(NewSetAnchorCmd(id(), anchor));
-}
-
-void Node::SetAnchor(uint32_t variable_id) {
- session()->Enqueue(NewSetAnchorCmd(id(), variable_id));
-}
-
-void Node::SendSizeChangeHint(float width_change_factor,
- float height_change_factor) {
- session()->Enqueue(NewSendSizeChangeHintCmdHACK(id(), width_change_factor,
- height_change_factor));
-}
-
-void Node::SetTag(uint32_t tag_value) {
- session()->Enqueue(NewSetTagCmd(id(), tag_value));
-}
-
-void Node::SetHitTestBehavior(
- fuchsia::ui::gfx::HitTestBehavior hit_test_behavior) {
- session()->Enqueue(NewSetHitTestBehaviorCmd(id(), hit_test_behavior));
-}
-
-void Node::Detach() { session()->Enqueue(NewDetachCmd(id())); }
-
-ShapeNode::ShapeNode(Session* session) : Node(session) {
- session->Enqueue(NewCreateShapeNodeCmd(id()));
-}
-
-ShapeNode::ShapeNode(ShapeNode&& moved) : Node(std::move(moved)) {}
-
-ShapeNode::~ShapeNode() = default;
-
-void ShapeNode::SetShape(uint32_t shape_id) {
- session()->Enqueue(NewSetShapeCmd(id(), shape_id));
-}
-
-void ShapeNode::SetMaterial(uint32_t material_id) {
- session()->Enqueue(NewSetMaterialCmd(id(), material_id));
-}
-
-ContainerNode::ContainerNode(Session* session) : Node(session) {}
-
-ContainerNode::ContainerNode(ContainerNode&& moved) : Node(std::move(moved)) {}
-
-ContainerNode::~ContainerNode() = default;
-
-void ContainerNode::AddChild(uint32_t child_node_id) {
- session()->Enqueue(NewAddChildCmd(id(), child_node_id));
-}
-
-void ContainerNode::AddPart(uint32_t part_node_id) {
- session()->Enqueue(NewAddPartCmd(id(), part_node_id));
-}
-
-void ContainerNode::DetachChildren() {
- session()->Enqueue(NewDetachChildrenCmd(id()));
-}
-
-EntityNode::EntityNode(Session* session) : ContainerNode(session) {
- session->Enqueue(NewCreateEntityNodeCmd(id()));
-}
-
-void EntityNode::Attach(const ViewHolder& view_holder) {
- session()->Enqueue(NewAddChildCmd(id(), view_holder.id()));
-}
-
-void EntityNode::Snapshot(fuchsia::ui::gfx::SnapshotCallbackHACKPtr callback) {
- session()->Enqueue(NewTakeSnapshotCmdHACK(id(), std::move(callback)));
-}
-
-EntityNode::~EntityNode() = default;
-
-void EntityNode::SetClip(uint32_t clip_id, bool clip_to_self) {
- session()->Enqueue(NewSetClipCmd(id(), clip_id, clip_to_self));
-}
-
-ImportNode::ImportNode(Session* session) : ContainerNode(session) {}
-
-ImportNode::ImportNode(ImportNode&& moved) : ContainerNode(std::move(moved)) {}
-
-ImportNode::~ImportNode() {
- ZX_DEBUG_ASSERT_MSG(is_bound_, "Import was never bound.");
-}
-
-void ImportNode::Bind(zx::eventpair import_token) {
- ZX_DEBUG_ASSERT(!is_bound_);
- session()->Enqueue(NewImportResourceCmd(
- id(), fuchsia::ui::gfx::ImportSpec::NODE, std::move(import_token)));
- is_bound_ = true;
-}
-
-void ImportNode::BindAsRequest(zx::eventpair* out_export_token) {
- ZX_DEBUG_ASSERT(!is_bound_);
- session()->Enqueue(NewImportResourceCmdAsRequest(
- id(), fuchsia::ui::gfx::ImportSpec::NODE, out_export_token));
- is_bound_ = true;
-}
-
-ViewHolder::ViewHolder(Session* session, zx::eventpair token,
- const std::string& debug_name)
- : Resource(session) {
- session->Enqueue(NewCreateViewHolderCmd(id(), std::move(token), debug_name));
-}
-
-ViewHolder::~ViewHolder() = default;
-
-void ViewHolder::SetViewProperties(const float bounding_box_min[3],
- const float bounding_box_max[3],
- const float inset_from_min[3],
- const float inset_from_max[3]) {
- session()->Enqueue(NewSetViewPropertiesCmd(id(), bounding_box_min,
- bounding_box_max, inset_from_min,
- inset_from_max));
-}
-
-void ViewHolder::SetViewProperties(
- const fuchsia::ui::gfx::ViewProperties& props) {
- session()->Enqueue(NewSetViewPropertiesCmd(id(), props));
-}
-
-View::View(Session* session, zx::eventpair token, const std::string& debug_name)
- : Resource(session) {
- session->Enqueue(NewCreateViewCmd(id(), std::move(token), debug_name));
-}
-
-View::~View() = default;
-
-void View::AddChild(const Node& child) const {
- ZX_DEBUG_ASSERT(session() == child.session());
- session()->Enqueue(NewAddChildCmd(id(), child.id()));
-}
-
-void View::DetachChild(const Node& child) const {
- ZX_DEBUG_ASSERT(session() == child.session());
- session()->Enqueue(NewDetachCmd(child.id()));
-}
-
-ClipNode::ClipNode(Session* session) : ContainerNode(session) {
- session->Enqueue(NewCreateClipNodeCmd(id()));
-}
-
-ClipNode::ClipNode(ClipNode&& moved) : ContainerNode(std::move(moved)) {}
-
-ClipNode::~ClipNode() = default;
-
-OpacityNode::OpacityNode(Session* session) : ContainerNode(session) {
- session->Enqueue(NewCreateOpacityNodeCmd(id()));
-}
-
-OpacityNode::OpacityNode(OpacityNode&& moved)
- : ContainerNode(std::move(moved)) {}
-
-OpacityNode::~OpacityNode() = default;
-
-void OpacityNode::SetOpacity(float opacity) {
- opacity = clamp(opacity, 0.f, 1.f);
- session()->Enqueue(NewSetOpacityCmd(id(), opacity));
-}
-
-Variable::Variable(Session* session, fuchsia::ui::gfx::Value initial_value)
- : Resource(session) {
- session->Enqueue(NewCreateVariableCmd(id(), std::move(initial_value)));
-}
-
-Variable::Variable(Variable&& moved) : Resource(std::move(moved)) {}
-
-Variable::~Variable() = default;
-
-Scene::Scene(Session* session) : ContainerNode(session) {
- session->Enqueue(NewCreateSceneCmd(id()));
-}
-
-Scene::Scene(Scene&& moved) : ContainerNode(std::move(moved)) {}
-
-Scene::~Scene() = default;
-
-void Scene::AddLight(uint32_t light_id) {
- session()->Enqueue(NewAddLightCmd(id(), light_id));
-}
-
-void Scene::DetachLights() { session()->Enqueue(NewDetachLightsCmd(id())); }
-
-void CameraBase::SetTransform(const float eye_position[3],
- const float eye_look_at[3],
- const float eye_up[3]) {
- session()->Enqueue(
- NewSetCameraTransformCmd(id(), eye_position, eye_look_at, eye_up));
-}
-
-void CameraBase::SetPoseBuffer(const Buffer& buffer, uint32_t num_entries,
- int64_t base_time, uint64_t time_interval) {
- session()->Enqueue(NewSetCameraPoseBufferCmd(id(), buffer.id(), num_entries,
- base_time, time_interval));
-}
-
-Camera::Camera(const Scene& scene) : Camera(scene.session(), scene.id()) {}
-
-Camera::Camera(Session* session, uint32_t scene_id) : CameraBase(session) {
- session->Enqueue(NewCreateCameraCmd(id(), scene_id));
-}
-
-Camera::Camera(Camera&& moved) : CameraBase(std::move(moved)) {}
-
-Camera::~Camera() = default;
-
-void Camera::SetProjection(const float fovy) {
- session()->Enqueue(NewSetCameraProjectionCmd(id(), fovy));
-}
-
-StereoCamera::StereoCamera(const Scene& scene)
- : StereoCamera(scene.session(), scene.id()) {}
-
-StereoCamera::StereoCamera(Session* session, uint32_t scene_id)
- : CameraBase(session) {
- session->Enqueue(NewCreateStereoCameraCmd(id(), scene_id));
-}
-
-StereoCamera::StereoCamera(StereoCamera&& moved)
- : CameraBase(std::move(moved)) {}
-
-StereoCamera::~StereoCamera() = default;
-
-void StereoCamera::SetStereoProjection(const float left_projection[16],
- const float right_projection[16]) {
- session()->Enqueue(
- NewSetStereoCameraProjectionCmd(id(), left_projection, right_projection));
-}
-
-Renderer::Renderer(Session* session) : Resource(session) {
- session->Enqueue(NewCreateRendererCmd(id()));
-}
-
-Renderer::Renderer(Renderer&& moved) : Resource(std::move(moved)) {}
-
-Renderer::~Renderer() = default;
-
-void Renderer::SetCamera(uint32_t camera_id) {
- session()->Enqueue(NewSetCameraCmd(id(), camera_id));
-}
-
-void Renderer::SetParam(fuchsia::ui::gfx::RendererParam param) {
- session()->Enqueue(NewSetRendererParamCmd(id(), std::move(param)));
-}
-
-void Renderer::SetShadowTechnique(fuchsia::ui::gfx::ShadowTechnique technique) {
- auto param = fuchsia::ui::gfx::RendererParam();
- param.set_shadow_technique(technique);
- SetParam(std::move(param));
-}
-
-void Renderer::SetDisableClipping(bool disable_clipping) {
- session()->Enqueue(NewSetDisableClippingCmd(id(), disable_clipping));
-}
-
-Layer::Layer(Session* session) : Resource(session) {
- session->Enqueue(NewCreateLayerCmd(id()));
-}
-
-Layer::Layer(Layer&& moved) : Resource(std::move(moved)) {}
-
-Layer::~Layer() = default;
-
-void Layer::SetRenderer(uint32_t renderer_id) {
- session()->Enqueue(NewSetRendererCmd(id(), renderer_id));
-}
-
-void Layer::SetSize(const float size[2]) {
- session()->Enqueue(NewSetSizeCmd(id(), size));
-}
-
-LayerStack::LayerStack(Session* session) : Resource(session) {
- session->Enqueue(NewCreateLayerStackCmd(id()));
-}
-
-LayerStack::LayerStack(LayerStack&& moved) : Resource(std::move(moved)) {}
-
-LayerStack::~LayerStack() = default;
-
-void LayerStack::AddLayer(uint32_t layer_id) {
- session()->Enqueue(NewAddLayerCmd(id(), layer_id));
-}
-
-void LayerStack::RemoveLayer(uint32_t layer_id) {
- session()->Enqueue(NewRemoveLayerCmd(id(), layer_id));
-}
-
-void LayerStack::RemoveAllLayers() {
- session()->Enqueue(NewRemoveAllLayersCmd(id()));
-}
-
-DisplayCompositor::DisplayCompositor(Session* session) : Resource(session) {
- session->Enqueue(NewCreateDisplayCompositorCmd(id()));
-}
-
-DisplayCompositor::DisplayCompositor(DisplayCompositor&& moved)
- : Resource(std::move(moved)) {}
-
-DisplayCompositor::~DisplayCompositor() = default;
-
-void DisplayCompositor::SetLayerStack(uint32_t layer_stack_id) {
- session()->Enqueue(NewSetLayerStackCmd(id(), layer_stack_id));
-}
-
-Compositor::Compositor(Session* session) : Resource(session) {
- session->Enqueue(NewCreateCompositorCmd(id()));
-}
-
-Compositor::Compositor(Compositor&& moved) : Resource(std::move(moved)) {}
-
-Compositor::~Compositor() = default;
-
-void Compositor::SetLayerStack(uint32_t layer_stack_id) {
- session()->Enqueue(NewSetLayerStackCmd(id(), layer_stack_id));
-}
-
-Light::Light(Session* session) : Resource(session) {}
-
-Light::Light(Light&& moved) : Resource(std::move(moved)) {}
-
-Light::~Light() = default;
-
-void Light::SetColor(const float rgb[3]) {
- session()->Enqueue(NewSetLightColorCmd(id(), rgb));
-}
-
-void Light::SetColor(uint32_t variable_id) {
- session()->Enqueue(NewSetLightColorCmd(id(), variable_id));
-}
-
-void Light::Detach() { session()->Enqueue(NewDetachLightCmd(id())); }
-
-AmbientLight::AmbientLight(Session* session) : Light(session) {
- session->Enqueue(NewCreateAmbientLightCmd(id()));
-}
-
-AmbientLight::AmbientLight(AmbientLight&& moved) : Light(std::move(moved)) {}
-
-AmbientLight::~AmbientLight() = default;
-
-DirectionalLight::DirectionalLight(Session* session) : Light(session) {
- session->Enqueue(NewCreateDirectionalLightCmd(id()));
-}
-
-DirectionalLight::DirectionalLight(DirectionalLight&& moved)
- : Light(std::move(moved)) {}
-
-DirectionalLight::~DirectionalLight() = default;
-
-void DirectionalLight::SetDirection(const float direction[3]) {
- session()->Enqueue(NewSetLightDirectionCmd(id(), direction));
-}
-
-void DirectionalLight::SetDirection(uint32_t variable_id) {
- session()->Enqueue(NewSetLightDirectionCmd(id(), variable_id));
-}
-
-} // namespace scenic
diff --git a/pkg/scenic_cpp/session.cc b/pkg/scenic_cpp/session.cc
deleted file mode 100644
index 7f48da9..0000000
--- a/pkg/scenic_cpp/session.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "lib/ui/scenic/cpp/session.h"
-
-#include <stdio.h>
-#include <zircon/assert.h>
-
-#include "lib/ui/scenic/cpp/commands.h"
-
-namespace scenic {
-
-constexpr size_t kCommandsPerMessage =
- (ZX_CHANNEL_MAX_MSG_BYTES - sizeof(fidl_message_header_t) -
- sizeof(fidl_vector_t)) /
- sizeof(fuchsia::ui::scenic::Command);
-
-SessionPtrAndListenerRequest CreateScenicSessionPtrAndListenerRequest(
- fuchsia::ui::scenic::Scenic* scenic) {
- fuchsia::ui::scenic::SessionPtr session;
- fidl::InterfaceHandle<fuchsia::ui::scenic::SessionListener> listener_handle;
- auto listener_request = listener_handle.NewRequest();
-
- scenic->CreateSession(session.NewRequest(), listener_handle.Bind());
-
- return {std::move(session), std::move(listener_request)};
-}
-
-Session::Session(fuchsia::ui::scenic::SessionPtr session,
- fidl::InterfaceRequest<fuchsia::ui::scenic::SessionListener>
- session_listener)
- : session_(std::move(session)), session_listener_binding_(this) {
- ZX_DEBUG_ASSERT(session_);
- if (session_listener.is_valid())
- session_listener_binding_.Bind(std::move(session_listener));
-}
-
-Session::Session(fuchsia::ui::scenic::Scenic* scenic)
- : session_listener_binding_(this) {
- ZX_DEBUG_ASSERT(scenic);
- scenic->CreateSession(session_.NewRequest(),
- session_listener_binding_.NewBinding());
-}
-
-Session::Session(SessionPtrAndListenerRequest session_and_listener)
- : Session(std::move(session_and_listener.first),
- std::move(session_and_listener.second)) {}
-
-Session::~Session() {
- ZX_DEBUG_ASSERT_MSG(resource_count_ == 0,
- "Some resources outlived the session: %u",
- resource_count_);
-}
-
-uint32_t Session::AllocResourceId() {
- uint32_t resource_id = next_resource_id_++;
- ZX_DEBUG_ASSERT(resource_id);
- resource_count_++;
- return resource_id;
-}
-
-void Session::ReleaseResource(uint32_t resource_id) {
- resource_count_--;
- Enqueue(NewReleaseResourceCmd(resource_id));
-}
-
-void Session::Enqueue(fuchsia::ui::gfx::Command command) {
- Enqueue(NewCommand(std::move(command)));
-}
-
-void Session::Enqueue(fuchsia::ui::input::Command command) {
- Enqueue(NewCommand(std::move(command)));
-}
-
-void Session::Enqueue(fuchsia::ui::scenic::Command command) {
- commands_.push_back(std::move(command));
- if (commands_->size() >= kCommandsPerMessage ||
- command.Which() == fuchsia::ui::scenic::Command::Tag::kInput) {
- Flush();
- }
-}
-
-void Session::EnqueueAcquireFence(zx::event fence) {
- ZX_DEBUG_ASSERT(fence);
- acquire_fences_.push_back(std::move(fence));
-}
-
-void Session::EnqueueReleaseFence(zx::event fence) {
- ZX_DEBUG_ASSERT(fence);
- release_fences_.push_back(std::move(fence));
-}
-
-void Session::Flush() {
- ZX_DEBUG_ASSERT(session_);
- if (!commands_->empty()) {
- ZX_DEBUG_ASSERT(static_cast<bool>(commands_));
- session_->Enqueue(std::move(commands_));
-
- // After being moved, |commands_| is in a "valid but unspecified state";
- // see http://en.cppreference.com/w/cpp/utility/move. Calling reset() makes
- // it safe to continue using.
- commands_.reset();
- }
-}
-
-void Session::Present(uint64_t presentation_time, PresentCallback callback) {
- ZX_DEBUG_ASSERT(session_);
- Flush();
-
- if (acquire_fences_.is_null())
- acquire_fences_.resize(0u);
- if (release_fences_.is_null())
- release_fences_.resize(0u);
- session_->Present(presentation_time, std::move(acquire_fences_),
- std::move(release_fences_), std::move(callback));
-}
-
-void Session::HitTest(uint32_t node_id, const float ray_origin[3],
- const float ray_direction[3], HitTestCallback callback) {
- ZX_DEBUG_ASSERT(session_);
- fuchsia::ui::gfx::vec3 ray_origin_vec;
- ray_origin_vec.x = ray_origin[0];
- ray_origin_vec.y = ray_origin[1];
- ray_origin_vec.z = ray_origin[2];
-
- fuchsia::ui::gfx::vec3 ray_direction_vec;
- ray_direction_vec.x = ray_direction[0];
- ray_direction_vec.y = ray_direction[1];
- ray_direction_vec.z = ray_direction[2];
-
- session_->HitTest(node_id, std::move(ray_origin_vec),
- std::move(ray_direction_vec), std::move(callback));
-}
-
-void Session::HitTestDeviceRay(
- const float ray_origin[3], const float ray_direction[3],
- fuchsia::ui::scenic::Session::HitTestDeviceRayCallback callback) {
- ZX_DEBUG_ASSERT(session_);
- fuchsia::ui::gfx::vec3 ray_origin_vec;
- ray_origin_vec.x = ray_origin[0];
- ray_origin_vec.y = ray_origin[1];
- ray_origin_vec.z = ray_origin[2];
-
- fuchsia::ui::gfx::vec3 ray_direction_vec;
- ray_direction_vec.x = ray_direction[0];
- ray_direction_vec.y = ray_direction[1];
- ray_direction_vec.z = ray_direction[2];
-
- session_->HitTestDeviceRay(std::move(ray_origin_vec),
- std::move(ray_direction_vec), std::move(callback));
-}
-
-void Session::Unbind() {
- ZX_DEBUG_ASSERT(session_);
- ZX_DEBUG_ASSERT(!session_handle_);
- session_handle_ = session_.Unbind();
- session_ = nullptr;
-}
-
-void Session::Rebind() {
- ZX_DEBUG_ASSERT(!session_);
- ZX_DEBUG_ASSERT(session_handle_);
- session_ = fuchsia::ui::scenic::SessionPtr(session_handle_.Bind());
- session_handle_ = nullptr;
-}
-
-void Session::OnScenicError(fidl::StringPtr error) {
- // TODO(SCN-903): replace fprintf with SDK-approved logging mechanism. Also
- // remove "#include <stdio.h>".
- fprintf(stderr, "Session error: %s", error->c_str());
-}
-
-void Session::OnScenicEvent(
- fidl::VectorPtr<fuchsia::ui::scenic::Event> events) {
- if (event_handler_)
- event_handler_(std::move(events));
-}
-
-void Session::SetDebugName(const std::string& debug_name) {
- session_->SetDebugName(debug_name);
-}
-
-} // namespace scenic
diff --git a/pkg/svc/include/lib/svc/dir.h b/pkg/svc/include/lib/svc/dir.h
deleted file mode 100644
index 8e16c97..0000000
--- a/pkg/svc/include/lib/svc/dir.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_SVC_SVC_H_
-#define LIB_SVC_SVC_H_
-
-#include <lib/async/dispatcher.h>
-#include <zircon/compiler.h>
-#include <zircon/types.h>
-
-__BEGIN_CDECLS
-
-typedef void(svc_connector_t)(void* context, const char* service_name,
- zx_handle_t service_request);
-
-typedef struct svc_dir svc_dir_t;
-
-__EXPORT zx_status_t svc_dir_create(async_dispatcher_t* dispatcher,
- zx_handle_t directory_request,
- svc_dir_t** out_result);
-
-// Adds a service named |service_name| to the given |dir|.
-//
-// If |type| is non-NULL, the service will be published in a directory whose
-// name matches the |type|. If |type| is NULL, the service will be published in
-// the root directory.
-//
-// The most commonly used values for |type| are "public", "debug", and "ctrl".
-// Services published under "public" are made available to clients via
-// |fuchsia.sys.Lancher#CreateComponent|. The "debug" serivices are exposed via
-// the hub. The "ctrl" services are used by the core platform to communicate
-// with your program.
-//
-// When a client requests the service, |handler| will be called on the async_t
-// passed to |svc_dir_create|. The |context| will be passed to |handler| as its
-// first argument.
-//
-// This may fail in two ways. If an entry with the given
-// |service_name| already exists, this returns
-// ZX_ERR_ALREADY_EXISTS. If the provided |service_name| is invalid,
-// ZX_ERR_INVALID_ARGS is returned. Otherwise, this returns ZX_OK.
-__EXPORT zx_status_t svc_dir_add_service(svc_dir_t* dir, const char* type,
- const char* service_name,
- void* context,
- svc_connector_t* handler);
-
-// Removes the service named |service_name| of type |type| from the
-// given |dir|. This reports a failure if the entry does not exist, by
-// returning ZX_ERR_NOT_FOUND. Otherwise, the service entry is
-// removed, and ZX_OK is returned.
-__EXPORT zx_status_t svc_dir_remove_service(svc_dir_t* dir, const char* type,
- const char* service_name);
-
-// Destroy the provided directory. This currently cannot fail, and
-// returns ZX_OK.
-__EXPORT zx_status_t svc_dir_destroy(svc_dir_t* dir);
-
-__END_CDECLS
-
-#endif // LIB_SVC_SVC_H_
diff --git a/pkg/svc/meta.json b/pkg/svc/meta.json
deleted file mode 100644
index 2a183d5..0000000
--- a/pkg/svc/meta.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/28/16547647b2a89d.debug",
- "dist": "arch/arm64/dist/libsvc.so",
- "link": "arch/arm64/lib/libsvc.so"
- },
- "x64": {
- "debug": ".build-id/31/f3907157249ab0.debug",
- "dist": "arch/x64/dist/libsvc.so",
- "link": "arch/x64/lib/libsvc.so"
- }
- },
- "deps": [
- "async",
- "fdio",
- "trace-engine"
- ],
- "format": "shared",
- "headers": [
- "pkg/svc/include/lib/svc/dir.h"
- ],
- "include_dir": "pkg/svc/include",
- "name": "svc",
- "root": "pkg/svc",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/sync/include/lib/sync/completion.h b/pkg/sync/include/lib/sync/completion.h
index 515a563..51af5c0 100644
--- a/pkg/sync/include/lib/sync/completion.h
+++ b/pkg/sync/include/lib/sync/completion.h
@@ -8,14 +8,224 @@
#include <zircon/compiler.h>
#include <zircon/types.h>
+////////////////////////////////////////////////////////////////////////////////
+//
+// sync_completion_t
+//
+// :: Overview ::
+//
+// sync_completion_t objects (henceforth, simply "completions") are lightweight
+// in-process events. Conceptually, a completion has an internal state of either
+// UNSIGNALED or SIGNALED. Threads in a process may alter this state, check the
+// state without blocking, or wait on the completion with an optional
+// timeout/deadline until it achieves the SIGNALED state. Completions are
+// currently implemented using Zircon futexes.
+//
+// :: Initialization ::
+//
+// Completions always start in the UNSIGNALED state. When used in C code, users
+// *must* explicitly initialize their completion's state using the
+// SYNC_COMPLETION_INIT preprocessor symbol. For example:
+//
+// ```
+// struct my_structure {
+// int32_t a_variable;
+// sync_completion_t a_completion;
+// };
+//
+// void init_my_structure(struct my_structure* s) {
+// s->a_variable = 0;
+// s->a_completion = SYNC_COMPLETION_INIT;
+// }
+// ```
+//
+// When used in C++ code, no explicit initialization steps are required. The
+// completion's structure will contain a default constructor which properly
+// initializes the completion's UNSIGNALED state.
+//
+// :: Operations ::
+//
+// The permitted operations on a completion are as follows.
+//
+// ++ sync_completion_wait ++
+// Block a thread with an optional relative timeout until the completion
+// achieves the signaled state. If the completion is already in the SIGNALED
+// state, the waiting thread will not block.
+//
+// ++ sync_completion_wait_deadline ++
+// Block a thread with an optional absolute deadline timeout until the
+// completion achieves the signaled state. If the completion is already in the
+// SIGNALED state, the waiting thread will not block.
+//
+// ++ sync_completion_signal ++
+// Change the internal state of a completion to SIGNALED, releasing any threads
+// which are currently waiting on it.
+//
+// ++ sync_completion_reset ++
+// Change the internal state of a completion to UNSIGNALED. See also `Avoid
+// "Strobing" Signals` (below) for some hazards related to the use of the reset
+// operation.
+//
+// ++ sync_completion_signaled ++
+// Observe the internal state of a completion, and return true if it is
+// SIGNALED, and false otherwise.
+//
+// :: No Spurious Wakeups ::
+//
+// sync_completion_wait() will *only* return:
+// ++ if the completion is signaled at some point by a call to
+// sync_completion_signal() (either before or after the call to
+// sync_completion_wait())
+// ++ or if the timeout occurs (if using timeouts)
+//
+// Implementation details:
+//
+// In general, futex-based concurrency algorithms can cause futex wakeups on
+// memory locations that have been deallocated (for example, the standard
+// algorithm for a mutex_unlock can do that). This means that futex-based
+// concurrency algorithms must be robust against spurious wakeups, because a
+// futex memory location may have been previously used, deallocated, and then
+// recycled.
+//
+// Completions guarantee that waiters will not suffer any spurious wakeups,
+// provided that the lifetime of the sync_completion_t instance is properly
+// respected. For example, pretend we have the following situation.
+//
+// ```
+// void thread_a() {
+// sync_completion_t C = SYNC_COMPLETION_INIT;
+// share_completion_with_thread_b(&C);
+// sync_completion_wait(&C, ZX_TIME_INFINITE);
+// }
+//
+// void thread_b() {
+// sync_completion_t* C = obtain_completion_from_thread_a();
+// sync_completion_signal(C);
+// }
+// ```
+//
+// The call to sync_completion_wait is guaranteed to not wake up spuriously,
+// even if an unrelated zx_futex_wake operation targeting the same memory
+// location happens to occur during the interactions between thread_a and
+// thread_b. This behavior **depends** on making sure that the life-cycle of C
+// is properly obeyed. After thread_b does sync_completion_signal(C), it must
+// not perform any further operations on C. Having signaled C, thread_b has
+// caused thread_a to unblock and begin the process of deallocating C. Any
+// operations performed on C after this point are racing with the deallocation
+// of C and might result in a use-after-free situation. While it is possible
+// that thread_b may still be in the call to sync_completion_signal when
+// thread_a unwinds and deallocates the completion, no reads or writes from or to
+// the completion's state will be made after this point, and the code is safe
+// provided that this is the final completion operation.
+//
+// :: Avoid "Strobing" Signals ::
+//
+// Users should avoid the pattern of "strobing" a signal operation.
+// Specifically, calling sync_completion_signal(C) immediately followed by
+// sync_completion_reset(C) is not guaranteed to wake up a waiter, even if the
+// user could prove that the waiter is waiting in the completion.
+//
+// Implementation details:
+//
+// The following is an example of a sequence which makes use of the strobe
+// pattern which can lead a missed event. It is based on specific details of
+// how sync_completion_t is implemented today, and should not be considered to
+// be the only way that a signal might end up getting missed, either now or in
+// the future. Again, user should always avoid this "strobing" pattern, it is
+// not guaranteed to wake a waiter.
+//
+// ```
+// global sync_completion_t C;
+//
+// Thread A:
+// 1) Wait on C with no timeout.
+// 2) Declare victory
+//
+// Thread B:
+// 1) Wait until thread A is blocked on completion C by polling Thread A's state
+// via zx_object_get_info.
+// 2) sync_completion_signal(C)
+// 3) sync_completion_reset(C)
+// 4) sync_completion_wait(C, timeout)
+// ```
+//
+// Step B.1 establishes the fact that (from thread B's perspective) thread A
+// managed to observe C in the UNSIGNALED state and join the internal futex wait
+// queue used to implement the completion_t. In the process, thread A sets the
+// completion_t's internal state to UNSIGNALED_WITH_WAITERS. The subsequent
+// signal/reset/wait operations (steps B.2-B.4), will release thread A from the
+// wait queue, but cycle the internal state of the completion_t through the
+// SIGNALED and UNSIGNALED states, and back again to the UNSIGNALED_WITH_WAITERS
+// state. If thread B manages to cycle the state all of the way back around to
+// UNSIGNALED_WITH_WAITERS before thread A manages to wake up, thread A will see
+// the state as UNSIGNALED_WITH_WAITERS and rejoin the wait queue thinking that
+// it had been woken by a spurious futex_wake.
+//
+// Once again, as a general rule the signal/reset pattern shown here should not
+// be used with sync_completion_t objects. It is considered to be racy and can
+// result in undesired behavior, no matter what steps are taken establish that A
+// is waiting before the signal/reset operations take place.
+//
+// :: Memory Ordering Semantics ::
+//
+// When a thread transitions the state of a completion from UNSIGNALED to
+// SIGNALED by calling sync_completion_signal, the operation provides the same
+// guarantees as an atomic modification of the completion state with Release
+// semantics. These guarantees do _not_ hold if the completion is already in
+// the SIGNALED state when the thread calls sync_completion_signal.
+//
+// When a thread returns from a sync_completion_wait operation with a status of
+// ZX_OK, the operation provides the same guarantees as having atomically
+// observed the completion state as being SIGNALED with Acquire semantics.
+// These guarantees do _not_ hold if the wait operation times out, or returns
+// any other error.
+//
+// The effects of these guarantees are that write operations to shared memory
+// performed by a thread may not be reordered beyond a signal operation which
+// successfully transitions a completion from UNSIGNALED to SIGNALED performed
+// by the same thread. Likewise, successful wait operations performed by a
+// thread against a completion guarantee that subsequent read operations
+// performed by that thread may not be reordered before the wait operation.
+//
+// Taken together, these guarantees make the following common pattern safe.
+//
+// ```
+// typedef struct {
+// uint32_t val;
+// sync_completion_t C;
+// } read_operation_t;
+//
+// void thread_a() {
+// read_operation_t Op;
+// Op.C = SYNC_COMPLETION_INIT;
+//
+// send_op_to_thread_b(&Op);
+// sync_completion_wait(&Op.C);
+// do_great_things_with_val(Op.val);
+// }
+//
+// void thread_b() {
+// while (true) {
+// read_operation_t* Op = obtain_read_op();
+// Op->val = compute_a_value_only_thread_b_can_compute();
+// sync_completion_signal(&Op->C);
+// }
+// }
+// ```
+//
+// Thread A is guaranteed to see the results written by thread B into the shared
+// Op.val member. The modifications performed by thread B may not be reordered
+// past the signal operation, and read operations performed by thread A may not
+// be moved before the wait operation.
+//
+
__BEGIN_CDECLS
typedef struct sync_completion {
- zx_futex_t futex;
+ zx_futex_t futex;
#ifdef __cplusplus
- sync_completion()
- : futex(0) {}
+ sync_completion() : futex(0) {}
#endif
} sync_completion_t;
@@ -38,18 +248,25 @@
// completion will also see the signal and immediately return.
void sync_completion_signal(sync_completion_t* completion);
-// Marks the completion as signaled, but doesn't awaken all waiters
-// right away. Instead, all waiters are requeued to the |futex|.
-// Waits after this call but before a reset of the
-// completion will also see the signal and immediately return.
+// Marks the completion as signaled, but doesn't awaken all waiters right away.
+// Instead, all waiters are requeued to the |requeue_target|, and the owner of
+// the |requeue_target| is set to |requeue_target_owner|, or to no one if
+// ZX_HANDLE_INVALID is passed.
+//
+// Waits after this call but before a reset of the completion will also see the
+// signal and immediately return.
//
// Intended to be used by libsync internally, e.g. the condition variable
// implementation.
-void sync_completion_signal_requeue(sync_completion_t* completion, zx_futex_t* futex);
+void sync_completion_signal_requeue(sync_completion_t* completion, zx_futex_t* requeue_target,
+ zx_handle_t requeue_target_owner);
// Resets the completion's signaled state to unsignaled.
void sync_completion_reset(sync_completion_t* completion);
+// Returns true iff a completion has been signaled.
+bool sync_completion_signaled(sync_completion_t* completion);
+
__END_CDECLS
-#endif // LIB_SYNC_COMPLETION_H_
+#endif // LIB_SYNC_COMPLETION_H_
diff --git a/pkg/sync/include/lib/sync/condition.h b/pkg/sync/include/lib/sync/condition.h
index 6f6eb58..27e5457 100644
--- a/pkg/sync/include/lib/sync/condition.h
+++ b/pkg/sync/include/lib/sync/condition.h
@@ -5,6 +5,7 @@
#ifndef LIB_SYNC_CONDITION_H_
#define LIB_SYNC_CONDITION_H_
+#include <assert.h>
#include <lib/sync/mutex.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
@@ -13,29 +14,31 @@
// A condition variable that works with a sync_mutex_t
typedef struct sync_condition {
- int lock;
- void* head;
- void* tail;
+ int lock;
+ void* head;
+ void* tail;
#ifdef __cplusplus
- sync_condition()
- : lock(0), head(nullptr), tail(nullptr) {}
+ sync_condition() : lock(0), head(nullptr), tail(nullptr) {}
#endif
} sync_condition_t;
+static_assert(sizeof(((sync_condition_t*)0)->lock) == sizeof(sync_mutex_t),
+ "sync_condition lock storage must be the same size as sync_mutex_t");
+
#if !defined(__cplusplus)
#define SYNC_CONDITION_INIT ((sync_condition_t){0})
#endif
-// Block until |condition| is signaled by sync_condition_signal()/sync_condition_broadcast(), or a spurious
-// wake up occurs.
+// Block until |condition| is signaled by sync_condition_signal()/sync_condition_broadcast(), or a
+// spurious wake up occurs.
//
// |mutex| must be in a locked state, and will be atomically unlocked for the duration of the wait,
// then locked again before the function returns.
void sync_condition_wait(sync_condition_t* condition, sync_mutex_t* mutex);
-// Block until |condition| is signaled by sync_condition_signal()/sync_condition_broadcast(), or a spurious
-// wake up or a timeout occurs.
+// Block until |condition| is signaled by sync_condition_signal()/sync_condition_broadcast(), or a
+// spurious wake up or a timeout occurs.
//
// |mutex| must be in a locked state, and will be atomically unlocked for the duration of the wait,
// then locked again before the function returns.
@@ -45,7 +48,8 @@
// Return value:
// ZX_OK if |condition| was signaled or a spurious wake up occurred.
// ZX_ERR_TIMED_OUT if the wait timed out.
-zx_status_t sync_condition_timedwait(sync_condition_t* condition, sync_mutex_t* mutex, zx_time_t deadline);
+zx_status_t sync_condition_timedwait(sync_condition_t* condition, sync_mutex_t* mutex,
+ zx_time_t deadline);
// Wake up one thread waiting for |condition|.
//
@@ -92,4 +96,4 @@
__END_CDECLS
-#endif // LIB_SYNC_CONDITION_H_
+#endif // LIB_SYNC_CONDITION_H_
diff --git a/pkg/sync/include/lib/sync/internal/condition-template.h b/pkg/sync/include/lib/sync/internal/condition-template.h
index 7bd4f2d..7a5506f 100644
--- a/pkg/sync/include/lib/sync/internal/condition-template.h
+++ b/pkg/sync/include/lib/sync/internal/condition-template.h
@@ -7,7 +7,7 @@
#include <zircon/syscalls.h>
#include <lib/sync/completion.h>
-#include <lib/sync/mutex.h>
+#include <lib/sync/internal/mutex-internal.h>
namespace condition_impl_internal {
@@ -23,23 +23,25 @@
// in order to instantiate the template:
template <typename Mutex>
struct MutexOps {
- // Return a pointer to the futex that backs the |mutex|
- static zx_futex_t* get_futex(Mutex* mutex);
+ // Return a pointer to the futex that backs the |mutex|
+ static zx_futex_t* get_futex(Mutex* mutex);
- // Lock the |mutex|. If an error occurs while locking the mutex,
- // ZX_ERR_BAD_STATE must be returned. An implementation-defined
- // error code can be returned via |mutex_lock_err| if it's not null.
- static zx_status_t lock(Mutex* mutex, int* mutex_lock_err);
+ // Lock the |mutex|. If an error occurs while locking the mutex,
+ // ZX_ERR_BAD_STATE must be returned. An implementation-defined
+ // error code can be returned via |mutex_lock_err| if it's not null.
+ static zx_status_t lock(Mutex* mutex, int* mutex_lock_err);
- // Similar to lock(), but also update the waiter information in the mutex.
- // If the mutex implements waiter counting, then the count must be adjusted
- // by |waiters_delta|. Otherwise, the mutex must be marked as potentially
- // having waiters.
- static zx_status_t lock_with_waiters(
- Mutex* mutex, int waiters_delta, int* mutex_lock_err);
+ // Similar to lock(), but also update the waiter information in the mutex.
+ // If the mutex implements waiter counting, then the count must be adjusted
+ // by |waiters_delta|. Otherwise, the mutex must be marked as potentially
+ // having waiters.
+ static zx_status_t lock_with_waiters(Mutex* mutex, int waiters_delta, int* mutex_lock_err);
- // Unlock the mutex
- static void unlock(Mutex* mutex);
+ // Unlock the mutex
+ static void unlock(Mutex* mutex);
+
+ // Requeue all of the memebrs waiting in |completion| to the futex backing |mutex|.
+ static void signal_requeue(sync_completion_t* completion, Mutex* mutex);
};
// Note that this library is used by libc, and as such needs to use
@@ -47,48 +49,45 @@
static inline void spin() {
#if defined(__x86_64__)
- __asm__ __volatile__("pause"
- :
- :
- : "memory");
+ __asm__ __volatile__("pause" : : : "memory");
#elif defined(__aarch64__)
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
#else
#error Please define spin() for your architecture
#endif
}
static inline bool cas(int* ptr, int* expected, int desired) {
- return __atomic_compare_exchange_n(ptr, expected, desired, false,
- __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return __atomic_compare_exchange_n(ptr, expected, desired, false, __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST);
}
static inline void wait(int* futex, int current_value) {
- int spins = 100;
- while (spins--) {
- if (__atomic_load_n(futex, __ATOMIC_SEQ_CST) == current_value) {
- spin();
- } else {
- return;
- }
+ int spins = 100;
+ while (spins--) {
+ if (__atomic_load_n(futex, __ATOMIC_SEQ_CST) == current_value) {
+ spin();
+ } else {
+ return;
}
- while (__atomic_load_n(futex, __ATOMIC_SEQ_CST) == current_value) {
- _zx_futex_wait(futex, current_value, ZX_HANDLE_INVALID, ZX_TIME_INFINITE);
- }
+ }
+ while (__atomic_load_n(futex, __ATOMIC_SEQ_CST) == current_value) {
+ _zx_futex_wait(futex, current_value, ZX_HANDLE_INVALID, ZX_TIME_INFINITE);
+ }
}
enum {
- WAITING,
- SIGNALED,
- LEAVING,
+ WAITING,
+ SIGNALED,
+ LEAVING,
};
struct Waiter {
- Waiter* prev = nullptr;
- Waiter* next = nullptr;
- int state = WAITING;
- sync_completion_t ready;
- int* notify = nullptr;
+ Waiter* prev = nullptr;
+ Waiter* next = nullptr;
+ int state = WAITING;
+ sync_completion_t ready;
+ int* notify = nullptr;
};
// Return value:
@@ -99,198 +98,197 @@
// provided by the mutex implementation.
template <typename Condition, typename Mutex>
static inline zx_status_t timedwait(Condition* c, Mutex* mutex, zx_time_t deadline,
- int* mutex_lock_err)
- __TA_NO_THREAD_SAFETY_ANALYSIS {
+ int* mutex_lock_err) __TA_NO_THREAD_SAFETY_ANALYSIS {
+ sync_mutex_lock(reinterpret_cast<sync_mutex_t*>(&c->lock));
+
+ Waiter node;
+
+ // Add our waiter node onto the condition's list. We add the node to the
+ // head of the list, but this is logically the end of the queue.
+ node.next = static_cast<Waiter*>(c->head);
+ c->head = &node;
+ if (!c->tail) {
+ c->tail = &node;
+ } else {
+ node.next->prev = &node;
+ }
+
+ sync_mutex_unlock(reinterpret_cast<sync_mutex_t*>(&c->lock));
+
+ MutexOps<Mutex>::unlock(mutex);
+
+ // Wait to be signaled. There are multiple ways this wait could finish:
+ // 1) After being woken by signal().
+ // 2) After being woken by a mutex unlock, after we were
+ // requeued from the condition's futex to the mutex's futex (by
+ // timedwait() in another thread).
+ // 3) After a timeout.
+ // In the original Linux version of this algorithm, this could also exit
+ // when interrupted by an asynchronous signal, but that does not apply on Zircon.
+ sync_completion_wait_deadline(&node.ready, deadline);
+
+ int oldstate = WAITING;
+ if (cas(&node.state, &oldstate, LEAVING)) {
+ // The wait timed out. So far, this thread was not signaled by
+ // signal() -- this thread was able to move state.node out of the
+ // WAITING state before any signal() call could do that.
+ //
+ // This thread must therefore remove the waiter node from the
+ // list itself.
+
+ // Access to cv object is valid because this waiter was not
+ // yet signaled and a new signal/broadcast cannot return
+ // after seeing a LEAVING waiter without getting notified
+ // via the futex notify below.
+
sync_mutex_lock(reinterpret_cast<sync_mutex_t*>(&c->lock));
- Waiter node;
+ // Remove our waiter node from the list.
+ if (c->head == &node) {
+ c->head = node.next;
+ } else if (node.prev) {
+ node.prev->next = node.next;
+ }
- // Add our waiter node onto the condition's list. We add the node to the
- // head of the list, but this is logically the end of the queue.
- node.next = static_cast<Waiter*>(c->head);
- c->head = &node;
- if (!c->tail) {
- c->tail = &node;
- } else {
- node.next->prev = &node;
+ if (c->tail == &node) {
+ c->tail = node.prev;
+ } else if (node.next) {
+ node.next->prev = node.prev;
}
sync_mutex_unlock(reinterpret_cast<sync_mutex_t*>(&c->lock));
- MutexOps<Mutex>::unlock(mutex);
-
- // Wait to be signaled. There are multiple ways this wait could finish:
- // 1) After being woken by signal().
- // 2) After being woken by a mutex unlock, after we were
- // requeued from the condition's futex to the mutex's futex (by
- // timedwait() in another thread).
- // 3) After a timeout.
- // In the original Linux version of this algorithm, this could also exit
- // when interrupted by an asynchronous signal, but that does not apply on Zircon.
- sync_completion_wait_deadline(&node.ready, deadline);
-
- int oldstate = WAITING;
- if (cas(&node.state, &oldstate, LEAVING)) {
- // The wait timed out. So far, this thread was not signaled by
- // signal() -- this thread was able to move state.node out of the
- // WAITING state before any signal() call could do that.
- //
- // This thread must therefore remove the waiter node from the
- // list itself.
-
- // Access to cv object is valid because this waiter was not
- // yet signaled and a new signal/broadcast cannot return
- // after seeing a LEAVING waiter without getting notified
- // via the futex notify below.
-
- sync_mutex_lock(reinterpret_cast<sync_mutex_t*>(&c->lock));
-
- // Remove our waiter node from the list.
- if (c->head == &node) {
- c->head = node.next;
- } else if (node.prev) {
- node.prev->next = node.next;
- }
-
- if (c->tail == &node) {
- c->tail = node.prev;
- } else if (node.next) {
- node.next->prev = node.prev;
- }
-
- sync_mutex_unlock(reinterpret_cast<sync_mutex_t*>(&c->lock));
-
- // It is possible that signal() saw our waiter node after we set
- // node.state to LEAVING but before we removed the node from the
- // list. If so, it will have set node.notify and will be waiting
- // on it, and we need to wake it up.
- //
- // This is rather complex. An alternative would be to eliminate
- // the |node.state| field and always claim |lock| if we could have
- // got a timeout. However, that presumably has higher overhead
- // (since it contends |lock| and involves more atomic ops).
- if (node.notify) {
- if (__atomic_fetch_add(node.notify, -1, __ATOMIC_SEQ_CST) == 1) {
- _zx_futex_wake(node.notify, 1);
- }
- }
-
- // We don't need lock_with_waiters() here: we haven't been signaled, and will
- // never be since we managed to claim the state as LEAVING. This means that
- // we could not have been woken up by unlock_requeue() + mutex unlock().
- if (MutexOps<Mutex>::lock(mutex, mutex_lock_err) != ZX_OK) {
- return ZX_ERR_BAD_STATE;
- }
- return ZX_ERR_TIMED_OUT;
- }
-
- // Since the CAS above failed, we have been signaled.
- // It could still be the case that sync_completion_wait_deadline() above timed out,
- // so we need to make sure to wait for the completion to control the wake order.
- // If the completion has already been signaled, this will return immediately.
- sync_completion_wait_deadline(&node.ready, ZX_TIME_INFINITE);
-
- // By this point, our part of the waiter list cannot change further.
- // It has been unlinked from the condition by signal().
- // Any timed out waiters would have removed themselves from the list
- // before signal() signaled the first node.ready in our list.
+ // It is possible that signal() saw our waiter node after we set
+ // node.state to LEAVING but before we removed the node from the
+ // list. If so, it will have set node.notify and will be waiting
+ // on it, and we need to wake it up.
//
- // It is therefore safe now to read node.next and node.prev without
- // holding c->lock.
-
- // As an optimization, we only update waiter count at the beginning and
- // end of the signaled list.
- int waiters_delta = 0;
- if (!node.prev) {
- waiters_delta++;
- }
- if (!node.next) {
- waiters_delta--;
+ // This is rather complex. An alternative would be to eliminate
+ // the |node.state| field and always claim |lock| if we could have
+ // got a timeout. However, that presumably has higher overhead
+ // (since it contends |lock| and involves more atomic ops).
+ if (node.notify) {
+ if (__atomic_fetch_add(node.notify, -1, __ATOMIC_SEQ_CST) == 1) {
+ _zx_futex_wake(node.notify, 1);
+ }
}
- // We must leave the mutex in the "locked with waiters" state here
- // (or adjust its waiter count, depending on the implementation).
- // There are two reasons for that:
- // 1) If we do the unlock_requeue() below, a condition waiter will be
- // requeued to the mutex's futex. We need to ensure that it will
- // be signaled by mutex unlock() in future.
- // 2) If the current thread was woken via an unlock_requeue() +
- // mutex unlock, there *might* be another thread waiting for
- // the mutex after us in the queue. We need to ensure that it
- // will be signaled by zxr_mutex_unlock() in future.
- zx_status_t status = MutexOps<Mutex>::lock_with_waiters(mutex, waiters_delta, mutex_lock_err);
-
- if (node.prev) {
- // Signal the completion that's holding back the next waiter, and
- // requeue it to the mutex so that it will be woken when the
- // mutex is unlocked.
- sync_completion_signal_requeue(&node.prev->ready, MutexOps<Mutex>::get_futex(mutex));
+ // We don't need lock_with_waiters() here: we haven't been signaled, and will
+ // never be since we managed to claim the state as LEAVING. This means that
+ // we could not have been woken up by unlock_requeue() + mutex unlock().
+ if (MutexOps<Mutex>::lock(mutex, mutex_lock_err) != ZX_OK) {
+ return ZX_ERR_BAD_STATE;
}
+ return ZX_ERR_TIMED_OUT;
+ }
- // Even if the first call to sync_completion_wait_deadline() timed out,
- // we still have been signaled. Thus we still return ZX_OK rather than
- // ZX_ERR_TIMED_OUT. This provides the following guarantee: if multiple
- // threads are waiting when signal() is called, at least one waiting
- // thread will be woken *and* get a ZX_OK from timedwait() (unless there
- // is an error locking the mutex). This property does not appear to be
- // required by pthread condvars, although an analogous property is
- // required for futex wake-ups. We also require this property for
- // sync_condition_t.
- return status;
+ // Since the CAS above failed, we have been signaled.
+ // It could still be the case that sync_completion_wait_deadline() above timed out,
+ // so we need to make sure to wait for the completion to control the wake order.
+ // If the completion has already been signaled, this will return immediately.
+ sync_completion_wait_deadline(&node.ready, ZX_TIME_INFINITE);
+
+ // By this point, our part of the waiter list cannot change further.
+ // It has been unlinked from the condition by signal().
+ // Any timed out waiters would have removed themselves from the list
+ // before signal() signaled the first node.ready in our list.
+ //
+ // It is therefore safe now to read node.next and node.prev without
+ // holding c->lock.
+
+ // As an optimization, we only update waiter count at the beginning and
+ // end of the signaled list.
+ int waiters_delta = 0;
+ if (!node.prev) {
+ waiters_delta++;
+ }
+ if (!node.next) {
+ waiters_delta--;
+ }
+
+ // We must leave the mutex in the "locked with waiters" state here
+ // (or adjust its waiter count, depending on the implementation).
+ // There are two reasons for that:
+ // 1) If we do the unlock_requeue() below, a condition waiter will be
+ // requeued to the mutex's futex. We need to ensure that it will
+ // be signaled by mutex unlock() in future.
+ // 2) If the current thread was woken via an unlock_requeue() +
+ // mutex unlock, there *might* be another thread waiting for
+ // the mutex after us in the queue. We need to ensure that it
+ // will be signaled by zxr_mutex_unlock() in future.
+ zx_status_t status = MutexOps<Mutex>::lock_with_waiters(mutex, waiters_delta, mutex_lock_err);
+
+ if (node.prev) {
+ // Signal the completion that's holding back the next waiter, and
+ // requeue it to the mutex so that it will be woken when the
+ // mutex is unlocked.
+ MutexOps<Mutex>::signal_requeue(&node.prev->ready, mutex);
+ }
+
+ // Even if the first call to sync_completion_wait_deadline() timed out,
+ // we still have been signaled. Thus we still return ZX_OK rather than
+ // ZX_ERR_TIMED_OUT. This provides the following guarantee: if multiple
+ // threads are waiting when signal() is called, at least one waiting
+ // thread will be woken *and* get a ZX_OK from timedwait() (unless there
+ // is an error locking the mutex). This property does not appear to be
+ // required by pthread condvars, although an analogous property is
+ // required for futex wake-ups. We also require this property for
+ // sync_condition_t.
+ return status;
}
// This will wake up to |n| threads that are waiting on the condition,
// or all waiting threads if |n| is set to -1
template <typename Condition>
static inline void signal(Condition* c, int n) {
- Waiter* p;
- Waiter* first = nullptr;
- int ref = 0;
- int cur;
+ Waiter* p;
+ Waiter* first = nullptr;
+ int ref = 0;
+ int cur;
- sync_mutex_lock(reinterpret_cast<sync_mutex_t*>(&c->lock));
- for (p = static_cast<Waiter*>(c->tail); n && p; p = p->prev) {
- int oldstate = WAITING;
- if (!cas(&p->state, &oldstate, SIGNALED)) {
- // This waiter timed out, and it marked itself as in the
- // LEAVING state. However, it hasn't yet claimed |lock|
- // (since we claimed the lock first) and so it hasn't yet
- // removed itself from the list. We will wait for the waiter
- // to remove itself from the list and to notify us of that.
- __atomic_fetch_add(&ref, 1, __ATOMIC_SEQ_CST);
- p->notify = &ref;
- } else {
- n--;
- if (!first) {
- first = p;
- }
- }
- }
- // Split the list, leaving any remainder on the cv.
- if (p) {
- if (p->next) {
- p->next->prev = 0;
- }
- p->next = 0;
+ sync_mutex_lock(reinterpret_cast<sync_mutex_t*>(&c->lock));
+ for (p = static_cast<Waiter*>(c->tail); n && p; p = p->prev) {
+ int oldstate = WAITING;
+ if (!cas(&p->state, &oldstate, SIGNALED)) {
+ // This waiter timed out, and it marked itself as in the
+ // LEAVING state. However, it hasn't yet claimed |lock|
+ // (since we claimed the lock first) and so it hasn't yet
+ // removed itself from the list. We will wait for the waiter
+ // to remove itself from the list and to notify us of that.
+ __atomic_fetch_add(&ref, 1, __ATOMIC_SEQ_CST);
+ p->notify = &ref;
} else {
- c->head = 0;
+ n--;
+ if (!first) {
+ first = p;
+ }
}
- c->tail = p;
- sync_mutex_unlock(reinterpret_cast<sync_mutex_t*>(&c->lock));
+ }
+ // Split the list, leaving any remainder on the cv.
+ if (p) {
+ if (p->next) {
+ p->next->prev = 0;
+ }
+ p->next = 0;
+ } else {
+ c->head = 0;
+ }
+ c->tail = p;
+ sync_mutex_unlock(reinterpret_cast<sync_mutex_t*>(&c->lock));
- // Wait for any waiters in the LEAVING state to remove
- // themselves from the list before returning or allowing
- // signaled threads to proceed.
- while ((cur = __atomic_load_n(&ref, __ATOMIC_SEQ_CST))) {
- wait(&ref, cur);
- }
+ // Wait for any waiters in the LEAVING state to remove
+ // themselves from the list before returning or allowing
+ // signaled threads to proceed.
+ while ((cur = __atomic_load_n(&ref, __ATOMIC_SEQ_CST))) {
+ wait(&ref, cur);
+ }
- // Allow first signaled waiter, if any, to proceed.
- if (first) {
- sync_completion_signal(&first->ready);
- }
+ // Allow first signaled waiter, if any, to proceed.
+ if (first) {
+ sync_completion_signal(&first->ready);
+ }
}
-} // namespace condition_impl_internal
+} // namespace condition_impl_internal
-#endif // LIB_SYNC_INTERNAL_CONDITION_TEMPLATE_H_
+#endif // LIB_SYNC_INTERNAL_CONDITION_TEMPLATE_H_
diff --git a/pkg/sync/include/lib/sync/internal/mutex-internal.h b/pkg/sync/include/lib/sync/internal/mutex-internal.h
new file mode 100644
index 0000000..4e47278
--- /dev/null
+++ b/pkg/sync/include/lib/sync/internal/mutex-internal.h
@@ -0,0 +1,53 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_SYNC_INTERNAL_MUTEX_INTERNAL_H_
+#define LIB_SYNC_INTERNAL_MUTEX_INTERNAL_H_
+
+#include <assert.h>
+#include <lib/sync/mutex.h>
+#include <zircon/process.h>
+#include <zircon/types.h>
+
+// The value of LIB_SYNC_MUTEX_UNLOCKED must be 0 to match C11's mtx.h and so
+// that mutexes can be allocated in BSS segments (zero-initialized data).
+//
+// Note that we use bit zero as the storage for our contested vs. unconstested
+// state, but the sense of the bit is negative instead of positive. IOW - a
+// contested mutex's state is encoded as the handle of the owning thread with
+// the LSB cleared (not set).
+#define LIB_SYNC_MUTEX_UNLOCKED ((zx_futex_storage_t)0)
+#define CONTESTED_BIT ((zx_futex_storage_t)1)
+
+static_assert(sizeof(zx_handle_t) <= sizeof(zx_futex_storage_t),
+ "mutex implementation requires futex storage to be "
+ "large enough to hold a zircon handle");
+
+static_assert((CONTESTED_BIT & ZX_HANDLE_FIXED_BITS_MASK) == CONTESTED_BIT,
+ "mutex implementation requires that it's contested state storage "
+ "bit be one of the zx_handle_t's guaranteed-to-be-one bits.");
+
+static_assert((~CONTESTED_BIT & (zx_futex_storage_t)ZX_HANDLE_FIXED_BITS_MASK) != 0,
+ "mutex implementation requires at least two guaranteed-to-be-one "
+ "bits in zx_handle_t's");
+
+static inline zx_futex_storage_t libsync_mutex_locked_and_uncontested(void) {
+ return ((zx_futex_storage_t)_zx_thread_self());
+}
+
+static inline bool libsync_mutex_is_contested(zx_futex_storage_t val) {
+ return ((val & CONTESTED_BIT) == 0);
+}
+
+static inline zx_futex_storage_t libsync_mutex_make_contested(zx_futex_storage_t val) {
+ return (val & ~CONTESTED_BIT);
+}
+
+static inline zx_handle_t libsync_mutex_make_owner_from_state(zx_futex_storage_t val) {
+ return (val != LIB_SYNC_MUTEX_UNLOCKED) ? (zx_handle_t)(val | CONTESTED_BIT) : ZX_HANDLE_INVALID;
+}
+
+#undef CONTESTED_BIT
+
+#endif // LIB_SYNC_INTERNAL_MUTEX_INTERNAL_H_
diff --git a/pkg/sync/include/lib/sync/mutex.h b/pkg/sync/include/lib/sync/mutex.h
index 37a5cd3..b7c020b 100644
--- a/pkg/sync/include/lib/sync/mutex.h
+++ b/pkg/sync/include/lib/sync/mutex.h
@@ -15,16 +15,15 @@
// The |mutex_t| mutex in the standard library has several quirks in its design
// that prevent it from being optimal. For example, the |mutex_t| interface
// supports recursion, which adds a branch to |mutex_init| to check that the
-// client has not asked for recusion, and |mutex_timedlock| operates in
+// client has not asked for recursion, and |mutex_timedlock| operates in
// |struct timespec| rather than |zx_time_t|.
//
// |sync_mutex| resolves these issues.
typedef struct __TA_CAPABILITY("mutex") sync_mutex {
- zx_futex_t futex;
+ zx_futex_t futex;
#ifdef __cplusplus
- sync_mutex()
- : futex(0) {}
+ sync_mutex() : futex(0) {}
#endif
} sync_mutex_t;
@@ -41,7 +40,7 @@
// Locks the mutex and mark the mutex as having a waiter.
//
-// Similar to |sync_mutex_lock| but markes the mutex as having a waiter. Intended
+// Similar to |sync_mutex_lock| but marks the mutex as having a waiter. Intended
// to be used by the condition variable implementation.
void sync_mutex_lock_with_waiter(sync_mutex_t* mutex) __TA_ACQUIRE(mutex);
@@ -69,4 +68,4 @@
__END_CDECLS
-#endif // LIB_SYNC_MUTEX_H_
+#endif // LIB_SYNC_MUTEX_H_
diff --git a/pkg/sync/meta.json b/pkg/sync/meta.json
index 4908432..04799a3 100644
--- a/pkg/sync/meta.json
+++ b/pkg/sync/meta.json
@@ -2,21 +2,22 @@
"binaries": {
"arm64": {
"link": "arch/arm64/lib/libsync.a"
- },
+ },
"x64": {
"link": "arch/x64/lib/libsync.a"
}
- },
- "deps": [],
- "format": "static",
+ },
+ "deps": [],
+ "format": "static",
"headers": [
- "pkg/sync/include/lib/sync/completion.h",
- "pkg/sync/include/lib/sync/condition.h",
- "pkg/sync/include/lib/sync/internal/condition-template.h",
+ "pkg/sync/include/lib/sync/internal/condition-template.h",
+ "pkg/sync/include/lib/sync/internal/mutex-internal.h",
+ "pkg/sync/include/lib/sync/completion.h",
+ "pkg/sync/include/lib/sync/condition.h",
"pkg/sync/include/lib/sync/mutex.h"
- ],
- "include_dir": "pkg/sync/include",
- "name": "sync",
- "root": "pkg/sync",
+ ],
+ "include_dir": "pkg/sync/include",
+ "name": "sync",
+ "root": "pkg/sync",
"type": "cc_prebuilt_library"
}
\ No newline at end of file
diff --git a/pkg/syslog/include/lib/syslog/global.h b/pkg/syslog/include/lib/syslog/global.h
deleted file mode 100644
index 9c9cc89..0000000
--- a/pkg/syslog/include/lib/syslog/global.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-//
-// Entry points used by clients.
-
-#ifndef LIB_SYSLOG_GLOBAL_H_
-#define LIB_SYSLOG_GLOBAL_H_
-
-#include <lib/syslog/logger.h>
-
-__BEGIN_CDECLS
-
-// Gets the global logger for the process to which log messages emitted
-// using the FX_LOG macros will be written. Returns NULL if logging is
-// not configured.
-fx_logger_t* fx_log_get_logger(void);
-
-// Returns true if writing messages with the given severity is enabled in the
-// global logger.
-static inline bool fx_log_is_enabled(fx_log_severity_t severity) {
- fx_logger_t* logger = fx_log_get_logger();
- return logger && severity >= fx_logger_get_min_severity(logger);
-}
-
-// Initializes the logging infrastructure with the specified configuration.
-// Returns |ZX_ERR_BAD_STATE| if logging has already been initialized.
-// If |console_fd| and |log_service_channel| are invalid in |config|,
-// this function chooses a default destination for the log.
-// |config| can be safely deallocated after this function returns.
-//
-// global logger would be deallocated once program ends.
-zx_status_t fx_log_init_with_config(const fx_logger_config_t* config);
-
-// Initializes the logging infrastructure for this process using default
-// parameters. Returns |ZX_ERR_BAD_STATE| if logging has already been
-// initialized.
-//
-// global logger would be deallocated once program ends.
-zx_status_t fx_log_init(void);
-
-// Returns true if writing messages with the given severity is enabled in the
-// global logger. |severity| is one of DEBUG, INFO, WARNING, ERROR, or FATAL.
-#define FX_LOG_IS_ENABLED(severity) (fx_log_is_enabled(FX_LOG_##severity))
-
-// Returns true if writing messages with the given verbosity is enabled in the
-// global logger. |verbosity| is positive number.
-#define FX_VLOG_IS_ENABLED(verbosity) (fx_log_is_enabled(-(verbosity)))
-
-#define _FX_LOG_SET_SEVERITY(severity) \
- do { \
- fx_logger_t* logger = fx_log_get_logger(); \
- if (logger) { \
- fx_logger_set_min_severity(logger, (severity)); \
- } \
- } while (0)
-
-// Sets severity for global logger.
-// |severity| is one of DEBUG, INFO, WARNING, ERROR, or FATAL.
-#define FX_LOG_SET_SEVERITY(severity) _FX_LOG_SET_SEVERITY(FX_LOG_##severity)
-
-// Sets verbosity for global logger.
-// |verbosity| is positive number. Logger severity is set to -verbosity
-#define FX_LOG_SET_VERBOSITY(verbosity) _FX_LOG_SET_SEVERITY(-(verbosity))
-
-#define _FX_LOG(severity, tag, message) \
- do { \
- fx_logger_t* logger = fx_log_get_logger(); \
- if (logger && fx_logger_get_min_severity(logger) <= (severity)) { \
- fx_logger_log(logger, (severity), (tag), (message)); \
- } \
- } while (0)
-
-#define _FX_LOGF(severity, tag, message, ...) \
- do { \
- fx_logger_t* logger = fx_log_get_logger(); \
- if (logger && fx_logger_get_min_severity(logger) <= (severity)) { \
- fx_logger_logf(logger, (severity), (tag), (message), \
- __VA_ARGS__); \
- } \
- } while (0)
-
-#define _FX_LOGVF(severity, tag, message, args) \
- do { \
- fx_logger_t* logger = fx_log_get_logger(); \
- if (logger && fx_logger_get_min_severity(logger) <= (severity)) { \
- fx_logger_logvf(logger, (severity), (tag), (message), (args)); \
- } \
- } while (0)
-
-// Writes a message to the global logger.
-// |severity| is one of DEBUG, INFO, WARNING, ERROR, FATAL
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-#define FX_LOG(severity, tag, message) _FX_LOG((FX_LOG_##severity), tag, message)
-
-// Writes formatted message to the global logger.
-// |severity| is one of DEBUG, INFO, WARNING, ERROR, FATAL
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-#define FX_LOGF(severity, tag, message, ...) _FX_LOGF((FX_LOG_##severity), tag, message, __VA_ARGS__)
-
-// Writes formatted message to the global logger using vaargs
-// |severity| is one of DEBUG, INFO, WARNING, ERROR, FATAL
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-// |args| are the arguments to |message|.
-#define FX_LOGVF(severity, tag, message, args) _FX_LOGVF((FX_LOG_##severity), tag, message, args)
-
-// Writes verbose message to the global logger.
-// |verbosity| is positive integer.
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-#define FX_VLOG(verbosity, tag, message) _FX_LOG(-(verbosity), tag, message)
-
-// Writes formatted verbose message to the global logger.
-// |verbosity| is positive integer.
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-#define FX_VLOGF(verbosity, tag, message, ...) _FX_LOGF(-(verbosity), tag, message, __VA_ARGS__)
-
-// Writes formatted verbose message to the global logger using vaargs
-// |verbosity| is positive integer.
-// |tag| is a tag to associated with the message, or NULL if none.
-// |message| is the message to write, or NULL if none.
-// |args| are the arguments to |message|.
-#define FX_VLOGVF(verbosity, tag, message, args) _FX_LOGVF(-(verbosity), tag, message, args)
-
-__END_CDECLS
-
-#endif // LIB_SYSLOG_GLOBAL_H_
diff --git a/pkg/syslog/include/lib/syslog/logger.h b/pkg/syslog/include/lib/syslog/logger.h
deleted file mode 100644
index 26e001a..0000000
--- a/pkg/syslog/include/lib/syslog/logger.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-//
-// This header contains definition for the logger object and protocol.
-
-#ifndef LIB_SYSLOG_LOGGER_H_
-#define LIB_SYSLOG_LOGGER_H_
-
-#include <stdarg.h>
-#include <unistd.h>
-
-#include <zircon/types.h>
-
-// Max no of tags associated with a logger.
-#define FX_LOG_MAX_TAGS (4)
-
-// Max individual tag length including terminating character.
-#define FX_LOG_MAX_TAG_LEN (64)
-
-// Log entry severity.
-// Used for coarse filtering of log messages
-typedef int fx_log_severity_t;
-#define FX_LOG_INFO (0)
-#define FX_LOG_WARNING (1)
-#define FX_LOG_ERROR (2)
-#define FX_LOG_FATAL (3)
-
-__BEGIN_CDECLS
-
-// Configuration for a logger object.
-// Specifies the destination to which log messages should be written.
-// Multiple destinations may be used concurrently.
-typedef struct fx_logger_config {
- // The minimum log severity.
- // Log messages with lower severity will be discarded.
- fx_log_severity_t min_severity;
-
- // The file descriptor to which formatted log messages should be written,
- // or -1 if log messages should not be written to the console.
- // logger takes ownership of this fd.
- int console_fd;
-
- // The FIDL log service channel to which the logger should connect, or
- // |ZX_HANDLE_INVALID| if the logger should not connect to the log service.
- // logger takes ownership of this handle.
- zx_handle_t log_service_channel;
-
- // An array of tag strings to associate with all messages written
- // by this logger. Tags will be truncated if they are (individually) longer
- // than |FX_LOG_MAX_TAG_LEN|.
- const char** tags;
-
- // Number of tag strings. Must be no more than |FX_LOG_MAX_TAGS|.
- size_t num_tags;
-} fx_logger_config_t;
-
-// Opaque type representing a logger object.
-typedef struct fx_logger fx_logger_t;
-
-// Creates a logger object from the specified configuration.
-//
-// This will return ZX_ERR_INVALID_ARGS if |num_tags| is more than
-// |FX_LOG_MAX_TAGS| and return |ZX_ERR_INTERNAL} if dup fails.
-// |config| can be safely deleted after this function returns.
-zx_status_t fx_logger_create(const fx_logger_config_t* config,
- fx_logger_t** out_logger);
-
-// Destroys a logger object.
-//
-// This closes |console_fd| or |log_service_channel| which were passed in
-// |fx_logger_config_t|.
-void fx_logger_destroy(fx_logger_t* logger);
-
-// Gets the logger's minimum log severity.
-fx_log_severity_t fx_logger_get_min_severity(fx_logger_t* logger);
-
-// Sets logger severity
-void fx_logger_set_min_severity(fx_logger_t* logger,
- fx_log_severity_t severity);
-
-// Activates fallback mode and logger starts writing to |fallback_fd|.
-// There is no way to revert this action.
-//
-// This function does not take ownership of |fallback_fd| and it should not be
-// closed till this logger object is no longer in use. Logger will log to
-// stderr if -1 is provided.
-//
-// This function is thread unsafe.
-void fx_logger_activate_fallback(fx_logger_t* logger,
- int fallback_fd);
-
-// Writes formatted message to a logger.
-// The message will be discarded if |severity| is less than the logger's
-// minimum log severity.
-// The |tag| may be NULL, in which case no additional tags are added to the
-// log message.
-// The |tag| will be truncated if it is longer than |FX_LOG_MAX_TAG_LEN|.
-// No message is written if |message| is NULL.
-zx_status_t fx_logger_logf(fx_logger_t* logger, fx_log_severity_t severity,
- const char* tag, const char* msg, ...);
-
-// Writes formatted message to a logger using varargs.
-// The message will be discarded if |severity| is less than the logger's
-// minimum log severity.
-// The |tag| may be NULL, in which case no additional tags are added to the
-// log message.
-// The |tag| will be truncated if it is longer than |FX_LOG_MAX_TAG_LEN|.
-// No message is written if |message| is NULL.
-zx_status_t fx_logger_logvf(fx_logger_t* logger, fx_log_severity_t severity,
- const char* tag, const char* msg, va_list args);
-
-// Writes a message to a logger.
-// The message will be discarded if |severity| is less than the logger's
-// minimum log severity.
-// The |tag| may be NULL, in which case no additional tags are added to the
-// log message.
-// The |tag| will be truncated if it is longer than |FX_LOG_MAX_TAG_LEN|.
-// No message is written if |message| is NULL.
-zx_status_t fx_logger_log(fx_logger_t* logger, fx_log_severity_t severity,
- const char* tag, const char* msg);
-
-__END_CDECLS
-
-#endif // LIB_SYSLOG_LOGGER_H_
diff --git a/pkg/syslog/include/lib/syslog/wire_format.h b/pkg/syslog/include/lib/syslog/wire_format.h
deleted file mode 100644
index 33dbff0..0000000
--- a/pkg/syslog/include/lib/syslog/wire_format.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This header file defines wire format to transfer logs to listening service.
-
-#ifndef LIB_SYSLOG_WIRE_FORMAT_H_
-#define LIB_SYSLOG_WIRE_FORMAT_H_
-
-#include <lib/syslog/logger.h>
-#include <zircon/types.h>
-
-// Defines max length for storing log_metadata, tags and msgbuffer.
-// TODO(anmittal): Increase it when zircon sockets are able to support a higher
-// buffer.
-#define FX_LOG_MAX_DATAGRAM_LEN (2032)
-
-typedef struct fx_log_metadata {
- zx_koid_t pid;
- zx_koid_t tid;
- zx_time_t time;
- fx_log_severity_t severity;
-
- // Increment this field whenever there is a socket write error and client
- // drops the log and send it with next log msg.
- uint32_t dropped_logs;
-} fx_log_metadata_t;
-
-// Packet to transfer over socket.
-typedef struct fx_log_packet {
- fx_log_metadata_t metadata;
-
- // Contains concatenated tags and message and a null terminating character at
- // the end.
- char data[FX_LOG_MAX_DATAGRAM_LEN - sizeof(fx_log_metadata_t)];
-} fx_log_packet_t;
-
-#endif // LIB_SYSLOG_WIRE_FORMAT_H_
diff --git a/pkg/syslog/meta.json b/pkg/syslog/meta.json
deleted file mode 100644
index e427a70..0000000
--- a/pkg/syslog/meta.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/ab/d169689a6ad6a1155ae97b4155fa92810bfdce.debug",
- "dist": "arch/arm64/dist/libsyslog.so",
- "link": "arch/arm64/lib/libsyslog.so"
- },
- "x64": {
- "debug": ".build-id/6c/dab7364d696b10a4fdeb1f6c64eac9c8f707f5.debug",
- "dist": "arch/x64/dist/libsyslog.so",
- "link": "arch/x64/lib/libsyslog.so"
- }
- },
- "deps": [
- "fdio"
- ],
- "format": "shared",
- "headers": [
- "pkg/syslog/include/lib/syslog/global.h",
- "pkg/syslog/include/lib/syslog/logger.h",
- "pkg/syslog/include/lib/syslog/wire_format.h"
- ],
- "include_dir": "pkg/syslog/include",
- "name": "syslog",
- "root": "pkg/syslog",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/sysroot/meta.json b/pkg/sysroot/meta.json
index 3219922..66b31ff 100644
--- a/pkg/sysroot/meta.json
+++ b/pkg/sysroot/meta.json
@@ -1,538 +1,545 @@
{
- "name": "sysroot",
- "root": "pkg/sysroot",
- "type": "sysroot",
+ "name": "sysroot",
+ "type": "sysroot",
"versions": {
"arm64": {
"debug_libs": [
- "arch/arm64/sysroot/debug/libc.so",
- "arch/arm64/sysroot/debug/libzircon.so"
- ],
+ ".build-id/e8/f15aa421e721e0.debug",
+ ".build-id/55/b95d079278df9d.debug",
+ ".build-id/61/c6eccde507b5db.debug",
+ ".build-id/b1/26a162015eed95.debug"
+ ],
+ "dist_dir": "arch/arm64/sysroot",
"dist_libs": [
- "arch/arm64/sysroot/dist/lib/ld.so.1"
- ],
+ "arch/arm64/sysroot/dist/lib/ld.so.1",
+ "arch/arm64/sysroot/dist/lib/asan/ld.so.1",
+ "arch/arm64/sysroot/dist/lib/asan-ubsan/ld.so.1"
+ ],
"headers": [
- "arch/arm64/sysroot/include/alloca.h",
- "arch/arm64/sysroot/include/ar.h",
- "arch/arm64/sysroot/include/arpa/ftp.h",
- "arch/arm64/sysroot/include/arpa/inet.h",
- "arch/arm64/sysroot/include/arpa/nameser.h",
- "arch/arm64/sysroot/include/arpa/nameser_compat.h",
- "arch/arm64/sysroot/include/arpa/telnet.h",
- "arch/arm64/sysroot/include/arpa/tftp.h",
- "arch/arm64/sysroot/include/assert.h",
- "arch/arm64/sysroot/include/bits/aarch64/endian.h",
- "arch/arm64/sysroot/include/bits/aarch64/fenv.h",
- "arch/arm64/sysroot/include/bits/aarch64/float.h",
- "arch/arm64/sysroot/include/bits/aarch64/io.h",
- "arch/arm64/sysroot/include/bits/aarch64/ioctl.h",
- "arch/arm64/sysroot/include/bits/aarch64/ipc.h",
- "arch/arm64/sysroot/include/bits/aarch64/reg.h",
- "arch/arm64/sysroot/include/bits/aarch64/setjmp.h",
- "arch/arm64/sysroot/include/bits/aarch64/signal.h",
- "arch/arm64/sysroot/include/bits/aarch64/stat.h",
- "arch/arm64/sysroot/include/bits/alltypes.h",
- "arch/arm64/sysroot/include/bits/endian.h",
- "arch/arm64/sysroot/include/bits/errno.h",
- "arch/arm64/sysroot/include/bits/fcntl.h",
- "arch/arm64/sysroot/include/bits/fenv.h",
- "arch/arm64/sysroot/include/bits/float.h",
- "arch/arm64/sysroot/include/bits/io.h",
- "arch/arm64/sysroot/include/bits/ioctl.h",
- "arch/arm64/sysroot/include/bits/ipc.h",
- "arch/arm64/sysroot/include/bits/limits.h",
- "arch/arm64/sysroot/include/bits/msg.h",
- "arch/arm64/sysroot/include/bits/null.h",
- "arch/arm64/sysroot/include/bits/poll.h",
- "arch/arm64/sysroot/include/bits/posix.h",
- "arch/arm64/sysroot/include/bits/reg.h",
- "arch/arm64/sysroot/include/bits/resource.h",
- "arch/arm64/sysroot/include/bits/sem.h",
- "arch/arm64/sysroot/include/bits/setjmp.h",
- "arch/arm64/sysroot/include/bits/shm.h",
- "arch/arm64/sysroot/include/bits/signal.h",
- "arch/arm64/sysroot/include/bits/socket.h",
- "arch/arm64/sysroot/include/bits/stat.h",
- "arch/arm64/sysroot/include/bits/statfs.h",
- "arch/arm64/sysroot/include/bits/termios.h",
- "arch/arm64/sysroot/include/bits/x86_64/endian.h",
- "arch/arm64/sysroot/include/bits/x86_64/fenv.h",
- "arch/arm64/sysroot/include/bits/x86_64/float.h",
- "arch/arm64/sysroot/include/bits/x86_64/io.h",
- "arch/arm64/sysroot/include/bits/x86_64/ioctl.h",
- "arch/arm64/sysroot/include/bits/x86_64/ipc.h",
- "arch/arm64/sysroot/include/bits/x86_64/reg.h",
- "arch/arm64/sysroot/include/bits/x86_64/setjmp.h",
- "arch/arm64/sysroot/include/bits/x86_64/signal.h",
- "arch/arm64/sysroot/include/bits/x86_64/stat.h",
- "arch/arm64/sysroot/include/byteswap.h",
- "arch/arm64/sysroot/include/complex.h",
- "arch/arm64/sysroot/include/cpio.h",
- "arch/arm64/sysroot/include/crypt.h",
- "arch/arm64/sysroot/include/ctype.h",
- "arch/arm64/sysroot/include/dirent.h",
- "arch/arm64/sysroot/include/dlfcn.h",
- "arch/arm64/sysroot/include/elf.h",
- "arch/arm64/sysroot/include/endian.h",
- "arch/arm64/sysroot/include/err.h",
- "arch/arm64/sysroot/include/errno.h",
- "arch/arm64/sysroot/include/fcntl.h",
- "arch/arm64/sysroot/include/features.h",
- "arch/arm64/sysroot/include/fenv.h",
- "arch/arm64/sysroot/include/float.h",
- "arch/arm64/sysroot/include/fmtmsg.h",
- "arch/arm64/sysroot/include/fnmatch.h",
- "arch/arm64/sysroot/include/ftw.h",
- "arch/arm64/sysroot/include/getopt.h",
- "arch/arm64/sysroot/include/glob.h",
- "arch/arm64/sysroot/include/grp.h",
- "arch/arm64/sysroot/include/iconv.h",
- "arch/arm64/sysroot/include/ifaddrs.h",
- "arch/arm64/sysroot/include/inttypes.h",
- "arch/arm64/sysroot/include/iso646.h",
- "arch/arm64/sysroot/include/langinfo.h",
- "arch/arm64/sysroot/include/libgen.h",
- "arch/arm64/sysroot/include/limits.h",
- "arch/arm64/sysroot/include/link.h",
- "arch/arm64/sysroot/include/locale.h",
- "arch/arm64/sysroot/include/malloc.h",
- "arch/arm64/sysroot/include/math.h",
- "arch/arm64/sysroot/include/memory.h",
- "arch/arm64/sysroot/include/monetary.h",
- "arch/arm64/sysroot/include/net/ethernet.h",
- "arch/arm64/sysroot/include/net/if.h",
- "arch/arm64/sysroot/include/net/if_arp.h",
- "arch/arm64/sysroot/include/net/route.h",
- "arch/arm64/sysroot/include/netdb.h",
- "arch/arm64/sysroot/include/netinet/ether.h",
- "arch/arm64/sysroot/include/netinet/icmp6.h",
- "arch/arm64/sysroot/include/netinet/if_ether.h",
- "arch/arm64/sysroot/include/netinet/igmp.h",
- "arch/arm64/sysroot/include/netinet/in.h",
- "arch/arm64/sysroot/include/netinet/in_systm.h",
- "arch/arm64/sysroot/include/netinet/ip.h",
- "arch/arm64/sysroot/include/netinet/ip6.h",
- "arch/arm64/sysroot/include/netinet/ip_icmp.h",
- "arch/arm64/sysroot/include/netinet/tcp.h",
- "arch/arm64/sysroot/include/netinet/udp.h",
- "arch/arm64/sysroot/include/netpacket/packet.h",
- "arch/arm64/sysroot/include/nl_types.h",
- "arch/arm64/sysroot/include/paths.h",
- "arch/arm64/sysroot/include/poll.h",
- "arch/arm64/sysroot/include/pthread.h",
- "arch/arm64/sysroot/include/pty.h",
- "arch/arm64/sysroot/include/pwd.h",
- "arch/arm64/sysroot/include/regex.h",
- "arch/arm64/sysroot/include/resolv.h",
- "arch/arm64/sysroot/include/sched.h",
- "arch/arm64/sysroot/include/search.h",
- "arch/arm64/sysroot/include/semaphore.h",
- "arch/arm64/sysroot/include/setjmp.h",
- "arch/arm64/sysroot/include/signal.h",
- "arch/arm64/sysroot/include/spawn.h",
- "arch/arm64/sysroot/include/stdio.h",
- "arch/arm64/sysroot/include/stdlib.h",
- "arch/arm64/sysroot/include/stdnoreturn.h",
- "arch/arm64/sysroot/include/string.h",
- "arch/arm64/sysroot/include/strings.h",
- "arch/arm64/sysroot/include/stropts.h",
- "arch/arm64/sysroot/include/sys/acct.h",
- "arch/arm64/sysroot/include/sys/auxv.h",
- "arch/arm64/sysroot/include/sys/dir.h",
- "arch/arm64/sysroot/include/sys/errno.h",
- "arch/arm64/sysroot/include/sys/eventfd.h",
- "arch/arm64/sysroot/include/sys/fcntl.h",
- "arch/arm64/sysroot/include/sys/file.h",
- "arch/arm64/sysroot/include/sys/fsuid.h",
- "arch/arm64/sysroot/include/sys/io.h",
- "arch/arm64/sysroot/include/sys/ioctl.h",
- "arch/arm64/sysroot/include/sys/ipc.h",
- "arch/arm64/sysroot/include/sys/klog.h",
- "arch/arm64/sysroot/include/sys/mman.h",
- "arch/arm64/sysroot/include/sys/mount.h",
- "arch/arm64/sysroot/include/sys/msg.h",
- "arch/arm64/sysroot/include/sys/mtio.h",
- "arch/arm64/sysroot/include/sys/param.h",
- "arch/arm64/sysroot/include/sys/personality.h",
- "arch/arm64/sysroot/include/sys/poll.h",
- "arch/arm64/sysroot/include/sys/quota.h",
- "arch/arm64/sysroot/include/sys/random.h",
- "arch/arm64/sysroot/include/sys/reboot.h",
- "arch/arm64/sysroot/include/sys/reg.h",
- "arch/arm64/sysroot/include/sys/select.h",
- "arch/arm64/sysroot/include/sys/sem.h",
- "arch/arm64/sysroot/include/sys/sendfile.h",
- "arch/arm64/sysroot/include/sys/shm.h",
- "arch/arm64/sysroot/include/sys/signal.h",
- "arch/arm64/sysroot/include/sys/signalfd.h",
- "arch/arm64/sysroot/include/sys/socket.h",
- "arch/arm64/sysroot/include/sys/stat.h",
- "arch/arm64/sysroot/include/sys/statfs.h",
- "arch/arm64/sysroot/include/sys/statvfs.h",
- "arch/arm64/sysroot/include/sys/stropts.h",
- "arch/arm64/sysroot/include/sys/swap.h",
- "arch/arm64/sysroot/include/sys/syslog.h",
- "arch/arm64/sysroot/include/sys/termios.h",
- "arch/arm64/sysroot/include/sys/time.h",
- "arch/arm64/sysroot/include/sys/timeb.h",
- "arch/arm64/sysroot/include/sys/timerfd.h",
- "arch/arm64/sysroot/include/sys/times.h",
- "arch/arm64/sysroot/include/sys/timex.h",
- "arch/arm64/sysroot/include/sys/ttydefaults.h",
- "arch/arm64/sysroot/include/sys/types.h",
- "arch/arm64/sysroot/include/sys/ucontext.h",
- "arch/arm64/sysroot/include/sys/uio.h",
- "arch/arm64/sysroot/include/sys/un.h",
- "arch/arm64/sysroot/include/sys/utsname.h",
- "arch/arm64/sysroot/include/sys/vfs.h",
- "arch/arm64/sysroot/include/sys/wait.h",
- "arch/arm64/sysroot/include/sysexits.h",
- "arch/arm64/sysroot/include/syslog.h",
- "arch/arm64/sysroot/include/tar.h",
- "arch/arm64/sysroot/include/termios.h",
- "arch/arm64/sysroot/include/threads.h",
- "arch/arm64/sysroot/include/time.h",
- "arch/arm64/sysroot/include/uchar.h",
- "arch/arm64/sysroot/include/ucontext.h",
- "arch/arm64/sysroot/include/unistd.h",
- "arch/arm64/sysroot/include/utime.h",
- "arch/arm64/sysroot/include/values.h",
- "arch/arm64/sysroot/include/wait.h",
- "arch/arm64/sysroot/include/wchar.h",
- "arch/arm64/sysroot/include/wctype.h",
- "arch/arm64/sysroot/include/wordexp.h",
- "arch/arm64/sysroot/include/zircon/assert.h",
- "arch/arm64/sysroot/include/zircon/boot/bootdata.h",
- "arch/arm64/sysroot/include/zircon/boot/driver-config.h",
- "arch/arm64/sysroot/include/zircon/boot/e820.h",
- "arch/arm64/sysroot/include/zircon/boot/image.h",
- "arch/arm64/sysroot/include/zircon/boot/multiboot.h",
- "arch/arm64/sysroot/include/zircon/boot/netboot.h",
- "arch/arm64/sysroot/include/zircon/boot/sysconfig.h",
- "arch/arm64/sysroot/include/zircon/compiler.h",
- "arch/arm64/sysroot/include/zircon/device/ioctl-wrapper.h",
- "arch/arm64/sysroot/include/zircon/device/ioctl.h",
- "arch/arm64/sysroot/include/zircon/device/ramdisk.h",
- "arch/arm64/sysroot/include/zircon/dlfcn.h",
- "arch/arm64/sysroot/include/zircon/driver/binding.h",
- "arch/arm64/sysroot/include/zircon/errors.h",
- "arch/arm64/sysroot/include/zircon/features.h",
- "arch/arm64/sysroot/include/zircon/fidl.h",
- "arch/arm64/sysroot/include/zircon/hw/gpt.h",
- "arch/arm64/sysroot/include/zircon/hw/i2c.h",
- "arch/arm64/sysroot/include/zircon/hw/pci.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-audio.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-cdc.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-hid.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-hub.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-mass-storage.h",
- "arch/arm64/sysroot/include/zircon/hw/usb-video.h",
- "arch/arm64/sysroot/include/zircon/hw/usb.h",
- "arch/arm64/sysroot/include/zircon/limits.h",
- "arch/arm64/sysroot/include/zircon/listnode.h",
- "arch/arm64/sysroot/include/zircon/pixelformat.h",
- "arch/arm64/sysroot/include/zircon/process.h",
- "arch/arm64/sysroot/include/zircon/processargs.h",
- "arch/arm64/sysroot/include/zircon/rights.h",
- "arch/arm64/sysroot/include/zircon/sanitizer.h",
- "arch/arm64/sysroot/include/zircon/status.h",
- "arch/arm64/sysroot/include/zircon/syscalls.h",
- "arch/arm64/sysroot/include/zircon/syscalls/debug.h",
- "arch/arm64/sysroot/include/zircon/syscalls/definitions.h",
- "arch/arm64/sysroot/include/zircon/syscalls/exception.h",
- "arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h",
- "arch/arm64/sysroot/include/zircon/syscalls/iommu.h",
- "arch/arm64/sysroot/include/zircon/syscalls/log.h",
- "arch/arm64/sysroot/include/zircon/syscalls/object.h",
- "arch/arm64/sysroot/include/zircon/syscalls/pci.h",
- "arch/arm64/sysroot/include/zircon/syscalls/policy.h",
- "arch/arm64/sysroot/include/zircon/syscalls/port.h",
- "arch/arm64/sysroot/include/zircon/syscalls/profile.h",
- "arch/arm64/sysroot/include/zircon/syscalls/resource.h",
- "arch/arm64/sysroot/include/zircon/syscalls/smc.h",
- "arch/arm64/sysroot/include/zircon/syscalls/system.h",
- "arch/arm64/sysroot/include/zircon/syscalls/types.h",
- "arch/arm64/sysroot/include/zircon/threads.h",
- "arch/arm64/sysroot/include/zircon/time.h",
- "arch/arm64/sysroot/include/zircon/tls.h",
- "arch/arm64/sysroot/include/zircon/types.h"
- ],
- "include_dir": "arch/arm64/sysroot/include",
+ "arch/arm64/sysroot/include/zircon/assert.h",
+ "arch/arm64/sysroot/include/zircon/boot/bootfs.h",
+ "arch/arm64/sysroot/include/zircon/boot/crash-reason.h",
+ "arch/arm64/sysroot/include/zircon/boot/driver-config.h",
+ "arch/arm64/sysroot/include/zircon/boot/e820.h",
+ "arch/arm64/sysroot/include/zircon/boot/image.h",
+ "arch/arm64/sysroot/include/zircon/boot/multiboot.h",
+ "arch/arm64/sysroot/include/zircon/boot/netboot.h",
+ "arch/arm64/sysroot/include/zircon/boot/sysconfig.h",
+ "arch/arm64/sysroot/include/zircon/compiler.h",
+ "arch/arm64/sysroot/include/zircon/errors.h",
+ "arch/arm64/sysroot/include/zircon/features.h",
+ "arch/arm64/sysroot/include/zircon/fidl.h",
+ "arch/arm64/sysroot/include/zircon/hw/debug/arm64.h",
+ "arch/arm64/sysroot/include/zircon/hw/debug/x86.h",
+ "arch/arm64/sysroot/include/zircon/hw/gpt.h",
+ "arch/arm64/sysroot/include/zircon/hw/i2c.h",
+ "arch/arm64/sysroot/include/zircon/hw/pci.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/audio.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/cdc.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/dfu.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/hid.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/hub.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/ums.h",
+ "arch/arm64/sysroot/include/zircon/hw/usb/video.h",
+ "arch/arm64/sysroot/include/zircon/limits.h",
+ "arch/arm64/sysroot/include/zircon/listnode.h",
+ "arch/arm64/sysroot/include/zircon/pixelformat.h",
+ "arch/arm64/sysroot/include/zircon/process.h",
+ "arch/arm64/sysroot/include/zircon/processargs.h",
+ "arch/arm64/sysroot/include/zircon/rights.h",
+ "arch/arm64/sysroot/include/zircon/string_view.h",
+ "arch/arm64/sysroot/include/zircon/syscalls.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/clock.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/debug.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/exception.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/hypervisor.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/iommu.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/log.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/object.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/pci.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/policy.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/port.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/profile.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/resource.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/scheduler.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/smc.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/system.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/types.h",
+ "arch/arm64/sysroot/include/zircon/time.h",
+ "arch/arm64/sysroot/include/zircon/tls.h",
+ "arch/arm64/sysroot/include/zircon/types.h",
+ "arch/arm64/sysroot/include/zircon/device/audio.h",
+ "arch/arm64/sysroot/include/zircon/testonly-syscalls.h",
+ "arch/arm64/sysroot/include/alloca.h",
+ "arch/arm64/sysroot/include/ar.h",
+ "arch/arm64/sysroot/include/arpa/ftp.h",
+ "arch/arm64/sysroot/include/arpa/inet.h",
+ "arch/arm64/sysroot/include/arpa/nameser.h",
+ "arch/arm64/sysroot/include/arpa/nameser_compat.h",
+ "arch/arm64/sysroot/include/arpa/telnet.h",
+ "arch/arm64/sysroot/include/arpa/tftp.h",
+ "arch/arm64/sysroot/include/assert.h",
+ "arch/arm64/sysroot/include/bits/aarch64/endian.h",
+ "arch/arm64/sysroot/include/bits/aarch64/fenv.h",
+ "arch/arm64/sysroot/include/bits/aarch64/io.h",
+ "arch/arm64/sysroot/include/bits/aarch64/ioctl.h",
+ "arch/arm64/sysroot/include/bits/aarch64/ipc.h",
+ "arch/arm64/sysroot/include/bits/aarch64/reg.h",
+ "arch/arm64/sysroot/include/bits/aarch64/setjmp.h",
+ "arch/arm64/sysroot/include/bits/aarch64/signal.h",
+ "arch/arm64/sysroot/include/bits/aarch64/stat.h",
+ "arch/arm64/sysroot/include/bits/alltypes.h",
+ "arch/arm64/sysroot/include/bits/endian.h",
+ "arch/arm64/sysroot/include/bits/errno.h",
+ "arch/arm64/sysroot/include/bits/fcntl.h",
+ "arch/arm64/sysroot/include/bits/fenv.h",
+ "arch/arm64/sysroot/include/bits/io.h",
+ "arch/arm64/sysroot/include/bits/ioctl.h",
+ "arch/arm64/sysroot/include/bits/ipc.h",
+ "arch/arm64/sysroot/include/bits/limits.h",
+ "arch/arm64/sysroot/include/bits/msg.h",
+ "arch/arm64/sysroot/include/bits/null.h",
+ "arch/arm64/sysroot/include/bits/poll.h",
+ "arch/arm64/sysroot/include/bits/posix.h",
+ "arch/arm64/sysroot/include/bits/reg.h",
+ "arch/arm64/sysroot/include/bits/resource.h",
+ "arch/arm64/sysroot/include/bits/sem.h",
+ "arch/arm64/sysroot/include/bits/setjmp.h",
+ "arch/arm64/sysroot/include/bits/shm.h",
+ "arch/arm64/sysroot/include/bits/signal.h",
+ "arch/arm64/sysroot/include/bits/socket.h",
+ "arch/arm64/sysroot/include/bits/stat.h",
+ "arch/arm64/sysroot/include/bits/statfs.h",
+ "arch/arm64/sysroot/include/bits/termios.h",
+ "arch/arm64/sysroot/include/bits/x86_64/endian.h",
+ "arch/arm64/sysroot/include/bits/x86_64/fenv.h",
+ "arch/arm64/sysroot/include/bits/x86_64/io.h",
+ "arch/arm64/sysroot/include/bits/x86_64/ioctl.h",
+ "arch/arm64/sysroot/include/bits/x86_64/ipc.h",
+ "arch/arm64/sysroot/include/bits/x86_64/reg.h",
+ "arch/arm64/sysroot/include/bits/x86_64/setjmp.h",
+ "arch/arm64/sysroot/include/bits/x86_64/signal.h",
+ "arch/arm64/sysroot/include/bits/x86_64/stat.h",
+ "arch/arm64/sysroot/include/byteswap.h",
+ "arch/arm64/sysroot/include/complex.h",
+ "arch/arm64/sysroot/include/cpio.h",
+ "arch/arm64/sysroot/include/ctype.h",
+ "arch/arm64/sysroot/include/dirent.h",
+ "arch/arm64/sysroot/include/dlfcn.h",
+ "arch/arm64/sysroot/include/elf.h",
+ "arch/arm64/sysroot/include/endian.h",
+ "arch/arm64/sysroot/include/err.h",
+ "arch/arm64/sysroot/include/errno.h",
+ "arch/arm64/sysroot/include/fcntl.h",
+ "arch/arm64/sysroot/include/features.h",
+ "arch/arm64/sysroot/include/fenv.h",
+ "arch/arm64/sysroot/include/fmtmsg.h",
+ "arch/arm64/sysroot/include/fnmatch.h",
+ "arch/arm64/sysroot/include/getopt.h",
+ "arch/arm64/sysroot/include/glob.h",
+ "arch/arm64/sysroot/include/grp.h",
+ "arch/arm64/sysroot/include/iconv.h",
+ "arch/arm64/sysroot/include/ifaddrs.h",
+ "arch/arm64/sysroot/include/inttypes.h",
+ "arch/arm64/sysroot/include/iso646.h",
+ "arch/arm64/sysroot/include/langinfo.h",
+ "arch/arm64/sysroot/include/libgen.h",
+ "arch/arm64/sysroot/include/limits.h",
+ "arch/arm64/sysroot/include/link.h",
+ "arch/arm64/sysroot/include/locale.h",
+ "arch/arm64/sysroot/include/malloc.h",
+ "arch/arm64/sysroot/include/math.h",
+ "arch/arm64/sysroot/include/memory.h",
+ "arch/arm64/sysroot/include/monetary.h",
+ "arch/arm64/sysroot/include/net/ethernet.h",
+ "arch/arm64/sysroot/include/net/if.h",
+ "arch/arm64/sysroot/include/net/if_arp.h",
+ "arch/arm64/sysroot/include/net/route.h",
+ "arch/arm64/sysroot/include/netdb.h",
+ "arch/arm64/sysroot/include/netinet/ether.h",
+ "arch/arm64/sysroot/include/netinet/icmp6.h",
+ "arch/arm64/sysroot/include/netinet/if_ether.h",
+ "arch/arm64/sysroot/include/netinet/igmp.h",
+ "arch/arm64/sysroot/include/netinet/in.h",
+ "arch/arm64/sysroot/include/netinet/in_systm.h",
+ "arch/arm64/sysroot/include/netinet/ip.h",
+ "arch/arm64/sysroot/include/netinet/ip6.h",
+ "arch/arm64/sysroot/include/netinet/ip_icmp.h",
+ "arch/arm64/sysroot/include/netinet/tcp.h",
+ "arch/arm64/sysroot/include/netinet/udp.h",
+ "arch/arm64/sysroot/include/netpacket/packet.h",
+ "arch/arm64/sysroot/include/nl_types.h",
+ "arch/arm64/sysroot/include/paths.h",
+ "arch/arm64/sysroot/include/poll.h",
+ "arch/arm64/sysroot/include/pthread.h",
+ "arch/arm64/sysroot/include/pwd.h",
+ "arch/arm64/sysroot/include/regex.h",
+ "arch/arm64/sysroot/include/resolv.h",
+ "arch/arm64/sysroot/include/sched.h",
+ "arch/arm64/sysroot/include/search.h",
+ "arch/arm64/sysroot/include/semaphore.h",
+ "arch/arm64/sysroot/include/setjmp.h",
+ "arch/arm64/sysroot/include/signal.h",
+ "arch/arm64/sysroot/include/spawn.h",
+ "arch/arm64/sysroot/include/stdio.h",
+ "arch/arm64/sysroot/include/stdlib.h",
+ "arch/arm64/sysroot/include/string.h",
+ "arch/arm64/sysroot/include/strings.h",
+ "arch/arm64/sysroot/include/stropts.h",
+ "arch/arm64/sysroot/include/sys/acct.h",
+ "arch/arm64/sysroot/include/sys/auxv.h",
+ "arch/arm64/sysroot/include/sys/dir.h",
+ "arch/arm64/sysroot/include/sys/errno.h",
+ "arch/arm64/sysroot/include/sys/eventfd.h",
+ "arch/arm64/sysroot/include/sys/fcntl.h",
+ "arch/arm64/sysroot/include/sys/file.h",
+ "arch/arm64/sysroot/include/sys/fsuid.h",
+ "arch/arm64/sysroot/include/sys/io.h",
+ "arch/arm64/sysroot/include/sys/ioctl.h",
+ "arch/arm64/sysroot/include/sys/ipc.h",
+ "arch/arm64/sysroot/include/sys/klog.h",
+ "arch/arm64/sysroot/include/sys/mman.h",
+ "arch/arm64/sysroot/include/sys/mount.h",
+ "arch/arm64/sysroot/include/sys/msg.h",
+ "arch/arm64/sysroot/include/sys/mtio.h",
+ "arch/arm64/sysroot/include/sys/param.h",
+ "arch/arm64/sysroot/include/sys/personality.h",
+ "arch/arm64/sysroot/include/sys/poll.h",
+ "arch/arm64/sysroot/include/sys/quota.h",
+ "arch/arm64/sysroot/include/sys/random.h",
+ "arch/arm64/sysroot/include/sys/reboot.h",
+ "arch/arm64/sysroot/include/sys/reg.h",
+ "arch/arm64/sysroot/include/sys/select.h",
+ "arch/arm64/sysroot/include/sys/sem.h",
+ "arch/arm64/sysroot/include/sys/shm.h",
+ "arch/arm64/sysroot/include/sys/signal.h",
+ "arch/arm64/sysroot/include/sys/signalfd.h",
+ "arch/arm64/sysroot/include/sys/socket.h",
+ "arch/arm64/sysroot/include/sys/stat.h",
+ "arch/arm64/sysroot/include/sys/statfs.h",
+ "arch/arm64/sysroot/include/sys/statvfs.h",
+ "arch/arm64/sysroot/include/sys/stropts.h",
+ "arch/arm64/sysroot/include/sys/swap.h",
+ "arch/arm64/sysroot/include/sys/syslog.h",
+ "arch/arm64/sysroot/include/sys/termios.h",
+ "arch/arm64/sysroot/include/sys/time.h",
+ "arch/arm64/sysroot/include/sys/timeb.h",
+ "arch/arm64/sysroot/include/sys/timerfd.h",
+ "arch/arm64/sysroot/include/sys/times.h",
+ "arch/arm64/sysroot/include/sys/timex.h",
+ "arch/arm64/sysroot/include/sys/ttydefaults.h",
+ "arch/arm64/sysroot/include/sys/types.h",
+ "arch/arm64/sysroot/include/sys/ucontext.h",
+ "arch/arm64/sysroot/include/sys/uio.h",
+ "arch/arm64/sysroot/include/sys/un.h",
+ "arch/arm64/sysroot/include/sys/utsname.h",
+ "arch/arm64/sysroot/include/sys/vfs.h",
+ "arch/arm64/sysroot/include/sys/wait.h",
+ "arch/arm64/sysroot/include/sysexits.h",
+ "arch/arm64/sysroot/include/syslog.h",
+ "arch/arm64/sysroot/include/tar.h",
+ "arch/arm64/sysroot/include/termios.h",
+ "arch/arm64/sysroot/include/threads.h",
+ "arch/arm64/sysroot/include/time.h",
+ "arch/arm64/sysroot/include/uchar.h",
+ "arch/arm64/sysroot/include/ucontext.h",
+ "arch/arm64/sysroot/include/unistd.h",
+ "arch/arm64/sysroot/include/utime.h",
+ "arch/arm64/sysroot/include/values.h",
+ "arch/arm64/sysroot/include/wait.h",
+ "arch/arm64/sysroot/include/wchar.h",
+ "arch/arm64/sysroot/include/wctype.h",
+ "arch/arm64/sysroot/include/wordexp.h",
+ "arch/arm64/sysroot/include/zircon/dlfcn.h",
+ "arch/arm64/sysroot/include/zircon/lookup.h",
+ "arch/arm64/sysroot/include/zircon/sanitizer.h",
+ "arch/arm64/sysroot/include/zircon/threads.h",
+ "arch/arm64/sysroot/include/zircon/utc.h",
+ "arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc",
+ "arch/arm64/sysroot/include/zircon/status.h",
+ "arch/arm64/sysroot/include/zircon/exception.h"
+ ],
+ "include_dir": "arch/arm64/sysroot/include",
"link_libs": [
- "arch/arm64/sysroot/lib/Scrt1.o",
- "arch/arm64/sysroot/lib/libc.so",
- "arch/arm64/sysroot/lib/libdl.so",
- "arch/arm64/sysroot/lib/libm.so",
- "arch/arm64/sysroot/lib/libpthread.so",
- "arch/arm64/sysroot/lib/librt.so",
+ "arch/arm64/sysroot/lib/libc.so",
+ "arch/arm64/sysroot/lib/libdl.so",
+ "arch/arm64/sysroot/lib/libm.so",
+ "arch/arm64/sysroot/lib/libpthread.so",
+ "arch/arm64/sysroot/lib/librt.so",
+ "arch/arm64/sysroot/lib/Scrt1.o",
"arch/arm64/sysroot/lib/libzircon.so"
- ],
+ ],
"root": "arch/arm64/sysroot"
- },
+ },
"x64": {
"debug_libs": [
- "arch/x64/sysroot/debug/libc.so",
- "arch/x64/sysroot/debug/libzircon.so"
- ],
+ ".build-id/59/1142fde7ffba7c.debug",
+ ".build-id/bc/9ab4810439a645.debug",
+ ".build-id/02/f5f7da6fb6d41f.debug",
+ ".build-id/a1/92662b149df3e5.debug"
+ ],
+ "dist_dir": "arch/x64/sysroot",
"dist_libs": [
- "arch/x64/sysroot/dist/lib/ld.so.1"
- ],
+ "arch/x64/sysroot/dist/lib/ld.so.1",
+ "arch/x64/sysroot/dist/lib/asan/ld.so.1",
+ "arch/x64/sysroot/dist/lib/asan-ubsan/ld.so.1"
+ ],
"headers": [
- "arch/x64/sysroot/include/alloca.h",
- "arch/x64/sysroot/include/ar.h",
- "arch/x64/sysroot/include/arpa/ftp.h",
- "arch/x64/sysroot/include/arpa/inet.h",
- "arch/x64/sysroot/include/arpa/nameser.h",
- "arch/x64/sysroot/include/arpa/nameser_compat.h",
- "arch/x64/sysroot/include/arpa/telnet.h",
- "arch/x64/sysroot/include/arpa/tftp.h",
- "arch/x64/sysroot/include/assert.h",
- "arch/x64/sysroot/include/bits/aarch64/endian.h",
- "arch/x64/sysroot/include/bits/aarch64/fenv.h",
- "arch/x64/sysroot/include/bits/aarch64/float.h",
- "arch/x64/sysroot/include/bits/aarch64/io.h",
- "arch/x64/sysroot/include/bits/aarch64/ioctl.h",
- "arch/x64/sysroot/include/bits/aarch64/ipc.h",
- "arch/x64/sysroot/include/bits/aarch64/reg.h",
- "arch/x64/sysroot/include/bits/aarch64/setjmp.h",
- "arch/x64/sysroot/include/bits/aarch64/signal.h",
- "arch/x64/sysroot/include/bits/aarch64/stat.h",
- "arch/x64/sysroot/include/bits/alltypes.h",
- "arch/x64/sysroot/include/bits/endian.h",
- "arch/x64/sysroot/include/bits/errno.h",
- "arch/x64/sysroot/include/bits/fcntl.h",
- "arch/x64/sysroot/include/bits/fenv.h",
- "arch/x64/sysroot/include/bits/float.h",
- "arch/x64/sysroot/include/bits/io.h",
- "arch/x64/sysroot/include/bits/ioctl.h",
- "arch/x64/sysroot/include/bits/ipc.h",
- "arch/x64/sysroot/include/bits/limits.h",
- "arch/x64/sysroot/include/bits/msg.h",
- "arch/x64/sysroot/include/bits/null.h",
- "arch/x64/sysroot/include/bits/poll.h",
- "arch/x64/sysroot/include/bits/posix.h",
- "arch/x64/sysroot/include/bits/reg.h",
- "arch/x64/sysroot/include/bits/resource.h",
- "arch/x64/sysroot/include/bits/sem.h",
- "arch/x64/sysroot/include/bits/setjmp.h",
- "arch/x64/sysroot/include/bits/shm.h",
- "arch/x64/sysroot/include/bits/signal.h",
- "arch/x64/sysroot/include/bits/socket.h",
- "arch/x64/sysroot/include/bits/stat.h",
- "arch/x64/sysroot/include/bits/statfs.h",
- "arch/x64/sysroot/include/bits/termios.h",
- "arch/x64/sysroot/include/bits/x86_64/endian.h",
- "arch/x64/sysroot/include/bits/x86_64/fenv.h",
- "arch/x64/sysroot/include/bits/x86_64/float.h",
- "arch/x64/sysroot/include/bits/x86_64/io.h",
- "arch/x64/sysroot/include/bits/x86_64/ioctl.h",
- "arch/x64/sysroot/include/bits/x86_64/ipc.h",
- "arch/x64/sysroot/include/bits/x86_64/reg.h",
- "arch/x64/sysroot/include/bits/x86_64/setjmp.h",
- "arch/x64/sysroot/include/bits/x86_64/signal.h",
- "arch/x64/sysroot/include/bits/x86_64/stat.h",
- "arch/x64/sysroot/include/byteswap.h",
- "arch/x64/sysroot/include/complex.h",
- "arch/x64/sysroot/include/cpio.h",
- "arch/x64/sysroot/include/crypt.h",
- "arch/x64/sysroot/include/ctype.h",
- "arch/x64/sysroot/include/dirent.h",
- "arch/x64/sysroot/include/dlfcn.h",
- "arch/x64/sysroot/include/elf.h",
- "arch/x64/sysroot/include/endian.h",
- "arch/x64/sysroot/include/err.h",
- "arch/x64/sysroot/include/errno.h",
- "arch/x64/sysroot/include/fcntl.h",
- "arch/x64/sysroot/include/features.h",
- "arch/x64/sysroot/include/fenv.h",
- "arch/x64/sysroot/include/float.h",
- "arch/x64/sysroot/include/fmtmsg.h",
- "arch/x64/sysroot/include/fnmatch.h",
- "arch/x64/sysroot/include/ftw.h",
- "arch/x64/sysroot/include/getopt.h",
- "arch/x64/sysroot/include/glob.h",
- "arch/x64/sysroot/include/grp.h",
- "arch/x64/sysroot/include/iconv.h",
- "arch/x64/sysroot/include/ifaddrs.h",
- "arch/x64/sysroot/include/inttypes.h",
- "arch/x64/sysroot/include/iso646.h",
- "arch/x64/sysroot/include/langinfo.h",
- "arch/x64/sysroot/include/libgen.h",
- "arch/x64/sysroot/include/limits.h",
- "arch/x64/sysroot/include/link.h",
- "arch/x64/sysroot/include/locale.h",
- "arch/x64/sysroot/include/malloc.h",
- "arch/x64/sysroot/include/math.h",
- "arch/x64/sysroot/include/memory.h",
- "arch/x64/sysroot/include/monetary.h",
- "arch/x64/sysroot/include/net/ethernet.h",
- "arch/x64/sysroot/include/net/if.h",
- "arch/x64/sysroot/include/net/if_arp.h",
- "arch/x64/sysroot/include/net/route.h",
- "arch/x64/sysroot/include/netdb.h",
- "arch/x64/sysroot/include/netinet/ether.h",
- "arch/x64/sysroot/include/netinet/icmp6.h",
- "arch/x64/sysroot/include/netinet/if_ether.h",
- "arch/x64/sysroot/include/netinet/igmp.h",
- "arch/x64/sysroot/include/netinet/in.h",
- "arch/x64/sysroot/include/netinet/in_systm.h",
- "arch/x64/sysroot/include/netinet/ip.h",
- "arch/x64/sysroot/include/netinet/ip6.h",
- "arch/x64/sysroot/include/netinet/ip_icmp.h",
- "arch/x64/sysroot/include/netinet/tcp.h",
- "arch/x64/sysroot/include/netinet/udp.h",
- "arch/x64/sysroot/include/netpacket/packet.h",
- "arch/x64/sysroot/include/nl_types.h",
- "arch/x64/sysroot/include/paths.h",
- "arch/x64/sysroot/include/poll.h",
- "arch/x64/sysroot/include/pthread.h",
- "arch/x64/sysroot/include/pty.h",
- "arch/x64/sysroot/include/pwd.h",
- "arch/x64/sysroot/include/regex.h",
- "arch/x64/sysroot/include/resolv.h",
- "arch/x64/sysroot/include/sched.h",
- "arch/x64/sysroot/include/search.h",
- "arch/x64/sysroot/include/semaphore.h",
- "arch/x64/sysroot/include/setjmp.h",
- "arch/x64/sysroot/include/signal.h",
- "arch/x64/sysroot/include/spawn.h",
- "arch/x64/sysroot/include/stdio.h",
- "arch/x64/sysroot/include/stdlib.h",
- "arch/x64/sysroot/include/stdnoreturn.h",
- "arch/x64/sysroot/include/string.h",
- "arch/x64/sysroot/include/strings.h",
- "arch/x64/sysroot/include/stropts.h",
- "arch/x64/sysroot/include/sys/acct.h",
- "arch/x64/sysroot/include/sys/auxv.h",
- "arch/x64/sysroot/include/sys/dir.h",
- "arch/x64/sysroot/include/sys/errno.h",
- "arch/x64/sysroot/include/sys/eventfd.h",
- "arch/x64/sysroot/include/sys/fcntl.h",
- "arch/x64/sysroot/include/sys/file.h",
- "arch/x64/sysroot/include/sys/fsuid.h",
- "arch/x64/sysroot/include/sys/io.h",
- "arch/x64/sysroot/include/sys/ioctl.h",
- "arch/x64/sysroot/include/sys/ipc.h",
- "arch/x64/sysroot/include/sys/klog.h",
- "arch/x64/sysroot/include/sys/mman.h",
- "arch/x64/sysroot/include/sys/mount.h",
- "arch/x64/sysroot/include/sys/msg.h",
- "arch/x64/sysroot/include/sys/mtio.h",
- "arch/x64/sysroot/include/sys/param.h",
- "arch/x64/sysroot/include/sys/personality.h",
- "arch/x64/sysroot/include/sys/poll.h",
- "arch/x64/sysroot/include/sys/quota.h",
- "arch/x64/sysroot/include/sys/random.h",
- "arch/x64/sysroot/include/sys/reboot.h",
- "arch/x64/sysroot/include/sys/reg.h",
- "arch/x64/sysroot/include/sys/select.h",
- "arch/x64/sysroot/include/sys/sem.h",
- "arch/x64/sysroot/include/sys/sendfile.h",
- "arch/x64/sysroot/include/sys/shm.h",
- "arch/x64/sysroot/include/sys/signal.h",
- "arch/x64/sysroot/include/sys/signalfd.h",
- "arch/x64/sysroot/include/sys/socket.h",
- "arch/x64/sysroot/include/sys/stat.h",
- "arch/x64/sysroot/include/sys/statfs.h",
- "arch/x64/sysroot/include/sys/statvfs.h",
- "arch/x64/sysroot/include/sys/stropts.h",
- "arch/x64/sysroot/include/sys/swap.h",
- "arch/x64/sysroot/include/sys/syslog.h",
- "arch/x64/sysroot/include/sys/termios.h",
- "arch/x64/sysroot/include/sys/time.h",
- "arch/x64/sysroot/include/sys/timeb.h",
- "arch/x64/sysroot/include/sys/timerfd.h",
- "arch/x64/sysroot/include/sys/times.h",
- "arch/x64/sysroot/include/sys/timex.h",
- "arch/x64/sysroot/include/sys/ttydefaults.h",
- "arch/x64/sysroot/include/sys/types.h",
- "arch/x64/sysroot/include/sys/ucontext.h",
- "arch/x64/sysroot/include/sys/uio.h",
- "arch/x64/sysroot/include/sys/un.h",
- "arch/x64/sysroot/include/sys/utsname.h",
- "arch/x64/sysroot/include/sys/vfs.h",
- "arch/x64/sysroot/include/sys/wait.h",
- "arch/x64/sysroot/include/sysexits.h",
- "arch/x64/sysroot/include/syslog.h",
- "arch/x64/sysroot/include/tar.h",
- "arch/x64/sysroot/include/termios.h",
- "arch/x64/sysroot/include/threads.h",
- "arch/x64/sysroot/include/time.h",
- "arch/x64/sysroot/include/uchar.h",
- "arch/x64/sysroot/include/ucontext.h",
- "arch/x64/sysroot/include/unistd.h",
- "arch/x64/sysroot/include/utime.h",
- "arch/x64/sysroot/include/values.h",
- "arch/x64/sysroot/include/wait.h",
- "arch/x64/sysroot/include/wchar.h",
- "arch/x64/sysroot/include/wctype.h",
- "arch/x64/sysroot/include/wordexp.h",
- "arch/x64/sysroot/include/zircon/assert.h",
- "arch/x64/sysroot/include/zircon/boot/bootdata.h",
- "arch/x64/sysroot/include/zircon/boot/driver-config.h",
- "arch/x64/sysroot/include/zircon/boot/e820.h",
- "arch/x64/sysroot/include/zircon/boot/image.h",
- "arch/x64/sysroot/include/zircon/boot/multiboot.h",
- "arch/x64/sysroot/include/zircon/boot/netboot.h",
- "arch/x64/sysroot/include/zircon/boot/sysconfig.h",
- "arch/x64/sysroot/include/zircon/compiler.h",
- "arch/x64/sysroot/include/zircon/device/ioctl-wrapper.h",
- "arch/x64/sysroot/include/zircon/device/ioctl.h",
- "arch/x64/sysroot/include/zircon/device/ramdisk.h",
- "arch/x64/sysroot/include/zircon/dlfcn.h",
- "arch/x64/sysroot/include/zircon/driver/binding.h",
- "arch/x64/sysroot/include/zircon/errors.h",
- "arch/x64/sysroot/include/zircon/features.h",
- "arch/x64/sysroot/include/zircon/fidl.h",
- "arch/x64/sysroot/include/zircon/hw/gpt.h",
- "arch/x64/sysroot/include/zircon/hw/i2c.h",
- "arch/x64/sysroot/include/zircon/hw/pci.h",
- "arch/x64/sysroot/include/zircon/hw/usb-audio.h",
- "arch/x64/sysroot/include/zircon/hw/usb-cdc.h",
- "arch/x64/sysroot/include/zircon/hw/usb-hid.h",
- "arch/x64/sysroot/include/zircon/hw/usb-hub.h",
- "arch/x64/sysroot/include/zircon/hw/usb-mass-storage.h",
- "arch/x64/sysroot/include/zircon/hw/usb-video.h",
- "arch/x64/sysroot/include/zircon/hw/usb.h",
- "arch/x64/sysroot/include/zircon/limits.h",
- "arch/x64/sysroot/include/zircon/listnode.h",
- "arch/x64/sysroot/include/zircon/pixelformat.h",
- "arch/x64/sysroot/include/zircon/process.h",
- "arch/x64/sysroot/include/zircon/processargs.h",
- "arch/x64/sysroot/include/zircon/rights.h",
- "arch/x64/sysroot/include/zircon/sanitizer.h",
- "arch/x64/sysroot/include/zircon/status.h",
- "arch/x64/sysroot/include/zircon/syscalls.h",
- "arch/x64/sysroot/include/zircon/syscalls/debug.h",
- "arch/x64/sysroot/include/zircon/syscalls/definitions.h",
- "arch/x64/sysroot/include/zircon/syscalls/exception.h",
- "arch/x64/sysroot/include/zircon/syscalls/hypervisor.h",
- "arch/x64/sysroot/include/zircon/syscalls/iommu.h",
- "arch/x64/sysroot/include/zircon/syscalls/log.h",
- "arch/x64/sysroot/include/zircon/syscalls/object.h",
- "arch/x64/sysroot/include/zircon/syscalls/pci.h",
- "arch/x64/sysroot/include/zircon/syscalls/policy.h",
- "arch/x64/sysroot/include/zircon/syscalls/port.h",
- "arch/x64/sysroot/include/zircon/syscalls/profile.h",
- "arch/x64/sysroot/include/zircon/syscalls/resource.h",
- "arch/x64/sysroot/include/zircon/syscalls/smc.h",
- "arch/x64/sysroot/include/zircon/syscalls/system.h",
- "arch/x64/sysroot/include/zircon/syscalls/types.h",
- "arch/x64/sysroot/include/zircon/threads.h",
- "arch/x64/sysroot/include/zircon/time.h",
- "arch/x64/sysroot/include/zircon/tls.h",
- "arch/x64/sysroot/include/zircon/types.h"
- ],
- "include_dir": "arch/x64/sysroot/include",
+ "arch/x64/sysroot/include/zircon/assert.h",
+ "arch/x64/sysroot/include/zircon/boot/bootfs.h",
+ "arch/x64/sysroot/include/zircon/boot/crash-reason.h",
+ "arch/x64/sysroot/include/zircon/boot/driver-config.h",
+ "arch/x64/sysroot/include/zircon/boot/e820.h",
+ "arch/x64/sysroot/include/zircon/boot/image.h",
+ "arch/x64/sysroot/include/zircon/boot/multiboot.h",
+ "arch/x64/sysroot/include/zircon/boot/netboot.h",
+ "arch/x64/sysroot/include/zircon/boot/sysconfig.h",
+ "arch/x64/sysroot/include/zircon/compiler.h",
+ "arch/x64/sysroot/include/zircon/errors.h",
+ "arch/x64/sysroot/include/zircon/features.h",
+ "arch/x64/sysroot/include/zircon/fidl.h",
+ "arch/x64/sysroot/include/zircon/hw/debug/arm64.h",
+ "arch/x64/sysroot/include/zircon/hw/debug/x86.h",
+ "arch/x64/sysroot/include/zircon/hw/gpt.h",
+ "arch/x64/sysroot/include/zircon/hw/i2c.h",
+ "arch/x64/sysroot/include/zircon/hw/pci.h",
+ "arch/x64/sysroot/include/zircon/hw/usb.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/audio.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/cdc.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/dfu.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/hid.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/hub.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/ums.h",
+ "arch/x64/sysroot/include/zircon/hw/usb/video.h",
+ "arch/x64/sysroot/include/zircon/limits.h",
+ "arch/x64/sysroot/include/zircon/listnode.h",
+ "arch/x64/sysroot/include/zircon/pixelformat.h",
+ "arch/x64/sysroot/include/zircon/process.h",
+ "arch/x64/sysroot/include/zircon/processargs.h",
+ "arch/x64/sysroot/include/zircon/rights.h",
+ "arch/x64/sysroot/include/zircon/string_view.h",
+ "arch/x64/sysroot/include/zircon/syscalls.h",
+ "arch/x64/sysroot/include/zircon/syscalls/clock.h",
+ "arch/x64/sysroot/include/zircon/syscalls/debug.h",
+ "arch/x64/sysroot/include/zircon/syscalls/exception.h",
+ "arch/x64/sysroot/include/zircon/syscalls/hypervisor.h",
+ "arch/x64/sysroot/include/zircon/syscalls/iommu.h",
+ "arch/x64/sysroot/include/zircon/syscalls/log.h",
+ "arch/x64/sysroot/include/zircon/syscalls/object.h",
+ "arch/x64/sysroot/include/zircon/syscalls/pci.h",
+ "arch/x64/sysroot/include/zircon/syscalls/policy.h",
+ "arch/x64/sysroot/include/zircon/syscalls/port.h",
+ "arch/x64/sysroot/include/zircon/syscalls/profile.h",
+ "arch/x64/sysroot/include/zircon/syscalls/resource.h",
+ "arch/x64/sysroot/include/zircon/syscalls/scheduler.h",
+ "arch/x64/sysroot/include/zircon/syscalls/smc.h",
+ "arch/x64/sysroot/include/zircon/syscalls/system.h",
+ "arch/x64/sysroot/include/zircon/syscalls/types.h",
+ "arch/x64/sysroot/include/zircon/time.h",
+ "arch/x64/sysroot/include/zircon/tls.h",
+ "arch/x64/sysroot/include/zircon/types.h",
+ "arch/x64/sysroot/include/zircon/device/audio.h",
+ "arch/x64/sysroot/include/zircon/testonly-syscalls.h",
+ "arch/x64/sysroot/include/alloca.h",
+ "arch/x64/sysroot/include/ar.h",
+ "arch/x64/sysroot/include/arpa/ftp.h",
+ "arch/x64/sysroot/include/arpa/inet.h",
+ "arch/x64/sysroot/include/arpa/nameser.h",
+ "arch/x64/sysroot/include/arpa/nameser_compat.h",
+ "arch/x64/sysroot/include/arpa/telnet.h",
+ "arch/x64/sysroot/include/arpa/tftp.h",
+ "arch/x64/sysroot/include/assert.h",
+ "arch/x64/sysroot/include/bits/aarch64/endian.h",
+ "arch/x64/sysroot/include/bits/aarch64/fenv.h",
+ "arch/x64/sysroot/include/bits/aarch64/io.h",
+ "arch/x64/sysroot/include/bits/aarch64/ioctl.h",
+ "arch/x64/sysroot/include/bits/aarch64/ipc.h",
+ "arch/x64/sysroot/include/bits/aarch64/reg.h",
+ "arch/x64/sysroot/include/bits/aarch64/setjmp.h",
+ "arch/x64/sysroot/include/bits/aarch64/signal.h",
+ "arch/x64/sysroot/include/bits/aarch64/stat.h",
+ "arch/x64/sysroot/include/bits/alltypes.h",
+ "arch/x64/sysroot/include/bits/endian.h",
+ "arch/x64/sysroot/include/bits/errno.h",
+ "arch/x64/sysroot/include/bits/fcntl.h",
+ "arch/x64/sysroot/include/bits/fenv.h",
+ "arch/x64/sysroot/include/bits/io.h",
+ "arch/x64/sysroot/include/bits/ioctl.h",
+ "arch/x64/sysroot/include/bits/ipc.h",
+ "arch/x64/sysroot/include/bits/limits.h",
+ "arch/x64/sysroot/include/bits/msg.h",
+ "arch/x64/sysroot/include/bits/null.h",
+ "arch/x64/sysroot/include/bits/poll.h",
+ "arch/x64/sysroot/include/bits/posix.h",
+ "arch/x64/sysroot/include/bits/reg.h",
+ "arch/x64/sysroot/include/bits/resource.h",
+ "arch/x64/sysroot/include/bits/sem.h",
+ "arch/x64/sysroot/include/bits/setjmp.h",
+ "arch/x64/sysroot/include/bits/shm.h",
+ "arch/x64/sysroot/include/bits/signal.h",
+ "arch/x64/sysroot/include/bits/socket.h",
+ "arch/x64/sysroot/include/bits/stat.h",
+ "arch/x64/sysroot/include/bits/statfs.h",
+ "arch/x64/sysroot/include/bits/termios.h",
+ "arch/x64/sysroot/include/bits/x86_64/endian.h",
+ "arch/x64/sysroot/include/bits/x86_64/fenv.h",
+ "arch/x64/sysroot/include/bits/x86_64/io.h",
+ "arch/x64/sysroot/include/bits/x86_64/ioctl.h",
+ "arch/x64/sysroot/include/bits/x86_64/ipc.h",
+ "arch/x64/sysroot/include/bits/x86_64/reg.h",
+ "arch/x64/sysroot/include/bits/x86_64/setjmp.h",
+ "arch/x64/sysroot/include/bits/x86_64/signal.h",
+ "arch/x64/sysroot/include/bits/x86_64/stat.h",
+ "arch/x64/sysroot/include/byteswap.h",
+ "arch/x64/sysroot/include/complex.h",
+ "arch/x64/sysroot/include/cpio.h",
+ "arch/x64/sysroot/include/ctype.h",
+ "arch/x64/sysroot/include/dirent.h",
+ "arch/x64/sysroot/include/dlfcn.h",
+ "arch/x64/sysroot/include/elf.h",
+ "arch/x64/sysroot/include/endian.h",
+ "arch/x64/sysroot/include/err.h",
+ "arch/x64/sysroot/include/errno.h",
+ "arch/x64/sysroot/include/fcntl.h",
+ "arch/x64/sysroot/include/features.h",
+ "arch/x64/sysroot/include/fenv.h",
+ "arch/x64/sysroot/include/fmtmsg.h",
+ "arch/x64/sysroot/include/fnmatch.h",
+ "arch/x64/sysroot/include/getopt.h",
+ "arch/x64/sysroot/include/glob.h",
+ "arch/x64/sysroot/include/grp.h",
+ "arch/x64/sysroot/include/iconv.h",
+ "arch/x64/sysroot/include/ifaddrs.h",
+ "arch/x64/sysroot/include/inttypes.h",
+ "arch/x64/sysroot/include/iso646.h",
+ "arch/x64/sysroot/include/langinfo.h",
+ "arch/x64/sysroot/include/libgen.h",
+ "arch/x64/sysroot/include/limits.h",
+ "arch/x64/sysroot/include/link.h",
+ "arch/x64/sysroot/include/locale.h",
+ "arch/x64/sysroot/include/malloc.h",
+ "arch/x64/sysroot/include/math.h",
+ "arch/x64/sysroot/include/memory.h",
+ "arch/x64/sysroot/include/monetary.h",
+ "arch/x64/sysroot/include/net/ethernet.h",
+ "arch/x64/sysroot/include/net/if.h",
+ "arch/x64/sysroot/include/net/if_arp.h",
+ "arch/x64/sysroot/include/net/route.h",
+ "arch/x64/sysroot/include/netdb.h",
+ "arch/x64/sysroot/include/netinet/ether.h",
+ "arch/x64/sysroot/include/netinet/icmp6.h",
+ "arch/x64/sysroot/include/netinet/if_ether.h",
+ "arch/x64/sysroot/include/netinet/igmp.h",
+ "arch/x64/sysroot/include/netinet/in.h",
+ "arch/x64/sysroot/include/netinet/in_systm.h",
+ "arch/x64/sysroot/include/netinet/ip.h",
+ "arch/x64/sysroot/include/netinet/ip6.h",
+ "arch/x64/sysroot/include/netinet/ip_icmp.h",
+ "arch/x64/sysroot/include/netinet/tcp.h",
+ "arch/x64/sysroot/include/netinet/udp.h",
+ "arch/x64/sysroot/include/netpacket/packet.h",
+ "arch/x64/sysroot/include/nl_types.h",
+ "arch/x64/sysroot/include/paths.h",
+ "arch/x64/sysroot/include/poll.h",
+ "arch/x64/sysroot/include/pthread.h",
+ "arch/x64/sysroot/include/pwd.h",
+ "arch/x64/sysroot/include/regex.h",
+ "arch/x64/sysroot/include/resolv.h",
+ "arch/x64/sysroot/include/sched.h",
+ "arch/x64/sysroot/include/search.h",
+ "arch/x64/sysroot/include/semaphore.h",
+ "arch/x64/sysroot/include/setjmp.h",
+ "arch/x64/sysroot/include/signal.h",
+ "arch/x64/sysroot/include/spawn.h",
+ "arch/x64/sysroot/include/stdio.h",
+ "arch/x64/sysroot/include/stdlib.h",
+ "arch/x64/sysroot/include/string.h",
+ "arch/x64/sysroot/include/strings.h",
+ "arch/x64/sysroot/include/stropts.h",
+ "arch/x64/sysroot/include/sys/acct.h",
+ "arch/x64/sysroot/include/sys/auxv.h",
+ "arch/x64/sysroot/include/sys/dir.h",
+ "arch/x64/sysroot/include/sys/errno.h",
+ "arch/x64/sysroot/include/sys/eventfd.h",
+ "arch/x64/sysroot/include/sys/fcntl.h",
+ "arch/x64/sysroot/include/sys/file.h",
+ "arch/x64/sysroot/include/sys/fsuid.h",
+ "arch/x64/sysroot/include/sys/io.h",
+ "arch/x64/sysroot/include/sys/ioctl.h",
+ "arch/x64/sysroot/include/sys/ipc.h",
+ "arch/x64/sysroot/include/sys/klog.h",
+ "arch/x64/sysroot/include/sys/mman.h",
+ "arch/x64/sysroot/include/sys/mount.h",
+ "arch/x64/sysroot/include/sys/msg.h",
+ "arch/x64/sysroot/include/sys/mtio.h",
+ "arch/x64/sysroot/include/sys/param.h",
+ "arch/x64/sysroot/include/sys/personality.h",
+ "arch/x64/sysroot/include/sys/poll.h",
+ "arch/x64/sysroot/include/sys/quota.h",
+ "arch/x64/sysroot/include/sys/random.h",
+ "arch/x64/sysroot/include/sys/reboot.h",
+ "arch/x64/sysroot/include/sys/reg.h",
+ "arch/x64/sysroot/include/sys/select.h",
+ "arch/x64/sysroot/include/sys/sem.h",
+ "arch/x64/sysroot/include/sys/shm.h",
+ "arch/x64/sysroot/include/sys/signal.h",
+ "arch/x64/sysroot/include/sys/signalfd.h",
+ "arch/x64/sysroot/include/sys/socket.h",
+ "arch/x64/sysroot/include/sys/stat.h",
+ "arch/x64/sysroot/include/sys/statfs.h",
+ "arch/x64/sysroot/include/sys/statvfs.h",
+ "arch/x64/sysroot/include/sys/stropts.h",
+ "arch/x64/sysroot/include/sys/swap.h",
+ "arch/x64/sysroot/include/sys/syslog.h",
+ "arch/x64/sysroot/include/sys/termios.h",
+ "arch/x64/sysroot/include/sys/time.h",
+ "arch/x64/sysroot/include/sys/timeb.h",
+ "arch/x64/sysroot/include/sys/timerfd.h",
+ "arch/x64/sysroot/include/sys/times.h",
+ "arch/x64/sysroot/include/sys/timex.h",
+ "arch/x64/sysroot/include/sys/ttydefaults.h",
+ "arch/x64/sysroot/include/sys/types.h",
+ "arch/x64/sysroot/include/sys/ucontext.h",
+ "arch/x64/sysroot/include/sys/uio.h",
+ "arch/x64/sysroot/include/sys/un.h",
+ "arch/x64/sysroot/include/sys/utsname.h",
+ "arch/x64/sysroot/include/sys/vfs.h",
+ "arch/x64/sysroot/include/sys/wait.h",
+ "arch/x64/sysroot/include/sysexits.h",
+ "arch/x64/sysroot/include/syslog.h",
+ "arch/x64/sysroot/include/tar.h",
+ "arch/x64/sysroot/include/termios.h",
+ "arch/x64/sysroot/include/threads.h",
+ "arch/x64/sysroot/include/time.h",
+ "arch/x64/sysroot/include/uchar.h",
+ "arch/x64/sysroot/include/ucontext.h",
+ "arch/x64/sysroot/include/unistd.h",
+ "arch/x64/sysroot/include/utime.h",
+ "arch/x64/sysroot/include/values.h",
+ "arch/x64/sysroot/include/wait.h",
+ "arch/x64/sysroot/include/wchar.h",
+ "arch/x64/sysroot/include/wctype.h",
+ "arch/x64/sysroot/include/wordexp.h",
+ "arch/x64/sysroot/include/zircon/dlfcn.h",
+ "arch/x64/sysroot/include/zircon/lookup.h",
+ "arch/x64/sysroot/include/zircon/sanitizer.h",
+ "arch/x64/sysroot/include/zircon/threads.h",
+ "arch/x64/sysroot/include/zircon/utc.h",
+ "arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc",
+ "arch/x64/sysroot/include/zircon/status.h",
+ "arch/x64/sysroot/include/zircon/exception.h"
+ ],
+ "include_dir": "arch/x64/sysroot/include",
"link_libs": [
- "arch/x64/sysroot/lib/Scrt1.o",
- "arch/x64/sysroot/lib/libc.so",
- "arch/x64/sysroot/lib/libdl.so",
- "arch/x64/sysroot/lib/libm.so",
- "arch/x64/sysroot/lib/libpthread.so",
- "arch/x64/sysroot/lib/librt.so",
+ "arch/x64/sysroot/lib/libc.so",
+ "arch/x64/sysroot/lib/libdl.so",
+ "arch/x64/sysroot/lib/libm.so",
+ "arch/x64/sysroot/lib/libpthread.so",
+ "arch/x64/sysroot/lib/librt.so",
+ "arch/x64/sysroot/lib/Scrt1.o",
"arch/x64/sysroot/lib/libzircon.so"
- ],
+ ],
"root": "arch/x64/sysroot"
}
}
diff --git a/pkg/trace-engine/meta.json b/pkg/trace-engine/meta.json
deleted file mode 100644
index 8856e4e..0000000
--- a/pkg/trace-engine/meta.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/e7/2a14a0b645f41576a9d25e89239df92cd488d0.debug",
- "dist": "arch/arm64/dist/libtrace-engine.so",
- "link": "arch/arm64/lib/libtrace-engine.so"
- },
- "x64": {
- "debug": ".build-id/db/dab49d734285639cadc0b2eb151b302ecb2edf.debug",
- "dist": "arch/x64/dist/libtrace-engine.so",
- "link": "arch/x64/lib/libtrace-engine.so"
- }
- },
- "deps": [],
- "format": "shared",
- "headers": [],
- "include_dir": "pkg/trace-engine/include",
- "name": "trace-engine",
- "root": "pkg/trace-engine",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/vulkan/meta.json b/pkg/vulkan/meta.json
deleted file mode 100644
index 440ecf0..0000000
--- a/pkg/vulkan/meta.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "binaries": {
- "arm64": {
- "debug": ".build-id/13/1673e529cae5f1.debug",
- "dist": "arch/arm64/dist/libvulkan.so",
- "link": "arch/arm64/lib/libvulkan.so"
- },
- "x64": {
- "debug": ".build-id/72/f8518d550ec0aa.debug",
- "dist": "arch/x64/dist/libvulkan.so",
- "link": "arch/x64/lib/libvulkan.so"
- }
- },
- "deps": [
- "fdio",
- "trace-engine"
- ],
- "format": "shared",
- "headers": [],
- "include_dir": "pkg/vulkan/include",
- "name": "vulkan",
- "root": "pkg/vulkan",
- "type": "cc_prebuilt_library"
-}
\ No newline at end of file
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_core_validation.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_core_validation.json
deleted file mode 100644
index 94887e6..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_core_validation.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "file_format_version" : "1.1.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_core_validation",
- "type": "GLOBAL",
- "library_path": "libVkLayer_core_validation.so",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "6"
- }
- ],
- "device_extensions": [
- {
- "name": "VK_EXT_debug_marker",
- "spec_version": "4",
- "entrypoints": ["vkDebugMarkerSetObjectTagEXT",
- "vkDebugMarkerSetObjectNameEXT",
- "vkCmdDebugMarkerBeginEXT",
- "vkCmdDebugMarkerEndEXT",
- "vkCmdDebugMarkerInsertEXT"
- ]
- },
- {
- "name": "VK_EXT_validation_cache",
- "spec_version": "1",
- "entrypoints": ["vkCreateValidationCacheEXT",
- "vkDestroyValidationCacheEXT",
- "vkGetValidationCacheDataEXT",
- "vkMergeValidationCachesEXT"
- ]
- }
- ]
- }
-}
-
-
-
-
-
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_image_pipe_swapchain.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_image_pipe_swapchain.json
deleted file mode 100644
index 7c6ebe6..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_image_pipe_swapchain.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_GOOGLE_image_pipe_swapchain",
- "type": "GLOBAL",
- "library_path": "libVkLayer_image_pipe_swapchain.so",
- "api_version": "1.0.38",
- "implementation_version": "1",
- "description": "Image Pipe Swapchain",
- "disable_environment": {
- "DISABLE_IMAGEPIPE_SWAPCHAIN_LAYER": "1"
- },
- "instance_extensions": [
- { "name": "VK_KHR_surface", "spec_version": "25" },
- { "name": "VK_KHR_magma_surface", "spec_version": "1" }
- ],
- "device_extensions": [
- { "name": "VK_KHR_swapchain", "spec_version": "68" }
- ]
- }
-}
\ No newline at end of file
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_object_tracker.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_object_tracker.json
deleted file mode 100644
index 3da8c58..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_object_tracker.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "file_format_version" : "1.1.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_object_tracker",
- "type": "GLOBAL",
- "library_path": "libVkLayer_object_tracker.so",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "6"
- }
- ],
- "device_extensions": [
- {
- "name": "VK_EXT_debug_marker",
- "spec_version": "4",
- "entrypoints": ["vkDebugMarkerSetObjectTagEXT",
- "vkDebugMarkerSetObjectNameEXT",
- "vkCmdDebugMarkerBeginEXT",
- "vkCmdDebugMarkerEndEXT",
- "vkCmdDebugMarkerInsertEXT"
- ]
- }
- ]
- }
-}
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_parameter_validation.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_parameter_validation.json
deleted file mode 100644
index 83018ed..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_parameter_validation.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "file_format_version" : "1.1.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_parameter_validation",
- "type": "GLOBAL",
- "library_path": "libVkLayer_parameter_validation.so",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "6"
- }
- ],
- "device_extensions": [
- {
- "name": "VK_EXT_debug_marker",
- "spec_version": "4",
- "entrypoints": ["vkDebugMarkerSetObjectTagEXT",
- "vkDebugMarkerSetObjectNameEXT",
- "vkCmdDebugMarkerBeginEXT",
- "vkCmdDebugMarkerEndEXT",
- "vkCmdDebugMarkerInsertEXT"
- ]
- }
- ]
- }
-}
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_standard_validation.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_standard_validation.json
deleted file mode 100644
index ccf4189..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_standard_validation.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "file_format_version": "1.1.1",
- "layer": {
- "name": "VK_LAYER_LUNARG_standard_validation",
- "type": "GLOBAL",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "LunarG Standard Validation",
- "component_layers": [
- "VK_LAYER_GOOGLE_threading",
- "VK_LAYER_LUNARG_parameter_validation",
- "VK_LAYER_LUNARG_object_tracker",
- "VK_LAYER_LUNARG_core_validation",
- "VK_LAYER_GOOGLE_unique_objects"
- ]
- }
-}
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_threading.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_threading.json
deleted file mode 100644
index 2e162b2..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_threading.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "file_format_version" : "1.1.0",
- "layer" : {
- "name": "VK_LAYER_GOOGLE_threading",
- "type": "GLOBAL",
- "library_path": "libVkLayer_threading.so",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "Google Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "6"
- }
- ]
- }
-}
diff --git a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_unique_objects.json b/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_unique_objects.json
deleted file mode 100644
index 82ad4e7..0000000
--- a/pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_unique_objects.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.1.0",
- "layer" : {
- "name": "VK_LAYER_GOOGLE_unique_objects",
- "type": "GLOBAL",
- "library_path": "libVkLayer_unique_objects.so",
- "api_version": "1.0.68",
- "implementation_version": "1",
- "description": "Google Validation Layer"
- }
-}
diff --git a/pkg/vulkan_layers/meta.json b/pkg/vulkan_layers/meta.json
deleted file mode 100644
index f5355b7..0000000
--- a/pkg/vulkan_layers/meta.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "binaries": {
- "arm64": [
- "arch/arm64/dist/libVkLayer_core_validation.so",
- "arch/arm64/dist/libVkLayer_threading.so",
- "arch/arm64/dist/libVkLayer_unique_objects.so",
- "arch/arm64/dist/libVkLayer_parameter_validation.so",
- "arch/arm64/dist/libVkLayer_object_tracker.so",
- "arch/arm64/dist/libVkLayer_image_pipe_swapchain.so"
- ],
- "x64": [
- "arch/x64/dist/libVkLayer_core_validation.so",
- "arch/x64/dist/libVkLayer_threading.so",
- "arch/x64/dist/libVkLayer_unique_objects.so",
- "arch/x64/dist/libVkLayer_parameter_validation.so",
- "arch/x64/dist/libVkLayer_object_tracker.so",
- "arch/x64/dist/libVkLayer_image_pipe_swapchain.so"
- ]
- },
- "name": "vulkan_layers",
- "resources": [
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_core_validation.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_parameter_validation.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_threading.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_unique_objects.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_object_tracker.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_standard_validation.json",
- "pkg/vulkan_layers/data/vulkan/explicit_layer.d/VkLayer_image_pipe_swapchain.json"
- ],
- "root": "pkg/vulkan_layers",
- "type": "loadable_module"
-}
\ No newline at end of file
diff --git a/pkg/zx/bti.cc b/pkg/zx/bti.cc
new file mode 100644
index 0000000..bd53051
--- /dev/null
+++ b/pkg/zx/bti.cc
@@ -0,0 +1,15 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/bti.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t bti::create(const iommu& iommu, uint32_t options, uint64_t bti_id, bti* result) {
+ return zx_bti_create(iommu.get(), options, bti_id, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/bti.cpp b/pkg/zx/bti.cpp
deleted file mode 100644
index 436177d..0000000
--- a/pkg/zx/bti.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/bti.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t bti::create(const iommu& iommu, uint32_t options, uint64_t bti_id, bti* result) {
- return zx_bti_create(iommu.get(), options, bti_id, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/channel.cc b/pkg/zx/channel.cc
new file mode 100644
index 0000000..39b4da6
--- /dev/null
+++ b/pkg/zx/channel.cc
@@ -0,0 +1,23 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/channel.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t channel::create(uint32_t flags, channel* endpoint0, channel* endpoint1) {
+ // Ensure aliasing of both out parameters to the same container
+ // has a well-defined result, and does not leak.
+ channel h0;
+ channel h1;
+ zx_status_t status =
+ zx_channel_create(flags, h0.reset_and_get_address(), h1.reset_and_get_address());
+ endpoint0->reset(h0.release());
+ endpoint1->reset(h1.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/channel.cpp b/pkg/zx/channel.cpp
deleted file mode 100644
index bbf84bb..0000000
--- a/pkg/zx/channel.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/channel.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t channel::create(uint32_t flags, channel* endpoint0,
- channel* endpoint1) {
- // Ensure aliasing of both out parameters to the same container
- // has a well-defined result, and does not leak.
- channel h0;
- channel h1;
- zx_status_t status = zx_channel_create(flags,
- h0.reset_and_get_address(),
- h1.reset_and_get_address());
- endpoint0->reset(h0.release());
- endpoint1->reset(h1.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/debuglog.cc b/pkg/zx/debuglog.cc
new file mode 100644
index 0000000..030c012
--- /dev/null
+++ b/pkg/zx/debuglog.cc
@@ -0,0 +1,15 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/debuglog.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t debuglog::create(const resource& resource, uint32_t options, debuglog* result) {
+ return zx_debuglog_create(resource.get(), options, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/debuglog.cpp b/pkg/zx/debuglog.cpp
deleted file mode 100644
index 05ee86d..0000000
--- a/pkg/zx/debuglog.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/debuglog.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t debuglog::create(const resource& resource, uint32_t options, debuglog* result) {
- return zx_debuglog_create(resource.get(), options, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/event.cc b/pkg/zx/event.cc
new file mode 100644
index 0000000..538aa99
--- /dev/null
+++ b/pkg/zx/event.cc
@@ -0,0 +1,15 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/event.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t event::create(uint32_t options, event* result) {
+ return zx_event_create(options, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/event.cpp b/pkg/zx/event.cpp
deleted file mode 100644
index 4539a68..0000000
--- a/pkg/zx/event.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/event.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t event::create(uint32_t options, event* result) {
- return zx_event_create(options, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/eventpair.cc b/pkg/zx/eventpair.cc
new file mode 100644
index 0000000..480ea07
--- /dev/null
+++ b/pkg/zx/eventpair.cc
@@ -0,0 +1,23 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/eventpair.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t eventpair::create(uint32_t flags, eventpair* endpoint0, eventpair* endpoint1) {
+ // Ensure aliasing of both out parameters to the same container
+ // has a well-defined result, and does not leak.
+ eventpair h0;
+ eventpair h1;
+ zx_status_t status =
+ zx_eventpair_create(flags, h0.reset_and_get_address(), h1.reset_and_get_address());
+ endpoint0->reset(h0.release());
+ endpoint1->reset(h1.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/eventpair.cpp b/pkg/zx/eventpair.cpp
deleted file mode 100644
index f561e14..0000000
--- a/pkg/zx/eventpair.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/eventpair.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t eventpair::create(uint32_t flags, eventpair* endpoint0,
- eventpair* endpoint1) {
- // Ensure aliasing of both out parameters to the same container
- // has a well-defined result, and does not leak.
- eventpair h0;
- eventpair h1;
- zx_status_t status = zx_eventpair_create(
- flags, h0.reset_and_get_address(),
- h1.reset_and_get_address());
- endpoint0->reset(h0.release());
- endpoint1->reset(h1.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/fifo.cc b/pkg/zx/fifo.cc
new file mode 100644
index 0000000..ea0e7d1
--- /dev/null
+++ b/pkg/zx/fifo.cc
@@ -0,0 +1,24 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/fifo.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t fifo::create(uint32_t elem_count, uint32_t elem_size, uint32_t options, fifo* out0,
+ fifo* out1) {
+ // Ensure aliasing of both out parameters to the same container
+ // has a well-defined result, and does not leak.
+ fifo h0;
+ fifo h1;
+ zx_status_t status = zx_fifo_create(elem_count, elem_size, options, h0.reset_and_get_address(),
+ h1.reset_and_get_address());
+ out0->reset(h0.release());
+ out1->reset(h1.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/fifo.cpp b/pkg/zx/fifo.cpp
deleted file mode 100644
index 27f965f..0000000
--- a/pkg/zx/fifo.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/fifo.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t fifo::create(uint32_t elem_count, uint32_t elem_size,
- uint32_t options, fifo* out0, fifo* out1) {
- // Ensure aliasing of both out parameters to the same container
- // has a well-defined result, and does not leak.
- fifo h0;
- fifo h1;
- zx_status_t status = zx_fifo_create(
- elem_count, elem_size, options, h0.reset_and_get_address(),
- h1.reset_and_get_address());
- out0->reset(h0.release());
- out1->reset(h1.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/guest.cc b/pkg/zx/guest.cc
new file mode 100644
index 0000000..b78effe
--- /dev/null
+++ b/pkg/zx/guest.cc
@@ -0,0 +1,20 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/guest.h>
+
+#include <zircon/syscalls.h>
+
+#include <lib/zx/vmar.h>
+
+namespace zx {
+
+zx_status_t guest::create(const resource& resource, uint32_t options, guest* guest, vmar* vmar) {
+ // Assume |resource|, |guest| and |vmar| must refer to different containers,
+ // due to strict aliasing.
+ return zx_guest_create(resource.get(), options, guest->reset_and_get_address(),
+ vmar->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/guest.cpp b/pkg/zx/guest.cpp
deleted file mode 100644
index f3d6029..0000000
--- a/pkg/zx/guest.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/guest.h>
-
-#include <zircon/syscalls.h>
-
-#include <lib/zx/vmar.h>
-
-namespace zx {
-
-zx_status_t guest::create(const resource& resource, uint32_t options,
- guest* guest, vmar* vmar) {
- // Assume |resource|, |guest| and |vmar| must refer to different containers,
- // due to strict aliasing.
- return zx_guest_create(
- resource.get(), options, guest->reset_and_get_address(),
- vmar->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/include/lib/zx/bti.h b/pkg/zx/include/lib/zx/bti.h
index 0a66716..4ce438b 100644
--- a/pkg/zx/include/lib/zx/bti.h
+++ b/pkg/zx/include/lib/zx/bti.h
@@ -13,36 +13,36 @@
namespace zx {
-class bti : public object<bti> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_BTI;
+class bti final : public object<bti> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_BTI;
- constexpr bti() = default;
+ constexpr bti() = default;
- explicit bti(zx_handle_t value) : object(value) {}
+ explicit bti(zx_handle_t value) : object(value) {}
- explicit bti(handle&& h) : object(h.release()) {}
+ explicit bti(handle&& h) : object(h.release()) {}
- bti(bti&& other) : object(other.release()) {}
+ bti(bti&& other) : object(other.release()) {}
- bti& operator=(bti&& other) {
- reset(other.release());
- return *this;
- }
+ bti& operator=(bti&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const iommu& iommu, uint32_t options, uint64_t bti_id, bti* result);
+ static zx_status_t create(const iommu& iommu, uint32_t options, uint64_t bti_id, bti* result);
- zx_status_t pin(uint32_t options, const vmo& vmo, uint64_t offset, uint64_t size,
- zx_paddr_t* addrs, size_t addrs_count, pmt* pmt) const {
- return zx_bti_pin(get(), options, vmo.get(), offset, size, addrs, addrs_count,
- pmt->reset_and_get_address());
- }
+ zx_status_t pin(uint32_t options, const vmo& vmo, uint64_t offset, uint64_t size,
+ zx_paddr_t* addrs, size_t addrs_count, pmt* pmt) const {
+ return zx_bti_pin(get(), options, vmo.get(), offset, size, addrs, addrs_count,
+ pmt->reset_and_get_address());
+ }
- zx_status_t release_quarantine() const { return zx_bti_release_quarantine(get()); }
+ zx_status_t release_quarantine() const { return zx_bti_release_quarantine(get()); }
};
using unowned_bti = unowned<bti>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_BTI_H_
diff --git a/pkg/zx/include/lib/zx/channel.h b/pkg/zx/include/lib/zx/channel.h
index bd28ca1..c5c7283 100644
--- a/pkg/zx/include/lib/zx/channel.h
+++ b/pkg/zx/include/lib/zx/channel.h
@@ -11,56 +11,61 @@
namespace zx {
-class channel : public object<channel> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_CHANNEL;
+class channel final : public object<channel> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_CHANNEL;
- constexpr channel() = default;
+ constexpr channel() = default;
- explicit channel(zx_handle_t value) : object(value) {}
+ explicit channel(zx_handle_t value) : object(value) {}
- explicit channel(handle&& h) : object(h.release()) {}
+ explicit channel(handle&& h) : object(h.release()) {}
- channel(channel&& other) : object(other.release()) {}
+ channel(channel&& other) : object(other.release()) {}
- channel& operator=(channel&& other) {
- reset(other.release());
- return *this;
- }
+ channel& operator=(channel&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t flags, channel* endpoint0,
- channel* endpoint1);
+ static zx_status_t create(uint32_t flags, channel* endpoint0, channel* endpoint1);
- zx_status_t read(uint32_t flags, void* bytes, uint32_t num_bytes,
- uint32_t* actual_bytes, zx_handle_t* handles,
- uint32_t num_handles, uint32_t* actual_handles) const {
- return zx_channel_read(get(), flags, bytes, handles, num_bytes,
- num_handles, actual_bytes, actual_handles);
- }
+ zx_status_t read(uint32_t flags, void* bytes, zx_handle_t* handles, uint32_t num_bytes,
+ uint32_t num_handles, uint32_t* actual_bytes, uint32_t* actual_handles) const {
+ return zx_channel_read(get(), flags, bytes, handles, num_bytes, num_handles, actual_bytes,
+ actual_handles);
+ }
- zx_status_t read_etc(uint32_t flags, void* bytes, uint32_t num_bytes,
- uint32_t* actual_bytes, zx_handle_info_t* handles,
- uint32_t num_handles, uint32_t* actual_handles) const {
- return zx_channel_read_etc(get(), flags, bytes, handles, num_bytes,
- num_handles, actual_bytes, actual_handles);
- }
-
- zx_status_t write(uint32_t flags, const void* bytes, uint32_t num_bytes,
- const zx_handle_t* handles, uint32_t num_handles) const {
- return zx_channel_write(get(), flags, bytes, num_bytes, handles,
- num_handles);
- }
-
- zx_status_t call(uint32_t flags, zx::time deadline,
- const zx_channel_call_args_t* args,
- uint32_t* actual_bytes, uint32_t* actual_handles) const {
- return zx_channel_call(get(), flags, deadline.get(), args, actual_bytes,
+ zx_status_t read_etc(uint32_t flags, void* bytes, zx_handle_info_t* handles, uint32_t num_bytes,
+ uint32_t num_handles, uint32_t* actual_bytes,
+ uint32_t* actual_handles) const {
+ return zx_channel_read_etc(get(), flags, bytes, handles, num_bytes, num_handles, actual_bytes,
actual_handles);
- }
+ }
+
+ zx_status_t write(uint32_t flags, const void* bytes, uint32_t num_bytes,
+ const zx_handle_t* handles, uint32_t num_handles) const {
+ return zx_channel_write(get(), flags, bytes, num_bytes, handles, num_handles);
+ }
+
+ zx_status_t write_etc(uint32_t flags, const void* bytes, uint32_t num_bytes,
+ zx_handle_disposition_t* handles, uint32_t num_handles) {
+ return zx_channel_write_etc(get(), flags, bytes, num_bytes, handles, num_handles);
+ }
+
+ zx_status_t call(uint32_t flags, zx::time deadline, const zx_channel_call_args_t* args,
+ uint32_t* actual_bytes, uint32_t* actual_handles) const {
+ return zx_channel_call(get(), flags, deadline.get(), args, actual_bytes, actual_handles);
+ }
+
+ zx_status_t call_etc(uint32_t flags, zx::time deadline, zx_channel_call_etc_args_t* args,
+ uint32_t* actual_bytes, uint32_t* actual_handles) const {
+ return zx_channel_call_etc(get(), flags, deadline.get(), args, actual_bytes, actual_handles);
+ }
};
using unowned_channel = unowned<channel>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_CHANNEL_H_
diff --git a/pkg/zx/include/lib/zx/clock.h b/pkg/zx/include/lib/zx/clock.h
new file mode 100644
index 0000000..39d1b80
--- /dev/null
+++ b/pkg/zx/include/lib/zx/clock.h
@@ -0,0 +1,102 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ZX_CLOCK_H_
+#define LIB_ZX_CLOCK_H_
+
+#include <lib/zx/handle.h>
+#include <lib/zx/object.h>
+#include <lib/zx/time.h>
+#include <zircon/syscalls/clock.h>
+
+namespace zx {
+
+class clock final : public object<clock> {
+ public:
+ class update_args {
+ public:
+ constexpr update_args() = default;
+
+ update_args& reset() {
+ options_ = 0;
+ return *this;
+ }
+
+ update_args& set_value(zx::time value) {
+ args_.value = value.get();
+ options_ |= ZX_CLOCK_UPDATE_OPTION_VALUE_VALID;
+ return *this;
+ }
+
+ update_args& set_rate_adjust(int32_t rate) {
+ args_.rate_adjust = rate;
+ options_ |= ZX_CLOCK_UPDATE_OPTION_RATE_ADJUST_VALID;
+ return *this;
+ }
+
+ update_args& set_error_bound(uint64_t error_bound) {
+ args_.error_bound = error_bound;
+ options_ |= ZX_CLOCK_UPDATE_OPTION_ERROR_BOUND_VALID;
+ return *this;
+ }
+
+ private:
+ friend class ::zx::clock;
+ zx_clock_update_args_v1_t args_{};
+ uint64_t options_ = 0;
+ };
+
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_CLOCK;
+
+ // TODO(johngro) : remove this alias once we remove the static get method from
+ // this class. This static get method will no longer be needed once UTC
+ // leaves the kernel, and "thread" time becomes fetch-able only from a
+ // get_info request. At that point in time, zx_clock_get will disappear and
+ // the only kernel provided sources of time will be get_monotonic and ticks.
+ zx_handle_t get_handle() const { return object_base::get(); }
+
+ constexpr clock() = default;
+
+ explicit clock(zx_handle_t value) : object(value) {}
+
+ explicit clock(handle&& h) : object(h.release()) {}
+
+ clock(clock&& other) : object(other.release()) {}
+
+ clock& operator=(clock&& other) {
+ reset(other.release());
+ return *this;
+ }
+
+ static zx_status_t create(uint64_t options, const zx_clock_create_args_v1* args, clock* result) {
+ options = (options & ~ZX_CLOCK_ARGS_VERSION_MASK) |
+ ((args != nullptr) ? ZX_CLOCK_ARGS_VERSION(1) : 0);
+
+ return zx_clock_create(options, args, result->reset_and_get_address());
+ }
+
+ zx_status_t read(zx_time_t* now_out) const { return zx_clock_read(value_, now_out); }
+
+ zx_status_t get_details(zx_clock_details_v1_t* details_out) const {
+ return zx_clock_get_details(value_, ZX_CLOCK_ARGS_VERSION(1), details_out);
+ }
+
+ zx_status_t update(const update_args& args) const {
+ uint64_t options = args.options_ | ZX_CLOCK_ARGS_VERSION(1);
+ return zx_clock_update(value_, options, &args.args_);
+ }
+
+ template <zx_clock_t kClockId>
+ static zx_status_t get(basic_time<kClockId>* result) {
+ return zx_clock_get(kClockId, result->get_address());
+ }
+
+ static time get_monotonic() { return time(zx_clock_get_monotonic()); }
+};
+
+using unowned_clock = unowned<clock>;
+
+} // namespace zx
+
+#endif // LIB_ZX_CLOCK_H_
diff --git a/pkg/zx/include/lib/zx/debuglog.h b/pkg/zx/include/lib/zx/debuglog.h
index 1b00042..2e7cf41 100644
--- a/pkg/zx/include/lib/zx/debuglog.h
+++ b/pkg/zx/include/lib/zx/debuglog.h
@@ -11,36 +11,36 @@
namespace zx {
-class debuglog : public object<debuglog> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_LOG;
+class debuglog final : public object<debuglog> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_LOG;
- constexpr debuglog() = default;
+ constexpr debuglog() = default;
- explicit debuglog(zx_handle_t value) : object(value) {}
+ explicit debuglog(zx_handle_t value) : object(value) {}
- explicit debuglog(handle&& h) : object(h.release()) {}
+ explicit debuglog(handle&& h) : object(h.release()) {}
- debuglog(debuglog&& other) : object(other.release()) {}
+ debuglog(debuglog&& other) : object(other.release()) {}
- debuglog& operator=(debuglog&& other) {
- reset(other.release());
- return *this;
- }
+ debuglog& operator=(debuglog&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& resource, uint32_t options, debuglog* result);
+ static zx_status_t create(const resource& resource, uint32_t options, debuglog* result);
- zx_status_t write(uint32_t options, const void* buffer, size_t buffer_size) const {
- return zx_debuglog_write(get(), options, buffer, buffer_size);
- }
+ zx_status_t write(uint32_t options, const void* buffer, size_t buffer_size) const {
+ return zx_debuglog_write(get(), options, buffer, buffer_size);
+ }
- zx_status_t read(uint32_t options, void* buffer, size_t buffer_size) const {
- return zx_debuglog_read(get(), options, buffer, buffer_size);
- }
+ zx_status_t read(uint32_t options, void* buffer, size_t buffer_size) const {
+ return zx_debuglog_read(get(), options, buffer, buffer_size);
+ }
};
using unowned_debuglog = unowned<debuglog>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_DEBUGLOG_H_
diff --git a/pkg/zx/include/lib/zx/event.h b/pkg/zx/include/lib/zx/event.h
index 590c4c1..a9d62af 100644
--- a/pkg/zx/include/lib/zx/event.h
+++ b/pkg/zx/include/lib/zx/event.h
@@ -10,28 +10,28 @@
namespace zx {
-class event : public object<event> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_EVENT;
+class event final : public object<event> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_EVENT;
- constexpr event() = default;
+ constexpr event() = default;
- explicit event(zx_handle_t value) : object(value) {}
+ explicit event(zx_handle_t value) : object(value) {}
- explicit event(handle&& h) : object(h.release()) {}
+ explicit event(handle&& h) : object(h.release()) {}
- event(event&& other) : object(other.release()) {}
+ event(event&& other) : object(other.release()) {}
- event& operator=(event&& other) {
- reset(other.release());
- return *this;
- }
+ event& operator=(event&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t options, event* result);
+ static zx_status_t create(uint32_t options, event* result);
};
using unowned_event = unowned<event>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_EVENT_H_
diff --git a/pkg/zx/include/lib/zx/eventpair.h b/pkg/zx/include/lib/zx/eventpair.h
index 56d094a..a46a6b0 100644
--- a/pkg/zx/include/lib/zx/eventpair.h
+++ b/pkg/zx/include/lib/zx/eventpair.h
@@ -10,29 +10,28 @@
namespace zx {
-class eventpair : public object<eventpair> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_EVENTPAIR;
+class eventpair final : public object<eventpair> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_EVENTPAIR;
- constexpr eventpair() = default;
+ constexpr eventpair() = default;
- explicit eventpair(zx_handle_t value) : object(value) {}
+ explicit eventpair(zx_handle_t value) : object(value) {}
- explicit eventpair(handle&& h) : object(h.release()) {}
+ explicit eventpair(handle&& h) : object(h.release()) {}
- eventpair(eventpair&& other) : object(other.release()) {}
+ eventpair(eventpair&& other) : object(other.release()) {}
- eventpair& operator=(eventpair&& other) {
- reset(other.release());
- return *this;
- }
+ eventpair& operator=(eventpair&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t options, eventpair* endpoint0,
- eventpair* endpoint1);
+ static zx_status_t create(uint32_t options, eventpair* endpoint0, eventpair* endpoint1);
};
using unowned_eventpair = unowned<eventpair>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_EVENTPAIR_H_
diff --git a/pkg/zx/include/lib/zx/exception.h b/pkg/zx/include/lib/zx/exception.h
new file mode 100644
index 0000000..d5cc756
--- /dev/null
+++ b/pkg/zx/include/lib/zx/exception.h
@@ -0,0 +1,43 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ZX_EXCEPTION_H_
+#define LIB_ZX_EXCEPTION_H_
+
+#include <lib/zx/handle.h>
+#include <lib/zx/object.h>
+#include <lib/zx/process.h>
+#include <lib/zx/thread.h>
+
+namespace zx {
+
+class exception final : public object<exception> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_EXCEPTION;
+
+ constexpr exception() = default;
+
+ explicit exception(zx_handle_t value) : object(value) {}
+
+ explicit exception(handle&& h) : object(h.release()) {}
+
+ exception(exception&& other) : object(other.release()) {}
+
+ exception& operator=(exception&& other) {
+ reset(other.release());
+ return *this;
+ }
+
+ zx_status_t get_thread(thread* thread) const {
+ return zx_exception_get_thread(get(), thread->reset_and_get_address());
+ }
+
+ zx_status_t get_process(process* process) const {
+ return zx_exception_get_process(get(), process->reset_and_get_address());
+ }
+};
+
+} // namespace zx
+
+#endif // LIB_ZX_EXCEPTION_H_
diff --git a/pkg/zx/include/lib/zx/fifo.h b/pkg/zx/include/lib/zx/fifo.h
index aeab229..c95648b 100644
--- a/pkg/zx/include/lib/zx/fifo.h
+++ b/pkg/zx/include/lib/zx/fifo.h
@@ -10,38 +10,38 @@
namespace zx {
-class fifo : public object<fifo> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_FIFO;
+class fifo final : public object<fifo> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_FIFO;
- constexpr fifo() = default;
+ constexpr fifo() = default;
- explicit fifo(zx_handle_t value) : object(value) {}
+ explicit fifo(zx_handle_t value) : object(value) {}
- explicit fifo(handle&& h) : object(h.release()) {}
+ explicit fifo(handle&& h) : object(h.release()) {}
- fifo(fifo&& other) : object(other.release()) {}
+ fifo(fifo&& other) : object(other.release()) {}
- fifo& operator=(fifo&& other) {
- reset(other.release());
- return *this;
- }
+ fifo& operator=(fifo&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t elem_count, uint32_t elem_size,
- uint32_t options, fifo* out0, fifo* out1);
+ static zx_status_t create(uint32_t elem_count, uint32_t elem_size, uint32_t options, fifo* out0,
+ fifo* out1);
- zx_status_t write(size_t elem_size, const void* buffer, size_t count, size_t* actual_count) const {
- return zx_fifo_write(get(), elem_size, buffer, count, actual_count);
- }
+ zx_status_t write(size_t elem_size, const void* buffer, size_t count,
+ size_t* actual_count) const {
+ return zx_fifo_write(get(), elem_size, buffer, count, actual_count);
+ }
- zx_status_t read(size_t elem_size, void* buffer, size_t count, size_t* actual_count) const {
- return zx_fifo_read(get(), elem_size, buffer, count, actual_count);
- }
-
+ zx_status_t read(size_t elem_size, void* buffer, size_t count, size_t* actual_count) const {
+ return zx_fifo_read(get(), elem_size, buffer, count, actual_count);
+ }
};
using unowned_fifo = unowned<fifo>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_FIFO_H_
diff --git a/pkg/zx/include/lib/zx/guest.h b/pkg/zx/include/lib/zx/guest.h
index 037bc6d..2c4c7ef 100644
--- a/pkg/zx/include/lib/zx/guest.h
+++ b/pkg/zx/include/lib/zx/guest.h
@@ -13,34 +13,33 @@
namespace zx {
-class guest : public object<guest> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_GUEST;
+class guest final : public object<guest> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_GUEST;
- constexpr guest() = default;
+ constexpr guest() = default;
- explicit guest(zx_handle_t value) : object(value) {}
+ explicit guest(zx_handle_t value) : object(value) {}
- explicit guest(handle&& h) : object(h.release()) {}
+ explicit guest(handle&& h) : object(h.release()) {}
- guest(guest&& other) : object(other.release()) {}
+ guest(guest&& other) : object(other.release()) {}
- guest& operator=(guest&& other) {
- reset(other.release());
- return *this;
- }
+ guest& operator=(guest&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& resource, uint32_t options,
- guest* guest, vmar* vmar);
+ static zx_status_t create(const resource& resource, uint32_t options, guest* guest, vmar* vmar);
- zx_status_t set_trap(uint32_t kind, zx_gpaddr_t addr, size_t len,
- const port& port, uint64_t key) {
- return zx_guest_set_trap(get(), kind, addr, len, port.get(), key);
- }
+ zx_status_t set_trap(uint32_t kind, zx_gpaddr_t addr, size_t len, const port& port,
+ uint64_t key) const {
+ return zx_guest_set_trap(get(), kind, addr, len, port.get(), key);
+ }
};
using unowned_guest = unowned<guest>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_GUEST_H_
diff --git a/pkg/zx/include/lib/zx/handle.h b/pkg/zx/include/lib/zx/handle.h
index 3daca00..930161d 100644
--- a/pkg/zx/include/lib/zx/handle.h
+++ b/pkg/zx/include/lib/zx/handle.h
@@ -12,6 +12,6 @@
using handle = object<void>;
using unowned_handle = unowned<handle>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_HANDLE_H_
diff --git a/pkg/zx/include/lib/zx/interrupt.h b/pkg/zx/include/lib/zx/interrupt.h
index b3d3eb7..bb55a08 100644
--- a/pkg/zx/include/lib/zx/interrupt.h
+++ b/pkg/zx/include/lib/zx/interrupt.h
@@ -7,54 +7,56 @@
#include <lib/zx/handle.h>
#include <lib/zx/object.h>
+#include <lib/zx/port.h>
#include <lib/zx/resource.h>
#include <lib/zx/time.h>
+#include <lib/zx/vcpu.h>
namespace zx {
-class interrupt : public object<interrupt> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_INTERRUPT;
+class interrupt final : public object<interrupt> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_INTERRUPT;
- constexpr interrupt() = default;
+ constexpr interrupt() = default;
- explicit interrupt(zx_handle_t value) : object(value) {}
+ explicit interrupt(zx_handle_t value) : object(value) {}
- explicit interrupt(handle&& h) : object(h.release()) {}
+ explicit interrupt(handle&& h) : object(h.release()) {}
- interrupt(interrupt&& other) : object(other.release()) {}
+ interrupt(interrupt&& other) : object(other.release()) {}
- interrupt& operator=(interrupt&& other) {
- reset(other.release());
- return *this;
- }
+ interrupt& operator=(interrupt&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& resource, uint32_t vector,
- uint32_t options, interrupt* result);
+ static zx_status_t create(const resource& resource, uint32_t vector, uint32_t options,
+ interrupt* result);
- zx_status_t wait(zx::time* timestamp) {
- return zx_interrupt_wait(get(), timestamp->get_address());
- }
+ zx_status_t wait(zx::time* timestamp) const {
+ return zx_interrupt_wait(get(), timestamp ? timestamp->get_address() : nullptr);
+ }
- zx_status_t destroy() {
- return zx_interrupt_destroy(get());
- }
+ zx_status_t destroy() const { return zx_interrupt_destroy(get()); }
- zx_status_t trigger(uint32_t options, zx::time timestamp) {
- return zx_interrupt_trigger(get(), options, timestamp.get());
- }
+ zx_status_t trigger(uint32_t options, zx::time timestamp) const {
+ return zx_interrupt_trigger(get(), options, timestamp.get());
+ }
- zx_status_t bind(zx_handle_t porth, uint64_t key, uint32_t options) {
- return zx_interrupt_bind(get(), porth, key, options);
- }
+ zx_status_t bind(const zx::port& port, uint64_t key, uint32_t options) const {
+ return zx_interrupt_bind(get(), port.get(), key, options);
+ }
- zx_status_t ack() {
- return zx_interrupt_ack(get());
- }
+ zx_status_t bind_vcpu(const zx::vcpu& vcpu, uint32_t options) const {
+ return zx_interrupt_bind_vcpu(get(), vcpu.get(), options);
+ }
+
+ zx_status_t ack() const { return zx_interrupt_ack(get()); }
};
using unowned_interrupt = unowned<interrupt>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_INTERRUPT_H_
diff --git a/pkg/zx/include/lib/zx/iommu.h b/pkg/zx/include/lib/zx/iommu.h
index 95dc427..b19a2bb 100644
--- a/pkg/zx/include/lib/zx/iommu.h
+++ b/pkg/zx/include/lib/zx/iommu.h
@@ -10,29 +10,29 @@
namespace zx {
-class iommu : public object<iommu> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_IOMMU;
+class iommu final : public object<iommu> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_IOMMU;
- constexpr iommu() = default;
+ constexpr iommu() = default;
- explicit iommu(zx_handle_t value) : object(value) {}
+ explicit iommu(zx_handle_t value) : object(value) {}
- explicit iommu(handle&& h) : object(h.release()) {}
+ explicit iommu(handle&& h) : object(h.release()) {}
- iommu(iommu&& other) : object(other.release()) {}
+ iommu(iommu&& other) : object(other.release()) {}
- iommu& operator=(iommu&& other) {
- reset(other.release());
- return *this;
- }
+ iommu& operator=(iommu&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& resource, uint32_t type, const void* desc,
- size_t desc_size, iommu* result);
+ static zx_status_t create(const resource& resource, uint32_t type, const void* desc,
+ size_t desc_size, iommu* result);
};
using unowned_iommu = unowned<iommu>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_IOMMU_H_
diff --git a/pkg/zx/include/lib/zx/job.h b/pkg/zx/include/lib/zx/job.h
index 3bd7125..7047ffc 100644
--- a/pkg/zx/include/lib/zx/job.h
+++ b/pkg/zx/include/lib/zx/job.h
@@ -6,58 +6,58 @@
#define LIB_ZX_JOB_H_
#include <lib/zx/task.h>
-#include <zircon/process.h>
+#include <lib/zx/process.h>
namespace zx {
class process;
-class job : public task<job> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_JOB;
+class job final : public task<job> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_JOB;
- constexpr job() = default;
+ constexpr job() = default;
- explicit job(zx_handle_t value) : task(value) {}
+ explicit job(zx_handle_t value) : task(value) {}
- explicit job(handle&& h) : task(h.release()) {}
+ explicit job(handle&& h) : task(h.release()) {}
- job(job&& other) : task(other.release()) {}
+ job(job&& other) : task(other.release()) {}
- job& operator=(job&& other) {
- reset(other.release());
- return *this;
- }
+ job& operator=(job&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const zx::job& parent, uint32_t options, job* result);
+ static zx_status_t create(const zx::job& parent, uint32_t options, job* result);
- // Provide strongly-typed overloads, in addition to get_child(handle*).
- using task<job>::get_child;
- zx_status_t get_child(uint64_t koid, zx_rights_t rights,
- job* result) const {
- // Allow for |result| and |this| aliasing the same container.
- job h;
- zx_status_t status = zx_object_get_child(
- value_, koid, rights, h.reset_and_get_address());
- result->reset(h.release());
- return status;
- }
- zx_status_t get_child(uint64_t koid, zx_rights_t rights,
- process* result) const;
+ // Provide strongly-typed overloads, in addition to get_child(handle*).
+ using task<job>::get_child;
+ zx_status_t get_child(uint64_t koid, zx_rights_t rights, job* result) const {
+ // Allow for |result| and |this| aliasing the same container.
+ job h;
+ zx_status_t status = zx_object_get_child(value_, koid, rights, h.reset_and_get_address());
+ result->reset(h.release());
+ return status;
+ }
+ zx_status_t get_child(uint64_t koid, zx_rights_t rights, process* result) const;
- zx_status_t set_policy(uint32_t options, uint32_t topic, const void* policy, uint32_t count) const {
- return zx_job_set_policy(get(), options, topic, policy, count);
- }
+ zx_status_t set_policy(uint32_t options, uint32_t topic, const void* policy,
+ uint32_t count) const {
+ return zx_job_set_policy(get(), options, topic, policy, count);
+ }
- // Ideally this would be called zx::job::default(), but default is a
- // C++ keyword and cannot be used as a function name.
- static inline unowned<job> default_job() {
- return unowned<job>(zx_job_default());
- }
+ zx_status_t set_critical(uint32_t options, const zx::process& process) const {
+ return zx_job_set_critical(get(), options, process.get());
+ }
+
+ // Ideally this would be called zx::job::default(), but default is a
+ // C++ keyword and cannot be used as a function name.
+ static inline unowned<job> default_job() { return unowned<job>(zx_job_default()); }
};
using unowned_job = unowned<job>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_JOB_H_
diff --git a/pkg/zx/include/lib/zx/log.h b/pkg/zx/include/lib/zx/log.h
deleted file mode 100644
index 36b6e22..0000000
--- a/pkg/zx/include/lib/zx/log.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_ZX_LOG_H_
-#define LIB_ZX_LOG_H_
-
-#include <lib/zx/handle.h>
-#include <lib/zx/object.h>
-
-namespace zx {
-
-class log : public object<log> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_LOG;
-
- constexpr log() = default;
-
- explicit log(zx_handle_t value) : object(value) {}
-
- explicit log(handle&& h) : object(h.release()) {}
-
- log(log&& other) : object(other.release()) {}
-
- log& operator=(log&& other) {
- reset(other.release());
- return *this;
- }
-
- static zx_status_t create(uint32_t flags, log* result);
-
- zx_status_t write(uint32_t len, const void* buffer, uint32_t flags) const {
- return zx_log_write(get(), len, buffer, flags);
- }
-
- zx_status_t read(uint32_t len, void* buffer, uint32_t flags) const {
- return zx_log_read(get(), len, buffer, flags);
- }
-};
-
-using unowned_log = unowned<log>;
-
-} // namespace zx
-
-#endif // LIB_ZX_LOG_H_
diff --git a/pkg/zx/include/lib/zx/msi.h b/pkg/zx/include/lib/zx/msi.h
new file mode 100644
index 0000000..cd45a94
--- /dev/null
+++ b/pkg/zx/include/lib/zx/msi.h
@@ -0,0 +1,47 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ZX_MSI_H_
+#define LIB_ZX_MSI_H_
+
+#include <lib/zx/handle.h>
+#include <lib/zx/interrupt.h>
+#include <lib/zx/object.h>
+#include <lib/zx/resource.h>
+#include <lib/zx/vmo.h>
+#include <stdint.h>
+#include <zircon/types.h>
+
+namespace zx {
+
+// This wrapper encompasses both MsiDispatcher MsiAllocationDispatcher due
+// to them only having static members and MsiDispatcher otherwise using the
+// same interface as a zx::interrupt.
+class msi final : public object<msi> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_MSI_ALLOCATION;
+
+ constexpr msi() = default;
+
+ explicit msi(zx_handle_t value) : object(value) {}
+
+ explicit msi(handle&& h) : object(h.release()) {}
+
+ msi(msi&& other) : object(other.release()) {}
+
+ msi& operator=(msi&& other) {
+ reset(other.release());
+ return *this;
+ }
+
+ static zx_status_t allocate(const resource& resource, uint32_t count, msi* result);
+ static zx_status_t create(const msi& msi, uint32_t options, uint32_t msi_id, const vmo& vmo,
+ size_t vmo_offset, interrupt* result);
+};
+
+using unowned_msi = unowned<msi>;
+
+} // namespace zx
+
+#endif // LIB_ZX_MSI_H_
diff --git a/pkg/zx/include/lib/zx/object.h b/pkg/zx/include/lib/zx/object.h
index 57c023c..710b474 100644
--- a/pkg/zx/include/lib/zx/object.h
+++ b/pkg/zx/include/lib/zx/object.h
@@ -5,10 +5,10 @@
#ifndef LIB_ZX_OBJECT_H_
#define LIB_ZX_OBJECT_H_
-#include <zircon/syscalls.h>
-#include <zircon/types.h>
#include <lib/zx/object_traits.h>
#include <lib/zx/time.h>
+#include <zircon/syscalls.h>
+#include <zircon/types.h>
namespace zx {
@@ -22,247 +22,262 @@
//
// The handle is automatically closed when the wrapper is destroyed.
class object_base {
-public:
- void reset(zx_handle_t value = ZX_HANDLE_INVALID) {
- close();
- value_ = value;
+ public:
+ void reset(zx_handle_t value = ZX_HANDLE_INVALID) {
+ close();
+ value_ = value;
+ }
+
+ bool is_valid() const { return value_ != ZX_HANDLE_INVALID; }
+ explicit operator bool() const { return is_valid(); }
+
+ zx_handle_t get() const { return value_; }
+
+ // Reset the underlying handle, and then get the address of the
+ // underlying internal handle storage.
+ //
+ // Note: The intended purpose is to facilitate interactions with C
+ // APIs which expect to be provided a pointer to a handle used as
+ // an out parameter.
+ zx_handle_t* reset_and_get_address() {
+ reset();
+ return &value_;
+ }
+
+ __attribute__((warn_unused_result)) zx_handle_t release() {
+ zx_handle_t result = value_;
+ value_ = ZX_HANDLE_INVALID;
+ return result;
+ }
+
+ zx_status_t get_info(uint32_t topic, void* buffer, size_t buffer_size, size_t* actual_count,
+ size_t* avail_count) const {
+ return zx_object_get_info(get(), topic, buffer, buffer_size, actual_count, avail_count);
+ }
+
+ zx_status_t get_property(uint32_t property, void* value, size_t size) const {
+ return zx_object_get_property(get(), property, value, size);
+ }
+
+ zx_status_t set_property(uint32_t property, const void* value, size_t size) const {
+ return zx_object_set_property(get(), property, value, size);
+ }
+
+ protected:
+ constexpr object_base() : value_(ZX_HANDLE_INVALID) {}
+
+ explicit object_base(zx_handle_t value) : value_(value) {}
+
+ ~object_base() { close(); }
+
+ object_base(const object_base&) = delete;
+
+ void operator=(const object_base&) = delete;
+
+ void close() {
+ if (value_ != ZX_HANDLE_INVALID) {
+ zx_handle_close(value_);
+ value_ = ZX_HANDLE_INVALID;
}
+ }
- bool is_valid() const { return value_ != ZX_HANDLE_INVALID; }
- explicit operator bool() const { return is_valid(); }
-
- zx_handle_t get() const { return value_; }
-
- // Reset the underlying handle, and then get the address of the
- // underlying internal handle storage.
- //
- // Note: The intended purpose is to facilitate interactions with C
- // APIs which expect to be provided a pointer to a handle used as
- // an out parameter.
- zx_handle_t* reset_and_get_address() {
- reset();
- return &value_;
- }
-
- __attribute__((warn_unused_result)) zx_handle_t release() {
- zx_handle_t result = value_;
- value_ = ZX_HANDLE_INVALID;
- return result;
- }
-
-protected:
- constexpr object_base() : value_(ZX_HANDLE_INVALID) {}
-
- explicit object_base(zx_handle_t value) : value_(value) {}
-
- ~object_base() { close(); }
-
- object_base(const object_base&) = delete;
-
- void operator=(const object_base&) = delete;
-
- void close() {
- if (value_ != ZX_HANDLE_INVALID) {
- zx_handle_close(value_);
- value_ = ZX_HANDLE_INVALID;
- }
- }
-
- zx_handle_t value_;
+ zx_handle_t value_;
};
+// Forward declaration for borrow method.
+template <typename T>
+class unowned;
+
// Provides type-safe access to operations on a handle.
-template <typename T> class object : public object_base {
-public:
- constexpr object() = default;
+template <typename T>
+class object : public object_base {
+ public:
+ constexpr object() = default;
- explicit object(zx_handle_t value) : object_base(value) {}
+ explicit object(zx_handle_t value) : object_base(value) {}
- template <typename U> object(object<U>&& other) : object_base(other.release()) {
- static_assert(is_same<T, void>::value, "Receiver must be compatible.");
- }
+ template <typename U>
+ object(object<U>&& other) : object_base(other.release()) {
+ static_assert(is_same<T, void>::value, "Receiver must be compatible.");
+ }
- template <typename U> object<T>& operator=(object<U>&& other) {
- static_assert(is_same<T, void>::value, "Receiver must be compatible.");
- reset(other.release());
- return *this;
- }
+ template <typename U>
+ object<T>& operator=(object<U>&& other) {
+ static_assert(is_same<T, void>::value, "Receiver must be compatible.");
+ reset(other.release());
+ return *this;
+ }
- void swap(object<T>& other) {
- zx_handle_t tmp = value_;
- value_ = other.value_;
- other.value_ = tmp;
- }
+ void swap(object<T>& other) {
+ zx_handle_t tmp = value_;
+ value_ = other.value_;
+ other.value_ = tmp;
+ }
- zx_status_t duplicate(zx_rights_t rights, object<T>* result) const {
- static_assert(object_traits<T>::supports_duplication,
- "Object must support duplication.");
- zx_handle_t h = ZX_HANDLE_INVALID;
- zx_status_t status = zx_handle_duplicate(value_, rights, &h);
- result->reset(h);
- return status;
- }
+ zx_status_t duplicate(zx_rights_t rights, object<T>* result) const {
+ static_assert(object_traits<T>::supports_duplication, "Object must support duplication.");
+ zx_handle_t h = ZX_HANDLE_INVALID;
+ zx_status_t status = zx_handle_duplicate(value_, rights, &h);
+ result->reset(h);
+ return status;
+ }
- zx_status_t replace(zx_rights_t rights, object<T>* result) {
- zx_handle_t h = ZX_HANDLE_INVALID;
- zx_status_t status = zx_handle_replace(value_, rights, &h);
- // We store ZX_HANDLE_INVALID to value_ before calling reset on result
- // in case result == this.
- value_ = ZX_HANDLE_INVALID;
- result->reset(h);
- return status;
- }
+ zx_status_t replace(zx_rights_t rights, object<T>* result) {
+ zx_handle_t h = ZX_HANDLE_INVALID;
+ zx_status_t status = zx_handle_replace(value_, rights, &h);
+ // We store ZX_HANDLE_INVALID to value_ before calling reset on result
+ // in case result == this.
+ value_ = ZX_HANDLE_INVALID;
+ result->reset(h);
+ return status;
+ }
- zx_status_t wait_one(zx_signals_t signals, zx::time deadline,
- zx_signals_t* pending) const {
- static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
- return zx_object_wait_one(value_, signals, deadline.get(), pending);
- }
+ zx_status_t wait_one(zx_signals_t signals, zx::time deadline, zx_signals_t* pending) const {
+ static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
+ return zx_object_wait_one(value_, signals, deadline.get(), pending);
+ }
- zx_status_t wait_async(const object<port>& port, uint64_t key,
- zx_signals_t signals, uint32_t options) const {
- static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
- return zx_object_wait_async(value_, port.get(), key, signals, options);
- }
+ zx_status_t wait_async(const object<port>& port, uint64_t key, zx_signals_t signals,
+ uint32_t options) const {
+ static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
+ return zx_object_wait_async(value_, port.get(), key, signals, options);
+ }
- static zx_status_t wait_many(zx_wait_item_t* wait_items, uint32_t count, zx::time deadline) {
- static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
- return zx_object_wait_many(wait_items, count, deadline.get());
- }
+ static zx_status_t wait_many(zx_wait_item_t* wait_items, uint32_t count, zx::time deadline) {
+ static_assert(object_traits<T>::supports_wait, "Object is not waitable.");
+ return zx_object_wait_many(wait_items, count, deadline.get());
+ }
- zx_status_t signal(uint32_t clear_mask, uint32_t set_mask) const {
- static_assert(object_traits<T>::supports_user_signal,
- "Object must support user signals.");
- return zx_object_signal(get(), clear_mask, set_mask);
- }
+ zx_status_t signal(uint32_t clear_mask, uint32_t set_mask) const {
+ static_assert(object_traits<T>::supports_user_signal, "Object must support user signals.");
+ return zx_object_signal(get(), clear_mask, set_mask);
+ }
- zx_status_t signal_peer(uint32_t clear_mask, uint32_t set_mask) const {
- static_assert(object_traits<T>::supports_user_signal,
- "Object must support user signals.");
- static_assert(object_traits<T>::has_peer_handle,
- "Object must have peer object.");
- return zx_object_signal_peer(get(), clear_mask, set_mask);
- }
+ zx_status_t signal_peer(uint32_t clear_mask, uint32_t set_mask) const {
+ static_assert(object_traits<T>::supports_user_signal, "Object must support user signals.");
+ static_assert(object_traits<T>::has_peer_handle, "Object must have peer object.");
+ return zx_object_signal_peer(get(), clear_mask, set_mask);
+ }
- zx_status_t get_info(uint32_t topic, void* buffer,
- size_t buffer_size,
- size_t* actual_count, size_t* avail_count) const {
- return zx_object_get_info(get(), topic, buffer, buffer_size, actual_count, avail_count);
- }
+ zx_status_t get_child(uint64_t koid, zx_rights_t rights, object<void>* result) const {
+ static_assert(object_traits<T>::supports_get_child, "Object must support getting children.");
+ // Allow for |result| and |this| being the same container, though that
+ // can only happen for |T=void|, due to strict aliasing.
+ object<void> h;
+ zx_status_t status = zx_object_get_child(value_, koid, rights, h.reset_and_get_address());
+ result->reset(h.release());
+ return status;
+ }
- zx_status_t get_child(uint64_t koid, zx_rights_t rights,
- object<void>* result) const {
- // Allow for |result| and |this| being the same container, though that
- // can only happen for |T=void|, due to strict aliasing.
- object<void> h;
- zx_status_t status = zx_object_get_child(
- value_, koid, rights, h.reset_and_get_address());
- result->reset(h.release());
- return status;
- }
+ zx_status_t set_profile(const object<profile>& profile, uint32_t options) const {
+ static_assert(object_traits<T>::supports_set_profile,
+ "Object must support scheduling profiles.");
+ return zx_object_set_profile(get(), profile.get(), options);
+ }
- zx_status_t get_property(uint32_t property, void* value,
- size_t size) const {
- return zx_object_get_property(get(), property, value, size);
- }
+ // Returns a type-safe wrapper of the underlying handle that does not claim ownership.
+ unowned<T> borrow() const { return unowned<T>(get()); }
- zx_status_t set_property(uint32_t property, const void* value,
- size_t size) const {
- return zx_object_set_property(get(), property, value, size);
- }
+ private:
+ template <typename A, typename B>
+ struct is_same {
+ static const bool value = false;
+ };
- zx_status_t get_cookie(const object_base& scope, uint64_t *cookie) const {
- return zx_object_get_cookie(get(), scope.get(), cookie);
- }
-
- zx_status_t set_cookie(const object_base& scope, uint64_t cookie) const {
- return zx_object_set_cookie(get(), scope.get(), cookie);
- }
-
- zx_status_t set_profile(const object<profile>& profile, uint32_t options) const {
- return zx_object_set_profile(get(), profile.get(), options);
- }
-
-private:
- template <typename A, typename B> struct is_same {
- static const bool value = false;
- };
-
- template <typename A> struct is_same<A, A> {
- static const bool value = true;
- };
+ template <typename A>
+ struct is_same<A, A> {
+ static const bool value = true;
+ };
};
-template <typename T> bool operator==(const object<T>& a, const object<T>& b) {
- return a.get() == b.get();
+template <typename T>
+bool operator==(const object<T>& a, const object<T>& b) {
+ return a.get() == b.get();
}
-template <typename T> bool operator!=(const object<T>& a, const object<T>& b) {
- return !(a == b);
+template <typename T>
+bool operator!=(const object<T>& a, const object<T>& b) {
+ return !(a == b);
}
-template <typename T> bool operator<(const object<T>& a, const object<T>& b) {
- return a.get() < b.get();
+template <typename T>
+bool operator<(const object<T>& a, const object<T>& b) {
+ return a.get() < b.get();
}
-template <typename T> bool operator>(const object<T>& a, const object<T>& b) {
- return a.get() > b.get();
+template <typename T>
+bool operator>(const object<T>& a, const object<T>& b) {
+ return a.get() > b.get();
}
-template <typename T> bool operator<=(const object<T>& a, const object<T>& b) {
- return !(a.get() > b.get());
+template <typename T>
+bool operator<=(const object<T>& a, const object<T>& b) {
+ return !(a.get() > b.get());
}
-template <typename T> bool operator>=(const object<T>& a, const object<T>& b) {
- return !(a.get() < b.get());
+template <typename T>
+bool operator>=(const object<T>& a, const object<T>& b) {
+ return !(a.get() < b.get());
}
-template <typename T> bool operator==(zx_handle_t a, const object<T>& b) {
- return a == b.get();
+template <typename T>
+bool operator==(zx_handle_t a, const object<T>& b) {
+ return a == b.get();
}
-template <typename T> bool operator!=(zx_handle_t a, const object<T>& b) {
- return !(a == b);
+template <typename T>
+bool operator!=(zx_handle_t a, const object<T>& b) {
+ return !(a == b);
}
-template <typename T> bool operator<(zx_handle_t a, const object<T>& b) {
- return a < b.get();
+template <typename T>
+bool operator<(zx_handle_t a, const object<T>& b) {
+ return a < b.get();
}
-template <typename T> bool operator>(zx_handle_t a, const object<T>& b) {
- return a > b.get();
+template <typename T>
+bool operator>(zx_handle_t a, const object<T>& b) {
+ return a > b.get();
}
-template <typename T> bool operator<=(zx_handle_t a, const object<T>& b) {
- return !(a > b.get());
+template <typename T>
+bool operator<=(zx_handle_t a, const object<T>& b) {
+ return !(a > b.get());
}
-template <typename T> bool operator>=(zx_handle_t a, const object<T>& b) {
- return !(a < b.get());
+template <typename T>
+bool operator>=(zx_handle_t a, const object<T>& b) {
+ return !(a < b.get());
}
-template <typename T> bool operator==(const object<T>& a, zx_handle_t b) {
- return a.get() == b;
+template <typename T>
+bool operator==(const object<T>& a, zx_handle_t b) {
+ return a.get() == b;
}
-template <typename T> bool operator!=(const object<T>& a, zx_handle_t b) {
- return !(a == b);
+template <typename T>
+bool operator!=(const object<T>& a, zx_handle_t b) {
+ return !(a == b);
}
-template <typename T> bool operator<(const object<T>& a, zx_handle_t b) {
- return a.get() < b;
+template <typename T>
+bool operator<(const object<T>& a, zx_handle_t b) {
+ return a.get() < b;
}
-template <typename T> bool operator>(const object<T>& a, zx_handle_t b) {
- return a.get() > b;
+template <typename T>
+bool operator>(const object<T>& a, zx_handle_t b) {
+ return a.get() > b;
}
-template <typename T> bool operator<=(const object<T>& a, zx_handle_t b) {
- return !(a.get() > b);
+template <typename T>
+bool operator<=(const object<T>& a, zx_handle_t b) {
+ return !(a.get() > b);
}
-template <typename T> bool operator>=(const object<T>& a, zx_handle_t b) {
- return !(a.get() < b);
+template <typename T>
+bool operator>=(const object<T>& a, zx_handle_t b) {
+ return !(a.get() < b);
}
// Wraps a handle to an object to provide type-safe access to its operations
@@ -283,37 +298,131 @@
// zx::unowned_event(handle)->signal(..)
template <typename T>
class unowned final {
-public:
- explicit unowned(zx_handle_t h) : value_(h) {}
- explicit unowned(const T& owner) : unowned(owner.get()) {}
- explicit unowned(unowned& other) : unowned(*other) {}
- constexpr unowned() = default;
- unowned(unowned&& other) = default;
+ public:
+ explicit unowned(zx_handle_t h) : value_(h) {}
+ explicit unowned(const T& owner) : unowned(owner.get()) {}
+ explicit unowned(const unowned& other) : unowned(*other) {}
+ constexpr unowned() = default;
+ unowned(unowned&& other) = default;
- ~unowned() { release_value(); }
+ ~unowned() { release_value(); }
- unowned& operator=(unowned& other) {
- *this = unowned(other);
- return *this;
- }
- unowned& operator=(unowned&& other) {
- release_value();
- value_ = static_cast<T&&>(other.value_);
- return *this;
+ unowned& operator=(const unowned& other) {
+ if (&other == this) {
+ return *this;
}
- const T& operator*() const { return value_; }
- const T* operator->() const { return &value_; }
+ *this = unowned(other);
+ return *this;
+ }
+ unowned& operator=(unowned&& other) {
+ release_value();
+ value_ = static_cast<T&&>(other.value_);
+ return *this;
+ }
-private:
- void release_value() {
- zx_handle_t h = value_.release();
- static_cast<void>(h);
- }
+ const T& operator*() const { return value_; }
+ const T* operator->() const { return &value_; }
- T value_;
+ private:
+ void release_value() {
+ zx_handle_t h = value_.release();
+ static_cast<void>(h);
+ }
+
+ T value_;
};
-} // namespace zx
+template <typename T>
+bool operator==(const unowned<T>& a, const unowned<T>& b) {
+ return a->get() == b->get();
+}
+
+template <typename T>
+bool operator!=(const unowned<T>& a, const unowned<T>& b) {
+ return !(a == b);
+}
+
+template <typename T>
+bool operator<(const unowned<T>& a, const unowned<T>& b) {
+ return a->get() < b->get();
+}
+
+template <typename T>
+bool operator>(const unowned<T>& a, const unowned<T>& b) {
+ return a->get() > b->get();
+}
+
+template <typename T>
+bool operator<=(const unowned<T>& a, const unowned<T>& b) {
+ return !(a > b);
+}
+
+template <typename T>
+bool operator>=(const unowned<T>& a, const unowned<T>& b) {
+ return !(a < b);
+}
+
+template <typename T>
+bool operator==(zx_handle_t a, const unowned<T>& b) {
+ return a == b->get();
+}
+
+template <typename T>
+bool operator!=(zx_handle_t a, const unowned<T>& b) {
+ return !(a == b);
+}
+
+template <typename T>
+bool operator<(zx_handle_t a, const unowned<T>& b) {
+ return a < b->get();
+}
+
+template <typename T>
+bool operator>(zx_handle_t a, const unowned<T>& b) {
+ return a > b->get();
+}
+
+template <typename T>
+bool operator<=(zx_handle_t a, const unowned<T>& b) {
+ return !(a > b);
+}
+
+template <typename T>
+bool operator>=(zx_handle_t a, const unowned<T>& b) {
+ return !(a < b);
+}
+
+template <typename T>
+bool operator==(const unowned<T>& a, zx_handle_t b) {
+ return a->get() == b;
+}
+
+template <typename T>
+bool operator!=(const unowned<T>& a, zx_handle_t b) {
+ return !(a == b);
+}
+
+template <typename T>
+bool operator<(const unowned<T>& a, zx_handle_t b) {
+ return a->get() < b;
+}
+
+template <typename T>
+bool operator>(const unowned<T>& a, zx_handle_t b) {
+ return a->get() > b;
+}
+
+template <typename T>
+bool operator<=(const unowned<T>& a, zx_handle_t b) {
+ return !(a > b);
+}
+
+template <typename T>
+bool operator>=(const unowned<T>& a, zx_handle_t b) {
+ return !(a < b);
+}
+
+} // namespace zx
#endif // LIB_ZX_OBJECT_H_
diff --git a/pkg/zx/include/lib/zx/object_traits.h b/pkg/zx/include/lib/zx/object_traits.h
index f5a62c6..1352c0b 100644
--- a/pkg/zx/include/lib/zx/object_traits.h
+++ b/pkg/zx/include/lib/zx/object_traits.h
@@ -9,103 +9,216 @@
class channel;
class eventpair;
-class log;
-class socket;
-class vmo;
-class vmar;
-class port;
-class guest;
+class exception;
class fifo;
+class guest;
class interrupt;
+class job;
+class log;
+class msi;
+class port;
+class process;
class pmt;
+class resource;
+class socket;
+class thread;
+class vmar;
+class vmo;
// The default traits supports:
-// - event
-// - thread
-// - process
-// - job
-// - vmo
// - bti
-// - resource
-// - timer
+// - event
// - iommu
-template <typename T> struct object_traits {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = false;
+// - profile
+// - timer
+// - vmo
+template <typename T>
+struct object_traits {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<channel> {
- static constexpr bool supports_duplication = false;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = true;
+template <>
+struct object_traits<channel> {
+ static constexpr bool supports_duplication = false;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = true;
};
-template <> struct object_traits<eventpair> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = true;
+template <>
+struct object_traits<eventpair> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = true;
};
-template <> struct object_traits<fifo> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = true;
+template <>
+struct object_traits<fifo> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = true;
};
-template <> struct object_traits<log> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<log> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<pmt> {
- static constexpr bool supports_duplication = false;
- static constexpr bool supports_user_signal = false;
- static constexpr bool supports_wait = false;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<pmt> {
+ static constexpr bool supports_duplication = false;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = false;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<socket> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = true;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = true;
+template <>
+struct object_traits<socket> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = true;
};
-template <> struct object_traits<port> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = false;
- static constexpr bool supports_wait = false;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<port> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = false;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<vmar> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = false;
- static constexpr bool supports_wait = false;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<vmar> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = false;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<interrupt> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = false;
- static constexpr bool supports_wait = true;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<interrupt> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-template <> struct object_traits<guest> {
- static constexpr bool supports_duplication = true;
- static constexpr bool supports_user_signal = false;
- static constexpr bool supports_wait = false;
- static constexpr bool has_peer_handle = false;
+template <>
+struct object_traits<guest> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = false;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
};
-} // namespace zx
+template <>
+struct object_traits<exception> {
+ static constexpr bool supports_duplication = false;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = false;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
+};
+
+template <>
+struct object_traits<job> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = true;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = true;
+ static constexpr bool has_peer_handle = false;
+};
+
+template <>
+struct object_traits<process> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = true;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = true;
+ static constexpr bool has_peer_handle = false;
+};
+
+template <>
+struct object_traits<thread> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = true;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
+};
+
+template <>
+struct object_traits<resource> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = true;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = true;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
+};
+
+template <>
+struct object_traits<msi> {
+ static constexpr bool supports_duplication = true;
+ static constexpr bool supports_get_child = false;
+ static constexpr bool supports_set_profile = false;
+ static constexpr bool supports_user_signal = false;
+ static constexpr bool supports_wait = true;
+ static constexpr bool supports_kill = false;
+ static constexpr bool has_peer_handle = false;
+};
+
+} // namespace zx
#endif // LIB_ZX_OBJECT_TRAITS_H_
diff --git a/pkg/zx/include/lib/zx/pager.h b/pkg/zx/include/lib/zx/pager.h
new file mode 100644
index 0000000..a1e4663
--- /dev/null
+++ b/pkg/zx/include/lib/zx/pager.h
@@ -0,0 +1,57 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ZX_PAGER_H_
+#define LIB_ZX_PAGER_H_
+
+#include <lib/zx/handle.h>
+#include <lib/zx/object.h>
+#include <lib/zx/port.h>
+#include <lib/zx/vmo.h>
+
+namespace zx {
+
+class pager final : public object<pager> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PAGER;
+
+ constexpr pager() = default;
+
+ explicit pager(zx_handle_t value) : object(value) {}
+
+ explicit pager(handle&& h) : object(h.release()) {}
+
+ pager(pager&& other) : object(other.release()) {}
+
+ pager& operator=(pager&& other) {
+ reset(other.release());
+ return *this;
+ }
+
+ static zx_status_t create(uint32_t options, pager* result);
+
+ zx_status_t create_vmo(uint32_t options, const port& port, uint64_t key, uint64_t size,
+ vmo* result) const {
+ return zx_pager_create_vmo(get(), options, port.get(), key, size,
+ result->reset_and_get_address());
+ }
+
+ zx_status_t detach_vmo(const vmo& vmo) const { return zx_pager_detach_vmo(get(), vmo.get()); }
+
+ zx_status_t supply_pages(const vmo& pager_vmo, uint64_t offset, uint64_t length,
+ const vmo& aux_vmo, uint64_t aux_offset) const {
+ return zx_pager_supply_pages(get(), pager_vmo.get(), offset, length, aux_vmo.get(), aux_offset);
+ }
+
+ zx_status_t op_range(uint32_t op, const vmo& pager_vmo, uint64_t offset, uint64_t length,
+ uint64_t data) const {
+ return zx_pager_op_range(get(), op, pager_vmo.get(), offset, length, data);
+ }
+};
+
+using unowned_pager = unowned<pager>;
+
+} // namespace zx
+
+#endif // LIB_ZX_PAGER_H_
diff --git a/pkg/zx/include/lib/zx/pmt.h b/pkg/zx/include/lib/zx/pmt.h
index 404235a..8d095da 100644
--- a/pkg/zx/include/lib/zx/pmt.h
+++ b/pkg/zx/include/lib/zx/pmt.h
@@ -10,28 +10,28 @@
namespace zx {
-class pmt : public object<pmt> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PMT;
+class pmt final : public object<pmt> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PMT;
- constexpr pmt() = default;
+ constexpr pmt() = default;
- explicit pmt(zx_handle_t value) : object(value) {}
+ explicit pmt(zx_handle_t value) : object(value) {}
- explicit pmt(handle&& h) : object(h.release()) {}
+ explicit pmt(handle&& h) : object(h.release()) {}
- pmt(pmt&& other) : object(other.release()) {}
+ pmt(pmt&& other) : object(other.release()) {}
- pmt& operator=(pmt&& other) {
- reset(other.release());
- return *this;
- }
+ pmt& operator=(pmt&& other) {
+ reset(other.release());
+ return *this;
+ }
- zx_status_t unpin() { return zx_pmt_unpin(release()); }
+ zx_status_t unpin() { return zx_pmt_unpin(release()); }
};
using unowned_pmt = unowned<pmt>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_PMT_H_
diff --git a/pkg/zx/include/lib/zx/port.h b/pkg/zx/include/lib/zx/port.h
index ef607ec..01a0fe5 100644
--- a/pkg/zx/include/lib/zx/port.h
+++ b/pkg/zx/include/lib/zx/port.h
@@ -11,40 +11,38 @@
namespace zx {
-class port : public object<port> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PORT;
+class port final : public object<port> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PORT;
- constexpr port() = default;
+ constexpr port() = default;
- explicit port(zx_handle_t value) : object(value) {}
+ explicit port(zx_handle_t value) : object(value) {}
- explicit port(handle&& h) : object(h.release()) {}
+ explicit port(handle&& h) : object(h.release()) {}
- port(port&& other) : object(other.release()) {}
+ port(port&& other) : object(other.release()) {}
- port& operator=(port&& other) {
- reset(other.release());
- return *this;
- }
+ port& operator=(port&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t options, port* result);
+ static zx_status_t create(uint32_t options, port* result);
- zx_status_t queue(const zx_port_packet_t* packet) const {
- return zx_port_queue(get(), packet);
- }
+ zx_status_t queue(const zx_port_packet_t* packet) const { return zx_port_queue(get(), packet); }
- zx_status_t wait(zx::time deadline, zx_port_packet_t* packet) const {
- return zx_port_wait(get(), deadline.get(), packet);
- }
+ zx_status_t wait(zx::time deadline, zx_port_packet_t* packet) const {
+ return zx_port_wait(get(), deadline.get(), packet);
+ }
- zx_status_t cancel(const object_base& source, uint64_t key) const {
- return zx_port_cancel(get(), source.get(), key);
- }
+ zx_status_t cancel(const object_base& source, uint64_t key) const {
+ return zx_port_cancel(get(), source.get(), key);
+ }
};
using unowned_port = unowned<port>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_PORT_H_
diff --git a/pkg/zx/include/lib/zx/process.h b/pkg/zx/include/lib/zx/process.h
index c3fe348..7fca7dc 100644
--- a/pkg/zx/include/lib/zx/process.h
+++ b/pkg/zx/include/lib/zx/process.h
@@ -15,53 +15,50 @@
class job;
class thread;
-class process : public task<process> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PROCESS;
+class process final : public task<process> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PROCESS;
- constexpr process() = default;
+ constexpr process() = default;
- explicit process(zx_handle_t value) : task(value) {}
+ explicit process(zx_handle_t value) : task(value) {}
- explicit process(handle&& h) : task(h.release()) {}
+ explicit process(handle&& h) : task(h.release()) {}
- process(process&& other) : task(other.release()) {}
+ process(process&& other) : task(other.release()) {}
- process& operator=(process&& other) {
- reset(other.release());
- return *this;
- }
+ process& operator=(process&& other) {
+ reset(other.release());
+ return *this;
+ }
- // Rather than creating a process directly with this syscall,
- // consider using the launchpad library, which properly sets up
- // the many details of creating a process beyond simply creating
- // the kernel structure.
- static zx_status_t create(const job& job, const char* name, uint32_t name_len,
- uint32_t flags, process* proc, vmar* root_vmar);
+ // Rather than creating a process directly with this syscall,
+ // consider using the launchpad library, which properly sets up
+ // the many details of creating a process beyond simply creating
+ // the kernel structure.
+ static zx_status_t create(const job& job, const char* name, uint32_t name_len, uint32_t flags,
+ process* proc, vmar* root_vmar);
- zx_status_t start(const thread& thread_handle, uintptr_t entry,
- uintptr_t stack, handle arg_handle, uintptr_t arg2) const;
+ zx_status_t start(const thread& thread_handle, uintptr_t entry, uintptr_t stack,
+ handle arg_handle, uintptr_t arg2) const;
- zx_status_t read_memory(uintptr_t vaddr, void* buffer, size_t len, size_t* actual) const {
- return zx_process_read_memory(get(), vaddr, buffer, len, actual);
- }
+ zx_status_t read_memory(uintptr_t vaddr, void* buffer, size_t len, size_t* actual) const {
+ return zx_process_read_memory(get(), vaddr, buffer, len, actual);
+ }
- zx_status_t write_memory(uintptr_t vaddr, const void* buffer, size_t len, size_t* actual) {
- return zx_process_write_memory(get(), vaddr, buffer, len, actual);
- }
+ zx_status_t write_memory(uintptr_t vaddr, const void* buffer, size_t len, size_t* actual) const {
+ return zx_process_write_memory(get(), vaddr, buffer, len, actual);
+ }
- // Provide strongly-typed overload, in addition to get_child(handle*).
- using task<process>::get_child;
- zx_status_t get_child(uint64_t koid, zx_rights_t rights,
- thread* result) const;
+ // Provide strongly-typed overload, in addition to get_child(handle*).
+ using task<process>::get_child;
+ zx_status_t get_child(uint64_t koid, zx_rights_t rights, thread* result) const;
- static inline unowned<process> self() {
- return unowned<process>(zx_process_self());
- }
+ static inline unowned<process> self() { return unowned<process>(zx_process_self()); }
};
using unowned_process = unowned<process>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_PROCESS_H_
diff --git a/pkg/zx/include/lib/zx/profile.h b/pkg/zx/include/lib/zx/profile.h
index ddc3fe3..fa3814f 100644
--- a/pkg/zx/include/lib/zx/profile.h
+++ b/pkg/zx/include/lib/zx/profile.h
@@ -6,33 +6,34 @@
#define LIB_ZX_PROFILE_H_
#include <lib/zx/handle.h>
+#include <lib/zx/job.h>
#include <lib/zx/object.h>
-#include <lib/zx/resource.h>
namespace zx {
-class profile : public object<profile> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_LOG;
+class profile final : public object<profile> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_PROFILE;
- constexpr profile() = default;
+ constexpr profile() = default;
- explicit profile(zx_handle_t value) : object(value) {}
+ explicit profile(zx_handle_t value) : object(value) {}
- explicit profile(handle&& h) : object(h.release()) {}
+ explicit profile(handle&& h) : object(h.release()) {}
- profile(profile&& other) : object(other.release()) {}
+ profile(profile&& other) : object(other.release()) {}
- profile& operator=(profile&& other) {
- reset(other.release());
- return *this;
- }
+ profile& operator=(profile&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& resource, const zx_profile_info_t* info, profile* result);
+ static zx_status_t create(const job& job, uint32_t options, const zx_profile_info_t* info,
+ profile* result);
};
using unowned_profile = unowned<profile>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_PROFILE_H_
diff --git a/pkg/zx/include/lib/zx/resource.h b/pkg/zx/include/lib/zx/resource.h
index 4909868..0f3afd1 100644
--- a/pkg/zx/include/lib/zx/resource.h
+++ b/pkg/zx/include/lib/zx/resource.h
@@ -10,34 +10,29 @@
namespace zx {
-class resource : public object<resource> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_RESOURCE;
+class resource final : public object<resource> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_RESOURCE;
- constexpr resource() = default;
+ constexpr resource() = default;
- explicit resource(zx_handle_t value) : object(value) {}
+ explicit resource(zx_handle_t value) : object(value) {}
- explicit resource(handle&& h) : object(h.release()) {}
+ explicit resource(handle&& h) : object(h.release()) {}
- resource(resource&& other) : object(other.release()) {}
+ resource(resource&& other) : object(other.release()) {}
- resource& operator=(resource&& other) {
- reset(other.release());
- return *this;
- }
+ resource& operator=(resource&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const resource& parent,
- uint32_t options,
- uint64_t base,
- size_t len,
- const char* name,
- size_t namelen,
- resource* result);
+ static zx_status_t create(const resource& parent, uint32_t options, uint64_t base, size_t len,
+ const char* name, size_t namelen, resource* result);
};
using unowned_resource = unowned<resource>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_RESOURCE_H_
diff --git a/pkg/zx/include/lib/zx/socket.h b/pkg/zx/include/lib/zx/socket.h
index 180e1fa..d1563e3 100644
--- a/pkg/zx/include/lib/zx/socket.h
+++ b/pkg/zx/include/lib/zx/socket.h
@@ -10,56 +10,38 @@
namespace zx {
-class socket : public object<socket> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_SOCKET;
+class socket final : public object<socket> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_SOCKET;
- constexpr socket() = default;
+ constexpr socket() = default;
- explicit socket(zx_handle_t value) : object(value) {}
+ explicit socket(zx_handle_t value) : object(value) {}
- explicit socket(handle&& h) : object(h.release()) {}
+ explicit socket(handle&& h) : object(h.release()) {}
- socket(socket&& other) : object(other.release()) {}
+ socket(socket&& other) : object(other.release()) {}
- socket& operator=(socket&& other) {
- reset(other.release());
- return *this;
- }
+ socket& operator=(socket&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t options, socket* endpoint0,
- socket* endpoint1);
+ static zx_status_t create(uint32_t options, socket* endpoint0, socket* endpoint1);
- zx_status_t write(uint32_t options, const void* buffer, size_t len,
- size_t* actual) const {
- return zx_socket_write(get(), options, buffer, len, actual);
- }
+ zx_status_t write(uint32_t options, const void* buffer, size_t len, size_t* actual) const {
+ return zx_socket_write(get(), options, buffer, len, actual);
+ }
- zx_status_t read(uint32_t options, void* buffer, size_t len,
- size_t* actual) const {
- return zx_socket_read(get(), options, buffer, len, actual);
- }
+ zx_status_t read(uint32_t options, void* buffer, size_t len, size_t* actual) const {
+ return zx_socket_read(get(), options, buffer, len, actual);
+ }
- zx_status_t share(socket socket_to_share) const {
- return zx_socket_share(get(), socket_to_share.release());
- }
-
- zx_status_t accept(socket* out_socket) const {
- // We use a temporary to handle the case where |this| and |out_socket|
- // are aliased.
- socket result;
- zx_status_t status = zx_socket_accept(get(), result.reset_and_get_address());
- out_socket->reset(result.release());
- return status;
- }
-
- zx_status_t shutdown(uint32_t options) const {
- return zx_socket_shutdown(get(), options);
- }
+ zx_status_t shutdown(uint32_t options) const { return zx_socket_shutdown(get(), options); }
};
using unowned_socket = unowned<socket>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_SOCKET_H_
diff --git a/pkg/zx/include/lib/zx/stream.h b/pkg/zx/include/lib/zx/stream.h
new file mode 100644
index 0000000..1d7080a
--- /dev/null
+++ b/pkg/zx/include/lib/zx/stream.h
@@ -0,0 +1,66 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIB_ZX_STREAM_H_
+#define LIB_ZX_STREAM_H_
+
+#include <lib/zx/handle.h>
+#include <lib/zx/object.h>
+#include <lib/zx/vmo.h>
+
+namespace zx {
+
+class stream final : public object<stream> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_STREAM;
+
+ constexpr stream() = default;
+
+ explicit stream(zx_handle_t value) : object(value) {}
+
+ explicit stream(handle&& h) : object(h.release()) {}
+
+ stream(stream&& other) : object(other.release()) {}
+
+ stream& operator=(stream&& other) {
+ reset(other.release());
+ return *this;
+ }
+
+ static zx_status_t create(uint32_t options, const vmo& vmo_handle, zx_off_t seek,
+ stream* out_stream);
+
+ zx_status_t writev(uint32_t options, const zx_iovec_t* vector, size_t vector_count,
+ size_t* actual) const {
+ return zx_stream_writev(get(), options, vector, vector_count, actual);
+ }
+
+ zx_status_t writev_at(uint32_t options, zx_off_t offset, const zx_iovec_t* vector,
+ size_t vector_count, size_t* actual) const {
+ return zx_stream_writev_at(get(), options, offset, vector, vector_count, actual);
+ }
+
+ zx_status_t readv(uint32_t options, const zx_iovec_t* vector, size_t vector_count,
+ size_t* actual) const {
+ // TODO: zx_stream_readv should accept a |const zx_iovec_t*|.
+ return zx_stream_readv(get(), options, const_cast<zx_iovec_t*>(vector), vector_count, actual);
+ }
+
+ zx_status_t readv_at(uint32_t options, zx_off_t offset, const zx_iovec_t* vector,
+ size_t vector_count, size_t* actual) const {
+ // TODO: zx_stream_readv should accept a |const zx_iovec_t*|.
+ return zx_stream_readv_at(get(), options, offset, const_cast<zx_iovec_t*>(vector), vector_count,
+ actual);
+ }
+
+ zx_status_t seek(zx_stream_seek_origin_t whence, int64_t offset, zx_off_t* out_seek) const {
+ return zx_stream_seek(get(), whence, offset, out_seek);
+ }
+};
+
+using unowned_stream = unowned<stream>;
+
+} // namespace zx
+
+#endif // LIB_ZX_STREAM_H_
diff --git a/pkg/zx/include/lib/zx/suspend_token.h b/pkg/zx/include/lib/zx/suspend_token.h
index 8eba2df..691094f 100644
--- a/pkg/zx/include/lib/zx/suspend_token.h
+++ b/pkg/zx/include/lib/zx/suspend_token.h
@@ -12,24 +12,24 @@
// The only thing you can do with a suspend token is close it (which will
// resume the thread).
-class suspend_token : public object<suspend_token> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_SUSPEND_TOKEN;
+class suspend_token final : public object<suspend_token> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_SUSPEND_TOKEN;
- constexpr suspend_token() = default;
+ constexpr suspend_token() = default;
- explicit suspend_token(zx_handle_t value) : object<suspend_token>(value) {}
+ explicit suspend_token(zx_handle_t value) : object<suspend_token>(value) {}
- explicit suspend_token(handle&& h) : object<suspend_token>(h.release()) {}
+ explicit suspend_token(handle&& h) : object<suspend_token>(h.release()) {}
- suspend_token(suspend_token&& other) : object<suspend_token>(other.release()) {}
+ suspend_token(suspend_token&& other) : object<suspend_token>(other.release()) {}
- suspend_token& operator=(suspend_token&& other) {
- reset(other.release());
- return *this;
- }
+ suspend_token& operator=(suspend_token&& other) {
+ reset(other.release());
+ return *this;
+ }
};
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_SUSPEND_TOKEN_H_
diff --git a/pkg/zx/include/lib/zx/task.h b/pkg/zx/include/lib/zx/task.h
index a3bc20d..ef1ec78 100644
--- a/pkg/zx/include/lib/zx/task.h
+++ b/pkg/zx/include/lib/zx/task.h
@@ -5,6 +5,7 @@
#ifndef LIB_ZX_TASK_H_
#define LIB_ZX_TASK_H_
+#include <lib/zx/channel.h>
#include <lib/zx/handle.h>
#include <lib/zx/object.h>
#include <lib/zx/suspend_token.h>
@@ -14,38 +15,33 @@
class port;
class suspend_token;
-template <typename T = void> class task : public object<T> {
-public:
- constexpr task() = default;
+template <typename T = void>
+class task : public object<T> {
+ public:
+ constexpr task() = default;
- explicit task(zx_handle_t value) : object<T>(value) {}
+ explicit task(zx_handle_t value) : object<T>(value) {}
- explicit task(handle&& h) : object<T>(h.release()) {}
+ explicit task(handle&& h) : object<T>(h.release()) {}
- task(task&& other) : object<T>(other.release()) {}
+ task(task&& other) : object<T>(other.release()) {}
- zx_status_t bind_exception_port(
- const object<port>& port, uint64_t key, uint32_t options) const {
- return zx_task_bind_exception_port(object<T>::get(), port.get(), key, options);
- }
+ zx_status_t kill() const {
+ static_assert(object_traits<T>::supports_kill, "Object must support being killed.");
+ return zx_task_kill(object<T>::get()); }
- zx_status_t kill() const { return zx_task_kill(object<T>::get()); }
+ zx_status_t suspend(suspend_token* result) const {
+ // Assume |result| must refer to a different container than |this|, due
+ // to strict aliasing.
+ return zx_task_suspend_token(object<T>::get(), result->reset_and_get_address());
+ }
- // Deprecated: Use the variant that takes a suspend_token.
- zx_status_t suspend() const { return zx_task_suspend(object<T>::get()); }
-
- zx_status_t suspend(suspend_token* result) const {
- // Assume |result| must refer to a different container than |this|, due
- // to strict aliasing.
- return zx_task_suspend_token(
- object<T>::get(), result->reset_and_get_address());
- }
-
- zx_status_t resume_from_exception(const object<port>& port, uint32_t options) const {
- return zx_task_resume_from_exception(object<T>::get(), port.get(), options);
- }
+ zx_status_t create_exception_channel(uint32_t options, object<channel>* channel) const {
+ return zx_task_create_exception_channel(object<T>::get(), options,
+ channel->reset_and_get_address());
+ }
};
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_TASK_H_
diff --git a/pkg/zx/include/lib/zx/thread.h b/pkg/zx/include/lib/zx/thread.h
index eabf3ed..bb80bc6 100644
--- a/pkg/zx/include/lib/zx/thread.h
+++ b/pkg/zx/include/lib/zx/thread.h
@@ -12,61 +12,53 @@
namespace zx {
class process;
-class thread : public task<thread> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_THREAD;
+class thread final : public task<thread> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_THREAD;
- constexpr thread() = default;
+ constexpr thread() = default;
- explicit thread(zx_handle_t value)
- : task(value) {}
+ explicit thread(zx_handle_t value) : task(value) {}
- explicit thread(handle&& h)
- : task(h.release()) {}
+ explicit thread(handle&& h) : task(h.release()) {}
- thread(thread&& other)
- : task(other.release()) {}
+ thread(thread&& other) : task(other.release()) {}
- thread& operator=(thread&& other) {
- reset(other.release());
- return *this;
- }
+ thread& operator=(thread&& other) {
+ reset(other.release());
+ return *this;
+ }
- // Rather than creating a thread directly with this syscall, consider using
- // std::thread or thrd_create, which properly integrates with the
- // thread-local data structures in libc.
- static zx_status_t create(const process& process, const char* name,
- uint32_t name_len, uint32_t flags,
- thread* result);
+ // Rather than creating a thread directly with this syscall, consider using
+ // std::thread or thrd_create, which properly integrates with the
+ // thread-local data structures in libc.
+ static zx_status_t create(const process& process, const char* name, uint32_t name_len,
+ uint32_t flags, thread* result);
- // The first variant maps exactly to the syscall and can be used for
- // launching threads in remote processes. The second variant is for
- // conveniently launching threads in the current process.
- zx_status_t start(uintptr_t thread_entry, uintptr_t stack, uintptr_t arg1,
- uintptr_t arg2) const {
- return zx_thread_start(get(), thread_entry, stack, arg1, arg2);
- }
- zx_status_t start(void (*thread_entry)(uintptr_t arg1, uintptr_t arg2),
- void* stack, uintptr_t arg1, uintptr_t arg2) {
- return zx_thread_start(get(),
- reinterpret_cast<uintptr_t>(thread_entry),
- reinterpret_cast<uintptr_t>(stack), arg1, arg2);
- }
+ // The first variant maps exactly to the syscall and can be used for
+ // launching threads in remote processes. The second variant is for
+ // conveniently launching threads in the current process.
+ zx_status_t start(uintptr_t thread_entry, uintptr_t stack, uintptr_t arg1, uintptr_t arg2) const {
+ return zx_thread_start(get(), thread_entry, stack, arg1, arg2);
+ }
+ zx_status_t start(void (*thread_entry)(uintptr_t arg1, uintptr_t arg2), void* stack,
+ uintptr_t arg1, uintptr_t arg2) const {
+ return zx_thread_start(get(), reinterpret_cast<uintptr_t>(thread_entry),
+ reinterpret_cast<uintptr_t>(stack), arg1, arg2);
+ }
- zx_status_t read_state(uint32_t kind, void* buffer, size_t len) const {
- return zx_thread_read_state(get(), kind, buffer, len);
- }
- zx_status_t write_state(uint32_t kind, const void* buffer, size_t len) {
- return zx_thread_write_state(get(), kind, buffer, len);
- }
+ zx_status_t read_state(uint32_t kind, void* buffer, size_t len) const {
+ return zx_thread_read_state(get(), kind, buffer, len);
+ }
+ zx_status_t write_state(uint32_t kind, const void* buffer, size_t len) const {
+ return zx_thread_write_state(get(), kind, buffer, len);
+ }
- static inline unowned<thread> self() {
- return unowned<thread>(zx_thread_self());
- }
+ static inline unowned<thread> self() { return unowned<thread>(zx_thread_self()); }
};
using unowned_thread = unowned<thread>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_THREAD_H_
diff --git a/pkg/zx/include/lib/zx/time.h b/pkg/zx/include/lib/zx/time.h
index 101e057..7ee0b02 100644
--- a/pkg/zx/include/lib/zx/time.h
+++ b/pkg/zx/include/lib/zx/time.h
@@ -10,224 +10,284 @@
#include <zircon/syscalls.h>
#include <zircon/time.h>
+#include <ctime>
+#include <limits>
+
namespace zx {
-class duration {
-public:
- constexpr duration() = default;
+class duration final {
+ public:
+ constexpr duration() = default;
- explicit constexpr duration(zx_duration_t value)
- : value_(value) {}
+ explicit constexpr duration(zx_duration_t value) : value_(value) {}
- static constexpr duration infinite() { return duration(ZX_TIME_INFINITE); }
+#if __cplusplus >= 201703L
+ explicit constexpr duration(std::timespec ts) : value_(zx_duration_from_timespec(ts)) {}
+#endif
- static constexpr duration infinite_past() { return duration(ZX_TIME_INFINITE_PAST); }
+ static constexpr duration infinite() { return duration(ZX_TIME_INFINITE); }
- constexpr zx_duration_t get() const { return value_; }
+ static constexpr duration infinite_past() { return duration(ZX_TIME_INFINITE_PAST); }
- constexpr duration operator+(duration other) const {
- return duration(zx_duration_add_duration(value_, other.value_));
- }
+ constexpr zx_duration_t get() const { return value_; }
- constexpr duration operator-(duration other) const {
- return duration(zx_duration_sub_duration(value_, other.value_));
- }
+ constexpr duration operator+(duration other) const {
+ return duration(zx_duration_add_duration(value_, other.value_));
+ }
- constexpr duration operator*(int64_t multiplier) const {
- return duration(zx_duration_mul_int64(value_, multiplier));
- }
+ constexpr duration operator-(duration other) const {
+ return duration(zx_duration_sub_duration(value_, other.value_));
+ }
- constexpr duration operator/(int64_t divisor) const {
- return duration(value_ / divisor);
- }
+ constexpr duration operator*(int64_t multiplier) const {
+ return duration(zx_duration_mul_int64(value_, multiplier));
+ }
- constexpr duration operator%(duration divisor) const {
- return duration(value_ % divisor.value_);
- }
+ constexpr duration operator/(int64_t divisor) const { return duration(value_ / divisor); }
- constexpr int64_t operator/(duration other) const {
- return value_ / other.value_;
- }
+ constexpr int64_t operator/(duration other) const { return value_ / other.value_; }
- constexpr duration& operator+=(duration other) {
- value_ = zx_duration_add_duration(value_, other.value_);
- return *this;
- }
+ constexpr duration operator%(int64_t divisor) const { return duration(value_ % divisor); }
- constexpr duration& operator-=(duration other) {
- value_ = zx_duration_sub_duration(value_, other.value_);
- return *this;
- }
+ constexpr int64_t operator%(duration other) const { return value_ % other.value_; }
- constexpr duration& operator*=(int64_t multiplier) {
- value_ = zx_duration_mul_int64(value_, multiplier);
- return *this;
- }
+ constexpr duration& operator+=(duration other) {
+ value_ = zx_duration_add_duration(value_, other.value_);
+ return *this;
+ }
- constexpr duration& operator/=(int64_t divisor) {
- value_ /= divisor;
- return *this;
- }
+ constexpr duration& operator-=(duration other) {
+ value_ = zx_duration_sub_duration(value_, other.value_);
+ return *this;
+ }
- constexpr bool operator==(duration other) const { return value_ == other.value_; }
- constexpr bool operator!=(duration other) const { return value_ != other.value_; }
- constexpr bool operator<(duration other) const { return value_ < other.value_; }
- constexpr bool operator<=(duration other) const { return value_ <= other.value_; }
- constexpr bool operator>(duration other) const { return value_ > other.value_; }
- constexpr bool operator>=(duration other) const { return value_ >= other.value_; }
+ constexpr duration& operator*=(int64_t multiplier) {
+ value_ = zx_duration_mul_int64(value_, multiplier);
+ return *this;
+ }
- constexpr int64_t to_nsecs() const { return value_; }
+ constexpr duration& operator/=(int64_t divisor) {
+ value_ /= divisor;
+ return *this;
+ }
- constexpr int64_t to_usecs() const { return value_ / ZX_USEC(1); }
+ constexpr duration& operator%=(int64_t divisor) {
+ value_ %= divisor;
+ return *this;
+ }
- constexpr int64_t to_msecs() const { return value_ / ZX_MSEC(1); }
+ constexpr bool operator==(duration other) const { return value_ == other.value_; }
+ constexpr bool operator!=(duration other) const { return value_ != other.value_; }
+ constexpr bool operator<(duration other) const { return value_ < other.value_; }
+ constexpr bool operator<=(duration other) const { return value_ <= other.value_; }
+ constexpr bool operator>(duration other) const { return value_ > other.value_; }
+ constexpr bool operator>=(duration other) const { return value_ >= other.value_; }
- constexpr int64_t to_secs() const { return value_ / ZX_SEC(1); }
+ constexpr int64_t to_nsecs() const { return value_; }
- constexpr int64_t to_mins() const { return value_ / ZX_MIN(1); }
+ constexpr int64_t to_usecs() const { return value_ / ZX_USEC(1); }
- constexpr int64_t to_hours() const { return value_ / ZX_HOUR(1); }
+ constexpr int64_t to_msecs() const { return value_ / ZX_MSEC(1); }
-private:
- zx_duration_t value_ = 0;
+ constexpr int64_t to_secs() const { return value_ / ZX_SEC(1); }
+
+ constexpr int64_t to_mins() const { return value_ / ZX_MIN(1); }
+
+ constexpr int64_t to_hours() const { return value_ / ZX_HOUR(1); }
+
+#if __cplusplus >= 201703L
+ constexpr std::timespec to_timespec() const { return zx_timespec_from_duration(value_); }
+#endif
+
+ private:
+ zx_duration_t value_ = 0;
};
-class ticks {
-public:
- constexpr ticks() = default;
+class ticks final {
+ public:
+ constexpr ticks() = default;
- explicit constexpr ticks(zx_ticks_t value) : value_(value) {}
+ explicit constexpr ticks(zx_ticks_t value) : value_(value) {}
- // Constructs a tick object for the current tick counter in the system.
- static ticks now() { return ticks(zx_ticks_get()); }
+ // Constructs a tick object for the current tick counter in the system.
+ static ticks now() { return ticks(zx_ticks_get()); }
- // Returns the number of ticks contained within one second.
- static ticks per_second() { return ticks(zx_ticks_per_second()); }
+ // Returns the number of ticks contained within one second.
+ static ticks per_second() { return ticks(zx_ticks_per_second()); }
- // Acquires the number of ticks contained within this object.
- constexpr zx_ticks_t get() const { return value_; }
+ // Acquires the number of ticks contained within this object.
+ constexpr zx_ticks_t get() const { return value_; }
- constexpr ticks operator+(ticks other) const {
- return ticks(value_ + other.value_);
+ static constexpr ticks infinite() { return ticks(INFINITE); }
+
+ static constexpr ticks infinite_past() { return ticks(INFINITE_PAST); }
+
+ constexpr ticks operator+(ticks other) const {
+ zx_ticks_t x = 0;
+
+ if (unlikely(add_overflow(value_, other.value_, &x))) {
+ if (x >= 0) {
+ return infinite_past();
+ } else {
+ return infinite();
+ }
}
- constexpr ticks operator-(ticks other) const {
- return ticks(value_ - other.value_);
+ return ticks(x);
+ }
+
+ constexpr ticks operator-(ticks other) const {
+ zx_ticks_t x = 0;
+
+ if (unlikely(sub_overflow(value_, other.value_, &x))) {
+ if (x >= 0) {
+ return infinite_past();
+ } else {
+ return infinite();
+ }
}
- constexpr ticks operator*(uint64_t multiplier) const {
- return ticks(value_ * multiplier);
+ return ticks(x);
+ }
+
+ constexpr ticks operator*(uint64_t multiplier) const {
+ zx_ticks_t x = 0;
+
+ if (unlikely(mul_overflow(value_, multiplier, &x))) {
+ if (value_ < 0) {
+ return infinite_past();
+ } else {
+ return infinite();
+ }
}
- constexpr ticks operator/(uint64_t divisor) const {
- return ticks(value_ / divisor);
- }
+ return ticks(x);
+ }
- constexpr uint64_t operator/(ticks other) const {
- return value_ / other.value_;
- }
+ constexpr ticks operator/(uint64_t divisor) const {
+ return ticks(static_cast<int64_t>(static_cast<uint64_t>(value_) / divisor));
+ }
- constexpr ticks& operator+=(ticks other) {
- value_ += other.value_;
- return *this;
- }
+ constexpr uint64_t operator/(ticks other) const {
+ return static_cast<uint64_t>(value_ / other.value_);
+ }
- constexpr ticks& operator-=(ticks other) {
- value_ -= other.value_;
- return *this;
- }
+ constexpr ticks operator%(uint64_t divisor) const {
+ return ticks(static_cast<int64_t>(static_cast<uint64_t>(value_) % divisor));
+ }
- constexpr ticks& operator*=(uint64_t multiplier) {
- value_ *= multiplier;
- return *this;
- }
+ constexpr uint64_t operator%(ticks other) const {
+ return static_cast<uint64_t>(value_ % other.value_);
+ }
- constexpr ticks& operator/=(uint64_t divisor) {
- value_ /= divisor;
- return *this;
- }
+ constexpr ticks& operator+=(ticks other) {
+ *this = *this + other;
+ return *this;
+ }
- constexpr bool operator==(ticks other) const { return value_ == other.value_; }
- constexpr bool operator!=(ticks other) const { return value_ != other.value_; }
- constexpr bool operator<(ticks other) const { return value_ < other.value_; }
- constexpr bool operator<=(ticks other) const { return value_ <= other.value_; }
- constexpr bool operator>(ticks other) const { return value_ > other.value_; }
- constexpr bool operator>=(ticks other) const { return value_ >= other.value_; }
+ constexpr ticks& operator-=(ticks other) {
+ *this = *this - other;
+ return *this;
+ }
-private:
- zx_ticks_t value_ = 0;
+ constexpr ticks& operator*=(uint64_t multiplier) {
+ *this = *this * multiplier;
+ return *this;
+ }
+
+ constexpr ticks& operator/=(uint64_t divisor) {
+ value_ /= divisor;
+ return *this;
+ }
+
+ constexpr ticks& operator%=(uint64_t divisor) {
+ value_ %= divisor;
+ return *this;
+ }
+
+ constexpr bool operator==(ticks other) const { return value_ == other.value_; }
+ constexpr bool operator!=(ticks other) const { return value_ != other.value_; }
+ constexpr bool operator<(ticks other) const { return value_ < other.value_; }
+ constexpr bool operator<=(ticks other) const { return value_ <= other.value_; }
+ constexpr bool operator>(ticks other) const { return value_ > other.value_; }
+ constexpr bool operator>=(ticks other) const { return value_ >= other.value_; }
+
+ private:
+ static constexpr zx_ticks_t INFINITE = std::numeric_limits<zx_ticks_t>::max();
+ static constexpr zx_ticks_t INFINITE_PAST = std::numeric_limits<zx_ticks_t>::min();
+
+ zx_ticks_t value_ = 0;
};
template <zx_clock_t kClockId>
-class basic_time {
-public:
- constexpr basic_time() = default;
+class basic_time final {
+ public:
+ constexpr basic_time() = default;
- explicit constexpr basic_time(zx_time_t value) : value_(value) {}
+ explicit constexpr basic_time(zx_time_t value) : value_(value) {}
- static constexpr basic_time<kClockId> infinite() {
- return basic_time<kClockId>(ZX_TIME_INFINITE);
- }
+#if __cplusplus >= 201703L
+ explicit constexpr basic_time(std::timespec ts) : value_(zx_time_from_timespec(ts)) {}
+#endif
- static constexpr basic_time<kClockId> infinite_past() {
- return basic_time<kClockId>(ZX_TIME_INFINITE_PAST);
- }
+ static constexpr basic_time<kClockId> infinite() {
+ return basic_time<kClockId>(ZX_TIME_INFINITE);
+ }
- constexpr zx_time_t get() const { return value_; }
+ static constexpr basic_time<kClockId> infinite_past() {
+ return basic_time<kClockId>(ZX_TIME_INFINITE_PAST);
+ }
- zx_time_t* get_address() { return &value_; }
+ constexpr zx_time_t get() const { return value_; }
- constexpr duration operator-(basic_time<kClockId> other) const {
- return duration(zx_time_sub_time(value_, other.value_));
- }
+ zx_time_t* get_address() { return &value_; }
- constexpr basic_time<kClockId> operator+(duration delta) const {
- return basic_time<kClockId>(zx_time_add_duration(value_, delta.get()));
- }
+ constexpr duration operator-(basic_time<kClockId> other) const {
+ return duration(zx_time_sub_time(value_, other.value_));
+ }
- constexpr basic_time<kClockId> operator-(duration delta) const {
- return basic_time<kClockId>(zx_time_sub_duration(value_, delta.get()));
- }
+ constexpr basic_time<kClockId> operator+(duration delta) const {
+ return basic_time<kClockId>(zx_time_add_duration(value_, delta.get()));
+ }
- constexpr basic_time<kClockId>& operator+=(duration delta) {
- value_ = zx_time_add_duration(value_, delta.get());
- return *this;
- }
+ constexpr basic_time<kClockId> operator-(duration delta) const {
+ return basic_time<kClockId>(zx_time_sub_duration(value_, delta.get()));
+ }
- constexpr basic_time<kClockId>& operator-=(duration delta) {
- value_ = zx_time_sub_duration(value_, delta.get());
- return *this;
- }
+ constexpr basic_time<kClockId>& operator+=(duration delta) {
+ value_ = zx_time_add_duration(value_, delta.get());
+ return *this;
+ }
- constexpr bool operator==(basic_time<kClockId> other) const { return value_ == other.value_; }
- constexpr bool operator!=(basic_time<kClockId> other) const { return value_ != other.value_; }
- constexpr bool operator<(basic_time<kClockId> other) const { return value_ < other.value_; }
- constexpr bool operator<=(basic_time<kClockId> other) const { return value_ <= other.value_; }
- constexpr bool operator>(basic_time<kClockId> other) const { return value_ > other.value_; }
- constexpr bool operator>=(basic_time<kClockId> other) const { return value_ >= other.value_; }
+ constexpr basic_time<kClockId>& operator-=(duration delta) {
+ value_ = zx_time_sub_duration(value_, delta.get());
+ return *this;
+ }
-private:
- zx_time_t value_ = 0;
+ constexpr bool operator==(basic_time<kClockId> other) const { return value_ == other.value_; }
+ constexpr bool operator!=(basic_time<kClockId> other) const { return value_ != other.value_; }
+ constexpr bool operator<(basic_time<kClockId> other) const { return value_ < other.value_; }
+ constexpr bool operator<=(basic_time<kClockId> other) const { return value_ <= other.value_; }
+ constexpr bool operator>(basic_time<kClockId> other) const { return value_ > other.value_; }
+ constexpr bool operator>=(basic_time<kClockId> other) const { return value_ >= other.value_; }
+
+#if __cplusplus >= 201703L
+ constexpr std::timespec to_timespec() const { return zx_timespec_from_time(value_); }
+#endif
+
+ private:
+ zx_time_t value_ = 0;
};
+template <zx_clock_t kClockId>
+constexpr basic_time<kClockId> operator+(duration delta, basic_time<kClockId> time) {
+ return time + delta;
+}
+
using time = basic_time<ZX_CLOCK_MONOTONIC>;
using time_utc = basic_time<ZX_CLOCK_UTC>;
using time_thread = basic_time<ZX_CLOCK_THREAD>;
-class clock {
-public:
- clock() = delete;
-
- template <zx_clock_t kClockId>
- static zx_status_t get(basic_time<kClockId>* result) {
- return zx_clock_get_new(kClockId, result->get_address());
- }
-
- static time get_monotonic() {
- return time(zx_clock_get_monotonic());
- }
-};
-
constexpr inline duration nsec(int64_t n) { return duration(ZX_NSEC(n)); }
constexpr inline duration usec(int64_t n) { return duration(ZX_USEC(n)); }
@@ -240,14 +300,12 @@
constexpr inline duration hour(int64_t n) { return duration(ZX_HOUR(n)); }
-inline zx_status_t nanosleep(zx::time deadline) {
- return zx_nanosleep(deadline.get());
-}
+inline zx_status_t nanosleep(zx::time deadline) { return zx_nanosleep(deadline.get()); }
inline time deadline_after(zx::duration nanoseconds) {
- return time(zx_deadline_after(nanoseconds.get()));
+ return time(zx_deadline_after(nanoseconds.get()));
}
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_TIME_H_
diff --git a/pkg/zx/include/lib/zx/timer.h b/pkg/zx/include/lib/zx/timer.h
index d7990ac..c119fc0 100644
--- a/pkg/zx/include/lib/zx/timer.h
+++ b/pkg/zx/include/lib/zx/timer.h
@@ -12,36 +12,34 @@
namespace zx {
-class timer : public object<timer> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_TIMER;
+class timer final : public object<timer> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_TIMER;
- constexpr timer() = default;
+ constexpr timer() = default;
- explicit timer(zx_handle_t value) : object(value) {}
+ explicit timer(zx_handle_t value) : object(value) {}
- explicit timer(handle&& h) : object(h.release()) {}
+ explicit timer(handle&& h) : object(h.release()) {}
- timer(timer&& other) : object(other.release()) {}
+ timer(timer&& other) : object(other.release()) {}
- timer& operator=(timer&& other) {
- reset(other.release());
- return *this;
- }
+ timer& operator=(timer&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint32_t options, zx_clock_t clock_id, timer* result);
+ static zx_status_t create(uint32_t options, zx_clock_t clock_id, timer* result);
- zx_status_t set(zx::time deadline, zx::duration slack) const {
- return zx_timer_set(get(), deadline.get(), slack.get());
- }
+ zx_status_t set(zx::time deadline, zx::duration slack) const {
+ return zx_timer_set(get(), deadline.get(), slack.get());
+ }
- zx_status_t cancel() const {
- return zx_timer_cancel(get());
- }
+ zx_status_t cancel() const { return zx_timer_cancel(get()); }
};
using unowned_timer = unowned<timer>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_TIMER_H_
diff --git a/pkg/zx/include/lib/zx/vcpu.h b/pkg/zx/include/lib/zx/vcpu.h
index dac3f3a..565d6fd 100644
--- a/pkg/zx/include/lib/zx/vcpu.h
+++ b/pkg/zx/include/lib/zx/vcpu.h
@@ -12,45 +12,40 @@
namespace zx {
-class vcpu : public object<vcpu> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VCPU;
+class vcpu final : public object<vcpu> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VCPU;
- constexpr vcpu() = default;
+ constexpr vcpu() = default;
- explicit vcpu(zx_handle_t value) : object(value) {}
+ explicit vcpu(zx_handle_t value) : object(value) {}
- explicit vcpu(handle&& h) : object(h.release()) {}
+ explicit vcpu(handle&& h) : object(h.release()) {}
- vcpu(vcpu&& other) : object(other.release()) {}
+ vcpu(vcpu&& other) : object(other.release()) {}
- vcpu& operator=(vcpu&& other) {
- reset(other.release());
- return *this;
- }
+ vcpu& operator=(vcpu&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(const guest& guest, uint32_t options,
- zx_gpaddr_t entry, vcpu* result);
+ static zx_status_t create(const guest& guest, uint32_t options, zx_gpaddr_t entry, vcpu* result);
- zx_status_t resume(zx_port_packet_t* packet) {
- return zx_vcpu_resume(get(), packet);
- }
+ zx_status_t resume(zx_port_packet_t* packet) const { return zx_vcpu_resume(get(), packet); }
- zx_status_t interrupt(uint32_t interrupt) {
- return zx_vcpu_interrupt(get(), interrupt);
- }
+ zx_status_t interrupt(uint32_t interrupt) const { return zx_vcpu_interrupt(get(), interrupt); }
- zx_status_t read_state(uint32_t kind, void* buf, size_t len) const {
- return zx_vcpu_read_state(get(), kind, buf, len);
- }
+ zx_status_t read_state(uint32_t kind, void* buf, size_t len) const {
+ return zx_vcpu_read_state(get(), kind, buf, len);
+ }
- zx_status_t write_state(uint32_t kind, const void* buf, size_t len) {
- return zx_vcpu_write_state(get(), kind, buf, len);
- }
+ zx_status_t write_state(uint32_t kind, const void* buf, size_t len) const {
+ return zx_vcpu_write_state(get(), kind, buf, len);
+ }
};
using unowned_vcpu = unowned<vcpu>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_VCPU_H_
diff --git a/pkg/zx/include/lib/zx/vmar.h b/pkg/zx/include/lib/zx/vmar.h
index 1553110..b861b33 100644
--- a/pkg/zx/include/lib/zx/vmar.h
+++ b/pkg/zx/include/lib/zx/vmar.h
@@ -13,50 +13,57 @@
// A wrapper for handles to VMARs. Note that vmar::~vmar() does not execute
// vmar::destroy(), it just closes the handle.
-class vmar : public object<vmar> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VMAR;
+class vmar final : public object<vmar> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VMAR;
- constexpr vmar() = default;
+ constexpr vmar() = default;
- explicit vmar(zx_handle_t value) : object(value) {}
+ explicit vmar(zx_handle_t value) : object(value) {}
- explicit vmar(handle&& h) : object(h.release()) {}
+ explicit vmar(handle&& h) : object(h.release()) {}
- vmar(vmar&& other) : vmar(other.release()) {}
+ vmar(vmar&& other) : vmar(other.release()) {}
- vmar& operator=(vmar&& other) {
- reset(other.release());
- return *this;
- }
+ vmar& operator=(vmar&& other) {
+ reset(other.release());
+ return *this;
+ }
- zx_status_t map(size_t vmar_offset, const vmo& vmo_handle, uint64_t vmo_offset,
- size_t len, zx_vm_option_t options, uintptr_t* ptr) const {
- return zx_vmar_map(get(), options, vmar_offset, vmo_handle.get(), vmo_offset, len, ptr);
- }
+ // DEPRECATED: Argument order does not match the C version.
+ zx_status_t map(size_t vmar_offset, const vmo& vmo_handle, uint64_t vmo_offset, size_t len,
+ zx_vm_option_t options, zx_vaddr_t* ptr) const {
+ return zx_vmar_map(get(), options, vmar_offset, vmo_handle.get(), vmo_offset, len, ptr);
+ }
- zx_status_t unmap(uintptr_t address, size_t len) const {
- return zx_vmar_unmap(get(), address, len);
- }
+ zx_status_t map(zx_vm_option_t options, size_t vmar_offset, const vmo& vmo_handle,
+ uint64_t vmo_offset, size_t len, zx_vaddr_t* ptr) const {
+ return zx_vmar_map(get(), options, vmar_offset, vmo_handle.get(), vmo_offset, len, ptr);
+ }
- zx_status_t protect(uintptr_t address, size_t len, zx_vm_option_t prot) const {
- return zx_vmar_protect(get(), prot, address, len);
- }
+ zx_status_t unmap(uintptr_t address, size_t len) const {
+ return zx_vmar_unmap(get(), address, len);
+ }
- zx_status_t destroy() const {
- return zx_vmar_destroy(get());
- }
+ zx_status_t protect2(zx_vm_option_t prot, uintptr_t address, size_t len) const {
+ return zx_vmar_protect(get(), prot, address, len);
+ }
- zx_status_t allocate(size_t offset, size_t size, uint32_t flags,
- vmar* child, uintptr_t* child_addr) const;
+ zx_status_t op_range(uint32_t op, uint64_t offset, uint64_t size, void* buffer,
+ size_t buffer_size) const {
+ return zx_vmar_op_range(get(), op, offset, size, buffer, buffer_size);
+ }
- static inline unowned<vmar> root_self() {
- return unowned<vmar>(zx_vmar_root_self());
- }
+ zx_status_t destroy() const { return zx_vmar_destroy(get()); }
+
+ zx_status_t allocate2(uint32_t options, size_t offset, size_t size, vmar* child,
+ uintptr_t* child_addr) const;
+
+ static inline unowned<vmar> root_self() { return unowned<vmar>(zx_vmar_root_self()); }
};
using unowned_vmar = unowned<vmar>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_VMAR_H_
diff --git a/pkg/zx/include/lib/zx/vmo.h b/pkg/zx/include/lib/zx/vmo.h
index 82e2cab..ae168a6 100644
--- a/pkg/zx/include/lib/zx/vmo.h
+++ b/pkg/zx/include/lib/zx/vmo.h
@@ -13,77 +13,72 @@
class bti;
-class vmo : public object<vmo> {
-public:
- static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VMO;
+class vmo final : public object<vmo> {
+ public:
+ static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_VMO;
- constexpr vmo() = default;
+ constexpr vmo() = default;
- explicit vmo(zx_handle_t value) : object(value) {}
+ explicit vmo(zx_handle_t value) : object(value) {}
- explicit vmo(handle&& h) : object(h.release()) {}
+ explicit vmo(handle&& h) : object(h.release()) {}
- vmo(vmo&& other) : object(other.release()) {}
+ vmo(vmo&& other) : object(other.release()) {}
- vmo& operator=(vmo&& other) {
- reset(other.release());
- return *this;
- }
+ vmo& operator=(vmo&& other) {
+ reset(other.release());
+ return *this;
+ }
- static zx_status_t create(uint64_t size, uint32_t options, vmo* result);
- static zx_status_t create_contiguous(
- const bti& bti, size_t size, uint32_t alignment_log2, vmo* result);
- static zx_status_t create_physical(
- const resource& resource, zx_paddr_t paddr, size_t size, vmo* result);
+ static zx_status_t create(uint64_t size, uint32_t options, vmo* result);
+ static zx_status_t create_contiguous(const bti& bti, size_t size, uint32_t alignment_log2,
+ vmo* result);
+ static zx_status_t create_physical(const resource& resource, zx_paddr_t paddr, size_t size,
+ vmo* result);
- zx_status_t read(void* data, uint64_t offset, size_t len) const {
- return zx_vmo_read(get(), data, offset, len);
- }
+ zx_status_t read(void* data, uint64_t offset, size_t len) const {
+ return zx_vmo_read(get(), data, offset, len);
+ }
- zx_status_t write(const void* data, uint64_t offset, size_t len) const {
- return zx_vmo_write(get(), data, offset, len);
- }
+ zx_status_t write(const void* data, uint64_t offset, size_t len) const {
+ return zx_vmo_write(get(), data, offset, len);
+ }
- zx_status_t get_size(uint64_t* size) const {
- return zx_vmo_get_size(get(), size);
- }
+ zx_status_t get_size(uint64_t* size) const { return zx_vmo_get_size(get(), size); }
- zx_status_t set_size(uint64_t size) const {
- return zx_vmo_set_size(get(), size);
- }
+ zx_status_t set_size(uint64_t size) const { return zx_vmo_set_size(get(), size); }
- zx_status_t clone(uint32_t options, uint64_t offset, uint64_t size,
- vmo* result) const {
- // Allow for the caller aliasing |result| to |this|.
- vmo h;
- zx_status_t status = zx_vmo_clone(
- get(), options, offset, size, h.reset_and_get_address());
- result->reset(h.release());
- return status;
- }
+ zx_status_t create_child(uint32_t options, uint64_t offset, uint64_t size, vmo* result) const {
+ // Allow for the caller aliasing |result| to |this|.
+ vmo h;
+ zx_status_t status =
+ zx_vmo_create_child(get(), options, offset, size, h.reset_and_get_address());
+ result->reset(h.release());
+ return status;
+ }
- zx_status_t op_range(uint32_t op, uint64_t offset, uint64_t size,
- void* buffer, size_t buffer_size) const {
- return zx_vmo_op_range(get(), op, offset, size, buffer, buffer_size);
- }
+ zx_status_t op_range(uint32_t op, uint64_t offset, uint64_t size, void* buffer,
+ size_t buffer_size) const {
+ return zx_vmo_op_range(get(), op, offset, size, buffer, buffer_size);
+ }
- zx_status_t set_cache_policy(uint32_t cache_policy) {
- return zx_vmo_set_cache_policy(get(), cache_policy);
- }
+ zx_status_t set_cache_policy(uint32_t cache_policy) const {
+ return zx_vmo_set_cache_policy(get(), cache_policy);
+ }
- zx_status_t replace_as_executable(const handle& vmex, vmo* result) {
- zx_handle_t h = ZX_HANDLE_INVALID;
- zx_status_t status = zx_vmo_replace_as_executable(value_, vmex.get(), &h);
- // We store ZX_HANDLE_INVALID to value_ before calling reset on result
- // in case result == this.
- value_ = ZX_HANDLE_INVALID;
- result->reset(h);
- return status;
- }
+ zx_status_t replace_as_executable(const resource& vmex, vmo* result) {
+ zx_handle_t h = ZX_HANDLE_INVALID;
+ zx_status_t status = zx_vmo_replace_as_executable(value_, vmex.get(), &h);
+ // We store ZX_HANDLE_INVALID to value_ before calling reset on result
+ // in case result == this.
+ value_ = ZX_HANDLE_INVALID;
+ result->reset(h);
+ return status;
+ }
};
using unowned_vmo = unowned<vmo>;
-} // namespace zx
+} // namespace zx
#endif // LIB_ZX_VMO_H_
diff --git a/pkg/zx/interrupt.cc b/pkg/zx/interrupt.cc
new file mode 100644
index 0000000..7cb0013
--- /dev/null
+++ b/pkg/zx/interrupt.cc
@@ -0,0 +1,18 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/interrupt.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t interrupt::create(const resource& resource, uint32_t vector, uint32_t options,
+ interrupt* result) {
+ // Assume |result| uses a distinct container from |resource|, due to
+ // strict aliasing.
+ return zx_interrupt_create(resource.get(), vector, options, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/interrupt.cpp b/pkg/zx/interrupt.cpp
deleted file mode 100644
index 609406d..0000000
--- a/pkg/zx/interrupt.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/interrupt.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t interrupt::create(const resource& resource, uint32_t vector,
- uint32_t options, interrupt* result) {
- // Assume |result| uses a distinct container from |resource|, due to
- // strict aliasing.
- return zx_interrupt_create(
- resource.get(), vector, options, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/iommu.cc b/pkg/zx/iommu.cc
new file mode 100644
index 0000000..a059eea
--- /dev/null
+++ b/pkg/zx/iommu.cc
@@ -0,0 +1,16 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/iommu.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t iommu::create(const resource& resource, uint32_t type, const void* desc,
+ size_t desc_size, iommu* result) {
+ return zx_iommu_create(resource.get(), type, desc, desc_size, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/iommu.cpp b/pkg/zx/iommu.cpp
deleted file mode 100644
index ad3c078..0000000
--- a/pkg/zx/iommu.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/iommu.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t iommu::create(const resource& resource, uint32_t type, const void* desc,
- size_t desc_size, iommu* result) {
- return zx_iommu_create(resource.get(), type, desc, desc_size, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/job.cc b/pkg/zx/job.cc
new file mode 100644
index 0000000..2a63ab0
--- /dev/null
+++ b/pkg/zx/job.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/job.h>
+
+#include <lib/zx/process.h>
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t job::create(const job& parent, uint32_t flags, job* result) {
+ // Allow for aliasing of the same container to |result| and |parent|.
+ job h;
+ zx_status_t status = zx_job_create(parent.get(), flags, h.reset_and_get_address());
+ result->reset(h.release());
+ return status;
+}
+
+zx_status_t job::get_child(uint64_t koid, zx_rights_t rights, process* result) const {
+ // Assume |result| and |this| are distinct containers, due to strict
+ // aliasing.
+ return zx_object_get_child(value_, koid, rights, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/job.cpp b/pkg/zx/job.cpp
deleted file mode 100644
index 6989589..0000000
--- a/pkg/zx/job.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/job.h>
-
-#include <lib/zx/process.h>
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t job::create(const job& parent, uint32_t flags, job* result) {
- // Allow for aliasing of the same container to |result| and |parent|.
- job h;
- zx_status_t status =
- zx_job_create(parent.get(), flags, h.reset_and_get_address());
- result->reset(h.release());
- return status;
-}
-
-zx_status_t job::get_child(uint64_t koid, zx_rights_t rights,
- process* result) const {
- // Assume |result| and |this| are distinct containers, due to strict
- // aliasing.
- return zx_object_get_child(
- value_, koid, rights, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/log.cpp b/pkg/zx/log.cpp
deleted file mode 100644
index 4c06b36..0000000
--- a/pkg/zx/log.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/log.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t log::create(uint32_t flags, log* result) {
- return zx_debuglog_create(ZX_HANDLE_INVALID, flags, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/meta.json b/pkg/zx/meta.json
index 27622e6..cefbaff 100644
--- a/pkg/zx/meta.json
+++ b/pkg/zx/meta.json
@@ -1,113 +1,68 @@
{
- "banjo_deps": [],
- "deps": [],
- "fidl_deps": [],
- "files": [
- "pkg/zx/bti.cpp",
- "pkg/zx/channel.cpp",
- "pkg/zx/debuglog.cpp",
- "pkg/zx/event.cpp",
- "pkg/zx/eventpair.cpp",
- "pkg/zx/fifo.cpp",
- "pkg/zx/guest.cpp",
- "pkg/zx/interrupt.cpp",
- "pkg/zx/iommu.cpp",
- "pkg/zx/job.cpp",
- "pkg/zx/log.cpp",
- "pkg/zx/port.cpp",
- "pkg/zx/process.cpp",
- "pkg/zx/profile.cpp",
- "pkg/zx/resource.cpp",
- "pkg/zx/socket.cpp",
- "pkg/zx/thread.cpp",
- "pkg/zx/timer.cpp",
- "pkg/zx/vcpu.cpp",
- "pkg/zx/vmar.cpp",
- "pkg/zx/vmo.cpp",
- "pkg/zx/include/lib/zx/bti.h",
- "pkg/zx/include/lib/zx/channel.h",
- "pkg/zx/include/lib/zx/debuglog.h",
- "pkg/zx/include/lib/zx/event.h",
- "pkg/zx/include/lib/zx/eventpair.h",
- "pkg/zx/include/lib/zx/fifo.h",
- "pkg/zx/include/lib/zx/guest.h",
- "pkg/zx/include/lib/zx/handle.h",
- "pkg/zx/include/lib/zx/interrupt.h",
- "pkg/zx/include/lib/zx/iommu.h",
- "pkg/zx/include/lib/zx/job.h",
- "pkg/zx/include/lib/zx/log.h",
- "pkg/zx/include/lib/zx/object.h",
- "pkg/zx/include/lib/zx/object_traits.h",
- "pkg/zx/include/lib/zx/pmt.h",
- "pkg/zx/include/lib/zx/port.h",
- "pkg/zx/include/lib/zx/process.h",
- "pkg/zx/include/lib/zx/profile.h",
- "pkg/zx/include/lib/zx/resource.h",
- "pkg/zx/include/lib/zx/socket.h",
- "pkg/zx/include/lib/zx/suspend_token.h",
- "pkg/zx/include/lib/zx/task.h",
- "pkg/zx/include/lib/zx/thread.h",
- "pkg/zx/include/lib/zx/time.h",
- "pkg/zx/include/lib/zx/timer.h",
- "pkg/zx/include/lib/zx/vcpu.h",
- "pkg/zx/include/lib/zx/vmar.h",
- "pkg/zx/include/lib/zx/vmo.h"
- ],
+ "banjo_deps": [],
+ "deps": [],
+ "fidl_deps": [],
"headers": [
- "pkg/zx/include/lib/zx/bti.h",
- "pkg/zx/include/lib/zx/channel.h",
- "pkg/zx/include/lib/zx/debuglog.h",
- "pkg/zx/include/lib/zx/event.h",
- "pkg/zx/include/lib/zx/eventpair.h",
- "pkg/zx/include/lib/zx/fifo.h",
- "pkg/zx/include/lib/zx/guest.h",
- "pkg/zx/include/lib/zx/handle.h",
- "pkg/zx/include/lib/zx/interrupt.h",
- "pkg/zx/include/lib/zx/iommu.h",
- "pkg/zx/include/lib/zx/job.h",
- "pkg/zx/include/lib/zx/log.h",
- "pkg/zx/include/lib/zx/object.h",
- "pkg/zx/include/lib/zx/object_traits.h",
- "pkg/zx/include/lib/zx/pmt.h",
- "pkg/zx/include/lib/zx/port.h",
- "pkg/zx/include/lib/zx/process.h",
- "pkg/zx/include/lib/zx/profile.h",
- "pkg/zx/include/lib/zx/resource.h",
- "pkg/zx/include/lib/zx/socket.h",
- "pkg/zx/include/lib/zx/suspend_token.h",
- "pkg/zx/include/lib/zx/task.h",
- "pkg/zx/include/lib/zx/thread.h",
- "pkg/zx/include/lib/zx/time.h",
- "pkg/zx/include/lib/zx/timer.h",
- "pkg/zx/include/lib/zx/vcpu.h",
- "pkg/zx/include/lib/zx/vmar.h",
+ "pkg/zx/include/lib/zx/bti.h",
+ "pkg/zx/include/lib/zx/channel.h",
+ "pkg/zx/include/lib/zx/clock.h",
+ "pkg/zx/include/lib/zx/debuglog.h",
+ "pkg/zx/include/lib/zx/event.h",
+ "pkg/zx/include/lib/zx/eventpair.h",
+ "pkg/zx/include/lib/zx/exception.h",
+ "pkg/zx/include/lib/zx/fifo.h",
+ "pkg/zx/include/lib/zx/guest.h",
+ "pkg/zx/include/lib/zx/handle.h",
+ "pkg/zx/include/lib/zx/interrupt.h",
+ "pkg/zx/include/lib/zx/iommu.h",
+ "pkg/zx/include/lib/zx/job.h",
+ "pkg/zx/include/lib/zx/msi.h",
+ "pkg/zx/include/lib/zx/object.h",
+ "pkg/zx/include/lib/zx/object_traits.h",
+ "pkg/zx/include/lib/zx/pager.h",
+ "pkg/zx/include/lib/zx/pmt.h",
+ "pkg/zx/include/lib/zx/port.h",
+ "pkg/zx/include/lib/zx/process.h",
+ "pkg/zx/include/lib/zx/profile.h",
+ "pkg/zx/include/lib/zx/resource.h",
+ "pkg/zx/include/lib/zx/socket.h",
+ "pkg/zx/include/lib/zx/stream.h",
+ "pkg/zx/include/lib/zx/suspend_token.h",
+ "pkg/zx/include/lib/zx/task.h",
+ "pkg/zx/include/lib/zx/thread.h",
+ "pkg/zx/include/lib/zx/time.h",
+ "pkg/zx/include/lib/zx/timer.h",
+ "pkg/zx/include/lib/zx/vcpu.h",
+ "pkg/zx/include/lib/zx/vmar.h",
"pkg/zx/include/lib/zx/vmo.h"
- ],
- "include_dir": "pkg/zx/include",
- "name": "zx",
- "root": "pkg/zx",
+ ],
+ "include_dir": "pkg/zx/include",
+ "name": "zx",
+ "root": "pkg/zx",
"sources": [
- "pkg/zx/bti.cpp",
- "pkg/zx/channel.cpp",
- "pkg/zx/debuglog.cpp",
- "pkg/zx/event.cpp",
- "pkg/zx/eventpair.cpp",
- "pkg/zx/fifo.cpp",
- "pkg/zx/guest.cpp",
- "pkg/zx/interrupt.cpp",
- "pkg/zx/iommu.cpp",
- "pkg/zx/job.cpp",
- "pkg/zx/log.cpp",
- "pkg/zx/port.cpp",
- "pkg/zx/process.cpp",
- "pkg/zx/profile.cpp",
- "pkg/zx/resource.cpp",
- "pkg/zx/socket.cpp",
- "pkg/zx/thread.cpp",
- "pkg/zx/timer.cpp",
- "pkg/zx/vcpu.cpp",
- "pkg/zx/vmar.cpp",
- "pkg/zx/vmo.cpp"
- ],
+ "pkg/zx/bti.cc",
+ "pkg/zx/channel.cc",
+ "pkg/zx/debuglog.cc",
+ "pkg/zx/event.cc",
+ "pkg/zx/eventpair.cc",
+ "pkg/zx/fifo.cc",
+ "pkg/zx/guest.cc",
+ "pkg/zx/interrupt.cc",
+ "pkg/zx/iommu.cc",
+ "pkg/zx/job.cc",
+ "pkg/zx/msi.cc",
+ "pkg/zx/pager.cc",
+ "pkg/zx/port.cc",
+ "pkg/zx/process.cc",
+ "pkg/zx/profile.cc",
+ "pkg/zx/resource.cc",
+ "pkg/zx/socket.cc",
+ "pkg/zx/stream.cc",
+ "pkg/zx/thread.cc",
+ "pkg/zx/timer.cc",
+ "pkg/zx/vcpu.cc",
+ "pkg/zx/vmar.cc",
+ "pkg/zx/vmo.cc"
+ ],
"type": "cc_source_library"
}
\ No newline at end of file
diff --git a/pkg/zx/msi.cc b/pkg/zx/msi.cc
new file mode 100644
index 0000000..86567de
--- /dev/null
+++ b/pkg/zx/msi.cc
@@ -0,0 +1,21 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/interrupt.h>
+#include <lib/zx/msi.h>
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t msi::allocate(const resource& resource, uint32_t count, msi* result) {
+ return zx_msi_allocate(resource.get(), count, result->reset_and_get_address());
+}
+
+zx_status_t msi::create(const msi& msi, uint32_t options, uint32_t msi_id, const vmo& vmo,
+ size_t vmo_offset, interrupt* result) {
+ return zx_msi_create(msi.get(), options, msi_id, vmo.get(), vmo_offset,
+ result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/pager.cc b/pkg/zx/pager.cc
new file mode 100644
index 0000000..b6131d6
--- /dev/null
+++ b/pkg/zx/pager.cc
@@ -0,0 +1,13 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/pager.h>
+
+namespace zx {
+
+zx_status_t pager::create(uint32_t options, pager* result) {
+ return zx_pager_create(options, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/port.cc b/pkg/zx/port.cc
new file mode 100644
index 0000000..7999684
--- /dev/null
+++ b/pkg/zx/port.cc
@@ -0,0 +1,15 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/port.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t port::create(uint32_t options, port* result) {
+ return zx_port_create(options, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/port.cpp b/pkg/zx/port.cpp
deleted file mode 100644
index f6ca294..0000000
--- a/pkg/zx/port.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/port.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t port::create(uint32_t options, port* result) {
- return zx_port_create(options, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/process.cc b/pkg/zx/process.cc
new file mode 100644
index 0000000..d17fd3a
--- /dev/null
+++ b/pkg/zx/process.cc
@@ -0,0 +1,34 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/process.h>
+
+#include <zircon/syscalls.h>
+
+#include <lib/zx/job.h>
+#include <lib/zx/thread.h>
+#include <lib/zx/vmar.h>
+
+namespace zx {
+
+zx_status_t process::create(const job& job, const char* name, uint32_t name_len, uint32_t flags,
+ process* proc, vmar* vmar) {
+ // Assume |proc|, |vmar| and |job| must refer to different containers, due
+ // to strict aliasing.
+ return zx_process_create(job.get(), name, name_len, flags, proc->reset_and_get_address(),
+ vmar->reset_and_get_address());
+}
+
+zx_status_t process::start(const thread& thread_handle, uintptr_t entry, uintptr_t stack,
+ handle arg_handle, uintptr_t arg2) const {
+ return zx_process_start(get(), thread_handle.get(), entry, stack, arg_handle.release(), arg2);
+}
+
+zx_status_t process::get_child(uint64_t koid, zx_rights_t rights, thread* result) const {
+ // Assume |result| and |this| are distinct containers, due to strict
+ // aliasing.
+ return zx_object_get_child(value_, koid, rights, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/process.cpp b/pkg/zx/process.cpp
deleted file mode 100644
index c47fa79..0000000
--- a/pkg/zx/process.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/process.h>
-
-#include <zircon/syscalls.h>
-
-#include <lib/zx/job.h>
-#include <lib/zx/thread.h>
-#include <lib/zx/vmar.h>
-
-namespace zx {
-
-zx_status_t process::create(const job& job, const char* name, uint32_t name_len,
- uint32_t flags, process* proc, vmar* vmar) {
- // Assume |proc|, |vmar| and |job| must refer to different containers, due
- // to strict aliasing.
- return zx_process_create(
- job.get(), name, name_len, flags, proc->reset_and_get_address(),
- vmar->reset_and_get_address());
-}
-
-zx_status_t process::start(const thread& thread_handle, uintptr_t entry,
- uintptr_t stack, handle arg_handle,
- uintptr_t arg2) const {
- return zx_process_start(get(), thread_handle.get(), entry, stack, arg_handle.release(), arg2);
-}
-
-zx_status_t process::get_child(uint64_t koid, zx_rights_t rights,
- thread* result) const {
- // Assume |result| and |this| are distinct containers, due to strict
- // aliasing.
- return zx_object_get_child(
- value_, koid, rights, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/profile.cc b/pkg/zx/profile.cc
new file mode 100644
index 0000000..40a424d
--- /dev/null
+++ b/pkg/zx/profile.cc
@@ -0,0 +1,17 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/profile.h>
+
+#include <zircon/syscalls.h>
+#include <zircon/syscalls/profile.h>
+
+namespace zx {
+
+zx_status_t profile::create(const job& job, uint32_t options, const zx_profile_info_t* info,
+ profile* result) {
+ return zx_profile_create(job.get(), options, info, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/profile.cpp b/pkg/zx/profile.cpp
deleted file mode 100644
index 9e67647..0000000
--- a/pkg/zx/profile.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/profile.h>
-
-#include <zircon/syscalls.h>
-#include <zircon/syscalls/profile.h>
-
-namespace zx {
-
-zx_status_t profile::create(const resource& resource, const zx_profile_info_t* info, profile* result) {
- return zx_profile_create(resource.get(), info, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/resource.cc b/pkg/zx/resource.cc
new file mode 100644
index 0000000..b4c2ec5
--- /dev/null
+++ b/pkg/zx/resource.cc
@@ -0,0 +1,20 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/resource.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t resource::create(const resource& parent, uint32_t options, uint64_t base, size_t len,
+ const char* name, size_t namelen, resource* result) {
+ resource h;
+ zx_status_t status = zx_resource_create(parent.get(), options, base, len, name, namelen,
+ h.reset_and_get_address());
+ result->reset(h.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/resource.cpp b/pkg/zx/resource.cpp
deleted file mode 100644
index 8f29841..0000000
--- a/pkg/zx/resource.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/resource.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t resource::create(const resource& parent,
- uint32_t options,
- uint64_t base,
- size_t len,
- const char* name,
- size_t namelen,
- resource* result) {
- resource h;
- zx_status_t status = zx_resource_create(parent.get(), options, base, len, name, namelen,
- h.reset_and_get_address());
- result->reset(h.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/socket.cc b/pkg/zx/socket.cc
new file mode 100644
index 0000000..2d07ac7
--- /dev/null
+++ b/pkg/zx/socket.cc
@@ -0,0 +1,23 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/socket.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t socket::create(uint32_t flags, socket* endpoint0, socket* endpoint1) {
+ // Ensure aliasing of both out parameters to the same container
+ // has a well-defined result, and does not leak.
+ socket h0;
+ socket h1;
+ zx_status_t status =
+ zx_socket_create(flags, h0.reset_and_get_address(), h1.reset_and_get_address());
+ endpoint0->reset(h0.release());
+ endpoint1->reset(h1.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/socket.cpp b/pkg/zx/socket.cpp
deleted file mode 100644
index 76f5071..0000000
--- a/pkg/zx/socket.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/socket.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t socket::create(uint32_t flags, socket* endpoint0,
- socket* endpoint1) {
- // Ensure aliasing of both out parameters to the same container
- // has a well-defined result, and does not leak.
- socket h0;
- socket h1;
- zx_status_t status = zx_socket_create(
- flags, h0.reset_and_get_address(),
- h1.reset_and_get_address());
- endpoint0->reset(h0.release());
- endpoint1->reset(h1.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/stream.cc b/pkg/zx/stream.cc
new file mode 100644
index 0000000..f5b12cb
--- /dev/null
+++ b/pkg/zx/stream.cc
@@ -0,0 +1,17 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/stream.h>
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t stream::create(uint32_t options, const vmo& vmo_handle, zx_off_t seek,
+ stream* out_stream) {
+ // Assume |out_stream| and |vmo_handle| must refer to different containers, due
+ // to strict aliasing.
+ return zx_stream_create(options, vmo_handle.get(), seek, out_stream->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/thread.cc b/pkg/zx/thread.cc
new file mode 100644
index 0000000..9856c04
--- /dev/null
+++ b/pkg/zx/thread.cc
@@ -0,0 +1,20 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/thread.h>
+
+#include <zircon/syscalls.h>
+
+#include <lib/zx/process.h>
+
+namespace zx {
+
+zx_status_t thread::create(const process& process, const char* name, uint32_t name_len,
+ uint32_t flags, thread* result) {
+ // Assume |result| and |process| must refer to different containers, due
+ // to strict aliasing.
+ return zx_thread_create(process.get(), name, name_len, flags, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/thread.cpp b/pkg/zx/thread.cpp
deleted file mode 100644
index 4b9ab4c..0000000
--- a/pkg/zx/thread.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/thread.h>
-
-#include <zircon/syscalls.h>
-
-#include <lib/zx/process.h>
-
-namespace zx {
-
-zx_status_t thread::create(const process& process, const char* name,
- uint32_t name_len, uint32_t flags, thread* result) {
- // Assume |result| and |process| must refer to different containers, due
- // to strict aliasing.
- return zx_thread_create(
- process.get(), name, name_len, flags, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/timer.cc b/pkg/zx/timer.cc
new file mode 100644
index 0000000..895e20c
--- /dev/null
+++ b/pkg/zx/timer.cc
@@ -0,0 +1,15 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/timer.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t timer::create(uint32_t options, zx_clock_t clock_id, timer* result) {
+ return zx_timer_create(options, clock_id, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/timer.cpp b/pkg/zx/timer.cpp
deleted file mode 100644
index f67ddc3..0000000
--- a/pkg/zx/timer.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/timer.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t timer::create(uint32_t options, zx_clock_t clock_id, timer* result) {
- return zx_timer_create(options, clock_id, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/vcpu.cc b/pkg/zx/vcpu.cc
new file mode 100644
index 0000000..1951adb
--- /dev/null
+++ b/pkg/zx/vcpu.cc
@@ -0,0 +1,17 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/vcpu.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t vcpu::create(const guest& guest, uint32_t options, zx_gpaddr_t entry, vcpu* vcpu) {
+ // Assume |guest| and |vcpu| must refer to different containers, due to
+ // strict aliasing.
+ return zx_vcpu_create(guest.get(), options, entry, vcpu->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/vcpu.cpp b/pkg/zx/vcpu.cpp
deleted file mode 100644
index 5584a5e..0000000
--- a/pkg/zx/vcpu.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/vcpu.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t vcpu::create(const guest& guest, uint32_t options,
- zx_gpaddr_t entry, vcpu* vcpu) {
- // Assume |guest| and |vcpu| must refer to different containers, due to
- // strict aliasing.
- return zx_vcpu_create(guest.get(), options, entry,
- vcpu->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/pkg/zx/vmar.cc b/pkg/zx/vmar.cc
new file mode 100644
index 0000000..2ae938e
--- /dev/null
+++ b/pkg/zx/vmar.cc
@@ -0,0 +1,21 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/vmar.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t vmar::allocate2(uint32_t options, size_t offset, size_t size, vmar* child,
+ uintptr_t* child_addr) const {
+ // Allow for aliasing of |child| to the same container as |this|.
+ vmar h;
+ zx_status_t status =
+ zx_vmar_allocate(get(), options, offset, size, h.reset_and_get_address(), child_addr);
+ child->reset(h.release());
+ return status;
+}
+
+} // namespace zx
diff --git a/pkg/zx/vmar.cpp b/pkg/zx/vmar.cpp
deleted file mode 100644
index 60148f2..0000000
--- a/pkg/zx/vmar.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/vmar.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t vmar::allocate(size_t offset, size_t size, zx_vm_option_t options,
- vmar* child, uintptr_t* child_addr) const {
- // Allow for aliasing of |child| to the same container as |this|.
- vmar h;
- zx_status_t status = zx_vmar_allocate(
- get(), options, offset, size, h.reset_and_get_address(), child_addr);
- child->reset(h.release());
- return status;
-}
-
-} // namespace zx
diff --git a/pkg/zx/vmo.cc b/pkg/zx/vmo.cc
new file mode 100644
index 0000000..9902a2e
--- /dev/null
+++ b/pkg/zx/vmo.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <lib/zx/vmo.h>
+#include <lib/zx/bti.h>
+
+#include <zircon/syscalls.h>
+
+namespace zx {
+
+zx_status_t vmo::create(uint64_t size, uint32_t options, vmo* result) {
+ return zx_vmo_create(size, options, result->reset_and_get_address());
+}
+
+zx_status_t vmo::create_contiguous(const bti& bti, size_t size, uint32_t alignment_log2,
+ vmo* result) {
+ return zx_vmo_create_contiguous(bti.get(), size, alignment_log2, result->reset_and_get_address());
+}
+
+zx_status_t vmo::create_physical(const resource& resource, zx_paddr_t paddr, size_t size,
+ vmo* result) {
+ return zx_vmo_create_physical(resource.get(), paddr, size, result->reset_and_get_address());
+}
+
+} // namespace zx
diff --git a/pkg/zx/vmo.cpp b/pkg/zx/vmo.cpp
deleted file mode 100644
index 130c71f..0000000
--- a/pkg/zx/vmo.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/zx/vmo.h>
-#include <lib/zx/bti.h>
-
-#include <zircon/syscalls.h>
-
-namespace zx {
-
-zx_status_t vmo::create(uint64_t size, uint32_t options, vmo* result) {
- return zx_vmo_create(size, options, result->reset_and_get_address());
-}
-
-zx_status_t vmo::create_contiguous(
- const bti& bti, size_t size, uint32_t alignment_log2, vmo* result) {
- return zx_vmo_create_contiguous(bti.get(), size, alignment_log2,
- result->reset_and_get_address());
-}
-
-zx_status_t vmo::create_physical(
- const resource& resource, zx_paddr_t paddr, size_t size, vmo* result) {
- return zx_vmo_create_physical(resource.get(), paddr, size, result->reset_and_get_address());
-}
-
-} // namespace zx
diff --git a/tools/bootserver b/tools/bootserver
deleted file mode 100755
index 3683705..0000000
--- a/tools/bootserver
+++ /dev/null
Binary files differ
diff --git a/tools/bootserver-meta.json b/tools/bootserver-meta.json
deleted file mode 100644
index 56c74dc..0000000
--- a/tools/bootserver-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/bootserver"
- ],
- "name": "bootserver",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/far b/tools/far
deleted file mode 100755
index 2474697..0000000
--- a/tools/far
+++ /dev/null
Binary files differ
diff --git a/tools/far-meta.json b/tools/far-meta.json
deleted file mode 100644
index 6d75f3b..0000000
--- a/tools/far-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/far"
- ],
- "name": "far",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/fidl-format b/tools/fidl-format
deleted file mode 100755
index 86609ea..0000000
--- a/tools/fidl-format
+++ /dev/null
Binary files differ
diff --git a/tools/fidl-format-meta.json b/tools/fidl-format-meta.json
deleted file mode 100644
index 9cf524d..0000000
--- a/tools/fidl-format-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/fidl-format"
- ],
- "name": "fidl-format",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/fidlc b/tools/fidlc
deleted file mode 100755
index a0e50cd..0000000
--- a/tools/fidlc
+++ /dev/null
Binary files differ
diff --git a/tools/fidlc-meta.json b/tools/fidlc-meta.json
deleted file mode 100644
index 53c3a51..0000000
--- a/tools/fidlc-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/fidlc"
- ],
- "name": "fidlc",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/fidlgen b/tools/fidlgen
deleted file mode 100755
index cde2208..0000000
--- a/tools/fidlgen
+++ /dev/null
Binary files differ
diff --git a/tools/fidlgen-meta.json b/tools/fidlgen-meta.json
deleted file mode 100644
index 9fe21f8..0000000
--- a/tools/fidlgen-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/fidlgen"
- ],
- "name": "fidlgen",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/fvm b/tools/fvm
deleted file mode 100755
index 677d53c..0000000
--- a/tools/fvm
+++ /dev/null
Binary files differ
diff --git a/tools/fvm-meta.json b/tools/fvm-meta.json
deleted file mode 100644
index 34f476a..0000000
--- a/tools/fvm-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/fvm"
- ],
- "name": "fvm",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/loglistener b/tools/loglistener
deleted file mode 100755
index 1811b12..0000000
--- a/tools/loglistener
+++ /dev/null
Binary files differ
diff --git a/tools/loglistener-meta.json b/tools/loglistener-meta.json
deleted file mode 100644
index e9adaf4..0000000
--- a/tools/loglistener-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/loglistener"
- ],
- "name": "loglistener",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/merkleroot b/tools/merkleroot
deleted file mode 100755
index 243eb0a..0000000
--- a/tools/merkleroot
+++ /dev/null
Binary files differ
diff --git a/tools/merkleroot-meta.json b/tools/merkleroot-meta.json
deleted file mode 100644
index 5f68196..0000000
--- a/tools/merkleroot-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/merkleroot"
- ],
- "name": "merkleroot",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/minfs b/tools/minfs
deleted file mode 100755
index af3b27b..0000000
--- a/tools/minfs
+++ /dev/null
Binary files differ
diff --git a/tools/minfs-meta.json b/tools/minfs-meta.json
deleted file mode 100644
index 552d645..0000000
--- a/tools/minfs-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/minfs"
- ],
- "name": "minfs",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/netaddr b/tools/netaddr
deleted file mode 100755
index 096d8b4..0000000
--- a/tools/netaddr
+++ /dev/null
Binary files differ
diff --git a/tools/netaddr-meta.json b/tools/netaddr-meta.json
deleted file mode 100644
index 601e966..0000000
--- a/tools/netaddr-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/netaddr"
- ],
- "name": "netaddr",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/netcp b/tools/netcp
deleted file mode 100755
index 81088e6..0000000
--- a/tools/netcp
+++ /dev/null
Binary files differ
diff --git a/tools/netcp-meta.json b/tools/netcp-meta.json
deleted file mode 100644
index 37fbb78..0000000
--- a/tools/netcp-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/netcp"
- ],
- "name": "netcp",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/netls b/tools/netls
deleted file mode 100755
index 77e8612..0000000
--- a/tools/netls
+++ /dev/null
Binary files differ
diff --git a/tools/netls-meta.json b/tools/netls-meta.json
deleted file mode 100644
index 7c98bca..0000000
--- a/tools/netls-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/netls"
- ],
- "name": "netls",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/netruncmd b/tools/netruncmd
deleted file mode 100755
index e26f473..0000000
--- a/tools/netruncmd
+++ /dev/null
Binary files differ
diff --git a/tools/netruncmd-meta.json b/tools/netruncmd-meta.json
deleted file mode 100644
index 043580b..0000000
--- a/tools/netruncmd-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/netruncmd"
- ],
- "name": "netruncmd",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/pm b/tools/pm
deleted file mode 100755
index c7b39e9..0000000
--- a/tools/pm
+++ /dev/null
Binary files differ
diff --git a/tools/pm-meta.json b/tools/pm-meta.json
deleted file mode 100644
index 65d04fb..0000000
--- a/tools/pm-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/pm"
- ],
- "name": "pm",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file
diff --git a/tools/zbi b/tools/zbi
deleted file mode 100755
index e06c212..0000000
--- a/tools/zbi
+++ /dev/null
Binary files differ
diff --git a/tools/zbi-meta.json b/tools/zbi-meta.json
deleted file mode 100644
index ce2df6c..0000000
--- a/tools/zbi-meta.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "files": [
- "tools/zbi"
- ],
- "name": "zbi",
- "root": "tools",
- "type": "host_tool"
-}
\ No newline at end of file