Skip to content

Commit

Permalink
decouple internal.h headers
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
shyouhei committed Dec 26, 2019
1 parent 33e9601 commit 5e22f87
Show file tree
Hide file tree
Showing 113 changed files with 1,327 additions and 689 deletions.
21 changes: 16 additions & 5 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/

#include "debug_counter.h"
#include "id.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/compar.h"
#include "internal/enum.h"
#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/rational.h"
#include "internal/vm.h"
#include "probes.h"
#include "ruby/encoding.h"
#include "ruby/util.h"
#include "ruby/st.h"
#include "probes.h"
#include "id.h"
#include "debug_counter.h"
#include "ruby/util.h"
#include "transient_heap.h"
#include "internal.h"

#if !ARRAY_DEBUG
# define NDEBUG
Expand Down
10 changes: 7 additions & 3 deletions ast.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/* indent-tabs-mode: nil */
#include "internal.h"
#include "internal/parse.h"
#include "internal/symbol.h"
#include "internal/warnings.h"
#include "iseq.h"
#include "node.h"
#include "ruby.h"
#include "ruby/encoding.h"
#include "ruby/util.h"
#include "internal.h"
#include "node.h"
#include "vm_core.h"
#include "iseq.h"

#include "builtin.h"

static VALUE rb_mAST;
Expand Down
37 changes: 25 additions & 12 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,40 @@
**********************************************************************/

#include "internal.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "id.h"
#include "ruby/config.h"

#include <ctype.h>
#include <float.h>
#include <math.h>

#ifdef HAVE_STRINGS_H
#include <strings.h>
# include <strings.h>
#endif
#include <math.h>
#include <float.h>
#include <ctype.h>

#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
# include <ieeefp.h>
#endif
#include "ruby_assert.h"

#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
#define USE_GMP
#include <gmp.h>
# define USE_GMP
# include <gmp.h>
#endif

#include "id.h"
#include "internal.h"
#include "internal/bignum.h"
#include "internal/complex.h"
#include "internal/gc.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/sanitizers.h"
#include "internal/util.h"
#include "internal/variable.h"
#include "internal/warnings.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "ruby_assert.h"

#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)

#ifndef RUBY_INTEGER_UNIFICATION
Expand Down
14 changes: 11 additions & 3 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@
* \{
*/

#include "ruby/config.h"
#include <ctype.h>

#include "constant.h"
#include "id_table.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/hash.h"
#include "internal/object.h"
#include "internal/variable.h"
#include "ruby/st.h"
#include "constant.h"
#include "vm_core.h"
#include "id_table.h"
#include <ctype.h>

#define id_attached id__attached__

Expand Down
5 changes: 4 additions & 1 deletion compar.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
**********************************************************************/

#include "ruby/ruby.h"
#include "id.h"
#include "internal.h"
#include "internal/compar.h"
#include "internal/error.h"
#include "internal/vm.h"
#include "ruby/ruby.h"

VALUE rb_mComparable;

Expand Down
38 changes: 26 additions & 12 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,39 @@
**********************************************************************/

#include "ruby/encoding.h"
#include "ruby/re.h"
#include "ruby/util.h"
#include "internal.h"
#include "encindex.h"
#include "ruby/config.h"
#include <math.h>

#ifdef HAVE_DLADDR
# include <dlfcn.h>
#endif

#include "encindex.h"
#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/compile.h"
#include "internal/complex.h"
#include "internal/debug.h"
#include "internal/encoding.h"
#include "internal/error.h"
#include "internal/hash.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/re.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
#include "ruby/re.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "vm_debug.h"

#include "builtin.h"
#include "iseq.h"
#include "insns.inc"
#include "insns_info.inc"
#include "id_table.h"
#include "gc.h"

#ifdef HAVE_DLADDR
# include <dlfcn.h>
#endif

#undef RUBY_UNTYPED_DATA_WARNING
#define RUBY_UNTYPED_DATA_WARNING 0
Expand Down
16 changes: 12 additions & 4 deletions complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
*/

#include "ruby/config.h"

#if defined _MSC_VER
/* Microsoft Visual C does not define M_PI and others by default */
# define _USE_MATH_DEFINES 1
#endif

#include <ctype.h>
#include <math.h>
#include "internal.h"
#include "id.h"

#define NDEBUG
#include "id.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/complex.h"
#include "internal/error.h"
#include "internal/math.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
#include "ruby_assert.h"

#define ZERO INT2FIX(0)
Expand Down Expand Up @@ -1700,8 +1710,6 @@ numeric_to_c(VALUE self)
return rb_complex_new1(self);
}

#include <ctype.h>

inline static int
issign(int c)
{
Expand Down
2 changes: 2 additions & 0 deletions constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
**********************************************************************/
#ifndef CONSTANT_H
#define CONSTANT_H
#include "ruby/ruby.h"
#include "id_table.h"

typedef enum {
CONST_DEPRECATED = 0x100,
Expand Down
20 changes: 13 additions & 7 deletions cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
**********************************************************************/

#include "internal.h"
#include "vm_core.h"
#include "gc.h"
#include "eval_intern.h"
#include "mjit.h"

#include COROUTINE_H
#include "ruby/config.h"

#ifndef _WIN32
#include <unistd.h>
#include <sys/mman.h>
#endif

#include COROUTINE_H

#include "eval_intern.h"
#include "gc.h"
#include "internal.h"
#include "internal/cont.h"
#include "internal/mjit.h"
#include "internal/proc.h"
#include "internal/warnings.h"
#include "mjit.h"
#include "vm_core.h"

static const int DEBUG = 0;

#define RB_PAGE_SIZE (pagesize)
Expand Down
2 changes: 2 additions & 0 deletions coroutine/amd64/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __attribute__((noreturn)) void
Expand Down
2 changes: 2 additions & 0 deletions coroutine/arm32/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __attribute__((noreturn)) void
Expand Down
2 changes: 2 additions & 0 deletions coroutine/arm64/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __attribute__((noreturn)) void
Expand Down
2 changes: 2 additions & 0 deletions coroutine/ppc64le/Context.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __attribute__((noreturn)) void
Expand Down
2 changes: 2 additions & 0 deletions coroutine/win32/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __declspec(noreturn) void __fastcall
Expand Down
2 changes: 2 additions & 0 deletions coroutine/win64/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __declspec(noreturn) void
Expand Down
2 changes: 2 additions & 0 deletions coroutine/x86/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma once

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define COROUTINE __attribute__((noreturn, fastcall)) void
Expand Down
17 changes: 12 additions & 5 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@
**********************************************************************/

#include "ruby/ruby.h"
#include "ruby/config.h"

#include <stdio.h>

#include "eval_intern.h"
#include "id.h"
#include "internal/debug.h"
#include "internal/signal.h"
#include "internal/util.h"
#include "ruby/encoding.h"
#include "ruby/io.h"
#include "ruby/ruby.h"
#include "ruby/util.h"
#include "vm_debug.h"
#include "eval_intern.h"
#include "vm_core.h"
#include "symbol.h"
#include "id.h"
#include "vm_core.h"
#include "vm_debug.h"

/* This is the only place struct RIMemo is actually used */
struct RIMemo {
Expand Down
Loading

0 comments on commit 5e22f87

Please sign in to comment.