rename-residency-from-mrafs-to-osd-20090119
[openafs.git] / src / afs / afs_axscache.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef AFSAXCACHEH
11 #define AFSAXCACHEH
12
13 /*  Access cache -
14  *  The way to use this package is:
15  *  If the cache pointer is not NULL, call afs_findAxs, and if it's not 
16  *                                    NULL, use its access field
17  *  Otherwise, 
18  *       axs_Alloc a new one,
19  *       fill it in,
20  *       insert it at the head of the list.
21  *
22  *  Of course, don't forget to axs_Free them occasionally, 
23  *
24  *  Alloc and Free need a lock on the freelist, the other guys are safe if the
25  *  parent structure is locked, but probably REQUIRE the parent to be locked...
26  */
27
28 struct axscache {
29     afs_int32 uid;              /* most frequently used field, I think */
30     afs_int32 axess;
31     struct axscache *next;
32 };
33
34 /* DON'T use this with a NULL pointer! 
35  * the quick check should cover 99.9% of the cases 
36  */
37 #define afs_FindAxs(cachep,id) (((cachep)->uid == id) ? (cachep) : afs_SlowFindAxs(&(cachep),(id)))
38
39 #define axs_Front(head,pp,p) {(pp)->next = (p)->next; (p)->next= *(head);*(head)=(p);}
40
41 #define afs_AddAxs(cachep,id,bits) {   \
42  struct axscache *ac;                  \
43  if ((ac = axs_Alloc())) {               \
44  ac->uid = (id);                         \
45  ac->axess = (afs_int32)(bits);               \
46  ac->next = (cachep);                    \
47  cachep = ac; }}
48
49 #endif