summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2018-05-30 09:45:21 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-30 09:45:21 (GMT)
commitb8d5da4c426b21ca0e56fc1cd6f75b49c0668e95 (patch) (side-by-side diff)
tree26cbb1b04cd9febcdd37237c9576ea1c5eff3926 /src
parenta14a6881538229cd938282bd56c7f0d12a089be6 (diff)
downloadgdbm-b8d5da4c426b21ca0e56fc1cd6f75b49c0668e95.tar.gz
gdbm-b8d5da4c426b21ca0e56fc1cd6f75b49c0668e95.tar.bz2
Namespace cleanup
Rename: __read to gdbm_file_read __write to gdbm_file_write __lseek to gdbm_file_seek __fsync to gdbm_file_sync
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/bucket.c6
-rw-r--r--src/falloc.c4
-rw-r--r--src/findkey.c2
-rw-r--r--src/fullio.c4
-rw-r--r--src/gdbmclose.c2
-rw-r--r--src/gdbmopen.c4
-rw-r--r--src/gdbmsetopt.c2
-rw-r--r--src/gdbmstore.c2
-rw-r--r--src/gdbmsync.c2
-rw-r--r--src/gdbmtool.c4
-rw-r--r--src/proto.h20
-rw-r--r--src/recover.c2
-rw-r--r--src/systems.h16
-rw-r--r--src/update.c8
14 files changed, 41 insertions, 37 deletions
diff --git a/src/bucket.c b/src/bucket.c
index 2289594..e17019c 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -109,13 +109,13 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
}
}
/* It is not in the cache, read it from the disk. */
/* Position the file pointer */
- file_pos = __lseek (dbf, bucket_adr, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, bucket_adr, SEEK_SET);
if (file_pos != bucket_adr)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
@@ -184,13 +184,13 @@ _gdbm_read_bucket_at (GDBM_FILE dbf, off_t off, hash_bucket *bucket,
memcpy (bucket, dbf->bucket_cache[i].ca_bucket, size);
return 0;
}
}
/* Read the bucket. */
- file_pos = __lseek (dbf, off, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, off, SEEK_SET);
if (file_pos != off)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
return -1;
}
if (_gdbm_full_read (dbf, bucket, size))
@@ -429,13 +429,13 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
int
_gdbm_write_bucket (GDBM_FILE dbf, cache_elem *ca_entry)
{
int rc;
off_t file_pos; /* The return value for lseek. */
- file_pos = __lseek (dbf, ca_entry->ca_adr, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, ca_entry->ca_adr, SEEK_SET);
if (file_pos != ca_entry->ca_adr)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
diff --git a/src/falloc.c b/src/falloc.c
index 13ee0ed..2f21ebe 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -188,13 +188,13 @@ pop_avail_block (GDBM_FILE dbf)
GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE);
_gdbm_fatal (dbf, _("malloc failed"));
return -1;
}
/* Read the block. */
- file_pos = __lseek (dbf, new_el.av_adr, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, new_el.av_adr, SEEK_SET);
if (file_pos != new_el.av_adr)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
free (new_blk);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
@@ -318,13 +318,13 @@ push_avail_block (GDBM_FILE dbf)
/* Free the unneeded space. */
new_loc.av_adr += av_size;
new_loc.av_size -= av_size;
_gdbm_free (dbf, new_loc.av_adr, new_loc.av_size);
/* Update the disk. */
- file_pos = __lseek (dbf, av_adr, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, av_adr, SEEK_SET);
if (file_pos != av_adr)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
diff --git a/src/findkey.c b/src/findkey.c
index 9bb4553..9c8fd71 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -80,13 +80,13 @@ _gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
GDBM_SET_ERRNO2 (dbf, GDBM_MALLOC_ERROR, FALSE, GDBM_DEBUG_LOOKUP);
_gdbm_fatal (dbf, _("malloc error"));
return NULL;
}
/* Read into the cache. */
- file_pos = __lseek (dbf, dbf->bucket->h_table[elem_loc].data_pointer,
+ file_pos = gdbm_file_seek (dbf, dbf->bucket->h_table[elem_loc].data_pointer,
SEEK_SET);
if (file_pos != dbf->bucket->h_table[elem_loc].data_pointer)
{
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_LOOKUP);
_gdbm_fatal (dbf, _("lseek error"));
return NULL;
diff --git a/src/fullio.c b/src/fullio.c
index bdb51cb..84eea60 100644
--- a/src/fullio.c
+++ b/src/fullio.c
@@ -24,13 +24,13 @@
int
_gdbm_full_read (GDBM_FILE dbf, void *buffer, size_t size)
{
char *ptr = buffer;
while (size)
{
- ssize_t rdbytes = __read (dbf, ptr, size);
+ ssize_t rdbytes = gdbm_file_read (dbf, ptr, size);
if (rdbytes == -1)
{
if (errno == EINTR)
continue;
if (gdbm_last_errno (dbf) == GDBM_NO_ERROR)
GDBM_SET_ERRNO (dbf, GDBM_FILE_READ_ERROR, FALSE);
@@ -52,13 +52,13 @@ _gdbm_full_read (GDBM_FILE dbf, void *buffer, size_t size)
int
_gdbm_full_write (GDBM_FILE dbf, void *buffer, size_t size)
{
char *ptr = buffer;
while (size)
{
- ssize_t wrbytes = __write (dbf, ptr, size);
+ ssize_t wrbytes = gdbm_file_write (dbf, ptr, size);
if (wrbytes == -1)
{
if (errno == EINTR)
continue;
if (gdbm_last_errno (dbf) == GDBM_NO_ERROR)
GDBM_SET_ERRNO (dbf, GDBM_FILE_WRITE_ERROR, TRUE);
diff --git a/src/gdbmclose.c b/src/gdbmclose.c
index c638183..ead9187 100644
--- a/src/gdbmclose.c
+++ b/src/gdbmclose.c
@@ -32,13 +32,13 @@ gdbm_close (GDBM_FILE dbf)
int index; /* For freeing the bucket cache. */
if (dbf->desc != -1)
{
/* Make sure the database is all on disk. */
if (dbf->read_write != GDBM_READER)
- __fsync (dbf);
+ gdbm_file_sync (dbf);
/* Close the file and free all malloced memory. */
#if HAVE_MMAP
_gdbm_mapped_unmap (dbf);
#endif
if (dbf->file_locking)
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index 22e7ca6..53d62a4 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -426,13 +426,13 @@ gdbm_fd_open (int fd, const char *file_name, int block_size,
dbf->desc = -1;
SAVE_ERRNO (gdbm_close (dbf));
return NULL;
}
/* Wait for initial configuration to be written to disk. */
- __fsync (dbf);
+ gdbm_file_sync (dbf);
free (dbf->bucket);
}
else
{
/* This is an old database. Read in the information from the file
@@ -505,13 +505,13 @@ gdbm_fd_open (int fd, const char *file_name, int block_size,
gdbm_close (dbf);
GDBM_SET_ERRNO2 (NULL, GDBM_MALLOC_ERROR, FALSE, GDBM_DEBUG_OPEN);
return NULL;
}
/* Read the hash table directory. */
- file_pos = __lseek (dbf, dbf->header->dir, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, dbf->header->dir, SEEK_SET);
if (file_pos != dbf->header->dir)
{
if (!(flags & GDBM_CLOERROR))
dbf->desc = -1;
SAVE_ERRNO (gdbm_close (dbf));
GDBM_SET_ERRNO2 (NULL, GDBM_FILE_SEEK_ERROR, FALSE, GDBM_DEBUG_OPEN);
diff --git a/src/gdbmsetopt.c b/src/gdbmsetopt.c
index ca62290..69e244c 100644
--- a/src/gdbmsetopt.c
+++ b/src/gdbmsetopt.c
@@ -187,13 +187,13 @@ setopt_gdbm_setmmap (GDBM_FILE dbf, void *optval, int optlen)
if ((n = getbool (optval, optlen)) == -1)
{
GDBM_SET_ERRNO (dbf, GDBM_OPT_ILLEGAL, FALSE);
return -1;
}
- __fsync (dbf);
+ gdbm_file_sync (dbf);
if (n == dbf->memory_mapping)
return 0;
if (n)
{
if (_gdbm_mapped_init (dbf) == 0)
dbf->memory_mapping = TRUE;
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 6b498b2..b8a1e66 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -157,13 +157,13 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
/* Update current bucket data pointer and sizes. */
dbf->bucket->h_table[elem_loc].data_pointer = file_adr;
dbf->bucket->h_table[elem_loc].key_size = key.dsize;
dbf->bucket->h_table[elem_loc].data_size = content.dsize;
/* Write the data to the file. */
- file_pos = __lseek (dbf, file_adr, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, file_adr, SEEK_SET);
if (file_pos != file_adr)
{
GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
"%s: lseek: %s", dbf->name, strerror (errno));
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
_gdbm_fatal (dbf, _("lseek error"));
diff --git a/src/gdbmsync.c b/src/gdbmsync.c
index 10fbaad..5d94cbe 100644
--- a/src/gdbmsync.c
+++ b/src/gdbmsync.c
@@ -31,9 +31,9 @@ gdbm_sync (GDBM_FILE dbf)
GDBM_ASSERT_CONSISTENCY (dbf, );
/* Initialize the gdbm_errno variable. */
gdbm_set_errno (dbf, GDBM_NO_ERROR, FALSE);
/* Do the sync on the file. */
- __fsync (dbf);
+ gdbm_file_sync (dbf);
}
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 11b6f20..dbb7510 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -224,13 +224,13 @@ _gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
+ sizeof (avail_block));
av_stk = emalloc (size);
/* Traverse the stack. */
while (temp)
{
- if (__lseek (dbf, temp, SEEK_SET) != temp)
+ if (gdbm_file_seek (dbf, temp, SEEK_SET) != temp)
{
terror ("lseek: %s", strerror (errno));
break;
}
if (_gdbm_full_read (dbf, av_stk, size))
@@ -282,13 +282,13 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
+ sizeof (avail_block);
av_stk = emalloc (size);
/* Print the stack. */
while (temp)
{
- if (__lseek (dbf, temp, SEEK_SET) != temp)
+ if (gdbm_file_seek (dbf, temp, SEEK_SET) != temp)
{
terror ("lseek: %s", strerror (errno));
break;
}
if (_gdbm_full_read (dbf, av_stk, size))
diff --git a/src/proto.h b/src/proto.h
index 9592f52..563505f 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -80,7 +80,27 @@ int _gdbm_base64_decode (const unsigned char *input, size_t input_len,
int _gdbm_load (FILE *fp, GDBM_FILE *pdbf, unsigned long *line);
int _gdbm_dump (GDBM_FILE dbf, FILE *fp);
/* From recover.c */
int _gdbm_next_bucket_dir (GDBM_FILE dbf, int bucket_dir);
+/* I/O macros. */
+#if HAVE_MMAP
+# define gdbm_file_read(_dbf, _buf, _size) \
+ _gdbm_mapped_read(_dbf, _buf, _size)
+# define gdbm_file_write(_dbf, _buf, _size) \
+ _gdbm_mapped_write(_dbf, _buf, _size)
+# define gdbm_file_seek(_dbf, _off, _whn) \
+ _gdbm_mapped_lseek(_dbf, _off, _whn)
+# define gdbm_file_sync(_dbf) \
+ _gdbm_mapped_sync(_dbf)
+#else
+# define gdbm_file_read(_dbf, _buf, _size) read(_dbf->desc, _buf, _size)
+# define gdbm_file_write(_dbf, _buf, _size) write(_dbf->desc, _buf, _size)
+# define gdbm_file_seek(_dbf, _off, _whn) lseek(_dbf->desc, _off, _whn)
+# if HAVE_FSYNC
+# define gdbm_file_sync(_dbf) fsync(_dbf->desc)
+# else
+# define gdbm_file_sync(_dbf) { sync(); sync(); }
+# endif
+#endif
diff --git a/src/recover.c b/src/recover.c
index 074c76f..f6859ea 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -175,13 +175,13 @@ _gdbm_finish_transfer (GDBM_FILE dbf, GDBM_FILE new_dbf,
/* Re-initialize mapping if required */
if (dbf->memory_mapping)
_gdbm_mapped_init (dbf);
#endif
/* Make sure the new database is all on disk. */
- __fsync (dbf);
+ gdbm_file_sync (dbf);
/* Force the right stuff for a correct bucket cache. */
dbf->cache_entry = &dbf->bucket_cache[0];
return _gdbm_get_bucket (dbf, 0);
}
diff --git a/src/systems.h b/src/systems.h
index c678573..750aa51 100644
--- a/src/systems.h
+++ b/src/systems.h
@@ -60,23 +60,7 @@
#endif
#ifndef STDERR_FILENO
# define STDERR_FILENO 2
#endif
-/* I/O macros. */
-#if HAVE_MMAP
-# define __read(_dbf, _buf, _size) _gdbm_mapped_read(_dbf, _buf, _size)
-# define __write(_dbf, _buf, _size) _gdbm_mapped_write(_dbf, _buf, _size)
-# define __lseek(_dbf, _off, _whn) _gdbm_mapped_lseek(_dbf, _off, _whn)
-# define __fsync(_dbf) _gdbm_mapped_sync(_dbf)
-#else
-# define __read(_dbf, _buf, _size) read(_dbf->desc, _buf, _size)
-# define __write(_dbf, _buf, _size) write(_dbf->desc, _buf, _size)
-# define __lseek(_dbf, _off, _whn) lseek(_dbf->desc, _off, _whn)
-# if HAVE_FSYNC
-# define __fsync(_dbf) fsync(_dbf->desc)
-# else
-# define __fsync(_dbf) { sync(); sync(); }
-# endif
-#endif
diff --git a/src/update.c b/src/update.c
index f4b8b78..e3ee717 100644
--- a/src/update.c
+++ b/src/update.c
@@ -27,13 +27,13 @@
static int
write_header (GDBM_FILE dbf)
{
off_t file_pos; /* Return value for lseek. */
int rc;
- file_pos = __lseek (dbf, 0L, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, 0L, SEEK_SET);
if (file_pos != 0)
{
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
@@ -47,13 +47,13 @@ write_header (GDBM_FILE dbf)
dbf->name, gdbm_db_strerror (dbf));
return -1;
}
/* Sync the file if fast_write is FALSE. */
if (dbf->fast_write == FALSE)
- __fsync (dbf);
+ gdbm_file_sync (dbf);
return 0;
}
/* After all changes have been made in memory, we now write them
@@ -91,13 +91,13 @@ _gdbm_end_update (GDBM_FILE dbf)
dbf->second_changed = FALSE;
}
/* Write the directory. */
if (dbf->directory_changed)
{
- file_pos = __lseek (dbf, dbf->header->dir, SEEK_SET);
+ file_pos = gdbm_file_seek (dbf, dbf->header->dir, SEEK_SET);
if (file_pos != dbf->header->dir)
{
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
@@ -111,13 +111,13 @@ _gdbm_end_update (GDBM_FILE dbf)
_gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
dbf->directory_changed = FALSE;
if (!dbf->header_changed && dbf->fast_write == FALSE)
- __fsync (dbf);
+ gdbm_file_sync (dbf);
}
/* Final write of the header. */
if (dbf->header_changed)
{
if (write_header (dbf))

Return to:

Send suggestions and report system problems to the System administrator.