diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-10 14:11:40 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-13 16:06:00 +0900 |
commit | 4ff3f205408ff8bb413d69151105d301858136ba (patch) | |
tree | 0494fea3f4cdb82ec1d34e462438389dfea8b8da /include/ruby/3/core | |
parent | a3f6f67967644f34226b4424227d2eec52fedd45 (diff) | |
download | ruby-4ff3f205408ff8bb413d69151105d301858136ba.tar.gz |
add #include guard hack
According to MSVC manual (*1), cl.exe can skip including a header file
when that:
- contains #pragma once, or
- starts with #ifndef, or
- starts with #if ! defined.
GCC has a similar trick (*2), but it acts more stricter (e. g. there
must be _no tokens_ outside of #ifndef...#endif).
Sun C lacked #pragma once for a looong time. Oracle Developer Studio
12.5 finally implemented it, but we cannot assume such recent version.
This changeset modifies header files so that each of them include
strictly one #ifndef...#endif. I believe this is the most portable way
to trigger compiler optimizations. [Bug #16770]
*1: https://docs.microsoft.com/en-us/cpp/preprocessor/once
*2: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
Diffstat (limited to 'include/ruby/3/core')
-rw-r--r-- | include/ruby/3/core/rarray.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rbasic.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rbignum.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rclass.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rdata.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rfile.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rhash.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rmatch.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/robject.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rregexp.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rstring.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rstruct.h | 6 | ||||
-rw-r--r-- | include/ruby/3/core/rtypeddata.h | 6 |
13 files changed, 39 insertions, 39 deletions
diff --git a/include/ruby/3/core/rarray.h b/include/ruby/3/core/rarray.h index cd8767a8a8..3234daae90 100644 --- a/include/ruby/3/core/rarray.h +++ b/include/ruby/3/core/rarray.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RARRAY_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RARRAY_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RArray. */ -#ifndef RUBY3_RARRAY_H -#define RUBY3_RARRAY_H #include "ruby/3/arithmetic/long.h" #include "ruby/3/attr/artificial.h" #include "ruby/3/attr/constexpr.h" diff --git a/include/ruby/3/core/rbasic.h b/include/ruby/3/core/rbasic.h index 510dd38da6..4f6fa576aa 100644 --- a/include/ruby/3/core/rbasic.h +++ b/include/ruby/3/core/rbasic.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RBASIC_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RBASIC_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RBasic. */ -#ifndef RUBY3_RBASIC_H -#define RUBY3_RBASIC_H #include "ruby/3/attr/artificial.h" #include "ruby/3/attr/constexpr.h" #include "ruby/3/attr/forceinline.h" diff --git a/include/ruby/3/core/rbignum.h b/include/ruby/3/core/rbignum.h index c1183e3ea6..09a478c2f8 100644 --- a/include/ruby/3/core/rbignum.h +++ b/include/ruby/3/core/rbignum.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RBIGNUM_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RBIGNUM_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Routines to manipulate struct ::RBignum. */ -#ifndef RUBY3_RBIGNUM_H -#define RUBY3_RBIGNUM_H #include "ruby/3/dllexport.h" #include "ruby/3/value.h" #include "ruby/3/value_type.h" diff --git a/include/ruby/3/core/rclass.h b/include/ruby/3/core/rclass.h index a54b34f5ba..e492da5ae5 100644 --- a/include/ruby/3/core/rclass.h +++ b/include/ruby/3/core/rclass.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RCLASS_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RCLASS_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Routines to manipulate struct ::RClass. */ -#ifndef RUBY3_RCLASS_H -#define RUBY3_RCLASS_H #include "ruby/3/dllexport.h" #include "ruby/3/value.h" #include "ruby/3/cast.h" diff --git a/include/ruby/3/core/rdata.h b/include/ruby/3/core/rdata.h index 651ceed0d7..6df6ea9e6d 100644 --- a/include/ruby/3/core/rdata.h +++ b/include/ruby/3/core/rdata.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RDATA_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RDATA_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RData. */ -#ifndef RUBY3_RDATA_H -#define RUBY3_RDATA_H #include "ruby/3/config.h" #ifdef STDC_HEADERS diff --git a/include/ruby/3/core/rfile.h b/include/ruby/3/core/rfile.h index 2b80a96e40..0b12d7bba4 100644 --- a/include/ruby/3/core/rfile.h +++ b/include/ruby/3/core/rfile.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RFILE_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RFILE_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RFile. */ -#ifndef RUBY3_RFILE_H -#define RUBY3_RFILE_H #include "ruby/3/core/rbasic.h" #include "ruby/3/cast.h" diff --git a/include/ruby/3/core/rhash.h b/include/ruby/3/core/rhash.h index 3778130141..e8f9901aa5 100644 --- a/include/ruby/3/core/rhash.h +++ b/include/ruby/3/core/rhash.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RHASH_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RHASH_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -30,8 +32,6 @@ * * Shyouhei stopped thinking. Let them be as is. */ -#ifndef RUBY3_RHASH_H -#define RUBY3_RHASH_H #include "ruby/3/config.h" #ifdef STDC_HEADERS diff --git a/include/ruby/3/core/rmatch.h b/include/ruby/3/core/rmatch.h index fff62f1473..f89cea849c 100644 --- a/include/ruby/3/core/rmatch.h +++ b/include/ruby/3/core/rmatch.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RMATCH_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RMATCH_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RMatch. */ -#ifndef RUBY3_RMATCH_H -#define RUBY3_RMATCH_H #include "ruby/3/attr/artificial.h" #include "ruby/3/attr/pure.h" #include "ruby/3/attr/returns_nonnull.h" diff --git a/include/ruby/3/core/robject.h b/include/ruby/3/core/robject.h index 82887a8c51..3f298214a9 100644 --- a/include/ruby/3/core/robject.h +++ b/include/ruby/3/core/robject.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_ROBJECT_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_ROBJECT_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RObject. */ -#ifndef RUBY3_ROBJECT_H -#define RUBY3_ROBJECT_H #include "ruby/3/config.h" #ifdef HAVE_STDINT_H diff --git a/include/ruby/3/core/rregexp.h b/include/ruby/3/core/rregexp.h index 1f30808e8a..0978c00c74 100644 --- a/include/ruby/3/core/rregexp.h +++ b/include/ruby/3/core/rregexp.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RREGEXP_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RREGEXP_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RRegexp. */ -#ifndef RUBY3_RREGEXP_H -#define RUBY3_RREGEXP_H #include "ruby/3/attr/artificial.h" #include "ruby/3/attr/pure.h" #include "ruby/3/cast.h" diff --git a/include/ruby/3/core/rstring.h b/include/ruby/3/core/rstring.h index 244b90e96c..8951dd0d30 100644 --- a/include/ruby/3/core/rstring.h +++ b/include/ruby/3/core/rstring.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RSTRING_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RSTRING_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RString. */ -#ifndef RUBY3_RSTRING_H -#define RUBY3_RSTRING_H #include "ruby/3/config.h" #include "ruby/3/arithmetic/long.h" #include "ruby/3/attr/artificial.h" diff --git a/include/ruby/3/core/rstruct.h b/include/ruby/3/core/rstruct.h index 55db1b3fc0..d474697e4e 100644 --- a/include/ruby/3/core/rstruct.h +++ b/include/ruby/3/core/rstruct.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RSTRUCT_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RSTRUCT_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Routines to manipulate struct ::RStruct. */ -#ifndef RUBY3_RSTRUCT_H -#define RUBY3_RSTRUCT_H #include "ruby/3/attr/artificial.h" #include "ruby/3/dllexport.h" #include "ruby/3/value.h" diff --git a/include/ruby/3/core/rtypeddata.h b/include/ruby/3/core/rtypeddata.h index cc00fa2500..d46fd5c519 100644 --- a/include/ruby/3/core/rtypeddata.h +++ b/include/ruby/3/core/rtypeddata.h @@ -1,4 +1,6 @@ -/** \noop-*-C++-*-vi:ft=cpp +#ifndef RUBY3_RTYPEDDATA_H /*-*-C++-*-vi:se ft=cpp:*/ +#define RUBY3_RTYPEDDATA_H +/** * @file * @author Ruby developers <ruby-core@ruby-lang.org> * @copyright This file is a part of the programming language Ruby. @@ -18,8 +20,6 @@ * extension libraries. They could be written in C++98. * @brief Defines struct ::RTypedData. */ -#ifndef RUBY3_RTYPEDDATA_H -#define RUBY3_RTYPEDDATA_H #include "ruby/3/config.h" #ifdef STDC_HEADERS |