Browse Source

Merge pull request #101 from rust3ds/feature/check-libctru-version

pull/112/head
Ian Chamberlain 2 years ago committed by GitHub
parent
commit
855dc46a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      README.md
  2. 4
      ctru-rs/Cargo.toml
  3. 7
      ctru-sys/Cargo.toml
  4. 33
      ctru-sys/bindgen.sh
  5. 71
      ctru-sys/build.rs
  6. 2
      ctru-sys/docstring-to-rustdoc/Cargo.toml
  7. 1
      ctru-sys/src/.gitattributes
  8. 38
      ctru-sys/src/bindings.rs

21
README.md

@ -5,8 +5,24 @@ A Rust wrapper library for smealum's [ctrulib](https://github.com/smealum/ctruli
## Structure ## Structure
This repository is organized as follows: This repository is organized as follows:
* `ctru-rs`: Safe, idiomatic wrapper around `ctru-sys`.
* `ctru-sys`: Low-level, unsafe bindings to ctrulib * `ctru-rs`: Safe, idiomatic wrapper around `ctru-sys`
* `ctru-sys`: Low-level, unsafe bindings to ctrulib.
This crate's version changes according to the version of `libctru`
used to generate the bindings, with the following convention:
* `libctru` version `X.Y.Z-W`
* `ctru-sys` version `XY.Z.P+X.Y.Z-W`
where `P` is usually 0 but may be incremented for fixes in e.g.
binding generation, `libc` dependency bump, etc.
It may be possible to build this crate against a different version of `libctru`,
but you may encounter linker errors or ABI issues. A build-time Cargo warning
(displayed when built with `-vv`) will be issued if the build script detects
a mismatch or is unable to check the installed `libctru` version.
## License ## License
@ -37,3 +53,4 @@ applies to every file in the tree, unless otherwise noted.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See [LICENSE-APACHE](https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE), [LICENSE-MIT](https://github.com/rust-lang/rust/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/rust-lang/rust/blob/master/COPYRIGHT) for details. See [LICENSE-APACHE](https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE), [LICENSE-MIT](https://github.com/rust-lang/rust/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/rust-lang/rust/blob/master/COPYRIGHT) for details.

4
ctru-rs/Cargo.toml

@ -1,7 +1,7 @@
[package] [package]
authors = ["Ronald Kinard <furyhunter600@gmail.com>"] authors = ["Ronald Kinard <furyhunter600@gmail.com>"]
description = "A safe wrapper around smealum's ctrulib." description = "A safe wrapper around smealum's ctrulib."
license = "https://en.wikipedia.org/wiki/Zlib_License" license = "Zlib"
name = "ctru-rs" name = "ctru-rs"
version = "0.7.1" version = "0.7.1"
edition = "2021" edition = "2021"
@ -13,7 +13,7 @@ name = "ctru"
[dependencies] [dependencies]
cfg-if = "1.0" cfg-if = "1.0"
ctru-sys = { path = "../ctru-sys", version = "0.4" } ctru-sys = { path = "../ctru-sys", version = "21.2" }
const-zero = "0.1.0" const-zero = "0.1.0"
linker-fix-3ds = { git = "https://github.com/rust3ds/rust-linker-fix-3ds.git" } linker-fix-3ds = { git = "https://github.com/rust3ds/rust-linker-fix-3ds.git" }
pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" } pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" }

7
ctru-sys/Cargo.toml

@ -1,10 +1,13 @@
[package] [package]
name = "ctru-sys" name = "ctru-sys"
version = "0.4.1" version = "21.2.0+2.1.2-1"
authors = ["Ronald Kinard <furyhunter600@gmail.com>"] authors = ["Ronald Kinard <furyhunter600@gmail.com>"]
license = "https://en.wikipedia.org/wiki/Zlib_License" license = "Zlib"
links = "ctru" links = "ctru"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
libc = { version = "0.2.121", default-features = false } libc = { version = "0.2.121", default-features = false }
[build-dependencies]
which = "4.4.0"

33
ctru-sys/bindgen.sh

@ -1,7 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euxo pipefail set -euo pipefail
echo "Determining libctru version..."
pacman=dkp-pacman
if ! command -v $pacman &>/dev/null; then
pacman=pacman
if ! command -v $pacman &>/dev/null; then
echo >&2 "ERROR: Unable to automatically determine libctru version!"
exit 1
fi
fi
LIBCTRU_VERSION="$($pacman -Qi libctru | grep Version | cut -d: -f 2 | tr -d ' ')"
CTRU_SYS_VERSION="$(
printf '%s' "$LIBCTRU_VERSION" |
cut -d- -f1 |
sed -E 's/^([0-9]+)\.([0-9.]+)$/\1\2/'
)"
echo "Generating bindings.rs..."
bindgen "$DEVKITPRO/libctru/include/3ds.h" \ bindgen "$DEVKITPRO/libctru/include/3ds.h" \
--rust-target nightly \ --rust-target nightly \
--use-core \ --use-core \
@ -18,9 +37,9 @@ bindgen "$DEVKITPRO/libctru/include/3ds.h" \
--with-derive-default \ --with-derive-default \
-- \ -- \
--target=arm-none-eabi \ --target=arm-none-eabi \
--sysroot=$DEVKITARM/arm-none-eabi \ --sysroot="$DEVKITARM/arm-none-eabi" \
-isystem$DEVKITARM/arm-none-eabi/include \ -isystem"$DEVKITARM/arm-none-eabi/include" \
-I$DEVKITPRO/libctru/include \ -I"$DEVKITPRO/libctru/include" \
-mfloat-abi=hard \ -mfloat-abi=hard \
-march=armv6k \ -march=armv6k \
-mtune=mpcore \ -mtune=mpcore \
@ -29,6 +48,10 @@ bindgen "$DEVKITPRO/libctru/include/3ds.h" \
-D__3DS__ \ -D__3DS__ \
> src/bindings.rs > src/bindings.rs
cargo run --package docstring-to-rustdoc -- src/bindings.rs echo "Updating docstrings in bindings.rs..."
cargo run --quiet --package docstring-to-rustdoc -- src/bindings.rs
echo "Formatting generated files..."
cargo fmt --all cargo fmt --all
echo "Generated bindings for ctru-sys version \"${CTRU_SYS_VERSION}.x+${LIBCTRU_VERSION}\""

71
ctru-sys/build.rs

@ -1,4 +1,6 @@
use std::env; use std::env;
use std::error::Error;
use std::process::{Command, Output, Stdio};
fn main() { fn main() {
let dkp_path = env::var("DEVKITPRO").unwrap(); let dkp_path = env::var("DEVKITPRO").unwrap();
@ -14,4 +16,73 @@ fn main() {
_ => "ctru", _ => "ctru",
} }
); );
match check_libctru_version() {
Ok((maj, min, patch)) => {
eprintln!("using libctru version {maj}.{min}.{patch}");
// These are accessible by the crate during build with `env!()`.
// We might consider exporting some public constants or something.
println!("cargo:rustc-env=LIBCTRU_VERSION={maj}.{min}.{patch}");
println!("cargo:rustc-env=LIBCTRU_MAJOR={maj}");
println!("cargo:rustc-env=LIBCTRU_MINOR={min}");
println!("cargo:rustc-env=LIBCTRU_PATCH={patch}");
}
Err(err) => println!("cargo:warning=failed to check libctru version: {err}"),
}
}
fn parse_version(version: &str) -> Result<(String, String, String), &str> {
let versions: Vec<_> = version
.split(|c| c == '.' || c == '-')
.map(String::from)
.collect();
match &versions[..] {
[major, minor, patch, _build] => Ok((major.clone(), minor.clone(), patch.clone())),
_ => Err("unexpected number of version segments"),
}
}
fn check_libctru_version() -> Result<(String, String, String), Box<dyn Error>> {
let pacman = which::which("dkp-pacman").or_else(|_| which::which("pacman"))?;
let Output { stdout, .. } = Command::new(&pacman)
.args(["--query", "libctru"])
.stderr(Stdio::inherit())
.output()?;
let output_str = String::from_utf8_lossy(&stdout);
let (_pkg, lib_version) = output_str
.split_once(char::is_whitespace)
.ok_or("unexpected pacman output format")?;
let lib_version = lib_version.trim();
let cargo_pkg_version = env::var("CARGO_PKG_VERSION").unwrap();
let (_, crate_built_version) = cargo_pkg_version
.split_once('+')
.expect("crate version should have '+' delimeter");
if lib_version != crate_built_version {
return Err(format!(
"libctru version is {lib_version} but this crate was built for {crate_built_version}"
))?;
}
let Output { stdout, .. } = Command::new(pacman)
.args(["--query", "--list", "libctru"])
.stderr(Stdio::inherit())
.output()?;
for line in String::from_utf8_lossy(&stdout).split('\n') {
let Some((_pkg, file)) = line.split_once(char::is_whitespace)
else { continue };
println!("cargo:rerun-if-changed={file}");
}
let (lib_major, lib_minor, lib_patch) = parse_version(lib_version)?;
Ok((lib_major, lib_minor, lib_patch))
} }

2
ctru-sys/docstring-to-rustdoc/Cargo.toml

@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
doxygen-rs = { git = "https://github.com/Techie-Pi/doxygen-rs.git", version = "0.2.2", rev = "573f483ad63ab4662650961998d3ed093a703983" } doxygen-rs = "0.3.1"

1
ctru-sys/src/.gitattributes vendored

@ -0,0 +1 @@
bindings.rs linguist-generated=true

38
ctru-sys/src/bindings.rs generated

@ -2952,7 +2952,7 @@ extern "C" {
pub fn svcOpenThread(thread: *mut Handle, process: Handle, threadId: u32_) -> Result; pub fn svcOpenThread(thread: *mut Handle, process: Handle, threadId: u32_) -> Result;
} }
extern "C" { extern "C" {
#[doc = "Exits the current thread.\n\n This will trigger a state change and hence release all [`svcWaitSynchronization`] operations.\n It means that you can join a thread by calling ``` svcWaitSynchronization(threadHandle,yourtimeout); ```"] #[doc = "Exits the current thread.\n\n This will trigger a state change and hence release all [`svcWaitSynchronization`] operations.\n It means that you can join a thread by calling ``` svcWaitSynchronization(threadHandle,yourtimeout);"]
#[doc = ""] #[doc = ""]
pub fn svcExitThread() -> !; pub fn svcExitThread() -> !;
} }
@ -4513,19 +4513,19 @@ extern "C" {
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Throws (and logs) a system error with the given Result code.\n @param[in] failure Result code to throw.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_GENERIC`] and fills in the required data.\n\n This function \\em does fill in the address where this function was called from."] #[doc = "Throws (and logs) a system error with the given Result code.\n @param[in] failure Result code to throw.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_GENERIC`] and fills in the required data.\n\n This function *does* fill in the address where this function was called from."]
#[doc = ""] #[doc = ""]
pub fn ERRF_ThrowResult(failure: Result) -> Result; pub fn ERRF_ThrowResult(failure: Result) -> Result;
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Logs a system error with the given Result code.\n @param[in] failure Result code to log.\n\n Similar to [`ERRF_Throw`] except that it does not display anything on the screen,\n nor does it force the system to reboot.\n\n This function \\em does fill in the address where this function was called from."] #[doc = "Logs a system error with the given Result code.\n @param[in] failure Result code to log.\n\n Similar to [`ERRF_Throw`] except that it does not display anything on the screen,\n nor does it force the system to reboot.\n\n This function *does* fill in the address where this function was called from."]
#[doc = ""] #[doc = ""]
pub fn ERRF_LogResult(failure: Result) -> Result; pub fn ERRF_LogResult(failure: Result) -> Result;
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Throws a system error with the given Result code and message.\n @param[in] failure Result code to throw.\n @param[in] message The message to display.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_FAILURE`] and fills in the required data.\n\n This function does \\em not fill in the address where this function was called from because it\n would not be displayed."] #[doc = "Throws a system error with the given Result code and message.\n @param[in] failure Result code to throw.\n @param[in] message The message to display.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_FAILURE`] and fills in the required data.\n\n This function does *not* fill in the address where this function was called from because it\n would not be displayed."]
#[doc = ""] #[doc = ""]
pub fn ERRF_ThrowResultWithMessage(failure: Result, message: *const ::libc::c_char) -> Result; pub fn ERRF_ThrowResultWithMessage(failure: Result, message: *const ::libc::c_char) -> Result;
} }
@ -4767,13 +4767,13 @@ pub struct LightSemaphore {
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Function used to implement user-mode synchronization primitives.\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter\n @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Does *nothing* since val >= 0\n syncArbitrateAddress(&val,ARBITRATION_WAIT_IF_LESS_THAN,0);\n ``` @note Usage of this function entails an implicit Data Memory Barrier (dmb)."] #[doc = "Function used to implement user-mode synchronization primitives.\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter\n @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Does *nothing* since val >= 0\n syncArbitrateAddress(&val,ARBITRATION_WAIT_IF_LESS_THAN,0);\n *@note* Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = ""] #[doc = ""]
pub fn syncArbitrateAddress(addr: *mut s32, type_: ArbitrationType, value: s32) -> Result; pub fn syncArbitrateAddress(addr: *mut s32, type_: ArbitrationType, value: s32) -> Result;
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Function used to implement user-mode synchronization primitives (with timeout).\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter (must use [`ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT`] or [`ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT)\n`] @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.\n syncArbitrateAddressWithTimeout(&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000LL);\n ``` @note Usage of this function entails an implicit Data Memory Barrier (dmb)."] #[doc = "Function used to implement user-mode synchronization primitives (with timeout).\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter (must use [`ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT`] or [`ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT)\n`] @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.\n syncArbitrateAddressWithTimeout(&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000LL);\n *@note* Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = ""] #[doc = ""]
pub fn syncArbitrateAddressWithTimeout( pub fn syncArbitrateAddressWithTimeout(
addr: *mut s32, addr: *mut s32,
@ -5310,7 +5310,7 @@ pub const GFX_RIGHT: gfx3dSide_t = 1;
pub type gfx3dSide_t = ::libc::c_uint; pub type gfx3dSide_t = ::libc::c_uint;
extern "C" { extern "C" {
#[doc = "Initializes the LCD framebuffers with default parameters\n This is equivalent to calling: ``` gfxInit(GSP_BGR8_OES,GSP_BGR8_OES,false); ```"] #[doc = "Initializes the LCD framebuffers with default parameters\n This is equivalent to calling: ``` gfxInit(GSP_BGR8_OES,GSP_BGR8_OES,false);"]
#[doc = ""] #[doc = ""]
pub fn gfxInitDefault(); pub fn gfxInitDefault();
} }
@ -5389,7 +5389,7 @@ extern "C" {
pub fn gfxConfigScreen(scr: gfxScreen_t, immediate: bool); pub fn gfxConfigScreen(scr: gfxScreen_t, immediate: bool);
} }
extern "C" { extern "C" {
#[doc = "Updates the configuration of both screens.\n @note This function is equivalent to: ``` gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true); ```"] #[doc = "Updates the configuration of both screens.\n @note This function is equivalent to: ``` gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true);"]
#[doc = ""] #[doc = ""]
pub fn gfxSwapBuffers(); pub fn gfxSwapBuffers();
} }
@ -5428,7 +5428,7 @@ impl Default for ConsoleFont {
} }
} }
} }
#[doc = "Console structure used to store the state of a console render context.\n\n Default values from consoleGetDefault();\n ``` PrintConsole defaultConsole =\n {\n \t//Font:\n \t{\n \t\t(u8*)default_font_bin, //font gfx\n \t\t0, //first ascii character in the set\n \t\t128, //number of characters in the font set\n\t},\n\t0,0, //cursorX cursorY\n\t0,0, //prevcursorX prevcursorY\n\t40, //console width\n\t30, //console height\n\t0, //window x\n\t0, //window y\n\t32, //window width\n\t24, //window height\n\t3, //tab size\n\t0, //font character offset\n\t0, //print callback\n\tfalse //console initialized\n };\n ```"] #[doc = "Console structure used to store the state of a console render context.\n\n Default values from consoleGetDefault();\n ``` PrintConsole defaultConsole =\n {\n \t//Font:\n \t{\n \t\t(u8*)default_font_bin, //font gfx\n \t\t0, //first ascii character in the set\n \t\t128, //number of characters in the font set\n\t},\n\t0,0, //cursorX cursorY\n\t0,0, //prevcursorX prevcursorY\n\t40, //console width\n\t30, //console height\n\t0, //window x\n\t0, //window y\n\t32, //window width\n\t24, //window height\n\t3, //tab size\n\t0, //font character offset\n\t0, //print callback\n\tfalse //console initialized\n };\n"]
#[doc = ""] #[doc = ""]
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -5957,42 +5957,42 @@ extern "C" {
pub fn decode_utf16(out: *mut u32, in_: *const u16) -> isize; pub fn decode_utf16(out: *mut u32, in_: *const u16) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-32 codepoint into a UTF-8 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out must be able to store 4 code units"] #[doc = "Convert a UTF-32 codepoint into a UTF-8 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* must be able to store 4 code units"]
#[doc = ""] #[doc = ""]
pub fn encode_utf8(out: *mut u8, in_: u32) -> isize; pub fn encode_utf8(out: *mut u8, in_: u32) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-32 codepoint into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out must be able to store 2 code units"] #[doc = "Convert a UTF-32 codepoint into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* must be able to store 2 code units"]
#[doc = ""] #[doc = ""]
pub fn encode_utf16(out: *mut u16, in_: u32) -> isize; pub fn encode_utf16(out: *mut u16, in_: u32) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-8 sequence into a UTF-16 sequence\n\n Fills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\n if it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-8 sequence into a UTF-16 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf8_to_utf16(out: *mut u16, in_: *const u8, len: usize) -> isize; pub fn utf8_to_utf16(out: *mut u16, in_: *const u8, len: usize) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-8 sequence into a UTF-32 sequence\n\n Fills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\n if it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-8 sequence into a UTF-32 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf8_to_utf32(out: *mut u32, in_: *const u8, len: usize) -> isize; pub fn utf8_to_utf32(out: *mut u32, in_: *const u8, len: usize) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-16 sequence into a UTF-8 sequence\n\n Fills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\n if it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-16 sequence into a UTF-8 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf16_to_utf8(out: *mut u8, in_: *const u16, len: usize) -> isize; pub fn utf16_to_utf8(out: *mut u8, in_: *const u16, len: usize) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-16 sequence into a UTF-32 sequence\n\n Fills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\n if it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-16 sequence into a UTF-32 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf16_to_utf32(out: *mut u32, in_: *const u16, len: usize) -> isize; pub fn utf16_to_utf32(out: *mut u32, in_: *const u16, len: usize) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-32 sequence into a UTF-8 sequence\n\n Fills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\n if it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-32 sequence into a UTF-8 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf32_to_utf8(out: *mut u8, in_: *const u32, len: usize) -> isize; pub fn utf32_to_utf8(out: *mut u8, in_: *const u32, len: usize) -> isize;
} }
extern "C" { extern "C" {
#[doc = "Convert a UTF-32 sequence into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note \\a out is not null-terminated"] #[doc = "Convert a UTF-32 sequence into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = ""] #[doc = ""]
pub fn utf32_to_utf16(out: *mut u16, in_: *const u32, len: usize) -> isize; pub fn utf32_to_utf16(out: *mut u16, in_: *const u32, len: usize) -> isize;
} }
@ -9500,7 +9500,7 @@ pub const BLOCK_8_BY_8: Y2RU_BlockAlignment = 1;
#[doc = ""] #[doc = ""]
pub type Y2RU_BlockAlignment = ::libc::c_uint; pub type Y2RU_BlockAlignment = ::libc::c_uint;
#[doc = "Coefficients of the YUV->RGB conversion formula.\n\n A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8\n fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are\n signed 11.5 fixed point numbers added as offsets to the RGB result.\n\n The overall conversion process formula is:\n ``` R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)\n G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)\n B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)\n ```"] #[doc = "Coefficients of the YUV->RGB conversion formula.\n\n A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8\n fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are\n signed 11.5 fixed point numbers added as offsets to the RGB result.\n\n The overall conversion process formula is:\n ``` R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)\n G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)\n B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)\n"]
#[doc = ""] #[doc = ""]
#[repr(C)] #[repr(C)]
#[derive(Debug, Default, Copy, Clone)] #[derive(Debug, Default, Copy, Clone)]
@ -9890,7 +9890,7 @@ extern "C" {
} }
extern "C" { extern "C" {
#[must_use] #[must_use]
#[doc = "Gets an handle to the end of conversion event.\n @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.\n\n To enable this event you have to use ``` ``` The event will be triggered when the corresponding interrupt is fired.\n\n @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered."] #[doc = "Gets an handle to the end of conversion event.\n @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.\n\n To enable this event you have to use ``` *The* event will be triggered when the corresponding interrupt is fired.\n\n @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered."]
#[doc = ""] #[doc = ""]
pub fn Y2RU_GetTransferEndEvent(end_event: *mut Handle) -> Result; pub fn Y2RU_GetTransferEndEvent(end_event: *mut Handle) -> Result;
} }

Loading…
Cancel
Save