From 01fa810682b759c0514c65a01d51c5599ea7f7c6 Mon Sep 17 00:00:00 2001 From: Tobias Schwinger Date: Mon, 5 Nov 2007 17:15:04 +0000 Subject: [PATCH] - nonstandard calling conventions disabled by default - automatic fallback configuration [SVN r40794] --- .../boost/function_types/config/compiler.hpp | 100 ++++++++++-------- .../detail/pp_cc_loop/master.hpp | 33 ++++++ .../detail/pp_cc_loop/preprocessed.hpp | 21 ++++ 3 files changed, 109 insertions(+), 45 deletions(-) diff --git a/include/boost/function_types/config/compiler.hpp b/include/boost/function_types/config/compiler.hpp index b9c020f..151c856 100644 --- a/include/boost/function_types/config/compiler.hpp +++ b/include/boost/function_types/config/compiler.hpp @@ -18,33 +18,36 @@ # error "unsupported compiler version" # endif - // enable clrcall calling covention (call to .NET managed code) when - // compiling with /clr -# if BOOST_MSVC >= 1400 && defined(__cplusplus_cli) -# ifndef BOOST_FT_CC_CLRCALL -# define BOOST_FT_CC_CLRCALL callable_builtin -# endif -# endif +# ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS - // Intel x86 architecture specific calling conventions -# ifdef _M_IX86 -# define BOOST_FT_COMMON_X86_CCs callable_builtin -# if BOOST_MSVC < 1400 - // version 7.1 is missing a keyword to specify the thiscall cc ... -# ifndef BOOST_FT_CC_IMPLICIT_THISCALL -# define BOOST_FT_CC_IMPLICIT_THISCALL non_variadic|member|callable_builtin -# ifndef BOOST_FT_CONFIG_OK -# pragma message("INFO| /Gd /Gr /Gz will compiler options will cause") -# pragma message("INFO| a compile error.") -# pragma message("INFO| Reconfigure Boost.FunctionTypes in this case.") -# pragma message("INFO| This message can be suppressed by defining") -# pragma message("INFO| BOOST_FT_CONFIG_OK.") + // enable clrcall calling covention (call to .NET managed code) when + // compiling with /clr +# if BOOST_MSVC >= 1400 && defined(__cplusplus_cli) +# ifndef BOOST_FT_CC_CLRCALL +# define BOOST_FT_CC_CLRCALL callable_builtin # endif -# endif -# else - // ...introduced in version 8 -# ifndef BOOST_FT_CC_THISCALL -# define BOOST_FT_CC_THISCALL non_variadic|member|callable_builtin +# endif + + // Intel x86 architecture specific calling conventions +# ifdef _M_IX86 +# define BOOST_FT_COMMON_X86_CCs callable_builtin +# if BOOST_MSVC < 1400 + // version 7.1 is missing a keyword to specify the thiscall cc ... +# ifndef BOOST_FT_CC_IMPLICIT_THISCALL +# define BOOST_FT_CC_IMPLICIT_THISCALL non_variadic|member|callable_builtin +# ifndef BOOST_FT_CONFIG_OK +# pragma message("INFO| /Gd /Gr /Gz will compiler options will cause") +# pragma message("INFO| a compile error.") +# pragma message("INFO| Reconfigure Boost.FunctionTypes in this case.") +# pragma message("INFO| This message can be suppressed by defining") +# pragma message("INFO| BOOST_FT_CONFIG_OK.") +# endif +# endif +# else + // ...introduced in version 8 +# ifndef BOOST_FT_CC_THISCALL +# define BOOST_FT_CC_THISCALL non_variadic|member|callable_builtin +# endif # endif # endif # endif @@ -55,32 +58,37 @@ # error "unsupported compiler version" # endif -# if defined(__i386__) -# // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20439 -# // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29328 -# if BOOST_WORKAROUND(__GNUC__,BOOST_TESTED_AT(4)) -# ifndef BOOST_FT_CC_IMPLICIT -# define BOOST_FT_CC_IMPLICIT member|callable_builtin +# ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS + +# if defined(__i386__) +# // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20439 +# // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29328 +# if BOOST_WORKAROUND(__GNUC__,BOOST_TESTED_AT(4)) +# ifndef BOOST_FT_CC_IMPLICIT +# define BOOST_FT_CC_IMPLICIT member|callable_builtin +# endif +# define BOOST_FT_COMMON_X86_CCs non_member|callable_builtin +# else +# define BOOST_FT_COMMON_X86_CCs callable_builtin # endif -# define BOOST_FT_COMMON_X86_CCs non_member|callable_builtin # else -# define BOOST_FT_COMMON_X86_CCs callable_builtin -# endif -# else -# ifndef BOOST_FT_CC_IMPLICIT -# define BOOST_FT_CC_IMPLICIT callable_builtin +# ifndef BOOST_FT_CC_IMPLICIT +# define BOOST_FT_CC_IMPLICIT callable_builtin +# endif # endif # endif -# // TODO: straighten out this hack -# ifndef __cdecl -# define __cdecl __attribute__((__cdecl__)) +# if (defined(BOOST_FT_CC_CDECL) || defined(BOOST_FT_COMMON_X86_CCs)) \ + && !defined(__cdecl) +# define __cdecl __attribute__((__cdecl__)) # endif -# ifndef __stdcall -# define __stdcall __attribute__((__stdcall__)) +# if (defined(BOOST_FT_CC_STDCALL) || defined(BOOST_FT_COMMON_X86_CCs)) \ + && !defined(__stdcall) +# define __stdcall __attribute__((__stdcall__)) # endif -# ifndef __fastcall -# define __fastcall __attribute__((__fastcall__)) +# if (defined(BOOST_FT_CC_FASTCALL) || defined(BOOST_FT_COMMON_X86_CCs)) \ + && !defined(__fastcall) +# define __fastcall __attribute__((__fastcall__)) # endif #elif defined(__BORLANDC__) @@ -91,7 +99,9 @@ # pragma message("WARNING: library untested with this compiler version") # endif -# define BOOST_FT_COMMON_X86_CCs callable_builtin +# ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS +# define BOOST_FT_COMMON_X86_CCs callable_builtin +# endif // syntactic specialities of cc specifier # define BOOST_FT_SYNTAX(result,lparen,cc_spec,type_mod,name,rparen) \ diff --git a/include/boost/function_types/detail/pp_cc_loop/master.hpp b/include/boost/function_types/detail/pp_cc_loop/master.hpp index 49ffded..5a6d6c4 100644 --- a/include/boost/function_types/detail/pp_cc_loop/master.hpp +++ b/include/boost/function_types/detail/pp_cc_loop/master.hpp @@ -37,6 +37,37 @@ # define BOOST_PP_ITERATION_LIMITS \ (0,BOOST_PP_SEQ_SIZE(BOOST_FT_CC_NAMES_SEQ)-1) # include BOOST_PP_ITERATE() +# if !defined(BOOST_FT_config_valid) && BOOST_FT_CC_PREPROCESSING +# define BOOST_FT_cc_id 1 +# define BOOST_FT_cc_name implicit_cc +# define BOOST_FT_cc BOOST_PP_EMPTY +# define BOOST_FT_cond callable_builtin +# include BOOST_PP_EXPAND ( ) +# undef BOOST_FT_cond +# undef BOOST_FT_cc_name +# undef BOOST_FT_cc +# undef BOOST_FT_cc_id +# elif !defined(BOOST_FT_config_valid) // and generating preprocessed file +BOOST_PP_EXPAND(#) ifndef BOOST_FT_config_valid +BOOST_PP_EXPAND(#) define BOOST_FT_cc_id 1 +BOOST_PP_EXPAND(#) define BOOST_FT_cc_name implicit_cc +BOOST_PP_EXPAND(#) define BOOST_FT_cc BOOST_PP_EMPTY +BOOST_PP_EXPAND(#) define BOOST_FT_cond callable_builtin +#define _() +BOOST_PP_EXPAND(#) include BOOST_PP_EXPAND _()( ) +#undef _ +BOOST_PP_EXPAND(#) undef BOOST_FT_cond +BOOST_PP_EXPAND(#) undef BOOST_FT_cc_name +BOOST_PP_EXPAND(#) undef BOOST_FT_cc +BOOST_PP_EXPAND(#) undef BOOST_FT_cc_id +BOOST_PP_EXPAND(#) else +BOOST_PP_EXPAND(#) undef BOOST_FT_config_valid +BOOST_PP_EXPAND(#) endif + +# else +# undef BOOST_FT_config_valid +# endif + # include # include @@ -53,6 +84,7 @@ # define BOOST_FT_cond BOOST_PP_CAT(BOOST_FT_CC_,BOOST_FT_cc_pp_name) # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND() # endif @@ -87,6 +119,7 @@ BOOST_PP_EXPAND(#) define BOOST_FT_cond BOOST_FT_cc_cond_v # undef BOOST_FT_cc_inf BOOST_PP_EXPAND(#) if BOOST_FT_cond +BOOST_PP_EXPAND(#) define BOOST_FT_config_valid 1 #define _() BOOST_PP_EXPAND(#) include BOOST_PP_EXPAND _()() #undef _ diff --git a/include/boost/function_types/detail/pp_cc_loop/preprocessed.hpp b/include/boost/function_types/detail/pp_cc_loop/preprocessed.hpp index 598de8a..87c6031 100644 --- a/include/boost/function_types/detail/pp_cc_loop/preprocessed.hpp +++ b/include/boost/function_types/detail/pp_cc_loop/preprocessed.hpp @@ -14,6 +14,7 @@ # define BOOST_FT_cc BOOST_PP_EMPTY # define BOOST_FT_cond BOOST_FT_CC_IMPLICIT # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -25,6 +26,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(__cdecl ) # define BOOST_FT_cond BOOST_FT_CC_CDECL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -36,6 +38,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(__stdcall ) # define BOOST_FT_cond BOOST_FT_CC_STDCALL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -47,6 +50,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(pascal ) # define BOOST_FT_cond BOOST_FT_CC_PASCAL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -58,6 +62,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(__fastcall) # define BOOST_FT_cond BOOST_FT_CC_FASTCALL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -69,6 +74,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(__clrcall ) # define BOOST_FT_cond BOOST_FT_CC_CLRCALL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -80,6 +86,7 @@ # define BOOST_FT_cc BOOST_PP_IDENTITY(__thiscall) # define BOOST_FT_cond BOOST_FT_CC_THISCALL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond @@ -91,9 +98,23 @@ # define BOOST_FT_cc BOOST_PP_EMPTY # define BOOST_FT_cond BOOST_FT_CC_IMPLICIT_THISCALL # if BOOST_FT_cond +# define BOOST_FT_config_valid 1 # include BOOST_PP_EXPAND ( ) # endif # undef BOOST_FT_cond # undef BOOST_FT_cc_name # undef BOOST_FT_cc # undef BOOST_FT_cc_id +# ifndef BOOST_FT_config_valid +# define BOOST_FT_cc_id 1 +# define BOOST_FT_cc_name implicit_cc +# define BOOST_FT_cc BOOST_PP_EMPTY +# define BOOST_FT_cond 0x00000001 +# include BOOST_PP_EXPAND ( ) +# undef BOOST_FT_cond +# undef BOOST_FT_cc_name +# undef BOOST_FT_cc +# undef BOOST_FT_cc_id +# else +# undef BOOST_FT_config_valid +# endif