Skip to content

Commit db9275b

Browse files
committed
fix compilation errors
1 parent 7721495 commit db9275b

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

src/misc/btor/btor2mem.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,8 @@ ABC_NAMESPACE_HEADER_START
2525

2626
/*------------------------------------------------------------------------*/
2727

28-
#define BTOR2_NEWN(ptr, nelems) \
29-
((ptr) = (typeof(ptr)) btorsim_malloc ((nelems) * sizeof *(ptr)))
30-
31-
#define BTOR2_CNEWN(ptr, nelems) \
32-
((ptr) = (typeof(ptr)) btorsim_calloc ((nelems), sizeof *(ptr)))
33-
3428
#define BTOR2_CLRN(ptr, nelems) (memset ((ptr), 0, (nelems) * sizeof *(ptr)))
3529

36-
#define BTOR2_REALLOC(p, n) \
37-
((p) = (typeof(p)) btorsim_realloc ((p), ((n) * sizeof *(p))))
38-
39-
#define BTOR2_NEW(ptr) BTOR2_NEWN ((ptr), 1)
40-
41-
#define BTOR2_CNEW(ptr) BTOR2_CNEWN ((ptr), 1)
42-
4330
#define BTOR2_CLR(ptr) BTOR2_CLRN ((ptr), 1)
4431

4532
#define BTOR2_DELETE(ptr) (free (ptr))
@@ -90,7 +77,7 @@ btorsim_strdup (const char *str)
9077
char *res = 0;
9178
if (str)
9279
{
93-
BTOR2_NEWN (res, strlen (str) + 1);
80+
res = (char *) btorsim_malloc ((strlen (str) + 1) * sizeof (char));
9481
strcpy (res, str);
9582
}
9683
return res;

src/misc/btor/btor2parser.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ btor2parser_strdup (const char *str)
6868
{
6969
assert (str);
7070

71-
char *res = btor2parser_malloc (strlen (str) + 1);
71+
char *res = (char *)btor2parser_malloc (strlen (str) + 1);
7272
strcpy (res, str);
7373
return res;
7474
}
7575

7676
Btor2Parser *
7777
btor2parser_new ()
7878
{
79-
Btor2Parser *res = btor2parser_malloc (sizeof *res);
79+
Btor2Parser *res = (Btor2Parser *)btor2parser_malloc (sizeof *res);
8080
memset (res, 0, sizeof *res);
8181
return res;
8282
}
@@ -158,7 +158,7 @@ perr_bfr (Btor2Parser *bfr, const char *fmt, ...)
158158
va_end (ap);
159159
buf[1023] = '\0';
160160

161-
bfr->error = btor2parser_malloc (strlen (buf) + 28);
161+
bfr->error = (char *)btor2parser_malloc (strlen (buf) + 28);
162162
sprintf (bfr->error, "line %" PRId64 ": %s", bfr->lineno, buf);
163163
return 0;
164164
}
@@ -169,7 +169,7 @@ pushc_bfr (Btor2Parser *bfr, int32_t ch)
169169
if (bfr->nbuf >= bfr->szbuf)
170170
{
171171
bfr->szbuf = bfr->szbuf ? 2 * bfr->szbuf : 1;
172-
bfr->buf = btor2parser_realloc (bfr->buf, bfr->szbuf * sizeof *bfr->buf);
172+
bfr->buf = (char *)btor2parser_realloc (bfr->buf, bfr->szbuf * sizeof *bfr->buf);
173173
}
174174
bfr->buf[bfr->nbuf++] = ch;
175175
}
@@ -181,7 +181,7 @@ pusht_bfr (Btor2Parser *bfr, Btor2Line *l)
181181
{
182182
bfr->sztable = bfr->sztable ? 2 * bfr->sztable : 1;
183183
bfr->table =
184-
btor2parser_realloc (bfr->table, bfr->sztable * sizeof *bfr->table);
184+
(Btor2Line **)btor2parser_realloc (bfr->table, bfr->sztable * sizeof *bfr->table);
185185
}
186186
bfr->table[bfr->ntable++] = l;
187187
}
@@ -401,13 +401,13 @@ new_line_bfr (Btor2Parser *bfr,
401401
Btor2Line *res;
402402
assert (0 < id);
403403
assert (bfr->ntable <= id);
404-
res = btor2parser_malloc (sizeof *res);
404+
res = (Btor2Line *)btor2parser_malloc (sizeof *res);
405405
memset (res, 0, sizeof (*res));
406406
res->id = id;
407407
res->lineno = lineno;
408408
res->tag = tag;
409409
res->name = name;
410-
res->args = btor2parser_malloc (sizeof (int64_t) * 3);
410+
res->args = (int64_t *)btor2parser_malloc (sizeof (int64_t) * 3);
411411
memset (res->args, 0, sizeof (int64_t) * 3);
412412
while (bfr->ntable < id) pusht_bfr (bfr, 0);
413413
assert (bfr->ntable == id);
@@ -617,7 +617,7 @@ check_sorts_bfr (Btor2Parser *bfr, Btor2Line *l)
617617
break;
618618

619619
/* [u:l] -> u - l + 1 */
620-
case BTOR2_TAG_slice:
620+
case BTOR2_TAG_slice: {
621621
assert (l->nargs == 1);
622622
if (!check_sort_bitvec (bfr, l, args)) return 0;
623623
/* NOTE: this cast is safe since l->args[1] and l->args[2] contains
@@ -631,7 +631,7 @@ check_sorts_bfr (Btor2Parser *bfr, Btor2Line *l)
631631
l->name,
632632
upper - lower + 1);
633633
break;
634-
634+
}
635635
/* 1 x 1 -> 1 */
636636
case BTOR2_TAG_iff:
637637
case BTOR2_TAG_implies:
@@ -706,7 +706,7 @@ check_sorts_bfr (Btor2Parser *bfr, Btor2Line *l)
706706
break;
707707

708708
case BTOR2_TAG_sext:
709-
case BTOR2_TAG_uext:
709+
case BTOR2_TAG_uext: {
710710
assert (l->nargs == 1);
711711
if (!check_sort_bitvec (bfr, l, args)) return 0;
712712
/* NOTE: this cast is safe since l->args[1] contains the extension
@@ -719,7 +719,7 @@ check_sorts_bfr (Btor2Parser *bfr, Btor2Line *l)
719719
l->name,
720720
ext);
721721
break;
722-
722+
}
723723
case BTOR2_TAG_read:
724724
assert (l->nargs == 2);
725725
if (args[0]->sort.tag != BTOR2_TAG_SORT_array)
@@ -1000,7 +1000,7 @@ mult_unbounded_bin_str (const char *a, const char *b)
10001000
alen = strlen (a);
10011001
blen = strlen (b);
10021002
rlen = alen + blen;
1003-
res = btor2parser_malloc (rlen + 1);
1003+
res = (char *)btor2parser_malloc (rlen + 1);
10041004
res[rlen] = 0;
10051005

10061006
for (r = res; r < res + blen; r++) *r = '0';
@@ -1058,7 +1058,7 @@ add_unbounded_bin_str (const char *a, const char *b)
10581058
rlen = (alen < blen) ? blen : alen;
10591059
rlen++;
10601060

1061-
res = btor2parser_malloc (rlen + 1);
1061+
res = (char *)btor2parser_malloc (rlen + 1);
10621062

10631063
p = a + alen;
10641064
q = b + blen;
@@ -1256,11 +1256,11 @@ check_state_init (Btor2Parser *bfr, int64_t state_id, int64_t init_id)
12561256

12571257
// 'init_id' is the highest id we will see when traversing down
12581258
size_t size = (labs (init_id) + 1) * sizeof (char);
1259-
cache = btor2parser_malloc (size);
1259+
cache = (char *)btor2parser_malloc (size);
12601260
memset (cache, 0, size);
12611261

12621262
BTOR2_INIT_STACK (stack);
1263-
BTOR2_PUSH_STACK (stack, init_id);
1263+
BTOR2_PUSH_STACK (int64_t, stack, init_id);
12641264
do
12651265
{
12661266
id = BTOR2_POP_STACK (stack);
@@ -1282,7 +1282,7 @@ check_state_init (Btor2Parser *bfr, int64_t state_id, int64_t init_id)
12821282
id);
12831283
break;
12841284
}
1285-
for (i = 0; i < line->nargs; i++) BTOR2_PUSH_STACK (stack, line->args[i]);
1285+
for (i = 0; i < line->nargs; i++) BTOR2_PUSH_STACK (int64_t, stack, line->args[i]);
12861286
} while (!BTOR2_EMPTY_STACK (stack));
12871287

12881288
free (cache);
@@ -1342,7 +1342,7 @@ parse_justice_bfr (Btor2Parser *bfr, Btor2Line *l)
13421342
{
13431343
uint32_t nargs;
13441344
if (!parse_pos_number_bfr (bfr, &nargs)) return 0;
1345-
l->args = btor2parser_realloc (l->args, sizeof (int64_t) * nargs);
1345+
l->args = (int64_t *)btor2parser_realloc (l->args, sizeof (int64_t) * nargs);
13461346
l->nargs = nargs;
13471347
if (!parse_args (bfr, l, nargs)) return 0;
13481348
return 1;

src/misc/btor/btor2stack.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,28 @@ BTOR2_DECLARE_STACK (BtorVoidPtr, void *);
5353
BTOR2_INIT_STACK ((stack)); \
5454
} while (0)
5555

56-
#define BTOR2_ENLARGE(p, o, n) \
56+
#define BTOR2_ENLARGE(T, p, o, n) \
5757
do \
5858
{ \
5959
size_t internaln = (o) ? 2 * (o) : 1; \
60-
BTOR2_REALLOC ((p), internaln); \
60+
(p) = (T *) btorsim_realloc ((p), ((internaln) * sizeof (T))); \
6161
(n) = internaln; \
6262
} while (0)
6363

64-
#define BTOR2_ENLARGE_STACK(stack) \
64+
#define BTOR2_ENLARGE_STACK(T, stack) \
6565
do \
6666
{ \
6767
size_t old_size = BTOR2_SIZE_STACK (stack), new_size; \
6868
size_t old_count = BTOR2_COUNT_STACK (stack); \
69-
BTOR2_ENLARGE ((stack).start, old_size, new_size); \
69+
BTOR2_ENLARGE (T, (stack).start, old_size, new_size); \
7070
(stack).top = (stack).start + old_count; \
7171
(stack).end = (stack).start + new_size; \
7272
} while (0)
7373

74-
#define BTOR2_PUSH_STACK(stack, elem) \
74+
#define BTOR2_PUSH_STACK(T, stack, elem) \
7575
do \
7676
{ \
77-
if (BTOR2_FULL_STACK ((stack))) BTOR2_ENLARGE_STACK ((stack)); \
77+
if (BTOR2_FULL_STACK ((stack))) BTOR2_ENLARGE_STACK (T, (stack)); \
7878
*((stack).top++) = (elem); \
7979
} while (0)
8080

0 commit comments

Comments
 (0)