Make futexes cancellable by pthreads

This commit is contained in:
Justine Tunney 2022-11-04 18:19:05 -07:00
parent 2278327eba
commit 022536cab6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
101 changed files with 627 additions and 391 deletions

View file

@ -16,13 +16,21 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/blockcancel.internal.h"
#include "libc/stdio/rand.h"
#include "libc/sysv/consts/grnd.h"
#include "libc/sysv/errfuns.h"
/**
* Returns random seeding bytes, the XNU/OpenBSD way.
*
* @return 0 on success, or -1 w/ errno
* @raise EIO if more than 256 bytes are requested
* @see getrandom()
*/
int getentropy(void *buf, size_t size) {
return getrandom(buf, size, GRND_RANDOM);
if (size > 256) return eio();
BLOCK_CANCELLATIONS;
if (getrandom(buf, size, 0) != size) notpossible;
ALLOW_CANCELLATIONS;
return 0;
}