-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler-rt] using more precise type for the Linux's timerfd api int… #77197
Open
devnexen
wants to merge
1
commit into
llvm:main
Choose a base branch
from
devnexen:sanitizer_precise_timerspec_linux
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-compiler-rt-sanitizer Author: David CARLIER (devnexen) Changes…erception. Full diff: https://github.com/llvm/llvm-project/pull/77197.diff 3 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 77fa1b4965a7a4..a40a771bc301bd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -6376,8 +6376,8 @@ INTERCEPTOR(char *, getpass, const char *prompt) {
#endif
#if SANITIZER_INTERCEPT_TIMERFD
-INTERCEPTOR(int, timerfd_settime, int fd, int flags, void *new_value,
- void *old_value) {
+INTERCEPTOR(int, timerfd_settime, int fd, int flags, __sanitizer_itimerspec *new_value,
+ __sanitizer_itimerspec *old_value) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, timerfd_settime, fd, flags, new_value,
old_value);
@@ -6388,7 +6388,7 @@ INTERCEPTOR(int, timerfd_settime, int fd, int flags, void *new_value,
return res;
}
-INTERCEPTOR(int, timerfd_gettime, int fd, void *curr_value) {
+INTERCEPTOR(int, timerfd_gettime, int fd, __sanitizer_itimerspec *curr_value) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, timerfd_gettime, fd, curr_value);
int res = REAL(timerfd_gettime)(fd, curr_value);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
index bf0f355847cb13..189bbfe7283d3d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
@@ -53,6 +53,7 @@
# if !SANITIZER_ANDROID
# include <sys/statfs.h>
# include <linux/perf_event.h>
+# include <linux/time.h>
# endif
using namespace __sanitizer;
@@ -81,6 +82,8 @@ COMPILER_CHECK(sizeof(struct __sanitizer_perf_event_attr) <=
sizeof(struct perf_event_attr));
CHECK_SIZE_AND_OFFSET(perf_event_attr, type);
CHECK_SIZE_AND_OFFSET(perf_event_attr, size);
+COMPILER_CHECK(sizeof(struct __sanitizer_itimerspec) ==
+ sizeof(struct itimerspec));
#endif
COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 34bfef1f7ef456..d0679b8ede5174 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -406,6 +406,18 @@ struct __sanitizer_timeb {
short dstflag;
};
+#if SANITIZER_LINUX && !SANITIZER_ANDROID
+struct __sanitizer_timespec {
+ __sanitizer_time_t tv_sec;
+ long tv_nsec;
+};
+
+struct __sanitizer_itimerspec {
+ struct __sanitizer_timespec it_interval;
+ struct __sanitizer_timespec it_value;
+};
+#endif
+
struct __sanitizer_ether_addr {
u8 octet[6];
};
|
You can test this locally with the following command:git-clang-format --diff 3fb0d8dc808cb7f315670d76109edc9c57cb3d90 6598044906c6c47691dc378b5412ed6d6b99dc14 -- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h View the diff from clang-format here.diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index a40a771bc3..5544fb9aeb 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -6376,7 +6376,8 @@ INTERCEPTOR(char *, getpass, const char *prompt) {
#endif
#if SANITIZER_INTERCEPT_TIMERFD
-INTERCEPTOR(int, timerfd_settime, int fd, int flags, __sanitizer_itimerspec *new_value,
+INTERCEPTOR(int, timerfd_settime, int fd, int flags,
+ __sanitizer_itimerspec *new_value,
__sanitizer_itimerspec *old_value) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, timerfd_settime, fd, flags, new_value,
@@ -6396,9 +6397,9 @@ INTERCEPTOR(int, timerfd_gettime, int fd, __sanitizer_itimerspec *curr_value) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, curr_value, struct_itimerspec_sz);
return res;
}
-#define INIT_TIMERFD \
- COMMON_INTERCEPT_FUNCTION(timerfd_settime); \
- COMMON_INTERCEPT_FUNCTION(timerfd_gettime);
+# define INIT_TIMERFD \
+ COMMON_INTERCEPT_FUNCTION(timerfd_settime); \
+ COMMON_INTERCEPT_FUNCTION(timerfd_gettime);
#else
#define INIT_TIMERFD
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
index 189bbfe728..a9c3356f40 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
@@ -51,9 +51,9 @@
# include <linux/aio_abi.h>
# if !SANITIZER_ANDROID
-# include <sys/statfs.h>
# include <linux/perf_event.h>
# include <linux/time.h>
+# include <sys/statfs.h>
# endif
using namespace __sanitizer;
@@ -84,7 +84,7 @@ CHECK_SIZE_AND_OFFSET(perf_event_attr, type);
CHECK_SIZE_AND_OFFSET(perf_event_attr, size);
COMPILER_CHECK(sizeof(struct __sanitizer_itimerspec) ==
sizeof(struct itimerspec));
-#endif
+# endif
COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index d0679b8ede..473ee19dd8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -406,7 +406,7 @@ struct __sanitizer_timeb {
short dstflag;
};
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+# if SANITIZER_LINUX && !SANITIZER_ANDROID
struct __sanitizer_timespec {
__sanitizer_time_t tv_sec;
long tv_nsec;
@@ -416,7 +416,7 @@ struct __sanitizer_itimerspec {
struct __sanitizer_timespec it_interval;
struct __sanitizer_timespec it_value;
};
-#endif
+# endif
struct __sanitizer_ether_addr {
u8 octet[6];
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…erception.