1 // Copyright (C) 2010-2020 Joel Rosdahl
2 //
3 // This program is free software; you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation; either version 3 of the License, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITHOUT
9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 //
13 // You should have received a copy of the GNU General Public License along with
14 // this program; if not, write to the Free Software Foundation, Inc., 51
15 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef CCACHE_SYSTEM_H
18 #define CCACHE_SYSTEM_H
19 
20 #include "config.h"
21 
22 #ifdef __clang__
23 #pragma clang diagnostic push
24 #if __has_warning("-Wreserved-id-macro")
25 #pragma clang diagnostic ignored "-Wreserved-id-macro"
26 #endif
27 #endif
28 #ifndef _FILE_OFFSET_BITS
29 #define _FILE_OFFSET_BITS 64
30 #endif
31 #ifdef __clang__
32 #pragma clang diagnostic pop
33 #endif
34 
35 #include <sys/file.h>
36 #ifdef HAVE_SYS_MMAN_H
37 #include <sys/mman.h>
38 #endif
39 #include <sys/stat.h>
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_WAIT_H
42 #include <sys/wait.h>
43 #endif
44 
45 #include <assert.h>
46 #include <ctype.h>
47 #include <dirent.h>
48 #include <errno.h>
49 #include <fcntl.h>
50 #include <inttypes.h>
51 #include <limits.h>
52 #include <signal.h>
53 #include <stdarg.h>
54 #include <stdbool.h>
55 #include <stddef.h>
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <strings.h>
60 #include <time.h>
61 #include <unistd.h>
62 #include <utime.h>
63 
64 // AIX/PASE does not properly define usleep within its headers. However, the
65 // function is available in libc.a. This extern define ensures that it is
66 // usable within the ccache code base.
67 #ifdef _AIX
68 extern int usleep(useconds_t);
69 #endif
70 
71 extern char **environ;
72 
73 #ifndef ESTALE
74 #define ESTALE -1
75 #endif
76 
77 #if !HAVE_VSNPRINTF
78   int rpl_vsnprintf(char *, size_t, const char *, va_list);
79   #define vsnprintf rpl_vsnprintf
80 #endif
81 #if !HAVE_SNPRINTF
82   int rpl_snprintf(char *, size_t, const char *, ...);
83   #define snprintf rpl_snprintf
84 #endif
85 #if !HAVE_VASPRINTF
86   int rpl_vasprintf(char **, const char *, va_list);
87   #define vasprintf rpl_vasprintf
88 #endif
89 #if !HAVE_ASPRINTF
90   int rpl_asprintf(char **, const char *, ...);
91   #define asprintf rpl_asprintf
92 #endif
93 
94 #endif // CCACHE_SYSTEM_H
95