mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: check for arc4random_uniform() and use it in KRandom::randomMax() if available
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
af34fced45
commit
f2b5c374ed
3 changed files with 14 additions and 3 deletions
|
@ -43,9 +43,10 @@ kde4_bool_to_01(X11_XSync_FOUND HAVE_XSYNC) # kidletim
|
|||
check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) # kioslave
|
||||
check_symbol_exists(getgrouplist "unistd.h;grp.h" HAVE_GETGROUPLIST) # kio
|
||||
|
||||
check_function_exists(backtrace HAVE_BACKTRACE) # kdecore, kio
|
||||
check_function_exists(fdatasync HAVE_FDATASYNC) # kdecore
|
||||
check_function_exists(sendfile HAVE_SENDFILE) # kioslave
|
||||
check_function_exists(backtrace HAVE_BACKTRACE) # kdecore, kio
|
||||
check_function_exists(fdatasync HAVE_FDATASYNC) # kdecore
|
||||
check_function_exists(arc4random_uniform HAVE_ARC4RANDOM_UNIFORM) # kdecore
|
||||
check_function_exists(sendfile HAVE_SENDFILE) # kioslave
|
||||
|
||||
check_library_exists(socket connect "" HAVE_SOCKET_LIBRARY) # kinit
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#cmakedefine HAVE_BACKTRACE 1
|
||||
#cmakedefine HAVE_GETMNTINFO 1
|
||||
#cmakedefine HAVE_FDATASYNC 1
|
||||
#cmakedefine HAVE_ARC4RANDOM_UNIFORM 1
|
||||
#cmakedefine HAVE_SENDFILE 1
|
||||
#cmakedefine HAVE_SETMNTENT 1
|
||||
#cmakedefine HAVE_STRTOLL 1
|
||||
|
|
|
@ -16,9 +16,14 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "krandom.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
#if defined(HAVE_ARC4RANDOM_UNIFORM)
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
int KRandom::randomMax(int max)
|
||||
{
|
||||
if (Q_UNLIKELY(max <= 0)) {
|
||||
|
@ -26,7 +31,11 @@ int KRandom::randomMax(int max)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_ARC4RANDOM_UNIFORM)
|
||||
return ::arc4random_uniform(max);
|
||||
#else
|
||||
return KRandom::random() % max;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString KRandom::randomString(int length)
|
||||
|
|
Loading…
Add table
Reference in a new issue