diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-12-04 17:16:30 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-12-26 20:45:12 +0900 |
commit | 5e22f873ed26092522f9bfc617d729bac88b284f (patch) | |
tree | 8d66856526cd7efa87b46c966298e6f42d67e68f /dir.c | |
parent | 33e9601938a79dae149caa88ff1bc06d376dd376 (diff) |
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).
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2711
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 80 |
1 files changed, 44 insertions, 36 deletions
@@ -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 <ctype.h> +#include <errno.h> #include <sys/types.h> #include <sys/stat.h> @@ -36,12 +34,10 @@ # define USE_OPENDIR_AT 0 # endif #endif + #if USE_OPENDIR_AT # include <fcntl.h> #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 <errno.h> - #ifndef HAVE_STDLIB_H char *getenv(); #endif @@ -78,28 +72,6 @@ char *getenv(); char *strchr(char*,char); #endif -#include <ctype.h> - -#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 <sys/attr.h> #endif @@ -123,15 +95,51 @@ char *strchr(char*,char); #ifdef __APPLE__ # define NORMALIZE_UTF8PATH 1 +# include <sys/param.h> +# include <sys/mount.h> +# include <sys/vnode.h> #else # define NORMALIZE_UTF8PATH 0 #endif -#if NORMALIZE_UTF8PATH -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/vnode.h> +#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 |