xref: /titanic_52/usr/src/lib/libnisdb/db_vers_c.x (revision b6c3f7863936abeae522e48a13887dddeb691a45)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	db_vers_c.x
24  *
25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 %#pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #if RPC_HDR
32 %#ifndef _DB_VERS_H
33 %#define _DB_VERS_H
34 #endif /* RPC_HDR */
35 
36 %/* 'vers' is the version identifier.  */
37 
38 %
39 %#include "nisdb_rw.h"
40 %
41 #if RPC_HDR || RPC_XDR
42 #ifdef USINGC
43 struct vers {
44 	u_int vers_high;
45 	u_int vers_low;
46 	u_int time_sec;
47 	u_int time_usec;
48 	__nisdb_rwlock_t vers_rwlock;
49 };
50 #endif /* USINGC */
51 #endif /* RPC_HDR */
52 
53 #ifndef USINGC
54 #ifdef RPC_HDR
55 %class vers {
56 %  unsigned int vers_high;     /* major version number, tracks checkpoints */
57 %  unsigned int vers_low;      /* minor version number, tracks updates. */
58 %  unsigned int time_sec;      /* time stamp */
59 %  unsigned int time_usec;
60 %  STRUCTRWLOCK(vers);
61 % public:
62 %/* No argument constructor.  All entries initialized to zero. */
63 %  vers() {
64 %	vers_high = vers_low = time_sec = time_usec = 0;
65 %	INITRW(vers);
66 %  }
67 %
68 %/* Constructor that makes copy of 'other'. */
69 %  vers( vers *other );
70 %
71 %/* Constructor:  create version with specified version numbers */
72 %  vers( unsigned int high, unsigned int low) {
73 %	vers_high = high; vers_low = low; time_sec = time_usec = 0;
74 %	INITRW(vers);
75 %  }
76 %
77 %/* Creates new 'vers' with next higher minor version.
78 %   If minor version exceeds MAXLOW, bump up major version instead.
79 %   Set timestamp to that of the current time. */
80 %  vers* nextminor();
81 %
82 %/* Creates new 'vers' with next higher major version.
83 %   Set timestamp to that of the current time. */
84 %  vers* nextmajor();
85 %
86 %/* Set this 'vers' to hold values found in 'others'. */
87 %  void assign( vers *other );
88 %
89 %/* Predicate indicating whether this vers is earlier than 'other' in
90 %   terms of version numbers. */
91 %  bool_t earlier_than( vers *other );
92 %
93 %/* Print the value of this 'vers' to specified file. */
94 %  void print( FILE *file );
95 %
96 %/* Zero out this vers. */
97 %  void zero();
98 %
99 %/* Predicate indicating whether this vers is equal to 'other'. */
100 %  bool_t  equal( vers *other);
101 %
102 %/* Locking methods */
103 %
104 %  int acqexcl(void) {
105 %	return (WLOCK(vers));
106 %  }
107 %
108 %  int relexcl(void) {
109 %	return (WULOCK(vers));
110 %  }
111 %
112 %  int acqnonexcl(void) {
113 %	return (RLOCK(vers));
114 %  }
115 %
116 %  int relnonexcl(void) {
117 %	return (RULOCK(vers));
118 %  }
119 %};
120 #endif /* RPC_HDR */
121 #endif /* USINGC */
122 
123 #if RPC_HDR
124 %#endif /* VERS_H */
125 #endif /* RPC_HDR */
126