forked from OSchip/llvm-project
[Sanitizer] Add sanitizer_win.cc for windows-specific implementations of libc functions. Add internal_open.
llvm-svn: 157985
This commit is contained in:
parent
11fff6df33
commit
dde1f11fe6
|
@ -29,10 +29,11 @@ void MiniLibcStub();
|
|||
int internal_strcmp(const char *s1, const char *s2);
|
||||
char *internal_strncpy(char *dst, const char *src, uptr n);
|
||||
|
||||
#ifndef _WIN32
|
||||
void *internal_mmap(void *addr, uptr length, int prot, int flags,
|
||||
int fd, u64 offset);
|
||||
#endif // _WIN32
|
||||
|
||||
typedef int fd_t;
|
||||
fd_t internal_open(const char *filename, bool write);
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
#include "sanitizer_defs.h"
|
||||
#include "sanitizer_libc.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
@ -32,6 +34,11 @@ void *internal_mmap(void *addr, uptr length, int prot, int flags,
|
|||
#endif
|
||||
}
|
||||
|
||||
fd_t internal_open(const char *filename, bool write) {
|
||||
return syscall(__NR_open, filename,
|
||||
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660);
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // __linux__
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include "sanitizer_libc.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
|
@ -26,6 +29,11 @@ void *internal_mmap(void *addr, size_t length, int prot, int flags,
|
|||
return mmap(addr, length, prot, flags, fd, offset);
|
||||
}
|
||||
|
||||
fd_t internal_open(const char *filename, bool write) {
|
||||
return open(filename,
|
||||
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660);
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // __APPLE__
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
//===-- sanitizer_win.cc ------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file is shared between AddressSanitizer and ThreadSanitizer
|
||||
// run-time libraries and implements windows-specific functions from
|
||||
// sanitizer_libc.h.
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "sanitizer_defs.h"
|
||||
#include "sanitizer_libc.h"
|
||||
|
||||
#define UNIMPLEMENTED_WIN() assert(false)
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
void *internal_mmap(void *addr, uptr length, int prot, int flags,
|
||||
int fd, u64 offset) {
|
||||
UNIMPLEMENTED_WIN();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fd_t internal_open(const char *filename, bool write) {
|
||||
UNIMPLEMENTED_WIN();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // _WIN32
|
Loading…
Reference in New Issue