1
|
1 // unwind-prot.h -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_unwind_prot_h) |
|
25 #define octave_unwind_prot_h 1 |
1
|
26 |
1297
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
529
|
31 #include <stddef.h> |
|
32 |
1
|
33 typedef void (*cleanup_func)(void *ptr); |
|
34 |
|
35 void add_unwind_protect (cleanup_func fptr, void *ptr); |
|
36 void run_unwind_protect (void); |
|
37 void discard_unwind_protect (void); |
|
38 void begin_unwind_frame (char *tag); |
|
39 void run_unwind_frame (char *tag); |
|
40 void discard_unwind_frame (char *tag); |
|
41 void run_all_unwind_protects (void); |
|
42 void discard_all_unwind_protects (void); |
|
43 |
|
44 void matrix_cleanup (void *m); |
|
45 void complex_matrix_cleanup (void *cm); |
|
46 |
|
47 void unwind_protect_int_internal (int *ptr, int value); |
|
48 void unwind_protect_ptr_internal (void **ptr, void *value); |
|
49 void unwind_protect_var_internal (void *ptr, void *value, size_t size); |
|
50 |
|
51 #define unwind_protect_int(i) \ |
|
52 unwind_protect_int_internal (&(i), (i)) |
|
53 |
|
54 #define unwind_protect_ptr(p) \ |
|
55 unwind_protect_ptr_internal ((void **) &(p), (void *) (p)) |
|
56 |
|
57 #define unwind_protect_var(i) \ |
|
58 unwind_protect_var_internal ((void *) &(i), (void *) &(i), sizeof (int)) |
|
59 |
453
|
60 class |
|
61 unwind_elem |
240
|
62 { |
|
63 public: |
|
64 unwind_elem (void); |
|
65 unwind_elem (char *t); |
|
66 unwind_elem (cleanup_func f, void *p); |
|
67 unwind_elem (const unwind_elem& el); |
|
68 ~unwind_elem (void); |
|
69 |
|
70 unwind_elem& operator = (const unwind_elem& el); |
|
71 |
|
72 char *tag (void); |
|
73 cleanup_func fptr (void); |
|
74 void *ptr (void); |
|
75 |
|
76 private: |
453
|
77 char *unwind_elem_tag; |
|
78 cleanup_func unwind_elem_fptr; |
|
79 void *unwind_elem_ptr; |
240
|
80 }; |
|
81 |
1
|
82 #endif |
|
83 |
|
84 /* |
|
85 ;;; Local Variables: *** |
|
86 ;;; mode: C++ *** |
|
87 ;;; page-delimiter: "^/\\*" *** |
|
88 ;;; End: *** |
|
89 */ |