--------------------- PatchSet 5447 Date: 2002/10/27 10:48:32 Author: serassio Branch: nt-2_5 Tag: (none) Log: Backport of WIN32 changes from nt branch Members: port/win32/include/READDIR.H:1.1.2.2->1.1.2.3 port/win32/include/autoconf.h:1.1.2.23->1.1.2.24 port/win32/include/cdefs.h:1.1->1.1.4.1 port/win32/include/getopt.h:1.1.2.2->1.1.2.3 port/win32/include/squid-mswin.h:1.1.2.13->1.1.2.14 Index: squid/port/win32/include/READDIR.H =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/READDIR.H,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/port/win32/include/READDIR.H 14 Jul 2002 21:07:29 -0000 1.1.2.2 +++ squid/port/win32/include/READDIR.H 27 Oct 2002 10:48:32 -0000 1.1.2.3 @@ -6,9 +6,8 @@ #include #include #include -#define off_t _off_t - +#ifdef _MSC_VER /* Microsoft C Compiler ONLY */ /* struct dirent - same as Unix */ struct dirent { long d_ino; /* inode (always 1 in WIN32) */ @@ -31,3 +30,4 @@ DIR * opendir(const char *); struct dirent * readdir(DIR *); int closedir(DIR *); +#endif Index: squid/port/win32/include/autoconf.h =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/autoconf.h,v retrieving revision 1.1.2.23 retrieving revision 1.1.2.24 diff -u -r1.1.2.23 -r1.1.2.24 --- squid/port/win32/include/autoconf.h 20 Oct 2002 09:19:16 -0000 1.1.2.23 +++ squid/port/win32/include/autoconf.h 27 Oct 2002 10:48:32 -0000 1.1.2.24 @@ -22,7 +22,7 @@ * */ -/* $Id: autoconf.h,v 1.1.2.23 2002/10/20 09:19:16 serassio Exp $ */ +/* $Id: autoconf.h,v 1.1.2.24 2002/10/27 10:48:32 serassio Exp $ */ /* * configure command line used to configure Squid @@ -219,8 +219,7 @@ #define USE_GNUREGEX 1 /* signed size_t, grr */ -#undef ssize_t -#define ssize_t int +/* #undef ssize_t */ /* * Yay! Another Linux brokenness. Its not good enough to know that @@ -297,7 +296,7 @@ * the dnsserver processes instead. */ #undef USE_DNSSERVERS -// #define USE_DNSSERVERS 1 +#define USE_DNSSERVERS 1 /* * we check for the existance of struct mallinfo @@ -932,8 +931,7 @@ /* #undef off_t */ /* Define to `int' if does not define. */ -#undef pid_t -#define pid_t long +/* #undef pid_t */ /* Define to `unsigned int' if does not define. */ /* #undef size_t */ --- /dev/null Wed Feb 14 01:07:22 2007 +++ squid/port/win32/include/cdefs.h Wed Feb 14 01:07:56 2007 @@ -0,0 +1,22 @@ +/* sys/cdefs.h + + Copyright 1998, 2000, 2001 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#ifndef _SYS_CDEFS_H +#define _SYS_CDEFS_H +#ifdef __cplusplus +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif +#define __P(protos) protos /* full-blown ANSI C */ +#endif + Index: squid/port/win32/include/getopt.h =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/getopt.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/port/win32/include/getopt.h 14 Jul 2002 21:07:29 -0000 1.1.2.2 +++ squid/port/win32/include/getopt.h 27 Oct 2002 10:48:32 -0000 1.1.2.3 @@ -1,73 +1,84 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - * Portions of this software are based upon public domain software - * originally written at the National Center for Supercomputing Applications, - * University of Illinois, Urbana-Champaign. */ -#ifndef GETOPT_H -#define GETOPT_H +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +int getopt (int, char * const *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_H__ */ + +#ifndef __UNISTD_GETOPT__ +#ifndef __GETOPT_LONG_H__ +#define __GETOPT_LONG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; -#ifdef WIN32 +int getopt_long (int, char *const *, const char *, const struct option *, int *); +#ifndef HAVE_DECL_GETOPT +#define HAVE_DECL_GETOPT 1 +#endif -extern char *optarg; -extern int optreset; -extern int optind; -extern int opterr; -extern int optopt; -int getopt(int argc, char* const *argv, const char *optstr); +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 -#endif /* WIN32 */ +#ifdef __cplusplus +} +#endif -#endif /* GETOPT_H */ \ No newline at end of file +#endif /* __GETOPT_LONG_H__ */ +#endif /* __UNISTD_GETOPT__ */ Index: squid/port/win32/include/squid-mswin.h =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/squid-mswin.h,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid/port/win32/include/squid-mswin.h 12 Sep 2002 18:35:59 -0000 1.1.2.13 +++ squid/port/win32/include/squid-mswin.h 27 Oct 2002 10:48:32 -0000 1.1.2.14 @@ -1,5 +1,5 @@ /* - * $Id: squid-mswin.h,v 1.1.2.13 2002/09/12 18:35:59 serassio Exp $ + * $Id: squid-mswin.h,v 1.1.2.14 2002/10/27 10:48:32 serassio Exp $ * * AUTHOR: Guido Serassio & Andrey Shorin * @@ -31,31 +31,66 @@ * */ -#include "default_config_file.h" +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ -/* Some tricks for MS Compilers */ +typedef char int8_t; +typedef unsigned char uint8_t; +typedef unsigned char u_int8_t; +typedef short int int16_t; +typedef unsigned short uint16_t; +typedef unsigned short u_int16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int u_int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +typedef unsigned __int64 u_int64_t; -#define __STDC__ 1 +typedef long pid_t; +typedef long off_t; +typedef int SOCKET; +typedef int ssize_t; +#include "default_config_file.h" +/* Some tricks for MS Compilers */ +#define __STDC__ 1 #pragma include_alias(, ) +#define THREADLOCAL __declspec(thread) + +#elif defined(__GNUC__) /* gcc environment */ + +/* MinGW doesn't defines u_int8_t data type */ +typedef unsigned char u_int8_t; + +#define THREADLOCAL __attribute__((section(".tls"))) + +#endif +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define alloca _alloca +#endif #define bzero(ptr,size) memset(ptr, 0, size) #define chdir _chdir #define dup _dup #define dup2 _dup2 #define fdopen _fdopen #define fileno _fileno +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define fstat _fstati64 +#endif #define ftruncate WIN32_ftruncate #define getcwd _getcwd #define getpid _getpid #define getrusage WIN32_getrusage #define ioctl ioctlsocket #define is_interface_down WIN32_is_interface_down +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define lseek _lseeki64 +#endif #define memccpy _memccpy -#define mkdir(p,m) _mkdir(p) +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ +#define mkdir(p) _mkdir(p) +#endif #define mktemp _mktemp #define open _open #define pclose _pclose @@ -63,8 +98,10 @@ #define putenv _putenv #define setmode _setmode #define sleep(t) Sleep((t)*1000) +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define snprintf _snprintf #define stat _stati64 +#endif #define strcasecmp _stricmp #define strdup _strdup #define strncasecmp _strnicmp @@ -72,7 +109,9 @@ #define truncate WIN32_truncate #define umask _umask #define unlink _unlink +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define vsnprintf _vsnprintf +#endif #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY @@ -93,7 +132,9 @@ #define O_NDELAY 0 #define S_IRWXO 007 +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR) +#endif #define SIGHUP 1 /* hangup */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ @@ -103,10 +144,10 @@ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ -#define ushort unsigned short int -#define uid_t int -#define gid_t int -#define mode_t int +typedef unsigned short int ushort; +typedef int uid_t; +typedef int gid_t; +typedef int mode_t; struct passwd { uid_t pw_uid; @@ -137,17 +178,20 @@ #include #include +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ /* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */ #pragma warning (push) #pragma warning (disable:4142) -typedef int SOCKET; +#endif /* prevent inclusion of wingdi.h */ #define NOGDI #include +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #pragma warning (pop) +#endif #include "readdir.h" -typedef char *caddr_t; +typedef char * caddr_t; #undef FD_CLOSE #undef FD_OPEN @@ -162,24 +206,6 @@ #define ECONNRESET WSAECONNRESET #define ERESTART WSATRY_AGAIN -/* internal to CRTLIB */ -#define FPIPE 0x08 /* file handle refers to a pipe */ -typedef struct { - long osfhnd; /* underlying OS file HANDLE */ - char osfile; /* attributes of file (e.g., open in text mode?) */ - char pipech; /* one char buffer for handles opened on pipes */ -#ifdef _MT - int lockinitflag; - CRITICAL_SECTION lock; -#endif /* _MT */ - } ioinfo; -extern _CRTIMP ioinfo * __pioinfo[]; -#define IOINFO_L2E 5 -#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) -#define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) ) -#define _osfile(i) ( _pioinfo(i)->osfile ) -int __cdecl _free_osfhnd(int); - #undef h_errno #define h_errno errno /* we'll set it ourselves */ @@ -220,14 +246,10 @@ #undef FD_ISSET #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(_get_osfhandle(fd)), (fd_set FAR *)(set)) -extern __declspec(thread) int ws32_result; +extern THREADLOCAL int ws32_result; #define strerror(e) WIN32_strerror(e) -/* internal to CRTLIB */ -/* used also in win32lib.c */ -extern void __cdecl _dosmaperr(unsigned long); - #define socket(f,t,p) \ (INVALID_SOCKET == ((SOCKET)ws32_result = socket(f,t,p)) ? \ ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \ @@ -248,13 +270,6 @@ #define shutdown(s,h) \ (SOCKET_ERROR == shutdown(_get_osfhandle(s),h) ? \ (errno = WSAGetLastError()), -1 : 0) -#define closesocket(s) \ - { \ - (SOCKET_ERROR == closesocket(_get_osfhandle(s)) ? \ - (errno = WSAGetLastError()), -1 : 0); \ - _free_osfhnd(s); \ - _osfile(s) = 0; \ - } #define select(n,r,w,e,t) \ (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \ (errno = WSAGetLastError()), -1 : ws32_result) @@ -321,8 +336,8 @@ #define read _read #define write _write #else -extern __declspec(thread) int _so_err; -extern __declspec(thread) int _so_err_siz; +extern THREADLOCAL int _so_err; +extern THREADLOCAL int _so_err_siz; #define read(fd,buf,siz) \ (_so_err_siz = sizeof(_so_err), \ getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \ @@ -334,7 +349,7 @@ #endif #if defined(COMM_C) || defined(TOOLS_C) -#define close closesocket +#define close WIN32_Close_FD_Socket #else #define close _close #endif