Mercurial > hg > CbC > CbC_gcc
comparison include/splay-tree.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* A splay-tree datatype. | 1 /* A splay-tree datatype. |
2 Copyright 1998, 1999, 2000, 2002, 2005, 2007, 2009, 2010 | 2 Copyright (C) 1998-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 Contributed by Mark Mitchell (mark@markmitchell.com). | 3 Contributed by Mark Mitchell (mark@markmitchell.com). |
5 | 4 |
6 This file is part of GCC. | 5 This file is part of GCC. |
7 | 6 |
8 GCC is free software; you can redistribute it and/or modify it | 7 GCC is free software; you can redistribute it and/or modify it |
35 extern "C" { | 34 extern "C" { |
36 #endif /* __cplusplus */ | 35 #endif /* __cplusplus */ |
37 | 36 |
38 #include "ansidecl.h" | 37 #include "ansidecl.h" |
39 | 38 |
40 #ifndef _WIN64 | 39 #ifdef HAVE_STDINT_H |
41 typedef unsigned long int libi_uhostptr_t; | 40 #include <stdint.h> |
42 typedef long int libi_shostptr_t; | |
43 #else | |
44 #ifdef __GNUC__ | |
45 __extension__ | |
46 #endif | 41 #endif |
47 typedef unsigned long long libi_uhostptr_t; | 42 #ifdef HAVE_INTTYPES_H |
48 #ifdef __GNUC__ | 43 #include <inttypes.h> |
49 __extension__ | |
50 #endif | |
51 typedef long long libi_shostptr_t; | |
52 #endif | |
53 | |
54 #ifndef GTY | |
55 #define GTY(X) | |
56 #endif | 44 #endif |
57 | 45 |
58 /* Use typedefs for the key and data types to facilitate changing | 46 /* Use typedefs for the key and data types to facilitate changing |
59 these types, if necessary. These types should be sufficiently wide | 47 these types, if necessary. These types should be sufficiently wide |
60 that any pointer or scalar can be cast to these types, and then | 48 that any pointer or scalar can be cast to these types, and then |
61 cast back, without loss of precision. */ | 49 cast back, without loss of precision. */ |
62 typedef libi_uhostptr_t splay_tree_key; | 50 typedef uintptr_t splay_tree_key; |
63 typedef libi_uhostptr_t splay_tree_value; | 51 typedef uintptr_t splay_tree_value; |
64 | 52 |
65 /* Forward declaration for a node in the tree. */ | 53 /* Forward declaration for a node in the tree. */ |
66 typedef struct splay_tree_node_s *splay_tree_node; | 54 typedef struct splay_tree_node_s *splay_tree_node; |
67 | 55 |
68 /* The type of a function which compares two splay-tree keys. The | 56 /* The type of a function which compares two splay-tree keys. The |
91 memory to be freed; the latter is a data pointer the splay tree | 79 memory to be freed; the latter is a data pointer the splay tree |
92 functions pass through to the freer. */ | 80 functions pass through to the freer. */ |
93 typedef void (*splay_tree_deallocate_fn) (void *, void *); | 81 typedef void (*splay_tree_deallocate_fn) (void *, void *); |
94 | 82 |
95 /* The nodes in the splay tree. */ | 83 /* The nodes in the splay tree. */ |
96 struct GTY(()) splay_tree_node_s { | 84 struct splay_tree_node_s { |
97 /* The key. */ | 85 /* The key. */ |
98 splay_tree_key GTY ((use_param1)) key; | 86 splay_tree_key key; |
99 | 87 |
100 /* The value. */ | 88 /* The value. */ |
101 splay_tree_value GTY ((use_param2)) value; | 89 splay_tree_value value; |
102 | 90 |
103 /* The left and right children, respectively. */ | 91 /* The left and right children, respectively. */ |
104 splay_tree_node GTY ((use_params)) left; | 92 splay_tree_node left; |
105 splay_tree_node GTY ((use_params)) right; | 93 splay_tree_node right; |
106 }; | 94 }; |
107 | 95 |
108 /* The splay tree itself. */ | 96 /* The splay tree itself. */ |
109 struct GTY(()) splay_tree_s { | 97 struct splay_tree_s { |
110 /* The root of the tree. */ | 98 /* The root of the tree. */ |
111 splay_tree_node GTY ((use_params)) root; | 99 splay_tree_node root; |
112 | 100 |
113 /* The comparision function. */ | 101 /* The comparision function. */ |
114 splay_tree_compare_fn comp; | 102 splay_tree_compare_fn comp; |
115 | 103 |
116 /* The deallocate-key function. NULL if no cleanup is necessary. */ | 104 /* The deallocate-key function. NULL if no cleanup is necessary. */ |
124 | 112 |
125 /* Free function for nodes and trees. Takes allocate_data as a parameter. */ | 113 /* Free function for nodes and trees. Takes allocate_data as a parameter. */ |
126 splay_tree_deallocate_fn deallocate; | 114 splay_tree_deallocate_fn deallocate; |
127 | 115 |
128 /* Parameter for allocate/free functions. */ | 116 /* Parameter for allocate/free functions. */ |
129 void * GTY((skip)) allocate_data; | 117 void *allocate_data; |
130 }; | 118 }; |
131 | 119 |
132 typedef struct splay_tree_s *splay_tree; | 120 typedef struct splay_tree_s *splay_tree; |
133 | 121 |
134 extern splay_tree splay_tree_new (splay_tree_compare_fn, | 122 extern splay_tree splay_tree_new (splay_tree_compare_fn, |