~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
/* Prototypes when using thr_alarm library functions */
17
18
#ifndef _thr_alarm_h
19
#define _thr_alarm_h
632.1.11 by Monty Taylor
Fixed Sun Studio warnings in mysys.
20
21
#include <signal.h>
22
1 by brian
clean slate
23
#ifdef	__cplusplus
24
extern "C" {
25
#endif
26
27
#ifndef USE_ALARM_THREAD
28
#define USE_ONE_SIGNAL_HAND		/* One must call process_alarm */
29
#endif
30
#ifdef HAVE_rts_threads
31
#undef USE_ONE_SIGNAL_HAND
32
#define USE_ALARM_THREAD
33
#define THR_SERVER_ALARM SIGUSR1
34
#else
35
#define THR_SERVER_ALARM SIGALRM
36
#endif
37
38
typedef struct st_alarm_info
39
{
298 by Brian Aker
ulong conversion.
40
  uint32_t next_alarm_time;
482 by Brian Aker
Remove uint.
41
  uint32_t active_alarms;
42
  uint32_t max_used_alarms;
1 by brian
clean slate
43
} ALARM_INFO;
44
45
void thr_alarm_info(ALARM_INFO *info);
46
28.1.35 by Monty Taylor
Removed all references to THREAD.
47
#if defined(DONT_USE_THR_ALARM)
1 by brian
clean slate
48
49
#define USE_ALARM_THREAD
50
#undef USE_ONE_SIGNAL_HAND
51
146 by Brian Aker
my_bool cleanup.
52
typedef bool thr_alarm_t;
53
typedef bool ALARM;
1 by brian
clean slate
54
55
#define thr_alarm_init(A) (*(A))=0
56
#define thr_alarm_in_use(A) (*(A) != 0)
57
#define thr_end_alarm(A)
58
#define thr_alarm(A,B,C) ((*(A)=1)-1)
59
/* The following should maybe be (*(A)) */
60
#define thr_got_alarm(A) 0
61
#define init_thr_alarm(A)
62
#define thr_alarm_kill(A)
63
#define resize_thr_alarm(N)
64
#define end_thr_alarm(A)
65
66
#else
67
68
typedef int thr_alarm_entry;
69
#define thr_got_alarm(thr_alarm) (**(thr_alarm))
70
71
typedef thr_alarm_entry* thr_alarm_t;
72
73
typedef struct st_alarm {
298 by Brian Aker
ulong conversion.
74
  uint32_t expire_time;
1 by brian
clean slate
75
  thr_alarm_entry alarmed;		/* set when alarm is due */
76
  pthread_t thread;
77
  my_thread_id thread_id;
146 by Brian Aker
my_bool cleanup.
78
  bool malloced;
1 by brian
clean slate
79
} ALARM;
80
482 by Brian Aker
Remove uint.
81
extern uint32_t thr_client_alarm;
1 by brian
clean slate
82
extern pthread_t alarm_thread;
83
632.1.11 by Monty Taylor
Fixed Sun Studio warnings in mysys.
84
int compare_uint32_t(void *unused, unsigned char *a_ptr,unsigned char* b_ptr);
85
RETSIGTYPE thread_alarm(int sig);
86
1 by brian
clean slate
87
#define thr_alarm_init(A) (*(A))=0
88
#define thr_alarm_in_use(A) (*(A)!= 0)
482 by Brian Aker
Remove uint.
89
void init_thr_alarm(uint32_t max_alarm);
90
void resize_thr_alarm(uint32_t max_alarms);
91
bool thr_alarm(thr_alarm_t *alarmed, uint32_t sec, ALARM *buff);
1 by brian
clean slate
92
void thr_alarm_kill(my_thread_id thread_id);
93
void thr_end_alarm(thr_alarm_t *alarmed);
146 by Brian Aker
my_bool cleanup.
94
void end_thr_alarm(bool free_structures);
454 by Monty Taylor
Removed RETSIGHANDLER to sig_handler define.
95
RETSIGTYPE process_alarm(int);
1 by brian
clean slate
96
#ifndef thr_got_alarm
146 by Brian Aker
my_bool cleanup.
97
bool thr_got_alarm(thr_alarm_t *alrm);
1 by brian
clean slate
98
#endif
99
100
101
#endif /* DONT_USE_THR_ALARM */
102
103
#ifdef	__cplusplus
104
}
105
#endif /* __cplusplus */
106
#endif /* _thr_alarm_h */