svn merge -r 217483:217500 svn+ssh://gcc.gnu.org/svn/gcc/trunk
[official-gcc.git] / libgomp / splay-tree.h
blobf29d437ebdd9330001cf3becac164e70a942b14e
1 /* A splay-tree datatype.
2 Copyright 1998-2014
3 Free Software Foundation, Inc.
4 Contributed by Mark Mitchell (mark@markmitchell.com).
6 This file is part of the GNU OpenMP Library (libgomp).
8 Libgomp is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 /* The splay tree code copied from include/splay-tree.h and adjusted,
28 so that all the data lives directly in splay_tree_node_s structure
29 and no extra allocations are needed.
31 Files including this header should before including it add:
32 typedef struct splay_tree_node_s *splay_tree_node;
33 typedef struct splay_tree_s *splay_tree;
34 typedef struct splay_tree_key_s *splay_tree_key;
35 define splay_tree_key_s structure, and define
36 splay_compare inline function. */
38 /* For an easily readable description of splay-trees, see:
40 Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
41 Algorithms. Harper-Collins, Inc. 1991.
43 The major feature of splay trees is that all basic tree operations
44 are amortized O(log n) time for a tree with n nodes. */
46 #ifndef _SPLAY_TREE_H
47 #define _SPLAY_TREE_H 1
49 typedef struct splay_tree_node_s *splay_tree_node;
50 typedef struct splay_tree_s *splay_tree;
51 typedef struct splay_tree_key_s *splay_tree_key;
53 struct splay_tree_key_s {
54 /* Address of the host object. */
55 uintptr_t host_start;
56 /* Address immediately after the host object. */
57 uintptr_t host_end;
58 /* Descriptor of the target memory. */
59 struct target_mem_desc *tgt;
60 /* Offset from tgt->tgt_start to the start of the target object. */
61 uintptr_t tgt_offset;
62 /* Reference count. */
63 uintptr_t refcount;
64 /* Asynchronous reference count. */
65 uintptr_t async_refcount;
66 /* True if data should be copied from device to host at the end. */
67 bool copy_from;
70 /* The nodes in the splay tree. */
71 struct splay_tree_node_s {
72 struct splay_tree_key_s key;
73 /* The left and right children, respectively. */
74 splay_tree_node left;
75 splay_tree_node right;
78 /* The splay tree. */
79 struct splay_tree_s {
80 splay_tree_node root;
83 attribute_hidden splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key);
84 attribute_hidden void splay_tree_insert (splay_tree, splay_tree_node);
85 attribute_hidden void splay_tree_remove (splay_tree, splay_tree_key);
87 #endif /* _SPLAY_TREE_H */