Skip to content

Commit e9ae3ae

Browse files
committed
COMMON: remove obsolete code
1 parent d2640ba commit e9ae3ae

File tree

11 files changed

+33
-176
lines changed

11 files changed

+33
-176
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-08-22
2+
Fix HASH var crash
3+
Fix HASH var handling of mixed types
4+
15
2014-08-15
26
Improved runtime performance
37
Fixed memory leak with UDS variables

src/common/bc.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -128,50 +128,32 @@ void bc_add2l(bc_t * bc, byte code, long p1) {
128128
* add buildin function call
129129
*/
130130
void bc_add_fcode(bc_t *bc, long idx) {
131-
#if defined(OS_ADDR16)
132-
bc_add2i(bc, kwTYPE_CALLF, idx);
133-
#else
134131
bc_add2l(bc, kwTYPE_CALLF, idx);
135-
#endif
136132
}
137133

138134
/*
139135
* add buildin procedure call
140136
*/
141137
void bc_add_pcode(bc_t *bc, long idx) {
142-
#if defined(OS_ADDR16)
143-
bc_add2i(bc, kwTYPE_CALLP, idx);
144-
#else
145138
bc_add2l(bc, kwTYPE_CALLP, idx);
146-
#endif
147139
}
148140

149141
/*
150142
* add an external function-call
151143
*/
152144
void bc_add_extfcode(bc_t *bc, int lib, long idx) {
153145
bc_add_code(bc, kwTYPE_CALLEXTF);
154-
#if defined(OS_ADDR16)
155-
bc_add_word(bc, lib);
156-
bc_add_word(bc, idx);
157-
#else
158146
bc_add_dword(bc, lib);
159147
bc_add_dword(bc, idx);
160-
#endif
161148
}
162149

163150
/*
164151
* add an external procedure-call
165152
*/
166153
void bc_add_extpcode(bc_t *bc, int lib, long idx) {
167154
bc_add_code(bc, kwTYPE_CALLEXTP);
168-
#if defined(OS_ADDR16)
169-
bc_add_word(bc, lib);
170-
bc_add_word(bc, idx);
171-
#else
172155
bc_add_dword(bc, lib);
173156
bc_add_dword(bc, idx);
174-
#endif
175157
}
176158

177159
/*
@@ -181,13 +163,8 @@ void bc_add_addr(bc_t *bc, addr_t idx) {
181163
if (bc->count >= bc->size - 4) {
182164
bc_resize(bc, bc->size + BC_ALLOC_INCR);
183165
}
184-
#if defined(OS_ADDR16)
185-
memcpy(bc->ptr + bc->count, &idx, 2);
186-
bc->count += 2;
187-
#else
188166
memcpy(bc->ptr + bc->count, &idx, 4);
189167
bc->count += 4;
190-
#endif
191168
}
192169

193170
/*
@@ -236,15 +213,11 @@ void bc_add2s(bc_t *bc, byte code, const char *p1) {
236213
sc_raise("STRING TOO BIG");
237214
} else {
238215
bc_add_code(bc, code);
239-
#if defined(OS_ADDR16)
240-
bc_add_word(bc, l);
241-
#else
242216
bc_add_dword(bc, l);
243-
#endif
244217

245-
if (bc->count >= bc->size - l)
218+
if (bc->count >= bc->size - l) {
246219
bc_resize(bc, bc->size + BC_ALLOC_INCR);
247-
220+
}
248221
memcpy(bc->ptr + bc->count, p1, l);
249222
bc->count += l;
250223
}

src/common/bc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
#include "common/kw.h"
1616

1717
#define BC_ALLOC_INCR 1024
18-
#if defined(OS_ADDR16)
19-
#define BC_MAX_STORE_SIZE 0x7FFF
20-
#else
2118
#define BC_MAX_STORE_SIZE 0x7FFFFFFF
22-
#endif
2319

2420
/**
2521
* @ingroup scan

src/common/blib.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,12 +2049,7 @@ void cmd_read() {
20492049
prog_dp += OS_REALSZ;
20502050
break;
20512051
case kwTYPE_STR: {
2052-
#if defined(OS_ADDR16)
2053-
word len;
2054-
#else
20552052
dword len;
2056-
#endif
2057-
20582053
prog_dp++;
20592054

20602055
vp->type = V_STR;

src/common/ceval.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ static bc_t *bc_out;
4141
*/
4242
void cev_prim() {
4343
byte code;
44-
#if defined(OS_ADDR16)
45-
word len;
46-
#else
4744
dword len;
48-
#endif
4945

5046
if (comp_error) {
5147
return;
@@ -65,11 +61,7 @@ void cev_prim() {
6561
case kwTYPE_STR:
6662
memcpy(&len, bc_in->ptr + bc_in->cp, OS_STRLEN);
6763
IP += OS_STRLEN;
68-
#if defined(OS_ADDR16)
69-
bc_add_word(bc_out, len);
70-
#else
7164
bc_add_dword(bc_out, len);
72-
#endif
7365
bc_add_n(bc_out, bc_in->ptr + bc_in->cp, len);
7466

7567
IP += len;

src/common/pmem.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ typedef unsigned int dword;
5151
// code
5252
typedef byte code_t; /**< basic code unit (unsigned) @ingroup mem */
5353

54-
#if defined(OS_ADDR16) // work with 16bits
55-
#define ADDR16 // just for short defs
56-
typedef int16 fcode_t; // buildin function code (signed)
57-
typedef int16 pcode_t; // buildin procedure code (signed)
58-
typedef word addr_t; // memory address (unsigned)
59-
#define INVALID_ADDR 0xFFFF // invalid address value (unsigned)
60-
typedef int16 bid_t; // IDs (labels, variables, etc) (signed)
61-
#define OS_ADDRSZ 2 // size of address pointer (always 2
62-
// for 16b mode)
63-
#define OS_CODESZ 2 // size of buildin func/proc ptrs
64-
// (always 2 for 16b mode)
65-
#define OS_STRLEN 2 // size of strings
66-
#else
67-
6854
typedef int32 fcode_t;
6955
typedef int32 pcode_t;
7056
typedef int32 bid_t;
@@ -77,7 +63,6 @@ typedef dword addr_t;
7763
#define OS_ADDRSZ 4 // size of address pointer (always 4 for 32b addresses)
7864
#define OS_CODESZ 4 // size of buildin func/proc ptrs (always 4 for 32b mode)
7965
#define OS_STRLEN 4 // size of strings
80-
#endif
8166

8267
#define ADDRSZ OS_ADDRSZ
8368
#define CODESZ OS_CODESZ

src/common/scan.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,11 +1825,7 @@ void comp_text_line(char *text) {
18251825
char *p;
18261826
char *lb_end;
18271827
char *last_cmd;
1828-
#if defined(OS_ADDR16)
1829-
int idx;
1830-
#else
18311828
long idx;
1832-
#endif
18331829
int sharp, ladd, linc, ldec, decl = 0, vattr;
18341830
int leqop;
18351831
char pname[SB_KEYWORD_SIZE + 1];
@@ -2592,11 +2588,7 @@ void comp_text_line(char *text) {
25922588
*/
25932589
addr_t comp_next_bc_cmd(addr_t ip) {
25942590
code_t code;
2595-
#if defined(ADDR16)
2596-
word len;
2597-
#else
25982591
dword len;
2599-
#endif
26002592

26012593
code = comp_prog.ptr[ip];
26022594
ip++;
@@ -4217,13 +4209,9 @@ mem_t comp_create_bin() {
42174209
#else
42184210
hdr.flags = 0;
42194211
#endif
4220-
#if defined(OS_ADDR16)
4221-
hdr.flags |= 2;
4222-
#elif defined(OS_ADDR32)
4223-
hdr.flags |= 4;
4224-
#endif
42254212

42264213
// executable header
4214+
hdr.flags |= 4;
42274215
hdr.bc_count = comp_prog.count;
42284216
hdr.var_count = comp_varcount;
42294217
hdr.lab_count = comp_labcount;

src/common/sys.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
* OS_FILEHANDLES Number of file handles to use.
3333
* Because there is a static array with information about each handle,
3434
* use small numbers on limited systems (a value of 16 is good enough).
35-
*
36-
* OS_ADDR32 Use 32bit code, in anycase
37-
*
38-
* OS_ADDR16 Use 16bit code, in anycase
39-
*
4035
*/
4136

4237
#if !defined(SB_SYS_H)
@@ -94,7 +89,6 @@ typedef long int var_int_t;
9489

9590
#define OS_INTSZ sizeof(var_int_t) // size of integer
9691
#define OS_REALSZ sizeof(var_num_t) // size of real
97-
#define OS_ADDR32
9892

9993
#define mem_lock(h) (void *)(h)
10094
#define mem_unlock(h)

src/common/var.c

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,7 @@ int v_length(var_t *var) {
125125
/*
126126
* return array element pointer
127127
*/
128-
#if defined(OS_ADDR16)
129-
var_t *v_getelemptr(var_t *v, word index)
130-
#else
131-
var_t *v_getelemptr(var_t *v, dword index)
132-
#endif
133-
{
128+
var_t *v_getelemptr(var_t *v, dword index) {
134129
if (v->type == V_ARRAY) {
135130
if (index < v->v.a.size)
136131
return (var_t *) (v->v.a.ptr + (index * sizeof(var_t)));
@@ -147,19 +142,10 @@ var_t *v_getelemptr(var_t *v, dword index)
147142
/*
148143
* resize an existing array
149144
*/
150-
#if defined(OS_ADDR16)
151-
void v_resize_array(var_t *v, word size)
152-
#else
153-
void v_resize_array(var_t *v, dword size)
154-
#endif
155-
{
145+
void v_resize_array(var_t *v, dword size) {
156146
byte *prev;
157147
var_t *elem;
158-
#if defined(OS_ADDR16)
159-
word i;
160-
#else
161148
dword i;
162-
#endif
163149

164150
if (v->type == V_ARRAY) {
165151
if (size < 0) {
@@ -183,15 +169,9 @@ void v_resize_array(var_t *v, dword size)
183169
v_free(elem);
184170
}
185171

186-
#if defined(OS_ADDR32)
187172
// do not resize array
188173
prev = NULL;
189-
#else
190-
// resize & copy
191-
prev = v->v.a.ptr;
192-
v->v.a.ptr = tmp_alloc(size * sizeof(var_t));
193-
memcpy(v->v.a.ptr, prev, size * sizeof(var_t));
194-
#endif
174+
195175
// array data
196176
v->v.a.size = size;
197177
v->v.a.ubound[0] = v->v.a.lbound[0] + (size - 1);
@@ -203,8 +183,6 @@ void v_resize_array(var_t *v, dword size)
203183
}
204184
} else if (v->v.a.size < size) {
205185
// resize up
206-
207-
#if defined(OS_ADDR32)
208186
// if there is space do not resize
209187
if (v->v.a.size == 0) {
210188
prev = v->v.a.ptr;
@@ -216,17 +194,10 @@ void v_resize_array(var_t *v, dword size)
216194
v->v.a.ptr = tmp_alloc((size + ARR_ALLOC) * sizeof(var_t));
217195
if (v->v.a.size > 0)
218196
memcpy(v->v.a.ptr, prev, v->v.a.size * sizeof(var_t));
219-
} else
197+
} else {
220198
prev = NULL;
199+
}
221200
}
222-
#else
223-
// resize & copy
224-
prev = v->v.a.ptr;
225-
v->v.a.ptr = tmp_alloc(size * sizeof(var_t));
226-
if (v->v.a.size > 0) {
227-
memcpy(v->v.a.ptr, prev, v->v.a.size * sizeof(var_t));
228-
}
229-
#endif
230201

231202
// init vars
232203
for (i = v->v.a.size; i < size; i++) {
@@ -289,30 +260,17 @@ var_t *v_new_matrix(int r, int c) {
289260
/*
290261
* create array
291262
*/
292-
#if defined(OS_ADDR16)
293-
void v_toarray1(var_t *v, word r)
294-
#else
295-
void v_toarray1(var_t *v, dword r)
296-
#endif
297-
{
263+
void v_toarray1(var_t *v, dword r) {
298264
var_t *e;
299-
#if defined(OS_ADDR16)
300-
word i;
301-
#else
302265
dword i;
303-
#endif
304266

305267
v_free(v);
306268
v->type = V_ARRAY;
307269

308270
if (r > 0) {
309271
// create data
310272
v->v.a.size = r;
311-
#if defined(OS_ADDR32)
312273
v->v.a.ptr = tmp_alloc(sizeof(var_t) * (v->v.a.size + ARR_ALLOC));
313-
#else
314-
v->v.a.ptr = tmp_alloc(sizeof(var_t) * v->v.a.size);
315-
#endif
316274
for (i = 0; i < r; i++) {
317275
e = (var_t *) (v->v.a.ptr + (sizeof(var_t) * i));
318276
v_init(e);

0 commit comments

Comments
 (0)