1 /* $Id$ 2 * GNU C on many unix-like OS : compiler-specific declarations 3 * 4 * HUSKYLIB: common defines, types and functions for HUSKY 5 * 6 * This is part of The HUSKY Fidonet Software project: 7 * see http://husky.sourceforge.net for details 8 * 9 * 10 * HUSKYLIB is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * HUSKYLIB is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; see file COPYING. If not, write to the 22 * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * 24 * See also http://www.gnu.org, license may be found here. 25 */ 26 27 /* Declarations for UNIX clones: Linux, FreeBSD, SUNOS (Solaris), MacOS etc. */ 28 29 #ifndef HUSKY_UNIX_H 30 #define HUSKY_UNIX_H 31 32 #ifndef __GNUC__ 33 #error This file may be used only with GNU C ! 34 #endif 35 36 #ifndef __UNIX__ 37 #error This file may be used only with GNU C on unix-like OS ! 38 #endif 39 40 41 # define _stdc 42 # define _intr 43 # define _intcast 44 # define _veccast 45 # define _fast 46 # define _loadds 47 48 # define cdecl 49 # define pascal 50 # define near 51 # undef far 52 # define far 53 54 # define farread read 55 # define farwrite write 56 57 # define HAS_UTIME_H 1 58 59 # if (defined(__APPLE__) && defined(__MACH__)) || defined(__NetBSD__) || \ 60 defined(__FreeBSD__) || defined(_AIX) || defined(__SUN__) || \ 61 defined(__LINUX__) || defined(__osf__) || defined(__hpux) || \ 62 defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__QNXNTO__) 63 # define mymkdir(a) mkdir((a), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) 64 # else 65 # define mymkdir(a) __mkdir((a), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) 66 # endif 67 68 # if !defined(__SUN__) && !defined(__QNXNTO__) 69 # define tell(a) lseek((a),0,SEEK_CUR) 70 # endif 71 72 # ifndef stricmp 73 # define stricmp strcasecmp 74 # endif 75 # ifndef strnicmp 76 # define strnicmp strncasecmp 77 # endif 78 79 # if !defined(USG) 80 # define HAS_SYS_PARAM_H 81 # endif 82 83 # if ((defined(BSD) && (BSD >= 199103)) || (defined(__FreeBSD__) && (__FreeBSD__ == 4))) 84 /* now we can be sure we are on BSD 4.4 */ 85 # define HAS_SYS_MOUNT_H 86 # endif 87 88 /* FreeBSD >=5.x */ 89 # if (defined(__FreeBSD__) && (__FreeBSD__ >= 5)) 90 # define HAS_SYS_STATVFS_H 91 # endif 92 93 /* we are not on any BSD-like OS */ 94 /* list other UNIX os'es without getfree mechanism here */ 95 # if defined( __svr4__ ) || defined( __SVR4 ) 96 # define HAS_SYS_STATVFS_H 97 # endif 98 99 # if defined(__SPARC__) 100 # define HAS_SYS_STATVFS_H 101 # define HAS_SYS_STATFS_H 102 # define HAS_SYS_VFS_H 103 # endif 104 105 # if defined (__LINUX__) 106 # if defined(__GLIBC__) 107 # define HAS_SYS_STATVFS_H 108 # else 109 # define HAS_SYS_VFS_H 110 # endif 111 # endif 112 113 # ifndef LONG_MAX 114 # include <limits.h> 115 # endif 116 117 # include <fcntl.h> 118 # ifndef O_BINARY 119 # define O_BINARY 0 /* O_BINARY flag has no effect under UNIX */ 120 # endif 121 122 # ifndef O_TEXT 123 # define O_TEXT 0 /* O_TEXT flag has no effect under UNIX */ 124 # endif 125 126 # ifndef SH_DENYNONE 127 # define SH_DENYNONE 0 128 # endif 129 # ifndef SH_DENYNO 130 # define SH_DENYNO 0 131 # endif 132 # ifndef SH_DENYALL 133 # define SH_DENYALL 1 134 # endif 135 136 # define _XPENTRY 137 138 /* Other OS's may sleep with other functions */ 139 140 # if defined(__SUN__) 141 # define mysleep(x) sleep(x) 142 /*# define sleep(x) usleep(x*1000000l)*/ 143 # define HAS_sleep 1 144 # elif defined(__BSD__) || defined(__CYGWIN__) || defined(__LINUX__) || defined(__APPLE__) || defined (__QNXNTO__) 145 # define mysleep(x) sleep(x) 146 # define HAS_sleep 1 147 # endif 148 # ifndef __SUN__ /* SunOs 2.7 not have snprintf() and vsnprintf in libc */ 149 /* If you known test for this - please report to developers */ 150 # define HAS_snprintf 1 151 # define HAS_vsnprintf 1 152 # endif 153 154 # if !defined(__QNXNTO__) 155 # define HAS_SYSEXITS_H 1 /* <sysexits.h> */ 156 # endif /* __QNXNTO__ */ 157 # define HAS_UNISTD_H 1 /* <unistd.h> */ 158 # define HAS_PWD_H 1 /* <pwd.h> */ 159 # define HAS_GRP_H 1 /* may be used "#include <grp.h>" */ 160 # define HAS_SIGNAL_H 1 /* <signal.h> */ 161 # define HAS_SYS_WAIT_H 1 /* <sys/wait.h> */ 162 # define USE_STAT_MACROS 1 163 164 # if defined(__LINUX__) || defined(__BSD__) || defined(__CYGWIN__) || \ 165 defined(__APPLE__) || defined(__SUN__) || defined(__QNXNTO__) 166 # define HAS_mktime 1 /* <time.h> */ 167 # define HAS_strftime 1 /* <time.h> */ 168 # define HAS_DIRENT_H 1 /* <dirent.h> */ 169 # endif 170 171 # if defined(__CYGWIN__) 172 # define HAS_strupr 1 /* <string.h> from libc (newlib) */ 173 # endif 174 175 # if defined(__LINUX__) || defined(__BSD__) 176 # define HAS_SYSLOG_H 1 177 # define HAS_SYS_SYSLOG_H 1 178 # endif 179 180 # if defined(__QNXNTO__) 181 # define HAS_sopen 1 /* <fcntl.h> */ 182 # define HAS_STRINGS_H 1 183 # define HAS_SYSLOG_H 1 184 # endif 185 186 # define HAS_popen_close 1 /* popen(); pclose() */ 187 188 189 typedef unsigned bit; 190 191 typedef unsigned char byte; 192 typedef signed char sbyte; 193 194 typedef unsigned short word; 195 typedef signed short sword; 196 197 #if defined(__ALPHA__) || defined(__X86_64__) /* add other 64 bit systems here */ 198 typedef unsigned int dword; 199 typedef signed int sdword; 200 #else /* 32 and 16 bit machines */ 201 typedef unsigned long dword; 202 typedef signed long sdword; 203 #endif 204 205 206 typedef signed char hCHAR; /* 1 byte */ 207 typedef signed char hSCHAR; /* 1 byte */ 208 typedef unsigned char hUCHAR; /* 1 byte */ 209 210 typedef signed char hINT8; /* 1 byte */ 211 typedef signed char hSINT8; /* 1 byte */ 212 typedef unsigned char hUINT8; /* 1 byte */ 213 214 typedef signed short hINT16; /* 2 bytes */ 215 typedef signed short hSINT16; /* 2 bytes */ 216 typedef unsigned short hUINT16; /* 2 bytes */ 217 218 typedef signed int hINT32; /* 4 bytes */ 219 typedef signed int hSINT32; /* 4 bytes */ 220 typedef unsigned int hUINT32; /* 4 bytes */ 221 222 #if defined(__ALPHA__) /* add other 64 bit systems here */ 223 typedef signed long hINT64; /* 4 bytes */ 224 typedef signed long hSINT64; /* 4 bytes */ 225 typedef unsigned long hUINT64; /* 4 bytes */ 226 # define HAS_INT64 227 #else 228 # if __WORDSIZE == 64 229 typedef long int hINT64; /* 8 bytes */ 230 typedef long int hSINT64; /* 8 bytes */ 231 typedef unsigned long int hUINT64; /* 8 bytes */ 232 # define HAS_INT64 233 # elif __GLIBC_HAVE_LONG_LONG 234 typedef long long int hINT64; /* 8 bytes */ 235 typedef long long int hSINT64; /* 8 bytes */ 236 typedef unsigned long long int hUINT64; /* 8 bytes */ 237 # define HAS_INT64 238 # elif __GNUC__>2 || (__GNUC__==2 && __GNUC_MINOR__>=8) 239 /* Test please GNU C before 2.8 ! (Stas Degteff) */ 240 typedef signed long long hINT64; /* 8 bytes */ 241 typedef signed long long hSINT64; /* 8 bytes */ 242 typedef unsigned long long hUINT64; /* 8 bytes */ 243 # define HAS_INT64 244 # endif 245 #endif 246 247 #endif 248