1/* Dirty system-dependent hacks. 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, 4 Inc. 5 6This file is part of GNU Wget. 7 8GNU Wget is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 3 of the License, or (at 11your option) any later version. 12 13GNU Wget is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with Wget. If not, see <http://www.gnu.org/licenses/>. 20 21Additional permission under GNU GPL version 3 section 7 22 23If you modify this program, or any covered work, by linking or 24combining it with the OpenSSL project's OpenSSL library (or a 25modified version of that library), containing parts covered by the 26terms of the OpenSSL or SSLeay licenses, the Free Software Foundation 27grants you additional permission to convey the resulting work. 28Corresponding Source for a non-source form of such a combination 29shall include the source code for the parts of OpenSSL used as well 30as that of the covered work. */ 31 32/* This file is included by wget.h. Random .c files need not include 33 it. */ 34 35#ifndef SYSDEP_H 36#define SYSDEP_H 37 38/* Testing for __sun is not enough because it's also defined on SunOS. */ 39#ifdef __sun 40# ifdef __SVR4 41# define solaris 42# endif 43#endif 44 45#if defined(__INTERIX) && !defined(_ALL_SOURCE) 46# define _ALL_SOURCE 47#endif 48 49/* The "namespace tweaks" below attempt to set a friendly "compilation 50 environment" under popular operating systems. Default compilation 51 environment often means that some functions that are "extensions" 52 are not declared -- `strptime' is one example. 53 54 But non-default environments can expose bugs in the system header 55 files, crippling compilation in _very_ non-obvious ways. Because 56 of that, we define them only on well-tested architectures where we 57 know they will work. */ 58 59#undef NAMESPACE_TWEAKS 60 61#ifdef solaris 62# define NAMESPACE_TWEAKS 63#endif 64 65#if defined(__linux__) || defined(__GLIBC__) 66# define NAMESPACE_TWEAKS 67#endif 68 69#ifdef NAMESPACE_TWEAKS 70 71/* Request the "Unix 98 compilation environment". */ 72#define _XOPEN_SOURCE 500 73 74#endif /* NAMESPACE_TWEAKS */ 75 76 77/* Alloca declaration, based on recommendation in the Autoconf manual. 78 These have to be after the above namespace tweaks, but before any 79 non-preprocessor code. */ 80 81#include <alloca.h> 82 83/* Must include these, so we can test for the missing stat macros and 84 define them as necessary. */ 85#include <sys/types.h> 86#include <sys/stat.h> 87 88#include <stdint.h> 89#include <inttypes.h> 90 91#ifdef WINDOWS 92/* Windows doesn't have some functions normally found on Unix-like 93 systems, such as strcasecmp, strptime, etc. Include mswindows.h so 94 we get the declarations for their replacements in mswindows.c, as 95 well as to pick up Windows-specific includes and constants. To be 96 able to test for such features, the file must be included as early 97 as possible. */ 98# include "mswindows.h" 99#endif 100 101/* Provided by gnulib on systems that don't have it: */ 102# include <stdbool.h> 103 104#ifndef struct_stat 105# define struct_stat struct stat 106#endif 107#ifndef struct_fstat 108# define struct_fstat struct stat 109#endif 110 111#include <intprops.h> 112 113/* For CHAR_BIT, LONG_MAX, etc. */ 114#include <limits.h> 115 116#ifndef CHAR_BIT 117# define CHAR_BIT 8 118#endif 119 120/* These are defined in cmpt.c if missing, so we must declare 121 them. */ 122#ifndef HAVE_STRCASECMP 123int strcasecmp (); 124#endif 125#ifndef HAVE_STRNCASECMP 126int strncasecmp (); 127#endif 128#ifndef HAVE_STRPTIME 129char *strptime (); 130#endif 131#ifndef HAVE_TIMEGM 132# include <time.h> 133time_t timegm (struct tm *); 134#endif 135#ifndef HAVE_MEMRCHR 136void *memrchr (const void *, int, size_t); 137#endif 138 139/* These are defined in snprintf.c. It would be nice to have an 140 snprintf.h, though. */ 141#ifndef HAVE_SNPRINTF 142int snprintf (char *str, size_t count, const char *fmt, ...); 143#endif 144#ifndef HAVE_VSNPRINTF 145#include <stdarg.h> 146int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 147#endif 148 149/* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't 150 provide MAP_FAILED, a symbolic constant for the value returned by 151 mmap() when it doesn't work. Usually, this constant should be -1. 152 This only makes sense for files that use mmap() and include 153 sys/mman.h *before* sysdep.h, but doesn't hurt others. */ 154 155#ifndef MAP_FAILED 156# define MAP_FAILED ((void *) -1) 157#endif 158 159/* Enable system fnmatch only on systems where fnmatch.h is usable. 160 If the fnmatch on your system is buggy, undef this symbol and a 161 replacement implementation will be used instead. */ 162#ifdef HAVE_WORKING_FNMATCH_H 163# define SYSTEM_FNMATCH 164#endif 165 166#include <fnmatch.h> 167 168/* Provide sig_atomic_t if the system doesn't. */ 169#ifndef HAVE_SIG_ATOMIC_T 170typedef int sig_atomic_t; 171#endif 172 173/* Provide uint32_t on the platforms that don't define it. Although 174 most code should be agnostic about integer sizes, some code really 175 does need a 32-bit integral type. Such code should use uint32_t. 176 (The exception is gnu-md5.[ch], which uses its own detection for 177 portability across platforms.) */ 178 179#ifndef HAVE_UINT32_T 180# if SIZEOF_INT == 4 181typedef unsigned int uint32_t; 182# else 183# if SIZEOF_LONG == 4 184typedef unsigned long uint32_t; 185# else 186# if SIZEOF_SHORT == 4 187typedef unsigned short uint32_t; 188# else 189 #error "Cannot determine a 32-bit unsigned integer type" 190# endif 191# endif 192# endif 193#endif 194 195/* If uintptr_t isn't defined, simply typedef it to unsigned long. */ 196#ifndef HAVE_UINTPTR_T 197typedef unsigned long uintptr_t; 198#endif 199 200/* If intptr_t isn't defined, simply typedef it to long. */ 201#ifndef HAVE_INTPTR_T 202typedef long intptr_t; 203#endif 204 205#endif /* SYSDEP_H */ 206