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