HPCToolkit
interval_t.h
Go to the documentation of this file.
1 #ifndef __PTRINTERVAL_T_H__
2 #define __PTRINTERVAL_T_H__
3 
4 //******************************************************************************
5 // global include files
6 //******************************************************************************
7 
8 #include <stdint.h>
9 
10 //******************************************************************************
11 // local include files
12 //******************************************************************************
13 
15 
16 //******************************************************************************
17 // macro
18 //******************************************************************************
19 
20 #define MAX_INTERVAL_STR 64
21 
22 //******************************************************************************
23 // type
24 //******************************************************************************
25 
26 typedef struct interval_s {
27  uintptr_t start;
28  uintptr_t end;
29 } interval_t;
30 
31 
32 //******************************************************************************
33 // Comparison
34 //******************************************************************************
35 
36 /*
37  * pre-condition: *p1 and *p2 are interval_t and do not overlap.
38  * if p1->start < p2->start returns -1
39  * if p1->start == p2->start returns 0
40  * if p1->start > p2->start returns 1
41  */
42 int
43 interval_t_cmp(void* p1, void* p2);
44 
45 /*
46  * pre-condition:
47  * interval is a interval_t* of the form [start, end),
48  * address is uintptr_t
49  * check if address is inside of interval, i.e. start <= address < end
50  *
51  * // special boundary case:
52  * if (address == UINTPTR_MAX && interval.start == UINTPTR_MAX)
53  * return 0;
54  *
55  * if address < interval.start , i.e. interval is "greater than" address
56  * return 1
57  * if interval.start <= address < interval.end, i.e. address is inside interval
58  * return 0
59  * else , i.e. interval is "less than" address
60  * returns -1
61  *
62  */
63 int
64 interval_t_inrange(void* interval, void* address);
65 
66 //******************************************************************************
67 // String output
68 //******************************************************************************
69 
70 /*
71  * concrete implementation of the abstract val_tostr function of the generic_val class.
72  * pre-condition: ptr_interval is of type ptrinterval_t*
73  * pre-condition: result[] is an array of length >= MAX_INTERVAL_STR
74  * post-condition: result[] is a string of the form [interval.start, interval.end)
75  */
76 void
77 interval_t_tostr(void* interval, char result[]);
78 
79 void
80 interval_t_print(interval_t* interval);
81 
82 /*
83  * the max spaces occupied by "([start_address ... end_address)
84  */
85 char*
87 
88 #endif /* __PTRINTERVAL_T_H__ */
void interval_t_print(interval_t *interval)
Definition: interval_t.c:57
uintptr_t end
Definition: interval_t.h:28
int interval_t_cmp(void *p1, void *p2)
Definition: interval_t.c:21
void interval_t_tostr(void *interval, char result[])
Definition: interval_t.c:49
uintptr_t start
Definition: interval_t.h:27
int interval_t_inrange(void *interval, void *address)
Definition: interval_t.c:31
struct interval_s interval_t
char * interval_maxspaces()
Definition: interval_t.c:65