aboutsummaryrefslogtreecommitdiffstats
path: root/random.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-12-04 17:16:30 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-12-26 20:45:12 +0900
commit5e22f873ed26092522f9bfc617d729bac88b284f (patch)
tree8d66856526cd7efa87b46c966298e6f42d67e68f /random.c
parent33e9601938a79dae149caa88ff1bc06d376dd376 (diff)
downloadruby-5e22f873ed26092522f9bfc617d729bac88b284f.tar.gz
decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
Diffstat (limited to 'random.c')
-rw-r--r--random.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/random.c b/random.c
index d763a214cd..29ac388311 100644
--- a/random.c
+++ b/random.c
@@ -9,41 +9,59 @@
**********************************************************************/
-#include "internal.h"
+#include "ruby/config.h"
+#include <errno.h>
#include <limits.h>
+#include <math.h>
+#include <time.h>
+
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
#endif
-#include <time.h>
+
#include <sys/types.h>
#include <sys/stat.h>
+
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+# include <fcntl.h>
#endif
-#include <math.h>
-#include <errno.h>
+
#if defined(HAVE_SYS_TIME_H)
-#include <sys/time.h>
+# include <sys/time.h>
#endif
#ifdef HAVE_SYSCALL_H
-#include <syscall.h>
+# include <syscall.h>
#elif defined HAVE_SYS_SYSCALL_H
-#include <sys/syscall.h>
+# include <sys/syscall.h>
#endif
#ifdef _WIN32
-#include <windows.h>
-#include <wincrypt.h>
+# include <winsock2.h>
+# include <windows.h>
+# include <wincrypt.h>
#endif
-#include "ruby_atomic.h"
#ifdef __OpenBSD__
/* to define OpenBSD for version check */
-#include <sys/param.h>
+# include <sys/param.h>
+#endif
+
+#if defined HAVE_GETRANDOM
+# include <sys/random.h>
+#elif defined __linux__ && defined __NR_getrandom
+# include <linux/random.h>
#endif
+#include "internal.h"
+#include "internal/compilers.h"
+#include "internal/error.h"
+#include "internal/numeric.h"
+#include "internal/random.h"
+#include "internal/sanitizers.h"
+#include "ruby_atomic.h"
+
typedef int int_must_be_32bit_at_least[sizeof(int) * CHAR_BIT < 32 ? -1 : 1];
#include "missing/mt19937.c"
@@ -320,11 +338,7 @@ fill_random_bytes_urandom(void *seed, size_t size)
# define fill_random_bytes_urandom(seed, size) -1
#endif
-#if defined HAVE_GETRANDOM
-# include <sys/random.h>
-#elif defined __linux__ && defined __NR_getrandom
-# include <linux/random.h>
-
+#if ! defined HAVE_GETRANDOM && defined __linux__ && defined __NR_getrandom
# ifndef GRND_NONBLOCK
# define GRND_NONBLOCK 0x0001 /* not defined in musl libc */
# endif