From: Matt Birkholz Date: Tue, 5 Jun 2018 06:51:13 +0000 (-0700) Subject: gdbm: Accommodate 1.14 (in Ubuntu 18.04) but disable file locking. X-Git-Tag: mit-scheme-pucked-x11-0.3.1~6^2~23 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b95c33cc4a0b90ee01ebbb83f7c6fae94e733c49;p=mit-scheme.git gdbm: Accommodate 1.14 (in Ubuntu 18.04) but disable file locking. --- diff --git a/src/gdbm/gdbm-adapter.c b/src/gdbm/gdbm-adapter.c index 840bf4080..0c94b1d16 100644 --- a/src/gdbm/gdbm-adapter.c +++ b/src/gdbm/gdbm-adapter.c @@ -67,7 +67,7 @@ alloc_gdbm_content (gdbm_args * args, int size) return (bytes); } -extern char * +extern const char * get_gdbm_version (void) { return (gdbm_version); @@ -81,26 +81,38 @@ fatal_error (const char * msg) error_external_return (); } +#ifdef GDBM_VERSION_MAJOR +# if GDBM_VERSION_MAJOR > 1 +# define GDBM_NEED_NOLOCK 1 +# elif GDBM_VERSION_MAJOR == 1 && GDBM_VERSION_MINOR >= 13 +# define GDBM_NEED_NOLOCK 1 +# endif +#endif + extern gdbm_args * do_gdbm_open (char * name, int block_size, int read_write, int mode) { gdbm_args *args = (gdbm_args *) malloc (sizeof (gdbm_args)); if (!args) return (args); +#ifdef GDBM_NEED_NOLOCK + read_write |= GDBM_NOLOCK; +#endif + args->key.dsize = 0; args->key.dptr = NULL; args->key_allocation = 0; args->content.dsize = 0; args->content.dptr = NULL; args->content_allocation = 0; - args->gdbm_errno = 0; - args->sys_errno = 0; + args->errno_gdbm = 0; + args->errno_sys = 0; args->dbf = gdbm_open (name, block_size, read_write, mode, &fatal_error); if (args->dbf == NULL) { - args->gdbm_errno = gdbm_errno; - args->sys_errno = errno; + args->errno_gdbm = gdbm_errno; + args->errno_sys = errno; } return (args); } @@ -122,8 +134,8 @@ do_gdbm_store (gdbm_args * args, int flag) int ret = gdbm_store (args->dbf, args->key, args->content, flag); if (ret == -1) { - args->gdbm_errno = gdbm_errno; - args->sys_errno = errno; + args->errno_gdbm = gdbm_errno; + args->errno_sys = errno; } return (ret); } @@ -180,8 +192,8 @@ do_gdbm_reorganize (gdbm_args * args) int ret = gdbm_reorganize (args->dbf); if (ret) { - args->gdbm_errno = gdbm_errno; - args->sys_errno = errno; + args->errno_gdbm = gdbm_errno; + args->errno_sys = errno; } return (ret); } @@ -198,8 +210,8 @@ do_gdbm_setopt (gdbm_args * args, int option, int value) int ret = gdbm_setopt (args->dbf, option, &value, sizeof (int)); if (ret) { - args->gdbm_errno = gdbm_errno; - args->sys_errno = errno; + args->errno_gdbm = gdbm_errno; + args->errno_sys = errno; } return (ret); } diff --git a/src/gdbm/gdbm-shim.h b/src/gdbm/gdbm-shim.h index 480099336..0353eebab 100644 --- a/src/gdbm/gdbm-shim.h +++ b/src/gdbm/gdbm-shim.h @@ -33,8 +33,8 @@ USA. typedef struct gdbm_args { GDBM_FILE dbf; - gdbm_error gdbm_errno; - int sys_errno; + gdbm_error errno_gdbm; + int errno_sys; datum key, content; int key_allocation, content_allocation; } gdbm_args; @@ -54,4 +54,4 @@ extern int do_gdbm_nextkey (gdbm_args * args); extern int do_gdbm_reorganize (gdbm_args * args); extern void do_gdbm_sync (gdbm_args * args); extern int do_gdbm_setopt (gdbm_args * args, int option, int value); -extern char * get_gdbm_version (void); +extern const char * get_gdbm_version (void); diff --git a/src/gdbm/gdbm.cdecl b/src/gdbm/gdbm.cdecl index 01c02b937..d357052b8 100644 --- a/src/gdbm/gdbm.cdecl +++ b/src/gdbm/gdbm.cdecl @@ -56,8 +56,8 @@ USA. (typedef gdbm_args (struct (dbf GDBM_FILE) - (gdbm_errno int) - (sys_errno int) + (errno_gdbm int) + (errno_sys int) (key datum) (content datum))) @@ -77,10 +77,10 @@ USA. (extern int do_gdbm_nextkey (args (* gdbm_args))) (extern int do_gdbm_reorganize (args (* gdbm_args))) (extern void do_gdbm_sync (args (* gdbm_args))) -(extern (* char) gdbm_strerror (errnum int)) -(extern (* char) strerror (errnum int)) +(extern (* (const char)) gdbm_strerror (errnum int)) +(extern (* (const char)) strerror (errnum int)) (extern int do_gdbm_setopt (args (* gdbm_args)) (option int) (value int)) -(extern (* char) get_gdbm_version) +(extern (* (const char)) get_gdbm_version) (enum (GDBM_NO_ERROR) (GDBM_MALLOC_ERROR) diff --git a/src/gdbm/gdbm.scm b/src/gdbm/gdbm.scm index 7713d5fa1..243dd0ec0 100644 --- a/src/gdbm/gdbm.scm +++ b/src/gdbm/gdbm.scm @@ -322,8 +322,8 @@ USA. (define (gdbm-error gdbf msg) (let ((args (gdbf-args gdbf))) (error (string-append msg " failed:") - (gdbm-strerror (C-> args "gdbm_args gdbm_errno")) - (strerror (C-> args "gdbm_args sys_errno"))))) + (gdbm-strerror (C-> args "gdbm_args errno_gdbm")) + (strerror (C-> args "gdbm_args errno_sys"))))) (define (gdbf-args-put-key! args key) (let ((bytes (->bytes key)))