Skip to content

Commit

Permalink
Provide getrandom for Android too
Browse files Browse the repository at this point in the history
  • Loading branch information
georgthegreat committed Sep 4, 2023
1 parent 6150a51 commit 78d24dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/libs/libc_compat/random/getentropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
2 changes: 2 additions & 0 deletions contrib/libs/libc_compat/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 78d24dc

Please sign in to comment.