MYCFLAGS="$MYCFLAGS -pthread"
fi
+if test_code 'arc4random_buf()' 'stdlib.h' '' '' 'arc4random_buf(NULL, 0);'; then
+ add_def HAVE_ARC4RANDOM
+fi
+
timepps_h=""
if [ $feat_refclock = "1" ] && [ $feat_pps = "1" ]; then
if test_code '<sys/timepps.h>' 'sys/timepps.h' '' '' ''; then
return 1;
}
+
+/* ================================================== */
+
+#define DEV_URANDOM "/dev/urandom"
+
+void
+UTI_GetRandomBytes(void *buf, unsigned int len)
+{
+#ifdef HAVE_ARC4RANDOM
+ arc4random_buf(buf, len);
+#else
+ static FILE *f = NULL;
+ if (!f)
+ f = fopen(DEV_URANDOM, "r");
+ if (!f)
+ LOG_FATAL(LOGF_Util, "Can't open %s : %s", DEV_URANDOM, strerror(errno));
+ if (fread(buf, 1, len, f) != len)
+ LOG_FATAL(LOGF_Util, "Can't read from %s", DEV_URANDOM);
+#endif
+}
permissions and its uid/gid must match the specified values. */
extern int UTI_CheckDirPermissions(const char *path, mode_t perm, uid_t uid, gid_t gid);
+/* Fill buffer with random bytes */
+extern void UTI_GetRandomBytes(void *buf, unsigned int len);
+
#endif /* GOT_UTIL_H */