Relocate the external headers provided by ASan and the common sanitizer
[blocksruntime.git] / lib / sanitizer_common / sanitizer_libc.h
blob8c3a78cd5193e948d1d77782cc8554eae4015093
1 //===-- sanitizer_libc.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 shared between AddressSanitizer and ThreadSanitizer
11 // run-time libraries.
12 // These tools can not use some of the libc functions directly because those
13 // functions are intercepted. Instead, we implement a tiny subset of libc here.
14 // NOTE: This file may be included into user code.
15 //===----------------------------------------------------------------------===//
16 #ifndef SANITIZER_LIBC_H
17 #define SANITIZER_LIBC_H
19 // ----------- ATTENTION -------------
20 // This header should NOT include any other headers from sanitizer runtime.
21 #include "sanitizer/common_interface_defs.h"
23 namespace __sanitizer {
25 // internal_X() is a custom implementation of X() for use in RTL.
27 // String functions
28 s64 internal_atoll(const char *nptr);
29 void *internal_memchr(const void *s, int c, uptr n);
30 int internal_memcmp(const void* s1, const void* s2, uptr n);
31 void *internal_memcpy(void *dest, const void *src, uptr n);
32 // Should not be used in performance-critical places.
33 void *internal_memset(void *s, int c, uptr n);
34 char* internal_strchr(const char *s, int c);
35 int internal_strcmp(const char *s1, const char *s2);
36 uptr internal_strcspn(const char *s, const char *reject);
37 char *internal_strdup(const char *s);
38 uptr internal_strlen(const char *s);
39 char *internal_strncat(char *dst, const char *src, uptr n);
40 int internal_strncmp(const char *s1, const char *s2, uptr n);
41 char *internal_strncpy(char *dst, const char *src, uptr n);
42 uptr internal_strnlen(const char *s, uptr maxlen);
43 char *internal_strrchr(const char *s, int c);
44 // This is O(N^2), but we are not using it in hot places.
45 char *internal_strstr(const char *haystack, const char *needle);
46 // Works only for base=10 and doesn't set errno.
47 s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
49 // Memory
50 void *internal_mmap(void *addr, uptr length, int prot, int flags,
51 int fd, u64 offset);
52 int internal_munmap(void *addr, uptr length);
54 // I/O
55 typedef int fd_t;
56 const fd_t kInvalidFd = -1;
57 int internal_close(fd_t fd);
58 fd_t internal_open(const char *filename, bool write);
59 uptr internal_read(fd_t fd, void *buf, uptr count);
60 uptr internal_write(fd_t fd, const void *buf, uptr count);
61 uptr internal_filesize(fd_t fd); // -1 on error.
62 int internal_dup2(int oldfd, int newfd);
63 int internal_snprintf(char *buffer, uptr length, const char *format, ...);
65 // Threading
66 int internal_sched_yield();
68 } // namespace __sanitizer
70 #endif // SANITIZER_LIBC_H