Skip to content

Add mutex in feature detection code#563

Draft
Andreas-Krebbel wants to merge 1 commit into
shibatch:masterfrom
Andreas-Krebbel:mutex
Draft

Add mutex in feature detection code#563
Andreas-Krebbel wants to merge 1 commit into
shibatch:masterfrom
Andreas-Krebbel:mutex

Conversation

@Andreas-Krebbel

Copy link
Copy Markdown
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
Copy Markdown
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