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