Skip to main content

xmlStrPrintf

Function xmlStrPrintf 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn xmlStrPrintf() -> c_int
Expand description

Assembly shim for the variadic xmlStrPrintf export.

Stable Rust cannot define variadic extern "C" functions (c_variadic is unstable), so this #[no_mangle] export is a noreturn inline-asm block that captures the SysV x86-64 register save area exactly like va_start, builds a va_list and forwards it to xmlStrVPrintf, then restores the stack and returns directly. Same technique as the writer module’s vfmt_shim! (see src/xml/writer/mod.rs).

§UPSTREAM-PARITY

int xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...);

Three fixed arguments (buf, len, msg) precede the varargs, so the va_list is built with gp_offset = 24 and passed as the fourth argument (register rcx).

Layout: reg_save_area = rsp+0 (6 GP + 8 SSE slots, 176 bytes); the va_list struct lives at rsp+176 (gp_offset, fp_offset, overflow_arg_area, reg_save_area); overflow varargs are above the return address. LLVM emits an 8-byte alignment push before the block, so a 240-byte frame (≡ 0 mod 16) keeps the call 16-aligned, the overflow area points at rsp+256 (= entry_rsp + 8) and the alignment push is popped before ret.

§SAFETY

  • Must only be called from C with (xmlChar*, int, const char*, ...) arguments matching the format string.