~akuzminsky/percona-data-recovery-tool-for-innodb/file_per_index

« back to all changes in this revision

Viewing changes to mysql-source/include/my_alarm.h

  • Committer: Aleksandr Kuzminsky
  • Date: 2010-12-10 09:09:58 UTC
  • Revision ID: aleksandr.kuzminsky@percona.com-20101210090958-01q3nmav530g5h2p
a fork from the trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/*
 
17
  File to include when we want to use alarm or a loop_counter to display
 
18
  some information when a program is running
 
19
*/
 
20
#ifndef _my_alarm_h
 
21
#define _my_alarm_h
 
22
#ifdef  __cplusplus
 
23
extern "C" {
 
24
#endif
 
25
 
 
26
extern int volatile my_have_got_alarm;
 
27
extern ulong my_time_to_wait_for_lock;
 
28
 
 
29
#if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP)
 
30
#include <signal.h>
 
31
#define ALARM_VARIABLES uint alarm_old=0; \
 
32
                        sig_return alarm_signal=0
 
33
#define ALARM_INIT      my_have_got_alarm=0 ; \
 
34
                        alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
 
35
                        alarm_signal=signal(SIGALRM,my_set_alarm_variable);
 
36
#define ALARM_END       VOID(signal(SIGALRM,alarm_signal)); \
 
37
                        VOID(alarm(alarm_old));
 
38
#define ALARM_TEST      my_have_got_alarm
 
39
#ifdef DONT_REMEMBER_SIGNAL
 
40
#define ALARM_REINIT    VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \
 
41
                        VOID(signal(SIGALRM,my_set_alarm_variable));\
 
42
                        my_have_got_alarm=0;
 
43
#else
 
44
#define ALARM_REINIT    VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \
 
45
                        my_have_got_alarm=0;
 
46
#endif /* DONT_REMEMBER_SIGNAL */
 
47
#else
 
48
#define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1
 
49
#define ALARM_INIT
 
50
#define ALARM_END
 
51
#define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
 
52
#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
 
53
#endif /* HAVE_ALARM */
 
54
 
 
55
#ifdef  __cplusplus
 
56
}
 
57
#endif
 
58
#endif