* config/pa/constraints.md: Adjust unused letters. Change "T"
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_libc.h
blobf193017f953eb3e2405502d4bd4a33493ff081ba
1 //===-- sanitizer_libc.h ----------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is shared between AddressSanitizer and ThreadSanitizer
9 // run-time libraries.
10 // These tools can not use some of the libc functions directly because those
11 // functions are intercepted. Instead, we implement a tiny subset of libc here.
12 // NOTE: This file may be included into user code.
13 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_LIBC_H
15 #define SANITIZER_LIBC_H
17 // ----------- ATTENTION -------------
18 // This header should NOT include any other headers from sanitizer runtime.
19 #include "sanitizer/common_interface_defs.h"
21 namespace __sanitizer {
23 // internal_X() is a custom implementation of X() for use in RTL.
25 // String functions
26 s64 internal_atoll(const char *nptr);
27 void *internal_memchr(const void *s, int c, uptr n);
28 int internal_memcmp(const void* s1, const void* s2, uptr n);
29 void *internal_memcpy(void *dest, const void *src, uptr n);
30 void *internal_memmove(void *dest, const void *src, uptr n);
31 // Should not be used in performance-critical places.
32 void *internal_memset(void *s, int c, uptr n);
33 char* internal_strchr(const char *s, int c);
34 int internal_strcmp(const char *s1, const char *s2);
35 uptr internal_strcspn(const char *s, const char *reject);
36 char *internal_strdup(const char *s);
37 uptr internal_strlen(const char *s);
38 char *internal_strncat(char *dst, const char *src, uptr n);
39 int internal_strncmp(const char *s1, const char *s2, uptr n);
40 char *internal_strncpy(char *dst, const char *src, uptr n);
41 uptr internal_strnlen(const char *s, uptr maxlen);
42 char *internal_strrchr(const char *s, int c);
43 // This is O(N^2), but we are not using it in hot places.
44 char *internal_strstr(const char *haystack, const char *needle);
45 // Works only for base=10 and doesn't set errno.
46 s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
48 // Return true if all bytes in [mem, mem+size) are zero.
49 // Optimized for the case when the result is true.
50 bool mem_is_zero(const char *mem, uptr size);
53 // Memory
54 void *internal_mmap(void *addr, uptr length, int prot, int flags,
55 int fd, u64 offset);
56 int internal_munmap(void *addr, uptr length);
58 // I/O
59 typedef int fd_t;
60 const fd_t kInvalidFd = -1;
61 const fd_t kStdinFd = 0;
62 const fd_t kStdoutFd = 1;
63 const fd_t kStderrFd = 2;
64 int internal_close(fd_t fd);
65 int internal_isatty(fd_t fd);
66 fd_t internal_open(const char *filename, bool write);
67 uptr internal_read(fd_t fd, void *buf, uptr count);
68 uptr internal_write(fd_t fd, const void *buf, uptr count);
69 uptr internal_filesize(fd_t fd); // -1 on error.
70 int internal_dup2(int oldfd, int newfd);
71 uptr internal_readlink(const char *path, char *buf, uptr bufsize);
72 int internal_snprintf(char *buffer, uptr length, const char *format, ...);
74 // Threading
75 int internal_sched_yield();
77 } // namespace __sanitizer
79 #endif // SANITIZER_LIBC_H