diff --git a/test cases/common/127 cpp and asm/meson.build b/test cases/common/127 cpp and asm/meson.build new file mode 100644 index 000000000..55c3d3c6f --- /dev/null +++ b/test cases/common/127 cpp and asm/meson.build @@ -0,0 +1,16 @@ +project('c++ and assembly test', 'cpp') + +sources = ['trivial.cc'] +# If the compiler cannot compile assembly, don't use it +if meson.get_compiler('cpp').get_id() != 'msvc' + cpu = host_machine.cpu_family() + sources += ['retval-' + cpu + '.S'] + cpp_args = ['-DUSE_ASM'] + message('Using ASM') +else + cpp_args = ['-DNO_USE_ASM'] +endif + +exe = executable('trivialprog', sources, + cpp_args : cpp_args) +test('runtest', exe) diff --git a/test cases/common/127 cpp and asm/retval-arm.S b/test cases/common/127 cpp and asm/retval-arm.S new file mode 100644 index 000000000..8b3719765 --- /dev/null +++ b/test cases/common/127 cpp and asm/retval-arm.S @@ -0,0 +1,8 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) + +SYMBOL_NAME(get_retval): + mov r0, #0 + mov pc, lr diff --git a/test cases/common/127 cpp and asm/retval-x86.S b/test cases/common/127 cpp and asm/retval-x86.S new file mode 100644 index 000000000..06bd75c28 --- /dev/null +++ b/test cases/common/127 cpp and asm/retval-x86.S @@ -0,0 +1,8 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) + +SYMBOL_NAME(get_retval): + xorl %eax, %eax + retl diff --git a/test cases/common/127 cpp and asm/retval-x86_64.S b/test cases/common/127 cpp and asm/retval-x86_64.S new file mode 100644 index 000000000..638921e3e --- /dev/null +++ b/test cases/common/127 cpp and asm/retval-x86_64.S @@ -0,0 +1,8 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) + +SYMBOL_NAME(get_retval): + xorl %eax, %eax + retq diff --git a/test cases/common/127 cpp and asm/symbol-underscore.h b/test cases/common/127 cpp and asm/symbol-underscore.h new file mode 100644 index 000000000..508cf50c5 --- /dev/null +++ b/test cases/common/127 cpp and asm/symbol-underscore.h @@ -0,0 +1,5 @@ +#if defined(__WIN32__) || defined(__APPLE__) +# define SYMBOL_NAME(name) _##name +#else +# define SYMBOL_NAME(name) name +#endif diff --git a/test cases/common/127 cpp and asm/trivial.cc b/test cases/common/127 cpp and asm/trivial.cc new file mode 100644 index 000000000..d2928c0c9 --- /dev/null +++ b/test cases/common/127 cpp and asm/trivial.cc @@ -0,0 +1,16 @@ +#include + +extern "C" { + int get_retval(void); +} + +int main(int argc, char **argv) { + std::cout << "C++ seems to be working." << std::endl; +#if defined(USE_ASM) + return get_retval(); +#elif defined(NO_USE_ASM) + return 0; +#else + #error "Forgot to pass asm define" +#endif +}