From 78d24dcefc7f0c0174e9287c7769bab54cae370a Mon Sep 17 00:00:00 2001 From: thegeorg Date: Mon, 4 Sep 2023 18:02:10 +0300 Subject: [PATCH] Provide getrandom for Android too --- contrib/libs/libc_compat/random/getentropy.c | 4 ++++ contrib/libs/libc_compat/ya.make | 2 ++ 2 files changed, 6 insertions(+) diff --git a/contrib/libs/libc_compat/random/getentropy.c b/contrib/libs/libc_compat/random/getentropy.c index 651ea95f1431..50e9c2fae25d 100644 --- a/contrib/libs/libc_compat/random/getentropy.c +++ b/contrib/libs/libc_compat/random/getentropy.c @@ -14,7 +14,9 @@ int getentropy(void *buffer, size_t len) return -1; } +#if defined(__linux__) && !defined(__ANDROID__) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); +#endif while (len) { ret = getrandom(pos, len, 0); @@ -27,7 +29,9 @@ int getentropy(void *buffer, size_t len) ret = 0; } +#if defined(__linux__) && !defined(__ANDROID__) pthread_setcancelstate(cs, 0); +#endif return ret; } diff --git a/contrib/libs/libc_compat/ya.make b/contrib/libs/libc_compat/ya.make index 44ebf490b075..8865d284d96e 100644 --- a/contrib/libs/libc_compat/ya.make +++ b/contrib/libs/libc_compat/ya.make @@ -33,10 +33,12 @@ IF (OS_ANDROID) strlcat.c strlcpy.c ) + IF (ANDROID_API < 28) SRCS( glob.c ) + ENABLE(PROVIDE_GETRANDOM_GETENTROPY) ENABLE(PROVIDE_REALLOCARRAY) ENDIF() IF (ANDROID_API < 24)