diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-26 16:52:13 +0300 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-26 23:39:15 +0100 |
| commit | e75e3976facda7de244fbb9a02eebf0d043ea1c8 (patch) | |
| tree | dab22f95b5c837a70b1b4164d97ff351a49ffd81 /test cases/common/119 cpp and asm | |
| parent | 53fe7c2f0a51697cd57628753852dd3f8711becf (diff) | |
| download | meson-e75e3976facda7de244fbb9a02eebf0d043ea1c8.tar.gz | |
Condense test directory names.
Diffstat (limited to 'test cases/common/119 cpp and asm')
| -rw-r--r-- | test cases/common/119 cpp and asm/meson.build | 33 | ||||
| -rw-r--r-- | test cases/common/119 cpp and asm/retval-arm.S | 11 | ||||
| -rw-r--r-- | test cases/common/119 cpp and asm/retval-x86.S | 11 | ||||
| -rw-r--r-- | test cases/common/119 cpp and asm/retval-x86_64.S | 11 | ||||
| -rw-r--r-- | test cases/common/119 cpp and asm/symbol-underscore.h | 5 | ||||
| -rw-r--r-- | test cases/common/119 cpp and asm/trivial.cc | 16 |
6 files changed, 87 insertions, 0 deletions
diff --git a/test cases/common/119 cpp and asm/meson.build b/test cases/common/119 cpp and asm/meson.build new file mode 100644 index 000000000..99713d485 --- /dev/null +++ b/test cases/common/119 cpp and asm/meson.build @@ -0,0 +1,33 @@ +project('c++ and assembly test') +add_languages('cpp') + +if meson.backend() == 'xcode' + error('MESON_SKIP_TEST: asm not supported with the Xcode backend. Patches welcome.') +endif + +cpp = meson.get_compiler('cpp') +cpu = host_machine.cpu_family() + +supported_cpus = ['arm', 'x86', 'x86_64'] + +if not supported_cpus.contains(cpu) + error('MESON_SKIP_TEST unsupported cpu:' + cpu) +endif + +if cpp.symbols_have_underscore_prefix() + add_project_arguments('-DMESON_TEST__UNDERSCORE_SYMBOL', language : 'cpp') +endif + +sources = ['trivial.cc'] +# If the compiler cannot compile assembly, don't use it +if not ['msvc', 'clang-cl', 'intel-cl'].contains(meson.get_compiler('cpp').get_id()) + 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/119 cpp and asm/retval-arm.S b/test cases/common/119 cpp and asm/retval-arm.S new file mode 100644 index 000000000..a8923624a --- /dev/null +++ b/test cases/common/119 cpp and asm/retval-arm.S @@ -0,0 +1,11 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) +# ifdef __linux__ +.type get_retval, %function +#endif + +SYMBOL_NAME(get_retval): + mov r0, #0 + mov pc, lr diff --git a/test cases/common/119 cpp and asm/retval-x86.S b/test cases/common/119 cpp and asm/retval-x86.S new file mode 100644 index 000000000..f9e819070 --- /dev/null +++ b/test cases/common/119 cpp and asm/retval-x86.S @@ -0,0 +1,11 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) +# ifdef __linux__ +.type get_retval, %function +#endif + +SYMBOL_NAME(get_retval): + xorl %eax, %eax + retl diff --git a/test cases/common/119 cpp and asm/retval-x86_64.S b/test cases/common/119 cpp and asm/retval-x86_64.S new file mode 100644 index 000000000..1a5f3eb23 --- /dev/null +++ b/test cases/common/119 cpp and asm/retval-x86_64.S @@ -0,0 +1,11 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(get_retval) +# ifdef __linux__ +.type get_retval, %function +#endif + +SYMBOL_NAME(get_retval): + xorl %eax, %eax + retq diff --git a/test cases/common/119 cpp and asm/symbol-underscore.h b/test cases/common/119 cpp and asm/symbol-underscore.h new file mode 100644 index 000000000..d0f3ef9cc --- /dev/null +++ b/test cases/common/119 cpp and asm/symbol-underscore.h @@ -0,0 +1,5 @@ +#if defined(MESON_TEST__UNDERSCORE_SYMBOL) +# define SYMBOL_NAME(name) _##name +#else +# define SYMBOL_NAME(name) name +#endif diff --git a/test cases/common/119 cpp and asm/trivial.cc b/test cases/common/119 cpp and asm/trivial.cc new file mode 100644 index 000000000..19d5e944d --- /dev/null +++ b/test cases/common/119 cpp and asm/trivial.cc @@ -0,0 +1,16 @@ +#include<iostream> + +extern "C" { + int get_retval(void); +} + +int main(void) { + 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 +} |
