The attached change fixes PR target/68739.  As noted in comment #2, the 
standard for libstdc++
requires a constexpr constructor for mutexes.  On hpux, we don't have a 
constexpr constructor because of
of the void * casts in the PTHREAD_MUTEX_INITIALIZER define and the void * 
element in the pthread_mutex
struct.

The attached patch changes the void * element to long in the pthread_mutex 
struct and removes the void *
cast from the initializer.  This keeps the layout the same as before.  As far 
as I can tell, this field is only used
internally so the type change shouldn't affect application code.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.  Committed to trunk.

Dave
--
John David Anglin       dave.ang...@bell.net


2017-02-25  John David Anglin  <dang...@gcc.gnu.org>

        PR target/68739
        * inclhack.def (hpux11_pthread_pointer): New fix.
        (hpux11_pthread_const): Adjust to remove void * cast from define.
        * fixincl.x: Regenerate.

Index: inclhack.def
===================================================================
--- inclhack.def        (revision 245737)
+++ inclhack.def        (working copy)
@@ -2366,16 +2366,34 @@
 };
 
 /*
- *  Fix C99 constant in __POINTER_SET define.
+ *  The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
+ *  in pthread.h need to be constant expressions to be standard complient.
+ *  As a result, we need to remove the void * casts in the initializers
+ *  (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
+ *  to use the long type.
  */
 fix = {
+    hackname  = hpux11_pthread_pointer;
+    mach      = "*-hp-hpux11.[0-3]*";
+    files     = sys/pthread.h;
+    select    = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
+
+    c_fix     = format;
+    c_fix_arg = "long\t%2%3";
+    test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
+};
+
+/*
+ *  Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
+ */
+fix = {
     hackname  = hpux11_pthread_const;
     mach      = "*-hp-hpux11.[0-3]*";
     files     = sys/pthread.h;
-    select    = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
+    select    = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
 
     c_fix     = format;
-    c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
+    c_fix_arg = "%11";
     test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
 };
 
Index: tests/base/sys/pthread.h
===================================================================
--- tests/base/sys/pthread.h    (revision 245737)
+++ tests/base/sys/pthread.h    (working copy)
@@ -14,8 +14,13 @@
 #endif  /* HPUX11_LWP_RWLOCK_VALID_CHECK */
 
 
+#if defined( HPUX11_PTHREAD_POINTER_CHECK )
+#define __MPOINTER             long    m_ptr
+#endif  /* HPUX11_PTHREAD_POINTER_CHECK */
+
+
 #if defined( HPUX11_PTHREAD_CONST_CHECK )
-#define __POINTER_SET          ((void *) 1L)
+#define __POINTER_SET          1
 #endif  /* HPUX11_PTHREAD_CONST_CHECK */
 
 

Reply via email to