~maria-captains/mariadb-native-client/trunk

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