[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / trampoline_setup_test.c
blob9cde76526b62e1a95359993fb81f5d5fcbb40921
1 // RUN: %clang_builtins %s %librt -fnested-functions -o %t && %run %t
2 // REQUIRES: librt_has_trampoline_setup
3 /* ===-- trampoline_setup_test.c - Test __trampoline_setup -----------------===
5 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 * See https://llvm.org/LICENSE.txt for license information.
7 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 * ===----------------------------------------------------------------------===
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdint.h>
18 * Tests nested functions
19 * The ppc compiler generates a call to __trampoline_setup
20 * The i386 and x86_64 compilers generate a call to ___enable_execute_stack
24 * Note that, nested functions are not ISO C and are not supported in Clang.
27 #if !defined(__clang__)
29 typedef int (*nested_func_t)(int x);
31 nested_func_t proc;
33 int main() {
34 /* Some locals */
35 int c = 10;
36 int d = 7;
38 /* Define a nested function: */
39 int bar(int x) { return x*5 + c*d; };
41 /* Assign global to point to nested function
42 * (really points to trampoline). */
43 proc = bar;
45 /* Invoke nested function: */
46 c = 4;
47 if ( (*proc)(3) != 43 )
48 return 1;
49 d = 5;
50 if ( (*proc)(4) != 40 )
51 return 1;
53 /* Success. */
54 return 0;
57 #else
59 int main() {
60 printf("skipped\n");
61 return 0;
64 #endif