summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorBruce Momjian2003-05-15 16:35:30 +0000
committerBruce Momjian2003-05-15 16:35:30 +0000
commit12c942383296bd626131241c012c2ab81b081738 (patch)
tree7a37bb6990282b36be53fae1bde399d8e603e9f9 /src/port
parent2c0556068fc308ed9cce06c85de7e42305d34b86 (diff)
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
Diffstat (limited to 'src/port')
-rw-r--r--src/port/dirmod.c2
-rw-r--r--src/port/getopt.c10
-rw-r--r--src/port/getrusage.c9
-rw-r--r--src/port/opendir.c122
4 files changed, 16 insertions, 127 deletions
diff --git a/src/port/dirmod.c b/src/port/dirmod.c
index e44ecc5edff..21c205a5d0f 100644
--- a/src/port/dirmod.c
+++ b/src/port/dirmod.c
@@ -6,6 +6,8 @@
#ifndef TEST_VERSION
+#include "postgres.h"
+
#undef rename
#undef unlink
diff --git a/src/port/getopt.c b/src/port/getopt.c
index bfb6b300773..0d60673db53 100644
--- a/src/port/getopt.c
+++ b/src/port/getopt.c
@@ -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
diff --git a/src/port/getrusage.c b/src/port/getrusage.c
index 14d37480460..386b1acf656 100644
--- a/src/port/getrusage.c
+++ b/src/port/getrusage.c
@@ -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;
}
diff --git a/src/port/opendir.c b/src/port/opendir.c
deleted file mode 100644
index 79ef4d38acf..00000000000
--- a/src/port/opendir.c
+++ /dev/null
@@ -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;
-}