win32: Add ftruncate function detection
PATCH 1/1 win32: Add ftruncate function detection
Add detection for ftruncate function in Meson, so that it can be used when possible instead of fallback version qemu_ftruncate64.
Signed-off-by Tianlan Zhou <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3234
--- include/system/os-win32.h | 2 +- meson.build | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
include/system/os-win32.h +1 -1
@@ -140,7 +140,7 @@ static inline void os_setup_limits(void)int qemu_ftruncate64 (int ,int64_t ); -#if !defined(ftruncate) +#ifndef CONFIG_FTRUNCATE # define ftruncate qemu_ftruncate64#endif
meson.build +11 -0
@@ -3253,6 +3253,17 @@ if host_os == 'windows' config_host_data.set('CONFIG_CONVERT_STRING_TO_BSTR', has_convert_string_to_bstr) endif +# Detect if ftruncate exist +if host_os == 'windows' + has_ftruncate = cxx.links(''' + #include <unistd.h> + int main() { + return ftruncate(0, 0); + } + ''') + config_host_data.set('CONFIG_FTRUNCATE', has_ftruncate) +endif + ######################## # Target configuration # ########################
Signature · 1 line
2.52.0