Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac allow system ucontext #90

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/qthread_check_swapcontext.m4
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ AC_CACHE_CHECK([whether swapcontext works properly],
[qthread_cv_swapcontext_works],
[
case "$host" in
*-darwin*)
qthread_cv_swapcontext_works=no
;;
# *-darwin*)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since current x86 and M1 Macs seemingly support system ucontext, I think it is ok to drop this case statement.

Copy link
Collaborator

@janciesko janciesko Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding something like
AS_IF([test "$host" in *-darvin*], [qt_host_based_enable_fastcontext=no], [qt_host_based_enable_fastcontext=yes] ;;
to L37 to disable fast context automatically on M1 Macs while the support is not available yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

darvin -> darwin. But really, it's the combo of darwin and aarch64 (however that parses). We don't want to disable fast context on earlier macs.

Copy link
Collaborator

@janciesko janciesko Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that combo should come together in L37 if I see this correctly when adding that additional check for Darwin.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/janciesko/qthreads/tree/mac-allow-system-ucontext-2

This is not correct. m1 macs are arm v8 not arm v7. The arch to AC will be something like arm64 or aarch64.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was more an idea / place holder. We'd need to add the right case depending on what config gives us.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can match on aarch64-*-darwin* | arm64*-*-darwin*

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since it shouldn't really match any of the architectures in the case, it should fall through without any change. I just tried from the qthreads repo branch (without the m4 change and without the disable fast context switch on configure) and it worked just fine.

# qthread_cv_swapcontext_works=no
# ;;
*)
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <ucontext.h>
Expand Down
2 changes: 1 addition & 1 deletion src/fastcontext/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# define SET _qt_setmctxt
# define GET _qt_getmctxt
# else
# error What kind of a Mac is this?
# error What kind of a Mac is this? If M1, use CFLAGS=-D_XOPEN_SOURCE and --disable-fastcontext --with-default-stack-size=65536 in configure.
# endif
#elif defined(__linux__)
# if (QTHREAD_ASSEMBLY_ARCH == QTHREAD_ARM)
Expand Down