[llvm] r289495 - [libFuzzer] Implement Timers for Windows.
Marcos Pividori via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 15:25:11 PST 2016
Author: mpividori
Date: Mon Dec 12 17:25:11 2016
New Revision: 289495
URL: http://llvm.org/viewvc/llvm-project?rev=289495&view=rev
Log:
[libFuzzer] Implement Timers for Windows.
Implemented timeouts for Windows using TimerQueueTimers.
Timers are used to supervise the time of execution of the
callback function that is being fuzzed.
Differential Revision: https://reviews.llvm.org/D27237
Modified:
llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp?rev=289495&r1=289494&r2=289495&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp Mon Dec 12 17:25:11 2016
@@ -95,8 +95,39 @@ BOOL WINAPI TERMHandler(DWORD dwCtrlType
}
}
+void CALLBACK AlarmHandler(PVOID, BOOLEAN) {
+ Fuzzer::StaticAlarmCallback();
+}
+
+class TimerQ {
+ HANDLE TimerQueue;
+ public:
+ TimerQ() : TimerQueue(NULL) {};
+ ~TimerQ() {
+ if (TimerQueue)
+ DeleteTimerQueueEx(TimerQueue, NULL);
+ };
+ void SetTimer(int Seconds) {
+ if (!TimerQueue) {
+ TimerQueue = CreateTimerQueue();
+ if (!TimerQueue) {
+ Printf("libFuzzer: CreateTimerQueue failed.\n");
+ exit(1);
+ }
+ }
+ HANDLE Timer;
+ if (!CreateTimerQueueTimer(&Timer, TimerQueue, AlarmHandler, NULL,
+ Seconds*1000, Seconds*1000, 0)) {
+ Printf("libFuzzer: CreateTimerQueueTimer failed.\n");
+ exit(1);
+ }
+ };
+};
+
+static TimerQ Timer;
+
void SetTimer(int Seconds) {
- // TODO: Complete this implementation.
+ Timer.SetTimer(Seconds);
return;
}
More information about the llvm-commits
mailing list