incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject [PATCH] Determine the sizeof (CRITICAL_SECTION) at configure step
Date Thu, 24 Apr 2008 16:42:49 GMT
  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?

  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.

Mime
View raw message