Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC port broken following switch to winsock2 #5766

Closed
vicuna opened this issue Sep 24, 2012 · 11 comments
Closed

MSVC port broken following switch to winsock2 #5766

vicuna opened this issue Sep 24, 2012 · 11 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 24, 2012

Original bug ID: 5766
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:08:12Z)
Resolution: fixed
Priority: normal
Severity: major
Target version: 4.01.0+dev
Category: platform support (windows, cross-compilation, etc)
Related to: #5676
Monitored by: vouillon

Bug description

Changes discussed in #5676 apparently broke the trunk, at least for the Win32 MSVC port. HANDLE, SO_OPENTYPE and SO_SYNCHRONOUS_NONALERT are no longer defined.

Error:

accept.c
accept.c(35) : error C2065: 'SO_OPENTYPE' : undeclared identifier
accept.c(39) : error C2065: 'SO_SYNCHRONOUS_NONALERT' : undeclared identifier
accept.c(40) : error C2065: 'SO_OPENTYPE' : undeclared identifier
accept.c(50) : error C2065: 'SO_OPENTYPE' : undeclared identifier

I can make things compile again by including io.h (to define HANDLE), and then defining missing SO_* symbols by hand:

===================================================================
--- unixsupport.h (revision 12946)
+++ unixsupport.h (working copy)
@@ -14,6 +14,7 @@
/* $Id$ */

#define WIN32_LEAN_AND_MEAN
+#include <io.h>
#include <wtypes.h>
#include <winbase.h>
#include <stdlib.h>
@@ -26,6 +27,10 @@
#include <wspiapi.h>
#endif

+#define SO_OPENTYPE 0x7008
+#define SO_SYNCHRONOUS_NONALERT 0x20
+
+
struct filedescr {
union {
HANDLE handle;

But I assume winsock2 does not support those flags.

Of course, including winsock.h in addition to winsock2.h does not work (many redefined symbols).

File attachments

@vicuna
Copy link
Author

vicuna commented Sep 24, 2012

Comment author: @alainfrisch

Same for mingw 64 port.

@vicuna
Copy link
Author

vicuna commented Sep 25, 2012

Comment author: vouillon

The piece of code using SO_SYNCHRONOUS_NONALERT was removed by commit 11966 to fix issue #5325. It was merged back into trunk from branch 4.00 by commit 12784. (It was left in branch 4.00 as a workaround to issue #5578.)

If we want to keep this piece of code, we should include mswsock.h (diff below) rather than defining the symbols by hand.

Is it really necessary to include io.h (from directory byterun/, not the windows header file)? This does not seem to be required by the mingw port. Maybe we should instead include windows.h rather than winbase.h in unixsupport.h?

Index: otherlibs/win32unix/unixsupport.h

--- otherlibs/win32unix/unixsupport.h (révision 12952)
+++ otherlibs/win32unix/unixsupport.h (copie de travail)
@@ -21,6 +21,7 @@
#include <process.h>
#include <sys/types.h>
#include <winsock2.h>
+#include <mswsock.h>
#ifdef HAS_IPV6
#include <ws2tcpip.h>
#include <wspiapi.h>

@vicuna
Copy link
Author

vicuna commented Sep 25, 2012

Comment author: @alainfrisch

Thanks. Indeed, including mswsock.h is enough for the mingw port (tested with mingw 64 only). For the msvc port, we need to include something more to define HANDLE, otherwise we get:

cl /nologo -D_CRT_SECURE_NO_DEPRECATE /Ox /MD -I../../byterun -I../unix -c createprocess.c
createprocess.c
c:\cygwin\home\afrisch\ocaml\record-disambiguation\otherlibs\win32unix\unixsupport.h(47) : error C2061: syntax error : identifier 'win_alloc_handle'
....

Including windows.h instead of winbase.h in unixsupport.h (but not io.h) does not seem to work.

@vicuna
Copy link
Author

vicuna commented Sep 25, 2012

Comment author: vouillon

It's not 'HANDLE' which is not defined, but 'value'. Hence, mlvalues.h should be included before unixsupport.h in all C files. I'm to blame for this. I have attached a patch that should fix both issues.

With mingw, the Windows header file direct.h included from unixsupport.h includes file io.h (from directory byterun!), which itself includes mlvalues.h...

@vicuna
Copy link
Author

vicuna commented Sep 26, 2012

Comment author: @alainfrisch

Thanks for the patch, I've committed it to the trunk (rev 12956). mswsock.h was also required in socket.c. What about including it from unixsupport.h? Do you see any problem?

@vicuna
Copy link
Author

vicuna commented Sep 26, 2012

Comment author: vouillon

I don't think there is any problem with including it in unixsupport.h.

But maybe the right fix is to remove the getsockopt/setsockopt calls (reverting the corresponding part of commit 12784)?

@vicuna
Copy link
Author

vicuna commented Sep 27, 2012

Comment author: @alainfrisch

Well, as long as there is no nice solution implemented for #5578, I think getsockopt/setsockopt calls have to remain.

@vicuna
Copy link
Author

vicuna commented Sep 29, 2012

Comment author: @damiendoligez

Alain, does your commit of Jerome's patch fix the problem? Should we close this PR?

@vicuna
Copy link
Author

vicuna commented Sep 29, 2012

Comment author: @alainfrisch

I think so, but I haven't tried to compile under mingw 32 bit and msvc 64 bit.

@vicuna
Copy link
Author

vicuna commented Sep 30, 2012

Comment author: @damiendoligez

I've compiled under mingw 32 bit, with a small (unrelated) fix to otherlibs/labltk/lib/Makefile (r 12978).

@vicuna
Copy link
Author

vicuna commented Oct 2, 2012

Comment author: @damiendoligez

For the record, I have also compiled successfully with msvc 64-bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants