my_alarm.h
上传用户:jmzj888
上传日期:2007-01-02
资源大小:220k
文件大小:1k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
  2.    This file is public domain and comes with NO WARRANTY of any kind */
  3. /*
  4.   File to include when we want to use alarm or a loop_counter to display
  5.   some information when a program is running
  6. */
  7. #ifndef _my_alarm_h
  8. #define _my_alarm_h
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. extern int volatile my_have_got_alarm;
  13. extern ulong my_time_to_wait_for_lock;
  14. #if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP)
  15. #include <signal.h>
  16. #define ALARM_VARIABLES uint alarm_old=0; 
  17. sig_return alarm_signal=0
  18. #define ALARM_INIT my_have_got_alarm=0 ; 
  19. alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); 
  20. alarm_signal=signal(SIGALRM,my_set_alarm_variable);
  21. #define ALARM_END VOID(signal(SIGALRM,alarm_signal)); 
  22. VOID(alarm(alarm_old));
  23. #define ALARM_TEST my_have_got_alarm
  24. #ifdef DONT_REMEMBER_SIGNAL
  25. #define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); 
  26. VOID(signal(SIGALRM,my_set_alarm_variable));
  27. my_have_got_alarm=0;
  28. #else
  29. #define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); 
  30. my_have_got_alarm=0;
  31. #endif /* DONT_REMEMBER_SIGNAL */
  32. #else
  33. #define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1
  34. #define ALARM_INIT
  35. #define ALARM_END
  36. #define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
  37. #define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
  38. #endif /* HAVE_ALARM */
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif