remove extra mkfs.1
[minix.git] / sys / ufs / chfs / ebh_misc.h
blob75b09ae140e45d042f8ceb2091d8a68832312c84
1 /* $NetBSD: ebh_misc.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
3 /*-
4 * Copyright (c) 2010 Department of Software Engineering,
5 * University of Szeged, Hungary
6 * All rights reserved.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by the Department of Software Engineering, University of Szeged, Hungary
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
33 #ifndef EBH_MISC_H_
34 #define EBH_MISC_H_
36 /******************************************************************************/
37 /* EBH specific functions */
38 /******************************************************************************/
40 #define CHFS_GET_MEMBER_POS(type, member) \
41 ((unsigned long)(&((type *)0)->member))
43 #define CHFS_GET_LID(lid) (le32toh(lid) & CHFS_LID_DIRTY_BIT_MASK)
45 /**
46 * EBH_TREE_DESTROY - destroys an RB-tree and frees the memory of its elements.
47 * @name - the RB-tree structure's name
48 * @head - pointer to the RB-tree's head
49 * @type - type of the elements
51 #define EBH_TREE_DESTROY(name, head, type) \
52 { \
53 type *var, *nxt; \
54 for (var = RB_MIN(name, head); var != NULL; var = nxt) { \
55 nxt = RB_NEXT(name, head, var); \
56 RB_REMOVE(name, head, var); \
57 kmem_free(var, sizeof(type)); \
58 } \
61 /* XXX HACK! we need a clean solution for destroying mutexes in trees */
62 #define EBH_TREE_DESTROY_MUTEX(name, head, type) \
63 { \
64 type *var, *nxt; \
65 for (var = RB_MIN(name, head); var != NULL; var = nxt) { \
66 nxt = RB_NEXT(name, head, var); \
67 RB_REMOVE(name, head, var); \
68 rw_destroy(&var->mutex); \
69 kmem_free(var, sizeof(type)); \
70 } \
73 /**
74 * EBH_QUEUE_DESTROY - destroys a TAILQ and frees the memory of its elements.
75 * @head: pointer to the head of the queue
76 * @type: type of the elements
77 * @entry: name of TAILQ_ENTRY
79 #define EBH_QUEUE_DESTROY(head, type, entry) \
80 { \
81 type *var; \
82 while ((var = TAILQ_FIRST(head))) { \
83 TAILQ_REMOVE(head, var, entry); \
84 kmem_free(var, sizeof(type)); \
85 } \
88 #endif /* EBH_MISC_H_ */