gcc-4.7-20111022 fails to build on PA-RISC

Jonathan Wakely jwakely.gcc@gmail.com
Sun Oct 30 20:45:00 GMT 2011


On 30 October 2011 20:04, Jonathan Wakely wrote:
>
>> What I'm trying to say here is, that if the volatile-member-
>> and-copy-initialization-semantics reason would be correct,
>> no-one could portably use
>>
>> pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
>>
>> in block scope or namespace scope without creating ill-formed
>> code. There must be something obvious that I'm failing to see...
>
> Right, it's ill-formed at block scope too so the initializer can't be
> used in C++, which is a problem in the Linuxthreads headers, but we
> need to workaround if we want to make std::mutex work on hppa-linux
> and other platforms using Linuxthreads.

Sorry, I should have checked before posting that, it compiles fine at
block scope.

Here's a more complete example based on the Linuxthreads code.

#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1 } }

#define __LOCK_ALT_INITIALIZER { __LT_SPINLOCK_ALT_INIT, 0 }

enum
{
  PTHREAD_MUTEX_TIMED_NP
};

#define PTHREAD_MUTEX_INITIALIZER \
  {0, 0, 0, PTHREAD_MUTEX_TIMED_NP, __LOCK_ALT_INITIALIZER}

typedef volatile struct {
  int lock[4];
}  __atomic_lock_t;


struct _pthread_fastlock
{
  __atomic_lock_t __spinlock;   /* Used by compare_and_swap emulation.  Also,
                                   adaptive SMP lock stores spin count here. */
  long int __status;            /* "Free" or "taken" or head of waiting list */
};

typedef struct
{
  int __m_reserved;               /* Reserved for future use */
  int __m_count;                  /* Depth of recursive locking */
  void* __m_owner;       /* Owner thread (if recursive or errcheck) */
  int __m_kind;                   /* Mutex kind: fast, recursive or errcheck */
  struct _pthread_fastlock __m_lock; /* Underlying fast lock */
} pthread_mutex_t;


pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;

And this works with that code:

struct mutex {
  pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
  mutex() = default;
};


So now I'm confused :-\

I'll try a bootstrap on gcc61 in the compiler farm.



More information about the Libstdc++ mailing list