[PATCH] D27237: [libFuzzer] Diff 6 - Implement Timers for Windows.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 16:22:44 PST 2016


mpividori created this revision.
mpividori added a reviewer: zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.

+ Implemented timeouts for Windows using TimerQueueTimers.


Repository:
  rL LLVM

https://reviews.llvm.org/D27237

Files:
  lib/Fuzzer/FuzzerUtilWindows.cpp


Index: lib/Fuzzer/FuzzerUtilWindows.cpp
===================================================================
--- lib/Fuzzer/FuzzerUtilWindows.cpp
+++ lib/Fuzzer/FuzzerUtilWindows.cpp
@@ -95,8 +95,39 @@
   }
 }
 
+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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27237.79670.patch
Type: text/x-patch
Size: 1050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161130/2f971bbe/attachment.bin>


More information about the llvm-commits mailing list