[m-rev.] diff: fixes sockets / tcp library with MSVC
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Oct 26 04:38:00 AEDT 2011
Branches: 11.07, main
Fix problems that prevent the sockets library in the extras distribution
compiling when using MSVC as the C compiler.
extras/net/sockets.mr
Fix bitrot: socketets.init/2 referred to a variable that does
not exist. (Presumably, it was deleted with the initialise
directive was added to this module.)
extras/net/tcp.m:
Include the header file that defines the type off_t.
SIGPIPE does not exist on Windows so protect any uses of
it inside #ifdefs. (Execution will abort if calls are made
to {ignore,unignore}_sigpipe on Windows.)
Julien.
Index: extras/net/sockets.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/net/sockets.m,v
retrieving revision 1.3
diff -u -r1.3 sockets.m
--- extras/net/sockets.m 7 May 2007 07:31:55 -0000 1.3
+++ extras/net/sockets.m 25 Oct 2011 17:13:57 -0000
@@ -115,20 +115,17 @@
WSADATA wsaData;
int err;
- if (!initialiased) {
- wVersionRequested = MAKEWORD( 2, 2 );
- err = WSAStartup(wVersionRequested, &wsaData);
+ wVersionRequested = MAKEWORD( 2, 2 );
+ err = WSAStartup(wVersionRequested, &wsaData);
- if ( err != 0 ) {
- MR_fatal_error(""Unable to find a usable winsock.dll\\n"");
- }
+ if ( err != 0 ) {
+ MR_fatal_error(""Unable to find a usable winsock.dll\\n"");
+ }
- if ( LOBYTE( wsaData.wVersion ) != 2 ||
- HIBYTE( wsaData.wVersion ) != 2 ) {
- WSACleanup();
- MR_fatal_error(""Unable to find a usable winsock.dll\\n"");
- }
- initialiased = MR_TRUE;
+ if ( LOBYTE( wsaData.wVersion ) != 2 ||
+ HIBYTE( wsaData.wVersion ) != 2 ) {
+ WSACleanup();
+ MR_fatal_error(""Unable to find a usable winsock.dll\\n"");
}
#endif /* MR_WIN32 */
").
Index: extras/net/tcp.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/net/tcp.m,v
retrieving revision 1.8
diff -u -r1.8 tcp.m
--- extras/net/tcp.m 21 Oct 2011 10:49:34 -0000 1.8
+++ extras/net/tcp.m 25 Oct 2011 17:31:06 -0000
@@ -173,6 +173,7 @@
#ifdef MR_WIN32
#include <windows.h>
#include <winsock.h>
+ #include <sys/types.h>
#define ML_error() WSAGetLastError()
@@ -694,27 +695,40 @@
%-----------------------------------------------------------------------------%
:- pragma foreign_decl("C", "
+
#include <signal.h>
- extern void *TCP__prev_sigpipe_handler;
+ #if defined(SIGPIPE)
+ extern void *TCP__prev_sigpipe_handler;
+ #endif
").
:- pragma foreign_code("C", "
- void *TCP__prev_sigpipe_handler = SIG_DFL;
+ #if defined(SIGPIPE)
+ void *TCP__prev_sigpipe_handler = SIG_DFL;
+ #endif
").
:- pragma foreign_proc("C",
tcp.ignore_sigpipe(_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
+#if defined(SIGPIPE)
TCP__prev_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
+#else
+ MR_external_fatal_error(""tcp"", ""SIGPIPE not available on this system."")
+#endif
").
:- pragma foreign_proc("C",
tcp.unignore_sigpipe(_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
+#if defined(SIGPIPE)
signal(SIGPIPE, TCP__prev_sigpipe_handler);
+#else
+ MR_external_fatal_error(""tcp"", ""SIGPIPE not available on this system."")
+#endif
").
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list