HPCToolkit
interval_t.c
Go to the documentation of this file.
1 //******************************************************************************
2 // global include files
3 //******************************************************************************
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 
9 //******************************************************************************
10 // local include files
11 //******************************************************************************
12 
13 #include <lib/prof-lean/mcs-lock.h>
14 #include "interval_t.h"
15 
16 static char
18 
19 
20 int
21 interval_t_cmp(void* lhs, void* rhs)
22 {
23  interval_t* p1 = (interval_t*)lhs;
24  interval_t* p2 = (interval_t*)rhs;
25  if (p1->start < p2->start) return -1;
26  if (p1->start == p2->start) return 0;
27  return 1;
28 }
29 
30 int
31 interval_t_inrange(void* lhs, void* val)
32 {
33  interval_t* interval = (interval_t*)lhs;
34  uintptr_t address = (uintptr_t)val;
35  // special boundary case:
36  if (address == UINTPTR_MAX && interval->start == UINTPTR_MAX) {
37  return 0;
38  }
39  else {
40  return (address < interval->start)? 1: (address < interval->end)? 0: -1;
41  }
42 }
43 
44 /*
45  * pre-condition: result[] is an array of length >= MAX_PTRINTERVAL_STR
46  * post-condition: a string of the form [ptrinterval->start, ptrinterval->end)
47  */
48 void
49 interval_t_tostr(void* ptrinterval, char result[])
50 {
51  interval_t* ptr_interval = (interval_t*)ptrinterval;
52  snprintf(result, MAX_INTERVAL_STR, "%s%18p%s%18p%s",
53  "[", (void*)ptr_interval->start, " ... ", (void*)ptr_interval->end, ")");
54 }
55 
56 void
58 {
59  char ptrinterval_buff[MAX_INTERVAL_STR];
60  interval_t_tostr(ptrinterval, ptrinterval_buff);
61  printf("%s", ptrinterval_buff);
62 }
63 
64 char*
66 {
67  return Interval_MaxSpaces;
68 }
#define MAX_INTERVAL_STR
Definition: interval_t.h:20
int interval_t_cmp(void *lhs, void *rhs)
Definition: interval_t.c:21
int interval_t_inrange(void *lhs, void *val)
Definition: interval_t.c:31
void interval_t_print(interval_t *ptrinterval)
Definition: interval_t.c:57
uintptr_t end
Definition: interval_t.h:28
char * interval_maxspaces()
Definition: interval_t.c:65
static char Interval_MaxSpaces[]
Definition: interval_t.c:17
void interval_t_tostr(void *ptrinterval, char result[])
Definition: interval_t.c:49
uintptr_t start
Definition: interval_t.h:27