1 /*	$OpenBSD: rf_shutdown.h,v 1.4 2002/12/16 07:01:05 tdeval Exp $	*/
2 /*	$NetBSD: rf_shutdown.h,v 1.2 1999/02/05 00:06:17 oster Exp $	*/
3 
4 /*
5  * rf_shutdown.h
6  */
7 /*
8  * Copyright (c) 1996 Carnegie-Mellon University.
9  * All rights reserved.
10  *
11  * Author: Jim Zelenka
12  *
13  * Permission to use, copy, modify and distribute this software and
14  * its documentation is hereby granted, provided that both the copyright
15  * notice and this permission notice appear in all copies of the
16  * software, derivative works or modified versions, and any portions
17  * thereof, and that both notices appear in supporting documentation.
18  *
19  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
20  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
21  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
22  *
23  * Carnegie Mellon requests users of this software to return to
24  *
25  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
26  *  School of Computer Science
27  *  Carnegie Mellon University
28  *  Pittsburgh PA 15213-3890
29  *
30  * any improvements or extensions that they make and grant Carnegie the
31  * rights to redistribute these changes.
32  */
33 /*
34  * Maintain lists of cleanup functions. Also, mechanisms for coordinating
35  * thread startup and shutdown.
36  */
37 
38 #ifndef	_RF__RF_SHUTDOWN_H_
39 #define	_RF__RF_SHUTDOWN_H_
40 
41 #include "rf_types.h"
42 #include "rf_threadstuff.h"
43 
44 /*
45  * Important note: The shutdown list is run like a stack, new
46  * entries pushed on top. Therefore, the most recently added
47  * entry (last started) is the first removed (stopped). This
48  * should handle system-dependencies pretty nicely- if a system
49  * is there when you start another, it'll be there when you
50  * shut down another. Hopefully, this subsystem will remove
51  * more complexity than it introduces.
52  */
53 
54 struct RF_ShutdownList_s {
55 	void		 (*cleanup) (void *arg);
56 	void		  *arg;
57 	char		  *file;
58 	int		   line;
59 	RF_ShutdownList_t *next;
60 };
61 #define	rf_ShutdownCreate(_listp_,_func_,_arg_)				\
62 	_rf_ShutdownCreate(_listp_, _func_, _arg_, __FILE__, __LINE__)
63 
64 int  _rf_ShutdownCreate(RF_ShutdownList_t **, void (*) (void *arg), void *,
65 	char *, int);
66 int  rf_ShutdownList(RF_ShutdownList_t **);
67 void rf_shutdown_hook(RF_ThreadArg_t);
68 
69 #endif	/* !_RF__RF_SHUTDOWN_H_ */
70