[llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp
Anand Shukla
ashukla at cs.uiuc.edu
Fri Jul 18 17:47:01 PDT 2003
Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Trigger:
Timer.cpp added (r1.1)
---
Log message:
Changed timer.c to timer.cpp
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp
diff -c /dev/null llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp:1.1
*** /dev/null Fri Jul 18 17:46:45 2003
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp Fri Jul 18 17:46:34 2003
***************
*** 0 ****
--- 1,107 ----
+ #include <unistd.h>
+ #include <signal.h>
+ #include <sys/time.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ #define INTERVAL_USEC 000000
+ #define INTERVAL_SEC 10
+
+ extern "C" void do_timer_interval();
+ uint64_t llvm_interval_counter;
+
+ sigset_t sig_usr2;
+ sigset_t sig_old;
+ sigset_t sig_all;
+
+
+
+
+ void mask_interrupt()
+ {
+ //sigprocmask(SIG_BLOCK, &sig_usr2, &sig_old);
+ }
+
+ void unmask_interrupt()
+ {
+ //sigprocmask(SIG_UNBLOCK, &sig_usr2, NULL);
+ }
+
+ void mask_all_interrupt()
+ {
+ //sigprocmask(SIG_BLOCK, &sig_all, &sig_old);
+ }
+
+ void unmask_all_interrupt()
+ {
+ //sigprocmask(SIG_UNBLOCK, &sig_all, NULL);
+ }
+
+ void timer_handler(int i)//int i, siginfo_t* s, void* v)
+ {
+ //mask_all_interrupt();
+ signal(SIGUSR2, SIG_IGN);
+ //printf("---------------------ding\n");
+ llvm_interval_counter++;
+ do_timer_interval();
+ //printf("---------------------dong\n");
+ signal(SIGUSR2, &timer_handler);
+ //unmask_all_interrupt();
+ }
+
+ int initialize_timer()
+ {
+ //printf("Intializing timer\n");
+ int duration_sec=0, duration_msec=0;
+ //struct sigaction *nvec, *ovec;
+ timer_t timer_id;
+ struct sigevent timer_evp;
+ struct itimerspec timer_spec, old_timer_spec;
+
+ memset(&timer_evp, 0, sizeof(timer_evp));
+ timer_evp.sigev_signo = SIGUSR2;
+ timer_evp.sigev_notify = SIGEV_SIGNAL;
+
+ //duration of timer
+ if(getenv("LLVM_TIMER_INTERVAL_SEC")!=NULL)
+ duration_sec = atoi(getenv("LLVM_TIMER_INTERVAL_SEC"));
+ else duration_sec = 3;
+
+ if(getenv("LLVM_TIMER_INTERVAL_MSEC")!=NULL)
+ duration_sec = atoi(getenv("LLVM_TIMER_INTERVAL_MSEC"));
+ else duration_msec = 0;
+
+ if(timer_create(CLOCK_REALTIME, &timer_evp, &timer_id)<0)
+ printf(" error\n");
+
+ //initializing the timer
+ timer_spec.it_value.tv_sec = duration_sec;
+ timer_spec.it_value.tv_nsec = duration_msec;
+
+ //generate voltages at TWICE the input frequency
+ //because lower and higher voltages are shown alternately
+ //convert freq into secs and nanoseconds
+ timer_spec.it_interval.tv_nsec = 0;//1000*1000000;
+ timer_spec.it_interval.tv_sec = 1;
+
+ //set timer
+ timer_settime(timer_id, 0, &timer_spec, &old_timer_spec);
+
+ //nvec = (struct sigaction*)malloc(sizeof(struct sigaction));
+ //ovec = (struct sigaction*)malloc(sizeof(struct sigaction));
+
+ // stuct sigvec nvec = new sigvec;
+ //sigvec ovec = new sigvec;
+ signal(SIGUSR2, &timer_handler);
+ /*
+ nvec->sa_handler = timer_handler;
+
+ sigaction(SIGUSR2, nvec, ovec);
+ sigemptyset(&sig_usr2);
+ sigemptyset(&sig_old);
+ sigfillset(&sig_all);
+ sigaddset(&sig_usr2, SIGUSR2);
+ */
+ return 1;
+ }
More information about the llvm-commits
mailing list