llvm/compiler-rt/lib/nsan/nsan.h

//===-- nsan.h -------------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of NumericalStabilitySanitizer.
//
// Private NSan header.
//===----------------------------------------------------------------------===//

#ifndef NSAN_H
#define NSAN_H

#include "sanitizer_common/sanitizer_internal_defs.h"

sptr;
u16;
u8;
uptr;

#include "nsan_platform.h"

#include <assert.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>

// Private nsan interface. Used e.g. by interceptors.
extern "C" {

void __nsan_init();

// This marks the shadow type of the given block of application memory as
// unknown.
// printf-free (see comment in nsan_interceptors.cc).
void __nsan_set_value_unknown(const void *addr, uptr size);

// Copies annotations in the shadow memory for a block of application memory to
// a new address. This function is used together with memory-copying functions
// in application memory, e.g. the instrumentation inserts
// `__nsan_copy_values(dest, src, size)` after builtin calls to
// `memcpy(dest, src, size)`. Intercepted memcpy calls also call this function.
// printf-free (see comment in nsan_interceptors.cc).
void __nsan_copy_values(const void *daddr, const void *saddr, uptr size);

SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char *
__nsan_default_options();
}

// Unwind the stack for fatal error, as the parameter `stack` is
// empty without origins.
#define GET_FATAL_STACK_TRACE_IF_EMPTY(STACK)

namespace __nsan {

extern bool nsan_initialized;
extern bool nsan_init_is_running;

void InitializeInterceptors();
void InitializeMallocInterceptors();

// See notes in nsan_platform.
inline u8 *GetShadowAddrFor(void *ptr) {}

inline u8 *GetShadowAddrFor(const void *ptr) {}

inline u8 *GetShadowTypeAddrFor(void *ptr) {}

inline u8 *GetShadowTypeAddrFor(const void *ptr) {}

// Information about value types and their shadow counterparts.
template <typename FT> struct FTInfo {};
template <> struct FTInfo<float> {};
template <> struct FTInfo<double> {};
template <> struct FTInfo<long double> {};

template <> struct FTInfo<__float128> {};

constexpr double kMaxULPDiff =;

// Helper for getULPDiff that works on bit representations.
template <typename BT> double GetULPDiffBits(BT v1_bits, BT v2_bits) {}

// Returns the the number of floating point values between v1 and v2, capped to
// u64max. Return 0 for (-0.0,0.0).
template <typename FT> double GetULPDiff(FT v1, FT v2) {}

// FIXME: This needs mor work: Because there is no 80-bit integer type, we have
// to go through __uint128_t. Therefore the assumptions about the sign bit do
// not hold.
template <> inline double GetULPDiff(long double v1, long double v2) {}

} // end namespace __nsan

#endif // NSAN_H