-
Notifications
You must be signed in to change notification settings - Fork 0
/
stubs.c
176 lines (127 loc) · 2.62 KB
/
stubs.c
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "postgres.h"
#include "storage/buf_internals.h"
#include "stubs.h"
MemoryContext CurrentMemoryContext = NULL;
void SetLatch(volatile Latch *latch)
{
}
void * palloc0(Size size)
{
return 0;
}
void *
MemoryContextAllocZero(MemoryContext context, Size size)
{
return 0;
}
int
s_lock(volatile slock_t *lock, const char *file, int line)
{
return 0;
}
void
InitBufTable(int size)
{
}
Size
BufTableShmemSize(int size)
{
return 0;
}
Size
add_size(Size s1, Size s2)
{
return 0;
}
extern int NBuffers;
//extern bool assert_enabled = true;
// ******************************
// src/backend/utils/error/elog.c
// ******************************
ErrorContextCallback *error_context_stack = NULL;
void
elog_start(const char *filename, int lineno, const char *funcname) {
}
void
elog_finish(int elevel, const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
exit(1);
}
// ******************************
// src/backend/storage/lmgr/lwlock.c
// ******************************
LWLockId LWLockAssign(void) {
return 0;
}
void LWLockAcquire(LWLockId lockid, LWLockMode mode){
}
void
LWLockRelease(LWLockId lockid)
{
}
/*
void
ProcSendSignal(BackendId procId) {
}
*/
void *MemoryContextAlloc(MemoryContext context, Size size) {
return malloc(size);
}
void pfree(void *pointer) {
free(pointer);
}
void *
ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
*foundPtr = false;
return malloc(size);
}
// ******************************
// src/backend/storage/ipc/shmem.c
// ******************************
Size
mul_size(Size s1, Size s2)
{
return 0;
}
// ******************************
// src/backend/storage/buffer/buf_init.c
// ******************************
long *PrivateRefCount;
BufferDesc *BufferDescriptors;
char *BufferBlocks;
void
InitBufferPool () {
int i;
PrivateRefCount = (long *) malloc(NBuffers * sizeof(long));
// Altered to use regular memory
BufferDescriptors = (BufferDesc *) malloc (NBuffers * sizeof(BufferDesc));
BufferBlocks = (char *) malloc (NBuffers * BLCKSZ);
ShmemBase = BufferBlocks;
// ShmemBase = (unsigned long) BufferBlocks;
if (false)
{
}
else
{
BufferDesc *buf;
buf = BufferDescriptors;
for (i = 0; i < NBuffers; buf++, i++)
{
CLEAR_BUFFERTAG(buf->tag);
buf->flags = 0;
buf->usage_count = 0;
buf->refcount = 0;
buf->wait_backend_pid = 0;
buf->freeNext = i + 1;
buf->buf_id = i;
*((char *) MAKE_PTR(i * BLCKSZ)) = '#';
buf->io_in_progress_lock = LWLockAssign();
buf->content_lock = LWLockAssign();
}
/* close the circular queue */
BufferDescriptors[NBuffers - 1].freeNext = -1;
StrategyInitialize(true);
}
}