xref: /titanic_44/usr/src/lib/libuuid/common/uuid_misc.h (revision 1e4c938b57d1656808e4112127ff1dce3eba5314)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_UUID_MISC_H
27 #define	_UUID_MISC_H
28 
29 /*
30  * The copyright in this file is taken from the original Leach
31  * & Salz UUID specification, from which this implementation
32  * is derived.
33  */
34 
35 /*
36  * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
37  * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
38  * Digital Equipment Corporation, Maynard, Mass.  Copyright (c) 1998
39  * Microsoft.  To anyone who acknowledges that this file is provided
40  * "AS IS" without any express or implied warranty: permission to use,
41  * copy, modify, and distribute this file for any purpose is hereby
42  * granted without fee, provided that the above copyright notices and
43  * this notice appears in all source code copies, and that none of the
44  * names of Open Software Foundation, Inc., Hewlett-Packard Company,
45  * or Digital Equipment Corporation be used in advertising or
46  * publicity pertaining to distribution of the software without
47  * specific, written prior permission.  Neither Open Software
48  * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
49  * Equipment Corporation makes any representations about the
50  * suitability of this software for any purpose.
51  */
52 
53 #ifdef	__cplusplus
54 extern "C" {
55 #endif
56 
57 #include <uuid/uuid.h>
58 #include <sys/types.h>
59 #include <thread.h>
60 
61 typedef uint64_t		uuid_time_t;
62 
63 /*
64  * data type for UUID generator persistent state
65  */
66 typedef struct {
67 	uuid_time_t		ts;	/* saved timestamp */
68 	uuid_node_t		node;	/* saved node ID */
69 	uint16_t		clock;	/* saved clock sequence */
70 } uuid_state_t;
71 
72 typedef struct {
73 	mutex_t			lock;
74 	uuid_state_t		state;
75 } shared_buffer_t;
76 
77 #define	STATE_LOCATION		"/var/sadm/system/uuid_state"
78 #define	URANDOM_PATH		"/dev/urandom"
79 #define	MAX_RETRY		8
80 #define	VER1_MASK		0xefff
81 
82 #define	STATE_FILE		1
83 #define	TEMP_FILE		2
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif /* _UUID_MISC_H */
90