run copyright.sh for 2011.
[external/binutils.git] / sim / common / sim-arange.h
1 /* Address ranges.
2    Copyright (C) 1998, 2007, 2008, 2009, 2010, 2011
3    Free Software Foundation, Inc.
4    Contributed by Cygnus Solutions.
5
6 This file is part of the GNU Simulators.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 /* This file is meant to be included by sim-basics.h.  */
22
23 #ifndef SIM_ARANGE_H
24 #define SIM_ARANGE_H
25
26 /* A list of address ranges.  */
27
28 typedef struct _addr_subrange {
29   struct _addr_subrange *next;
30
31   /* Range of addresses to be traced is [start,end].  */
32   address_word start,end;
33 } ADDR_SUBRANGE;
34
35 /* For speed, searching is done on a tree.  */
36
37 typedef struct _addr_range_tree {
38   struct _addr_range_tree *lower;
39   struct _addr_range_tree *higher;
40
41   /* Range of addresses to be traced is [start,end].  */
42   address_word start,end;
43 } ADDR_RANGE_TREE;
44
45 /* The top level struct.  */
46
47 typedef struct _addr_range {
48   ADDR_SUBRANGE *ranges;
49 #define ADDR_RANGE_RANGES(ar) ((ar)->ranges)
50   ADDR_RANGE_TREE *range_tree;
51 #define ADDR_RANGE_TREE(ar) ((ar)->range_tree)
52 } ADDR_RANGE;
53
54 /* Add address range START,END to AR.  */
55 extern void sim_addr_range_add (ADDR_RANGE * /*ar*/,
56                                 address_word /*start*/,
57                                 address_word /*end*/);
58
59 /* Delete address range START,END from AR.  */
60 extern void sim_addr_range_delete (ADDR_RANGE * /*ar*/,
61                                    address_word /*start*/,
62                                    address_word /*end*/);
63
64 /* Return non-zero if ADDR is in range AR, traversing the entire tree.
65    If no range is specified, that is defined to mean "everything".  */
66 extern INLINE int
67 sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/);
68 #define ADDR_RANGE_HIT_P(ar, addr) \
69   ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr)))
70
71 #ifdef HAVE_INLINE
72 #ifdef SIM_ARANGE_C
73 #define SIM_ARANGE_INLINE INLINE
74 #else
75 #define SIM_ARANGE_INLINE EXTERN_INLINE
76 #endif
77 #include "sim-arange.c"
78 #else
79 #define SIM_ARANGE_INLINE
80 #endif
81 #define SIM_ARANGE_C_INCLUDED
82
83 #endif /* SIM_ARANGE_H */