File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -107,14 +107,28 @@ static PRGR libfunc_rgr;
107
107
#if LJ_TARGET_LINUX
108
108
/* Avoid a dependency on glibc 2.25+ and use the getrandom syscall instead. */
109
109
#include <sys/syscall.h>
110
- #elif LJ_TARGET_OSX || LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
110
+ #else
111
+
112
+ #if LJ_TARGET_OSX
113
+ #include <Availability.h>
114
+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 || \
115
+ __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
116
+ #define LJ_TARGET_HAS_GETENTROPY 1
117
+ #endif
118
+ #elif LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
119
+ #define LJ_TARGET_HAS_GETENTROPY 1
120
+ #endif
121
+
122
+ #if LJ_TARGET_HAS_GETENTROPY
111
123
extern int getentropy (void * buf , size_t len );
112
124
#ifdef __ELF__
113
125
__attribute__((weak ))
114
126
#endif
115
127
;
116
128
#endif
117
129
130
+ #endif
131
+
118
132
/* For the /dev/urandom fallback. */
119
133
#include <fcntl.h>
120
134
#include <unistd.h>
@@ -181,7 +195,7 @@ int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs)
181
195
if (syscall (SYS_getrandom , rs -> u , sizeof (rs -> u ), 0 ) == (long )sizeof (rs -> u ))
182
196
goto ok ;
183
197
184
- #elif LJ_TARGET_OSX || LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
198
+ #elif LJ_TARGET_HAS_GETENTROPY
185
199
186
200
#ifdef __ELF__
187
201
if (getentropy && getentropy (rs -> u , sizeof (rs -> u )) == 0 )
You can’t perform that action at this time.
0 commit comments