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

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 15:35:33 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL289495: [libFuzzer] Implement Timers for Windows. (authored by mpividori).

Changed prior to commit:
  https://reviews.llvm.org/D27237?vs=79670&id=81156#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27237

Files:
  llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp


Index: llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp
===================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerUtilWindows.cpp
+++ llvm/trunk/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.81156.patch
Type: text/x-patch
Size: 1083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161212/e11db36c/attachment.bin>


More information about the llvm-commits mailing list