1 /* systems.h - Most of the system dependant code and defines are here. */ 2 3 /* This file is part of GDBM, the GNU data base manager. 4 Copyright (C) 1990-2021 Free Software Foundation, Inc. 5 6 GDBM is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 GDBM is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ 18 19 /* Include all system headers first. */ 20 #include <sys/types.h> 21 #include <stdio.h> 22 #include <stddef.h> 23 #if HAVE_SYS_FILE_H 24 # include <sys/file.h> 25 #endif 26 #include <sys/stat.h> 27 #include <stdlib.h> 28 #if HAVE_STRING_H 29 # include <string.h> 30 #else 31 # include <strings.h> 32 #endif 33 #include <unistd.h> 34 #include <fcntl.h> 35 #include <errno.h> 36 #include <limits.h> 37 38 #ifndef SEEK_SET 39 # define SEEK_SET 0 40 #endif 41 42 #ifndef O_CLOEXEC 43 # define O_CLOEXEC 0 44 #endif 45 46 /* Default block size. Some systems do not have blocksize in their 47 stat record. This code uses the BSD blocksize from stat. */ 48 49 #if HAVE_STRUCT_STAT_ST_BLKSIZE 50 # define STATBLKSIZE(st) (st).st_blksize 51 #else 52 # define STATBLKSIZE(st) 1024 53 #endif 54 55 #if ! HAVE_STRUCT_STAT_ST_MTIM 56 # if HAVE_STRUCT_STAT_ST_MTIMESPEC 57 # define st_mtim st_mtimespec 58 # define HAVE_STRUCT_STAT_ST_MTIM 1 59 # endif 60 #endif 61 62 #ifndef STDERR_FILENO 63 # define STDERR_FILENO 2 64 #endif 65 66 67