1 /* systems.h - Most of the system dependant code and defines are here. */
3 /* This file is part of GDBM, the GNU data base manager.
4 Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation,
7 GDBM is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GDBM is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
20 /* Include all system headers first. */
21 #include <sys/types.h>
24 # include <sys/file.h>
45 /* Default block size. Some systems do not have blocksize in their
46 stat record. This code uses the BSD blocksize from stat. */
48 #if HAVE_STRUCT_STAT_ST_BLKSIZE
49 # define STATBLKSIZE file_stat.st_blksize
51 # define STATBLKSIZE 1024
54 /* Do we have ftruncate? */
56 # define TRUNCATE(dbf) ftruncate (dbf->desc, 0)
58 # define TRUNCATE(dbf) close( open (dbf->name, O_RDWR|O_TRUNC, mode));
62 # define STDERR_FILENO 2
67 # define __read(_dbf, _buf, _size) _gdbm_mapped_read(_dbf, _buf, _size)
68 # define __write(_dbf, _buf, _size) _gdbm_mapped_write(_dbf, _buf, _size)
69 # define __lseek(_dbf, _off, _whn) _gdbm_mapped_lseek(_dbf, _off, _whn)
70 # define __fsync(_dbf) _gdbm_mapped_sync(_dbf)
72 # define __read(_dbf, _buf, _size) read(_dbf->desc, _buf, _size)
73 # define __write(_dbf, _buf, _size) write(_dbf->desc, _buf, _size)
74 # define __lseek(_dbf, _off, _whn) lseek(_dbf->desc, _off, _whn)
76 # define __fsync(_dbf) fsync(_dbf->desc)
78 # define __fsync(_dbf) { sync(); sync(); }