xref: /dflybsd-src/contrib/gdb-7/gdb/cleanups.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1*ef5ccd6cSJohn Marino /* Cleanups.
2*ef5ccd6cSJohn Marino    Copyright (C) 1986-2013 Free Software Foundation, Inc.
3*ef5ccd6cSJohn Marino 
4*ef5ccd6cSJohn Marino    This file is part of GDB.
5*ef5ccd6cSJohn Marino 
6*ef5ccd6cSJohn Marino    This program is free software; you can redistribute it and/or modify
7*ef5ccd6cSJohn Marino    it under the terms of the GNU General Public License as published by
8*ef5ccd6cSJohn Marino    the Free Software Foundation; either version 3 of the License, or
9*ef5ccd6cSJohn Marino    (at your option) any later version.
10*ef5ccd6cSJohn Marino 
11*ef5ccd6cSJohn Marino    This program is distributed in the hope that it will be useful,
12*ef5ccd6cSJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*ef5ccd6cSJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*ef5ccd6cSJohn Marino    GNU General Public License for more details.
15*ef5ccd6cSJohn Marino 
16*ef5ccd6cSJohn Marino    You should have received a copy of the GNU General Public License
17*ef5ccd6cSJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18*ef5ccd6cSJohn Marino 
19*ef5ccd6cSJohn Marino #ifndef CLEANUPS_H
20*ef5ccd6cSJohn Marino #define CLEANUPS_H
21*ef5ccd6cSJohn Marino 
22*ef5ccd6cSJohn Marino /* Outside of cleanups.c, this is an opaque type.  */
23*ef5ccd6cSJohn Marino struct cleanup;
24*ef5ccd6cSJohn Marino 
25*ef5ccd6cSJohn Marino /* NOTE: cagney/2000-03-04: This typedef is strictly for the
26*ef5ccd6cSJohn Marino    make_cleanup function declarations below.  Do not use this typedef
27*ef5ccd6cSJohn Marino    as a cast when passing functions into the make_cleanup() code.
28*ef5ccd6cSJohn Marino    Instead either use a bounce function or add a wrapper function.
29*ef5ccd6cSJohn Marino    Calling a f(char*) function with f(void*) is non-portable.  */
30*ef5ccd6cSJohn Marino typedef void (make_cleanup_ftype) (void *);
31*ef5ccd6cSJohn Marino 
32*ef5ccd6cSJohn Marino /* Function type for the dtor in make_cleanup_dtor.  */
33*ef5ccd6cSJohn Marino typedef void (make_cleanup_dtor_ftype) (void *);
34*ef5ccd6cSJohn Marino 
35*ef5ccd6cSJohn Marino /* WARNING: The result of the "make cleanup" routines is not the intuitive
36*ef5ccd6cSJohn Marino    choice of being a handle on the just-created cleanup.  Instead it is an
37*ef5ccd6cSJohn Marino    opaque handle of the cleanup mechanism and represents all cleanups created
38*ef5ccd6cSJohn Marino    from that point onwards.
39*ef5ccd6cSJohn Marino    The result is guaranteed to be non-NULL though.  */
40*ef5ccd6cSJohn Marino 
41*ef5ccd6cSJohn Marino extern struct cleanup *make_cleanup (make_cleanup_ftype *, void *);
42*ef5ccd6cSJohn Marino 
43*ef5ccd6cSJohn Marino extern struct cleanup *make_cleanup_dtor (make_cleanup_ftype *, void *,
44*ef5ccd6cSJohn Marino 					  make_cleanup_dtor_ftype *);
45*ef5ccd6cSJohn Marino 
46*ef5ccd6cSJohn Marino extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
47*ef5ccd6cSJohn Marino 
48*ef5ccd6cSJohn Marino /* A special value to pass to do_cleanups and do_final_cleanups
49*ef5ccd6cSJohn Marino    to tell them to do all cleanups.  */
50*ef5ccd6cSJohn Marino extern struct cleanup *all_cleanups (void);
51*ef5ccd6cSJohn Marino 
52*ef5ccd6cSJohn Marino extern void do_cleanups (struct cleanup *);
53*ef5ccd6cSJohn Marino extern void do_final_cleanups (struct cleanup *);
54*ef5ccd6cSJohn Marino 
55*ef5ccd6cSJohn Marino extern void discard_cleanups (struct cleanup *);
56*ef5ccd6cSJohn Marino extern void discard_final_cleanups (struct cleanup *);
57*ef5ccd6cSJohn Marino 
58*ef5ccd6cSJohn Marino extern struct cleanup *save_cleanups (void);
59*ef5ccd6cSJohn Marino extern struct cleanup *save_final_cleanups (void);
60*ef5ccd6cSJohn Marino 
61*ef5ccd6cSJohn Marino extern void restore_cleanups (struct cleanup *);
62*ef5ccd6cSJohn Marino extern void restore_final_cleanups (struct cleanup *);
63*ef5ccd6cSJohn Marino 
64*ef5ccd6cSJohn Marino /* A no-op cleanup.
65*ef5ccd6cSJohn Marino    This is useful when you want to establish a known reference point
66*ef5ccd6cSJohn Marino    to pass to do_cleanups.  */
67*ef5ccd6cSJohn Marino extern void null_cleanup (void *);
68*ef5ccd6cSJohn Marino 
69*ef5ccd6cSJohn Marino #endif /* CLEANUPS_H */
70