gdb/common/cleanups.h - gdb

Data types defined

Macros defined

Source code

  1. /* Cleanups.
  2.    Copyright (C) 1986-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef CLEANUPS_H
  15. #define CLEANUPS_H

  16. /* Outside of cleanups.c, this is an opaque type.  */
  17. struct cleanup;

  18. /* NOTE: cagney/2000-03-04: This typedef is strictly for the
  19.    make_cleanup function declarations below.  Do not use this typedef
  20.    as a cast when passing functions into the make_cleanup() code.
  21.    Instead either use a bounce function or add a wrapper function.
  22.    Calling a f(char*) function with f(void*) is non-portable.  */
  23. typedef void (make_cleanup_ftype) (void *);

  24. /* Function type for the dtor in make_cleanup_dtor.  */
  25. typedef void (make_cleanup_dtor_ftype) (void *);

  26. /* WARNING: The result of the "make cleanup" routines is not the intuitive
  27.    choice of being a handle on the just-created cleanup.  Instead it is an
  28.    opaque handle of the cleanup mechanism and represents all cleanups created
  29.    from that point onwards.
  30.    The result is guaranteed to be non-NULL though.  */

  31. extern struct cleanup *make_cleanup (make_cleanup_ftype *, void *);

  32. extern struct cleanup *make_cleanup_dtor (make_cleanup_ftype *, void *,
  33.                                           make_cleanup_dtor_ftype *);

  34. extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);

  35. /* A special value to pass to do_cleanups and do_final_cleanups
  36.    to tell them to do all cleanups.  */
  37. extern struct cleanup *all_cleanups (void);

  38. extern void do_cleanups (struct cleanup *);
  39. extern void do_final_cleanups (struct cleanup *);

  40. extern void discard_cleanups (struct cleanup *);
  41. extern void discard_final_cleanups (struct cleanup *);

  42. extern struct cleanup *save_cleanups (void);
  43. extern struct cleanup *save_final_cleanups (void);

  44. extern void restore_cleanups (struct cleanup *);
  45. extern void restore_final_cleanups (struct cleanup *);

  46. /* A no-op cleanup.
  47.    This is useful when you want to establish a known reference point
  48.    to pass to do_cleanups.  */
  49. extern void null_cleanup (void *);

  50. #endif /* CLEANUPS_H */