Skip to content

Commit 07bb392

Browse files
committed
[sanitizer] replace size_t with SIZE_T in interceptors (same for ssize_t, off_t and off64_t). This is done to avoid confusion and to make the code work with compilers that define size_t w/o any includes (MSVC)
llvm-svn: 170103
1 parent e36abf6 commit 07bb392

File tree

4 files changed

+99
-104
lines changed

4 files changed

+99
-104
lines changed

compiler-rt/lib/asan/asan_intercepted_functions.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,16 @@ DECLARE_FUNCTION_AND_WRAPPER(long long, atoll, const char *nptr); // NOLINT
153153
DECLARE_FUNCTION_AND_WRAPPER(long long, strtoll, const char *nptr, char **endptr, int base); // NOLINT
154154
# endif
155155

156-
// unistd.h
157-
// FIXME: remove these typedefs once we get rid of mach_override.
158-
typedef uptr size_t;
159-
typedef sptr ssize_t;
160-
typedef u64 off_t;
161-
typedef u64 off64_t;
162-
163-
DECLARE_FUNCTION_AND_WRAPPER(ssize_t, read, int fd, void *buf, size_t count);
164-
DECLARE_FUNCTION_AND_WRAPPER(ssize_t, pread, int fd, void *buf,
165-
size_t count, off_t offset);
166-
DECLARE_FUNCTION_AND_WRAPPER(ssize_t, pread64, int fd, void *buf,
167-
size_t count, off64_t offset);
156+
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, read, int fd, void *buf, SIZE_T count);
157+
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread, int fd, void *buf,
158+
SIZE_T count, OFF_T offset);
159+
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread64, int fd, void *buf,
160+
SIZE_T count, OFF64_T offset);
168161

169162
# if ASAN_INTERCEPT_MLOCKX
170163
// mlock/munlock
171-
DECLARE_FUNCTION_AND_WRAPPER(int, mlock, const void *addr, size_t len);
172-
DECLARE_FUNCTION_AND_WRAPPER(int, munlock, const void *addr, size_t len);
164+
DECLARE_FUNCTION_AND_WRAPPER(int, mlock, const void *addr, SIZE_T len);
165+
DECLARE_FUNCTION_AND_WRAPPER(int, munlock, const void *addr, SIZE_T len);
173166
DECLARE_FUNCTION_AND_WRAPPER(int, mlockall, int flags);
174167
DECLARE_FUNCTION_AND_WRAPPER(int, munlockall, void);
175168
# endif

compiler-rt/lib/interception/interception.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
# error "Interception doesn't work on this operating system."
2020
#endif
2121

22+
#include "sanitizer/common_interface_defs.h"
23+
24+
// These typedefs should be used only in the interceptor definitions to replace
25+
// the standard system types (e.g. SSIZE_T instead of ssize_t)
26+
typedef __sanitizer::uptr SIZE_T;
27+
typedef __sanitizer::sptr SSIZE_T;
28+
typedef __sanitizer::u64 OFF_T;
29+
typedef __sanitizer::u64 OFF64_T;
30+
2231
// How to use this library:
2332
// 1) Include this header to define your own interceptors
2433
// (see details below).

0 commit comments

Comments
 (0)