mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Allow Win32 to compile under MinGW. Major changes are:
Win32 port is now called 'win32' rather than 'win' add -lwsock32 on Win32 make gethostname() be only used when kerberos4 is enabled use /port/getopt.c new /port/opendir.c routines disable GUC unix_socket_group on Win32 convert some keywords.c symbols to KEYWORD_P to prevent conflict create new FCNTL_NONBLOCK macro to turn off socket blocking create new /include/port.h file that has /port prototypes, move out of c.h new /include/port/win32_include dir to hold missing include files work around ERROR being defined in Win32 includes
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#ifndef TEST_VERSION
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#undef rename
|
||||
#undef unlink
|
||||
|
||||
|
@@ -30,9 +30,11 @@
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
@@ -92,7 +94,7 @@ const char *ostr;
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", argv[0], optopt);
|
||||
"illegal option -- %c\n", optopt);
|
||||
return BADCH;
|
||||
}
|
||||
if (*++oli != ':')
|
||||
@@ -112,8 +114,8 @@ const char *ostr;
|
||||
return BADARG;
|
||||
if (opterr)
|
||||
(void) fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
argv[0], optopt);
|
||||
"option requires an argument -- %c\n",
|
||||
optopt);
|
||||
return BADCH;
|
||||
}
|
||||
else
|
||||
|
@@ -1,7 +1,9 @@
|
||||
/* $Id: getrusage.c,v 1.1 2002/07/18 04:13:59 momjian Exp $ */
|
||||
/* $Id: getrusage.c,v 1.2 2003/05/15 16:35:30 momjian Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "postgres.h"
|
||||
#include "rusagestub.h"
|
||||
|
||||
/* This code works on:
|
||||
@@ -19,6 +21,10 @@
|
||||
int
|
||||
getrusage(int who, struct rusage * rusage)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (rusage)
|
||||
memset(rusage, 0, sizeof(rusage));
|
||||
#else
|
||||
struct tms tms;
|
||||
int tick_rate = CLK_TCK; /* ticks per second */
|
||||
clock_t u,
|
||||
@@ -54,5 +60,6 @@ getrusage(int who, struct rusage * rusage)
|
||||
rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
|
||||
rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
|
||||
rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* $Header: /cvsroot/pgsql/src/port/Attic/opendir.c,v 1.1 2003/05/09 01:16:29 momjian Exp $
|
||||
*
|
||||
* Copyright (c) 2003 SRA, Inc.
|
||||
* Copyright (c) 2003 SKC, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose, without fee, and without a
|
||||
* written agreement is hereby granted, provided that the above
|
||||
* copyright notice and this paragraph and the following two
|
||||
* paragraphs appear in all copies.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
|
||||
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
|
||||
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "dirent.h"
|
||||
|
||||
DIR *
|
||||
opendir(const char *dir)
|
||||
{
|
||||
DIR *dp;
|
||||
char *findspec;
|
||||
HANDLE handle;
|
||||
size_t dirlen;
|
||||
|
||||
dirlen = strlen(dir);
|
||||
findspec = palloc(dirlen + 2 + 1);
|
||||
if (findspec == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dirlen == 0)
|
||||
strcpy(findspec, "*");
|
||||
else if (isalpha(dir[0]) && dir[1] == ':' && dir[2] == '\0')
|
||||
sprintf(findspec, "%s*", dir);
|
||||
else if (dir[dirlen - 1] == '/' || dir[dirlen - 1] == '\\')
|
||||
sprintf(findspec, "%s*", dir);
|
||||
else
|
||||
sprintf(findspec, "%s\\*", dir);
|
||||
|
||||
dp = (DIR *)palloc(sizeof(DIR));
|
||||
if (dp == NULL)
|
||||
{
|
||||
pfree(findspec);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dp->offset = 0;
|
||||
dp->finished = 0;
|
||||
dp->dir = pstrdup(dir);
|
||||
if (dp->dir == NULL)
|
||||
{
|
||||
pfree(dp);
|
||||
pfree(findspec);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = FindFirstFile(findspec, &(dp->finddata));
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
pfree(dp->dir);
|
||||
pfree(dp);
|
||||
pfree(findspec);
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
dp->handle = handle;
|
||||
|
||||
pfree(findspec);
|
||||
return dp;
|
||||
}
|
||||
|
||||
|
||||
struct dirent *
|
||||
readdir(DIR *dp)
|
||||
{
|
||||
if (dp == NULL || dp->finished)
|
||||
return NULL;
|
||||
|
||||
if (dp->offset != 0)
|
||||
{
|
||||
if (FindNextFile(dp->handle, &(dp->finddata)) == 0)
|
||||
{
|
||||
dp->finished = 1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
dp->offset++;
|
||||
|
||||
strncpy(dp->ent.d_name, dp->finddata.cFileName, MAX_PATH);
|
||||
dp->ent.d_ino = 1;
|
||||
|
||||
return &(dp->ent);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
closedir(DIR *dp)
|
||||
{
|
||||
FindClose(dp->handle);
|
||||
pfree(dp->dir);
|
||||
pfree(dp);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user