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

Add mutex in feature detection code #563

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Andreas-Krebbel
Copy link
Contributor

This implements a suggestion from @shibatch for #561. It uses a pthread mutex to prevent multiple threads from accessing the sigjmp variable in the feature detection code simultaneously.

Remaining todos:

  1. How to initialize the pthread mutex on MacOX and Windows? The code currently errors out on these platforms
  2. With older Glibc's I guess this requires sleef users to link against libpthread. Would that be acceptable? With newer Glibcs libpthread is part of libc already.

Apart from that the code fixes the problems in #561

@shibatch
Copy link
Owner

On Windows, you can use InitOnceExecuteOnce to initialize the mutex.
Or you could call the entire detection code from InitOnceExecuteOnce.
I think we do not need to write this code now.

https://devblogs.microsoft.com/oldnewthing/20110408-01/?p=10983
https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce

I see no problem linking libpthread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants