aboutsummaryrefslogtreecommitdiff
path: root/rust/qemu-api/meson.build
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-14 09:05:38 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-02-25 16:18:08 +0100
commit8a420dd109b9e4e2244cfa32bc92829093268b3e (patch)
tree40e9db642b552c7bb840cd7f46bda933d2e0c517 /rust/qemu-api/meson.build
parent4cfe9edb1b1961af9cda74351f73b0abb3159b67 (diff)
downloadqemu-8a420dd109b9e4e2244cfa32bc92829093268b3e.zip
qemu-8a420dd109b9e4e2244cfa32bc92829093268b3e.tar.gz
qemu-8a420dd109b9e4e2244cfa32bc92829093268b3e.tar.bz2
rust: add module to convert between success/-errno and io::Result
It is a common convention in QEMU to return a positive value in case of success, and a negated errno value in case of error. Unfortunately, using errno portably in Rust is a bit complicated; on Unix the errno values are supported natively by io::Error, but on Windows they are not; so, use the libc crate. This is a set of utility functions that are used by both chardev and block layer bindings. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/meson.build')
-rw-r--r--rust/qemu-api/meson.build4
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index 2e9c107..bcf1cf7 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -2,6 +2,8 @@ _qemu_api_cfg = run_command(rustc_args,
'--config-headers', config_host_h, '--features', files('Cargo.toml'),
capture: true, check: true).stdout().strip().splitlines()
+libc_dep = dependency('libc-0.2-rs')
+
# _qemu_api_cfg += ['--cfg', 'feature="allocator"']
if rustc.version().version_compare('>=1.77.0')
_qemu_api_cfg += ['--cfg', 'has_offset_of']
@@ -22,6 +24,7 @@ _qemu_api_rs = static_library(
'src/cell.rs',
'src/chardev.rs',
'src/c_str.rs',
+ 'src/errno.rs',
'src/irq.rs',
'src/memory.rs',
'src/module.rs',
@@ -39,6 +42,7 @@ _qemu_api_rs = static_library(
override_options: ['rust_std=2021', 'build.rust_std=2021'],
rust_abi: 'rust',
rust_args: _qemu_api_cfg,
+ dependencies: libc_dep,
)
rust.test('rust-qemu-api-tests', _qemu_api_rs,