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