Support for OpenACC acc_on_device in offloading configurations.
[official-gcc.git] / libgomp / splay-tree.h
blobffe5822219b1e6715ff286ce57dfbca552f19e03
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 Offloading and Multi Processing Library
7 (libgomp).
9 Libgomp is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 /* The splay tree code copied from include/splay-tree.h and adjusted,
29 so that all the data lives directly in splay_tree_node_s structure
30 and no extra allocations are needed.
32 Files including this header should before including it add:
33 typedef struct splay_tree_node_s *splay_tree_node;
34 typedef struct splay_tree_s *splay_tree;
35 typedef struct splay_tree_key_s *splay_tree_key;
36 define splay_tree_key_s structure, and define
37 splay_compare inline function. */
39 /* For an easily readable description of splay-trees, see:
41 Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
42 Algorithms. Harper-Collins, Inc. 1991.
44 The major feature of splay trees is that all basic tree operations
45 are amortized O(log n) time for a tree with n nodes. */
47 #ifndef _SPLAY_TREE_H
48 #define _SPLAY_TREE_H 1
50 typedef struct splay_tree_node_s *splay_tree_node;
51 typedef struct splay_tree_s *splay_tree;
52 typedef struct splay_tree_key_s *splay_tree_key;
54 struct splay_tree_key_s {
55 /* Address of the host object. */
56 uintptr_t host_start;
57 /* Address immediately after the host object. */
58 uintptr_t host_end;
59 /* Descriptor of the target memory. */
60 struct target_mem_desc *tgt;
61 /* Offset from tgt->tgt_start to the start of the target object. */
62 uintptr_t tgt_offset;
63 /* Reference count. */
64 uintptr_t refcount;
65 /* Asynchronous reference count. */
66 uintptr_t async_refcount;
67 /* True if data should be copied from device to host at the end. */
68 bool copy_from;
71 /* The nodes in the splay tree. */
72 struct splay_tree_node_s {
73 struct splay_tree_key_s key;
74 /* The left and right children, respectively. */
75 splay_tree_node left;
76 splay_tree_node right;
79 /* The splay tree. */
80 struct splay_tree_s {
81 splay_tree_node root;
84 extern splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key);
85 extern void splay_tree_insert (splay_tree, splay_tree_node);
86 extern void splay_tree_remove (splay_tree, splay_tree_key);
88 #endif /* _SPLAY_TREE_H */