1
|
1 // unwind-prot.h -*- C++ -*- |
|
2 /* |
|
3 |
383
|
4 Copyright (C) 1992, 1993, 1994 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 |
529
|
27 #include <stddef.h> |
|
28 |
1
|
29 typedef void (*cleanup_func)(void *ptr); |
|
30 |
|
31 void add_unwind_protect (cleanup_func fptr, void *ptr); |
|
32 void run_unwind_protect (void); |
|
33 void discard_unwind_protect (void); |
|
34 void begin_unwind_frame (char *tag); |
|
35 void run_unwind_frame (char *tag); |
|
36 void discard_unwind_frame (char *tag); |
|
37 void run_all_unwind_protects (void); |
|
38 void discard_all_unwind_protects (void); |
|
39 |
|
40 void matrix_cleanup (void *m); |
|
41 void complex_matrix_cleanup (void *cm); |
|
42 |
|
43 void unwind_protect_int_internal (int *ptr, int value); |
|
44 void unwind_protect_ptr_internal (void **ptr, void *value); |
|
45 void unwind_protect_var_internal (void *ptr, void *value, size_t size); |
|
46 |
|
47 #define unwind_protect_int(i) \ |
|
48 unwind_protect_int_internal (&(i), (i)) |
|
49 |
|
50 #define unwind_protect_ptr(p) \ |
|
51 unwind_protect_ptr_internal ((void **) &(p), (void *) (p)) |
|
52 |
|
53 #define unwind_protect_var(i) \ |
|
54 unwind_protect_var_internal ((void *) &(i), (void *) &(i), sizeof (int)) |
|
55 |
453
|
56 class |
|
57 unwind_elem |
240
|
58 { |
|
59 public: |
|
60 unwind_elem (void); |
|
61 unwind_elem (char *t); |
|
62 unwind_elem (cleanup_func f, void *p); |
|
63 unwind_elem (const unwind_elem& el); |
|
64 ~unwind_elem (void); |
|
65 |
|
66 unwind_elem& operator = (const unwind_elem& el); |
|
67 |
|
68 char *tag (void); |
|
69 cleanup_func fptr (void); |
|
70 void *ptr (void); |
|
71 |
|
72 private: |
453
|
73 char *unwind_elem_tag; |
|
74 cleanup_func unwind_elem_fptr; |
|
75 void *unwind_elem_ptr; |
240
|
76 }; |
|
77 |
1
|
78 #endif |
|
79 |
|
80 /* |
|
81 ;;; Local Variables: *** |
|
82 ;;; mode: C++ *** |
|
83 ;;; page-delimiter: "^/\\*" *** |
|
84 ;;; End: *** |
|
85 */ |