Skip to content

Commit

Permalink
win32: avoid discarding the exception handler
Browse files Browse the repository at this point in the history
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 d89f30b ("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>
  • Loading branch information
elmarco committed Oct 3, 2023
1 parent 7db57a7 commit 75b773d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/qemu/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,10 @@
#define QEMU_ANNOTATE(x)
#endif

#if __has_attribute(used)
# define QEMU_USED __attribute__((used))
#else
# define QEMU_USED
#endif

#endif /* COMPILER_H */
2 changes: 1 addition & 1 deletion util/oslib-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 75b773d

Please sign in to comment.