[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / shadowcallstack / libc_support.h
blob9c8e0566380bc846d336b46c010a65c130775b0a
1 // This header provides replacements for certain libc functions. It is necessary
2 // in order to safely run the tests on aarch64, because the system libc might
3 // not have been compiled with -ffixed-x18.
5 #pragma once
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <stdio.h>
11 #ifdef __aarch64__
13 size_t scs_strlen(const char *p) {
14 size_t retval = 0;
15 while (*p++)
16 retval++;
17 return retval;
20 // We mark this function as noinline to make sure that its callers do not
21 // become leaf functions as a result of inlining. This is because we want to
22 // make sure that we generate the correct code for non-leaf functions.
24 __attribute__((noinline)) void scs_fputs_stdout(const char *p) {
25 __asm__ __volatile__(
26 "mov x0, #1\n" // stdout
27 "mov x1, %0\n"
28 "mov x2, %1\n"
29 "mov x8, #64\n" // write
30 "svc #0\n" ::"r"(p),
31 "r"(scs_strlen(p))
32 : "x0", "x1", "x2", "x8");
35 #else
36 #error Unsupported platform
37 #endif