asan_interceptors.h revision c0d78c1de1f2607c874020d27b72cf989c5ce092
1//===-- asan_interceptors.h -------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is a part of AddressSanitizer, an address sanity checker.
11//
12// ASan-private header for asan_interceptors.cc
13//===----------------------------------------------------------------------===//
14#ifndef ASAN_INTERCEPTORS_H
15#define ASAN_INTERCEPTORS_H
16
17#include "asan_internal.h"
18#include "interception/interception.h"
19
20DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size);
21DECLARE_REAL(void*, memcpy, void *to, const void *from, uptr size);
22DECLARE_REAL(void*, memset, void *block, int c, uptr size);
23DECLARE_REAL(char*, strchr, const char *str, int c);
24DECLARE_REAL(uptr, strlen, const char *s);
25DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size);
26DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen);
27struct sigaction;
28DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act,
29                             struct sigaction *oldact);
30
31namespace __asan {
32
33// __asan::internal_X() is the implementation of X() for use in RTL.
34s64 internal_atoll(const char *nptr);
35uptr internal_strlen(const char *s);
36uptr internal_strnlen(const char *s, uptr maxlen);
37char* internal_strchr(const char *s, int c);
38void* internal_memchr(const void* s, int c, uptr n);
39void* internal_memset(void *s, int c, uptr n);
40int internal_memcmp(const void* s1, const void* s2, uptr n);
41char *internal_strstr(const char *haystack, const char *needle);
42char *internal_strncat(char *dst, const char *src, uptr n);
43// Works only for base=10 and doesn't set errno.
44s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
45
46void InitializeAsanInterceptors();
47
48#if defined(__APPLE__)
49void InitializeMacInterceptors();
50#endif  // __APPLE__
51
52}  // namespace __asan
53
54#endif  // ASAN_INTERCEPTORS_H
55