From 5e22f873ed26092522f9bfc617d729bac88b284f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Wed, 4 Dec 2019 17:16:30 +0900 Subject: 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). --- dir.c | 80 +++++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 36 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 6a926f4..c72011a 100644 --- a/dir.c +++ b/dir.c @@ -11,12 +11,10 @@ **********************************************************************/ -#include "ruby/encoding.h" -#include "ruby/thread.h" -#include "internal.h" -#include "id.h" -#include "encindex.h" +#include "ruby/config.h" +#include +#include #include #include @@ -36,12 +34,10 @@ # define USE_OPENDIR_AT 0 # endif #endif + #if USE_OPENDIR_AT # include #endif -#ifndef AT_FDCWD -# define AT_FDCWD -1 -#endif #undef HAVE_DIRENT_NAMLEN #if defined HAVE_DIRENT_H && !defined _WIN32 @@ -68,8 +64,6 @@ # endif #endif -#include - #ifndef HAVE_STDLIB_H char *getenv(); #endif @@ -78,28 +72,6 @@ char *getenv(); char *strchr(char*,char); #endif -#include - -#include "ruby/util.h" - -#define vm_initialized rb_cThread - -/* define system APIs */ -#ifdef _WIN32 -#undef chdir -#define chdir(p) rb_w32_uchdir(p) -#undef mkdir -#define mkdir(p, m) rb_w32_umkdir((p), (m)) -#undef rmdir -#define rmdir(p) rb_w32_urmdir(p) -#undef opendir -#define opendir(p) rb_w32_uopendir(p) -#define ruby_getcwd() rb_w32_ugetcwd(NULL, 0) -#define IS_WIN32 1 -#else -#define IS_WIN32 0 -#endif - #ifdef HAVE_SYS_ATTR_H #include #endif @@ -123,15 +95,51 @@ char *strchr(char*,char); #ifdef __APPLE__ # define NORMALIZE_UTF8PATH 1 +# include +# include +# include #else # define NORMALIZE_UTF8PATH 0 #endif -#if NORMALIZE_UTF8PATH -#include -#include -#include +#include "encindex.h" +#include "id.h" +#include "internal.h" +#include "internal/dir.h" +#include "internal/encoding.h" +#include "internal/error.h" +#include "internal/file.h" +#include "internal/gc.h" +#include "internal/io.h" +#include "internal/vm.h" +#include "ruby/encoding.h" +#include "ruby/ruby.h" +#include "ruby/thread.h" +#include "ruby/util.h" +#ifndef AT_FDCWD +# define AT_FDCWD -1 +#endif + +#define vm_initialized rb_cThread + +/* define system APIs */ +#ifdef _WIN32 +# undef chdir +# define chdir(p) rb_w32_uchdir(p) +# undef mkdir +# define mkdir(p, m) rb_w32_umkdir((p), (m)) +# undef rmdir +# define rmdir(p) rb_w32_urmdir(p) +# undef opendir +# define opendir(p) rb_w32_uopendir(p) +# define ruby_getcwd() rb_w32_ugetcwd(NULL, 0) +# define IS_WIN32 1 +#else +# define IS_WIN32 0 +#endif + +#if NORMALIZE_UTF8PATH # if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST # define need_normalization(dirp, path) need_normalization(dirp) # else -- cgit v1.1