Browse Source
Fix linking problems on some platforms caused by inline/non-inline versions
Fix linking problems on some platforms caused by inline/non-inline versions
of same functions (obsoletes MAYBE_INLINE) [by Alexei Sheplyakov].master
123 changed files with 621 additions and 463 deletions
-
128ChangeLog
-
8src/base/cl_inline.h
-
8src/base/cl_inline2.h
-
5src/base/cl_macros.h
-
131src/base/cl_maybe_inline.h
-
5src/base/string/cl_st_concat1.cc
-
5src/base/string/cl_st_concat2.cc
-
5src/base/string/cl_st_concat3.cc
-
1src/base/string/cl_st_make0.cc
-
5src/complex/algebraic/cl_C_abs.cc
-
3src/complex/algebraic/cl_C_abs_aux.cc
-
7src/complex/algebraic/cl_C_signum.cc
-
8src/complex/algebraic/cl_DF_hypot.cc
-
8src/complex/algebraic/cl_FF_hypot.cc
-
8src/complex/algebraic/cl_LF_hypot.cc
-
8src/complex/algebraic/cl_SF_hypot.cc
-
6src/complex/transcendental/cl_C_acosh.cc
-
10src/complex/transcendental/cl_C_asinh_aux.cc
-
10src/complex/transcendental/cl_C_atanh_aux.cc
-
8src/float/dfloat/division/cl_DF_fceil.cc
-
7src/float/dfloat/elem/cl_DF_div.cc
-
7src/float/dfloat/elem/cl_DF_ffloor.cc
-
3src/float/dfloat/elem/cl_DF_minusp.cc
-
5src/float/dfloat/elem/cl_DF_mul.cc
-
10src/float/dfloat/elem/cl_DF_plusp.cc
-
3src/float/dfloat/elem/cl_DF_zerop.cc
-
5src/float/dfloat/misc/cl_DF_abs.cc
-
3src/float/dfloat/misc/cl_DF_digits.cc
-
3src/float/dfloat/misc/cl_DF_eqhashcode.cc
-
3src/float/dfloat/misc/cl_DF_exponent.cc
-
3src/float/dfloat/misc/cl_DF_idecode.cc
-
8src/float/dfloat/misc/cl_DF_precision.cc
-
8src/float/dfloat/misc/cl_DF_sign.cc
-
10src/float/dfloat/misc/cl_DF_signum.cc
-
13src/float/elem/cl_F_minusp.cc
-
13src/float/elem/cl_F_plusp.cc
-
13src/float/elem/cl_F_zerop.cc
-
7src/float/ffloat/division/cl_FF_fceil.cc
-
7src/float/ffloat/elem/cl_FF_div.cc
-
7src/float/ffloat/elem/cl_FF_ffloor.cc
-
3src/float/ffloat/elem/cl_FF_minusp.cc
-
5src/float/ffloat/elem/cl_FF_mul.cc
-
10src/float/ffloat/elem/cl_FF_plusp.cc
-
3src/float/ffloat/elem/cl_FF_zerop.cc
-
7src/float/ffloat/misc/cl_FF_abs.cc
-
3src/float/ffloat/misc/cl_FF_digits.cc
-
3src/float/ffloat/misc/cl_FF_eqhashcode.cc
-
3src/float/ffloat/misc/cl_FF_exponent.cc
-
6src/float/ffloat/misc/cl_FF_idecode.cc
-
8src/float/ffloat/misc/cl_FF_precision.cc
-
8src/float/ffloat/misc/cl_FF_sign.cc
-
10src/float/ffloat/misc/cl_FF_signum.cc
-
7src/float/lfloat/division/cl_LF_fceil.cc
-
9src/float/lfloat/elem/cl_LF_compare.cc
-
7src/float/lfloat/elem/cl_LF_ffloor.cc
-
3src/float/lfloat/elem/cl_LF_minusp.cc
-
10src/float/lfloat/elem/cl_LF_plusp.cc
-
5src/float/lfloat/elem/cl_LF_to_I.cc
-
3src/float/lfloat/elem/cl_LF_zerop.cc
-
7src/float/lfloat/misc/cl_LF_abs.cc
-
3src/float/lfloat/misc/cl_LF_digits.cc
-
3src/float/lfloat/misc/cl_LF_eqhashcode.cc
-
3src/float/lfloat/misc/cl_LF_exponent.cc
-
3src/float/lfloat/misc/cl_LF_idecode.cc
-
8src/float/lfloat/misc/cl_LF_precision.cc
-
14src/float/lfloat/misc/cl_LF_shortenrel.cc
-
12src/float/lfloat/misc/cl_LF_shortenwith.cc
-
6src/float/lfloat/misc/cl_LF_sign.cc
-
8src/float/lfloat/misc/cl_LF_signum.cc
-
13src/float/misc/cl_F_abs.cc
-
11src/float/misc/cl_F_digits.cc
-
13src/float/misc/cl_F_eqhashcode.cc
-
13src/float/misc/cl_F_exponent.cc
-
13src/float/misc/cl_F_idecode.cc
-
5src/float/misc/cl_F_precision.cc
-
13src/float/misc/cl_F_sign.cc
-
14src/float/misc/cl_F_signum.cc
-
8src/float/sfloat/division/cl_SF_fceil.cc
-
8src/float/sfloat/division/cl_SF_ffloor.cc
-
11src/float/sfloat/elem/cl_SF_compare.cc
-
6src/float/sfloat/elem/cl_SF_minus.cc
-
3src/float/sfloat/elem/cl_SF_minusp.cc
-
11src/float/sfloat/elem/cl_SF_plusp.cc
-
5src/float/sfloat/elem/cl_SF_uminus.cc
-
3src/float/sfloat/elem/cl_SF_zerop.cc
-
7src/float/sfloat/misc/cl_SF_abs.cc
-
3src/float/sfloat/misc/cl_SF_digits.cc
-
3src/float/sfloat/misc/cl_SF_eqhashcode.cc
-
3src/float/sfloat/misc/cl_SF_exponent.cc
-
3src/float/sfloat/misc/cl_SF_idecode.cc
-
8src/float/sfloat/misc/cl_SF_precision.cc
-
6src/float/sfloat/misc/cl_SF_sign.cc
-
11src/float/sfloat/misc/cl_SF_signum.cc
-
11src/float/transcendental/cl_F_atanhx.cc
-
17src/float/transcendental/cl_F_atanx.cc
-
5src/float/transcendental/cl_F_exp.cc
-
7src/float/transcendental/cl_F_expx.cc
-
9src/float/transcendental/cl_F_lnx.cc
-
7src/float/transcendental/cl_F_sinhx.cc
-
7src/float/transcendental/cl_F_sinx.cc
@ -0,0 +1,8 @@ |
|||
/* |
|||
* Selectively inline a function in *some* translation units. |
|||
* See cl_maybe_inline.h file for the explanation. |
|||
*/ |
|||
#undef CL_INLINE |
|||
#undef CL_INLINE_DECL |
|||
#define CL_INLINE static inline |
|||
#define CL_INLINE_DECL(fcn) CL_INLINE_HINT fcn ## _inline |
@ -0,0 +1,8 @@ |
|||
/* |
|||
* Selectively inline a function in *some* translation units. |
|||
* See cl_maybe_inline.h file for the explanation. |
|||
*/ |
|||
#undef CL_INLINE2 |
|||
#undef CL_INLINE2_DECL |
|||
#define CL_INLINE2 static inline |
|||
#define CL_INLINE2_DECL(fcn) CL_INLINE_HINT fcn ## _inline |
@ -0,0 +1,131 @@ |
|||
// CLN internal inlining hints |
|||
|
|||
#ifndef _CL_MAYBE_INLINE_H |
|||
#define _CL_MAYBE_INLINE_H |
|||
|
|||
/* |
|||
* Selectively inline a function in *some* translation units. |
|||
* |
|||
* The need to inline a function in some places and not in others came from |
|||
* three situations: |
|||
* |
|||
* 1) Some functions, like cl_SF_zerop or cl_FF_zerop, are just a single |
|||
* machine instruction when inlined. Putting their definitions into a public |
|||
* header would expose too many internals of the library, leading violation |
|||
* of abstraction and increased compilation times. Still, it would be nice |
|||
* to use the inline version of these functions in the library itself. |
|||
* |
|||
* 2) Some functions, like cl_{SF,FF,DF,LF}_idecode, are usually only |
|||
* invoked through a dispatcher cl_F_idecode that does nothing but dispatch |
|||
* the call to the right function. Here inlining is used, regardless of |
|||
* the size of the inlined functions, because it removes one function call |
|||
* from the chain of function calls. A compiler cannot know that this |
|||
* caller is the main caller for the 4 inlined functions. |
|||
* |
|||
* 3) Similarly, cl_I_from_NDS would be a bottleneck if not inlined: every |
|||
* creation of a new cl_I goes through this function. A compiler cannot |
|||
* know a priori the bottlenecks. |
|||
* |
|||
* Hence, there is a set of macros which help to create inline and |
|||
* non-inline versions of a function without duplicating the code. |
|||
* |
|||
* Usage: |
|||
* |
|||
* 1. In the public header, declare function as usual: |
|||
* |
|||
* extern cl_bar cl_foo(const cl_baz&); |
|||
* |
|||
* 2. Put the definition into a separate file, say, cl_foo.cc, in the |
|||
* following way: |
|||
* |
|||
* // cl_foo.cc |
|||
* |
|||
* #include "cl_macros.h" |
|||
* #include "whatever/you/need.h" |
|||
* |
|||
* CL_INLINE cl_bar CL_INLINE_DECL(cl_foo)(const cl_baz& x) |
|||
* { |
|||
* // the actual code goes here |
|||
* } |
|||
* |
|||
* This provides normal (non-inline) version of a function cl_foo. |
|||
* |
|||
* 3. In order to use the inline version, do |
|||
* |
|||
* // cl_blah.cc |
|||
* |
|||
* #include "cl_inline.h" |
|||
* #include "path/to/cl_foo.cc" |
|||
* |
|||
* This will declare and define function cl_foo_inline, which is an inline |
|||
* version of cl_foo. |
|||
* |
|||
* XXX: |
|||
* The name of the inline version *really* has to be different, since ISO C++ |
|||
* demands (in 7.1.2.4) |
|||
* |
|||
* "If a function with external linkage is declared inline in one translation |
|||
* unit, it shall be declared inline in all translation units in which it |
|||
* appears; no diagnostic is required." |
|||
* |
|||
* Feel free to implement this functionality in a better *standard-compliant* |
|||
* way. Or submit a DR (defect report) to the standard committee. |
|||
*/ |
|||
#define CL_INLINE |
|||
#define CL_INLINE_DECL(fcn) fcn |
|||
|
|||
/* |
|||
* Use these macros to provide inline and non-inline versions of a function |
|||
* which uses an inline version of other function(s). |
|||
*/ |
|||
#define CL_INLINE2 |
|||
#define CL_INLINE2_DECL(fcn) fcn |
|||
|
|||
/* |
|||
* Some functions (zerop, signum, etc) just dispatch the call to the |
|||
* appropriate type-specific functions. It would be nice to have these |
|||
* type-specific functions inlined. However, the compiler can not know that, |
|||
* unless one gives it a hint. |
|||
* |
|||
* Usage: |
|||
* |
|||
* const cl_foo CL_FLATTEN cl_bar(const cl_R& x) |
|||
* { |
|||
* // the actual code |
|||
* } |
|||
* |
|||
* Please note: |
|||
* |
|||
* 1. This is only a *hint*, it's always up to the compiler to NOT inline |
|||
* a function. |
|||
* 2. It's ignored if the optimization is switched off. |
|||
*/ |
|||
#ifdef __GNUC__ |
|||
#define CL_FLATTEN __attribute__((flatten)) |
|||
#else |
|||
#define CL_FLATTEN |
|||
#endif |
|||
|
|||
/* |
|||
* Tell the compiler to inline a function more aggressively, i.e. even if the |
|||
* optimization is switched off. |
|||
* |
|||
* Usage: |
|||
* |
|||
* cl_blah CL_INLINE_HINT cl_foo(const cl_baz& x) |
|||
* { |
|||
* // the actual code |
|||
* } |
|||
* |
|||
* Notes: |
|||
* 1. This is only a hint, it does NOT guarantee the function will be |
|||
* actually always inlined. |
|||
* 2. CL_INLINE and CL_INLINE2 macros set this attribute automagically. |
|||
*/ |
|||
#ifdef __GNUC__ |
|||
#define CL_INLINE_HINT __attribute__((always_inline)) |
|||
#else |
|||
#define CL_INLINE_HINT |
|||
#endif |
|||
|
|||
#endif /* _CL_MAYBE_INLINE_H */ |
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue