OSDN Git Service

win32: avoid discarding the exception handler
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 25 Sep 2023 11:36:04 +0000 (15:36 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 Oct 2023 11:05:20 +0000 (15:05 +0400)
In all likelihood, the compiler with lto doesn't see the function being
used, from assembly macro __try1. Help it by marking the function has
being used.

Resolves:
https://gitlab.com/qemu-project/qemu/-/issues/1904

Fixes: commit d89f30b4df ("win32: wrap socket close() with an exception handler")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
include/qemu/compiler.h
util/oslib-win32.c

index 7f1bbbf..1109482 100644 (file)
 #define QEMU_ANNOTATE(x)
 #endif
 
+#if __has_attribute(used)
+# define QEMU_USED __attribute__((used))
+#else
+# define QEMU_USED
+#endif
+
 #endif /* COMPILER_H */
index 19a0ea7..55b0189 100644 (file)
@@ -479,7 +479,7 @@ int qemu_bind_wrap(int sockfd, const struct sockaddr *addr,
     return ret;
 }
 
-EXCEPTION_DISPOSITION
+QEMU_USED EXCEPTION_DISPOSITION
 win32_close_exception_handler(struct _EXCEPTION_RECORD *exception_record,
                               void *registration, struct _CONTEXT *context,
                               void *dispatcher)