Commit 12c94238 authored by Bruce Momjian's avatar Bruce Momjian

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
parent 2c055606
...@@ -1393,7 +1393,7 @@ case $host_os in ...@@ -1393,7 +1393,7 @@ case $host_os in
hpux*) template=hpux ;; hpux*) template=hpux ;;
irix*) template=irix5 ;; irix*) template=irix5 ;;
linux*) template=linux ;; linux*) template=linux ;;
mingw*) template=win ;; mingw*) template=win32 ;;
netbsd*) template=netbsd ;; netbsd*) template=netbsd ;;
nextstep*) template=nextstep ;; nextstep*) template=nextstep ;;
openbsd*) template=openbsd ;; openbsd*) template=openbsd ;;
...@@ -2808,7 +2808,6 @@ echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;} ...@@ -2808,7 +2808,6 @@ echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
done done
IFS=$ac_save_IFS IFS=$ac_save_IFS
# #
# Tcl/Tk # Tcl/Tk
# #
...@@ -5236,6 +5235,65 @@ _ACEOF ...@@ -5236,6 +5235,65 @@ _ACEOF
fi fi
echo "$as_me:$LINENO: checking for main in -lwsock32" >&5
echo $ECHO_N "checking for main in -lwsock32... $ECHO_C" >&6
if test "${ac_cv_lib_wsock32_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lwsock32 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
main ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_wsock32_main=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_wsock32_main=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5
echo "${ECHO_T}$ac_cv_lib_wsock32_main" >&6
if test $ac_cv_lib_wsock32_main = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBWSOCK32 1
_ACEOF
LIBS="-lwsock32 $LIBS"
fi
echo "$as_me:$LINENO: checking for library containing getopt_long" >&5 echo "$as_me:$LINENO: checking for library containing getopt_long" >&5
echo $ECHO_N "checking for library containing getopt_long... $ECHO_C" >&6 echo $ECHO_N "checking for library containing getopt_long... $ECHO_C" >&6
if test "${ac_cv_search_getopt_long+set}" = set; then if test "${ac_cv_search_getopt_long+set}" = set; then
...@@ -6072,6 +6130,85 @@ echo "$as_me: error: library 'krb' is required for Kerberos 4" >&2;} ...@@ -6072,6 +6130,85 @@ echo "$as_me: error: library 'krb' is required for Kerberos 4" >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
for ac_func in gethostname
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
char (*f) ();
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func;
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
else
LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
fi
done
fi fi
if test "$with_krb5" = yes ; then if test "$with_krb5" = yes ; then
...@@ -11080,7 +11217,7 @@ fi ...@@ -11080,7 +11217,7 @@ fi
for ac_func in crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul for ac_func in crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5
...@@ -11258,9 +11395,8 @@ LIBOBJS="$LIBOBJS qsort.$ac_objext" ;; ...@@ -11258,9 +11395,8 @@ LIBOBJS="$LIBOBJS qsort.$ac_objext" ;;
esac esac
# Win32 can't to rename or unlink on an open file # Win32 can't to rename or unlink on an open file
case $host_os in win32*) case $host_os in win32*|mingw*)
LIBOBJS="$LIBOBJS dirmod.$ac_objext" LIBOBJS="$LIBOBJS dirmod.$ac_objext" ;;
LIBOBJS="$LIBOBJS opendir.$ac_objext" ;;
esac esac
if test "$with_readline" = yes; then if test "$with_readline" = yes; then
......
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.249 2003/05/10 04:03:37 momjian Exp $ dnl $Header: /cvsroot/pgsql/configure.in,v 1.250 2003/05/15 16:35:27 momjian Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -65,7 +65,7 @@ case $host_os in ...@@ -65,7 +65,7 @@ case $host_os in
hpux*) template=hpux ;; hpux*) template=hpux ;;
irix*) template=irix5 ;; irix*) template=irix5 ;;
linux*) template=linux ;; linux*) template=linux ;;
mingw*) template=win ;; mingw*) template=win32 ;;
netbsd*) template=netbsd ;; netbsd*) template=netbsd ;;
nextstep*) template=nextstep ;; nextstep*) template=nextstep ;;
openbsd*) template=openbsd ;; openbsd*) template=openbsd ;;
...@@ -319,7 +319,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do ...@@ -319,7 +319,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
done done
IFS=$ac_save_IFS IFS=$ac_save_IFS
# #
# Tcl/Tk # Tcl/Tk
# #
...@@ -607,6 +606,7 @@ AC_CHECK_LIB(BSD, main) ...@@ -607,6 +606,7 @@ AC_CHECK_LIB(BSD, main)
AC_CHECK_LIB(gen, main) AC_CHECK_LIB(gen, main)
AC_CHECK_LIB(PW, main) AC_CHECK_LIB(PW, main)
AC_CHECK_LIB(resolv, main) AC_CHECK_LIB(resolv, main)
AC_CHECK_LIB(wsock32, main)
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt]) AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
# QNX: # QNX:
AC_CHECK_LIB(unix, main) AC_CHECK_LIB(unix, main)
...@@ -639,6 +639,7 @@ fi ...@@ -639,6 +639,7 @@ fi
if test "$with_krb4" = yes ; then if test "$with_krb4" = yes ; then
AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])]) AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])]) AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
AC_REPLACE_FUNCS([gethostname])
fi fi
if test "$with_krb5" = yes ; then if test "$with_krb5" = yes ; then
...@@ -839,7 +840,7 @@ else ...@@ -839,7 +840,7 @@ else
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break]) AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi fi
AC_REPLACE_FUNCS([crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul]) AC_REPLACE_FUNCS([crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
# system's version of getaddrinfo(), if any, may be used only if we found # system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
...@@ -862,9 +863,8 @@ AC_LIBOBJ(qsort) ;; ...@@ -862,9 +863,8 @@ AC_LIBOBJ(qsort) ;;
esac esac
# Win32 can't to rename or unlink on an open file # Win32 can't to rename or unlink on an open file
case $host_os in win32*) case $host_os in win32*|mingw*)
AC_LIBOBJ(dirmod) AC_LIBOBJ(dirmod) ;;
AC_LIBOBJ(opendir) ;;
esac esac
if test "$with_readline" = yes; then if test "$with_readline" = yes; then
......
TODO list for PostgreSQL TODO list for PostgreSQL
======================== ========================
Last updated: Wed Apr 2 17:44:34 EST 2003 Last updated: Thu May 15 12:10:39 EDT 2003
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.31 2003/04/25 04:37:23 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.32 2003/05/15 16:35:28 momjian Exp $
* *
* Since the server static private key ($DataDir/server.key) * Since the server static private key ($DataDir/server.key)
* will normally be stored unencrypted so that the database * will normally be stored unencrypted so that the database
...@@ -85,16 +85,12 @@ ...@@ -85,16 +85,12 @@
#include "libpq/libpq.h" #include "libpq/libpq.h"
#include "miscadmin.h" #include "miscadmin.h"
#ifdef WIN32
#include "win32.h"
#else
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H #ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.152 2003/04/25 01:24:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.153 2003/05/15 16:35:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -357,6 +357,9 @@ Setup_AF_UNIX(void) ...@@ -357,6 +357,9 @@ Setup_AF_UNIX(void)
Assert(Unix_socket_group); Assert(Unix_socket_group);
if (Unix_socket_group[0] != '\0') if (Unix_socket_group[0] != '\0')
{ {
#ifdef WIN32
elog(FATAL, "Config value 'unix_socket_group' not supported on this platform");
#else
char *endptr; char *endptr;
unsigned long int val; unsigned long int val;
gid_t gid; gid_t gid;
...@@ -385,6 +388,7 @@ Setup_AF_UNIX(void) ...@@ -385,6 +388,7 @@ Setup_AF_UNIX(void)
sock_path, strerror(errno)); sock_path, strerror(errno));
return STATUS_ERROR; return STATUS_ERROR;
} }
#endif
} }
if (chmod(sock_path, Unix_socket_permissions) == -1) if (chmod(sock_path, Unix_socket_permissions) == -1)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.56 2002/11/08 20:23:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.57 2003/05/15 16:35:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -159,13 +159,14 @@ main(int argc, char *argv[]) ...@@ -159,13 +159,14 @@ main(int argc, char *argv[])
strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "--version") == 0 ||
strcmp(argv[1], "-V") == 0))) strcmp(argv[1], "-V") == 0)))
{ {
#ifndef WIN32
#ifndef __BEOS__
/* /*
* Make sure we are not running as root. * Make sure we are not running as root.
* *
* BeOS currently runs everything as root :-(, so this check must be * BeOS currently runs everything as root :-(, so this check must be
* temporarily disabled there... * temporarily disabled there...
*/ */
#ifndef __BEOS__
if (geteuid() == 0) if (geteuid() == 0)
{ {
fprintf(stderr, gettext( fprintf(stderr, gettext(
...@@ -176,7 +177,7 @@ main(int argc, char *argv[]) ...@@ -176,7 +177,7 @@ main(int argc, char *argv[])
)); ));
exit(1); exit(1);
} }
#endif /* __BEOS__ */ #endif /* !__BEOS__ */
/* /*
* Also make sure that real and effective uids are the same. * Also make sure that real and effective uids are the same.
...@@ -193,6 +194,7 @@ main(int argc, char *argv[]) ...@@ -193,6 +194,7 @@ main(int argc, char *argv[])
argv[0]); argv[0]);
exit(1); exit(1);
} }
#endif /* !WIN32 */
} }
/* /*
...@@ -221,6 +223,7 @@ main(int argc, char *argv[]) ...@@ -221,6 +223,7 @@ main(int argc, char *argv[])
* specifying current userid as the "authenticated" Postgres user * specifying current userid as the "authenticated" Postgres user
* name. * name.
*/ */
#ifndef WIN32
pw = getpwuid(geteuid()); pw = getpwuid(geteuid());
if (pw == NULL) if (pw == NULL)
{ {
...@@ -230,6 +233,18 @@ main(int argc, char *argv[]) ...@@ -230,6 +233,18 @@ main(int argc, char *argv[])
} }
/* Allocate new memory because later getpwuid() calls can overwrite it */ /* Allocate new memory because later getpwuid() calls can overwrite it */
pw_name_persist = strdup(pw->pw_name); pw_name_persist = strdup(pw->pw_name);
#else
{
long namesize = 256 /* UNLEN */ + 1;
pw_name_persist = malloc(namesize);
if (!GetUserName(pw_name_persist, &namesize))
{
fprintf(stderr, "%s: GetUserName failed\n", argv[0]);
exit(1);
}
}
#endif
exit(PostgresMain(argc, new_argv, pw_name_persist)); exit(PostgresMain(argc, new_argv, pw_name_persist));
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.413 2003/05/04 00:03:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.414 2003/05/15 16:35:28 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -322,12 +322,12 @@ static void doNegateFloat(Value *v); ...@@ -322,12 +322,12 @@ static void doNegateFloat(Value *v);
*/ */
/* ordinary key words in alphabetical order */ /* ordinary key words in alphabetical order */
%token <keyword> ABORT_P ABSOLUTE ACCESS ACTION ADD AFTER %token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
ASSERTION ASSIGNMENT AT AUTHORIZATION ASSERTION ASSIGNMENT AT AUTHORIZATION
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
BOOLEAN BOTH BY BOOLEAN_P BOTH BY
CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
...@@ -336,9 +336,9 @@ static void doNegateFloat(Value *v); ...@@ -336,9 +336,9 @@ static void doNegateFloat(Value *v);
CREATEUSER CROSS CURRENT_DATE CURRENT_TIME CREATEUSER CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT
DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS
DESC DISTINCT DO DOMAIN_P DOUBLE DROP DESC DISTINCT DO DOMAIN_P DOUBLE_P DROP
EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT
EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT
...@@ -351,8 +351,8 @@ static void doNegateFloat(Value *v); ...@@ -351,8 +351,8 @@ static void doNegateFloat(Value *v);
HANDLER HAVING HOLD HOUR_P HANDLER HAVING HOLD HOUR_P
ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCREMENT ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCREMENT
INDEX INHERITS INITIALLY INNER_P INOUT INPUT INDEX INHERITS INITIALLY INNER_P INOUT INPUT_P
INSENSITIVE INSERT INSTEAD INT INTEGER INTERSECT INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT
INTERVAL INTO INVOKER IS ISNULL ISOLATION INTERVAL INTO INVOKER IS ISNULL ISOLATION
JOIN JOIN
...@@ -373,18 +373,17 @@ static void doNegateFloat(Value *v); ...@@ -373,18 +373,17 @@ static void doNegateFloat(Value *v);
ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNER ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNER
PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION
PRECISION PRESERVE PREPARE PRIMARY PRIOR PRIVILEGES PROCEDURAL PRECISION PRESERVE PREPARE PRIMARY
PROCEDURE PRIOR PRIVILEGES PROCEDURAL PROCEDURE
READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE READ REAL RECHECK REFERENCES REINDEX RELATIVE_P RENAME REPLACE
RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS
RULE RULE
SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
STATISTICS STDIN STDOUT STORAGE STRICT SUBSTRING STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYSID
SYSID
TABLE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP TABLE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
...@@ -2675,14 +2674,14 @@ fetch_direction: ...@@ -2675,14 +2674,14 @@ fetch_direction:
n->howMany = -1; n->howMany = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
| ABSOLUTE fetch_count | ABSOLUTE_P fetch_count
{ {
FetchStmt *n = makeNode(FetchStmt); FetchStmt *n = makeNode(FetchStmt);
n->direction = FETCH_ABSOLUTE; n->direction = FETCH_ABSOLUTE;
n->howMany = $2; n->howMany = $2;
$$ = (Node *)n; $$ = (Node *)n;
} }
| RELATIVE fetch_count | RELATIVE_P fetch_count
{ {
FetchStmt *n = makeNode(FetchStmt); FetchStmt *n = makeNode(FetchStmt);
n->direction = FETCH_RELATIVE; n->direction = FETCH_RELATIVE;
...@@ -3146,15 +3145,15 @@ createfunc_opt_item: ...@@ -3146,15 +3145,15 @@ createfunc_opt_item:
{ {
$$ = makeDefElem("volatility", (Node *)makeString("volatile")); $$ = makeDefElem("volatility", (Node *)makeString("volatile"));
} }
| CALLED ON NULL_P INPUT | CALLED ON NULL_P INPUT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(FALSE)); $$ = makeDefElem("strict", (Node *)makeInteger(FALSE));
} }
| RETURNS NULL_P ON NULL_P INPUT | RETURNS NULL_P ON NULL_P INPUT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); $$ = makeDefElem("strict", (Node *)makeInteger(TRUE));
} }
| STRICT | STRICT_P
{ {
$$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); $$ = makeDefElem("strict", (Node *)makeInteger(TRUE));
} }
...@@ -5077,7 +5076,7 @@ GenericType: ...@@ -5077,7 +5076,7 @@ GenericType:
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30 * Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
* - thomas 1997-09-18 * - thomas 1997-09-18
*/ */
Numeric: INT Numeric: INT_P
{ {
$$ = SystemTypeName("int4"); $$ = SystemTypeName("int4");
} }
...@@ -5101,11 +5100,11 @@ Numeric: INT ...@@ -5101,11 +5100,11 @@ Numeric: INT
{ {
$$ = $2; $$ = $2;
} }
| DOUBLE PRECISION | DOUBLE_P PRECISION
{ {
$$ = SystemTypeName("float8"); $$ = SystemTypeName("float8");
} }
| DECIMAL opt_decimal | DECIMAL_P opt_decimal
{ {
$$ = SystemTypeName("numeric"); $$ = SystemTypeName("numeric");
$$->typmod = $2; $$->typmod = $2;
...@@ -5120,7 +5119,7 @@ Numeric: INT ...@@ -5120,7 +5119,7 @@ Numeric: INT
$$ = SystemTypeName("numeric"); $$ = SystemTypeName("numeric");
$$->typmod = $2; $$->typmod = $2;
} }
| BOOLEAN | BOOLEAN_P
{ {
$$ = SystemTypeName("bool"); $$ = SystemTypeName("bool");
} }
...@@ -7179,7 +7178,7 @@ ColLabel: IDENT { $$ = $1; } ...@@ -7179,7 +7178,7 @@ ColLabel: IDENT { $$ = $1; }
*/ */
unreserved_keyword: unreserved_keyword:
ABORT_P ABORT_P
| ABSOLUTE | ABSOLUTE_P
| ACCESS | ACCESS
| ACTION | ACTION
| ADD | ADD
...@@ -7222,7 +7221,7 @@ unreserved_keyword: ...@@ -7222,7 +7221,7 @@ unreserved_keyword:
| DELIMITER | DELIMITER
| DELIMITERS | DELIMITERS
| DOMAIN_P | DOMAIN_P
| DOUBLE | DOUBLE_P
| DROP | DROP
| EACH | EACH
| ENCODING | ENCODING
...@@ -7248,7 +7247,7 @@ unreserved_keyword: ...@@ -7248,7 +7247,7 @@ unreserved_keyword:
| INDEX | INDEX
| INHERITS | INHERITS
| INOUT | INOUT
| INPUT | INPUT_P
| INSENSITIVE | INSENSITIVE
| INSERT | INSERT
| INSTEAD | INSTEAD
...@@ -7299,7 +7298,7 @@ unreserved_keyword: ...@@ -7299,7 +7298,7 @@ unreserved_keyword:
| READ | READ
| RECHECK | RECHECK
| REINDEX | REINDEX
| RELATIVE | RELATIVE_P
| RENAME | RENAME
| REPLACE | REPLACE
| RESET | RESET
...@@ -7328,8 +7327,8 @@ unreserved_keyword: ...@@ -7328,8 +7327,8 @@ unreserved_keyword:
| STDIN | STDIN
| STDOUT | STDOUT
| STORAGE | STORAGE
| STRICT
| SYSID | SYSID
| STRICT_P
| TEMP | TEMP
| TEMPLATE | TEMPLATE
| TEMPORARY | TEMPORARY
...@@ -7374,17 +7373,17 @@ unreserved_keyword: ...@@ -7374,17 +7373,17 @@ unreserved_keyword:
col_name_keyword: col_name_keyword:
BIGINT BIGINT
| BIT | BIT
| BOOLEAN | BOOLEAN_P
| CHAR_P | CHAR_P
| CHARACTER | CHARACTER
| COALESCE | COALESCE
| CONVERT | CONVERT
| DEC | DEC
| DECIMAL | DECIMAL_P
| EXISTS | EXISTS
| EXTRACT | EXTRACT
| FLOAT_P | FLOAT_P
| INT | INT_P
| INTEGER | INTEGER
| INTERVAL | INTERVAL
| NCHAR | NCHAR
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.138 2003/04/08 23:20:02 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.139 2003/05/15 16:35:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
static const ScanKeyword ScanKeywords[] = { static const ScanKeyword ScanKeywords[] = {
/* name, value */ /* name, value */
{"abort", ABORT_P}, {"abort", ABORT_P},
{"absolute", ABSOLUTE}, {"absolute", ABSOLUTE_P},
{"access", ACCESS}, {"access", ACCESS},
{"action", ACTION}, {"action", ACTION},
{"add", ADD}, {"add", ADD},
...@@ -57,7 +57,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -57,7 +57,7 @@ static const ScanKeyword ScanKeywords[] = {
{"bigint", BIGINT}, {"bigint", BIGINT},
{"binary", BINARY}, {"binary", BINARY},
{"bit", BIT}, {"bit", BIT},
{"boolean", BOOLEAN}, {"boolean", BOOLEAN_P},
{"both", BOTH}, {"both", BOTH},
{"by", BY}, {"by", BY},
{"cache", CACHE}, {"cache", CACHE},
...@@ -99,7 +99,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -99,7 +99,7 @@ static const ScanKeyword ScanKeywords[] = {
{"day", DAY_P}, {"day", DAY_P},
{"deallocate", DEALLOCATE}, {"deallocate", DEALLOCATE},
{"dec", DEC}, {"dec", DEC},
{"decimal", DECIMAL}, {"decimal", DECIMAL_P},
{"declare", DECLARE}, {"declare", DECLARE},
{"default", DEFAULT}, {"default", DEFAULT},
{"deferrable", DEFERRABLE}, {"deferrable", DEFERRABLE},
...@@ -112,7 +112,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -112,7 +112,7 @@ static const ScanKeyword ScanKeywords[] = {
{"distinct", DISTINCT}, {"distinct", DISTINCT},
{"do", DO}, {"do", DO},
{"domain", DOMAIN_P}, {"domain", DOMAIN_P},
{"double", DOUBLE}, {"double", DOUBLE_P},
{"drop", DROP}, {"drop", DROP},
{"each", EACH}, {"each", EACH},
{"else", ELSE}, {"else", ELSE},
...@@ -157,11 +157,11 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -157,11 +157,11 @@ static const ScanKeyword ScanKeywords[] = {
{"initially", INITIALLY}, {"initially", INITIALLY},
{"inner", INNER_P}, {"inner", INNER_P},
{"inout", INOUT}, {"inout", INOUT},
{"input", INPUT}, {"input", INPUT_P},
{"insensitive", INSENSITIVE}, {"insensitive", INSENSITIVE},
{"insert", INSERT}, {"insert", INSERT},
{"instead", INSTEAD}, {"instead", INSTEAD},
{"int", INT}, {"int", INT_P},
{"integer", INTEGER}, {"integer", INTEGER},
{"intersect", INTERSECT}, {"intersect", INTERSECT},
{"interval", INTERVAL}, {"interval", INTERVAL},
...@@ -246,7 +246,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -246,7 +246,7 @@ static const ScanKeyword ScanKeywords[] = {
{"recheck", RECHECK}, {"recheck", RECHECK},
{"references", REFERENCES}, {"references", REFERENCES},
{"reindex", REINDEX}, {"reindex", REINDEX},
{"relative", RELATIVE}, {"relative", RELATIVE_P},
{"rename", RENAME}, {"rename", RENAME},
{"replace", REPLACE}, {"replace", REPLACE},
{"reset", RESET}, {"reset", RESET},
...@@ -283,7 +283,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -283,7 +283,7 @@ static const ScanKeyword ScanKeywords[] = {
{"stdin", STDIN}, {"stdin", STDIN},
{"stdout", STDOUT}, {"stdout", STDOUT},
{"storage", STORAGE}, {"storage", STORAGE},
{"strict", STRICT}, {"strict", STRICT_P},
{"substring", SUBSTRING}, {"substring", SUBSTRING},
{"sysid", SYSID}, {"sysid", SYSID},
{"table", TABLE}, {"table", TABLE},
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# be converted to Method 2. # be converted to Method 2.
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.18 2002/07/27 20:10:05 petere Exp $ # $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.19 2003/05/15 16:35:29 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -26,7 +26,7 @@ OBJS+=dynloader.o pg_sema.o pg_shmem.o ...@@ -26,7 +26,7 @@ OBJS+=dynloader.o pg_sema.o pg_shmem.o
OBJS+=$(TAS) OBJS+=$(TAS)
ifeq ($(PORTNAME), qnx4) ifeq ($(PORTNAME), qnx4)
OBJS+=getrusage.o qnx4/SUBSYS.o OBJS+=qnx4/SUBSYS.o
endif endif
ifeq ($(PORTNAME), beos) ifeq ($(PORTNAME), beos)
OBJS+=beos/SUBSYS.o OBJS+=beos/SUBSYS.o
...@@ -34,6 +34,9 @@ endif ...@@ -34,6 +34,9 @@ endif
ifeq ($(PORTNAME), darwin) ifeq ($(PORTNAME), darwin)
OBJS+=darwin/SUBSYS.o OBJS+=darwin/SUBSYS.o
endif endif
ifeq ($(PORTNAME), win32)
OBJS+=win32/SUBSYS.o
endif
all: SUBSYS.o all: SUBSYS.o
...@@ -55,6 +58,11 @@ darwin/SUBSYS.o: darwin.dir ...@@ -55,6 +58,11 @@ darwin/SUBSYS.o: darwin.dir
darwin.dir: darwin.dir:
$(MAKE) -C darwin all $(MAKE) -C darwin all
win32/SUBSYS.o: win32.dir
win32.dir:
$(MAKE) -C win32 all
tas.o: tas.s tas.o: tas.s
$(CC) $(CFLAGS) -c $< $(CC) $(CFLAGS) -c $<
...@@ -67,3 +75,5 @@ distclean clean: ...@@ -67,3 +75,5 @@ distclean clean:
$(MAKE) -C beos clean $(MAKE) -C beos clean
$(MAKE) -C darwin clean $(MAKE) -C darwin clean
$(MAKE) -C qnx4 clean $(MAKE) -C qnx4 clean
$(MAKE) -C win32 clean
/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/win.c,v 1.2 2003/03/21 17:18:34 petere Exp $ */ /* $Header: /cvsroot/pgsql/src/backend/port/dynloader/win32.c,v 1.1 2003/05/15 16:35:29 momjian Exp $ */
#include <windows.h> #include <windows.h>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "postgres.h" #include "postgres.h"
#include "storage/shmem.h" #include "storage/shmem.h"
#include "sema.h"
#include <errno.h> #include <errno.h>
...@@ -131,7 +130,8 @@ semget(int semKey, int semNum, int flags) ...@@ -131,7 +130,8 @@ semget(int semKey, int semNum, int flags)
Size sem_set_size = sizeof(win32_sem_set_hdr) + semNum * (sizeof(HANDLE) + sizeof(int)); Size sem_set_size = sizeof(win32_sem_set_hdr) + semNum * (sizeof(HANDLE) + sizeof(int));
HANDLE *sem_handles = NULL; HANDLE *sem_handles = NULL;
int *sem_counts = NULL; int *sem_counts = NULL;
int i;
sec_attrs.nLength = sizeof(sec_attrs); sec_attrs.nLength = sizeof(sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL; sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = TRUE; sec_attrs.bInheritHandle = TRUE;
...@@ -158,7 +158,7 @@ semget(int semKey, int semNum, int flags) ...@@ -158,7 +158,7 @@ semget(int semKey, int semNum, int flags)
sem_handles = (HANDLE *) ((off_t) new_set + new_set->m_semaphoreHandles); sem_handles = (HANDLE *) ((off_t) new_set + new_set->m_semaphoreHandles);
sem_counts = (int *) ((off_t) new_set + new_set->m_semaphoreCounts); sem_counts = (int *) ((off_t) new_set + new_set->m_semaphoreCounts);
for (int i = 0; i < semNum && ans; ++i) for (i = 0; i < semNum && ans; ++i)
{ {
strcpy(num_part, _itoa(i, cur_num, 10)); strcpy(num_part, _itoa(i, cur_num, 10));
...@@ -186,8 +186,9 @@ semget(int semKey, int semNum, int flags) ...@@ -186,8 +186,9 @@ semget(int semKey, int semNum, int flags)
return MAKE_OFFSET(new_set); return MAKE_OFFSET(new_set);
else else
{ {
int i;
/* Blow away what we've got right now... */ /* Blow away what we've got right now... */
for (int i = 0; i < semNum; ++i) for (i = 0; i < semNum; ++i)
{ {
if (sem_handles[i]) if (sem_handles[i])
CloseHandle(sem_handles[i]); CloseHandle(sem_handles[i]);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* Copyright (c) 2001-2003, PostgreSQL Global Development Group * Copyright (c) 2001-2003, PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.35 2003/04/27 20:09:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.36 2003/05/15 16:35:29 momjian Exp $
* ---------- * ----------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -217,7 +217,7 @@ pgstat_init(void) ...@@ -217,7 +217,7 @@ pgstat_init(void)
* messages will be discarded; backends won't block waiting to send * messages will be discarded; backends won't block waiting to send
* messages to the collector. * messages to the collector.
*/ */
if (fcntl(pgStatSock, F_SETFL, O_NONBLOCK) < 0) if (FCNTL_NONBLOCK(pgStatSock) < 0)
{ {
elog(LOG, "PGSTAT: fcntl() failed: %m"); elog(LOG, "PGSTAT: fcntl() failed: %m");
goto startup_failed; goto startup_failed;
...@@ -1520,7 +1520,7 @@ pgstat_recvbuffer(void) ...@@ -1520,7 +1520,7 @@ pgstat_recvbuffer(void)
* Set the write pipe to nonblock mode, so that we cannot block when * Set the write pipe to nonblock mode, so that we cannot block when
* the collector falls behind. * the collector falls behind.
*/ */
if (fcntl(writePipe, F_SETFL, O_NONBLOCK) < 0) if (FCNTL_NONBLOCK(writePipe) < 0)
{ {
elog(LOG, "PGSTATBUFF: fcntl() failed: %m"); elog(LOG, "PGSTATBUFF: fcntl() failed: %m");
exit(1); exit(1);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.327 2003/05/10 18:15:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.328 2003/05/15 16:35:29 momjian Exp $
* *
* NOTES * NOTES
* *
...@@ -211,6 +211,11 @@ bool LogSourcePort; ...@@ -211,6 +211,11 @@ bool LogSourcePort;
bool Log_connections = false; bool Log_connections = false;
bool Db_user_namespace = false; bool Db_user_namespace = false;
/* For FNCTL_NONBLOCK */
#if defined(WIN32) || defined(__BEOS__)
long ioctlsocket_ret;
#endif
/* list of library:init-function to be preloaded */ /* list of library:init-function to be preloaded */
char *preload_libraries_string = NULL; char *preload_libraries_string = NULL;
...@@ -1708,6 +1713,9 @@ reaper(SIGNAL_ARGS) ...@@ -1708,6 +1713,9 @@ reaper(SIGNAL_ARGS)
{ {
int save_errno = errno; int save_errno = errno;
#ifdef WIN32
#warning fix waidpid for Win32
#else
#ifdef HAVE_WAITPID #ifdef HAVE_WAITPID
int status; /* backend exit status */ int status; /* backend exit status */
...@@ -1807,6 +1815,7 @@ reaper(SIGNAL_ARGS) ...@@ -1807,6 +1815,7 @@ reaper(SIGNAL_ARGS)
CleanupProc(pid, exitstatus); CleanupProc(pid, exitstatus);
} /* loop over pending child-death reports */ } /* loop over pending child-death reports */
#endif
if (FatalError) if (FatalError)
{ {
...@@ -2141,23 +2150,14 @@ report_fork_failure_to_client(Port *port, int errnum) ...@@ -2141,23 +2150,14 @@ report_fork_failure_to_client(Port *port, int errnum)
{ {
char buffer[1000]; char buffer[1000];
#ifdef __BEOS__
int on = 1;
#endif
/* Format the error message packet */ /* Format the error message packet */
snprintf(buffer, sizeof(buffer), "E%s%s\n", snprintf(buffer, sizeof(buffer), "E%s%s\n",
gettext("Server process fork() failed: "), gettext("Server process fork() failed: "),
strerror(errnum)); strerror(errnum));
/* Set port to non-blocking. Don't do send() if this fails */ /* Set port to non-blocking. Don't do send() if this fails */
#ifdef __BEOS__ if (FCNTL_NONBLOCK(port->sock) < 0)
if (ioctl(port->sock, FIONBIO, &on) != 0)
return; return;
#else
if (fcntl(port->sock, F_SETFL, O_NONBLOCK) < 0)
return;
#endif
send(port->sock, buffer, strlen(buffer) + 1, 0); send(port->sock, buffer, strlen(buffer) + 1, 0);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.129 2003/02/18 02:13:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.130 2003/05/15 16:35:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -944,6 +944,9 @@ ProcSendSignal(BackendId procId) ...@@ -944,6 +944,9 @@ ProcSendSignal(BackendId procId)
bool bool
enable_sig_alarm(int delayms, bool is_statement_timeout) enable_sig_alarm(int delayms, bool is_statement_timeout)
{ {
#ifdef WIN32
# warning add Win32 timer
#else
struct timeval fin_time; struct timeval fin_time;
#ifndef __BEOS__ #ifndef __BEOS__
struct itimerval timeval; struct itimerval timeval;
...@@ -1012,7 +1015,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) ...@@ -1012,7 +1015,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout)
if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0) if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
return false; return false;
#endif #endif
#endif
return true; return true;
} }
...@@ -1026,6 +1029,9 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) ...@@ -1026,6 +1029,9 @@ enable_sig_alarm(int delayms, bool is_statement_timeout)
bool bool
disable_sig_alarm(bool is_statement_timeout) disable_sig_alarm(bool is_statement_timeout)
{ {
#ifdef WIN32
#warning add Win32 timer
#else
/* /*
* Always disable the interrupt if it is active; this avoids being * Always disable the interrupt if it is active; this avoids being
* interrupted by the signal handler and thereby possibly getting * interrupted by the signal handler and thereby possibly getting
...@@ -1065,7 +1071,7 @@ disable_sig_alarm(bool is_statement_timeout) ...@@ -1065,7 +1071,7 @@ disable_sig_alarm(bool is_statement_timeout)
if (!CheckStatementTimeout()) if (!CheckStatementTimeout())
return false; return false;
} }
#endif
return true; return true;
} }
...@@ -1098,6 +1104,9 @@ CheckStatementTimeout(void) ...@@ -1098,6 +1104,9 @@ CheckStatementTimeout(void)
else else
{ {
/* Not time yet, so (re)schedule the interrupt */ /* Not time yet, so (re)schedule the interrupt */
#ifdef WIN32
#warning add win32 timer
#else
#ifndef __BEOS__ #ifndef __BEOS__
struct itimerval timeval; struct itimerval timeval;
...@@ -1120,6 +1129,7 @@ CheckStatementTimeout(void) ...@@ -1120,6 +1129,7 @@ CheckStatementTimeout(void)
(statement_fin_time.tv_usec - now.tv_usec); (statement_fin_time.tv_usec - now.tv_usec);
if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0) if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
return false; return false;
#endif
#endif #endif
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.32 2003/04/04 20:42:12 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.33 2003/05/15 16:35:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,9 +44,11 @@ static int ...@@ -44,9 +44,11 @@ static int
ValidateBinary(char *path) ValidateBinary(char *path)
{ {
struct stat buf; struct stat buf;
#ifndef WIN32
uid_t euid; uid_t euid;
struct group *gp; struct group *gp;
struct passwd *pwp; struct passwd *pwp;
#endif
int i; int i;
int is_r = 0; int is_r = 0;
int is_x = 0; int is_x = 0;
...@@ -82,6 +84,11 @@ ValidateBinary(char *path) ...@@ -82,6 +84,11 @@ ValidateBinary(char *path)
* Ensure that the file is both executable and readable (required for * Ensure that the file is both executable and readable (required for
* dynamic loading). * dynamic loading).
*/ */
#ifdef WIN32
is_r = buf.st_mode & S_IRUSR;
is_x = buf.st_mode & S_IXUSR;
return is_x ? (is_r ? 0 : -2) : -1;
#else
euid = geteuid(); euid = geteuid();
if (euid == buf.st_uid) if (euid == buf.st_uid)
{ {
...@@ -125,6 +132,7 @@ ValidateBinary(char *path) ...@@ -125,6 +132,7 @@ ValidateBinary(char *path)
elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute", elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute",
path); path);
return is_x ? (is_r ? 0 : -2) : -1; return is_x ? (is_r ? 0 : -2) : -1;
#endif
} }
/* /*
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Encoding names and routines for work with it. All * Encoding names and routines for work with it. All
* in this file is shared bedween FE and BE. * in this file is shared bedween FE and BE.
* *
* $Id: encnames.c,v 1.12 2003/03/10 22:28:18 tgl Exp $ * $Id: encnames.c,v 1.13 2003/05/15 16:35:29 momjian Exp $
*/ */
#ifdef FRONTEND #ifdef FRONTEND
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -13,11 +13,7 @@ ...@@ -13,11 +13,7 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#endif #endif
#ifdef WIN32
#include "win32.h"
#else
#include <unistd.h> #include <unistd.h>
#endif
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include <ctype.h> #include <ctype.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.144 2003/05/09 16:59:43 momjian Exp $ * $Id: c.h,v 1.145 2003/05/15 16:35:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
#include "pg_config.h" #include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */ #include "pg_config_manual.h" /* must be after pg_config.h */
#include "pg_config_os.h"
#include "postgres_ext.h" #include "postgres_ext.h"
#include <stdio.h> #include <stdio.h>
...@@ -66,11 +65,14 @@ ...@@ -66,11 +65,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <sys/fcntl.h> /* ensure O_BINARY is available */ #include <fcntl.h> /* ensure O_BINARY is available */
#ifdef HAVE_SUPPORTDEFS_H #ifdef HAVE_SUPPORTDEFS_H
#include <SupportDefs.h> #include <SupportDefs.h>
#endif #endif
/* Must be here so we can redefine some functions on Win32 */
#include "pg_config_os.h"
/* Must be before gettext() games below */ /* Must be before gettext() games below */
#include <locale.h> #include <locale.h>
...@@ -696,64 +698,23 @@ typedef NameData *Name; ...@@ -696,64 +698,23 @@ typedef NameData *Name;
#define PG_BINARY_W "w" #define PG_BINARY_W "w"
#endif #endif
#if defined(sun) && defined(__sparc__) && !defined(__SVR4) #if !defined(WIN32) && !defined(__BEOS__)
#include <unistd.h> #define FCNTL_NONBLOCK(sock) fcntl(sock, F_SETFL, O_NONBLOCK)
#else
extern long ioctlsocket_ret;
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
#ifdef WIN32
#define FCNTL_NONBLOCK(sock) ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
#endif #endif
#ifdef __BEOS__
/* Portable path handling for Unix/Win32 */ #define FCNTL_NONBLOCK(sock) ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
bool is_absolute_path(const char *filename);
char *first_path_separator(const char *filename);
char *last_path_separator(const char *filename);
char *get_progname(char *argv0);
#if defined(bsdi) || defined(netbsd)
int fseeko(FILE *stream, off_t offset, int whence);
off_t ftello(FILE *stream);
#endif #endif
/*
* Win32 doesn't have reliable rename/unlink during concurrent access
*/
#if defined(WIN32) && !defined(FRONTEND)
int pgrename(const char *from, const char *to);
int pgunlink(const char *path);
#define rename(path) pgrename(path)
#define unlink(from, to) pgunlink(from, to)
#endif #endif
/* #if defined(sun) && defined(__sparc__) && !defined(__SVR4)
* Win32 doesn't have opendir/readdir/closedir() #include <unistd.h>
*/
#ifdef WIN32
struct dirent {
ino_t d_ino; /* inode (always 1 on WIN32) */
char d_name[MAX_PATH + 1]; /* filename (null terminated) */
};
typedef struct {
HANDLE handle; /* handle for FindFirstFile or
* FindNextFile */
long offset; /* offset into directory */
int finished; /* 1 if there are not more files */
WIN32_FIND_DATA finddata; /* file data FindFirstFile or FindNextFile
* returns */
char *dir; /* the directory path we are reading */
struct dirent ent; /* the dirent to return */
} DIR;
extern DIR *opendir(const char *);
extern struct dirent *readdir(DIR *);
extern int closedir(DIR *);
#endif #endif
/*
* Win32 requires a special close for sockets and pipes, while on Unix
* close() does them all.
*/
#ifndef WIN32
#define closesocket close
#endif
/* These are for things that are one way on Unix and another on NT */ /* These are for things that are one way on Unix and another on NT */
#define NULL_DEV "/dev/null" #define NULL_DEV "/dev/null"
...@@ -794,37 +755,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args); ...@@ -794,37 +755,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#define SIGNAL_ARGS int postgres_signal_arg #define SIGNAL_ARGS int postgres_signal_arg
#endif #endif
/*
* Default "extern" declarations or macro substitutes for library routines.
* When necessary, these routines are provided by files in src/port/.
*/
#ifndef HAVE_CRYPT
char *crypt(const char *key, const char *setting);
#endif
#ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek((a), (b), (c))
#define ftello(a) ftell((a))
#endif
#ifndef HAVE_ISINF
extern int isinf(double x);
#endif
#ifndef HAVE_GETHOSTNAME
extern int gethostname(char *name, int namelen);
#endif
#ifndef HAVE_RINT
extern double rint(double x);
#endif
#ifndef HAVE_INET_ATON
# include <netinet/in.h>
# include <arpa/inet.h>
extern int inet_aton(const char *cp, struct in_addr * addr);
#endif
/* /*
* When there is no sigsetjmp, its functionality is provided by plain * When there is no sigsetjmp, its functionality is provided by plain
* setjmp. Incidentally, nothing provides setjmp's functionality in * setjmp. Incidentally, nothing provides setjmp's functionality in
...@@ -836,22 +766,6 @@ extern int inet_aton(const char *cp, struct in_addr * addr); ...@@ -836,22 +766,6 @@ extern int inet_aton(const char *cp, struct in_addr * addr);
# define siglongjmp longjmp # define siglongjmp longjmp
#endif #endif
#ifndef HAVE_STRCASECMP
extern int strcasecmp(char *s1, char *s2);
#endif
#ifndef HAVE_STRDUP
extern char *strdup(char const *);
#endif
#ifndef HAVE_RANDOM
extern long random(void);
#endif
#ifndef HAVE_SRANDOM
extern void srandom(unsigned int seed);
#endif
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
extern int fdatasync(int fildes); extern int fdatasync(int fildes);
#endif #endif
...@@ -868,4 +782,7 @@ extern int fdatasync(int fildes); ...@@ -868,4 +782,7 @@ extern int fdatasync(int fildes);
# define HAVE_STRTOULL 1 # define HAVE_STRTOULL 1
#endif #endif
/* /port compatibility functions */
#include "port.h"
#endif /* C_H */ #endif /* C_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* for developers. If you edit any of these, be sure to do a *full* * for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted). * rebuild (and an initdb if noted).
* *
* $Id: pg_config_manual.h,v 1.2 2003/04/18 01:03:42 momjian Exp $ * $Id: pg_config_manual.h,v 1.3 2003/05/15 16:35:29 momjian Exp $
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
* Define this if your operating system supports AF_UNIX family * Define this if your operating system supports AF_UNIX family
* sockets. * sockets.
*/ */
#if !defined(__QNX__) && !defined(__BEOS__) #if !defined(__QNX__) && !defined(__BEOS__) && !defined(WIN32)
# define HAVE_UNIX_SOCKETS 1 # define HAVE_UNIX_SOCKETS 1
#endif #endif
......
/*-------------------------------------------------------------------------
*
* port.h
* Header for /port compatibility functions.
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: port.h,v 1.1 2003/05/15 16:35:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Portable path handling for Unix/Win32 */
bool is_absolute_path(const char *filename);
char *first_path_separator(const char *filename);
char *last_path_separator(const char *filename);
char *get_progname(char *argv0);
#if defined(bsdi) || defined(netbsd)
int fseeko(FILE *stream, off_t offset, int whence);
off_t ftello(FILE *stream);
#endif
/*
* Win32 doesn't have reliable rename/unlink during concurrent access
*/
#if defined(WIN32) && !defined(FRONTEND)
int pgrename(const char *from, const char *to);
int pgunlink(const char *path);
#define rename(from, to) pgrename(from, to)
#define unlink(path) pgunlink(path)
#endif
/*
* Win32 requires a special close for sockets and pipes, while on Unix
* close() does them all.
*/
#ifndef WIN32
#define closesocket close
#endif
/*
* Default "extern" declarations or macro substitutes for library routines.
* When necessary, these routines are provided by files in src/port/.
*/
#ifndef HAVE_CRYPT
char *crypt(const char *key, const char *setting);
#endif
#ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek((a), (b), (c))
#define ftello(a) ftell((a))
#endif
#ifndef HAVE_GETOPT
extern int getopt(int nargc, char *const *nargv, const char *ostr);
#endif
#ifndef HAVE_ISINF
extern int isinf(double x);
#endif
#if !defined(HAVE_GETHOSTNAME) && defined(KRB4)
extern int gethostname(char *name, int namelen);
#endif
#ifndef HAVE_RINT
extern double rint(double x);
#endif
#ifndef HAVE_INET_ATON
# include <netinet/in.h>
# include <arpa/inet.h>
extern int inet_aton(const char *cp, struct in_addr * addr);
#endif
#ifndef HAVE_STRCASECMP
extern int strcasecmp(char *s1, char *s2);
#endif
#ifndef HAVE_STRDUP
extern char *strdup(char const *);
#endif
#ifndef HAVE_RANDOM
extern long random(void);
#endif
#ifndef HAVE_SRANDOM
extern void srandom(unsigned int seed);
#endif
/* $Header: /cvsroot/pgsql/src/include/port/Attic/win.h,v 1.15 2003/03/21 17:18:34 petere Exp $ */
#define HAS_TEST_AND_SET
#ifdef BUILDING_DLL
#define DLLIMPORT __declspec (dllexport)
#else
#define DLLIMPORT __declspec (dllimport)
#endif
#if defined(_DLL)
#define DLLIMPORT __declspec (dllexport)
#else
#define DLLIMPORT __declspec (dllimport)
#endif
/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.9 2003/04/29 18:25:54 momjian Exp $ */ /* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.10 2003/05/15 16:35:29 momjian Exp $ */
/* undefine and redefine after #include */
#undef mkdir
#undef ERROR
#include <windows.h>
#undef near
/* Must be here to avoid conflicting with prototype in windows.h */
#define mkdir(a,b) mkdir(a)
#define USES_WINSOCK #define USES_WINSOCK
#define NOFILE 100 #define NOFILE 100
...@@ -33,6 +44,9 @@ ...@@ -33,6 +44,9 @@
/* /*
* IPC defines * IPC defines
*/ */
#undef HAVE_UNION_SEMUN
#define HAVE_UNION_SEMUN 1
#define IPC_RMID 256 #define IPC_RMID 256
#define IPC_CREAT 512 #define IPC_CREAT 512
#define IPC_EXCL 1024 #define IPC_EXCL 1024
...@@ -40,6 +54,14 @@ ...@@ -40,6 +54,14 @@
#define IPC_NOWAIT 2048 #define IPC_NOWAIT 2048
#define IPC_STAT 4096 #define IPC_STAT 4096
#define EACCESS 2048
#define EIDRM 4096
#define SETALL 8192
#define GETNCNT 16384
#define GETVAL 65536
#define SETVAL 131072
#define GETPID 262144
/* /*
* Shared memory * Shared memory
...@@ -77,6 +99,30 @@ int semctl(int semId, int semNum, int flag, union semun); ...@@ -77,6 +99,30 @@ int semctl(int semId, int semNum, int flag, union semun);
int semget(int semKey, int semNum, int flags); int semget(int semKey, int semNum, int flags);
int semop(int semId, struct sembuf * sops, int flag); int semop(int semId, struct sembuf * sops, int flag);
#define sleep(sec) (Sleep(sec * 1000), /* no return value */ 0)
/* Some extra signals */
#define SIGHUP 1
#define SIGQUIT 3
#define SIGTRAP 5
#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */
#define SIGKILL 9
#define SIGPIPE 13
#define SIGALRM 14
#define SIGSTOP 17
#define SIGCONT 19
#define SIGCHLD 20
#define SIGTTIN 21
#define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */
#define SIGWINCH 28
#define SIGUSR1 30
#define SIGUSR2 31
struct timezone
{
int tz_minuteswest; /* Minutes west of GMT. */
int tz_dsttime; /* Nonzero if DST is ever in effect. */
};
/* FROM SRA */ /* FROM SRA */
...@@ -130,5 +176,3 @@ extern double rint(double x); ...@@ -130,5 +176,3 @@ extern double rint(double x);
*/ */
#define snprintf _snprintf #define snprintf _snprintf
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
/*
* Unfortunately, <wingdi.h> of VC++ also defines ERROR.
* To avoid the conflict, we include <windows.h> here and undefine ERROR
* immediately.
*
* Note: Don't include <wingdi.h> directly. It causes compile errors.
*/
#include <winsock2.h>
#undef ERROR
#undef small
/* Restore old ERROR value */
#ifdef PGERROR
#define ERROR PGERROR
#endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: rusagestub.h,v 1.10 2002/06/20 20:29:42 momjian Exp $ * $Id: rusagestub.h,v 1.11 2003/05/15 16:35:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
#define RUSAGESTUB_H #define RUSAGESTUB_H
#include <sys/time.h> /* for struct timeval */ #include <sys/time.h> /* for struct timeval */
#ifndef WIN32
#include <sys/times.h> /* for struct tms */ #include <sys/times.h> /* for struct tms */
#endif
#include <limits.h> /* for CLK_TCK */ #include <limits.h> /* for CLK_TCK */
#define RUSAGE_SELF 0 #define RUSAGE_SELF 0
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: elog.h,v 1.41 2003/04/24 21:16:44 tgl Exp $ * $Id: elog.h,v 1.42 2003/05/15 16:35:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -35,6 +35,15 @@ ...@@ -35,6 +35,15 @@
#define WARNING 19 /* Warnings */ #define WARNING 19 /* Warnings */
#define ERROR 20 /* user error - abort transaction; return #define ERROR 20 /* user error - abort transaction; return
* to known state */ * to known state */
#define ERROR 20 /* user error - abort transaction; return
* to known state */
/* Save ERROR value in PGERROR so it can bve restored when Win32 includes
* modify it. We have to use a constant rather than ERROR because macros
* are expanded only when referenced outside macros.
*/
#ifdef WIN32
#define PGERROR 20
#endif
#define FATAL 21 /* fatal error - abort process */ #define FATAL 21 /* fatal error - abort process */
#define PANIC 22 /* take down the other backends with me */ #define PANIC 22 /* take down the other backends with me */
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.76 2003/04/19 00:02:30 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.77 2003/05/15 16:35:30 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -386,10 +386,10 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, ...@@ -386,10 +386,10 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
/* /*
* libpq uses a non-blocking socket. But kerberos needs a blocking * libpq uses a non-blocking socket. But kerberos needs a blocking
* socket, and we have to block somehow to do mutual authentication * socket, and we have to block somehow to do mutual authentication
* anyway. So we temporarily make it blocking. * anyway. So we temporarily make it blocking. Win32 doesn't support this.
*/ */
flags = fcntl(sock, F_GETFL); flags = fcntl(sock, F_GETFL);
if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK))) if (flags < 0 || fcntl(sock, F_SETFL, flags & ~O_NONBLOCK)))
{ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("could not set socket to blocking mode: %s\n"), strerror(errno)); libpq_gettext("could not set socket to blocking mode: %s\n"), strerror(errno));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.240 2003/05/05 00:44:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.241 2003/05/15 16:35:30 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -719,17 +719,7 @@ update_db_info(PGconn *conn) ...@@ -719,17 +719,7 @@ update_db_info(PGconn *conn)
static int static int
connectMakeNonblocking(PGconn *conn) connectMakeNonblocking(PGconn *conn)
{ {
#if defined(WIN32) || defined(__BEOS__) if (FCNTL_NONBLOCK(conn->sock) < 0)
int on = 1;
#endif
#if defined(WIN32)
if (ioctlsocket(conn->sock, FIONBIO, &on) != 0)
#elif defined(__BEOS__)
if (ioctl(conn->sock, FIONBIO, &on) != 0)
#else
if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0)
#endif
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not set socket to non-blocking mode: %s\n"), libpq_gettext("could not set socket to non-blocking mode: %s\n"),
......
# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.19 2003/03/21 17:18:34 petere Exp $ # $Header: /cvsroot/pgsql/src/makefiles/Makefile.win32,v 1.1 2003/05/15 16:35:30 momjian Exp $
# Use replacement include files for those missing on Win32
override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32_include"
DLLTOOL= dlltool DLLTOOL= dlltool
DLLWRAP= dllwrap DLLWRAP= dllwrap
BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef TEST_VERSION #ifndef TEST_VERSION
#include "postgres.h"
#undef rename #undef rename
#undef unlink #undef unlink
......
...@@ -30,9 +30,11 @@ ...@@ -30,9 +30,11 @@
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * 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) #if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
...@@ -92,7 +94,7 @@ const char *ostr; ...@@ -92,7 +94,7 @@ const char *ostr;
++optind; ++optind;
if (opterr && *ostr != ':') if (opterr && *ostr != ':')
(void) fprintf(stderr, (void) fprintf(stderr,
"%s: illegal option -- %c\n", argv[0], optopt); "illegal option -- %c\n", optopt);
return BADCH; return BADCH;
} }
if (*++oli != ':') if (*++oli != ':')
...@@ -112,8 +114,8 @@ const char *ostr; ...@@ -112,8 +114,8 @@ const char *ostr;
return BADARG; return BADARG;
if (opterr) if (opterr)
(void) fprintf(stderr, (void) fprintf(stderr,
"%s: option requires an argument -- %c\n", "option requires an argument -- %c\n",
argv[0], optopt); optopt);
return BADCH; return BADCH;
} }
else else
......
/* $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 <stdio.h>
#include <errno.h> #include <errno.h>
#include "postgres.h"
#include "rusagestub.h" #include "rusagestub.h"
/* This code works on: /* This code works on:
...@@ -19,6 +21,10 @@ ...@@ -19,6 +21,10 @@
int int
getrusage(int who, struct rusage * rusage) getrusage(int who, struct rusage * rusage)
{ {
#ifdef WIN32
if (rusage)
memset(rusage, 0, sizeof(rusage));
#else
struct tms tms; struct tms tms;
int tick_rate = CLK_TCK; /* ticks per second */ int tick_rate = CLK_TCK; /* ticks per second */
clock_t u, clock_t u,
...@@ -54,5 +60,6 @@ getrusage(int who, struct rusage * rusage) ...@@ -54,5 +60,6 @@ getrusage(int who, struct rusage * rusage)
rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate); 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_sec = TICK_TO_SEC(s, tick_rate);
rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate); rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
#endif
return 0; return 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;
}
if test "$GCC" = yes; then
CFLAGS="-O2"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment