1 // Copyright 2019 The Android Open Source Project 2 // 3 // This software is licensed under the terms of the GNU General Public 4 // License version 2, as published by the Free Software Foundation, and 5 // may be copied, distributed, and modified under those terms. 6 // 7 // This program is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 // GNU General Public License for more details. 11 12 #ifndef _AEMU_SYS_STAT_H_ 13 #define _AEMU_SYS_STAT_H_ 14 15 16 // This sets up a series of compatibility defines that enable compilation 17 // of qemu on windows with clang-cl. 18 #include_next <sys/stat.h> 19 20 #define fstat64 _fstat64 21 #define stat _stati64 22 #define S_IRUSR _S_IREAD 23 #define S_IWUSR _S_IWRITE 24 25 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 26 27 28 /* 29 * File type macros. Note that block devices, sockets and links cannot be 30 * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are 31 * only defined for compatibility. These macros should always return false 32 * on Windows. 33 */ 34 #if !defined(S_ISFIFO) 35 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) 36 #endif 37 #if !defined(S_ISDIR) 38 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 39 #endif 40 #if !defined(S_ISREG) 41 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 42 #endif 43 #if !defined(S_ISLNK) 44 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 45 #endif 46 #if !defined(S_ISSOCK) 47 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) 48 #endif 49 #if !defined(S_ISCHR) 50 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) 51 #endif 52 #if !defined(S_ISBLK) 53 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) 54 #endif 55 56 57 /* File type and permission flags for stat(), general mask */ 58 #if !defined(S_IFMT) 59 # define S_IFMT _S_IFMT 60 #endif 61 62 /* Directory bit */ 63 #if !defined(S_IFDIR) 64 # define S_IFDIR _S_IFDIR 65 #endif 66 67 /* Character device bit */ 68 #if !defined(S_IFCHR) 69 # define S_IFCHR _S_IFCHR 70 #endif 71 72 /* Pipe bit */ 73 #if !defined(S_IFFIFO) 74 # define S_IFFIFO _S_IFFIFO 75 #endif 76 77 /* Regular file bit */ 78 #if !defined(S_IFREG) 79 # define S_IFREG _S_IFREG 80 #endif 81 82 /* Read permission */ 83 #if !defined(S_IREAD) 84 # define S_IREAD _S_IREAD 85 #endif 86 87 /* Write permission */ 88 #if !defined(S_IWRITE) 89 # define S_IWRITE _S_IWRITE 90 #endif 91 92 /* Execute permission */ 93 #if !defined(S_IEXEC) 94 # define S_IEXEC _S_IEXEC 95 #endif 96 97 /* Pipe */ 98 #if !defined(S_IFIFO) 99 # define S_IFIFO _S_IFIFO 100 #endif 101 102 /* Block device */ 103 #if !defined(S_IFBLK) 104 # define S_IFBLK 0 105 #endif 106 107 /* Link */ 108 #if !defined(S_IFLNK) 109 # define S_IFLNK 0 110 #endif 111 112 /* Socket */ 113 #if !defined(S_IFSOCK) 114 # define S_IFSOCK 0 115 #endif 116 117 /* Read user permission */ 118 #if !defined(S_IRUSR) 119 # define S_IRUSR S_IREAD 120 #endif 121 122 /* Write user permission */ 123 #if !defined(S_IWUSR) 124 # define S_IWUSR S_IWRITE 125 #endif 126 127 /* Execute user permission */ 128 #if !defined(S_IXUSR) 129 # define S_IXUSR 0 130 #endif 131 132 /* Read group permission */ 133 #if !defined(S_IRGRP) 134 # define S_IRGRP 0 135 #endif 136 137 /* Write group permission */ 138 #if !defined(S_IWGRP) 139 # define S_IWGRP 0 140 #endif 141 142 /* Execute group permission */ 143 #if !defined(S_IXGRP) 144 # define S_IXGRP 0 145 #endif 146 147 /* Read others permission */ 148 #if !defined(S_IROTH) 149 # define S_IROTH 0 150 #endif 151 152 /* Write others permission */ 153 #if !defined(S_IWOTH) 154 # define S_IWOTH 0 155 #endif 156 157 /* Execute others permission */ 158 #if !defined(S_IXOTH) 159 # define S_IXOTH 0 160 #endif 161 162 #endif /* Not _AEMU_SYS_STAT_H_ */