aboutsummaryrefslogtreecommitdiffstats
path: root/test/ccured_olden/bh/trusted_bh.c
blob: 6c76f8c27f9237e1c369e956a47d373b95c526a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "defs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#ifndef _MSVC
#include <sys/times.h>
#include <sys/param.h>
#endif


#ifndef NO_PERF_CHANGES
///*
// * ALLOCATE: memory allocation with error checking.
// */
//void *allocate(int nb)
//{
//    void *mem;
//
//    mem = (void *) calloc(nb, 1);		/* calloc zeros memory      */
//    if (mem == NULL) {
//        fprintf(stderr, "allocate: not enuf memory (%d bytes)\n", nb);
//        exit(1);
//    }
//    return (mem);
//}
#endif // NO_PERF_CHANGES



// Now some wrappers
typedef struct {
  void *_p;
  void *_b;
} fatp_void;

//fatp_void strcpy_fss(char *dest, char *src) {
//  fatp_void res;
//  strcpy(dest, src);
//  res._p = (void*)dest;
//  res._b = (void*)(dest + strlen(dest));
//  return res;
//}

#ifndef NO_PERF_CHANGES
  #ifdef node2body
  #undef node2body
  #endif
  bodyptr node2body(nodeptr x) {
    return (bodyptr)x;
  }
#endif

// And the wild version. I'm being lazy about types
fatp_void node2body_ww(fatp_void x) {
  return x;
}

typedef struct {
  nodeptr *_p;
  void *_b;
  void *_e;
} seqp_node;
bodyptr node2body_sq(seqp_node x) {
  if((void*)x._p < x._b || (void*)((char*)x._p + sizeof(body)) > x._e) {
    fprintf(stderr, "Bounds check failed in node2body_sq\n");
    exit(1);
  }
  return (bodyptr)x._p;
}

#ifndef NO_PERF_CHANGES
  #ifdef node2cell
  #undef node2cell
  #endif
  cellptr node2cell(nodeptr x) {
    return (cellptr)x;
  }
#endif

// And the wild version.. I'm being lazy about types
fatp_void node2cell_ww(fatp_void x) {
  return x;
}

cellptr node2cell_sq(seqp_node x) {
  //  if((void*)x._p < x._b || (void*)((char*)x._p + sizeof(cell)) > x._e) {
  //    fprintf(stderr, "Bounds check failed in node2cell_sq\n");
  //    exit(1);
  //  }
  return (cellptr)x._p;
}