Changeset: a117dbc1a304 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a117dbc1a304
Modified Files:
NT/monetdb_config.h.in
clients/R/MonetDB.R/src/mapi.c
clients/Tests/exports.stable.out
clients/mapiclient/mclient.c
clients/mapiclient/mnc.c
clients/mapilib/mapi.c
clients/mapilib/mapi.h
clients/odbc/driver/ODBCGlobal.h
common/stream/stream.c
common/utils/mutils.c
common/utils/mutils.h
configure.ag
gdk/gdk_atoms.c
gdk/gdk_posix.c
gdk/gdk_posix.h
gdk/gdk_storage.c
gdk/gdk_utils.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/kernel/aggr.c
monetdb5/modules/kernel/alarm.c
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/kernel/counters.c
monetdb5/modules/kernel/logger.c
monetdb5/modules/kernel/mmath.c
monetdb5/modules/mal/batcalc.c
monetdb5/modules/mal/calc.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/transaction.c
sql/backends/monet5/datacell/dcsocket.c
sql/backends/monet5/gsl/gsl.c
sql/server/sql_parser.y
tools/merovingian/daemon/client.c
tools/merovingian/daemon/connections.c
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/multiplex-funnel.c
tools/merovingian/daemon/proxy.c
tools/merovingian/utils/control.c
Branch: Oct2014
Log Message:
Cleanup for Windows.
Use Windows CRT version of errno, translate Windows-specific errors
(GetLastError()) to Unix-style errors where needed.
Use SOCKET_ERROR and INVALID_SOCKET macros to test return values from
socket-related calls and use WSAGetLastError() for error codes.
Remove unneeded dllimport definitions.
diffs (truncated from 1719 to 300 lines):
diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -111,13 +111,6 @@
/* Define to 1 if you have the <crypt.h> header file. */
/* #undef HAVE_CRYPT_H */
-/* Define to 1 if you have the <cstdio> header file. */
-#if _MSC_VER >= 1300
-#define HAVE_CSTDIO 1
-#else
-/* #undef HAVE_CSTDIO */
-#endif
-
/* Define to 1 if you have the `ctime_r' function. */
#define HAVE_CTIME_R 1
@@ -229,13 +222,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1 /* generated by the Makefile */
-/* Define to 1 if you have the <iostream> header file. */
-#if _MSC_VER >= 1300
-#define HAVE_IOSTREAM 1
-#else
-/* #undef HAVE_IOSTREAM */
-#endif
-
/* Define to 1 if you have the <io.h> header file. */
#define HAVE_IO_H 1
@@ -1035,9 +1021,6 @@ typedef unsigned __int64 uint64_t;
#define __bool_true_false_are_defined 1
-#define SLASH_2_DIR_SEP(s) {char *t; for(t=strchr(s, '/' ); t;
t=strchr(t+1, '/' )) *t=DIR_SEP;}
-#define DIR_SEP_2_SLASH(s) {char *t; for(t=strchr(s, DIR_SEP); t;
t=strchr(t+1, DIR_SEP)) *t='/' ;}
-
#ifdef HAVE_LONG_LONG
typedef long long lng;
# define SIZEOF_LNG SIZEOF_LONG_LONG
diff --git a/clients/R/MonetDB.R/src/mapi.c b/clients/R/MonetDB.R/src/mapi.c
--- a/clients/R/MonetDB.R/src/mapi.c
+++ b/clients/R/MonetDB.R/src/mapi.c
@@ -132,25 +132,25 @@ SEXP mapiConnect(SEXP host, SEXP port, S
for (rp = result; rp != NULL; rp = rp->ai_next) {
sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
- if (sock == -1)
+ if (sock == INVALID_SOCKET)
continue;
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)
&sto,
- sizeof(sto)) < 0) {
+ sizeof(sto)) == SOCKET_ERROR) {
error("setsockopt failed");
}
if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)
&sto,
- sizeof(sto)) < 0) {
+ sizeof(sto)) == SOCKET_ERROR) {
error("setsockopt failed\n");
}
// lets have a 1M buffer on this socket, ok?
int recvbuf_size = ALLOCSIZE;
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (const char *) &recvbuf_size,
sizeof(recvbuf_size))) {
+ (const char *) &recvbuf_size,
sizeof(recvbuf_size)) == SOCKET_ERROR) {
error("setsockopt failed");
}
- if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) {
+ if (connect(sock, rp->ai_addr, rp->ai_addrlen) != SOCKET_ERROR)
{
if (DEBUG) {
printf("II: Connected to %s:%s\n", hostval,
portvalstr);
}
@@ -183,7 +183,13 @@ size_t sockRead(int fd, void *buf, size_
ssize_t retval = -1;
do {
retval = recv(fd, buf, size, MSG_WAITALL);
- } while (retval == -1 && errno == EINTR);
+ } while (retval == SOCKET_ERROR &&
+#ifdef _MSC_VER
+ WSAGetLastError() == WSAEINTR
+#else
+ errno == EINTR
+#endif
+ );
if (retval == -1) {
#ifdef __WIN32__
errno = WSAGetLastError();
@@ -198,7 +204,13 @@ size_t sockWrite(int fd, const void *buf
ssize_t retval = -1;
do {
retval = send(fd, buf, size, 0);
- } while (retval == -1 && errno == EINTR);
+ } while (retval == SOCKET_ERROR &&
+#ifdef _MSC_VER
+ WSAGetLastError() == WSAEINTR
+#else
+ errno == EINTR
+#endif
+ );
if (retval == -1) {
#ifdef __WIN32__
errno = WSAGetLastError();
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -476,7 +476,6 @@ int ptrToStr(str *dst, int *len, const p
const ptr ptr_nil;
struct dirent *readdir(DIR *dir);
void rewinddir(DIR *dir);
-void set_errno(int);
int shtFromStr(const char *src, int *len, sht **dst);
int shtToStr(str *dst, int *len, const sht *src);
const sht sht_nil;
@@ -488,12 +487,12 @@ int strToStr(str *dst, int *len, const c
const char str_nil[2];
int void_inplace(BAT *b, oid id, const void *val, bit force);
BUN void_replace_bat(BAT *b, BAT *u, bit force);
-int *win_errno(void);
int win_mkdir(const char *, const int mode);
int win_rename(const char *, const char *);
int win_rmdir(const char *);
int win_stat(const char *, struct stat *);
int win_unlink(const char *);
+int winerror(int);
const wrd wrd_nil;
# mapi
@@ -594,6 +593,7 @@ MapiMsg mapi_timeout(Mapi mid, unsigned
MapiMsg mapi_trace(Mapi mid, int flag);
char *mapi_unquote(char *msg);
MapiMsg mapi_virtual_result(MapiHdl hdl, int columns, const char
**columnnames, const char **columntypes, const int *columnlengths, int
tuplecount, const char ***tuples);
+const char *wsaerror(int);
# monetdb5
str AGGRavg12_dbl(bat *retval, const bat *bid, const bat *eid);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -68,10 +68,6 @@
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
-#else
-#ifdef NATIVE_WIN32
-#include <Windows.h>
-#endif
#endif
#endif
@@ -247,8 +243,8 @@ gettime(void)
tb.time -= tbbase.time;
return (timertype) tb.time * 1000000 + (timertype) tb.millitm *
1000;
}
-#endif
-#endif
+#endif /* HAVE_FTIME */
+#endif /* HAVE_GETTIMEOFDAY */
}
static void
diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c
--- a/clients/mapiclient/mnc.c
+++ b/clients/mapiclient/mnc.c
@@ -179,7 +179,7 @@ main(int argc, char **argv)
s = socket(rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
if (s == INVALID_SOCKET)
continue;
- if (connect(s, rp->ai_addr, (socklen_t) rp->ai_addrlen)
!= -1)
+ if (connect(s, rp->ai_addr, (socklen_t) rp->ai_addrlen)
!= SOCKET_ERROR)
break; /* success */
closesocket(s);
}
@@ -209,7 +209,7 @@ main(int argc, char **argv)
exit(1);
}
- if (connect(s, serv, sizeof(server)) < 0) {
+ if (connect(s, serv, sizeof(server)) == SOCKET_ERROR) {
fprintf(stderr,
"initiating connection on socket failed: %s\n",
strerror(errno));
@@ -242,7 +242,7 @@ main(int argc, char **argv)
length = (SOCKLEN) sizeof(server);
server.sin_port = htons((unsigned short) ((port) & 0xFFFF));
- if (bind(sock, (SOCKPTR) &server, length) < 0) {
+ if (bind(sock, (SOCKPTR) &server, length) == SOCKET_ERROR) {
fprintf(stderr, "bind to port %d failed: %s\n",
port, strerror(errno));
exit(1);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1099,6 +1099,119 @@ mapi_error_str(Mapi mid)
return mid->errorstr;
}
+#ifdef _MSC_VER
+static struct {
+ int e;
+ const char *m;
+} wsaerrlist[] = {
+ { WSA_INVALID_HANDLE, "Specified event object handle is invalid" },
+ { WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available" },
+ { WSA_INVALID_PARAMETER, "One or more parameters are invalid" },
+ { WSA_OPERATION_ABORTED, "Overlapped operation aborted" },
+ { WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled
state" },
+ { WSA_IO_PENDING, "Overlapped operations will complete later" },
+ { WSAEINTR, "Interrupted function call" },
+ { WSAEBADF, "File handle is not valid" },
+ { WSAEACCES, "Permission denied" },
+ { WSAEFAULT, "Bad address" },
+ { WSAEINVAL, "Invalid argument" },
+ { WSAEMFILE, "Too many open files" },
+ { WSAEWOULDBLOCK, "Resource temporarily unavailable" },
+ { WSAEINPROGRESS, "Operation now in progress" },
+ { WSAEALREADY, "Operation already in progress" },
+ { WSAENOTSOCK, "Socket operation on nonsocket" },
+ { WSAEDESTADDRREQ, "Destination address required" },
+ { WSAEMSGSIZE, "Message too long" },
+ { WSAEPROTOTYPE, "Protocol wrong type for socket" },
+ { WSAENOPROTOOPT, "Bad protocol option" },
+ { WSAEPROTONOSUPPORT, "Protocol not supported" },
+ { WSAESOCKTNOSUPPORT, "Socket type not supported" },
+ { WSAEOPNOTSUPP, "Operation not supported" },
+ { WSAEPFNOSUPPORT, "Protocol family not supported" },
+ { WSAEAFNOSUPPORT, "Address family not supported by protocol family" },
+ { WSAEADDRINUSE, "Address already in use" },
+ { WSAEADDRNOTAVAIL, "Cannot assign requested address" },
+ { WSAENETDOWN, "Network is down" },
+ { WSAENETUNREACH, "Network is unreachable" },
+ { WSAENETRESET, "Network dropped connection on reset" },
+ { WSAECONNABORTED, "Software caused connection abort" },
+ { WSAECONNRESET, "Connection reset by peer" },
+ { WSAENOBUFS, "No buffer space available" },
+ { WSAEISCONN, "Socket is already connected" },
+ { WSAENOTCONN, "Socket is not connected" },
+ { WSAESHUTDOWN, "Cannot send after socket shutdown" },
+ { WSAETOOMANYREFS, "Too many references" },
+ { WSAETIMEDOUT, "Connection timed out" },
+ { WSAECONNREFUSED, "Connection refused" },
+ { WSAELOOP, "Cannot translate name" },
+ { WSAENAMETOOLONG, "Name too long" },
+ { WSAEHOSTDOWN, "Host is down" },
+ { WSAEHOSTUNREACH, "No route to host" },
+ { WSAENOTEMPTY, "Directory not empty" },
+ { WSAEPROCLIM, "Too many processes" },
+ { WSAEUSERS, "User quota exceeded" },
+ { WSAEDQUOT, "Disk quota exceeded" },
+ { WSAESTALE, "Stale file handle reference" },
+ { WSAEREMOTE, "Item is remote" },
+ { WSASYSNOTREADY, "Network subsystem is unavailable" },
+ { WSAVERNOTSUPPORTED, "Winsock.dll version out of range" },
+ { WSANOTINITIALISED, "Successful WSAStartup not yet performed" },
+ { WSAEDISCON, "Graceful shutdown in progress" },
+ { WSAENOMORE, "No more results" },
+ { WSAECANCELLED, "Call has been canceled" },
+ { WSAEINVALIDPROCTABLE, "Procedure call table is invalid" },
+ { WSAEINVALIDPROVIDER, "Service provider is invalid" },
+ { WSAEPROVIDERFAILEDINIT, "Service provider failed to initialize" },
+ { WSASYSCALLFAILURE, "System call failure" },
+ { WSASERVICE_NOT_FOUND, "Service not found" },
+ { WSATYPE_NOT_FOUND, "Class type not found" },
+ { WSA_E_NO_MORE, "No more results" },
+ { WSA_E_CANCELLED, "Call was canceled" },
+ { WSAEREFUSED, "Database query was refused" },
+ { WSAHOST_NOT_FOUND, "Host not found" },
+ { WSATRY_AGAIN, "Nonauthoritative host not found" },
+ { WSANO_RECOVERY, "This is a nonrecoverable error" },
+ { WSANO_DATA, "Valid name, no data record of requested type" },
+ { WSA_QOS_RECEIVERS, "QOS receivers" },
+ { WSA_QOS_SENDERS, "QOS senders" },
+ { WSA_QOS_NO_SENDERS, "No QOS senders" },
+ { WSA_QOS_NO_RECEIVERS, "QOS no receivers" },
+ { WSA_QOS_REQUEST_CONFIRMED, "QOS request confirmed" },
+ { WSA_QOS_ADMISSION_FAILURE, "QOS admission error" },
+ { WSA_QOS_POLICY_FAILURE, "QOS policy failure" },
+ { WSA_QOS_BAD_STYLE, "QOS bad style" },
+ { WSA_QOS_BAD_OBJECT, "QOS bad object" },
+ { WSA_QOS_TRAFFIC_CTRL_ERROR, "QOS traffic control error" },
+ { WSA_QOS_GENERIC_ERROR, "QOS generic error" },
+ { WSA_QOS_ESERVICETYPE, "QOS service type error" },
+ { WSA_QOS_EFLOWSPEC, "QOS flowspec error" },
+ { WSA_QOS_EPROVSPECBUF, "Invalid QOS provider buffer" },
+ { WSA_QOS_EFILTERSTYLE, "Invalid QOS filter style" },
+ { WSA_QOS_EFILTERTYPE, "Invalid QOS filter type" },
+ { WSA_QOS_EFILTERCOUNT, "Incorrect QOS filter count" },
+ { WSA_QOS_EOBJLENGTH, "Invalid QOS object length" },
+ { WSA_QOS_EFLOWCOUNT, "Incorrect QOS flow count" },
+ { WSA_QOS_EUNKOWNPSOBJ, "Unrecognized QOS object" },
+ { WSA_QOS_EPOLICYOBJ, "Invalid QOS policy object" },
+ { WSA_QOS_EFLOWDESC, "Invalid QOS flow descriptor" },
+ { WSA_QOS_EPSFLOWSPEC, "Invalid QOS provider-specific flowspec" },
+ { WSA_QOS_EPSFILTERSPEC, "Invalid QOS provider-specific filterspec" },
+ { WSA_QOS_ESDMODEOBJ, "Invalid QOS shape discard mode object" },
+ { WSA_QOS_ESHAPERATEOBJ, "Invalid QOS shaping rate object" },
+ { WSA_QOS_RESERVED_PETYPE, "Reserved policy QOS element type" },
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list