1
0
Files
irix-657m-src/eoe/lib/libdb/64-bit-clean.patch
2022-09-29 17:59:04 +03:00

81 lines
2.0 KiB
Diff

Hi Margo,
I missed this in my last email but...
The backward compatibility with hsearch code in berkeley-db 1.85
(hash/search.h hash/hsearch.c) is not 64-bit clean.
It assumes sizeof(DB *) == sizeof(int) in the hcreate return value.
I'm not sure how important this is, and how to solve this cleanly
but I thought on systems newer than the PDP-11 (sizeof(int) == 2)
and on modern systems supporting 64-bit like SGIs where you have
multiple programming models it may be slightly better to assume that
sizeof(int) == sizeof(long) than to assume that pointers are int size.
I admit this is ugly too but I feared using (void *) would break
the very same backward compatibility this was designed to solve ...
Anyway, here's my patch which fixes this for SGI systems at least,
(i.e. compiles with no truncation warnings on all three programming
models even though (sizeof(long) == 8) in cc -64)
if you see better solutions feel free to change this. Thanks, Ariel.
*** hsearch.c Tue Dec 24 17:59:31 1996
--- hsearch.c.orig Tue Dec 24 17:19:52 1996
***************
*** 49,55 ****
static DB *dbp = NULL;
static ENTRY retval;
! extern long
hcreate(nel)
u_int nel;
{
--- 49,55 ----
static DB *dbp = NULL;
static ENTRY retval;
! extern int
hcreate(nel)
u_int nel;
{
***************
*** 62,68 ****
info.hash = NULL;
info.lorder = 0;
dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
! return ((long)dbp);
}
extern ENTRY *
--- 62,68 ----
info.hash = NULL;
info.lorder = 0;
dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
! return ((int)dbp);
}
extern ENTRY *
*** search.h Tue Dec 24 17:59:05 1996
--- search.h.orig Tue Dec 24 17:25:10 1996
***************
*** 46,51 ****
FIND, ENTER
} ACTION;
! long hcreate __P((unsigned int));
void hdestroy __P((void));
ENTRY *hsearch __P((ENTRY, ACTION));
--- 46,51 ----
FIND, ENTER
} ACTION;
! int hcreate __P((unsigned int));
void hdestroy __P((void));
ENTRY *hsearch __P((ENTRY, ACTION));