Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / mcas / ptst.h
blobc569844247c97217b3aabfab065b46e205b6a595
1 /******************************************************************************
2 * ptst.h
4 * Per-thread state management.
6 * Copyright (c) 2002-2003, K A Fraser
7 Copyright (c) 2003, Keir Fraser All rights reserved.
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution. Neither the name of the Keir Fraser
19 * nor the names of its contributors may be used to endorse or
20 * promote products derived from this software without specific
21 * prior written permission.
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef __PTST_H__
37 #define __PTST_H__
39 typedef struct ptst_st ptst_t;
41 #include "gc.h"
42 #include "random.h"
44 struct ptst_st
46 /* Thread id */
47 unsigned int id;
49 /* State management */
50 ptst_t *next;
51 unsigned int count;
52 /* Utility structures */
53 gc_t *gc;
54 rand_t rand;
57 extern pthread_key_t ptst_key;
60 * Enter/leave a critical region. A thread gets a state handle for
61 * use during critical regions.
63 ptst_t *critical_enter(void);
64 #define critical_exit(_p) gc_exit(_p)
66 /* Iterators */
67 extern ptst_t *ptst_list;
68 #define ptst_first() (ptst_list)
69 #define ptst_next(_p) ((_p)->next)
71 /* Called once at start-of-day for entire application. */
72 void _init_ptst_subsystem(void);
74 #endif /* __PTST_H__ */