source: BAORadio/libindi/libindi/drivers/telescope/exception.h @ 620

Last change on this file since 620 was 620, checked in by frichard, 13 years ago
File size: 851 bytes
Line 
1/* exception.h */
2#include <stdio.h>
3#include <stdlib.h>
4#include <setjmp.h>
5
6#ifndef __EXCEPTION__
7#define __EXCEPTION__  1
8
9/* exceptions de base */
10
11#define ERR_MALLOC     10
12#define NULL_POINTEUR  11
13#define ERR_FOPEN      12
14
15/*prototypes*/
16
17/* definition des structures de donnees de gestion de la pile des contextes
18   et des macros TRY, CATCH, et ENDTRY */
19
20
21/* liste chainee des contextes */
22typedef struct except_ctx
23{
24  jmp_buf ctx;
25  struct except_ctx* super;
26} except;
27extern except* _exceptions;
28
29/* les macros */
30#define TRY { \
31  int exc; \
32  push_exc(); \
33  exc = setjmp(_exceptions->ctx); \
34  switch(exc){ \
35  case 0:
36
37#define CATCH(X) \
38  break; \
39  case(X): \
40  exc = 0;
41
42#define ENDTRY \
43  break; \
44  default: \
45  pop_exc(exc); }\
46  }
47
48#define THROW(X) longjmp(_exceptions->ctx, X)
49
50
51void push_exc();
52void pop_exc(int);
53
54#endif
Note: See TracBrowser for help on using the repository browser.