brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 7d88911 Raw
59 lines · c
1//===-- sanitizer_redefine_builtins.h ---------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Redefine builtin functions to use internal versions. This is needed where10// compiler optimizations end up producing unwanted libcalls!11//12//===----------------------------------------------------------------------===//13#ifndef SANITIZER_COMMON_NO_REDEFINE_BUILTINS14#  ifndef SANITIZER_REDEFINE_BUILTINS_H15#    define SANITIZER_REDEFINE_BUILTINS_H16 17// The asm hack only works with GCC and Clang.18#    if !defined(_WIN32) && !defined(_AIX) && !defined(__APPLE__)19 20asm(R"(21    .set memcpy, __sanitizer_internal_memcpy22    .set memmove, __sanitizer_internal_memmove23    .set memset, __sanitizer_internal_memset24    )");25 26#      if defined(__cplusplus) && \27          !defined(SANITIZER_COMMON_REDEFINE_BUILTINS_IN_STD)28 29// The builtins should not be redefined in source files that make use of C++30// standard libraries, in particular where C++STL headers with inline functions31// are used. The redefinition in such cases would lead to ODR violations.32//33// Try to break the build in common cases where builtins shouldn't be redefined.34namespace std {35class Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file {36  Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file(37      const Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file&) = delete;38  Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file& operator=(39      const Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file&) = delete;40};41using array = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;42using atomic = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;43using function = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;44using map = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;45using set = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;46using shared_ptr = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;47using string = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;48using unique_ptr = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;49using unordered_map = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;50using unordered_set = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;51using vector = Define_SANITIZER_COMMON_NO_REDEFINE_BUILTINS_in_cpp_file;52}  // namespace std53 54#      endif  // __cpluplus55#    endif    // !_WIN3256 57#  endif  // SANITIZER_REDEFINE_BUILTINS_H58#endif    // SANITIZER_COMMON_NO_REDEFINE_BUILTINS59