summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2022-06-08 11:51:07 +1000
committerTony Cook <tony@develop-help.com>2022-06-09 09:33:01 +1000
commitbbaab2c3cd9375c5ab28059cbb70d4a8c77e77fa (patch)
treeb72410ce972cb6a1dc03ca0d1e1d79218b82e20d
parentbbe73871dcd2907ceb9917083763f810f9879b85 (diff)
downloadperl-bbaab2c3cd9375c5ab28059cbb70d4a8c77e77fa.tar.gz
use Off_t for file offsets in sdbm.c
On Win32 long is only 32-bits (even for x86_64), which meant file sizes were limited to 2GB. This successfully runs the example code, and can successfully read all the keys back. I didn't add a test, since creating a 2GB (or 8GB for the issue test) would be unfriendly.
-rw-r--r--ext/SDBM_File/SDBM_File.pm2
-rw-r--r--ext/SDBM_File/sdbm.c11
2 files changed, 9 insertions, 4 deletions
diff --git a/ext/SDBM_File/SDBM_File.pm b/ext/SDBM_File/SDBM_File.pm
index 30e380a6bb..bfaad3b4d6 100644
--- a/ext/SDBM_File/SDBM_File.pm
+++ b/ext/SDBM_File/SDBM_File.pm
@@ -7,7 +7,7 @@ require Tie::Hash;
require XSLoader;
our @ISA = qw(Tie::Hash);
-our $VERSION = "1.15";
+our $VERSION = "1.16";
our @EXPORT_OK = qw(PAGFEXT DIRFEXT PAIRMAX);
use Exporter "import";
diff --git a/ext/SDBM_File/sdbm.c b/ext/SDBM_File/sdbm.c
index 7cf07d7599..c27c535da0 100644
--- a/ext/SDBM_File/sdbm.c
+++ b/ext/SDBM_File/sdbm.c
@@ -43,6 +43,11 @@ extern Free_t free(Malloc_t);
const datum nullitem = {0, 0};
+#ifdef WIN32
+# undef lseek
+# define lseek _lseeki64
+#endif
+
/*
* forward
*/
@@ -59,8 +64,8 @@ static int makroom(DBM *, long, int);
#define exhash(item) sdbm_hash((item).dptr, (item).dsize)
#define ioerr(db) ((db)->flags |= DBM_IOERR)
-#define OFF_PAG(off) (long) (off) * PBLKSIZ
-#define OFF_DIR(off) (long) (off) * DBLKSIZ
+#define OFF_PAG(off) (Off_t) (off) * PBLKSIZ
+#define OFF_DIR(off) (Off_t) (off) * DBLKSIZ
static const long masks[] = {
000000000000, 000000000001, 000000000003, 000000000007,
@@ -291,7 +296,7 @@ makroom(DBM *db, long int hash, int need)
char twin[PBLKSIZ];
#if defined(DOSISH) || defined(WIN32)
char zer[PBLKSIZ];
- long oldtail;
+ Off_t oldtail;
#endif
char *pag = db->pagbuf;
char *New = twin;