EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: asyn driver on Windows XP
From: "Mark Rivers" <[email protected]>
To: "Dirk Zimoch" <[email protected]>, "Eric Norum" <[email protected]>, "EPICS" <[email protected]>
Date: Tue, 31 May 2011 11:14:59 -0500
Folks,

I think we need to revisit this problem.  The problem is that when
building on win32-x86 there is confusion about what OS version is being
built for.  This most often leads to an error when running applications
built with asyn.  asyn contains the following code to determine if
WSAPoll should be used:

# elif defined(_WIN32)
#  if defined(POLLIN)
#   define poll(fd,nfd,t) WSAPoll(fd,nfd,t)
#  else
#   define FAKE_POLL
#  endif

POLLIN should only be defined on more recent (e.g. Windows Vista and
Windows 7) systems, not on XP, where WSAPoll() does not exist.

Previously users who were building with Microsoft Visual C++ 2008
Express Edition were finding that the file 

C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h

Contained the following:

#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0601
#endif

The definitions of _WIN32_WINNT are:
Windows 7                                         _WIN32_WINNT_WIN7
(0x0601) 
Windows Server 2008                               _WIN32_WINNT_WS08
(0x0600) 
Windows Vista                                     _WIN32_WINNT_VISTA
(0x0600) 
Windows Server 2003 with SP1, Windows XP with SP2 _WIN32_WINNT_WS03
(0x0502) 
Windows Server 2003, Windows XP                   _WIN32_WINNT_WINXP
(0x0501) 
Windows 2000                                      _WIN32_WINNT_WIN2K
(0x0500)

I recently upgraded my Windows XP SP3 system from Visual Studio 2005 to
Visual Studio 2008, and in doing that it added

C:\Program Files\Microsoft SDKs\Windows\v6.0A

In place of
C:\Program Files\Microsoft SDKs\Windows\v5.0


C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\sdkddkver.h
contains:
#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0600
#endif

Note that although this is a Windows XP SP3 system, _WIN32_WINNT is
defined to be 0x0600, which is Windows Vista.

When I build and run win32-x86 applications build with asyn they link
OK, but they give a run-time error that WSAPoll cannot be found in the
Winsock DLL.

I worked around the problem by modifying sdkddkver.h to set the value to
0x0503 (XP SP3), but this is clearly not the correct solution.

I has originally blamed Microsoft for doing something stupid with VS
Express, but I am coming to the conclusion that we are doing something
wrong in the EPICS build system.

We are assuming that the default build with Visual Studio with the flags
we use will build an application that can run on the host machine.  This
is clearly incorrect.  Microsoft is letting one build an application on
a host OS that can run on other target OS, for example I can build an
application on Windows 7 that will run on XP, etc.

I believe we need to define _WIN32_WINNT in
CONFIG_SITE.win32-x86.win32-x86 or a similar file to declare what
Windows OS we are targeting with our EPICS build.  One may well want to
set this to 0x0503 so that the executable can run on XP, even if it is
being built on a Windows 7 system, for example.

Does this seem correct?

Janet, Jeff?

Thanks,
Mark

-----Original Message-----
From: Mark Rivers 
Sent: Monday, November 15, 2010 11:07 AM
To: 'Dirk Zimoch'; EPICS
Subject: RE: asyn driver on Windows XP

Hi Dirk,

A similar problem has been seen by other users when using Microsoft
Visual C++ 2008 Express Edition.

The problem turned out to be apparently an error in Microsoft's header
file.  Here is a message from Anthony Owen at the Australian Synchrotron
with his fix.

*******************************************************************
Hi Mark,

It turns out that the issue was with the Microsoft SDK. The SDK is
installed as part of the Visual Studio Package.

I tried SDK 6.0V and SDK 7.0 and got the same problem. It was narrowed
down to be the version being incorrectly detected in the file:

C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h

<snip>

#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0601
#endif

<snip>

It was defining 0x0601 which appears to be Windows 7.
With this changed to 0x0503 (Windows XP SP3) and ASYN reverted to its
original form, POLLIN is not defined and ASYN uses FAKE_POLL.
It compiled and executed successfully.

Hope this helps if you have to use Visual Express!

Best Regards,

Anthony Owen
*******************************************************************

So the header file was incorrectly setting the system version to be
0x0601, which is Windows 7, even though it was an XP system.  That then
caused POLLIN to be defined when it should not have been.

Is there a similar problem in Visual Studio 10?

Mark


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dirk Zimoch
Sent: Monday, November 15, 2010 10:58 AM
To: EPICS
Subject: asyn driver on Windows XP

Hi all,

I have a problem with the latest version of asyn driver on Windows XP. 
It tries to use a function WSAPoll() that does not exist in XP, only in 
Vista and newer. However I do not want use an old version of asyn driver

without that function because of all the new features and bugfixes.

The code in question is:

#if defined(__rtems__)
# define USE_SOCKTIMEOUT
#else
# define USE_POLL
# if defined(vxWorks)
#  define FAKE_POLL
# elif defined(_WIN32)
#  if defined(POLLIN)
#   define poll(fd,nfd,t) WSAPoll(fd,nfd,t)
#  else
#   define FAKE_POLL
#  endif
# else
#  include <sys/poll.h>
# endif
#endif

It seems I have POLLIN defined but no WSAPoll.

I am using the compiler from Visual Studio 10.

Any idea?

Dirk


Replies:
RE: asyn driver on Windows XP Jeff Hill
RE: asyn driver on Windows XP Mark Rivers

Navigate by Date:
Prev: Re: Parallel States Sequencer emmanuel_mayssat
Next: Re: Xenomai Linux David Kline
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: caget command holds for more than 10 seconds Hinko Kocevar
Next: RE: asyn driver on Windows XP Jeff Hill
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·