xref: /freebsd/sys/contrib/openzfs/include/sys/unique.h (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * https://opensource.org/license/CDDL-1.0.
11  */
12 /*
13  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
14  * Use is subject to license terms.
15  */
16 
17 #ifndef	_SYS_UNIQUE_H
18 #define	_SYS_UNIQUE_H
19 
20 #include <sys/zfs_context.h>
21 
22 #ifdef	__cplusplus
23 extern "C" {
24 #endif
25 
26 /* The number of significant bits in each unique value. */
27 #define	UNIQUE_BITS	56
28 
29 void unique_init(void);
30 void unique_fini(void);
31 
32 /*
33  * Return a new unique value (which will not be uniquified against until
34  * it is unique_insert()-ed).
35  */
36 uint64_t unique_create(void);
37 
38 /* Return a unique value, which equals the one passed in if possible. */
39 uint64_t unique_insert(uint64_t value);
40 
41 /* Indicate that this value no longer needs to be uniquified against. */
42 void unique_remove(uint64_t value);
43 
44 #ifdef	__cplusplus
45 }
46 #endif
47 
48 #endif /* _SYS_UNIQUE_H */
49