Farid Zaripov wrote:
  The sizeof (CRITICAL_SECTION) equal to 24 on _WIN32 and 40 on _WIN64.
But in rw/_mutex.h now used the hardcoded value equal to 24. This is
not causes any problems because we #define _RWSTD_NO_FWD_DECLARATIONS
in rw/_config_msvcrt.h for _WIN64. I have tried to comment the
#define _RWSTD_NO_FWD_DECLARATIONS in rw/_config_msvcrt.h and build
(with applied the patch below) the library, examples and tests and
found no problems. Perhaps somebody remembers why we #define
_RWSTD_NO_FWD_DECLARATIONS
for _WIN64?

The #definition was introduced way back in 2001. Unfortunately,
whoever added it didn't bother to explain why. My guess is that
it was done as a quick hack around the change to volatile in
the Win32 InterlockedXxx() API. I'm all for taking it out and
doing the right thing. I'm not sure that we need a new config
test for it though. Why not simply hardcode the known values
for each of the two versions of Windows directly in the file?

Martin


  ChangeLog:
  * etc/config/src/CRITICAL_SECTION.cpp: New config test to determine
the size of CRITICAL_SECTION structure.
  * include/rw/_config-msvcrt.h [_WIN64]: Remove #define
_RWSTD_NO_FWD_DECLARATIONS
  * include/rw/_mutex.h (__rw_critical_section): Use
_RWSTD_CRITICAL_SECTION_SIZE config macro
  instead of hardcoded value.

------------------------
Index: etc/config/src/CRITICAL_SECTION.cpp
===================================================================
--- etc/config/src/CRITICAL_SECTION.cpp (revision 0)
+++ etc/config/src/CRITICAL_SECTION.cpp (revision 0)
@@ -0,0 +1,34 @@
+// checking for size of CRITICAL_SECTION +
+/**********************************************************************
*****
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  License); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1999-2007 Rogue Wave Software, Inc.
+ * +
************************************************************************
**/
+
+#include <windows.h>
+#include <stdio.h>
+
+int main ()
+{
+    printf ("#define _RWSTD_CRITICAL_SECTION_SIZE    %u\n",
+            unsigned (sizeof (CRITICAL_SECTION)));
+
+    return 0;
+}

Property changes on: etc\config\src\CRITICAL_SECTION.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: include/rw/_config-msvcrt.h
===================================================================
--- include/rw/_config-msvcrt.h (revision 651205)
+++ include/rw/_config-msvcrt.h (working copy)
@@ -93,11 +93,6 @@
 #  define _RWSTD_LONG_LONG __int64
 #endif   // _MSC_VER <= 1300 || _RWSTD_NO_LONG_LONG
-#if defined (_WIN64)
-     // FIXME: handle by forward declaring fuctions in <rw/_mutex.h>
-#  define _RWSTD_NO_FWD_DECLARATIONS
-#endif   // _WIN64
-
 #if defined (WIN32) && !defined(_WIN32)
 #  define _WIN32
 #endif
Index: include/rw/_mutex.h
===================================================================
--- include/rw/_mutex.h (revision 651205)
+++ include/rw/_mutex.h (working copy)
@@ -153,10 +153,16 @@
_RWSTD_NAMESPACE (__rw) { +# ifdef _RWSTD_NO_CRITICAL_SECTION
+       // use 32-bit Windows value by default
+#      define _RWSTD_CRITICAL_SECTION_SIZE 24
+#    endif   // _RWSTD_NO_CRITICAL_SECTION
+
 // fake critical section type
 union __rw_critical_section {
     long _C_pad;   // force alignment
-    char _C_buf [24 /* == sizeof (_RTL_CRITICAL_SECTION) */];
+ // _RWSTD_CRITICAL_SECTION_SIZE == sizeof (_RTL_CRITICAL_SECTION) + char _C_buf [_RWSTD_CRITICAL_SECTION_SIZE];
 };
# define _RWSTD_MUTEX_T _RW::__rw_critical_section
------------------------

Farid.

Reply via email to