sanitizer_libc.h revision 1f11d31faa5ed89b74f7d543b1182fe8de198be5
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//
15// We also define several basic types here to avoid using system headers
16// as the latter complicate portability of this low-level code.
17//===----------------------------------------------------------------------===//
18#ifndef SANITIZER_LIBC_H
19#define SANITIZER_LIBC_H
20
21#include "sanitizer_defs.h"
22
23// No code here yet. Will move more code in the next changes.
24namespace __sanitizer {
25
26void MiniLibcStub();
27
28// internal_X() is a custom implementation of X() for use in RTL.
29
30// String functions
31void *internal_memchr(const void *s, int c, uptr n);
32int internal_strcmp(const char *s1, const char *s2);
33char *internal_strncpy(char *dst, const char *src, uptr n);
34
35// Memory
36void *internal_mmap(void *addr, uptr length, int prot, int flags,
37                    int fd, u64 offset);
38int internal_munmap(void *addr, uptr length);
39
40// I/O
41typedef int fd_t;
42const fd_t kInvalidFd = -1;
43int internal_close(fd_t fd);
44fd_t internal_open(const char *filename, bool write);
45uptr internal_read(fd_t fd, void *buf, uptr count);
46uptr internal_write(fd_t fd, const void *buf, uptr count);
47int internal_sscanf(const char *str, const char *format, ...);
48
49}  // namespace __sanitizer
50
51#endif  // SANITIZER_LIBC_H
52