Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / src / dbinc / db_dispatch.h
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 1996, 2012 Oracle and/or its affiliates.  All rights reserved.
5  */
6 /*
7  * Copyright (c) 1995, 1996
8  *      The President and Fellows of Harvard University.  All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $Id$
35  */
36
37 #ifndef _DB_DISPATCH_H_
38 #define _DB_DISPATCH_H_
39
40 #if defined(__cplusplus)
41 extern "C" {
42 #endif
43
44 /*
45  * Declarations and typedefs for the list of transaction IDs used during
46  * recovery.  This is a generic list used to pass along whatever information
47  * we need during recovery.
48  */
49 typedef enum {
50         TXNLIST_DELETE,
51         TXNLIST_LSN,
52         TXNLIST_TXNID
53 } db_txnlist_type;
54
55 #define DB_TXNLIST_MASK(hp, n)  (n % hp->nslots)
56 struct __db_txnhead {
57         void *td;               /* If abort, the detail for the txn. */
58         DB_THREAD_INFO *thread_info;    /* Thread information. */
59         u_int32_t maxid;        /* Maximum transaction id. */
60         DB_LSN maxlsn;          /* Maximum commit lsn. */
61         DB_LSN ckplsn;          /* LSN of last retained checkpoint. */
62         DB_LSN trunc_lsn;       /* Lsn to which we are going to truncate;
63                                  * make sure we abort anyone after this. */
64         u_int32_t generation;   /* Current generation number. */
65         u_int32_t gen_alloc;    /* Number of generations allocated. */
66         struct {
67                 u_int32_t generation;
68                 u_int32_t txn_min;
69                 u_int32_t txn_max;
70         } *gen_array;           /* Array of txnids associated with a gen. */
71         u_int nslots;
72         LIST_HEAD(__db_headlink, __db_txnlist) head[1];
73 };
74
75 #define DB_LSN_STACK_SIZE 4
76 struct __db_txnlist {
77         db_txnlist_type type;
78         LIST_ENTRY(__db_txnlist) links;
79         union {
80                 struct {
81                         u_int32_t txnid;
82                         u_int32_t generation;
83                         u_int32_t status;
84                 } t;
85                 struct {
86                         u_int32_t stack_size;
87                         u_int32_t stack_indx;
88                         DB_LSN *lsn_stack;
89                 } l;
90         } u;
91 };
92
93 #if defined(__cplusplus)
94 }
95 #endif
96
97 #endif /* !_DB_DISPATCH_H_ */