Skip to content

Commit 12994ed

Browse files
authored
Merge pull request #767 from fjtrujy/fixEE_GCC15
Prepare for GCC 15 upgrade
2 parents 54938c4 + ebc30a1 commit 12994ed

File tree

11 files changed

+159
-223
lines changed

11 files changed

+159
-223
lines changed

ee/erl/include/hashtab.h

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ This implements a hash table.
2828
--------------------------------------------------------------------
2929
*/
3030

31-
#ifndef STANDARD
32-
#include "standard.h"
33-
#endif
31+
#ifndef HASHTAB_H
32+
#define HASHTAB_H
3433

35-
#ifndef HASHTAB
36-
#define HASHTAB
34+
#include "standard.h"
3735

3836
#ifdef __cplusplus
3937
extern "C" {
@@ -43,25 +41,25 @@ extern "C" {
4341

4442
struct hitem
4543
{
46-
ub1 *key; /* key that is hashed */
47-
ub4 keyl; /* length of key */
48-
void *stuff; /* stuff stored in this hitem */
49-
ub4 hval; /* hash value */
50-
struct hitem *next; /* next hitem in list */
44+
const char *key; /* key that is hashed */
45+
size_t keyl; /* length of key */
46+
void *stuff; /* stuff stored in this hitem */
47+
size_t hval; /* hash value */
48+
struct hitem *next; /* next hitem in list */
5149
};
5250
typedef struct hitem hitem;
5351

5452

5553
struct htab
5654
{
5755
struct hitem **table; /* hash table, array of size 2^logsize */
58-
word logsize; /* log of size of table */
59-
size_t mask; /* (hashval & mask) is position in table */
60-
ub4 count; /* how many items in this hash table so far? */
61-
ub4 apos; /* position in the array */
56+
int logsize; /* log of size of table */
57+
size_t mask; /* (hashval & mask) is position in table */
58+
size_t count; /* how many items in this hash table so far? */
59+
size_t apos; /* position in the array */
6260
struct hitem *ipos; /* current item in the array */
6361
struct reroot *space; /* space for the hitems */
64-
ub4 bcount; /* # hitems useable in current block */
62+
size_t bcount; /* # hitems useable in current block */
6563
};
6664
typedef struct htab htab;
6765

@@ -77,7 +75,7 @@ typedef struct htab htab;
7775
RETURNS:
7876
the new table
7977
*/
80-
extern htab *hcreate(/*_ word logsize _*/);
78+
extern htab *hcreate(int logsize);
8179

8280

8381
/* hdestroy - destroy a hash table
@@ -88,16 +86,16 @@ extern htab *hcreate(/*_ word logsize _*/);
8886
RETURNS:
8987
nothing
9088
*/
91-
extern void hdestroy(/*_ htab *t _*/);
89+
extern void hdestroy(htab *t);
9290

9391

9492
/* hcount, hkey, hkeyl, hstuff
9593
ARGUMENTS:
9694
t - the hash table
9795
RETURNS:
98-
hcount - (ub4) The number of items in the hash table
99-
hkey - (ub1 *) key for the current item
100-
hkeyl - (ub4) key length for the current item
96+
hcount - (size_t) The number of items in the hash table
97+
hkey - (const char *) key for the current item
98+
hkeyl - (size_t) key length for the current item
10199
hstuff - (void *) stuff for the current item
102100
NOTE:
103101
The current position always has an item as long as there
@@ -121,7 +119,7 @@ extern void hdestroy(/*_ htab *t _*/);
121119
TRUE if the item exists, FALSE if it does not.
122120
If the item exists, moves the current position to that item.
123121
*/
124-
extern word hfind(/*_ htab *t, ub1 *key, ub4 keyl _*/);
122+
extern int hfind(htab *t, const char *key, size_t keyl);
125123

126124

127125
/* hadd - add a new item to the hash table
@@ -134,7 +132,7 @@ extern word hfind(/*_ htab *t, ub1 *key, ub4 keyl _*/);
134132
RETURNS:
135133
FALSE if the operation fails (because that key is already there).
136134
*/
137-
extern word hadd(/*_ htab *t, ub1 *key, ub4 keyl, void *stuff _*/);
135+
extern int hadd(htab *t, const char *key, size_t keyl, void *stuff);
138136

139137

140138
/* hdel - delete the item at the current position
@@ -153,7 +151,7 @@ extern word hadd(/*_ htab *t, ub1 *key, ub4 keyl, void *stuff _*/);
153151
hdel(tab);
154152
}
155153
*/
156-
extern word hdel(/* htab *t */);
154+
extern int hdel(htab *t);
157155

158156

159157
/* hfirst - move position to the first item in the table
@@ -163,7 +161,7 @@ extern word hdel(/* htab *t */);
163161
FALSE if there is no current item (meaning the table is empty)
164162
NOTE:
165163
*/
166-
extern word hfirst(/*_ htab *t _*/);
164+
extern int hfirst(htab *t);
167165

168166

169167
/* hnext - move position to the next item in the table
@@ -193,7 +191,7 @@ extern word hfirst(/*_ htab *t _*/);
193191
NOTE:
194192
This is private to hashtab; do not use it externally.
195193
*/
196-
extern word hnbucket(/*_ htab *t _*/);
194+
extern int hnbucket(htab *t);
197195

198196

199197
/* hstat - print statistics about the hash table
@@ -218,4 +216,4 @@ extern void hstat(/*_ htab *t _*/);
218216
}
219217
#endif
220218

221-
#endif /* HASHTAB */
219+
#endif /* HASHTAB_H */

ee/erl/include/lookupa.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ Source is http://burtleburtle.net/bob/c/lookupa.h
77
------------------------------------------------------------------------------
88
*/
99

10-
#ifndef STANDARD
11-
#include "standard.h"
12-
#endif
10+
#ifndef LOOKUPA_H
11+
#define LOOKUPA_H
1312

14-
#ifndef LOOKUPA
15-
#define LOOKUPA
13+
#include "standard.h"
1614

1715
#ifdef __cplusplus
1816
extern "C" {
1917
#endif
2018

2119
#define CHECKSTATE 8
22-
#define hashsize(n) ((ub4)1<<(n))
20+
#define hashsize(n) ((size_t)1<<(n))
2321
#define hashmask(n) (hashsize(n)-1)
2422

25-
extern ub4 lookup(/*_ ub1 *k, ub4 length, ub4 level _*/);
26-
extern void checksum(/*_ ub1 *k, ub4 length, ub4 *state _*/);
23+
extern uint32_t lookup(const char *k, size_t length, uint32_t level);
24+
extern void checksum(const char *k, size_t length, uint32_t *state);
2725

2826
#ifdef __cplusplus
2927
}

ee/erl/include/recycle.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ This also decreases memory fragmentation, and freeing all structures
1313
--------------------------------------------------------------------
1414
*/
1515

16-
#ifndef STANDARD
17-
#include "standard.h"
18-
#endif
16+
#ifndef RECYCLE_H
17+
#define RECYCLE_H
1918

20-
#ifndef RECYCLE
21-
#define RECYCLE
19+
#include "standard.h"
2220

2321
#ifdef __cplusplus
2422
extern "C" {
@@ -39,21 +37,21 @@ struct reroot
3937
struct recycle *trash; /* list of deleted items */
4038
size_t size; /* size of an item */
4139
size_t logsize; /* log_2 of number of items in a block */
42-
word numleft; /* number of bytes left in this block */
40+
int numleft; /* number of bytes left in this block */
4341
};
4442
typedef struct reroot reroot;
4543

4644
/* make a new recycling root */
47-
extern reroot *remkroot(/*_ size_t mysize _*/);
45+
extern reroot *remkroot(size_t mysize);
4846

4947
/* free a recycling root and all the items it has made */
50-
extern void refree(/*_ struct reroot *r _*/);
48+
extern void refree(struct reroot *r);
5149

5250
/* get a new (cleared) item from the root */
5351
#define renew(r) ((r)->numleft ? \
5452
(((char *)((r)->list+1))+((r)->numleft-=(r)->size)) : renewx(r))
5553

56-
extern char *renewx(/*_ struct reroot *r _*/);
54+
extern char *renewx(struct reroot *r);
5755

5856
/* delete an item; let the root recycle it */
5957
/* void redel(/o_ struct reroot *r, struct recycle *item _o/); */
@@ -64,10 +62,10 @@ extern char *renewx(/*_ struct reroot *r _*/);
6462

6563
/* malloc, but exit program if no joy */
6664
/* use plain free() to free memory allocated by remalloc() */
67-
extern char *remalloc(/*_ size_t len _*/);
65+
extern char *remalloc(size_t len);
6866

6967
#ifdef __cplusplus
7068
}
7169
#endif
7270

73-
#endif /* RECYCLE */
71+
#endif /* RECYCLE_H */

ee/erl/include/standard.h

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
Standard definitions and types, Bob Jenkins
44
------------------------------------------------------------------------------
55
*/
6-
#ifndef STANDARD
7-
# define STANDARD
8-
# ifndef STDIO
9-
# include <stdio.h>
10-
# define STDIO
11-
# endif
12-
# ifndef STDDEF
13-
# include <stddef.h>
14-
# define STDDEF
15-
# endif
6+
#ifndef STANDARD_H
7+
#define STANDARD_H
8+
9+
#include <stddef.h>
10+
#include <stdint.h>
11+
#include <stdbool.h>
12+
1613
#define UB8MAXVAL 0xffffffffffffffffLL
1714
#define UB8BITS 64
1815
#define SB8MAXVAL 0x7fffffffffffffffLL
@@ -25,45 +22,7 @@ Standard definitions and types, Bob Jenkins
2522
#define UB1MAXVAL 0xff
2623
#define UB1BITS 8
2724
#define SB1MAXVAL 0x7f
28-
#ifdef _EE
29-
#include <tamtypes.h>
30-
typedef u64 ub8;
31-
typedef s64 sb8;
32-
typedef u32 ub4;
33-
typedef s32 sb4;
34-
typedef u16 ub2;
35-
typedef s16 sb2;
36-
typedef u8 ub1;
37-
typedef s8 sb1;
38-
#else
39-
typedef unsigned long long ub8;
40-
typedef signed long long sb8;
41-
typedef unsigned long int ub4; /* unsigned 4-byte quantities */
42-
typedef signed long int sb4;
43-
typedef unsigned short int ub2;
44-
typedef signed short int sb2;
45-
typedef unsigned char ub1;
46-
typedef signed char sb1; /* signed 1-byte quantities */
47-
#endif
48-
typedef int word; /* fastest type available */
4925

50-
#define bis(target,mask) ((target) |= (mask))
51-
#define bic(target,mask) ((target) &= ~(mask))
52-
#define bit(target,mask) ((target) & (mask))
53-
#ifndef min
54-
# define min(a,b) (((a)<(b)) ? (a) : (b))
55-
#endif /* min */
56-
#ifndef max
57-
# define max(a,b) (((a)<(b)) ? (b) : (a))
58-
#endif /* max */
59-
#ifndef align
60-
# define align(a) (((ub4)a+(sizeof(void *)-1))&(~(sizeof(void *)-1)))
61-
#endif /* align */
62-
#ifndef abs
63-
# define abs(a) (((a)>0) ? (a) : -(a))
64-
#endif
65-
#define TRUE 1
66-
#define FALSE 0
67-
#define SUCCESS 0 /* 1 on VAX */
26+
#define align(a) (((uint32_t)a+(sizeof(void *)-1))&(~(sizeof(void *)-1)))
6827

69-
#endif /* STANDARD */
28+
#endif /* STANDARD_H */

ee/erl/src/erl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static void add_loosy(struct erl_record_t * erl, u8 * reloc, int type, const cha
512512
l->next = hstuff(loosy_relocs);
513513
hstuff(loosy_relocs) = l;
514514
} else {
515-
hkey(loosy_relocs) = (ub1 *)strdup(symbol);
515+
hkey(loosy_relocs) = strdup(symbol);
516516
}
517517
}
518518

@@ -530,7 +530,7 @@ static int fix_loosy(struct erl_record_t * provider, const char * symbol, u32 ad
530530
count++;
531531
}
532532
r_destroy_loosy(hstuff(loosy_relocs));
533-
free(hkey(loosy_relocs));
533+
free((void *)hkey(loosy_relocs));
534534
hdel(loosy_relocs);
535535
}
536536

@@ -1177,7 +1177,7 @@ void erl_flush_symbols(struct erl_record_t * erl) {
11771177

11781178
if (hfirst(erl->symbols)) do {
11791179
destroy_symbol((struct symbol_t *) hstuff(erl->symbols));
1180-
free(hkey(erl->symbols));
1180+
free((void *)hkey(erl->symbols));
11811181
hdel(erl->symbols);
11821182
} while (hcount(erl->symbols));
11831183

0 commit comments

Comments
 (0)