linux-rework-signal-blocking-for-afsdb-handler-and-clean-up-osi-invisible-before...
[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 extern struct axscache *axs_Alloc(), *afs_SlowFindAxs();
35 extern void afs_RemoveAxs(), afs_FreeAllAxs();
36 extern afs_rwlock_t afs_xaxs;
37
38 /* DON'T use this with a NULL pointer! 
39  * the quick check should cover 99.9% of the cases 
40  */
41 #define afs_FindAxs(cachep,id) (((cachep)->uid == id) ? cachep : afs_SlowFindAxs(&(cachep),id))
42
43 #define axs_Front(head,pp,p) {(pp)->next = (p)->next; (p)->next= *(head);*(head)=(p);}
44
45 #define afs_AddAxs(cachep,id,bits) {   \
46  struct axscache *ac;                  \
47  if (ac = axs_Alloc()) {               \
48  ac->uid = id;                         \
49  ac->axess = (afs_int32)bits;               \
50  ac->next = cachep;                    \
51  cachep = ac; }}
52
53 #endif
54